module.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. #ifndef MODULE_INCLUDED
  2. /*
  3. Modules
  4. */
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #if SupportModules
  9. #include "bh_waypt.h"
  10. typedef struct moduletableheader {
  11. int mth_xsize; /* Extents in world space */
  12. int mth_ysize;
  13. int mth_zsize;
  14. int mth_numx; /* Number of modules along each axis */
  15. int mth_numy;
  16. int mth_numz;
  17. /* Pointer to an array of pointers to modules */
  18. struct module **mth_moduletable;
  19. } MODULETABLEHEADER;
  20. /*
  21. NOTES
  22. There are no pointers to strategy and/or animation data structures yet.
  23. These will be added as and when they are needed.
  24. */
  25. typedef enum {
  26. mtype_module,
  27. mtype_term
  28. } MODULETYPE;
  29. typedef union mref {
  30. char mref_name[4]; /* Module name */
  31. struct module *mref_ptr; /* Module pointer */
  32. } MREF;
  33. typedef enum {
  34. vmtype_vmodule,
  35. vmtype_term
  36. } VMODULETYPE;
  37. typedef enum {
  38. vmodi_null, /* Null instruction */
  39. vmodi_bra_vc /* Branch if viewport closed */
  40. } VMODI;
  41. typedef union _vmodidata {
  42. char vmodidata_label[4];
  43. struct vmodule *vmodidata_ptr;
  44. int vmodidata;
  45. } VMODIDATA;
  46. typedef struct vmodule {
  47. VMODULETYPE vmod_type;
  48. char vmod_name[4]; /* Unique name for this VMODULE */
  49. VMODI vmod_instr;
  50. VMODIDATA vmod_data;
  51. MREF vmod_mref;
  52. VECTORCH vmod_dir;
  53. int vmod_angle;
  54. int vmod_flags;
  55. } VMODULE;
  56. #define vm_flag_gotptrs 0x00000001 /* VMODULE references have
  57. been converted from
  58. names to pointers */
  59. #if 0
  60. typedef enum {
  61. vptype_viewport,
  62. vptype_term
  63. } VIEWPORTTYPE;
  64. typedef struct viewport {
  65. VIEWPORTTYPE vp_type;
  66. int vp_flags;
  67. VECTORCH vp0;
  68. VECTORCH vp1;
  69. VECTORCH vp2;
  70. VECTORCH vp3;
  71. } VIEWPORT;
  72. #endif
  73. /*
  74. This is the map block for module objects. It was originally based on the
  75. MAPBLOCK8 structure.
  76. */
  77. typedef struct modulemapblock {
  78. int MapType;
  79. int MapShape;
  80. #if LoadingMapsShapesAndTexturesEtc
  81. int MapFNameIndex;
  82. char **MapFNameArray;
  83. SHAPEHEADER **MapShapeDataArray;
  84. #endif
  85. VECTORCH MapWorld;
  86. EULER MapEuler;
  87. int MapFlags;
  88. int MapFlags2;
  89. int MapFlags3;
  90. MAPSETVDB *MapVDBData;
  91. int MapInteriorType;
  92. #if InterfaceEngine
  93. /* This will point to the Object_Chunk, it will have to be */
  94. /* cast within C++ though */
  95. void * o_chunk;
  96. #endif
  97. int MapLightType; /* See LIGHTTYPES */
  98. VECTORCH MapOrigin; /* Origin of Rotation */
  99. SIMSHAPELIST *MapSimShapes;
  100. int MapViewType; /* See "VDB_ViewType" */
  101. struct displayblock **MapMPtr; /* Write our dptr here as mother */
  102. struct displayblock **MapDPtr; /* Read our dptr here as daughter */
  103. VECTORCH MapMOffset; /* Offset from mother */
  104. #if SupportMorphing
  105. MORPHHEADER *MapMorphHeader;
  106. #endif
  107. } MODULEMAPBLOCK;
  108. /*
  109. Module functions called either when the module is visible or when the view
  110. is inside the module.
  111. */
  112. typedef enum {
  113. mfun_null,
  114. } MFUNCTION;
  115. /*
  116. This is the MODULE structure
  117. */
  118. struct aimodule;
  119. typedef struct module {
  120. MODULETYPE m_type;
  121. char m_name[4]; /* Unique name for this MODULE */
  122. int m_index; /* Unique module index */
  123. int m_flags;
  124. VECTORCH m_world; /* World location */
  125. MREF m_ext; /* Get module extents from the shape
  126. found through this other module */
  127. int m_ext_scale; /* Scale extents by this value (fp) */
  128. int m_maxx; /* Module extents */
  129. int m_minx;
  130. int m_maxy;
  131. int m_miny;
  132. int m_maxz;
  133. int m_minz;
  134. MODULEMAPBLOCK *m_mapptr; /* Map data for the module object */
  135. struct displayblock *m_dptr; /* Display block (not constant) */
  136. MREF m_vptr; /* Vertical pointer to module array */
  137. VMODULE *m_vmptr; /* Pointer to an array of VMODULE, or
  138. "visible module" structures */
  139. MREF *m_link_ptrs; /* Pointer to an arbitrary sized array
  140. of module references - the array is
  141. zero terminated */
  142. /*should be got rid of soon*/
  143. MODULETABLEHEADER *m_table; /* A hash table whose creation is
  144. triggered by a threshold value set by
  145. "system.h". This is to speed up module
  146. list traversal */
  147. MFUNCTION m_ifvisible; /* Function called if module visible */
  148. MFUNCTION m_ifvinside; /* Function called if view inside */
  149. MREF m_funref; /* Function access to another module */
  150. struct strategyblock *m_sbptr; /* Project supplies structure */
  151. int m_numlights; /* # light blocks in array */
  152. struct lightblock *m_lightarray; /* Ptr. to array of light blocks */
  153. struct extraitemdata *m_extraitemdata;
  154. MATRIXCH m_mat; /* Internal use only */
  155. #if SupportWindows95
  156. char * name;
  157. #endif
  158. WAYPOINT_HEADER *m_waypoints;
  159. struct aimodule *m_aimodule; /* the aimodule that this module is a part of*/
  160. float m_sound_reverb; /*settings for the way sound should */
  161. int m_sound_env_index;/*be played in this module*/
  162. } MODULE;
  163. /* Flags */
  164. #define m_flag_infinite 0x00000001 /* No extent test, the
  165. view is always in this
  166. module */
  167. #define m_flag_gotptrs 0x00000002 /* Module references have
  168. been converted from
  169. names to pointers */
  170. #define m_flag_open 0x00000004 /* The viewport/Door is
  171. open. This state is
  172. read from the "dptr"
  173. morphing frame if it is
  174. present and if it is
  175. appropriate to do so */
  176. #define m_flag_dormant 0x00000008 /* The module is not active */
  177. #define m_flag_gotmat 0x00000010 /* Internal use only */
  178. #define m_flag_visible_on_map 0x00000020 /* Flag for Kevin's map stuff */
  179. #define m_flag_slipped_inside 0x00000040 /* Another flag 4 Kevin */
  180. #define MODULEFLAG_AIRDUCT 0x80000000
  181. #define MODULEFLAG_STAIRS 0x40000000
  182. #define MODULEFLAG_SKY 0x20000000
  183. #define MODULEFLAG_FOG 0x10000000
  184. #define MODULEFLAG_HORIZONTALDOOR 0x08000000
  185. typedef struct aimodule
  186. {
  187. int m_index; //the index in AIModuleArray
  188. VECTORCH m_world; /* World location */
  189. //adjacent aimodules - null terminated array
  190. struct aimodule **m_link_ptrs;
  191. //the render modules that make up this ai module - null terminated array
  192. MODULE **m_module_ptrs;
  193. WAYPOINT_HEADER *m_waypoints;
  194. /* CDF 1/6/98 - Routefinder Globals */
  195. int RouteFinder_FrameStamp;
  196. int RouteFinder_IterationNumber;
  197. }AIMODULE;
  198. /*
  199. Module Scene Structure
  200. */
  201. typedef struct scenemodule {
  202. MODULE *sm_module; /* Pointer to module structure for this scene */
  203. MODULE **sm_marray; /* Pointer to array of pointers to all modules */
  204. } SCENEMODULE;
  205. /*
  206. "The View"
  207. The "View Finder" accesses the view location and orientation through this
  208. global structure. This is so that views can be passed to other functions as
  209. a single pointer if required.
  210. */
  211. typedef struct aview {
  212. VECTORCH vloc;
  213. MATRIXCH vmat;
  214. struct viewdescriptorblock *vvdb;
  215. } AVIEW;
  216. /*
  217. Module Function Prototypes
  218. */
  219. #if IncludeModuleFunctionPrototypes
  220. void ModuleHandler(VIEWDESCRIPTORBLOCK *vdb);
  221. void ProcessModules(VIEWDESCRIPTORBLOCK *vdb, MODULE *mptr);
  222. void ViewFinder(MODULE *mptr);
  223. void ReadVMODULEArrays(VMODULE *vptr);
  224. void UpdateModules(void);
  225. void ModuleFunctions(MODULE *mptr, MFUNCTION mf);
  226. void AllocateModuleObject(MODULE *mptr);
  227. void DeallocateModuleObject(MODULE *mptr);
  228. /*
  229. A project supplied function. The display block has been successfuly
  230. allocated and has been fully initialised.
  231. */
  232. void ModuleObjectJustAllocated(MODULE *mptr);
  233. /*
  234. A project supplied function. The display block is about to be deallocated.
  235. */
  236. void ModuleObjectAboutToBeDeallocated(MODULE *mptr);
  237. /*
  238. A project supplied function. These are the new and old modules this ????
  239. */
  240. void NewAndOldModules(int num_new, MODULE **m_new,
  241. int num_old, MODULE **m_old, char *m_currvis);
  242. #if SupportMultiCamModules
  243. void InitGlobalVMA(void);
  244. void DeallocateGlobalVMA(void);
  245. #if SupportMultiCamModules
  246. void UpdateDynamicModuleObjects(void);
  247. #endif
  248. #endif
  249. void PreprocessAllModules(void);
  250. void PreprocessModuleArray(MODULE **m_array_ptr);
  251. void PreprocessVMODIDATA(VMODULE *v_ptr);
  252. void DeallocateModuleVisArrays(void);
  253. int GetModuleVisArrays(void);
  254. int InsideModule(MODULE *mptr);
  255. void ConvertModuleNameToPointer(MREF *mref_ptr, MODULE **m_array_ptr);
  256. void ConvertVModuleNameToPointer(VMODIDATA *vmodidata_ptr, VMODULE *v_array_ptr);
  257. int CompareName(char *name1, char *name2);
  258. void PrintName(char *name);
  259. int SaveModuleArray(MODULE *mptr, char *filename);
  260. MODULE* LoadModuleArray(MODULE *mptr, int size, char *filename);
  261. int IsModuleVisibleFromModule(MODULE *source, MODULE *target);
  262. #endif /* IncludeModuleFunctionPrototypes */
  263. extern SCENEMODULE **Global_ModulePtr;
  264. extern SCENEMODULE *MainSceneArray[];
  265. extern AVIEW ModuleView;
  266. extern MODULE *Global_MotherModule;
  267. extern char *ModuleCurrVisArray;
  268. extern char *ModulePrevVisArray;
  269. extern char *ModuleTempArray;
  270. extern char *ModuleLocalVisArray;
  271. extern int ModuleArraySize;
  272. extern int AIModuleArraySize;
  273. extern AIMODULE *AIModuleArray;
  274. #endif /* SupportModules */
  275. #ifdef __cplusplus
  276. };
  277. #endif
  278. #define MODULE_INCLUDED
  279. #endif