2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 // $Header: r:/t2repos/thief2/src/editor/ged_rmap.c,v 1.2 2000/02/19 13:10:47 toml Exp $
7 // support for remapping the brush ids
20 #include <dbmem.h> // must be last header!
22 #define MAX_CALLBACKS 16
24 static ged_remap_callback remap_callbacks
[MAX_CALLBACKS
];
26 BOOL
ged_remap_add_callback(ged_remap_callback cb
)
29 for (i
=0; i
<MAX_CALLBACKS
; i
++)
30 if (remap_callbacks
[i
]==NULL
)
32 remap_callbacks
[i
]=cb
;
38 BOOL
ged_remap_rem_callback(ged_remap_callback cb
)
41 for (i
=0; i
<MAX_CALLBACKS
; i
++)
42 if (remap_callbacks
[i
]==cb
)
44 remap_callbacks
[i
]=NULL
;
50 // @TODO: make this have an installable callback for all systems who care
51 // compress brush id space, build new csg_brush list
52 int ged_remap_brushes(void)
54 int newid
=1, hIter
, i
, max_id
=0;
58 us
=blistIterStart(&hIter
);
61 if (us
->br_id
>max_id
) max_id
=us
->br_id
;
62 us
=blistIterNext(hIter
);
64 AssertMsg(max_id
<MAX_CSG_BRUSHES
,"Too Many Brushes in Level");
65 mapping
=(int *)Malloc(sizeof(int)*MAX_CSG_BRUSHES
);
66 memset(mapping
,0xff,sizeof(int)*MAX_CSG_BRUSHES
);
67 us
=blistIterStart(&hIter
);
70 editBrush
*nxt
=blistIterNext(hIter
);
71 if (us
->br_id
<MAX_CSG_BRUSHES
)
73 mapping
[us
->br_id
]=newid
; // this mapping is
75 if (us
->br_id
>newid
) // if under newid, we have already remapped
76 csg_brush
[us
->br_id
]=NULL
; // so dont step on it
81 Warning(("Punting brush %d\n",us
->br_id
));
82 // should somehow delete it, eh?
86 for (i
=0; i
<MAX_CALLBACKS
; i
++)
87 if (remap_callbacks
[i
]!=NULL
)
88 (*remap_callbacks
[i
])(mapping
);
89 remap_csg_database(mapping
); // this will TRASH mapping
90 // @TODO: wake up the GFH
92 return newid
; // new max