/*========================================================================= * SectInfo.cpp : SectInfo's functions * * * * SectInfo MUST BE REPLACE BY THE C FILENAME * * * Version 1.0 * Creation date 01/10/96 * Revision date * * That file needs to be compatible for all platforms. * * (c) Ubi Studios 1996 *=======================================================================*/ /*******************************************************/ /**** For the structures and variables declarations ****/ /*******************************************************/ #define D_SectInfo_StructureDefine #define D_SectInfo_VariableDefine #include "ToolsCPA.h" #include "Options/Options.h" #include "Macros.h" #include "Actions/AllActs.h" #include "Structur/MemGame.h" #include "Structur/ErrGame.h" #include "Structur/Objects.h" #include "Structur/GameScpt.h" #include "Structur/StdObjSt.h" #include "Structur/EngMode.h" #include "Structur/anim_s.h" #include "Basic.h" #include "GameEng.h" #include "micros.h" #include "MainChar.h" #include "ObjInit.h" #include "ZeMem.h" #include "AlwAct.h" #include "Playanim/playanim.h" #ifdef GAM_USE_SNA #include "sna.h" #endif /* GAM_USE_SNA */ #include "always.h" extern BOOL bFirst; #if defined(GAM_USE_SNA) /* extern tdstEngineObject *g_a20_stSNAObjectsInFix[20]; extern unsigned long g_ulSNANbObjectsInFix; */ #endif /* GAM_USE_SNA */ HIE_tdxHandleToSuperObject g_hCharacterLauchingSoundEvents; /*----------------------------------------------------------------------------- * Description : SectInfo's object action script callback *----------------------------------------------------------------------------- * Input : Object pointer * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Francois *----------------------------------------------------------------------------- * Modification date : Modification Author : Olivier * Modifications : *---------------------------------------------------------------------------*/ #if defined(GAM_USE_SCRIPT) SCR_tde_Anl_ReturnValue fn_eSectInfoScriptCallBack(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction) { SCR_tde_Anl_ReturnValue eReturnValue = SCR_ERV_Anl_NormalReturn; MS_tdxHandleToSectInfo h_SectInfo; struct tdstEngineObject_ *p_stEngineObject; _p_stFile=_p_stFile; SCR_M_RdL0_GetSectionLong(C_ParentSection,0,struct tdstEngineObject_ *, p_stEngineObject); if (M_IsTitle) { MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypeSectInfo , p_stEngineObject); h_SectInfo = fn_h_SectInfoRealAlloc(); MMG_fn_vEndMemoryInfo (); h_SectInfo->hCurrentSector=NULL; p_stEngineObject->h_SectInfo=h_SectInfo; SCR_M_RdL0_SetSectionLong(C_ThisSection,0,h_SectInfo); } else if (M_IsEntry) { SCR_M_RdL0_GetSectionLong(C_ThisSection,0,MS_tdxHandleToSectInfo,h_SectInfo); } return(eReturnValue); } #endif /* GAM_USE_SCRIPT */ /*----------------------------------------------------------------------------- * Description : SectInfo's mini-structure sizeof *----------------------------------------------------------------------------- * Input : None * Output : Size of *----------------------------------------------------------------------------- * Creation date : 14/10/96 Author : Francois *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ unsigned long fn_ulSectInfoSizeOf() { return(sizeof(struct tdstSectInfo_)); } /*----------------------------------------------------------------------------- * Description : SectInfo's object action allocation *----------------------------------------------------------------------------- * Input : Object pointer * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Francois *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vSectInfoAlloc(struct tdstEngineObject_ *p_stObject) { if (p_stObject==NULL) M_GameFatalError(E_uwGameMiniStructObjectNull); if (p_stObject->h_SectInfo!=NULL) M_GameFatalError(E_uwGameMiniStructAllocAlreadyAlloc); MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypeSectInfo , p_stObject); p_stObject->h_SectInfo = fn_h_SectInfoRealAlloc(); MMG_fn_vEndMemoryInfo (); } MS_tdxHandleToSectInfo fn_h_SectInfoRealAlloc() { MS_tdxHandleToSectInfo h_SectInfo; h_SectInfo = (MS_tdxHandleToSectInfo)M_p_GameMallocInHLM(fn_ulSectInfoSizeOf()); h_SectInfo->hNodeInSector = SECT_fn_hCreateElementLstCharacter(); return(h_SectInfo); } /*----------------------------------------------------------------------------- * Description : SectInfo's object action free *----------------------------------------------------------------------------- * Input : Object pointer * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Francois *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vSectInfoFree(struct tdstEngineObject_ *p_stObject) { if (p_stObject==NULL) M_GameFatalError(E_uwGameMiniStructObjectNull); if (p_stObject->h_SectInfo==NULL) M_GameFatalError(E_uwGameMiniStructNull); MMG_fn_vAddMemoryInfo( MMG_C_lTypeMiniStructure , MMG_C_lSubTypeSectInfo , p_stObject ); M_GameFreeInHLM(p_stObject->h_SectInfo); } /*----------------------------------------------------------------------------- * Description : SectInfo's object action initialisation *----------------------------------------------------------------------------- * Input : When this function's called (see ObjInit.h) * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Francois *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ ACP_tdxBool fn_bIsInFix(struct tdstEngineObject_ *p_stObject) { #if defined(GAM_USE_SNA) unsigned char ucI; for(ucI=0;ucIh_SectInfo==NULL) M_GameFatalError(E_uwGameMiniStructNull); #if defined(GAM_USE_SNA) if( (!fn_bIsInFix( p_stObject) && SNA_fn_ucGetLoadType()==SNA_SAVE_SNAPSHOT) ||(fn_bIsInFix( p_stObject) && SNA_fn_ucGetLoadType()==4) ||(SNA_fn_ucGetLoadType()==SNA_LOAD_SNAPSHOT) ||(SNA_fn_ucGetLoadType()==SNA_LOAD_SCRIPT) ) #endif /* GAM_USE_SNA */ { switch(eObjectInit) { case OTI_MapLoaded: p_stObject->h_SectInfo->hCurrentSector = NULL; fn_vSectInfoSavedValueSAI(p_stObject->h_SectInfo); case OTI_LoadSavedGame: case OTI_ReinitTheMap: case OTI_PlayerDead: if (M_GetSuperObject(p_stObject)!=NULL) { p_stV = POS_fn_p_stGetTranslationVector(fn_p_st3dDataGetMatrix(p_stObject->h_3dData)); fn_vSectInfoInitForSingleCharacter(M_GetSuperObject(p_stObject),p_stV); MTH3D_M_vCopyVector(&p_stObject->h_SectInfo->stPreviousPosition,p_stV); } break; /* ANNECY MT - 18/09/98 {*/ case OTI_AlwaysCreated: if (M_GetSuperObject(p_stObject)!=NULL) { h_SO = M_GetSuperObject(p_stObject); p_stV = POS_fn_p_stGetTranslationVector (HIE_fn_hGetSuperObjectGlobalMatrix(h_SO)); fn_vInsertObjectInSectorList(p_stObject->h_SectInfo->hCurrentSector,h_SO); SECT_fn_vSetCharacterPointerInCharacterList(p_stObject->h_SectInfo->hNodeInSector, h_SO); MTH3D_M_vCopyVector(&p_stObject->h_SectInfo->stPreviousPosition,p_stV); if( (hLight = M_GetMSHandle(h_SO,MSLight)) != 0 ) /*VOLUNTARY ASSIGNMENT*/ { SECT_fn_vSetHandleOfLightsInDNMLightsList( fn_hMSLightGetLightNodeInSector(hLight), fn_p_stMSLightGetLight(hLight) ); } } break; /* END ANNECY MT }*/ default: break; } } } /*----------------------------------------------------------------------------- * Description : SectInfo's object action desinitialisation *----------------------------------------------------------------------------- * Input : When this function's called (see ObjInit.h) * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Francois *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vSectInfoDesinit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit) { if (p_stObject==NULL) M_GameFatalError(E_uwGameMiniStructObjectNull); if (p_stObject->h_SectInfo==NULL) M_GameFatalError(E_uwGameMiniStructNull); switch(eObjectInit) { case OTI_MapLoaded: case OTI_ReinitTheMap: case OTI_LoadSavedGame: case OTI_AlwaysCreated: case OTI_PlayerDead: if (M_GetSuperObject(p_stObject)) { fn_vRemoveObjectInSectorList(M_GetSuperObject(p_stObject)); } break; default: break; } } /*************************************************************************/ void fn_vSectInfoSavedValueSAI(MS_tdxHandleToSectInfo hSectInfo) { /*SAI_fn_bInsertPointerInTable((void*)&hSectInfo->hCurrentSector,SAI_ePlayerSaveCurrentValue);*/ } /*************************************************************************/ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vSectInfoFreeInitValueSAI(MS_tdxHandleToSectInfo hSectInfo) { /*SAI_fn_bRemoveValueFromTable((void*)&hSectInfo->hCurrentSector,SAI_ePlayerSaveCurrentValue);*/ } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /*************************************************************************/ /*----------------------------------------------------------------------------- * Description : SectInfo's object copy clone action *----------------------------------------------------------------------------- * Input : Handle to destination, handle to source * Output : None *----------------------------------------------------------------------------- * Creation date : 30/06/97 Author : Olivier Jourdan *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vSectInfoCopyClone(struct tdstEngineObject_ * _p_stObjectDest,struct tdstEngineObject_ * _p_stObjectSrc) { /* Useless*/ /* memcpy(_p_stObjectDest->h_SectInfo,_p_stObjectSrc->h_SectInfo,fn_ulSectInfoSizeOf());*/ } /*----------------------------------------------------------------------------- * Description : Init Sector informations for a single character *----------------------------------------------------------------------------- * Input : Object and Sector * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *----------------------------------------------------------------------------- * Modification date : 02/07/97 Modification Author : Olivier * Modifications : Optimization *---------------------------------------------------------------------------*/ void fn_vSectInfoInitForSingleCharacter(HIE_tdxHandleToSuperObject hCharacter,struct MTH3D_tdstVector_ * hPosition) { HIE_tdxHandleToSuperObject testSO; MS_tdxHandleToSectInfo hSectInfo; MS_tdxHandleToMSLight hLight; /* if (((SNA_fn_ucGetLoadType()!=4) ||fn_bIsInFix(HIE_fn_hGetSuperObjectObject(hCharacter)))) // MR0110*/ /* {*/ #if defined(GAM_USE_SNA) if( (!fn_bIsInFix( HIE_fn_hGetSuperObjectObject(hCharacter)) && SNA_fn_ucGetLoadType()==SNA_SAVE_SNAPSHOT) ||(fn_bIsInFix( HIE_fn_hGetSuperObjectObject(hCharacter)) && SNA_fn_ucGetLoadType()==4) ||(SNA_fn_ucGetLoadType()==SNA_LOAD_SNAPSHOT) ||(SNA_fn_ucGetLoadType()==SNA_LOAD_SCRIPT) ) { #endif /* GAM_USE_SNA */ hSectInfo = M_GetMSHandle(hCharacter,SectInfo); testSO = (HIE_tdxHandleToSuperObject)SECT_fn_hResearchInWhatSectorIAm(SECT_hFatherSector,hPosition); /* if we are in a sector, take it, else use the universe sector*/ hSectInfo->hCurrentSector = testSO ? testSO : HIE_fn_hGetChildNumber(SECT_hFatherSector,HIE_fn_lGetNumberOfChildren(SECT_hFatherSector)-1); SECT_fn_vSetCharacterPointerInCharacterList(hSectInfo->hNodeInSector, hCharacter); if( (hLight = M_GetMSHandle(hCharacter,MSLight)) != 0 ) /*VOLUNTARY ASSIGNMENT*/ { SECT_fn_vSetHandleOfLightsInDNMLightsList( fn_hMSLightGetLightNodeInSector(hLight), fn_p_stMSLightGetLight(hLight) ); } /* put the object in the sector list*/ fn_vInsertObjectInSectorList(hSectInfo->hCurrentSector,hCharacter); #if defined(GAM_USE_SNA) } #endif /* GAM_USE_SNA */ } /*void fn_vInsertAnimLightsInSectorList2(HIE_tdxHandleToSuperObject hSector,tdstAnimLights *p_stAnimLights) { long lState, i; for (i = 0; i < p_stAnimLights->uwNumberOfLights; i ++ ) { GLI_xGetLightState(p_stAnimLights->a_p_stLights[i],&lState); if (lState) { SECT_fn_vIsolateDNMLightsListNode(p_stAnimLights->a_hLightsInSector[i]); SECT_fn_vAddTailDNMLightsListNode(hSector,p_stAnimLights->a_hLightsInSector[i]); } else SECT_fn_vIsolateDNMLightsListNode(p_stAnimLights->a_hLightsInSector[i]); // MR0109 } } */ /*----------------------------------------------------------------------------- * Description : Insert an object in Sector list *----------------------------------------------------------------------------- * Input : Object and Sector * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *----------------------------------------------------------------------------- * Modification date : 02/07/97 Modification Author : Olivier * Modifications : Optimization *---------------------------------------------------------------------------*/ void fn_vInsertObjectInSectorList(HIE_tdxHandleToSuperObject hSector, HIE_tdxHandleToSuperObject hCharacter) { tdstSectInfo * p_stSectInfo; p_stSectInfo = M_GetMSHandle(hCharacter,SectInfo); SECT_fn_vIsolateCharListNode(p_stSectInfo->hNodeInSector); if( fn_ucStandardGameGetPlatFormType(M_GetMSHandle(hCharacter,StandardGame))!=0 ) SECT_fn_vAddHeadCharListNode(hSector,p_stSectInfo->hNodeInSector); else SECT_fn_vAddTailCharListNode(hSector,p_stSectInfo->hNodeInSector); if( M_GetMSHandle(hCharacter,MSLight) ) fn_vInsertLightInSectorList(hSector,hCharacter); } /*----------------------------------------------------------------------------- * Description : Insert a light in Sector list *----------------------------------------------------------------------------- * Input : Object and Sector * Output : None *----------------------------------------------------------------------------- * Creation date : 28/02/97 Author : Michaël *----------------------------------------------------------------------------- * Modification date : 02/07/97 Modification Author : Olivier * Modifications : Optimization *---------------------------------------------------------------------------*/ void fn_vInsertLightInSectorList(HIE_tdxHandleToSuperObject hSector, HIE_tdxHandleToSuperObject hCharacter) { MS_tdxHandleToMSLight hMSLight; hMSLight = M_GetMSHandle(hCharacter,MSLight); if (fn_bMSLightGetLocalLight(hMSLight)) { HIE_fn_vSetSuperObjectExcluLight(hCharacter,fn_bMSLightGetOnlyLocalLight(hMSLight)); return; } SECT_fn_vIsolateDNMLightsListNode(fn_hMSLightGetLightNodeInSector(hMSLight)); SECT_fn_vAddTailDNMLightsListNode(hSector,fn_hMSLightGetLightNodeInSector(hMSLight)); } /*void fn_vIsolateAnimLights(tdstAnimLights *p_stAnimLights) { long i; for ( i = 0; i uwNumberOfLights; i ++ ) { SECT_fn_vIsolateDNMLightsListNode(p_stAnimLights->a_hLightsInSector[i]); } } */ /*----------------------------------------------------------------------------- * Description : Remove an object from sector list *----------------------------------------------------------------------------- * Input : Object and Sector * Output : None *----------------------------------------------------------------------------- * Creation date : 01/10/96 Author : Olivier *----------------------------------------------------------------------------- * Modification date : 14/03/96 Modification Author : Michaël * Modifications : Remove light from sector *---------------------------------------------------------------------------* * Modification date : 02/07/97 Modification Author : Olivier * Modifications : Optimization *---------------------------------------------------------------------------*/ void fn_vRemoveObjectInSectorList(HIE_tdxHandleToSuperObject hCharacter) { /*tdstAnimLights *p_stAnimLights;*/ SECT_fn_vIsolateCharListNode(M_GetMSHandle(hCharacter,SectInfo)->hNodeInSector); if( M_GetMSHandle(hCharacter,MSLight) ) { SECT_fn_vIsolateDNMLightsListNode(fn_hMSLightGetLightNodeInSector(M_GetMSHandle(hCharacter,MSLight))); } /* p_stAnimLights=PLA_fn_pstGetLightsOfAnim(hCharacter);*/ /* if (p_stAnimLights&&(p_stAnimLights->uwNumberOfLights>0)) fn_vIsolateAnimLights(p_stAnimLights); */} /*----------------------------------------------------------------------------- * Description : SectInfo access functions *----------------------------------------------------------------------------- * Input : MS_tdxHandleToSectInfo + (value) * Output : (value or pointer) *----------------------------------------------------------------------------- * Creation date : 03/02/97 Author : Francois *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ HIE_tdxHandleToSuperObject fn_h_SectInfoGetCurrentSector(MS_tdxHandleToSectInfo h_SectInfo) { return(h_SectInfo->hCurrentSector); } void fn_vSectInfoSetCurrentSector(MS_tdxHandleToSectInfo h_SectInfo,HIE_tdxHandleToSuperObject hCurrentSector) { h_SectInfo->hCurrentSector = hCurrentSector; } HIE_tdxHandleToSuperObject GAM_fn_hGetCurrentSector(HIE_tdxHandleToSuperObject _hCharacter) { if( HIE_fn_ulGetSuperObjectType(_hCharacter) != HIE_C_ulActor ) return NULL; if( !M_GetMSHandle(_hCharacter,SectInfo) ) return NULL; return fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hCharacter,SectInfo)); } #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void GAM_fn_vSetCurrentSector(HIE_tdxHandleToSuperObject _hCharacter,HIE_tdxHandleToSuperObject _hCurrentSector) { if( HIE_fn_ulGetSuperObjectType(_hCharacter) != HIE_C_ulActor ) return; if( !M_GetMSHandle(_hCharacter,SectInfo) ) return; fn_vSectInfoSetCurrentSector(M_GetMSHandle(_hCharacter,SectInfo),_hCurrentSector); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /*----------------------------------------------------------------------------- * Description : Sect Info Sound Events Lauching After Crossing *----------------------------------------------------------------------------- * Input : Character crossing sector * Output : Nothing *----------------------------------------------------------------------------- * Creation date : 03/02/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void fn_vSectInfoLaunchSectorSoundEvents(HIE_tdxHandleToSuperObject _hCharacter) { HIE_tdxHandleToSuperObject * p_a10History; HIE_tdxHandleToSuperObject * p_hIndex; ACP_tdxIndex xNbChanges,xIndex; if( _hCharacter == g_hCharacterLauchingSoundEvents) { if( (xNbChanges = SCT_fn_xGetSectorChangeHistory(&p_a10History)) > 1 ) { for( xIndex=0,p_hIndex=p_a10History; xIndex<(xNbChanges-1); xIndex++,p_hIndex++ ) { fn_vSectInfoLaunchEventsFromS1ToS2(*p_hIndex,*(p_hIndex+1)); } } } } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /*----------------------------------------------------------------------------- * Description : Launch sound events when crossing from sector 1 * towards sector 2 *----------------------------------------------------------------------------- * Input : Sector from and Sector towards * Output : Nothing *----------------------------------------------------------------------------- * Creation date : 03/02/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vSectInfoLaunchEventsFromS1ToS2(HIE_tdxHandleToSuperObject _hSector1,HIE_tdxHandleToSuperObject _hSector2) { unsigned long ulI; SCT_tdxHandleOfLstSoundEvent hSoundEventList; SND_tduRefEvt stEvent; SCT_M_ForEachSoundEventNodeInSoundEventList(_hSector2,hSoundEventList,ulI) { if( SCT_fn_hGetSectorInSoundEventList(hSoundEventList) == _hSector1 || SCT_fn_hGetSectorInSoundEventList(hSoundEventList) == NULL) { /* Lauching the sound event */ /* Temporary, type of event will be FANTOME */ stEvent.pstPtr = SCT_fn_uGetSoundEventInSoundEventList(hSoundEventList); SND_fn_lSendRequestSound(/*C_SOUNDOBJECT_SECTOR*/SND_C_OBJET_FANTOME,g_lSoundObjectTypeMusic,stEvent,0,NULL); } } } /*----------------------------------------------------------------------------- * Description : Events are launched By Ed (default) or by the active * Camera *----------------------------------------------------------------------------- * Input : Nothing * Output : Nothing *----------------------------------------------------------------------------- * Creation date : 03/02/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void fn_vSectInfoSetCharacterLauchingEvents(HIE_tdxHandleToSuperObject _hCharacter) { g_hCharacterLauchingSoundEvents = _hCharacter; } /*----------------------------------------------------------------------------- * Description : Debugging functions for sectors *----------------------------------------------------------------------------- * Input : character * Output : name of the current (previous) sector *----------------------------------------------------------------------------- * Creation date : 20/06/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ char * fn_p_szSectInfoGetCurrentSectorName(HIE_tdxHandleToSuperObject _hCharacter) { #ifdef _DEBUG return( fn_szGetSectorName(M_GetMSHandle(_hCharacter,SectInfo)->hCurrentSector) ); #else char *pChar = NULL; return pChar; #endif /* DEBUG */ } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /* JMS 14-01-1998 */ #define C_xCorrectionVector MTH_M_xFloatToReal(0.2f) /*----------------------------------------------------------------------------- * Description : New version to test if a character cross a border * between two sectors. * This function do all modifications in SectInfo * mini-structure, and update informations. *----------------------------------------------------------------------------- * Input : handle on a character * Output : void *----------------------------------------------------------------------------- * Creation date : 28/09/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ void GAM_fn_vSectInfoTestChangeSectorForCharacter(HIE_tdxHandleToSuperObject _hCharacter) { tdstSectInfo * p_stSectInfo; MTH3D_tdstVector stCurrentPosition; HIE_tdxHandleToSuperObject hSector,hPreviousSector; /* Try*/ MTH3D_tdstVector stCurrentRaisedPosition,stPreviousRaisedPosition; MTH3D_tdstVector stAdding; /* JMS 14-01-1998 */ /* Ceci est un ANTI-BUG : Il faudra par la suite que le point test de passage de secteur */ /* soit placé par les éditeurs de tel sorte que ce dernier soit "protégé" par les ZDMs */ /* afin qu'il ne puisse en aucun cas se retrouvé en dehors de la map. */ MTH3D_tdstVector a2_stColons[2]; POS_fn_vGetRotationMatrix(HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter),a2_stColons,a2_stColons+1,&stAdding); MTH3D_M_vMulScalarVector(&stAdding,C_xCorrectionVector,&stAdding); /* End JMS 14-01-1998 */ p_stSectInfo = M_GetMSHandle(_hCharacter,SectInfo); POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter),&stCurrentPosition); hSector = p_stSectInfo->hCurrentSector; hPreviousSector = p_stSectInfo->hCurrentSector; MTH3D_M_vCopyVector(&stCurrentRaisedPosition,&stCurrentPosition); MTH3D_M_vCopyVector(&stPreviousRaisedPosition,&p_stSectInfo->stPreviousPosition); MTH3D_M_vAddVector(&stCurrentRaisedPosition,&stCurrentRaisedPosition,&stAdding); MTH3D_M_vAddVector(&stPreviousRaisedPosition,&stPreviousRaisedPosition,&stAdding); SCT_fn_vTestChangeSectorWithHistory( &stPreviousRaisedPosition, &stCurrentRaisedPosition, &hSector); if( hSector!=p_stSectInfo->hCurrentSector ) { ACP_tdxBool bOnInactivedSector; /*DFM PLA_fn_vDesInitAllChildOfCharacter(_hCharacter);*/ if( _hCharacter == g_hCharacterLauchingSoundEvents) /* NOUVEAU*/ fn_vSectInfoLaunchEventsFromS1ToS2(p_stSectInfo->hCurrentSector,hSector); p_stSectInfo->hCurrentSector = hSector; /**/ if( !fn_ucIsAnAlwaysObject((tdstEngineObject *)HIE_fn_hGetSuperObjectObject(_hCharacter)) && !fn_bGetIfCharacterIsInAlwaysActiveCharacterList(_hCharacter) ) { bOnInactivedSector = (ACP_tdxBool) (p_stSectInfo->hCurrentSector != g_hSOCurrentMainSector); if( bOnInactivedSector ) { SECT_tdxHandleOfElementLstActivityInteraction hActivityList; HIE_tdxHandleToSuperObject hChildSector; long i; SECT_M_ForEachActivityNodeInActivityInteractionList(g_hSOCurrentMainSector,hActivityList,i) { hChildSector = SECT_GetSectorInActivityList(hActivityList); if( hChildSector == p_stSectInfo->hCurrentSector ) { bOnInactivedSector = FALSE; break; } } if( bOnInactivedSector ) { HIE_fn_vIsolate(_hCharacter); if( fn_ucStandardGameGetPlatFormType(M_GetMSHandle(_hCharacter,StandardGame))!=0 ) { HIE_fn_vSuperObjectAddHead(gp_stInactiveDynamicWorld,_hCharacter); } else { HIE_fn_vSuperObjectAddTail(gp_stInactiveDynamicWorld,_hCharacter); } M_UnactivateObject((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(_hCharacter)); } } } /**/ /*fn_vSectInfoLaunchSectorSoundEvents(_hCharacter);*/ fn_vInsertObjectInSectorList( p_stSectInfo->hCurrentSector,_hCharacter); if( _hCharacter==MC_fn_hGetCharacterInMainCharacterNode( MC_fn_hGetFirstMainCharNode()) ) fn_vInitObjectsWhenPlayerChangeSector(_hCharacter,p_stSectInfo->hCurrentSector,hPreviousSector); } MTH3D_M_vCopyVector(&p_stSectInfo->stPreviousPosition,&stCurrentPosition); } /*----------------------------------------------------------------------------- * Description : Debug function to test incoherences in sectors list *----------------------------------------------------------------------------- * Input : void * Output : void *----------------------------------------------------------------------------- * Creation date : 25/09/97 Author : Olivier *----------------------------------------------------------------------------- * Modification date : Modification Author : * Modifications : *---------------------------------------------------------------------------*/ #ifdef _DEBUG /*#ifdef DEBUG_LINK_TABLES*/ char * fn_p_szGetSectorName(HIE_tdxHandleToSuperObject _hSector) { #if defined(GAM_USE_SCRIPT) void * p_vSectorObject; SCR_tdst_Link_Table * p_stSectorLinkTable; SCR_tdst_Link_Value * p_stLinkValue; p_stSectorLinkTable = SECT_fn_pGetLinkTable(); p_vSectorObject = HIE_fn_hGetSuperObjectObject(_hSector); p_stLinkValue = SCR_fnp_st_Link_SearchValue(p_stSectorLinkTable,(unsigned long)p_vSectorObject); return((char*) (SCR_M_p_sz_Link_GetKey(p_stLinkValue)+SCR_M_ul_Link_GetAdditionalLong(p_stLinkValue,1))); #else /* GAM_USE_SCRIPT */ /*char *pChar;*/ /*return pChar;*/ return NULL; #endif /* GAM_USE_SCRIPT */ } /*#endif /* DEBUG_LINK_TABLES */ void fn_vTestIntegrityForOneSector(HIE_tdxHandleToSuperObject _hSector) { SECT_tdxHandleOfElementLstGraphicInteraction hGraphicNode,hGraphicNode2; SECT_tdxHandleOfElementLstCollisionInteraction hCollisionNode,hCollisionNode2; SECT_tdxHandleOfElementLstActivityInteraction hActivityNode,hActivityNode2; SECT_tdxHandleOfElementLstSoundInteraction hSoundNode,hSoundNode2; unsigned long ulI,ulJ; long lCount; char szTotalInformation[255]; /* Testing integrity for GRAPHIC list*/ SECT_M_ForEachGraphicNodeInGraphicInteractionList(_hSector,hGraphicNode,ulI) { if( _hSector==SECT_GetSectorInGraphicList(hGraphicNode) ) { M_GameInformationErrorWithString(E_uwGameCurrentSectorInOwnGraphicList,fn_p_szGetSectorName(_hSector)); } lCount = 0; SECT_M_ForEachGraphicNodeInGraphicInteractionList(_hSector,hGraphicNode2,ulJ) { if( SECT_GetSectorInGraphicList(hGraphicNode)==SECT_GetSectorInGraphicList(hGraphicNode2) ) lCount++; } if( lCount!=1 ) { strcpy(szTotalInformation,fn_p_szGetSectorName(_hSector)); strcat(szTotalInformation," : "); strcat(szTotalInformation,fn_p_szGetSectorName(SECT_GetSectorInGraphicList(hGraphicNode))); M_GameInformationErrorWithString(E_uwGameSectorTwiceInGraphicList,szTotalInformation); } } /* Testing integrity for ACTIVITY list*/ SECT_M_ForEachActivityNodeInActivityInteractionList(_hSector,hActivityNode,ulI) { if( _hSector==SECT_GetSectorInActivityList(hActivityNode) ) { M_GameInformationErrorWithString(E_uwGameCurrentSectorInOwnActivityList,fn_p_szGetSectorName(_hSector)); } lCount = 0; SECT_M_ForEachActivityNodeInActivityInteractionList(_hSector,hActivityNode2,ulJ) { if( SECT_GetSectorInActivityList(hActivityNode)==SECT_GetSectorInActivityList(hActivityNode2) ) lCount++; } if( lCount!=1 ) { strcpy(szTotalInformation,fn_p_szGetSectorName(_hSector)); strcat(szTotalInformation," : "); strcat(szTotalInformation,fn_p_szGetSectorName(SECT_GetSectorInActivityList(hActivityNode))); M_GameInformationErrorWithString(E_uwGameSectorTwiceInActivityList,szTotalInformation); } } /* Testing integrity for COLLISION list*/ SECT_M_ForEachCollisionNodeInCollisionInteractionList(_hSector,hCollisionNode,ulI) { if( _hSector==SECT_GetSectorInCollisionList(hCollisionNode) ) { M_GameInformationErrorWithString(E_uwGameCurrentSectorInOwnCollisionList,fn_p_szGetSectorName(_hSector)); } lCount = 0; SECT_M_ForEachCollisionNodeInCollisionInteractionList(_hSector,hCollisionNode2,ulJ) { if( SECT_GetSectorInCollisionList(hCollisionNode)==SECT_GetSectorInCollisionList(hCollisionNode2) ) lCount++; } if( lCount!=1 ) { strcpy(szTotalInformation,fn_p_szGetSectorName(_hSector)); strcat(szTotalInformation," : "); strcat(szTotalInformation,fn_p_szGetSectorName(SECT_GetSectorInCollisionList(hCollisionNode))); M_GameInformationErrorWithString(E_uwGameSectorTwiceInCollisionList,szTotalInformation); } } /* Testing integrity for SOUND list*/ SECT_M_ForEachSoundNodeInSoundInteractionList(_hSector,hSoundNode,ulI) { if( _hSector==SECT_GetSectorInSoundList(hSoundNode) ) { M_GameInformationErrorWithString(E_uwGameCurrentSectorInOwnSoundList,fn_p_szGetSectorName(_hSector)); } lCount = 0; SECT_M_ForEachSoundNodeInSoundInteractionList(_hSector,hSoundNode2,ulJ) { if( SECT_GetSectorInSoundList(hSoundNode)==SECT_GetSectorInSoundList(hSoundNode2) ) lCount++; } if( lCount!=1 ) { M_GameInformationErrorWithString(E_uwGameSectorTwiceInSoundList,fn_p_szGetSectorName(SECT_GetSectorInSoundList(hSoundNode))); strcpy(szTotalInformation,fn_p_szGetSectorName(_hSector)); strcat(szTotalInformation," : "); strcat(szTotalInformation,fn_p_szGetSectorName(SECT_GetSectorInSoundList(hSoundNode))); M_GameInformationErrorWithString(E_uwGameSectorTwiceInSoundList,szTotalInformation); } } } #endif /* _DEBUG */ void fn_vTestAllSectorsListForIncoherences() { #ifdef _DEBUG ACP_tdxIndex xI; HIE_tdxHandleToSuperObject hSector; HIE_M_ForEachChildOf(SECT_hFatherSector,hSector,xI) { fn_vTestIntegrityForOneSector(hSector); } #endif /* _DEBUG */ }