1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132 |
- #include "3dc.h"
- #include "inline.h"
- #include "module.h"
- #include "stratdef.h"
- #include "bh_types.h"
- #include "pvisible.h"
- #include "pfarlocs.h"
- #include "avpview.h"
- #include "ourasert.h"
- #include "pldghost.h"
- #if SupportModules
- /* imported externs */
- extern SCENE Global_Scene;
- extern int NumActiveBlocks;
- extern DISPLAYBLOCK *ActiveBlockList[];
- extern DISPLAYBLOCK *dptr_last;
- extern unsigned char KeyASCII;
- /**** Protos ****/
- void FindVisibleModules(VMODULE *vptr,int flag);
- /**** Statics ****/
- static MODULE **Global_ModuleArrayPtr;
- void AllNewModuleHandler(void)
- {
- {
- int i;
- SCENEMODULE *smptr;
- smptr = Global_ModulePtr[Global_Scene];
- Global_ModuleArrayPtr = smptr->sm_marray;
-
- for(i = 0; i < ModuleArraySize; i++)
- {
- ModuleCurrVisArray[i] = 0;
- }
- }
-
- /* handle dynamic module objects */
- {
- int numberOfObjects = NumActiveBlocks;
-
- while (numberOfObjects--)
- {
- DISPLAYBLOCK* objectPtr = ActiveBlockList[numberOfObjects];
-
- if(objectPtr->ObFlags3 & ObFlag3_DynamicModuleObject)
- {
- STRATEGYBLOCK *sbPtr = objectPtr->ObStrategyBlock;
- sbPtr->containingModule = (ModuleFromPosition(&(objectPtr->ObWorld), sbPtr->containingModule));
- if (sbPtr->containingModule)
- if (ModuleIsPhysical(sbPtr->containingModule))
- {
- ModuleCurrVisArray[sbPtr->containingModule->m_index] = 1;
- if(sbPtr->containingModule->m_vmptr) FindVisibleModules(sbPtr->containingModule->m_vmptr,1);
- }
- }
- }
- }
-
- /*If this is an network game , and this machine is the ai server , then need to check if
- there are any aliens near to other players*/
- if(AvP.Network!=I_No_Network && AvP.NetworkAIServer)
- {
- /* go through the strategy blocks looking for players*/
- int sbIndex;
- for(sbIndex=0;sbIndex<NumActiveStBlocks;sbIndex++)
- {
- STRATEGYBLOCK *playerSbPtr = ActiveStBlockList[sbIndex];
- NETGHOSTDATABLOCK *ghostData;
- if(playerSbPtr->I_SBtype!=I_BehaviourNetGhost) continue;
- ghostData = (NETGHOSTDATABLOCK *)playerSbPtr->SBdataptr;
- if(ghostData->type==I_BehaviourAlienPlayer ||
- ghostData->type==I_BehaviourMarinePlayer ||
- ghostData->type==I_BehaviourPredatorPlayer)
- {
- int sbIndex2;
- //found one of the players
- if(!playerSbPtr->containingModule) continue;
- /*now search through the strategy blocks , to see if any aliens are
- visible from the player's location*/
- for(sbIndex2=0;sbIndex2<NumActiveStBlocks;sbIndex2++)
- {
- STRATEGYBLOCK *alienSbPtr = ActiveStBlockList[sbIndex2];
- /*Is it an alien?*/
- if(alienSbPtr->I_SBtype!=I_BehaviourAlien) continue;
- if(!alienSbPtr->containingModule) continue;
- if(IsModuleVisibleFromModule(playerSbPtr->containingModule,alienSbPtr->containingModule))
- {
- /*The player can see the alien , so link in all modules that the
- player can see*/
- if (ModuleIsPhysical(playerSbPtr->containingModule))
- {
- ModuleCurrVisArray[playerSbPtr->containingModule->m_index] = 1;
- if(playerSbPtr->containingModule->m_vmptr) FindVisibleModules(playerSbPtr->containingModule->m_vmptr,1);
- }
- /*Since all modules visible by this player have now been linked , don't need
- to check for any more aliens for this player*/
- break;
- }
- }
- }
- }
- }
-
- /* handle player visibilities */
- {
- extern MODULE * playerPherModule;
- playerPherModule = (ModuleFromPosition(&(Global_VDB_Ptr->VDB_World), playerPherModule));
-
- if(!playerPherModule)
- {
- playerPherModule = (ModuleFromPosition(&(Player->ObWorld), playerPherModule));
- }
- if (playerPherModule)
- {
- ModuleCurrVisArray[playerPherModule->m_index] = 2;
- if(playerPherModule->m_vmptr) FindVisibleModules(playerPherModule->m_vmptr,2);
- }
- }
- /* handle AIMODULE visibility stuff */
- {
- int i;
- for(i = 0; i < ModuleArraySize; i++)
- {
- if (ModuleCurrVisArray[i] == 2)
- {
- AIMODULE *aiModulePtr = Global_ModuleArrayPtr[i]->m_aimodule;
- if (aiModulePtr)
- {
- MODULE **modulelistPtr = aiModulePtr->m_module_ptrs;
- while(*modulelistPtr)
- {
- int index = (*modulelistPtr)->m_index;
- if (!ModuleCurrVisArray[index]) ModuleCurrVisArray[index]=1;
- modulelistPtr++;
- }
- }
- }
- }
- }
- /* update active block list */
- {
- int i;
-
- for(i = 0; i < ModuleArraySize; i++)
- {
- MODULE *mptr = Global_ModuleArrayPtr[i];
- if(ModuleCurrVisArray[i])
- {
- if(mptr->m_dptr == 0 && ((mptr->m_flags & m_flag_dormant) == 0))
- {
- AllocateModuleObject(mptr);
- }
- }
- else
- {
- if(mptr->m_dptr) DeallocateModuleObject(mptr);
- }
- }
- }
- /* call Patrick's code */
- DoObjectVisibilities();
- }
- void FindVisibleModules(VMODULE *vptr,int flag)
- {
- while(vptr->vmod_type != vmtype_term)
- {
- MODULE *mptr;
- /* Add this module to the visible array */
- if(vptr->vmod_mref.mref_ptr)
- {
- mptr = vptr->vmod_mref.mref_ptr;
- ModuleCurrVisArray[mptr->m_index] = flag;
- }
- /* VMODULE instructions */
- switch(vptr->vmod_instr)
- {
- case vmodi_null:
- vptr++;
- break;
- case vmodi_bra_vc:
- /* If the door/viewport is closed... */
- /* Branch to this vptr */
- /* else vptr++; */
- if(mptr)
- {
- if(mptr->m_flags & m_flag_open) vptr++;
- else vptr = vptr->vmod_data.vmodidata_ptr;
- }
- break;
- }
- }
- }
- int ThisObjectIsInAModuleVisibleFromCurrentlyVisibleModules(STRATEGYBLOCK *sbPtr)
- {
- VMODULE *vPtr;
-
- GLOBALASSERT(sbPtr);
- GLOBALASSERT(sbPtr->containingModule);
- vPtr = sbPtr->containingModule->m_vmptr;
- GLOBALASSERT(vPtr);
-
- if(ModuleCurrVisArray[sbPtr->containingModule->m_index] == 2)
- {
- return 1;
- }
-
- while(vPtr->vmod_type != vmtype_term)
- {
- MODULE *mptr;
- /* consider this module */
- if(vPtr->vmod_mref.mref_ptr)
- {
- mptr = vPtr->vmod_mref.mref_ptr;
- if(ModuleCurrVisArray[mptr->m_index] == 2)
- {
- if(vPtr->vmod_instr==vmodi_bra_vc)
- {
- if(mptr->m_flags & m_flag_open) return 1;
- }
- else
- {
- return 1;
- }
- }
- }
- /* VMODULE instructions */
- switch(vPtr->vmod_instr)
- {
- case vmodi_null:
- vPtr++;
- break;
- case vmodi_bra_vc:
- /* If the door/viewport is closed... */
- /* Branch to this vPtr */
- /* else vPtr++; */
- if(mptr)
- {
- if(mptr->m_flags & m_flag_open) vPtr++;
- else vPtr = vPtr->vmod_data.vmodidata_ptr;
- }
- break;
- }
- }
- return 0;
- }
- void ModuleFunctions(MODULE *mptr, MFUNCTION mf)
- {
- switch(mf)
- {
- case mfun_null:
- break;
- }
- }
- void AllocateModuleObject(MODULE *mptr)
- {
- DISPLAYBLOCK *dptr;
- MODULEMAPBLOCK *mapblockptr;
- STRATEGYBLOCK *sb = 0;
- #if SupportMorphing
- MORPHCTRL *mc;
- #endif
- dptr_last = 0;
- mptr->m_dptr = 0;
- if(mptr == 0) return; /* Whoops! */
- if(mptr->m_mapptr == 0) return; /* Not all modules have maps */
- dptr = CreateActiveObject();
- if(dptr) {
- /* Tell the module we exist */
- mptr->m_dptr = dptr;
- /* Tell the object who its module is */
- dptr->ObMyModule = mptr;
- /* Get the strategy block, if it exists */
- if(mptr->m_sbptr) sb = mptr->m_sbptr;
- /* If there is a STRATEGYBLOCK, tell it we exist */
- if(sb) {
- dptr->ObStrategyBlock = sb;
- sb->SBdptr = dptr;
- }
- /* Read the map */
- mapblockptr = mptr->m_mapptr;
- dptr->ObShape = mapblockptr->MapShape;
- CopyLocation(&mapblockptr->MapWorld, &dptr->ObWorld);
- CopyEuler(&mapblockptr->MapEuler, &dptr->ObEuler);
- dptr->ObFlags = mapblockptr->MapFlags;
- dptr->ObFlags2 = mapblockptr->MapFlags2;
- dptr->ObFlags3 = mapblockptr->MapFlags3;
- #if SupportMorphing
- /* If there is a strategy block, see if it has a MORPHCTRL structure */
- if(sb) {
- if(sb->SBmorphctrl) {
- /* Pass MORPHCTRL to dptr */
- dptr->ObMorphCtrl = sb->SBmorphctrl;
- /* Copy the morph pointer from the map to the dptr */
- mc = dptr->ObMorphCtrl;
- mc->ObMorphHeader = mapblockptr->MapMorphHeader;
- /* OLD TEST - These values are now set elsewhere */
- #if 0
- if(mc->ObMorphHeader) {
- mc->ObMorphCurrFrame = 0;
- mc->ObMorphFlags = mph_flag_play/* | mph_flag_noloop | mph_flag_reverse*/;
- mc->ObMorphSpeed = ONE_FIXED;
- }
- #endif
- }
- }
- #endif /* Support Morphing */
- #if InterfaceEngine
- dbptr->o_chunk = mapblockptr->o_chunk;
- #endif
- dptr->ObLightType = LightType_PerVertex;
- dptr->ObFlags |= ObFlag_MultLSrc;
- if(mapblockptr->MapVDBData)
- MapSetVDB(dptr, mapblockptr->MapVDBData);
- dptr->ObLightType = mapblockptr->MapLightType;
- MapBlockInit(dptr);
- /* KJL 14:15:34 04/19/97 - their used to be lots of maths here
- to calculate orientation, but in AvP all modules are aligned to
- the world space axes... */
- {
- extern MATRIXCH IdentityMatrix;
- dptr->ObMat = IdentityMatrix;
- }
-
- /*
- Module lights
- There is an option for a pointer to an array of lights in a module
- structure. These lights are transferred to the display block and
- flagged as "LFlag_WasNotAllocated" so that "DeallocateLightBlock()"
- knows to ignore them.
- The number of lights in the array is "m_numlights" and the pointer
- is called "m_lightarray".
- The addition of non-allocated does not need to be a module specific
- option.
- Non-allocated lights can co-exist peacefully with the other lights.
- */
- if(mptr->m_numlights && mptr->m_lightarray) {
- LIGHTBLOCK *lptr_array = mptr->m_lightarray;
- int i;
- for(i = mptr->m_numlights; i!=0; i--) {
- /* Make sure the light is flagged correctly */
- lptr_array->LightFlags |= LFlag_WasNotAllocated;
- /* Add the light */
- AddLightBlock(dptr, lptr_array);
- /* Next light from the array */
- lptr_array++;
- }
- }
- /*
- As with shared points, extra item data for prelighting is also
- copied from the module to the display block.
- WARNING:
- Allocation and deallocation of this pointer is the responsibility
- of the user!
- */
- dptr->ObEIDPtr = mptr->m_extraitemdata;
- /* Added Name to DISPLAYBLOCK */
- #if SupportWindows95
- dptr->name = mptr->name;
- #endif
- MapPostProcessing(dptr);
- ModuleObjectJustAllocated(mptr); /* Project Function */
- /* Bug Fix */
- if (dptr->ObStrategyBlock) {
- STRATEGYBLOCK *sbptr=dptr->ObStrategyBlock;
- if (sbptr->I_SBtype==I_BehaviourSimpleAnimation) {
- SIMPLE_ANIM_BEHAV_BLOCK *sanimbhv;
- sanimbhv = (SIMPLE_ANIM_BEHAV_BLOCK*)(sbptr->SBdataptr);
- GLOBALASSERT(sanimbhv->bhvr_type == I_BehaviourSimpleAnimation);
- GLOBALASSERT (dptr == sbptr->SBdptr);
- if(!dptr->ObTxAnimCtrlBlks) {
- dptr->ObTxAnimCtrlBlks = sanimbhv->tacbSimple;
- }
- }
- }
- }
- dptr_last = dptr;
- }
- void DeallocateModuleObject(MODULE *mptr)
- {
- DISPLAYBLOCK *dptr;
- STRATEGYBLOCK *sb;
- if(mptr->m_dptr) {
- ModuleObjectAboutToBeDeallocated(mptr); /* Project Function */
- dptr = mptr->m_dptr;
- DestroyActiveObject(dptr);
- /* Clear module reference to dptr */
- mptr->m_dptr = 0;
- /* If there is a STRATEGYBLOCK, clear that reference too */
- if(mptr->m_sbptr) {
- sb = mptr->m_sbptr;
- sb->SBdptr = 0;
- }
- }
- }
- /*
- The Module Preprocessor
- Pass the array of pointers to modules.
- This function creates module indices and converts names into pointers.
- */
- /*
- temp patch to match current chunk
- loader configuration
- */
- void PreprocessAllModules(void)
- {
- SCENEMODULE **sm_array_ptr;
- SCENEMODULE *sm_ptr;
- if(Global_ModulePtr == 0) return;
- sm_array_ptr = Global_ModulePtr;
- while(*sm_array_ptr)
- {
- sm_ptr = *sm_array_ptr;
- PreprocessModuleArray(sm_ptr->sm_marray);
- sm_array_ptr++;
- }
- }
- /*
- A special function to deallocate the module visibility arrays
- */
- void DeallocateModuleVisArrays(void)
- {
- if(ModuleCurrVisArray) {
- DeallocateMem(ModuleCurrVisArray);
- ModuleCurrVisArray = 0;
- }
- }
- /*
- Allocate the two arrays used to keep track of module visibility from
- frame to frame. The function uses the global scene variable to access the
- appropriate SCENEMODULE and find out how many modules are present. It also
- deallocates the previous arrays if they exist.
- */
- int GetModuleVisArrays(void)
- {
- SCENEMODULE *sm_ptr;
- MODULE **m_array_ptr;
- MODULE *m_ptr;
- int index, i;
- if(Global_ModulePtr == 0) return No;
- DeallocateModuleVisArrays();
- sm_ptr = Global_ModulePtr[Global_Scene];
- m_array_ptr = sm_ptr->sm_marray;
- index = smallint;
- while(*m_array_ptr) {
- m_ptr = *m_array_ptr++;
- if(m_ptr->m_index > index) index = m_ptr->m_index;
- }
- ModuleArraySize = index + 1;
- ModuleCurrVisArray = AllocateMem(ModuleArraySize);
- if(ModuleCurrVisArray)
- {
- for(i = 0; i < ModuleArraySize; i++)
- {
- ModuleCurrVisArray[i] = 0;
- }
- #if 0
- textprint("visibility arrays ok, size %d\n", ModuleArraySize);
- #endif
- return Yes;
- }
- else return No;
- }
- #define ppma_print No
- #if 1
- void PreprocessModuleArray(MODULE **m_array_ptr)
- {
- MODULE **m_array = m_array_ptr;
- MODULE *m_ptr;
- int index;
- #if ppma_print
- textprint("PreprocessModuleArray %u\n", m_array_ptr);
- #endif
- index = 0;
- while(*m_array) {
- /* Get the module pointer */
- m_ptr = *m_array;
- /* Assign the module an index */
- m_ptr->m_index = index++;
- #if ppma_print
- textprint("\nModule %u, ", m_ptr);
- PrintName(&m_ptr->m_name);
- textprint(", index %d\n", m_ptr->m_index);
- textprint(" (vptr = ");
- PrintName(&m_ptr->m_vptr.mref_name);
- textprint(")\n");
- #endif
- /* Convert module references from names to pointers */
- if(!(m_ptr->m_flags & m_flag_gotptrs)) {
- #if 0
- /* Vertical Pointer */
- ConvertModuleNameToPointer(&m_ptr->m_vptr, m_array_ptr);
- /* Extent Pointer */
- ConvertModuleNameToPointer(&m_ptr->m_ext, m_array_ptr);
- /* Function Pointer */
- ConvertModuleNameToPointer(&m_ptr->m_funref, m_array_ptr);
- // Hack by John to make the m_link pointers work
- if (m_ptr->m_link_ptrs)
- {
- MREF * m_link_ptr = m_ptr->m_link_ptrs;
-
- while (m_link_ptr->mref_ptr)
- {
- ConvertModuleNameToPointer(m_link_ptr++, m_array_ptr);
- }
- }
- #endif
- /* VMODULE Array */
- if(m_ptr->m_vmptr) {
- /* Convert VMODIDATA names to pointers */
- PreprocessVMODIDATA(m_ptr->m_vmptr);
- /* Convert MREF names to pointers */
- /*
- v_ptr = m_ptr->m_vmptr;
- while(v_ptr->vmod_type != vmtype_term) {
- ConvertModuleNameToPointer(&v_ptr->vmod_mref, m_array_ptr);
- v_ptr++;
- }
- */
- }
- /* Tell the module that its names are now pointers */
- m_ptr->m_flags |= m_flag_gotptrs;
- }
- /* Calculate module extents */
-
- //I'll set the extents and world position in the loaders -Richard.
- //GetModuleMapData(m_ptr);
- /* Next module array entry */
- m_array++;
- }
- /*WaitForReturn();*/
- }
- #else
- #endif
- /*
- VMODIDATA is the data associated with VMODI, the VMODULE instruction. Some
- of the data items are names which need to be converted to pointers.
- */
- void PreprocessVMODIDATA(VMODULE *v_ptr)
- {
- VMODULE *v_array_ptr = v_ptr;
- while(v_ptr->vmod_type != vmtype_term) {
- if(!(v_ptr->vmod_flags & vm_flag_gotptrs)) {
- switch(v_ptr->vmod_instr) {
- case vmodi_null:
- break;
- case vmodi_bra_vc:
- ConvertVModuleNameToPointer(&v_ptr->vmod_data, v_array_ptr);
- break;
- }
- v_ptr->vmod_flags |= vm_flag_gotptrs;
- }
- v_ptr++;
- }
- }
- /*
- Convert MREF name to MREF pointer
- */
- #define cmntp_print No
- void ConvertModuleNameToPointer(MREF *mref_ptr, MODULE **m_array_ptr)
- {
- MODULE *m_ptr;
- int StillSearching;
- #if cmntp_print
- textprint("ConvertModuleNameToPointer\n");
- #endif
- /* Set "null" names to null pointers */
- if(CompareName((char *)&mref_ptr->mref_name, "null")) {
- #if cmntp_print
- textprint("making ptr null\n");
- #endif
- mref_ptr->mref_ptr = 0;
- return;
- }
- /* Search for the module with the same name */
- #if cmntp_print
- textprint("Searching for name...\n");
- #endif
- StillSearching = Yes;
- while(*m_array_ptr && StillSearching) {
- m_ptr = *m_array_ptr;
- if(CompareName((char *)&mref_ptr->mref_name, (char *)&m_ptr->m_name)) {
- #if cmntp_print
- textprint(" found name ");
- PrintName(&m_ptr->m_name);
- textprint(", ptr %u\n", m_ptr);
- #endif
- mref_ptr->mref_ptr = m_ptr;
- StillSearching = No;
- }
- m_array_ptr++;
- }
- /* If the name was not found, make this a null pointer */
- if(StillSearching) mref_ptr->mref_ptr = 0;
- }
- /*
- Convert VMODIDATA.vmodidata_label names to VMODIDATA.vmodidata_ptr
- */
- #define cvmntp_print No
- void ConvertVModuleNameToPointer(VMODIDATA *vmodidata_ptr, VMODULE *v_array_ptr)
- {
- int StillSearching;
- #if cvmntp_print
- textprint("ConvertVModuleNameToPointer\n");
- #endif
- /* Set "null" names to null pointers */
- if(CompareName((char *)&vmodidata_ptr->vmodidata_label, "null")) {
- #if cvmntp_print
- textprint(" making vmodidata_ptr null\n");
- #endif
- vmodidata_ptr->vmodidata_ptr = 0;
- return;
- }
- /* Search for the VMODULE with the same name */
- #if cvmntp_print
- textprint(" Searching for name...\n");
- #endif
- StillSearching = Yes;
- while((v_array_ptr->vmod_type != vmtype_term) && StillSearching) {
- if(CompareName((char *)&vmodidata_ptr->vmodidata_label, (char *)&v_array_ptr->vmod_name)) {
- #if cmntp_print
- textprint(" found name ");
- PrintName(&v_array_ptr->vmod_name);
- textprint(", ptr %u\n", v_array_ptr);
- #endif
- vmodidata_ptr->vmodidata_ptr = v_array_ptr;
- StillSearching = No;
- }
- v_array_ptr++;
- }
- /* If the name was not found, make this a null pointer */
- if(StillSearching)
- {
- if(v_array_ptr->vmod_type == vmtype_term)
- {
- vmodidata_ptr->vmodidata_ptr = v_array_ptr;
- }
- else
- {
- vmodidata_ptr->vmodidata_ptr = 0;
- }
- }
- }
- int CompareName(char *name1, char *name2)
- {
- int i;
- for(i = 4; i!=0; i--) {
- if(*name1++ != *name2++) return No;
- }
- return Yes;
- }
- void PrintName(char *name)
- {
- char m_name[5];
- m_name[0] = name[0];
- m_name[1] = name[1];
- m_name[2] = name[2];
- m_name[3] = name[3];
- m_name[4] = 0;
- textprint(m_name);
- }
- int IsModuleVisibleFromModule(MODULE *source, MODULE *target) {
- VMODULE *vptr;
- MODULE *mptr;
- int gotit;
- vptr=source->m_vmptr;
- gotit=0;
- if ((source==NULL)||(target==NULL)) return(0);
- if (source==target) return(1);
- while(! ((vptr->vmod_type == vmtype_term)||(gotit)) ) {
- /* Add this module to the visible array */
- if(vptr->vmod_mref.mref_ptr) {
- mptr = vptr->vmod_mref.mref_ptr;
- if (mptr==target) gotit=1;
- }
- /* VMODULE instructions */
- switch(vptr->vmod_instr) {
- case vmodi_null:
- vptr++;
- break;
- case vmodi_bra_vc:
- /* NYD */
- /* If the door/viewport is closed... */
- /* Branch to this vptr */
- if(mptr)
- {
- if(mptr->m_flags & m_flag_open)
- vptr++;
- else
- vptr = vptr->vmod_data.vmodidata_ptr;
- }
- /* else vptr++; */
- break;
- }
- }
- return(gotit);
- }
- int IsAIModuleVisibleFromAIModule(AIMODULE *source,AIMODULE *target) {
- if ((source==NULL)||(target==NULL)) return(0);
- if (source==target) return(1);
- {
- MODULE **targetModulelistPtr;
- MODULE **sourceModulelistPtr = source->m_module_ptrs;
- while(*sourceModulelistPtr) {
- targetModulelistPtr=target->m_module_ptrs;
- while(*targetModulelistPtr) {
- if (IsModuleVisibleFromModule(*sourceModulelistPtr,*targetModulelistPtr)) {
- return(1);
- }
- targetModulelistPtr++;
- }
- sourceModulelistPtr++;
- }
- }
- return(0);
- }
- #endif
|