1 #ifndef MODULE_INCLUDED 2 3 4 /* 5 6 Modules 7 8 */ 9 10 11 #ifdef __cplusplus 12 13 extern "C" { 14 15 #endif 16 17 18 #if SupportModules 19 20 21 #include "bh_waypt.h" 22 23 typedef struct moduletableheader { 24 25 int mth_xsize; /* Extents in world space */ 26 int mth_ysize; 27 int mth_zsize; 28 29 int mth_numx; /* Number of modules along each axis */ 30 int mth_numy; 31 int mth_numz; 32 33 /* Pointer to an array of pointers to modules */ 34 35 struct module **mth_moduletable; 36 37 } MODULETABLEHEADER; 38 39 40 /* 41 42 NOTES 43 44 There are no pointers to strategy and/or animation data structures yet. 45 These will be added as and when they are needed. 46 47 */ 48 49 typedef enum { 50 51 mtype_module, 52 mtype_term 53 54 } MODULETYPE; 55 56 57 typedef union mref { 58 59 char mref_name[4]; /* Module name */ 60 struct module *mref_ptr; /* Module pointer */ 61 62 } MREF; 63 64 65 typedef enum { 66 67 vmtype_vmodule, 68 vmtype_term 69 70 } VMODULETYPE; 71 72 73 typedef enum { 74 75 vmodi_null, /* Null instruction */ 76 vmodi_bra_vc /* Branch if viewport closed */ 77 78 } VMODI; 79 80 typedef union _vmodidata { 81 82 char vmodidata_label[4]; 83 struct vmodule *vmodidata_ptr; 84 int vmodidata; 85 86 } VMODIDATA; 87 88 89 typedef struct vmodule { 90 91 VMODULETYPE vmod_type; 92 char vmod_name[4]; /* Unique name for this VMODULE */ 93 VMODI vmod_instr; 94 VMODIDATA vmod_data; 95 MREF vmod_mref; 96 VECTORCH vmod_dir; 97 int vmod_angle; 98 int vmod_flags; 99 100 } VMODULE; 101 102 103 #define vm_flag_gotptrs 0x00000001 /* VMODULE references have 104 been converted from 105 names to pointers */ 106 107 108 #if 0 109 110 typedef enum { 111 112 vptype_viewport, 113 vptype_term 114 115 } VIEWPORTTYPE; 116 117 118 typedef struct viewport { 119 120 VIEWPORTTYPE vp_type; 121 122 int vp_flags; 123 124 VECTORCH vp0; 125 VECTORCH vp1; 126 VECTORCH vp2; 127 VECTORCH vp3; 128 129 } VIEWPORT; 130 131 #endif 132 133 134 /* 135 136 This is the map block for module objects. It was originally based on the 137 MAPBLOCK8 structure. 138 139 */ 140 141 typedef struct modulemapblock { 142 143 int MapType; 144 int MapShape; 145 146 #if LoadingMapsShapesAndTexturesEtc 147 148 int MapFNameIndex; 149 char **MapFNameArray; 150 SHAPEHEADER **MapShapeDataArray; 151 152 #endif 153 154 VECTORCH MapWorld; 155 156 EULER MapEuler; 157 158 int MapFlags; 159 int MapFlags2; 160 int MapFlags3; 161 162 163 164 MAPSETVDB *MapVDBData; 165 166 int MapInteriorType; 167 168 int MapLightType; /* See LIGHTTYPES */ 169 170 171 VECTORCH MapOrigin; /* Origin of Rotation */ 172 173 SIMSHAPELIST *MapSimShapes; 174 175 int MapViewType; /* See "VDB_ViewType" */ 176 177 178 struct displayblock **MapMPtr; /* Write our dptr here as mother */ 179 struct displayblock **MapDPtr; /* Read our dptr here as daughter */ 180 181 VECTORCH MapMOffset; /* Offset from mother */ 182 183 #if SupportMorphing 184 MORPHHEADER *MapMorphHeader; 185 #endif 186 187 } MODULEMAPBLOCK; 188 189 190 /* 191 192 Module functions called either when the module is visible or when the view 193 is inside the module. 194 195 */ 196 197 typedef enum { 198 199 mfun_null, 200 201 } MFUNCTION; 202 203 204 /* 205 206 This is the MODULE structure 207 208 */ 209 210 struct aimodule; 211 212 typedef struct module { 213 214 MODULETYPE m_type; 215 216 char m_name[4]; /* Unique name for this MODULE */ 217 218 int m_index; /* Unique module index */ 219 220 int m_flags; 221 222 VECTORCH m_world; /* World location */ 223 224 MREF m_ext; /* Get module extents from the shape 225 found through this other module */ 226 227 int m_ext_scale; /* Scale extents by this value (fp) */ 228 229 int m_maxx; /* Module extents */ 230 int m_minx; 231 int m_maxy; 232 int m_miny; 233 int m_maxz; 234 int m_minz; 235 236 MODULEMAPBLOCK *m_mapptr; /* Map data for the module object */ 237 struct displayblock *m_dptr; /* Display block (not constant) */ 238 239 MREF m_vptr; /* Vertical pointer to module array */ 240 241 VMODULE *m_vmptr; /* Pointer to an array of VMODULE, or 242 "visible module" structures */ 243 244 MREF *m_link_ptrs; /* Pointer to an arbitrary sized array 245 of module references - the array is 246 zero terminated */ 247 /*should be got rid of soon*/ 248 249 250 251 MODULETABLEHEADER *m_table; /* A hash table whose creation is 252 triggered by a threshold value set by 253 "system.h". This is to speed up module 254 list traversal */ 255 256 MFUNCTION m_ifvisible; /* Function called if module visible */ 257 MFUNCTION m_ifvinside; /* Function called if view inside */ 258 MREF m_funref; /* Function access to another module */ 259 260 struct strategyblock *m_sbptr; /* Project supplies structure */ 261 262 int m_numlights; /* # light blocks in array */ 263 struct lightblock *m_lightarray; /* Ptr. to array of light blocks */ 264 265 struct extraitemdata *m_extraitemdata; 266 267 MATRIXCH m_mat; /* Internal use only */ 268 269 char * name; 270 271 WAYPOINT_HEADER *m_waypoints; 272 273 struct aimodule *m_aimodule; /* the aimodule that this module is a part of*/ 274 275 float m_sound_reverb; /*settings for the way sound should */ 276 int m_sound_env_index;/*be played in this module*/ 277 278 } MODULE; 279 280 281 /* Flags */ 282 283 #define m_flag_infinite 0x00000001 /* No extent test, the 284 view is always in this 285 module */ 286 287 #define m_flag_gotptrs 0x00000002 /* Module references have 288 been converted from 289 names to pointers */ 290 291 #define m_flag_open 0x00000004 /* The viewport/Door is 292 open. This state is 293 read from the "dptr" 294 morphing frame if it is 295 present and if it is 296 appropriate to do so */ 297 298 #define m_flag_dormant 0x00000008 /* The module is not active */ 299 300 301 #define m_flag_gotmat 0x00000010 /* Internal use only */ 302 303 #define m_flag_visible_on_map 0x00000020 /* Flag for Kevin's map stuff */ 304 305 #define m_flag_slipped_inside 0x00000040 /* Another flag 4 Kevin */ 306 307 #define MODULEFLAG_AIRDUCT 0x80000000 308 #define MODULEFLAG_STAIRS 0x40000000 309 #define MODULEFLAG_SKY 0x20000000 310 #define MODULEFLAG_FOG 0x10000000 311 #define MODULEFLAG_HORIZONTALDOOR 0x08000000 312 313 314 typedef struct aimodule 315 { 316 int m_index; //the index in AIModuleArray 317 318 VECTORCH m_world; /* World location */ 319 320 //adjacent aimodules - null terminated array 321 struct aimodule **m_link_ptrs; 322 323 //the render modules that make up this ai module - null terminated array 324 MODULE **m_module_ptrs; 325 326 WAYPOINT_HEADER *m_waypoints; 327 328 /* CDF 1/6/98 - Routefinder Globals */ 329 int RouteFinder_FrameStamp; 330 int RouteFinder_IterationNumber; 331 332 }AIMODULE; 333 334 335 /* 336 Module Scene Structure 337 338 */ 339 340 typedef struct scenemodule { 341 342 MODULE *sm_module; /* Pointer to module structure for this scene */ 343 MODULE **sm_marray; /* Pointer to array of pointers to all modules */ 344 345 } SCENEMODULE; 346 347 348 /* 349 350 "The View" 351 352 The "View Finder" accesses the view location and orientation through this 353 global structure. This is so that views can be passed to other functions as 354 a single pointer if required. 355 356 */ 357 358 typedef struct aview { 359 360 VECTORCH vloc; 361 MATRIXCH vmat; 362 struct viewdescriptorblock *vvdb; 363 364 } AVIEW; 365 366 367 368 369 /* 370 371 Module Function Prototypes 372 373 */ 374 375 #if IncludeModuleFunctionPrototypes 376 377 void ModuleHandler(VIEWDESCRIPTORBLOCK *vdb); 378 void ProcessModules(VIEWDESCRIPTORBLOCK *vdb, MODULE *mptr); 379 void ViewFinder(MODULE *mptr); 380 void ReadVMODULEArrays(VMODULE *vptr); 381 382 383 void UpdateModules(void); 384 void ModuleFunctions(MODULE *mptr, MFUNCTION mf); 385 void AllocateModuleObject(MODULE *mptr); 386 void DeallocateModuleObject(MODULE *mptr); 387 void AllNewModuleHandler(void); 388 389 390 /* 391 392 A project supplied function. The display block has been successfuly 393 allocated and has been fully initialised. 394 395 */ 396 397 void ModuleObjectJustAllocated(MODULE *mptr); 398 399 400 /* 401 402 A project supplied function. The display block is about to be deallocated. 403 404 */ 405 406 void ModuleObjectAboutToBeDeallocated(MODULE *mptr); 407 408 409 /* 410 411 A project supplied function. These are the new and old modules this ???? 412 413 */ 414 415 void NewAndOldModules(int num_new, MODULE **m_new, 416 int num_old, MODULE **m_old, char *m_currvis); 417 418 419 420 #if SupportMultiCamModules 421 void InitGlobalVMA(void); 422 void DeallocateGlobalVMA(void); 423 #if SupportMultiCamModules 424 void UpdateDynamicModuleObjects(void); 425 #endif 426 #endif 427 428 void PreprocessAllModules(void); 429 void PreprocessModuleArray(MODULE **m_array_ptr); 430 void PreprocessVMODIDATA(VMODULE *v_ptr); 431 432 void DeallocateModuleVisArrays(void); 433 int GetModuleVisArrays(void); 434 int InsideModule(MODULE *mptr); 435 436 void ConvertModuleNameToPointer(MREF *mref_ptr, MODULE **m_array_ptr); 437 void ConvertVModuleNameToPointer(VMODIDATA *vmodidata_ptr, VMODULE *v_array_ptr); 438 439 int CompareName(char *name1, char *name2); 440 void PrintName(char *name); 441 442 int SaveModuleArray(MODULE *mptr, char *filename); 443 MODULE* LoadModuleArray(MODULE *mptr, int size, char *filename); 444 445 int IsModuleVisibleFromModule(MODULE *source, MODULE *target); 446 int ThisObjectIsInAModuleVisibleFromCurrentlyVisibleModules(struct strategyblock *sbPtr); 447 448 #endif /* IncludeModuleFunctionPrototypes */ 449 450 extern SCENEMODULE **Global_ModulePtr; 451 extern SCENEMODULE *MainSceneArray[]; 452 extern AVIEW ModuleView; 453 extern MODULE *Global_MotherModule; 454 extern char *ModuleCurrVisArray; 455 extern char *ModulePrevVisArray; 456 extern char *ModuleTempArray; 457 extern char *ModuleLocalVisArray; 458 extern int ModuleArraySize; 459 460 extern int AIModuleArraySize; 461 extern AIMODULE *AIModuleArray; 462 463 464 #endif /* SupportModules */ 465 466 467 #ifdef __cplusplus 468 469 }; 470 471 #endif 472 473 #define MODULE_INCLUDED 474 475 #endif 476