2 // this is a combination of some C++ and preprocessor magic which allows a
3 // group of initilization functions to be declared across many different
4 // source files and then at the appropriate time all can be called at once.
5 // The "trick" is that it automatically works for all modules linked to the
6 // program so you don't have to keep a handmade list anywhere of the names
7 // of the initilization functions. This is used by the AI functions to initilize
8 // all the function pointers etc for the various creatures.
10 #include "InitList.fdh"
12 void InitList::AddFunction(void (*func
)(void))
14 AddFunction((void *)func
);
17 void InitList::AddFunction(bool (*func
)(void))
19 AddFunction((void *)func
);
22 void InitList::AddFunction(void *func
)
24 //stat("AddFunction (void)%08x [%d]", func, fCount);
25 if (fCount
>= MAX_INIT_RECORDS
)
28 fFunctions
[fCount
++] = (void *)func
;
32 void c------------------------------() {}
35 bool InitList::CallFunctions()
39 if (fCount
>= MAX_INIT_RECORDS
)
41 stat("InitList::CallFunctions(%08x): too many initializers", this);
45 stat("InitList::CallFunctions(%08x): executing %d functions...", this, fCount
);
49 void (*func
)(void) = (void (*)())fFunctions
[i
];