reman3/Rayman_X/cpa/tempgrp/GAM/ZdxStuff.c

3091 lines
113 KiB
C

/*--------------------------------------------------------------------
* Notes on used notation in functions comments:
* OPTIMIZED: n, where n is the number of time the function has been
* optimized
*--------------------------------------------------------------------*/
#define D_State_Define
#define D_ZdxStuff_StructureDefine
#define D_ZdxStuff_VariableDefine
#include "ToolsCPA.h"
#ifdef LST2_StaticIsOptimised
void qsort(void *,size_t,size_t,int (*)(const void *,const void *)); /* for qsort */
#endif
#include "GameEng.h"
#include "Structur/State.h"
#include "Actions/AllActs.h"
#include "Structur/GameScpt.h"
#include "Structur/ErrGame.h"
#include "Structur/MemGame.h"
#include "Structur/StdObjSt.h"
#include "Structur/EngMode.h"
#include "Structur/Objects.h"
#include "Structur/ObjsTbls.h"
#include "Basic.h"
#include "Family.h"
#include "Physicol.h"
#include "ZdxStuff.h"
#include "ToolCam.h"
#include "Zemem.h"
#include "Structur/3DOSLkTb.h"
#include "ChanList.h"
#include "Collisio.h"
#include "GLI\GLI_Defn.h"
#include "ObjType.h"
#define C_ucNbPointsInGeometricAccelerator 30
#define C_ucNbElementsInGeometricAccelerator 4
#define C_ucNumberBidulesInElements 10
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
unsigned char g_ucZDCVisible = 0; /* Oliv' - Thnx for init of variable :-) 19/05/1999 */
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
/* Oliv' - 19/05/1999 - I want to see Zdx too */
#if defined(_U64_GLI_BENCH_)
unsigned char g_ucZDCVisible = 0; /* Oliv' - Thnx for init of variable :-) 19/05/1999 */
#define ZDX_C_lDrawMask GLI_C_lAllIsEnable &\
~GLI_C_lIsTextured
char * g_szZoneTypes[5] = { "All ZdX", "ZdD", "ZdE", "ZdM", "ZdR" };
#endif /* _U64_GLI_BENCH_ */
/* EndOfOliv' */
#if defined(_DEBUG)
#define ZDX_C_lDrawMask GLI_C_lAllIsEnable &\
~GLI_C_lIsTextured &\
~GLI_C_lIsNotWired &\
~GLI_C_lIsNotOutlined &\
~GLI_C_lIsGouraud &\
~GLI_C_lIsNotGrided &\
~GLI_C_lIsNotDoted &\
~GLI_C_lIsTestingBackface &\
~GLI_C_lIsNotDrawingSuperObjectBoundingVolume &\
~GLI_C_lIsNotDrawCollideInformationLight &\
~GLI_C_lIsUseRLI &\
~GLI_C_lIsNotDrawCollideInformation &\
~GLI_C_lIsUseStaticLights
/*--- For Displaying ZdX*/
char * g_szZoneTypes[5] = { "All ZdX", "ZdD", "ZdE", "ZdM", "ZdR" };
/*----------------------------------------------------------------------
* Internal global variables used for loading
*--------------------------------------------------------------------*/
/*
ACP_tdxHandleOfObject g_hCollisionGeoObj;
ACP_tdxHandleOfObject g_hStaticCollisionGeoObj;
ACP_tdxHandleOfObject g_hZdrCollisionGeoObj;
*/
/* Needed to draw the box bounding volumes */
ACP_tdxHandleOfObject g_hBoxGeomObj;
ACP_tdxHandleOfObject g_hSphereGeomObj;
extern GMT_tdxHandleToGameMaterial gs_hMaterial;
#endif /*_DEBUG*/
/*--------------------------------------------------------------------
*********************************************************************
* OPTIMISATION FUNCTIONS
*********************************************************************
*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------
* Return geometric zone if active, NULL if inactive
* OPTIMIZED : 1
*--------------------------------------------------------------------*/
ACP_tdxHandleOfObject fn_hIsThisZoneActive(
HIE_tdxHandleToSuperObject _hCharacter,
unsigned char _ucZoneType,
unsigned char _ucZoneNumber)
{
tdstGeometricZdxList *p_stGeoZdxList;
tdeCollSetPrivilegedActivation ePrivilege;
tdstZoneSetList *p_stZoneSet;
tdstZdxList *p_stZdxList = NULL;
tdstZdxIndexList *p_stZdxIndex;
ACP_tdxIndex xI;
int iIndex,iMax;
ePrivilege = fn_eGetPrivilegedActivationZoneOfCharacter(_ucZoneType,_hCharacter,_ucZoneNumber);
if( ePrivilege == edmPriviligedActivated )
{
p_stZdxList = (tdstZdxList *)CS_fn_hGetZdxList(_ucZoneType,_hCharacter);
LST2_M_StaticGetElementNumber(&p_stZdxList->hGeoZdxList,p_stGeoZdxList,_ucZoneNumber,xI);
return( p_stGeoZdxList->hGeoObj );
}
else if( ePrivilege == edmPriviligedDefault )
{
/* search on current activation*/
p_stZoneSet = fn_p_stGetCurrentZoneSetOfType2(_ucZoneType,_hCharacter);
if( p_stZoneSet )
{
p_stZdxIndex = LST2_M_StaticGetFirstElement( &p_stZoneSet->hZdxIndexList );
iMax = LST2_M_StaticGetNumberOfElements( &p_stZoneSet->hZdxIndexList );
iIndex=0;
while( (iIndex < iMax) && (_ucZoneNumber>fn_uwGetIndexFromZdxIndexList(p_stZdxIndex)) )
{
p_stZdxIndex = LST2_M_StaticGetNextElement( p_stZdxIndex );
iIndex++;
}
if( (iIndex < iMax) && (_ucZoneNumber == fn_uwGetIndexFromZdxIndexList(p_stZdxIndex)) )
{
p_stZdxList = (tdstZdxList *)CS_fn_hGetZdxList(_ucZoneType,_hCharacter);
LST2_M_StaticGetElementNumber(&p_stZdxList->hGeoZdxList,p_stGeoZdxList,_ucZoneNumber,xI);
return( p_stGeoZdxList->hGeoObj );
}
}
}
return NULL;
}
/*--------------------------------------------------------------------
* Return Game Material if exist, NULL if can't find it
* OPTIMIZED : 1
*--------------------------------------------------------------------*/
GMT_tdxHandleToGameMaterial fn_hIsTypeExistsInGeoObj(ACP_tdxHandleOfObject _hGeoObj,GMT_tdxMask _wMaterialMask)
{
ACP_tdxIndex xIndex, xIndexMax;
GMT_tdxHandleToGameMaterial hGMT;
ACP_tdxIndex xNbElements, xNbElementsMax;
/* Oliv' - Achtung ! the function is re-evaluated each time in the FOR loop !!*/
/* More over : this is NOT the good function called*/
xNbElementsMax = GEO_xGetGeometricObjectNumberOfElementsMax( _hGeoObj ); /* note the Max at end of function*/
/* for( xNbElements=0; xNbElements<GEO_xGetGeometricObjectNumberOfElements(_hGeoObj); xNbElements++ )*/
for( xNbElements=0; xNbElements<xNbElementsMax; xNbElements++ )
/* EndOfOliv'*/
{
switch( GEO_xGetElementType(_hGeoObj,xNbElements) )
{
case GEO_C_xElementIndexedTriangles:
/* Only one GameMaterial */
GEO_vGetGameMaterialOfIndexedTriangles(_hGeoObj,xNbElements,&hGMT);
if( GMT_fn_xMultipleTestCollideIdentifierFromGameMaterial(hGMT,_wMaterialMask) )
return hGMT;
break;
case GEO_C_xElementSpheres:
/* One GameMaterial by sphere */
/* Oliv' - Achtung ! the function is re-evaluated each time in the FOR loop !!*/
xIndexMax = GEO_lGetIndexedSphereNbSpheres( _hGeoObj, xNbElements );
/* for( xIndex=0; xIndex<GEO_lGetIndexedSphereNbSpheres(_hGeoObj,xNbElements); xIndex++ )*/
for( xIndex=0; xIndex<xIndexMax; xIndex++ )
/* EndOfOliv'*/
{
hGMT = GEO_hGetGameMaterialOfIndexedSphere(_hGeoObj,xNbElements,xIndex);
if( GMT_fn_xMultipleTestCollideIdentifierFromGameMaterial(hGMT,_wMaterialMask) )
return hGMT;
}
break;
case GEO_C_xElementAlignedBoxes:
/* Oliv' - Achtung ! the function is re-evaluated each time in the FOR loop !!*/
xIndexMax = GEO_lGetAlignedBoxNbBoxes( _hGeoObj, xNbElements );
/* for( xIndex=0; xIndex<GEO_lGetAlignedBoxNbBoxes(_hGeoObj,xNbElements); xIndex++ )*/
for( xIndex=0; xIndex<xIndexMax; xIndex++ )
/* EndOfOliv'*/
{
hGMT = GEO_vGetGameMaterialOfIndexedAlignedBox(_hGeoObj,xNbElements,xIndex);
if( GMT_fn_xMultipleTestCollideIdentifierFromGameMaterial(hGMT,_wMaterialMask) )
return hGMT;
}
break;
case GEO_C_xElementCones:
/* Oliv' - Achtung ! the function is re-evaluated each time in the FOR loop !!*/
xIndexMax = GEO_lGetConeNbCones( _hGeoObj, xNbElements );
/* for( xIndex=0; xIndex<GEO_lGetConeNbCones(_hGeoObj,xNbElements); xIndex++ )*/
for( xIndex=0; xIndex<xIndexMax; xIndex++ )
/* EndOfOliv'*/
{
hGMT = GEO_vGetGameMaterialOfIndexedCone(_hGeoObj,xNbElements,xIndex);
if( GMT_fn_xMultipleTestCollideIdentifierFromGameMaterial(hGMT,_wMaterialMask) )
return hGMT;
}
break;
case GEO_C_xElementPoints:
hGMT = GEO_xGetGameMaterialOfElementPoints(_hGeoObj,xNbElements);
if( GMT_fn_xMultipleTestCollideIdentifierFromGameMaterial(hGMT,_wMaterialMask) )
return hGMT;
break;
/* Nothing to do with these things */
case GEO_C_xElementNULL:
//XB99/04/27
#ifndef U64
case GEO_C_xElementFaceMapDescriptors:
#endif U64
//End XB99/04/27
case GEO_C_xElementSprites:
//XB99/04/27
#ifndef U64
case GEO_C_xElementTMeshes:
#endif U64
//End XB99/04/27
case GEO_C_xElementLines:
break;
default:
break;
}
}
return NULL;
}
/*--------------------------------------------------------------------
* Detect if a character is in a ZDD
* OPTIMIZED : 1
*--------------------------------------------------------------------*/
ACP_tdxBool fn_bIsCharacterInZdd(ACP_tdxHandleOfObject _hGeoObj,POS_tdstCompletePosition * _p_stMatrix,HIE_tdxHandleToSuperObject _hCharacter)
{
POS_tdstCompletePosition stMatrix;
MTH3D_tdstVector stPosition;
/* jt 020699 */
if(!M_ObjectIsActive ((tdstEngineObject*)HIE_fn_hGetSuperObjectObject(_hCharacter)) )
return FALSE;
/* end jt 020699 */
/* ANNECY MT - 18/09/98 {*/
POS_fn_vInvertMatrix(&stMatrix,_p_stMatrix);
POS_fn_vMulMatrixVertex(&stPosition,&stMatrix,POS_fn_p_stGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter)));
/* END ANNECY MT }*/
return( INT_fn_bGetInclusionPointInGeometricObject(&stPosition,_hGeoObj) );
}
/*--------------------------------------------------------------------
* Return current activation set
* OPTIMIZED : 1
*--------------------------------------------------------------------*/
ZDX_tdxHandleToZoneSetList fn_p_stGetCurrentZoneSetOfType2(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj)
{
if( M_GetMSHandle(hSuperObj,CollSet) )
return( fn_hGetCurrentZoneSetOfType(ucZoneType,M_GetMSHandle(hSuperObj,CollSet)) );
return NULL;
}
/*--------------------------------------------------------------------
* Update activation list for a character, to decrease calls to LST
* macros
* OPTIMIZED : 2
*--------------------------------------------------------------------*/
void fn_vUpdateCurrentActivationForCharacter(HIE_tdxHandleToSuperObject _hCharacter)
{
ACP_tdxIndex xIndex,xI;
tdstZoneSetEncapsulation * p_stZSE;
ZDX_tdxHandleToCsaList hCsaList = NULL;
tdxHandleToState hStateTmp,hFirstState;
MS_tdxHandleToCollSet hCollSet;
LST2_M_StaticAnchorDeclaration(tdxHandleToState)* hAnchor;
hCollSet = M_GetMSHandle(_hCharacter,CollSet);
if( !hCollSet )
return;
/* Get number of state in list*/
hFirstState = fn_h3dDataGetCurrentState(M_GetMSHandle(_hCharacter,3dData));
hAnchor=& fn_h3dDataGetFamily(M_GetMSHandle(_hCharacter,3dData))->hForStateArray;
LST3_M_StaticWhatElementNumber(hFirstState,hAnchor,hStateTmp,xIndex); /* Changed for binarisation*/
/* ZDD*/
hCsaList=CS_fn_hGetActivationList(C_ucTypeZdd,_hCharacter);
if( hCsaList )
{
LST2_M_StaticGetElementNumber(&hCsaList->hZoneSetEncapsulationList,p_stZSE,xIndex,xI);
fn_vSetCurrentZoneSetOfType(C_ucTypeZdd,hCollSet,(ZDX_tdxHandleToZoneSetList)p_stZSE->p_stZoneSetList);
}
else
{
fn_vSetCurrentZoneSetOfType(C_ucTypeZdd,hCollSet,(ZDX_tdxHandleToZoneSetList)NULL);
}
/* ZDE*/
hCsaList=CS_fn_hGetActivationList(C_ucTypeZde,_hCharacter);
if( hCsaList )
{
LST2_M_StaticGetElementNumber(&hCsaList->hZoneSetEncapsulationList,p_stZSE,xIndex,xI);
fn_vSetCurrentZoneSetOfType(C_ucTypeZde,hCollSet,(ZDX_tdxHandleToZoneSetList)p_stZSE->p_stZoneSetList);
}
else
{
fn_vSetCurrentZoneSetOfType(C_ucTypeZde,hCollSet,(ZDX_tdxHandleToZoneSetList)NULL);
}
/* ZDR*/
hCsaList=CS_fn_hGetActivationList(C_ucTypeZdr,_hCharacter);
if( hCsaList )
{
LST2_M_StaticGetElementNumber(&hCsaList->hZoneSetEncapsulationList,p_stZSE,xIndex,xI);
fn_vSetCurrentZoneSetOfType(C_ucTypeZdr,hCollSet,(ZDX_tdxHandleToZoneSetList)p_stZSE->p_stZoneSetList);
}
else
{
fn_vSetCurrentZoneSetOfType(C_ucTypeZdr,hCollSet,(ZDX_tdxHandleToZoneSetList)NULL);
}
/* ZDM*/
hCsaList=CS_fn_hGetActivationList(C_ucTypeZdm,_hCharacter);
if( hCsaList )
{
LST2_M_StaticGetElementNumber(&hCsaList->hZoneSetEncapsulationList,p_stZSE,xIndex,xI);
fn_vSetCurrentZoneSetOfType(C_ucTypeZdm,hCollSet,(ZDX_tdxHandleToZoneSetList)p_stZSE->p_stZoneSetList);
}
else
{
fn_vSetCurrentZoneSetOfType(C_ucTypeZdm,hCollSet,(ZDX_tdxHandleToZoneSetList)NULL);
}
}
/*--------------------------------------------------------------------
*********************************************************************
* OPTIMISATION FUNCTIONS END BLOCK
*********************************************************************
*--------------------------------------------------------------------*/
/*----------------------------------------------------------------------
* Internal functions declarations
*--------------------------------------------------------------------*/
void fn_vSortZoneSetList(tdstCsaList * p_stCsaList);
/*----------------------------------------------------------------------
* Creation of the List of Zdx Geometric objects
*--------------------------------------------------------------------*/
#if defined(GAM_USE_SCRIPT)
/* script only*/
SCR_tde_Anl_ReturnValue fn_eScriptCallBackZdxArrayDescription(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;
tdstZdxList * p_stZdxList;
tdstGeometricZdxList * p_stGeoZdxList;
ACP_tdxHandleOfObject hGeoObj;
#if defined(ACTIVE_EDITOR)
char a255_cLinkKey[255];
#endif /* ACTIVE_EDITOR */
_p_stFile=_p_stFile;
if(M_IsTitle)
{
M_CheckScriptParamNumber(2);
p_stZdxList=fn_p_stCreateZdxListElement();
p_stZdxList->uwNumberOfZdx=(unsigned short)fn_lAToI(_ap_szParams[1]);
SCR_M_RdL0_SetSectionLong(C_ThisSection,0,p_stZdxList);
}
else if (M_IsEntry)
{
char szForScript[_MAX_PATH];
SCR_M_RdL0_GetSectionLong(C_ThisSection,0,tdstZdxList *,p_stZdxList);
if( M_ActionIs(C_EntryGeometricObject) )
{
char szFileName[_MAX_PATH];
M_CheckScriptParamNumber(1);
p_stGeoZdxList=fn_p_stCreateGeometricZdxListElement();
hGeoObj=GLI_pLoadGeometricInFile(_ap_szParams[0]);
/*COL_fn_bCreateOctree(hGeoObj,5,10,3);*/
GEO_vCreateObjectListOfPointsMaterial ( hGeoObj );
GEO_vComputeObjectListOfPointsMaterial(hGeoObj);
p_stGeoZdxList->hGeoObj=hGeoObj;
LST2_M_StaticAddTail(&p_stZdxList->hGeoZdxList,p_stGeoZdxList);
strcpy(szForScript,fn_szGetZdxDataPath());
strcat(szForScript,"\\");
fn_v_File_ComputeFileSectionName(_ap_szParams[0],szFileName,szForScript+strlen(szForScript));
/* LinkTable management*/
#if defined(ACTIVE_EDITOR)
SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
SCR_M_v_Link_SetAdditionalLong(
SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stCharacterZone,
a255_cLinkKey,(unsigned long)p_stGeoZdxList),
1,
strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
#endif /* ACTIVE_EDITOR */
}
else if (M_ActionIs("Nothing"))
{
p_stGeoZdxList=fn_p_stCreateGeometricZdxListElement();
p_stGeoZdxList->hGeoObj = NULL;
LST2_M_StaticAddTail(&p_stZdxList->hGeoZdxList,p_stGeoZdxList);
}
else
{
M_GameInformationError(E_uwGameScriptCallBackDescriptionUnknownAction);
}
}
return(eReturnValue);
}
void fn_vInsertZSEInZoneSetList(tdstCsaList * p_stCsaList,tdstZoneSetEncapsulation *p_stZSE);
/*----------------------------------------------------------------------
* Create the list of zone set
*--------------------------------------------------------------------*/
/* script only*/
SCR_tde_Anl_ReturnValue fn_eScriptCallBackCreateNewZoneSetArray(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;
tdstZoneSetEncapsulation * p_stZSE;
tdstZoneSetList * p_stZoneSetList;
tdstCsaList * p_stCsaList;
tdxHandleToFamilyList hFamily;
if(M_IsTitle)
{
char szFileName[_MAX_PATH+2];
char *p_cEnd;
/* MR1104*/
/*M_CheckScriptParamNumber(1);*/
p_stCsaList=fn_p_stCreateCsaListElement();
SCR_M_RdL0_SetSectionLong(C_ThisSection,0,p_stCsaList);
hFamily = NULL;
strcpy (szFileName , SCR_M_RdL0_GetOpenFileNameR(0) + strlen (fn_szGetFamiliesDataPath()) + 1);
p_cEnd = strchr (szFileName, '\\');
if (p_cEnd)
{
tdObjectType otType;
*p_cEnd = 0;
otType = fn_otFindFamilyTypeOfFamilyTypeName (szFileName);
if (otType != -1)
hFamily = fn_hFindFamily (otType);
}
SCR_M_RdL0_SetSectionLong(C_ThisSection,1,hFamily);
}
else if (M_IsEntry)
{
SCR_M_RdL0_GetSectionLong(C_ThisSection,0,tdstCsaList *,p_stCsaList);
SCR_M_RdL0_GetSectionLong(C_ThisSection,1,tdxHandleToFamilyList,hFamily);
if (hFamily == NULL)
return (eReturnValue);
if( M_ActionIs(C_EntryActivationZone) )
{
SCR_tdst_Cxt_Values *p_stValues ;
char szSectionName[_MAX_PATH+2];
char szFileName[_MAX_PATH+2];
SCR_tdst_Link_Value *stLinkValue;
short uwIndex;
strcpy(szSectionName,fn_szGetFamiliesDataPath());
strcat(szSectionName,"\\");
fn_v_File_ComputeFileSectionName(_ap_szParams[0],szFileName,szSectionName+strlen(szSectionName));
M_CheckScriptParamNumber(2);
{
tdxHandleToState hState2,hState;
char szSectionName2[_MAX_PATH+2];
strcpy(szSectionName2,fn_szGetFamiliesDataPath());
strcat(szSectionName2,"\\");
strcat(szSectionName2,_ap_szParams[1]);
stLinkValue=SCR_fnp_st_Link_CreateOrGetLinkFromKey( &g_st3DOSLinkTable.stState, szSectionName2);
hState=(tdxHandleToState)stLinkValue->ulValue;
LST3_M_StaticWhatElementNumber(hState,&hFamily->hForStateArray,hState2,uwIndex);
}
/* MR1004*/
stLinkValue=SCR_fnp_st_Link_CreateOrGetLinkFromKey( &g_st3DOSLinkTable.stACZ, szSectionName);
p_stValues=SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
p_stZoneSetList=(ZDX_tdxHandleToZoneSetList)(p_stValues->a_ulValues[0]);
p_stZSE = fn_p_stCreateZoneSetEncapsulation();
p_stZSE->uwIndex=uwIndex;
p_stZSE->p_stZoneSetList = p_stZoneSetList;
/*LST2_M_StaticAddTail(&p_stCsaList->hZoneSetEncapsulationList,p_stZSE);*/
fn_vInsertZSEInZoneSetList(p_stCsaList,p_stZSE);
}
else
{
M_GameInformationError(E_uwGameScriptCallBackDescriptionUnknownAction);
}
}
else if(M_IsEnd)
{
/*** Sorting the list to speed up ***/
SCR_M_RdL0_GetSectionLong(C_ThisSection,0,tdstCsaList *,p_stCsaList);
/*fn_vSortZoneSetList(p_stCsaList);*/
}
return(eReturnValue);
}
#endif /* GAM_USE_SCRIPT */
/*----------------------------------------------------------------------
* Sorting the ZoneSetList in p_stCsaList, to speed up access
* OPTIMIZED : 0
*--------------------------------------------------------------------*/
/*
void fn_vSortZoneSetList(tdstCsaList * p_stCsaList)
{
#ifdef U64
tdstZoneSetEncapsulation * p_stZSE;
// tdstZoneSetEncapsulation * p_stZSE2;
tdstZoneSetEncapsulation * p_stZSE3;
unsigned short uwIndex1,uwIndex2;
unsigned short uwPosition;
LST2_M_StaticForEachElementOf(&p_stCsaList->hZoneSetEncapsulationList,p_stZSE,uwIndex1)
{
uwPosition = p_stZSE->uwIndex;
LST2_M_StaticForEachElementOf(&p_stCsaList->hZoneSetEncapsulationList,p_stZSE3,uwIndex2)
{
if( p_stZSE3->uwIndex > uwPosition )
{
// Insert p_stZoneSetList before p_stZoneSetList3
LST2_M_StaticIsolate(p_stZSE);
LST2_M_StaticInsertBetween(p_stZSE,LST2_M_StaticGetPrevElement(p_stZSE3),p_stZSE3);
//goto END_INTERNAL_LOOP;
break;
}
else if( p_stZSE3->uwIndex == uwPosition )
{
//goto END_INTERNAL_LOOP;
break;
} }
////END_INTERNAL_LOOP:;
}
#endif
}
*/
#ifndef LST2_StaticIsOptimised
void fn_vInsertZSEInZoneSetList(tdstCsaList * p_stCsaList,tdstZoneSetEncapsulation *p_stZSE)
{
tdstZoneSetEncapsulation *p_stZSECurrent;
tdstZoneSetEncapsulation *p_stZSENext;
if (LST2_M_StaticGetNumberOfElements(&p_stCsaList->hZoneSetEncapsulationList)==0)
{
LST2_M_StaticAddTail(&p_stCsaList->hZoneSetEncapsulationList,p_stZSE);
}
else
{
/* add on tail*/
p_stZSECurrent = LST2_M_StaticGetLastElement(&p_stCsaList->hZoneSetEncapsulationList);
if (p_stZSE->uwIndex > p_stZSECurrent->uwIndex)
{
LST2_M_StaticAddTail(&p_stCsaList->hZoneSetEncapsulationList,p_stZSE);
}
else
{
/* add on head*/
p_stZSECurrent = LST2_M_StaticGetFirstElement(&p_stCsaList->hZoneSetEncapsulationList);
if (p_stZSE->uwIndex < p_stZSECurrent->uwIndex)
{
LST2_M_StaticAddHead(&p_stCsaList->hZoneSetEncapsulationList,p_stZSE);
}
else
{
/* insert on list*/
p_stZSENext = LST2_M_StaticGetNextElement(p_stZSECurrent);
while ((p_stZSENext != LST2_C_StaticInvalid) && (p_stZSENext->uwIndex < p_stZSE->uwIndex))
{
p_stZSECurrent = p_stZSENext;
p_stZSENext = LST2_M_StaticGetNextElement(p_stZSENext);
}
LST3_M_StaticInsertBetween(&p_stCsaList->hZoneSetEncapsulationList,p_stZSE,p_stZSECurrent,p_stZSENext);
}
}
}
}
#endif /*LST2_StaticIsOptimised*/
#if defined(LST2_StaticIsOptimised)
#ifndef D_THROW_ZSE_INDEX /* Oliv' - 21/06/1999 */
int fn_iCmpZoneSetIndex(const void *p_stZSE1,const void *p_stZSE2)
{
int iIndexDiff;
iIndexDiff=((tdstZoneSetEncapsulation *)p_stZSE1)->uwIndex-((tdstZoneSetEncapsulation *)p_stZSE2)->uwIndex;
return iIndexDiff;
}
void fn_vSortZoneSetList(tdstCsaList * p_stCsaList)
{
qsort(
LST2_M_StaticGetFirstElement(&p_stCsaList->hZoneSetEncapsulationList),
LST2_M_StaticGetNumberOfElements(&p_stCsaList->hZoneSetEncapsulationList),
sizeof(tdstZoneSetEncapsulation),
fn_iCmpZoneSetIndex);
/*
Oliv' - DEBUG
{
tdstZoneSetEncapsulation *p_stZSE;
long lIndex, lMax = LST2_M_StaticGetNumberOfElements(&p_stCsaList->hZoneSetEncapsulationList);
osSyncPrintf( "---> New CsaList <---\n" );
for (
lIndex=0, p_stZSE=LST2_M_StaticGetFirstElement(&p_stCsaList->hZoneSetEncapsulationList);
lIndex < lMax;
lIndex++, p_stZSE=LST2_M_StaticGetNextElement(p_stZSE)
)
{
if( p_stZSE->uwIndex != lIndex )
{
osSyncPrintf( " ERROR ->" );
}
osSyncPrintf( " [%02d] @ 0x%x\n", p_stZSE->uwIndex, p_stZSE->p_stZoneSetList );
}
}
EndOfOliv'
*/
}
#endif /* D_THROW_ZSE_INDEX */
#endif /*LST2_StaticIsOptimised*/
/*----------------------------------------------------------------------
* Correcting Activation list by inserting NULL cases in the table
* OPTIMIZED : 0
*--------------------------------------------------------------------*/
/* used*/
#ifndef D_THROW_ZSE_INDEX /* Oliv' - 21/06/1999 */
void fn_vCorrectActivationList(tdstCsaList * _p_stCsaList,long _lNumberOfState)
{
#if !defined(LST2_StaticIsOptimised)
tdstZoneSetEncapsulation * p_stZSENew;
tdstZoneSetEncapsulation * p_stZSECurrent;
tdstZoneSetEncapsulation * p_stZSENext;
unsigned short uwIndex , uwNextIndex;
if (LST2_M_StaticGetNumberOfElements(&_p_stCsaList->hZoneSetEncapsulationList)==0)
{
/* fill all th list*/
for ( uwIndex = 0 ; uwIndex < _lNumberOfState ; uwIndex++ )
{
p_stZSENew = fn_p_stCreateZoneSetEncapsulation();
p_stZSENew->uwIndex = uwIndex;
LST2_M_StaticAddTail(&_p_stCsaList->hZoneSetEncapsulationList,p_stZSENew);
}
}
else
{
/* insert on head*/
p_stZSECurrent = LST2_M_StaticGetFirstElement(&_p_stCsaList->hZoneSetEncapsulationList);
uwIndex = p_stZSECurrent->uwIndex;
while (uwIndex>0)
{
uwIndex--;
p_stZSENew = fn_p_stCreateZoneSetEncapsulation();
p_stZSENew->uwIndex = uwIndex;
LST2_M_StaticAddHead(&_p_stCsaList->hZoneSetEncapsulationList,p_stZSENew);
}
/* insert in list*/
p_stZSENext = LST2_M_StaticGetNextElement(p_stZSECurrent);
while (p_stZSENext!=LST2_C_StaticInvalid)
{
uwIndex = (unsigned short) (p_stZSECurrent->uwIndex+1);
uwNextIndex = p_stZSENext->uwIndex;
while (uwIndex < uwNextIndex)
{
p_stZSENew = fn_p_stCreateZoneSetEncapsulation();
p_stZSENew->uwIndex = uwIndex;
LST3_M_StaticInsertBetween(&_p_stCsaList->hZoneSetEncapsulationList,p_stZSENew,p_stZSECurrent,p_stZSENext);
p_stZSECurrent = p_stZSENew;
uwIndex++;
}
p_stZSECurrent = p_stZSENext;
p_stZSENext = LST2_M_StaticGetNextElement(p_stZSENext);
}
/* insert on tail*/
p_stZSECurrent = LST2_M_StaticGetLastElement(&_p_stCsaList->hZoneSetEncapsulationList);
uwIndex = (unsigned short) (p_stZSECurrent->uwIndex+1);
while (uwIndex < _lNumberOfState)
{
p_stZSENew = fn_p_stCreateZoneSetEncapsulation();
p_stZSENew->uwIndex = uwIndex;
LST2_M_StaticAddTail(&_p_stCsaList->hZoneSetEncapsulationList,p_stZSENew);
uwIndex++;
}
}
if (LST2_M_StaticGetNumberOfElements(&_p_stCsaList->hZoneSetEncapsulationList) > _lNumberOfState)
{
M_GameWarningError(E_uwGameBadNumberOfStatesInActivationList);
Erm_M_ClearLastError(C_ucErmDefaultChannel);
}
#else
unsigned short uwPosition;
tdstZoneSetEncapsulation * p_stZSE;
tdstZoneSetEncapsulation * p_stZSE2;
int iModificationFlag;
iModificationFlag=0;
for(uwPosition=0,
p_stZSE =LST2_M_StaticGetFirstElement(&_p_stCsaList->hZoneSetEncapsulationList),
p_stZSE2=LST2_M_StaticGetLastElement(&_p_stCsaList->hZoneSetEncapsulationList);
p_stZSE<p_stZSE2;
uwPosition++) {
if(p_stZSE->uwIndex>uwPosition) {
iModificationFlag=~0;
p_stZSE2->uwIndex=uwPosition;
p_stZSE2=LST2_M_StaticGetPrevElement(p_stZSE);
} else
p_stZSE =LST2_M_StaticGetNextElement(p_stZSE);
}
if(iModificationFlag)
fn_vSortZoneSetList(_p_stCsaList);
#endif
}
#endif /* D_THROW_ZSE_INDEX */
/*----------------------------------------------------------------------
* Access functions
* OPTIMIZED : 0
*--------------------------------------------------------------------*/
unsigned short fn_uwGetIndexFromZdxIndexList(tdstZdxIndexList * p_stZdxIndexList)
{
#ifdef ACTIVE_EDITOR
if( !p_stZdxIndexList )
return 0;
#endif
return( p_stZdxIndexList->uwZdxIndex );
}
/*--------------------------------------------------------------------
* Return activation list linked to the current state
* OPTIMIZED : 0
*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_
tdstZoneSetList * fn_p_stGetCurrentZoneSetOfType(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj)
{
short uwI;
int iIndex; /* AR971127 -> int for LST*/
tdstZoneSetEncapsulation * p_stZSE;
ZDX_tdxHandleToCsaList hCsaList = NULL;
tdxHandleToState hStateTmp;
LST2_M_StaticAnchorDeclaration(tdxHandleToState)* hAnchor;
hCsaList=CS_fn_hGetActivationList(ucZoneType,hSuperObj);
if( !hCsaList )
return NULL;
hAnchor=& fn_h3dDataGetFamily(M_GetMSHandle(hSuperObj,3dData))->hForStateArray;
LST3_M_StaticWhatElementNumber(
fn_h3dDataGetCurrentState(M_GetMSHandle(hSuperObj,3dData)),hAnchor,
hStateTmp,iIndex); /* changed for binarisation*/
LST2_M_StaticGetElementNumber(&hCsaList->hZoneSetEncapsulationList,p_stZSE,iIndex,uwI);
return( (ZDX_tdxHandleToZoneSetList)p_stZSE->p_stZoneSetList );
}
#endif /* _FIRE_DEADCODE_U64_ */
/*--------------------------------------------------------------------
* return index in ZdxList from index in ActivationList
* OPTIMIZED : 0
*--------------------------------------------------------------------*/
/*
unsigned short fn_uwGetIndexOfZdx(unsigned char ucZoneNumber,tdstZoneSetList * p_stZoneSetList)
{
unsigned short uwI;
tdstZdxIndexList * p_stZdxIndexList;
#ifdef ACTIVE_EDITOR
if( !p_stZoneSetList )
return 0;
#endif
LST2_M_StaticGetElementNumber(&p_stZoneSetList->hZdxIndexList,p_stZdxIndexList,(ucZoneNumber-1),uwI);
return p_stZdxIndexList->uwZdxIndex;
}
*/
/*--------------------------------------------------------------------
* return Geometric object from index in ZdxList
* OPTIMIZED : 1
*--------------------------------------------------------------------*/
ACP_tdxHandleOfObject fn_hGetGeometricZdxOfTypeAtIndex(
unsigned char ucZoneType,
unsigned short uwIndex,
HIE_tdxHandleToSuperObject hSuperObj)
{
tdstGeometricZdxList * p_stGeoZdxList;
tdstZdxList * p_stZdxList;
unsigned short uwI;
p_stZdxList=(tdstZdxList *)CS_fn_hGetZdxList(ucZoneType,hSuperObj);
#ifdef ACTIVE_EDITOR
if( !p_stZdxList )
return NULL;
#endif
#ifdef _DEBUG
if( uwIndex>=LST2_M_StaticGetNumberOfElements(&p_stZdxList->hGeoZdxList) )
return NULL;
#endif /* _DEBUG */
LST2_M_StaticGetElementNumber(&p_stZdxList->hGeoZdxList,p_stGeoZdxList,uwIndex,uwI);
return(p_stGeoZdxList->hGeoObj);
}
/*--------------------------------------------------------------------
* Set Geometric object from index in ZdxList
* OPTIMIZED : 1
*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_
void fn_vSetGeometricZdxOfTypeAtIndex(unsigned char ucZoneType,unsigned short uwIndex,HIE_tdxHandleToSuperObject hSuperObj,ACP_tdxHandleOfObject hGeoObj)
{
tdstGeometricZdxList * p_stGeoZdxList;
tdstZdxList * p_stZdxList = NULL;
unsigned short uwI;
p_stZdxList=CS_fn_hGetZdxList(ucZoneType,hSuperObj);
#ifdef ACTIVE_EDITOR
if( !p_stZdxList )
return;
#endif
LST2_M_StaticGetElementNumber(&p_stZdxList->hGeoZdxList,p_stGeoZdxList,uwIndex,uwI);
p_stGeoZdxList->hGeoObj=hGeoObj;
}
#endif /* _FIRE_DEADCODE_U64_ */
/*----------------------------------------------------------------------
* Memory Management
*--------------------------------------------------------------------*/
tdstZdxList * fn_p_stCreateZdxListElement()
{
tdstZdxList * p_stZdxList;
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeZdxListElement , 0 );
p_stZdxList=(tdstZdxList *)M_p_GameMallocInHLM(sizeof(tdstZdxList));
LST2_M_StaticInitAnchor(&p_stZdxList->hGeoZdxList);
return p_stZdxList;
}
/*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdstZdxIndexList * fn_p_stCreateZdxIndexListElement()
{
tdstZdxIndexList * p_stZdxIndexList;
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeZdxIndexListElement , 0 );
p_stZdxIndexList=(tdstZdxIndexList *)M_p_GameMallocInHLM(sizeof(tdstZdxIndexList));
LST2_M_StaticInitElement(p_stZdxIndexList);
return p_stZdxIndexList;
}
/*--------------------------------------------------------------------*/
tdstGeometricZdxList * fn_p_stCreateGeometricZdxListElement()
{
tdstGeometricZdxList * p_stGeometricZdxList;
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeGeometricZdxListElement , 0 );
p_stGeometricZdxList=(tdstGeometricZdxList *)M_p_GameMallocInHLM(sizeof(tdstGeometricZdxList));
p_stGeometricZdxList->hGeoObj=NULL;
LST2_M_StaticInitElement(p_stGeometricZdxList);
return p_stGeometricZdxList;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*--------------------------------------------------------------------*/
tdstZoneSetList * fn_p_stCreateZoneSetListElement()
{
tdstZoneSetList * p_stZoneSetList;
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeZoneSetListElement , 0 );
p_stZoneSetList=(tdstZoneSetList *)M_p_GameMallocInHLM(sizeof(tdstZoneSetList));
LST2_M_StaticInitAnchor(&p_stZoneSetList->hZdxIndexList);
return p_stZoneSetList;
}
/*--------------------------------------------------------------------*/
tdstCsaList * fn_p_stCreateCsaListElement()
{
tdstCsaList * p_stCsaList;
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeCsaListElement , 0 );
p_stCsaList=(tdstCsaList *)M_p_GameMallocInHLM(sizeof(tdstCsaList));
LST2_M_StaticInitAnchor(&p_stCsaList->hZoneSetEncapsulationList);
return p_stCsaList;
}
/*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vFreeZdxListElement(tdstZdxList * p_stZdxList)
{
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeZdxListElement , 0 );
M_GameFreeInHLM(p_stZdxList);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_
void fn_vFreeZdxIndexListElement(tdstZdxIndexList * p_stZdxIndexList)
{
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeZdxIndexListElement , 0 );
M_GameFreeInHLM(p_stZdxIndexList);
}
#endif /* _FIRE_DEADCODE_U64_ */
/*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vFreeGeometricZdxListElement(tdstGeometricZdxList * p_stGeoZdxList)
{
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeGeometricZdxListElement , 0 );
M_GameFreeInHLM(p_stGeoZdxList);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_
void fn_vFreeZoneSetListElement(tdstZoneSetList * p_stZoneSetList)
{
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeZoneSetListElement , 0 );
M_GameFreeInHLM(p_stZoneSetList);
}
/*--------------------------------------------------------------------*/
void fn_vFreeCsaListElement(tdstCsaList * p_stCsaList)
{
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeCsaListElement , 0 );
M_GameFreeInHLM(p_stCsaList);
}
#endif /* _FIRE_DEADCODE_U64_ */
/*----------------------------------------------------------------------
* Miscellaneous functions
*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_
ACP_tdxHandleOfObject ZDX_fn_hGetGeometricZdxInListAtIndex(unsigned short uwIndex,ZDX_tdxHandleToZdxList hZdxList)
{
ZDX_tdxHandleToGeoZdxList hGeoZdxList;
unsigned short uwI;
#ifdef ACTIVE_EDITOR
if( !hZdxList )
return NULL;
#endif
LST2_M_StaticGetElementNumber(&hZdxList->hGeoZdxList,hGeoZdxList,uwIndex,uwI);
return(hGeoZdxList->hGeoObj);
}
/*--------------------------------------------------------------------*/
void ZDX_fn_vSetGeometricZdxInListAtIndex(unsigned short uwIndex,ZDX_tdxHandleToZdxList hZdxList,ACP_tdxHandleOfObject hGeoObj)
{
ZDX_tdxHandleToGeoZdxList hGeoZdxList;
unsigned short uwI;
LST2_M_StaticGetElementNumber(&hZdxList->hGeoZdxList,hGeoZdxList,uwIndex,uwI);
hGeoZdxList->hGeoObj = hGeoObj;
}
/*--------------------------------------------------------------------*/
ACP_tdxHandleOfObject fn_hGetGeoObjFromGeoZdx(ZDX_tdxHandleToGeoZdxList hGeoZdxList)
{
return(((tdstGeometricZdxList *)hGeoZdxList)->hGeoObj);
}
/*--------------------------------------------------------------------*/
void fn_vSetGeoObjInGeoZdx(ZDX_tdxHandleToGeoZdxList hGeoZdxList,ACP_tdxHandleOfObject hGeoObj)
{
((tdstGeometricZdxList *)hGeoZdxList)->hGeoObj=hGeoObj;
}
#endif /* _FIRE_DEADCODE_U64_ */
/*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
ZDX_tdxHandleToZdxIndexList ZDX_fn_hGetFirstZdxIndexListOfTypeInZoneSet(unsigned char ucZoneType,ZDX_tdxHandleToZoneSetList hZoneSet)
{
return( LST2_M_StaticGetFirstElement( &hZoneSet->hZdxIndexList ) );
}
/*--------------------------------------------------------------------*/
ZDX_tdxHandleToZdxIndexList ZDX_fn_hGetNextBrotherInZdxIndexList(ZDX_tdxHandleToZdxIndexList hZdxIndexList)
{
return( LST2_M_StaticGetNextElement(hZdxIndexList) );
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------
* This function is only for editors
*--------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_
unsigned short fn_uwGetNumberOfGeoObjInList(ZDX_tdxHandleToZdxList hZdxList)
{
return( ((tdstZdxList *)hZdxList)->uwNumberOfZdx );
}
#endif /* _FIRE_DEADCODE_U64_ */
/*--------------------------------------------------------------------*/
/* Oliv' - 19/05/1999 - I want to see Zdx too */
#if defined(_DEBUG) || defined(_U64_GLI_BENCH_)
/* EndOfOliv' */
/* debug*/
void fn_vZdxDisplayForPhysical(
GLD_tdstViewportAttributes * _p_stViewPort,
HIE_tdxHandleToSuperObject _hPhysical,
long _lDrawMask)
{
ACP_tdxHandleOfObject hGeoObj;
PCS_tdxHandleToPhysicalCollSet hPhysicalCollideSet;
HIE_fn_bStoreMatrix(HIE_fn_hGetSuperObjectGlobalMatrix(_hPhysical));
HIE_fn_vPushOnCameraMatrixStack(_hPhysical);
hPhysicalCollideSet = PO_fn_hGetCollideSet( (PO_tdxHandleToPhysicalObject)HIE_fn_hGetSuperObjectObject(_hPhysical) );
if( hPhysicalCollideSet )
{
if( _lDrawMask&C_lModuleZdxAreOn && _lDrawMask&C_lZddAreOn )
{
hGeoObj = PCS_fn_hGetZddGeoObjOfPhysicalCollSet(hPhysicalCollideSet);
if( hGeoObj )
{
GLI_xSendObjectToViewport(_p_stViewPort,hGeoObj,gp_stLight,ZDX_C_lDrawMask);
}
}
if( _lDrawMask&C_lModuleZdxAreOn && _lDrawMask&C_lZdeAreOn )
{
hGeoObj = PCS_fn_hGetZdeGeoObjOfPhysicalCollSet(hPhysicalCollideSet);
if( hGeoObj )
{
GLI_xSendObjectToViewport(_p_stViewPort,hGeoObj,gp_stLight,ZDX_C_lDrawMask);
}
}
if( _lDrawMask&C_lModuleZdxAreOn && _lDrawMask&C_lZdrAreOn )
{
hGeoObj = PCS_fn_hGetZdrGeoObjOfPhysicalCollSet(hPhysicalCollideSet);
if( hGeoObj )
{
GLI_xSendObjectToViewport(_p_stViewPort,hGeoObj,gp_stLight,ZDX_C_lDrawMask);
}
}
}
HIE_fn_vPopMatrix();
HIE_fn_vPopOnCameraMatrixStack();
}
/* debug*/
void fn_vZdxDisplayZonesListForCharacter( GLD_tdstViewportAttributes * _p_stViewPort,
HIE_tdxHandleToSuperObject _hCharacter,
unsigned char _ucZoneType)
{
ACP_tdxIndex xI;
ZDX_tdxHandleToZoneSetList p_stZoneSet;
ZDX_tdxHandleToZdxIndexList p_stZdxIndex;
tdeCollSetPrivilegedActivation ePrivilege;
unsigned short uwCurrentIndexInActivation;
ACP_tdxHandleOfObject hGeoObj;
/* Deal with ONE's ZDE */
hGeoObj = NULL;
xI = 0;
p_stZoneSet = fn_p_stGetCurrentZoneSetOfType2(_ucZoneType,_hCharacter);
p_stZdxIndex = (p_stZoneSet ? LST2_M_StaticGetFirstElement( &p_stZoneSet->hZdxIndexList ) : LST2_C_StaticInvalid);
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
while( xI < fn_lGetZdxListNumberOfElements(_ucZoneType,_hCharacter) )
{
ePrivilege = fn_eGetPrivilegedActivationZoneOfCharacter(_ucZoneType,_hCharacter,xI);
if( (ePrivilege == edmPriviligedActivated) ||
((ePrivilege == edmPriviligedDefault) && (uwCurrentIndexInActivation == xI)) )
{
hGeoObj=fn_hGetGeometricZdxOfTypeAtIndex(_ucZoneType,xI,_hCharacter);
if( hGeoObj )
{
GLI_xSendObjectToViewport(
_p_stViewPort,
hGeoObj,
gp_stLight,
(ZDX_C_lDrawMask & ~GLI_C_lHasNotSinusEffect) /*remove the sinus effect bit*/
| (HIE_fn_lGetSuperObjectDrawMask(_hCharacter) & GLI_C_lHasNotSinusEffect) /*put the bit of the parent character instead*/
);
}
}
xI++;
if( (p_stZdxIndex != LST2_C_StaticInvalid) && (uwCurrentIndexInActivation < xI) )
{
p_stZdxIndex = LST2_M_StaticGetNextElement( p_stZdxIndex );
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
}
}
}
/* debug*/
void fn_vZdxDisplayForCharacter( GLD_tdstViewportAttributes * _p_stViewPort,
HIE_tdxHandleToSuperObject _hCharacter)
{
/* unsigned short uwIndex;*/
ZDX_tdxHandleToZoneSetList p_stZoneSetList;
/* ACP_tdxHandleOfObject hGeoObj;*/
/* ZDX_tdxHandleToZdxIndexList p_stZdxIndexList;*/
ACP_tdxBool bOnPlatform;
HIE_tdxHandleToSuperObject hFather;
long lDrawMask = C_lAllZdxAreOn;
bOnPlatform = FALSE;
hFather = HIE_M_hGetSuperObjectFather(_hCharacter);
if( hFather && (HIE_fn_ulGetSuperObjectType(hFather) == HIE_C_ulActor) && (fn_ucStandardGameGetPlatFormType(M_GetMSHandle(hFather, StandardGame)) != 0) )
{
bOnPlatform = TRUE;
HIE_fn_vPushOnCameraMatrixStack(hFather);
}
HIE_fn_bStoreMatrix(HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter));
HIE_fn_vPushOnCameraMatrixStack(_hCharacter);
if( !CAM_fn_bSuperObjectIsACamera(_hCharacter) )
{
if( M_GetMSHandle( _hCharacter, CollSet ) )
{
lDrawMask = fn_l3dDataGetZdxMask(M_GetMSHandle(_hCharacter,3dData));
/*--- Dealing with ZDDs*/
p_stZoneSetList = fn_p_stGetCurrentZoneSetOfType2(C_ucTypeZdd,_hCharacter);
if( p_stZoneSetList && lDrawMask&C_lCharacterZdxAreOn && lDrawMask&C_lZddAreOn
&& ( (g_ucZDCVisible == 1) || (g_ucZDCVisible == 2) ) )
{
fn_vZdxDisplayZonesListForCharacter(_p_stViewPort, _hCharacter, C_ucTypeZdd);
}
/*--- Dealing with ZDEs*/
p_stZoneSetList = fn_p_stGetCurrentZoneSetOfType2(C_ucTypeZde,_hCharacter);
if( p_stZoneSetList && lDrawMask&C_lCharacterZdxAreOn && lDrawMask&C_lZdeAreOn
&& ( (g_ucZDCVisible == 1) || (g_ucZDCVisible == 3) ) )
{
fn_vZdxDisplayZonesListForCharacter(_p_stViewPort, _hCharacter, C_ucTypeZde);
}
/*--- Dealing with ZDMs*/
p_stZoneSetList=fn_p_stGetCurrentZoneSetOfType2(C_ucTypeZdm,_hCharacter);
if( p_stZoneSetList && lDrawMask&C_lCharacterZdxAreOn && lDrawMask&C_lZdmAreOn
&& ( (g_ucZDCVisible == 1) || (g_ucZDCVisible == 4) ) )
{
fn_vZdxDisplayZonesListForCharacter(_p_stViewPort, _hCharacter, C_ucTypeZdm);
}
/*--- Dealing with ZDRs*/
p_stZoneSetList=fn_p_stGetCurrentZoneSetOfType2(C_ucTypeZdr,_hCharacter);
if( p_stZoneSetList && lDrawMask&C_lCharacterZdxAreOn && lDrawMask&C_lZdrAreOn
&& ( (g_ucZDCVisible == 1) || (g_ucZDCVisible == 5) ) )
{
fn_vZdxDisplayZonesListForCharacter(_p_stViewPort, _hCharacter, C_ucTypeZdr);
}
}
}
/* Dealing with module ZDX*/
{
CHN_tdxHandleToChannel hChannel;
HIE_tdxHandleToSuperObject hModule;
hChannel = fn_h3dDataGetFirstActiveChannel(M_GetMSHandle(_hCharacter,3dData));
while ( hChannel )
{
long lType;
if (hChannel->hZoomSupObject)
hModule = hChannel->hZoomSupObject;
else
hModule = hChannel->hSupObject;
lType = HIE_fn_ulGetSuperObjectType(hModule);
if (lType & (HIE_C_ulPO | HIE_C_ulPO_Mirror ))
fn_vZdxDisplayForPhysical(_p_stViewPort,hModule,lDrawMask);
hChannel = hChannel->p_stNextActiveChannel;
}
}
HIE_fn_vPopMatrix();
HIE_fn_vPopOnCameraMatrixStack();
if( bOnPlatform )
{
HIE_fn_vPopOnCameraMatrixStack();
}
}
/* Oliv' - I don't want this one function - 19/05/1999 */
#if defined(_DEBUG)
/* EndOfOliv' */
extern POS_tdstCompletePosition *g_p_stCurrentInCamCoordsMatrix;
extern POS_tdstCompletePosition *g_p_stCurrentMatrix;
/*ANNECY TQ 11/03/98{*/
/* debug*/
void fn_vBoundingVolumeDisplayForSuperObject( GLD_tdstViewportAttributes * _p_stViewPort,
HIE_tdxHandleToSuperObject _hSuperObject)
{
GEO_tdxHandleToParallelBox hParallelBox;
GEO_tdxHandleToBoundingSphere hBoundingSphere;
POS_tdstCompletePosition stIdentityMatrix;
POS_tdstCompletePosition *hGlobalMatrix;
MTH3D_tdstVector stMaxPoint;
MTH3D_tdstVector stMinPoint;
long lDrawMask;
POS_tdstCompletePosition stCameraMatrixMultipliedByGlobalMatrix;
/* We push the global matrix of the object on the top of the pile
-> It will be used by the viewport */
hGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(_hSuperObject);
HIE_fn_bLoadMatrix(hGlobalMatrix);
lDrawMask = ZDX_C_lDrawMask;
if( !CAM_fn_bSuperObjectIsACamera(_hSuperObject) )
{
if(HIE_fn_SO_bHasABoxBoundingVolume (_hSuperObject))
{
lDrawMask |= GLI_C_lIsNotDrawCollideInformationLight;
hParallelBox = (GEO_tdxHandleToParallelBox)HIE_fn_hGetSuperObjectBoundingVolume(_hSuperObject);
if(hParallelBox)
{
/* The matrix that is on the top of the pile is the global matrix of the object */
/* This matrix is used by the viewport to determine in what axis system, the
coordinates he receives are */
/* For the parallel boxes, the coordinates are in the global axis system, so
we push the identity matrix on the top of the pile */
HIE_fn_vPopMatrix();
POS_fn_vSetIdentityMatrix(&stIdentityMatrix);
HIE_fn_bLoadMatrix(&stIdentityMatrix);
/* Our global geometric object (aligned box) to be sent to the viewport */
if (!g_hBoxGeomObj)
{
ACP_tdxHandleOfElement hAlignedBoxes;
GEO_vCreateGeometricObject(&g_hBoxGeomObj, 2 /* 2 points */, 1 /* 1 element */);
GEO_vCreateElementAlignedBoxes(g_hBoxGeomObj, &hAlignedBoxes, 1);
}
HIE_fn_hGetSuperObjectGlobalMatrix(_hSuperObject);
/* The points do not include the translation of the object */
/* We have to add the translation vector to obtain the coordinates of the box in
the global axis system */
MTH3D_M_vAddVector(&stMaxPoint, GEO_fn_pGetMaxPointOfParallelBox(hParallelBox), &hGlobalMatrix->stTranslationVector);
MTH3D_M_vAddVector(&stMinPoint, GEO_fn_pGetMinPointOfParallelBox(hParallelBox), &hGlobalMatrix->stTranslationVector);
GEO_vSetPointOfObject ( g_hBoxGeomObj,
&stMaxPoint,
1);
GEO_vSetPointOfObject ( g_hBoxGeomObj,
&stMinPoint,
0);
GEO_vSetMinMaxPointOfIndexedAlignedBox( g_hBoxGeomObj,
0, /* First element */
0, /* First Aligned box of the element */
0, /* First point = Max */
1);/* Second point = Min */
/**/
POS_fn_vMulMatrixMatrix(&stCameraMatrixMultipliedByGlobalMatrix , &((GLI_tdstSpecificAttributesFor3D *)_p_stViewPort->p_vSpecificToXD) -> p_stCam -> stMatrix , g_p_stCurrentMatrix);
g_p_stCurrentInCamCoordsMatrix = &stCameraMatrixMultipliedByGlobalMatrix;
/**/
GLI_xSendObjectToViewportWithLights(_p_stViewPort, g_hBoxGeomObj, lDrawMask);
}
}
else
{
hBoundingSphere = (GEO_tdxHandleToBoundingSphere)HIE_fn_hGetSuperObjectBoundingVolume(_hSuperObject);
if (!g_hSphereGeomObj)
{
ACP_tdxHandleOfElement hAlignedSpheres;
GEO_vCreateGeometricObject(&g_hSphereGeomObj, 1 /* 1 points */, 1 /* 1 element */);
GEO_vCreateElementSpheres(g_hSphereGeomObj, &hAlignedSpheres, 1);
}
if(hBoundingSphere) /* Some char have NO bounding volume*/
{
GEO_vSetPointOfObject( g_hSphereGeomObj,
GEO_fn_pGetCenterPointOfBoundingSphere(hBoundingSphere),
0);
GEO_vSetCenterPointOfIndexedSphere ( g_hSphereGeomObj,
0, /* First Element */
0, /* First Sphere of the element */
0); /* First Point */
GEO_vSetRadiusOfIndexedSphere ( g_hSphereGeomObj,
0, /* First Element */
0, /* First Sphere of the element */
GEO_fn_xGetRadiusOfBoundingSphere(hBoundingSphere)
);
GEO_vSetGameMaterialOfIndexedSphere(g_hSphereGeomObj,
0,
0,
gs_hMaterial);
/**/
POS_fn_vMulMatrixMatrix(&stCameraMatrixMultipliedByGlobalMatrix , &((GLI_tdstSpecificAttributesFor3D *)_p_stViewPort->p_vSpecificToXD) -> p_stCam -> stMatrix , g_p_stCurrentMatrix);
g_p_stCurrentInCamCoordsMatrix = &stCameraMatrixMultipliedByGlobalMatrix;
/**/
GLI_xSendObjectToViewportWithLights(_p_stViewPort, g_hSphereGeomObj, lDrawMask);
}
}
}
HIE_fn_vPopMatrix();
}
/*ENDANNECY TQ}*/
/* Oliv' - I don't want this one function - 19/05/1999 */
#endif /*_DEBUG */
/* EndOfOliv' */
/* debug*/
void fn_vZdxDrawing(
GLD_tdstViewportAttributes * _p_stViewPort,
HIE_tdxHandleToSuperObject _hSector)
{
/*** This function deals with sectors ***/
SECT_tdxHandleOfElementLstCharacter hCharacterList;
SECT_tdxHandleOfElementLstGraphicInteraction hGraphicList;
unsigned long ulI,ulJ;
SECT_M_ForEachCharListInSector(_hSector,hCharacterList,ulI)
{
/* ANNECY AV {*/
if( M_ObjectIsActive((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(SECT_GetCharacterInList(hCharacterList))) )
/* END ANNECY AV }*/
{
fn_vZdxDisplayForCharacter(_p_stViewPort,
SECT_GetCharacterInList(hCharacterList));
}
}
SECT_M_ForEachGraphicNodeInGraphicInteractionList(_hSector,hGraphicList,ulI)
{
SECT_M_ForEachCharListInSector(SECT_GetSectorInGraphicList(hGraphicList),hCharacterList,ulJ)
{
/* END ANNECY AV {*/
if( M_ObjectIsActive((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(SECT_GetCharacterInList(hCharacterList))) )
/* END ANNECY AV }*/
{
fn_vZdxDisplayForCharacter(_p_stViewPort,
SECT_GetCharacterInList(hCharacterList));
}
}
}
}
/* Oliv' - I don't want this one function - 19/05/1999 */
#if defined(_DEBUG)
/* EndOfOliv' */
/*ANNECY TQ 11/03/98{*/
/* debug*/
void fn_vBoundingVolumesDrawing(
GLD_tdstViewportAttributes * _p_stViewPort,
HIE_tdxHandleToSuperObject _hSuperObject)
{
/*** This function deals with sectors ***/
HIE_tdxHandleToSuperObject pChild;
SECT_tdxHandleOfElementLstCharacter hCharacterList;
SECT_tdxHandleOfElementLstGraphicInteraction hGraphicList;
unsigned long p,ulI,ulJ;
long lType;
lType=HIE_fn_ulGetSuperObjectType(_hSuperObject);
if(lType==HIE_C_ulSector)
{
SECT_M_ForEachCharListInSector(_hSuperObject,hCharacterList,ulI)
{
if( M_ObjectIsActivable((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(SECT_GetCharacterInList(hCharacterList))) )
fn_vBoundingVolumeDisplayForSuperObject(_p_stViewPort,
SECT_GetCharacterInList(hCharacterList));
}
SECT_M_ForEachGraphicNodeInGraphicInteractionList(_hSuperObject,hGraphicList,ulI)
{
SECT_M_ForEachCharListInSector(SECT_GetSectorInGraphicList(hGraphicList),hCharacterList,ulJ)
{
if( M_ObjectIsActivable((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(SECT_GetCharacterInList(hCharacterList))) )
{
fn_vBoundingVolumeDisplayForSuperObject(_p_stViewPort,
SECT_GetCharacterInList(hCharacterList));
}
}
}
}
else
fn_vBoundingVolumeDisplayForSuperObject(_p_stViewPort, _hSuperObject);
HIE_M_ForEachChildOf(_hSuperObject,pChild,p)
{
lType=HIE_fn_ulGetSuperObjectType(pChild);
if(lType==HIE_C_ulSector)
{
SECT_M_ForEachCharListInSector(pChild,hCharacterList,ulI)
{
if( M_ObjectIsActivable((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(SECT_GetCharacterInList(hCharacterList))) )
fn_vBoundingVolumeDisplayForSuperObject(_p_stViewPort,
SECT_GetCharacterInList(hCharacterList));
}
SECT_M_ForEachGraphicNodeInGraphicInteractionList(_hSuperObject,hGraphicList,ulI)
{
SECT_M_ForEachCharListInSector(SECT_GetSectorInGraphicList(hGraphicList),hCharacterList,ulJ)
{
if( M_ObjectIsActivable((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(SECT_GetCharacterInList(hCharacterList))) )
{
fn_vBoundingVolumeDisplayForSuperObject(_p_stViewPort,
SECT_GetCharacterInList(hCharacterList));
}
}
}
}
else
fn_vBoundingVolumesDrawing(_p_stViewPort, pChild);
}
}
/* Oliv' - I don't want this one function - 19/05/1999 */
#endif /*_DEBUG */
/* EndOfOliv' */
/*ENDANNECY TQ}*/
/* debug*/
void ZDX_fn_vDisplayAllZdx(GLD_tdstViewportAttributes * p_stViewPort,HIE_tdxHandleToSuperObject p_stSupObject)
{
fn_vZdxDrawing(p_stViewPort,p_stSupObject);
}
/* Oliv' - 19/05/1999 - I want to see Zdx too */
#endif /* _DEBUG || _U64_GLI_BENCH_ */
/* EndOfOliv' */
/*ANNECY TQ 11/03/98{*/
#if defined(_DEBUG)
/* debug*/
void ZDX_fn_vDisplayAllBoundingVolumes(GLD_tdstViewportAttributes * p_stViewPort,HIE_tdxHandleToSuperObject p_stSupObject)
{
fn_vBoundingVolumesDrawing(p_stViewPort,p_stSupObject);
}
#endif /* _DEBUG*/
/*ENDANNECY TQ}*/
/*--------------------------------------------------------------------*/
void fn_vInsertZdxIndexInZoneSetList(ZDX_tdxHandleToZoneSetList _hZoneSetList,ZDX_tdxHandleToZdxIndexList _hIndex);
/*----------------------------------------------------------------------
* Create activation zone
*--------------------------------------------------------------------*/
#if defined(GAM_USE_SCRIPT)
/* script*/
SCR_tde_Anl_ReturnValue fn_eScriptCallBackCreateNewActivationZone(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;
tdstZdxIndexList * p_stZdxIndexList;
tdstZoneSetList * p_stZoneSetList;
if(M_IsTitle)
{
BOOL bAdded = FALSE;
char a255_cLinkKey[255];
M_CheckScriptParamNumber(0);
p_stZoneSetList=fn_p_stCreateZoneSetListElement();
SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
SCR_M_v_Link_SetAdditionalLong(
SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stACZ,
a255_cLinkKey,(unsigned long)p_stZoneSetList),
1,strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
SCR_M_RdL0_SetSectionLong(C_ThisSection,0,p_stZoneSetList);
}
else if (M_IsEntry)
{
if( M_ActionIs(C_EntryNewIndex) )
{
SCR_M_RdL0_GetSectionLong(C_ThisSection,0,tdstZoneSetList *,p_stZoneSetList);
p_stZdxIndexList=fn_p_stCreateZdxIndexListElement();
p_stZdxIndexList->uwZdxIndex=(unsigned short)fn_lAToI(_ap_szParams[0]);
/*LST2_M_StaticAddTail(&p_stZoneSetList->hZdxIndexList,p_stZdxIndexList);*/
fn_vInsertZdxIndexInZoneSetList(p_stZoneSetList,p_stZdxIndexList);
}
else
{
M_GameInformationError(E_uwGameScriptCallBackDescriptionUnknownAction);
}
}
else if (M_IsEnd)
{
SCR_M_RdL0_GetSectionLong(C_ThisSection,0,tdstZoneSetList *,p_stZoneSetList);
/*GAM_fn_vOrderZoneSetList( p_stZoneSetList );*/
}
return(eReturnValue);
}
#endif /* GAM_USE_SCRIPT */
/*-----------------------------------------------------------------------
* Returns all object with Zde of type in contact with the specified
* Zde of the character
* NOTE: this function is called by AI, so in case of character's ZDX,
* channel number is number in geoZdx list, and NOT in the state list.
* OPTIMIZED: 1
*----------------------------------------------------------------------*/
/* used*/
void fn_vGetAllCharactersInContactWithThisZde(HIE_tdxHandleToSuperObject _hSuperObj,unsigned char _ucModuleOrCharacter,unsigned char _ucChannelNumber,HIE_tdxHandleToSuperObject * _hSuperObjTable,unsigned short * _p_uwNumber,GMT_tdxMask _wMaterialMask)
{
ACP_tdxHandleOfObject hGeoObj;
long lMaxNumberOfObjects;
long lCurrentNumberOfObjects;
lMaxNumberOfObjects = (long)(*_p_uwNumber);
lCurrentNumberOfObjects = 0;
if( _ucModuleOrCharacter )
{
fn_vGetAllCharactersInContactWithThisModuleZde(_hSuperObj,_ucChannelNumber,_hSuperObjTable,_wMaterialMask,lMaxNumberOfObjects,&lCurrentNumberOfObjects);
}
else
{
hGeoObj = fn_hIsThisZoneActive(_hSuperObj,C_ucTypeZde,(unsigned char)(_ucChannelNumber-1));
if( hGeoObj )
fn_vGetAllCharacterInContactWithThisGeoObj(_hSuperObj,hGeoObj,HIE_fn_hGetSuperObjectGlobalMatrix(_hSuperObj),_hSuperObjTable,_wMaterialMask,lMaxNumberOfObjects,&lCurrentNumberOfObjects);
}
*_p_uwNumber = (unsigned short)lCurrentNumberOfObjects;
}
#pragma warning (disable : 4706) /* There are some voluntary assignment inside this function*/
/*-----------------------------------------------------------------------
* Returns all object with Zde of type in contact with the specified
* Geometric Object
* OPTIMIZED: 2
*----------------------------------------------------------------------*/
/* used*/
void fn_vGetAllCharacterInContactWithThisGeoObj(
HIE_tdxHandleToSuperObject _hSuperObj,
ACP_tdxHandleOfObject _hGeoObj,
POS_tdstCompletePosition * _hMatrix,
HIE_tdxHandleToSuperObject * _hSuperObjTable,
GMT_tdxMask _wMaterialMask,
long _lMaxNumberOfObjects,
long * _p_lCurrentNumberOfObjects)
{
SECT_tdxHandleOfElementLstCharacter hCharacterList;
SECT_tdxHandleOfElementLstCollisionInteraction hCollisionList;
unsigned long ulI,ulJ;
HIE_tdxHandleToSuperObject hCharInList;
int bThisActorIsAProjectile = fn_ulStandardGameGetCustomBits (M_GetMSHandle(_hSuperObj,StandardGame)) & GAM_C_CustBitProjectile;
int bNoCollisionWithProjectile = fn_bCollSetGetCharacterNoCollisionZdeWithProjectile (M_GetMSHandle(_hSuperObj,CollSet));
/* Deal with interactions between characters*/
/* First, the Active Sector*/
SECT_M_ForEachCharListInSector(fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hSuperObj,SectInfo)),hCharacterList,ulI)
{
if( *_p_lCurrentNumberOfObjects < _lMaxNumberOfObjects )
{
hCharInList = SECT_GetCharacterInList(hCharacterList);
if( _hSuperObj != hCharInList )
{
if( M_ObjectIsActive ((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(hCharInList)) )
{
{
/* If this actor is a projectile and the other actor has the 'no collision zde with projectile' flag -> do nothing*/
MS_tdxHandleToCollSet hCollSet;
if (bThisActorIsAProjectile && ((hCollSet = M_GetMSHandle (hCharInList,CollSet)) != 0) && fn_bCollSetGetCharacterNoCollisionZdeWithProjectile (hCollSet))
continue;
/* If this actor has the 'no collision zde with projectile' flag and the other actor is a projectile -> do nothing*/
if (bNoCollisionWithProjectile && (fn_ulStandardGameGetCustomBits (M_GetMSHandle(hCharInList,StandardGame)) & GAM_C_CustBitProjectile))
continue;
}
if( fn_bIsThisZdeInClashWithCharacterZdeOfTypes(_hGeoObj,_hMatrix,hCharInList,_wMaterialMask) )
{
/* Ok, let's add this character in the list*/
_hSuperObjTable[(*_p_lCurrentNumberOfObjects)++] = hCharInList;
}
}
}
}
else
{
return;
}
}
if( (*_p_lCurrentNumberOfObjects< _lMaxNumberOfObjects) )
{
/* And now, the collision list*/
SECT_M_ForEachCollisionNodeInCollisionInteractionList(fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hSuperObj,SectInfo)),hCollisionList,ulI)
{
SECT_M_ForEachCharListInSector(SECT_GetSectorInCollisionList(hCollisionList),hCharacterList,ulJ)
{
if( (*_p_lCurrentNumberOfObjects < _lMaxNumberOfObjects) )
{
hCharInList = SECT_GetCharacterInList(hCharacterList);
if( M_ObjectIsActive ((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(hCharInList)) )
{
{
/* If this actor is a projectile and the other actor has the 'no collision zde with projectile' flag -> do nothing*/
MS_tdxHandleToCollSet hCollSet;
if (bThisActorIsAProjectile && ((hCollSet = M_GetMSHandle (hCharInList,CollSet)) != 0) && fn_bCollSetGetCharacterNoCollisionZdeWithProjectile (hCollSet))
continue;
/* If this actor has the 'no collision zde with projectile' flag and the other actor is a projectile -> do nothing*/
if (bNoCollisionWithProjectile && (fn_ulStandardGameGetCustomBits (M_GetMSHandle(hCharInList,StandardGame)) & GAM_C_CustBitProjectile))
continue;
}
if( fn_bIsThisZdeInClashWithCharacterZdeOfTypes(_hGeoObj,_hMatrix,hCharInList,_wMaterialMask) )
{
/* Ok, let's add this character in the list*/
_hSuperObjTable[(*_p_lCurrentNumberOfObjects)++] = hCharInList;
}
}
}
else
{
return;
}
}
}
}
}
#pragma warning (default : 4706)
/*-----------------------------------------------------------------------
* Returns all object with Zde of type in contact with the specified
* module Zde
* OPTIMIZED: 0
*----------------------------------------------------------------------*/
void fn_vGetAllCharactersInContactWithThisModuleZde
(
HIE_tdxHandleToSuperObject _hSuperObj,
unsigned char _ucChannelNumber,
HIE_tdxHandleToSuperObject * _hSuperObjTable,
GMT_tdxMask _wMaterialMask,
long _lMaxNumberOfObjects,
long * _p_lCurrentNumberofObjects)
{
HIE_tdxHandleToSuperObject hModule;
ACP_tdxHandleOfObject hGeoObj;
PO_tdxHandleToPhysicalObject hPhysical;
PCS_tdxHandleToPhysicalCollSet hPhyCollSet;
hModule = fn_hGetSuperObjectInChannel( fn_h3dDataGetChannelSOList(M_GetMSHandle(_hSuperObj,3dData)),_ucChannelNumber);
if( ! hModule || HIE_fn_ulGetSuperObjectType ( hModule ) != HIE_C_ulPO )
{
hModule = fn_hGetZoomSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(_hSuperObj,3dData)), (unsigned short)(_ucChannelNumber));
if ( !hModule || HIE_fn_ulGetSuperObjectType(hModule) != HIE_C_ulPO )
return;
}
hPhysical = ( PO_tdxHandleToPhysicalObject ) HIE_fn_hGetSuperObjectObject ( hModule ) ;
/*#ifdef _DEBUG
if( !hPhysical )
return;
#endif _DEBUG */ /* _1_warning_removed_here_ - Oliv'*/
hPhyCollSet = PO_fn_hGetCollideSet(hPhysical);
if( !hPhyCollSet )
return;
hGeoObj = PCS_fn_hGetZdeGeoObjOfPhysicalCollSet( hPhyCollSet );
if( !hGeoObj )
return;
#ifdef ACTIVE_EDITOR
fn_vCheckModuleAccessGam(_hSuperObj, _ucChannelNumber);
#endif
fn_vGetAllCharacterInContactWithThisGeoObj(_hSuperObj,hGeoObj,HIE_fn_hGetSuperObjectGlobalMatrix(hModule),_hSuperObjTable,_wMaterialMask,_lMaxNumberOfObjects,_p_lCurrentNumberofObjects);
}
/*-----------------------------------------------------------------------
* Looking for contact for a Geometric Object Zde
* OPTIMIZED: 0
*----------------------------------------------------------------------*/
/* used*/
ACP_tdxBool fn_bIsThisZdeInClashWithCharacterZdeOfTypes(ACP_tdxHandleOfObject _hGeoObj,POS_tdstCompletePosition * _hMatrix,HIE_tdxHandleToSuperObject _hCharacter,GMT_tdxMask _wMaterialMask)
{
ACP_tdxIndex xI;
tdstZdxIndexList *p_stZdxIndex;
tdstZoneSetList *p_stZoneSet;
ACP_tdxHandleOfObject hStaticGeoObj;
PO_tdxHandleToPhysicalObject hPhysical;
PCS_tdxHandleToPhysicalCollSet hPhyCollSet;
GMT_tdxHandleToGameMaterial hMat1,hMat2;
CHN_tdxHandleToChannel hChannel;
ACP_tdxIndex xIndex;
HIE_tdxHandleToSuperObject hModule;
long lType;
tdeCollSetPrivilegedActivation ePrivilege;
unsigned short uwCurrentIndexInActivation;
/* jt 020699 */
if(!M_ObjectIsActive ((tdstEngineObject*)HIE_fn_hGetSuperObjectObject(_hCharacter)) )
return FALSE;
/* end jt 020699 */
/* Dealing with actor's Zde*/
hStaticGeoObj = NULL;
hPhysical = NULL;
hPhyCollSet = NULL;
hMat1 = NULL;
hMat2 = NULL;
hChannel = NULL;
xIndex = 0;
hModule = NULL;
lType = 0;
xI = 0;
p_stZoneSet = fn_p_stGetCurrentZoneSetOfType2(C_ucTypeZde,_hCharacter);
if( fn_bIsAllDefaultPrivilegedActivationZoneOfCharacter(C_ucTypeZde,_hCharacter) )
{
/* no forced activated or disactivated zone, uses current activation*/
if( p_stZoneSet )
{
ZDX_M_ForEachZdxIndexListOfTypeInZoneSet(C_ucTypeZde,p_stZoneSet,p_stZdxIndex,xI)
{
hStaticGeoObj = fn_hGetGeometricZdxOfTypeAtIndex(C_ucTypeZde,fn_uwGetIndexFromZdxIndexList(p_stZdxIndex),_hCharacter);
if( hStaticGeoObj && ((_wMaterialMask == 0) || fn_hIsTypeExistsInGeoObj(hStaticGeoObj,_wMaterialMask)) )
{
/* Intersection test*/
if( INT_fn_bDetectIntersectGeomObjWithGeomObj(_hGeoObj,_hMatrix,hStaticGeoObj,HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter),&hMat1,&hMat2) )
{
/*ANNECY BBB if the mask has no bit set, all geobojs are eligible, even if their gmt has no CMT!*/
if( (_wMaterialMask == 0) || GMT_fn_xMultipleTestCollideIdentifierFromGameMaterial(hMat2,_wMaterialMask) )
{
return TRUE;
}
}
}
}
}
}
else
{
p_stZdxIndex = (p_stZoneSet ? LST2_M_StaticGetFirstElement( &p_stZoneSet->hZdxIndexList ) : LST2_C_StaticInvalid);
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
while( xI < fn_lGetZdxListNumberOfElements(C_ucTypeZde,_hCharacter) )
{
ePrivilege = fn_eGetPrivilegedActivationZoneOfCharacter(C_ucTypeZde,_hCharacter,xI);
if( (ePrivilege == edmPriviligedActivated) ||
((ePrivilege == edmPriviligedDefault) && (uwCurrentIndexInActivation == xI)) )
{
hStaticGeoObj=fn_hGetGeometricZdxOfTypeAtIndex(C_ucTypeZde, xI,_hCharacter);
/*ANNECY BBB if the mask has no bit set, all geobojs are eligible, even if their gmt has no CMT!*/
if( hStaticGeoObj && ((_wMaterialMask == 0) || fn_hIsTypeExistsInGeoObj(hStaticGeoObj,_wMaterialMask)) )
{
/* Intersection test*/
if( INT_fn_bDetectIntersectGeomObjWithGeomObj(_hGeoObj,_hMatrix,hStaticGeoObj,HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter),&hMat1,&hMat2) )
{
/*ANNECY BBB if the mask has no bit set, all geobojs are eligible, even if their gmt has no CMT!*/
if( (_wMaterialMask == 0) || GMT_fn_xMultipleTestCollideIdentifierFromGameMaterial(hMat2,_wMaterialMask) )
{
return TRUE;
}
}
}
}
/**/
xI++;
if( (p_stZdxIndex != LST2_C_StaticInvalid) && (uwCurrentIndexInActivation < xI) )
{
p_stZdxIndex = LST2_M_StaticGetNextElement( p_stZdxIndex );
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
}
}
}
#ifndef ACTIVE_EDITOR
/* (The flag ObjectTableHasZde may not be correct with editors)*/
/* If the current object table of the actor has no object with zde -> quit*/
{
tdxHandleToObjectsTablesList hObjectTable;
if ((hObjectTable = fn_h3dDataGetCurrentObjectsTable (M_GetMSHandle (_hCharacter,3dData))) == NULL ||
fn_bObjectTableHasZde (hObjectTable) == FALSE)
{
return FALSE;
}
}
#endif
/* Dealing with actor's module Zde*/
/* Testing only one level of channels*/
hChannel = fn_h3dDataGetFirstActiveChannel(M_GetMSHandle(_hCharacter,3dData));
while (hChannel)
{
if (hChannel->hZoomSupObject)
hModule = hChannel->hZoomSupObject;
else
hModule = hChannel->hSupObject;
lType = HIE_fn_ulGetSuperObjectType(hModule);
if( lType & (HIE_C_ulPO | HIE_C_ulPO_Mirror ))
{
hPhysical = (PO_tdxHandleToPhysicalObject)HIE_fn_hGetSuperObjectObject(hModule);
hPhyCollSet = PO_fn_hGetCollideSet(hPhysical);
if( hPhyCollSet )
{
hStaticGeoObj = PCS_fn_hGetZdeGeoObjOfPhysicalCollSet( hPhyCollSet );
/*ANNECY BBB if the mask has no bit set, all geobojs are eligible, even if their gmt has no CMT!*/
if( hStaticGeoObj && ((_wMaterialMask == 0) || fn_hIsTypeExistsInGeoObj(hStaticGeoObj,_wMaterialMask)) )
{
/* Intersection test*/
if( INT_fn_bDetectIntersectGeomObjWithGeomObj(_hGeoObj,_hMatrix,hStaticGeoObj,HIE_fn_hGetSuperObjectGlobalMatrix(hModule),&hMat1,&hMat2) )
{
/*ANNECY BBB if the mask has no bit set, all geobojs are eligible, even if their gmt has no CMT!*/
if( (_wMaterialMask == 0) || GMT_fn_xMultipleTestCollideIdentifierFromGameMaterial(hMat2,_wMaterialMask) )
return TRUE;
}
}
}
}
hChannel = hChannel->p_stNextActiveChannel;
}
return FALSE;
}
/*-----------------------------------------------------------------------
* Get the specified ZDx (if exists) and its global matrix
*
* NOTE: this function is called by AI, so, in case of character's ZDX
* channel number is the number of Zone in geometric list, and NOT in
* state list.
* OPTIMIZED: 1
*----------------------------------------------------------------------*/
/* used*/
ACP_tdxHandleOfObject ZDX_fn_hGetGeoObjOfTypeAndMatrixFromZdxInfos(
HIE_tdxHandleToSuperObject _hCharacter,
unsigned char _ucZoneType,
unsigned char _ucModuleOrCharacter,
unsigned char _ucChannelNumber,
POS_tdstCompletePosition ** _p_hMatrix)
{
ACP_tdxHandleOfObject hGeoObj;
HIE_tdxHandleToSuperObject hModule,hModuleIfZoom;
PO_tdxHandleToPhysicalObject hPhysical;
PCS_tdxHandleToPhysicalCollSet hPhyCollSet;
if( _ucModuleOrCharacter )
{
long lType;
hModuleIfZoom = hModule = fn_hGetSuperObjectInChannel( fn_h3dDataGetChannelSOList(M_GetMSHandle(_hCharacter,3dData)),_ucChannelNumber);
if ( ! hModule )
return NULL ;
lType = HIE_fn_ulGetSuperObjectType ( hModule ) ;
if ( (lType & (HIE_C_ulPO | HIE_C_ulPO_Mirror) ) == 0 )
{
hModuleIfZoom = fn_hGetSuperObjectInChannel( fn_h3dDataGetChannelSOList(M_GetMSHandle(_hCharacter,3dData)),(unsigned short)(_ucChannelNumber+C_wMaskForZoom));
if ( !hModuleIfZoom )
return NULL;
}
hPhysical = ( PO_tdxHandleToPhysicalObject ) HIE_fn_hGetSuperObjectObject ( hModuleIfZoom ) ;
#ifdef _DEBUG
if( ! hPhysical )
return NULL;
#endif /* _DEBUG */
hPhyCollSet = PO_fn_hGetCollideSet ( hPhysical ) ;
if( ! hPhyCollSet )
return NULL ;
hGeoObj = PCS_fn_hGetGeoObjOfPhysicalCollSet ( _ucZoneType , hPhyCollSet ) ;
if( ! hGeoObj )
return NULL ;
#ifdef ACTIVE_EDITOR
fn_vCheckModuleAccessGam(_hCharacter, _ucChannelNumber);
#endif
*_p_hMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hModule);
return hGeoObj;
}
else
{
/* OK, let's deal with the GeoZdxList, and NOT the state list.*/
hGeoObj = fn_hIsThisZoneActive(_hCharacter,_ucZoneType,(unsigned char)(_ucChannelNumber-1));
if( hGeoObj )
{
*_p_hMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacter);
return hGeoObj;
}
}
return NULL;
}
/*-----------------------------------------------------------------------
* Tells if the specified ZDE of character one is in contact with
* one (or more) ZDE(s) of character two
* OPTIMIZED: 0
*----------------------------------------------------------------------*/
/* used*/
ACP_tdxBool fn_bThisZdeFromOneVsAllZdeFromTwo(
HIE_tdxHandleToSuperObject _hCharacterONE,
unsigned char _ucModuleOrCharacter,
unsigned char _ucChannelNumber,
HIE_tdxHandleToSuperObject _hCharacterTWO,
GMT_tdxMask _wMaterialMask)
{
POS_tdstCompletePosition * p_stMatrix;
ACP_tdxHandleOfObject hGeoObj;
hGeoObj = ZDX_fn_hGetGeoObjOfTypeAndMatrixFromZdxInfos(_hCharacterONE,C_ucTypeZde,_ucModuleOrCharacter,_ucChannelNumber,&p_stMatrix);
if( !hGeoObj )
return FALSE;
return( fn_bIsThisZdeInClashWithCharacterZdeOfTypes(hGeoObj,p_stMatrix,_hCharacterTWO,_wMaterialMask) );
}
/*-----------------------------------------------------------------------
* Tells if the specified ZDE of character ONE is in contact with the
* specified ZDE of character TWO (don't care about GameMaterial)
* OPTIMIZED: 0
*---------------------------------------------------------------------*/
/* used*/
ACP_tdxBool fn_bThisZdeFromOneVsThisZdeFromTwo(
HIE_tdxHandleToSuperObject _hCharacterONE,
unsigned char _ucModuleOrCharacterForONE,
unsigned char _ucChannelNumberForONE,
HIE_tdxHandleToSuperObject _hCharacterTWO,
unsigned char _ucModuleOrCharacterForTWO,
unsigned char _ucChannelNumberForTWO)
{
POS_tdstCompletePosition *p_stMatrix1,*p_stMatrix2;
ACP_tdxHandleOfObject hGeoObj1,hGeoObj2;
GMT_tdxHandleToGameMaterial hMat1,hMat2;
hGeoObj1 = ZDX_fn_hGetGeoObjOfTypeAndMatrixFromZdxInfos(_hCharacterONE,C_ucTypeZde,_ucModuleOrCharacterForONE,_ucChannelNumberForONE,&p_stMatrix1);
hGeoObj2 = ZDX_fn_hGetGeoObjOfTypeAndMatrixFromZdxInfos(_hCharacterTWO,C_ucTypeZde,_ucModuleOrCharacterForTWO,_ucChannelNumberForTWO,&p_stMatrix2);
if( !hGeoObj1 || !hGeoObj2 )
return FALSE;
if( INT_fn_bDetectIntersectGeomObjWithGeomObj(hGeoObj1,p_stMatrix1,hGeoObj2,p_stMatrix2,&hMat1,&hMat2) )
return TRUE;
else
return FALSE;
}
/*-----------------------------------------------------------------------
* Tells if any zone of type _wCharacterMask of _hCharacter if in
* contact with a zone of type _wOthersMask from any character
* OPTIMIZED: 2
*---------------------------------------------------------------------*/
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
/* used only by 1 AI function that is not used...*/
void fn_vThisTypeVsThisType(
HIE_tdxHandleToSuperObject _hCharacter,
GMT_tdxMask _wCharacterMask,
GMT_tdxMask _wOthersMask,
HIE_tdxHandleToSuperObject * _p_hObjectTable,
unsigned short * _p_uwNumber)
{
SECT_tdxHandleOfElementLstCharacter hCharacterList;
HIE_tdxHandleToSuperObject hSOTmp;
SECT_tdxHandleOfElementLstCollisionInteraction hCollisionList;
unsigned long ulI,ulJ;
unsigned short uwCurrentNumber = 0;
unsigned short uwMaxNumber = *_p_uwNumber;
SECT_M_ForEachCharListInSector(fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hCharacter,SectInfo)),hCharacterList,ulI)
{
hSOTmp = SECT_GetCharacterInList(hCharacterList);
if( _hCharacter!=hSOTmp )
{
if( M_ObjectIsActive ((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(hSOTmp)) )
{
if( uwCurrentNumber<uwMaxNumber )
{
if( fn_bThisTypeFromOneVsThisTypeFromTwo(_hCharacter,
_wCharacterMask,hSOTmp,_wOthersMask) )
{
_p_hObjectTable[uwCurrentNumber++] = hSOTmp;
}
}
else
{
*_p_uwNumber = uwMaxNumber;
return;
}
}
}
}
/* And now, the activity list*/
SECT_M_ForEachCollisionNodeInCollisionInteractionList(fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hCharacter,SectInfo)),hCollisionList,ulI)
{
SECT_M_ForEachCharListInSector(SECT_GetSectorInCollisionList(hCollisionList),hCharacterList,ulJ)
{
if( uwCurrentNumber<uwMaxNumber )
{
hSOTmp = SECT_GetCharacterInList(hCharacterList);
if( M_ObjectIsActive ((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(hSOTmp)) )
{
if( fn_bThisTypeFromOneVsThisTypeFromTwo(_hCharacter,
_wCharacterMask,hSOTmp,_wOthersMask) )
{
_p_hObjectTable[uwCurrentNumber++] = hSOTmp;
}
}
}
else
{
*_p_uwNumber = uwMaxNumber;
return;
}
}
}
*_p_uwNumber = uwCurrentNumber;
}
#endif
/*-----------------------------------------------------------------------
* returns TRUE if a ZDE of specified type from character ONE is in
* contact with a ZDE of specified type from character TWO
* OPTIMIZED: 1
*---------------------------------------------------------------------*/
/* used*/
ACP_tdxBool fn_bThisTypeFromOneVsThisTypeFromTwo(
HIE_tdxHandleToSuperObject _hCharacterONE,
GMT_tdxMask _wMaterialMaskOfONE,
HIE_tdxHandleToSuperObject _hCharacterTWO,
GMT_tdxMask _wMaterialMaskOfTWO)
{
ACP_tdxIndex xI;
tdstZdxIndexList * p_stZdxIndex;
tdstZoneSetList * p_stZoneSet;
ACP_tdxHandleOfObject hGeoObj1;
PO_tdxHandleToPhysicalObject hPhysical;
PCS_tdxHandleToPhysicalCollSet hPhyCollSet;
CHN_tdxHandleToChannel hChannel;
ACP_tdxIndex xIndex;
long lType;
HIE_tdxHandleToSuperObject hModule;
tdeCollSetPrivilegedActivation ePrivilege;
unsigned short uwCurrentIndexInActivation;
/* Deal with ONE's ZDE */
hGeoObj1 = NULL;
hPhysical = NULL;
hPhyCollSet = NULL;
hChannel = NULL;
xIndex = 0;
hModule = NULL;
lType = 0;
xI = 0;
p_stZoneSet = fn_p_stGetCurrentZoneSetOfType2(C_ucTypeZde,_hCharacterONE);
if(fn_bIsAllDefaultPrivilegedActivationZoneOfCharacter(C_ucTypeZde,_hCharacterONE))
{
if( p_stZoneSet )
{
ZDX_M_ForEachZdxIndexListOfTypeInZoneSet(C_ucTypeZde,p_stZoneSet,p_stZdxIndex,xI)
{
hGeoObj1 = fn_hGetGeometricZdxOfTypeAtIndex(C_ucTypeZde,fn_uwGetIndexFromZdxIndexList(p_stZdxIndex),_hCharacterONE);
if( hGeoObj1 && fn_hIsTypeExistsInGeoObj(hGeoObj1,_wMaterialMaskOfONE) )
{
if( fn_bIsThisZdeInClashWithCharacterZdeOfTypes(hGeoObj1,HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacterONE),_hCharacterTWO,_wMaterialMaskOfTWO) )
return TRUE;
}
}
}
}
else
{
p_stZdxIndex = (p_stZoneSet ? LST2_M_StaticGetFirstElement( &p_stZoneSet->hZdxIndexList ) : LST2_C_StaticInvalid);
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
while( xI < fn_lGetZdxListNumberOfElements(C_ucTypeZde,_hCharacterONE) )
{
ePrivilege = fn_eGetPrivilegedActivationZoneOfCharacter(C_ucTypeZde,_hCharacterONE,xI);
if( (ePrivilege == edmPriviligedActivated) ||
((ePrivilege == edmPriviligedDefault) && (uwCurrentIndexInActivation == xI)) )
{
hGeoObj1 = fn_hGetGeometricZdxOfTypeAtIndex(C_ucTypeZde,xI,_hCharacterONE);
if( hGeoObj1 && fn_hIsTypeExistsInGeoObj(hGeoObj1,_wMaterialMaskOfONE) )
{
if( fn_bIsThisZdeInClashWithCharacterZdeOfTypes(hGeoObj1,HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacterONE),_hCharacterTWO,_wMaterialMaskOfTWO) )
return TRUE;
}
}
/**/
xI++;
if( (p_stZdxIndex != LST2_C_StaticInvalid) && (uwCurrentIndexInActivation < xI) )
{
p_stZdxIndex = LST2_M_StaticGetNextElement( p_stZdxIndex );
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
}
}
}
/*
p_stZoneSet = fn_p_stGetCurrentZoneSetOfType2(C_ucTypeZde,_hCharacterONE);
if( p_stZoneSet )
{
ZDX_M_ForEachZdxIndexListOfTypeInZoneSet(C_ucTypeZde,p_stZoneSet,p_stZdxIndex,xI)
{
hGeoObj1 = fn_hGetGeometricZdxOfTypeAtIndex(C_ucTypeZde,
fn_uwGetIndexFromZdxIndexList(p_stZdxIndex),
_hCharacterONE);
if( hGeoObj1 && fn_hIsTypeExistsInGeoObj(hGeoObj1,_wMaterialMaskOfONE) )
{
if( fn_bIsThisZdeInClashWithCharacterZdeOfTypes(hGeoObj1,HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacterONE),_hCharacterTWO,_wMaterialMaskOfTWO) )
return TRUE;
}
}
}
*/
/* Dealing with ONE's module Zde*/
hChannel = fn_h3dDataGetFirstActiveChannel(M_GetMSHandle(_hCharacterONE,3dData));
while (hChannel)
{
if ( hModule && hChannel->hZoomSupObject)
{
hModule = hChannel->hZoomSupObject;
}
else
{
hModule = hChannel->hSupObject;
}
lType = HIE_fn_ulGetSuperObjectType(hModule);
if( lType & (HIE_C_ulPO | HIE_C_ulPO_Mirror ))
{
hPhysical = (PO_tdxHandleToPhysicalObject)HIE_fn_hGetSuperObjectObject(hModule);
hPhyCollSet = PO_fn_hGetCollideSet(hPhysical);
if( hPhyCollSet )
{
hGeoObj1 = PCS_fn_hGetZdeGeoObjOfPhysicalCollSet( hPhyCollSet );
if( hGeoObj1 && fn_hIsTypeExistsInGeoObj(hGeoObj1,_wMaterialMaskOfONE) )
{
if( fn_bIsThisZdeInClashWithCharacterZdeOfTypes(hGeoObj1,HIE_fn_hGetSuperObjectGlobalMatrix(hModule),_hCharacterTWO,_wMaterialMaskOfTWO) )
return TRUE;
}
}
}
hChannel = hChannel->p_stNextActiveChannel;
}
return FALSE;
}
/*-----------------------------------------------------------------------
* Detect if character TWO is detected by the specified zone of
* character ONE
*
* NOTE: this function is called by AI, so, in case of character's ZDX
* channel number is the number of Zone in geometric list, and NOT in
* state list.
* OPTIMIZED: 2
*---------------------------------------------------------------------*/
/* used*/
ACP_tdxBool fn_bIsCharacterTWODetectedByThisZddOfCharacterOne(
HIE_tdxHandleToSuperObject _hCharacterONE,
unsigned char _ucModuleOrCharacter,
unsigned char _ucChannelNumber,
HIE_tdxHandleToSuperObject _hCharacterTWO)
{
POS_tdstCompletePosition * p_stMatrix;
ACP_tdxHandleOfObject hGeoObj;
hGeoObj = ZDX_fn_hGetGeoObjOfTypeAndMatrixFromZdxInfos(_hCharacterONE,C_ucTypeZdd,_ucModuleOrCharacter,_ucChannelNumber,&p_stMatrix);
if( !hGeoObj )
return FALSE;
return( fn_bIsCharacterInZdd(hGeoObj,p_stMatrix,_hCharacterTWO) );
}
/*-----------------------------------------------------------------------
* Detect if character TWO is detected any ZDD of character ONE
* OPTIMIZED: 1
*---------------------------------------------------------------------*/
/* used*/
ACP_tdxBool fn_bIsCharacterTWODetectedByCharacterOne(
HIE_tdxHandleToSuperObject _hCharacterONE,
HIE_tdxHandleToSuperObject _hCharacterTWO)
{
ACP_tdxIndex xI;
tdstZdxIndexList * p_stZdxIndex;
tdstZoneSetList * p_stZoneSet;
ACP_tdxHandleOfObject hGeoObj1;
PO_tdxHandleToPhysicalObject hPhysical;
PCS_tdxHandleToPhysicalCollSet hPhyCollSet;
CHN_tdxHandleToChannel hChannel;
ACP_tdxIndex xIndex;
long lType;
HIE_tdxHandleToSuperObject hModule;
tdeCollSetPrivilegedActivation ePrivilege;
unsigned short uwCurrentIndexInActivation;
/* Deal with ONE's ZDE */
hGeoObj1 = NULL;
hPhysical = NULL;
hPhyCollSet = NULL;
hChannel = NULL;
xIndex = 0;
hModule = NULL;
lType = 0;
xI = 0;
p_stZoneSet = fn_p_stGetCurrentZoneSetOfType2(C_ucTypeZdd,_hCharacterONE);
p_stZdxIndex = (p_stZoneSet ? LST2_M_StaticGetFirstElement( &p_stZoneSet->hZdxIndexList ) : LST2_C_StaticInvalid);
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
while( xI < fn_lGetZdxListNumberOfElements(C_ucTypeZdd,_hCharacterONE) )
{
ePrivilege = fn_eGetPrivilegedActivationZoneOfCharacter(C_ucTypeZdd,_hCharacterONE,xI);
if( (ePrivilege == edmPriviligedActivated) ||
((ePrivilege == edmPriviligedDefault) && (uwCurrentIndexInActivation == xI)) )
{
hGeoObj1 = fn_hGetGeometricZdxOfTypeAtIndex(C_ucTypeZdd,xI,_hCharacterONE);
if( hGeoObj1 )
{
if( fn_bIsCharacterInZdd(hGeoObj1,HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacterONE),_hCharacterTWO) )
return TRUE;
}
}
/**/
xI++;
if( (p_stZdxIndex != LST2_C_StaticInvalid) && (uwCurrentIndexInActivation < xI) )
{
p_stZdxIndex = LST2_M_StaticGetNextElement( p_stZdxIndex );
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
}
}
/*
p_stZoneSet = fn_p_stGetCurrentZoneSetOfType2(C_ucTypeZdd,_hCharacterONE);
if( p_stZoneSet )
{
ZDX_M_ForEachZdxIndexListOfTypeInZoneSet(C_ucTypeZdd,p_stZoneSet,p_stZdxIndex,xI)
{
hGeoObj1 = fn_hGetGeometricZdxOfTypeAtIndex(C_ucTypeZdd,fn_uwGetIndexFromZdxIndexList(p_stZdxIndex),_hCharacterONE);
if( hGeoObj1 )
{
if( fn_bIsCharacterInZdd(hGeoObj1,HIE_fn_hGetSuperObjectGlobalMatrix(_hCharacterONE),_hCharacterTWO) )
return TRUE;
}
}
}
*/
/* Dealing with ONE's module ZDD*/
hChannel = fn_h3dDataGetFirstActiveChannel(M_GetMSHandle(_hCharacterONE,3dData));
while (hChannel)
{
if ( hModule && hChannel->hZoomSupObject)
{
hModule = hChannel->hZoomSupObject;
}
else
{
hModule = hChannel->hSupObject;
}
lType = HIE_fn_ulGetSuperObjectType(hModule);
if( lType & (HIE_C_ulPO | HIE_C_ulPO_Mirror ))
{
hPhysical = (PO_tdxHandleToPhysicalObject)HIE_fn_hGetSuperObjectObject(hModule);
hPhyCollSet = PO_fn_hGetCollideSet(hPhysical);
if( hPhyCollSet )
{
hGeoObj1 = PCS_fn_hGetZddGeoObjOfPhysicalCollSet( hPhyCollSet );
if( hGeoObj1 )
{
if( fn_bIsCharacterInZdd(hGeoObj1,HIE_fn_hGetSuperObjectGlobalMatrix(hModule),_hCharacterTWO) )
return TRUE;
}
}
}
hChannel = hChannel->p_stNextActiveChannel;
}
return FALSE;
}
/*-----------------------------------------------------------------------
* Detect all the objects in the module specified by channel number
* OPTIMIZED: 0
*---------------------------------------------------------------------*/
/* used*/
void fn_vGetAllObjectsInModuleZdd(
HIE_tdxHandleToSuperObject hSuperObj,
unsigned char _ucChannelNumber,
HIE_tdxHandleToSuperObject * p_hSuperObjTable,
long _lNumberMaxOfObjects,
long * _p_lCurrentNumberOfObjects)
{
HIE_tdxHandleToSuperObject hModule,hModuleIfZoom;
POS_tdstCompletePosition * p_stMatrix;
ACP_tdxHandleOfObject hGeoObj;
PO_tdxHandleToPhysicalObject hPhysical;
hModuleIfZoom = hModule = fn_hGetSuperObjectInChannel( fn_h3dDataGetChannelSOList(M_GetMSHandle(hSuperObj,3dData)),_ucChannelNumber);
if( !hModule ) return;
if( HIE_fn_ulGetSuperObjectType(hModule) != HIE_C_ulPO )
{
hModuleIfZoom = fn_hGetSuperObjectInChannel( fn_h3dDataGetChannelSOList(M_GetMSHandle(hSuperObj,3dData)),(unsigned short)(_ucChannelNumber+C_wMaskForZoom));
if( !hModuleIfZoom ) return;
}
hPhysical = (PO_tdxHandleToPhysicalObject)HIE_fn_hGetSuperObjectObject(hModuleIfZoom);
hGeoObj = PCS_fn_hGetZddGeoObjOfPhysicalCollSet( PO_fn_hGetCollideSet(hPhysical) );
if( !hGeoObj )
return;
#ifdef ACTIVE_EDITOR
fn_vCheckModuleAccessGam(hSuperObj, _ucChannelNumber);
#endif
p_stMatrix = HIE_fn_hGetSuperObjectGlobalMatrix(hModule);
fn_vDetectAllObjectsInThisModule(hSuperObj,hGeoObj,p_stMatrix,p_hSuperObjTable,_lNumberMaxOfObjects,_p_lCurrentNumberOfObjects);
}
/*-----------------------------------------------------------------------
* Detect all the objects in the module, with sectors
* OPTIMIZED: 4
*---------------------------------------------------------------------*/
/* used*/
void fn_vDetectAllObjectsInThisModule(
HIE_tdxHandleToSuperObject _hCharacter,
ACP_tdxHandleOfObject _hModule,
POS_tdstCompletePosition * _p_stMatrix,
HIE_tdxHandleToSuperObject * _p_hSuperObjTable,
long _lMaxNumberOfObjects,
long * _lCurrentNumberOfObjects)
{
SECT_tdxHandleOfElementLstCharacter hCharacterList;
SECT_tdxHandleOfElementLstActivityInteraction hActivityList;
long i,j;
HIE_tdxHandleToSuperObject hCharInList;
/* Deal with interactions between characters*/
/* First, the Active Sector*/
SECT_M_ForEachCharListInSector(fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hCharacter,SectInfo)),hCharacterList,i)
{
hCharInList = SECT_GetCharacterInList(hCharacterList);
if( _hCharacter != hCharInList )
{
if( M_ObjectIsActive ((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(hCharInList)) )
{
if( fn_bIsCharacterInZdd(_hModule,_p_stMatrix,hCharInList) )
{
if( (*_lCurrentNumberOfObjects)< _lMaxNumberOfObjects )
{
_p_hSuperObjTable[(*_lCurrentNumberOfObjects)++] = hCharInList;
}
else
break;
}
}
}
}
/* And now, the activity list*/
if( *_lCurrentNumberOfObjects < _lMaxNumberOfObjects )
{
SECT_M_ForEachActivityNodeInActivityInteractionList(fn_h_SectInfoGetCurrentSector(M_GetMSHandle(_hCharacter,SectInfo)),hActivityList,i)
{
if( *_lCurrentNumberOfObjects < _lMaxNumberOfObjects )
{
SECT_M_ForEachCharListInSector(SECT_GetSectorInActivityList(hActivityList),hCharacterList,j)
{
hCharInList = SECT_GetCharacterInList(hCharacterList);
if( M_ObjectIsActive ((struct tdstEngineObject_*)HIE_fn_hGetSuperObjectObject(hCharInList)) )
{
if( fn_bIsCharacterInZdd(_hModule,_p_stMatrix,hCharInList) )
{
if( *_lCurrentNumberOfObjects < _lMaxNumberOfObjects )
{
_p_hSuperObjTable[(*_lCurrentNumberOfObjects)++] = hCharInList;
}
else
break;
}
}
}
}
else
break;
}
}
}
/*-----------------------------------------------------------------------
* For ascendant compatibility
* Variables:
* _hSuperObj Owner of Zdd
* _ucModuleOrCharacter 0 if actor's zones, 1 if module actor's
* zones
* _ucChanelNumber Channel number if _ucModuleOrCharacter=1.
* Number of the actor's zone used if
* _ucModuleOrCharacter=0
* _p_hSuperObjTable Array of HIE_tdxHandleToSuperObject
* _p_uwNumber Must contains the max length of
* _p_hSuperObjTable when function is
* called. After, contains the number of
* objects detected.
* NOTE: this function is called by AI, so, in case of character's ZDX
* channel number is the number of Zone in geometric list, and NOT in
* state list.
*---------------------------------------------------------------------*/
/* used*/
void fn_vGetAllObjectsInZdd(HIE_tdxHandleToSuperObject _hSuperObj,
unsigned char _ucModuleOrCharacter,
unsigned char _ucChannelNumber,
HIE_tdxHandleToSuperObject * _p_hSuperObjTable,
unsigned short * _p_uwNumber)
{
ACP_tdxHandleOfObject hGeoObj;
long lMaxNumberOfObjects;
long lCurrentNumberOfObjects;
lMaxNumberOfObjects = (long)(*_p_uwNumber);
lCurrentNumberOfObjects = 0;
if( _ucModuleOrCharacter )
{
fn_vGetAllObjectsInModuleZdd(_hSuperObj,_ucChannelNumber,_p_hSuperObjTable,lMaxNumberOfObjects,&lCurrentNumberOfObjects);
}
else
{
/* Ok, deals with the geoList, and NOT the state list*/
hGeoObj = fn_hIsThisZoneActive(_hSuperObj,C_ucTypeZdd,(unsigned char)(_ucChannelNumber-1));
if( hGeoObj )
{
fn_vDetectAllObjectsInThisModule(_hSuperObj,hGeoObj,HIE_fn_hGetSuperObjectGlobalMatrix(_hSuperObj),_p_hSuperObjTable,lMaxNumberOfObjects,&lCurrentNumberOfObjects);
}
}
*_p_uwNumber = (unsigned short)lCurrentNumberOfObjects;
}
/*-----------------------------------------------------------------------
* CallBack for activation
*---------------------------------------------------------------------*/
#if defined(GAM_USE_SCRIPT)
/* script*/
SCR_tde_Anl_ReturnValue fn_eScriptCallBackCreateActivation(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;
tdstCsaList * p_stCsaList;
tdstZoneSetEncapsulation * p_stZSE;
SCR_tdst_Link_Value *stLinkValue;
SCR_tdst_Cxt_Values *p_stValues ;
short uwIndex;
tdstZoneSetList * p_stZoneSetList;
tdxHandleToFamilyList hFamily;
/* Get the list to be attached with*/
SCR_M_RdL0_GetSectionLong(C_ParentSection,0,tdstCsaList *,p_stCsaList);
SCR_M_RdL0_GetSectionLong(C_ParentSection,1,tdxHandleToFamilyList,hFamily);
if (M_IsEntry)
{
if( M_ActionIs("ActivationZone") )
{
tdxHandleToState hState2,hState;
char szStateSectionName[_MAX_PATH];
char szLinkTableKey[_MAX_PATH];
char szFileName[_MAX_PATH];
M_CheckScriptParamNumber(2);
/* Compute name of state*/
strcpy(szStateSectionName,fn_szGetFamiliesDataPath());
strcat(szStateSectionName,"\\");
strcat(szStateSectionName,_ap_szParams[1]);
stLinkValue=SCR_fnp_st_Link_CreateOrGetLinkFromKey( &g_st3DOSLinkTable.stState, szStateSectionName);
/* Compute complete name of current section*/
strcpy(szLinkTableKey,fn_szGetFamiliesDataPath());
strcat(szLinkTableKey,"\\");
fn_v_File_ComputeFileSectionName(_ap_szParams[0],szFileName,szLinkTableKey+strlen(szLinkTableKey));
/* Get state from link table*/
stLinkValue=SCR_fnp_st_Link_CreateOrGetLinkFromKey( &g_st3DOSLinkTable.stState, szStateSectionName);
// Shaitan => state list in the level
if (SCR_M_e_Link_GetState(stLinkValue) != SCR_ELS_Link_NotInitialized)
{
// End Shaitan => state list in the level
hState=(tdxHandleToState)stLinkValue->ulValue;
/* Get index of state in array of state*/
LST3_M_StaticWhatElementNumber(hState,&hFamily->hForStateArray,hState2,uwIndex);
/* Load activation*/
stLinkValue=SCR_fnp_st_Link_CreateOrGetLinkFromKey( &g_st3DOSLinkTable.stACZ, szLinkTableKey);
p_stZSE = fn_p_stCreateZoneSetEncapsulation();
p_stValues=SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
p_stZoneSetList=(tdstZoneSetList *)(p_stValues->a_ulValues[0]);
p_stZSE->uwIndex=uwIndex;
p_stZSE->p_stZoneSetList = p_stZoneSetList;
/*LST2_M_StaticAddTail(&p_stCsaList->hZoneSetEncapsulationList,p_stZSE);*/
fn_vInsertZSEInZoneSetList(p_stCsaList,p_stZSE);
SCR_M_RdL0_SetSectionLong(C_ThisSection,0,p_stZoneSetList);
// Shaitan => state list in the level
}
// End Shaitan => state list in the level
}
else
{
M_GameInformationError(E_uwGameScriptCallBackDescriptionUnknownAction);
}
}
return(eReturnValue);
}
#endif /* GAM_USE_SCRIPT */
/*-----------------------------------------------------------------------
* Function need to speed up collisions coz editor can't create
* geometric object with multiples elements
* OPTIMIZED: 1
*---------------------------------------------------------------------*/
/* used*/
ACP_tdxHandleOfObject fn_hMakeOneObjectFromManyZdx(unsigned char _ucZoneType,HIE_tdxHandleToSuperObject _hCharacter)
{
return fn_hMakeOneObjectFromManyOthers( _ucZoneType, _hCharacter, g_hCollisionGeoObj);
}
/* used*/
ACP_tdxHandleOfObject fn_hStaticMakeOneObjectFromManyZdx(unsigned char _ucZoneType,HIE_tdxHandleToSuperObject _hCharacter)
{
return fn_hMakeOneObjectFromManyOthers( _ucZoneType, _hCharacter, g_hStaticCollisionGeoObj);
}
/*-----------------------------------------------------------------------
* Main Function
* OPTIMIZED: 1
*---------------------------------------------------------------------*/
/* used*/
ACP_tdxHandleOfObject fn_hMakeOneObjectFromManyOthers( unsigned char _ucZoneType, HIE_tdxHandleToSuperObject _hCharacter,
ACP_tdxHandleOfObject _hTargetObject)
{
ACP_tdxIndex xIndex;
ACP_tdxHandleOfObject a10_hTable[10];
ACP_tdxHandleOfObject hGeoObj;
ACP_tdxIndex xI;
tdstZdxIndexList *p_stZdxIndex;
tdstZoneSetList *p_stZoneSet;
tdeCollSetPrivilegedActivation ePrivilege;
unsigned short uwCurrentIndexInActivation;
/* Deal with ONE's ZDx */
xIndex = 0;
hGeoObj = NULL;
p_stZoneSet = fn_p_stGetCurrentZoneSetOfType2(_ucZoneType,_hCharacter);
if( fn_bIsAllDefaultPrivilegedActivationZoneOfCharacter(_ucZoneType,_hCharacter) )
{
/* no forced activated or disactivated zone, uses current activation*/
if( p_stZoneSet )
{
ZDX_M_ForEachZdxIndexListOfTypeInZoneSet(_ucZoneType,p_stZoneSet,p_stZdxIndex,xI)
{
hGeoObj = fn_hGetGeometricZdxOfTypeAtIndex(_ucZoneType,fn_uwGetIndexFromZdxIndexList(p_stZdxIndex),_hCharacter);
if (hGeoObj) a10_hTable[xIndex++] = hGeoObj;
}
}
}
else
{
xI = 0;
p_stZdxIndex = (p_stZoneSet ? LST2_M_StaticGetFirstElement( &p_stZoneSet->hZdxIndexList ) : LST2_C_StaticInvalid);
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
while( xI < fn_lGetZdxListNumberOfElements(_ucZoneType,_hCharacter) )
{
ePrivilege = fn_eGetPrivilegedActivationZoneOfCharacter(_ucZoneType,_hCharacter,xI);
if( (ePrivilege == edmPriviligedActivated) ||
((ePrivilege == edmPriviligedDefault) && (uwCurrentIndexInActivation == xI)) )
{
hGeoObj = fn_hGetGeometricZdxOfTypeAtIndex(_ucZoneType,xI,_hCharacter);
if (hGeoObj) a10_hTable[xIndex++] = hGeoObj;
}
/**/
xI++;
if( (p_stZdxIndex != LST2_C_StaticInvalid) && (uwCurrentIndexInActivation < xI) )
{
p_stZdxIndex = LST2_M_StaticGetNextElement( p_stZdxIndex );
uwCurrentIndexInActivation = (unsigned short)((p_stZdxIndex == LST2_C_StaticInvalid) ? -1 : fn_uwGetIndexFromZdxIndexList(p_stZdxIndex));
}
}
}
GEO_fn_hTransformTableOfObjectInOneObjectForGAM(_hTargetObject,a10_hTable,xIndex);
return _hTargetObject;
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vClearCollisionGeometricObject()
{
GEO_fn_vClearObjectForGAM(g_hCollisionGeoObj);
}
void fn_vClearStaticCollisionGeometricObject()
{
GEO_fn_vClearObjectForGAM(g_hStaticCollisionGeoObj);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* used*/
void fn_vFirstTimeInitCollisionGeometricObject()
{
ACP_tdxHandleOfElement hElement;
/* Accelerator for Dynamic ZDM*/
GEO_vCreateGeometricObject( &g_hCollisionGeoObj,
C_ucNbPointsInGeometricAccelerator,
C_ucNbElementsInGeometricAccelerator );
/* Element 0*/
GEO_vCreateElementSpheres(g_hCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
/* Element 1*/
GEO_vCreateElementAlignedBoxes(g_hCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
/* Element 2*/
GEO_vCreateElementCones(g_hCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
/* Element 3*/
GEO_xCreateElementPoints(g_hCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
GEO_vEndModifyObject( g_hCollisionGeoObj );
GEO_vCreateObjectListOfPointsMaterial ( g_hCollisionGeoObj );
GEO_vComputeObjectListOfPointsMaterial(g_hCollisionGeoObj);
/* Accelerator for static ZDM and ZDR*/
GEO_vCreateGeometricObject( &g_hStaticCollisionGeoObj,
C_ucNbPointsInGeometricAccelerator,
C_ucNbElementsInGeometricAccelerator );
/* Element 0*/
GEO_vCreateElementSpheres(g_hStaticCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
/* Element 1*/
GEO_vCreateElementAlignedBoxes(g_hStaticCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
/* Element 2*/
GEO_vCreateElementCones(g_hStaticCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
/* Element 3*/
GEO_xCreateElementPoints(g_hStaticCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
GEO_vEndModifyObject( g_hStaticCollisionGeoObj );
GEO_vCreateObjectListOfPointsMaterial ( g_hStaticCollisionGeoObj );
GEO_vComputeObjectListOfPointsMaterial(g_hStaticCollisionGeoObj);
/* ANNECY AV {*/
/*
// Accelerator for dynamic ZDR
GEO_vCreateGeometricObject( &g_hZdrCollisionGeoObj,
C_ucNbPointsInGeometricAccelerator,
C_ucNbElementsInGeometricAccelerator );
// Element 0
GEO_vCreateElementSpheres(g_hZdrCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
// Element 1
GEO_vCreateElementAlignedBoxes(g_hZdrCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
// Element 2
GEO_vCreateElementCones(g_hZdrCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
// Element 3
GEO_xCreateElementPoints(g_hZdrCollisionGeoObj,
&hElement,C_ucNumberBidulesInElements);
GEO_vEndModifyObject( g_hZdrCollisionGeoObj );
GEO_vCreateObjectListOfPointsMaterial ( g_hZdrCollisionGeoObj );
GEO_vComputeObjectListOfPointsMaterial(g_hZdrCollisionGeoObj);
*/
/* END ANNECY AV }*/
}
/*-----------------------------------------------------------------------
* Zdx drawing management for one character
*---------------------------------------------------------------------*/
/*ANNECY TQ 27/04/98{*/
/* Oliv' - 19/05/1999 - I want to see Zdx too */
#if defined(_DEBUG) || defined(_U64_GLI_BENCH_)
/* EndOfOliv' */
/*ENDANNECY TQ}*/
/* debug*/
void fn_vSetActivationOfModuleZdxDrawing(
HIE_tdxHandleToSuperObject _hCharacter,ACP_tdxBool _bState)
{
if( _bState )
{
fn_v3dDataSetZdxMask(M_GetMSHandle(_hCharacter,3dData),
fn_l3dDataGetZdxMask(M_GetMSHandle(_hCharacter,3dData))
| C_lModuleZdxAreOn );
}
else
{
fn_v3dDataSetZdxMask(M_GetMSHandle(_hCharacter,3dData),
fn_l3dDataGetZdxMask(M_GetMSHandle(_hCharacter,3dData))
& C_lAllZdxAreOn-C_lModuleZdxAreOn);
}
}
/* debug*/
void fn_vSetActivationOfCharacterZdxDrawing(
HIE_tdxHandleToSuperObject _hCharacter,ACP_tdxBool _bState)
{
if( _bState )
{
fn_v3dDataSetZdxMask(M_GetMSHandle(_hCharacter,3dData),
fn_l3dDataGetZdxMask(M_GetMSHandle(_hCharacter,3dData))
| C_lCharacterZdxAreOn );
}
else
{
fn_v3dDataSetZdxMask(M_GetMSHandle(_hCharacter,3dData),
fn_l3dDataGetZdxMask(M_GetMSHandle(_hCharacter,3dData))
& C_lAllZdxAreOn-C_lCharacterZdxAreOn);
}
}
/* debug*/
void fn_vSetActivationOfZoneTypeDrawing(
HIE_tdxHandleToSuperObject _hCharacter,ACP_tdxBool _bState,
unsigned char _ucZoneType)
{
long lMaskModificator = 0;
if( _ucZoneType== C_ucTypeZdd )
{
lMaskModificator = C_lZddAreOn;
}
else if( _ucZoneType== C_ucTypeZde )
{
lMaskModificator = C_lZdeAreOn;
}
else if( _ucZoneType== C_ucTypeZdr )
{
lMaskModificator = C_lZdrAreOn;
}
else if( _ucZoneType== C_ucTypeZdm )
{
lMaskModificator = C_lZdmAreOn;
}
if( _bState )
{
fn_v3dDataSetZdxMask(M_GetMSHandle(_hCharacter,3dData),
fn_l3dDataGetZdxMask(M_GetMSHandle(_hCharacter,3dData))
| lMaskModificator | C_lModuleZdxAreOn | C_lCharacterZdxAreOn);
}
else
{
fn_v3dDataSetZdxMask(M_GetMSHandle(_hCharacter,3dData),
fn_l3dDataGetZdxMask(M_GetMSHandle(_hCharacter,3dData))
& C_lAllZdxAreOn-lMaskModificator);
}
}
/* debug*/
void fn_vUnactivateAllZdxDisplay(
HIE_tdxHandleToSuperObject _hCharacter)
{
fn_v3dDataSetZdxMask(M_GetMSHandle(_hCharacter,3dData),0);
}
/* debug*/
void fn_vActivateAllZdxDisplay(
HIE_tdxHandleToSuperObject _hCharacter)
{
fn_v3dDataSetZdxMask(M_GetMSHandle(_hCharacter,3dData),
C_lAllZdxAreOn);
}
/*-----------------------------------------------------------------------
* Zdx drawing management for all characters
*---------------------------------------------------------------------*/
/*** Module ZDX ***/
/* debug*/
void fn_vRecursiveSetActivationOfModuleZdxDrawing(
HIE_tdxHandleToSuperObject _hSO,ACP_tdxBool _bState)
{
HIE_tdxHandleToSuperObject hChild;
ACP_tdxIndex xI;
HIE_M_ForEachChildOf(_hSO,hChild,xI)
{
fn_vRecursiveSetActivationOfModuleZdxDrawing(hChild,_bState);
}
if( HIE_fn_ulGetSuperObjectType(_hSO)==HIE_C_ulActor )
{
fn_vSetActivationOfModuleZdxDrawing(_hSO,_bState);
}
}
/* debug*/
void fn_vSetActivationOfModuleZdxDrawingForAllCharacters(ACP_tdxBool _bState)
{
fn_vRecursiveSetActivationOfModuleZdxDrawing(
gp_stDynamicWorld,_bState);
}
/*** Character ZDX ***/
/* debug*/
void fn_vRecursiveSetActivationOfCharacterZdxDrawing(
HIE_tdxHandleToSuperObject _hSO,ACP_tdxBool _bState)
{
HIE_tdxHandleToSuperObject hChild;
ACP_tdxIndex xI;
HIE_M_ForEachChildOf(_hSO,hChild,xI)
{
fn_vRecursiveSetActivationOfCharacterZdxDrawing(hChild,_bState);
}
if( HIE_fn_ulGetSuperObjectType(_hSO)==HIE_C_ulActor )
{
fn_vSetActivationOfCharacterZdxDrawing(_hSO,_bState);
}
}
/* debug*/
void fn_vSetActivationOfCharacterZdxDrawingForAllCharacters(ACP_tdxBool _bState)
{
fn_vRecursiveSetActivationOfCharacterZdxDrawing(
gp_stDynamicWorld,_bState);
}
/*** Display according to the type of ZDX ***/
/* debug*/
void fn_vRecursiveSetActivationOfZoneTypeDrawing(
HIE_tdxHandleToSuperObject _hSO,ACP_tdxBool _bState,
unsigned char _ucZoneType)
{
HIE_tdxHandleToSuperObject hChild;
ACP_tdxIndex xI;
HIE_M_ForEachChildOf(_hSO,hChild,xI)
{
fn_vRecursiveSetActivationOfZoneTypeDrawing(hChild,_bState,_ucZoneType);
}
if( HIE_fn_ulGetSuperObjectType(_hSO)==HIE_C_ulActor )
{
fn_vSetActivationOfZoneTypeDrawing(_hSO,_bState,_ucZoneType);
}
}
/* debug*/
void fn_vSetActivationOfZoneTypeDrawingForAllCharacters(
ACP_tdxBool _bState,unsigned char _ucZoneType)
{
fn_vRecursiveSetActivationOfZoneTypeDrawing(
gp_stDynamicWorld,_bState,_ucZoneType);
}
/*** All ZDX for all characters ***/
/* debug*/
void fn_vRecursiveUnactivateAllZdxDisplay(
HIE_tdxHandleToSuperObject _hSO)
{
HIE_tdxHandleToSuperObject hChild;
ACP_tdxIndex xI;
HIE_M_ForEachChildOf(_hSO,hChild,xI)
{
fn_vRecursiveUnactivateAllZdxDisplay(hChild);
}
if( HIE_fn_ulGetSuperObjectType(_hSO)==HIE_C_ulActor )
{
fn_vUnactivateAllZdxDisplay(_hSO);
}
}
/* debug*/
void fn_vUnactivateAllZdxDisplayForAllCharacters()
{
fn_vRecursiveUnactivateAllZdxDisplay(gp_stDynamicWorld);
}
/* debug*/
void fn_vRecursiveActivateAllZdxDisplay(
HIE_tdxHandleToSuperObject _hSO)
{
HIE_tdxHandleToSuperObject hChild;
ACP_tdxIndex xI;
HIE_M_ForEachChildOf(_hSO,hChild,xI)
{
fn_vRecursiveActivateAllZdxDisplay(hChild);
}
if( HIE_fn_ulGetSuperObjectType(_hSO)==HIE_C_ulActor )
{
fn_vActivateAllZdxDisplay(_hSO);
}
}
/* debug*/
void fn_vActivateAllZdxDisplayForAllCharacters()
{
fn_vRecursiveActivateAllZdxDisplay(gp_stDynamicWorld);
}
/*ANNECY TQ 27/04/98{*/
/* Oliv' - 19/05/1999 - I want to see Zdx too */
#endif /* _DEBUG || _U64_GLI_BENCH_ */
/* EndOfOliv' */
/*ENDANNECY TQ}*/
/*--------------------------------------------------------------------*/
/*** Function to order ZoneSetList by index ***/
/*void GAM_fn_vOrderZoneSetList(ZDX_tdxHandleToZoneSetList _hZoneSetList)*/
/*{*/
/* ZDX_tdxHandleToZdxIndexList hCurrentIndex;*/
/* ZDX_tdxHandleToZdxIndexList hNextIndex;*/
/* ZDX_tdxHandleToZdxIndexList hNext;*/
/* ZDX_tdxHandleToZdxIndexList hPreviousIndex;*/
/* if( LST2_M_StaticGetNumberOfElements( &_hZoneSetList->hZdxIndexList ) == 2 )*/
/* {*/
/* hCurrentIndex = LST2_M_StaticGetFirstElement( &_hZoneSetList->hZdxIndexList );*/
/* hNextIndex = LST2_M_StaticGetNextElement ( hCurrentIndex );*/
/* if( fn_uwGetIndexFromZdxIndexList( hCurrentIndex ) > fn_uwGetIndexFromZdxIndexList( hNextIndex ) )*/
/* {*/
/* LST2_M_StaticIsolate( hCurrentIndex );*/
/* LST2_M_StaticAddTail( &_hZoneSetList->hZdxIndexList , hCurrentIndex );*/
/* }*/
/* }*/
/* else if( LST2_M_StaticGetNumberOfElements( &_hZoneSetList->hZdxIndexList ) > 2 )*/
/* {*/
/* hCurrentIndex = LST2_M_StaticGetFirstElement( &_hZoneSetList->hZdxIndexList );*/
/* hCurrentIndex = LST2_M_StaticGetNextElement ( hCurrentIndex ); // second*/
/* hNextIndex = LST2_M_StaticGetNextElement ( hCurrentIndex ); // third*/
/* do {*/
/* hPreviousIndex = LST2_M_StaticGetPrevElement( hCurrentIndex );*/
/* while( (hPreviousIndex != LST2_C_StaticInvalid) &&*/
/* ( fn_uwGetIndexFromZdxIndexList( hPreviousIndex ) > fn_uwGetIndexFromZdxIndexList( hCurrentIndex ) ) )*/
/* {*/
/* hPreviousIndex = LST2_M_StaticGetPrevElement( hPreviousIndex );*/
/* }*/
/* if( hPreviousIndex != LST2_M_StaticGetPrevElement( hCurrentIndex ) )*/
/* {*/
/* LST2_M_StaticIsolate( hCurrentIndex );*/
/* if( hPreviousIndex )*/
/* {*/
/* hNext = LST2_M_StaticGetNextElement( hPreviousIndex );*/
/* LST2_M_StaticInsertBetween( hCurrentIndex, hPreviousIndex, hNext );*/
/* }*/
/* else*/
/* {*/
/* LST2_M_StaticAddHead( &_hZoneSetList->hZdxIndexList , hCurrentIndex );*/
/* }*/
/* }*/
/* hCurrentIndex = hNextIndex;*/
/* if( hCurrentIndex != LST2_C_StaticInvalid )*/
/* hNextIndex = LST2_M_StaticGetNextElement ( hNextIndex );*/
/* } while( hCurrentIndex != LST2_C_StaticInvalid );*/
/* }*/
/*}*/
#if defined(GAM_USE_SCRIPT)
/* Function used only by script callback*/
void fn_vInsertZdxIndexInZoneSetList(ZDX_tdxHandleToZoneSetList _hZoneSetList,ZDX_tdxHandleToZdxIndexList _hIndex)
{
ZDX_tdxHandleToZdxIndexList hIndexCurrent;
ZDX_tdxHandleToZdxIndexList hIndexNext;
if (LST2_M_StaticGetNumberOfElements(&_hZoneSetList->hZdxIndexList)==0)
{
LST2_M_StaticAddTail(&_hZoneSetList->hZdxIndexList,_hIndex);
}
else
{
/* add on tail*/
hIndexCurrent = LST2_M_StaticGetLastElement(&_hZoneSetList->hZdxIndexList);
if (fn_uwGetIndexFromZdxIndexList (_hIndex) > fn_uwGetIndexFromZdxIndexList (hIndexCurrent))
{
LST2_M_StaticAddTail(&_hZoneSetList->hZdxIndexList,_hIndex);
}
else
{
/* add on head*/
hIndexCurrent = LST2_M_StaticGetFirstElement(&_hZoneSetList->hZdxIndexList);
if (fn_uwGetIndexFromZdxIndexList (_hIndex) < fn_uwGetIndexFromZdxIndexList (hIndexCurrent))
{
LST2_M_StaticAddHead(&_hZoneSetList->hZdxIndexList,_hIndex);
}
else
{
/* insert on list*/
hIndexNext = LST2_M_StaticGetNextElement(hIndexCurrent);
while ((hIndexNext != LST2_C_StaticInvalid) && (fn_uwGetIndexFromZdxIndexList (hIndexNext) < fn_uwGetIndexFromZdxIndexList (_hIndex)))
{
hIndexCurrent = hIndexNext;
hIndexNext = LST2_M_StaticGetNextElement(hIndexNext);
}
LST3_M_StaticInsertBetween(&_hZoneSetList->hZdxIndexList,_hIndex,hIndexCurrent,hIndexNext);
}
}
}
}
#endif
/* used*/
tdeCollSetPrivilegedActivation fn_eGetPrivilegedActivationZoneOfCharacter(unsigned char _ucZoneType,
HIE_tdxHandleToSuperObject _hCharacter,
ACP_tdxIndex _xIndex)
{
register MS_tdxHandleToCollSet hCollSet = M_GetMSHandle(_hCharacter,CollSet);
if( hCollSet )
return( CS_fn_eGetPrivilegedActivationZone(_ucZoneType,hCollSet,_xIndex) );
return edmNumberOfPrivilegedActivation;
}
/* used*/
ACP_tdxBool fn_bIsAllDefaultPrivilegedActivationZoneOfCharacter( unsigned char _ucZoneType,
HIE_tdxHandleToSuperObject _hCharacter)
{
register MS_tdxHandleToCollSet hCollSet = M_GetMSHandle(_hCharacter,CollSet);
if( hCollSet )
return((ACP_tdxBool)( CS_fn_ulGetPrivilegedActivationZoneInCollSet(_ucZoneType,hCollSet) == 0 ));
return TRUE;
}
/*--------------------------------------------------------------------*/
/* used*/
long fn_lGetZdxListNumberOfElements(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj)
{
ZDX_tdxHandleToZdxList hZdxList;
hZdxList = CS_fn_hGetZdxList(ucZoneType,hSuperObj);
if( hZdxList )
return LST2_M_StaticGetNumberOfElements( &hZdxList->hGeoZdxList );
return 0;
}
/*--------------------------------------------------------------------*/
#ifdef ACTIVE_EDITOR
/* active editor only*/
ZDX_tdxHandleToZdxList ZDX_fn_hCreateEmptyListOftype(unsigned char ucZonetype,unsigned short uwNumberOfElements)
{
tdstZdxList * p_stZdxList;
tdstGeometricZdxList * p_stGeoZdxList;
unsigned short uwI;
p_stZdxList=fn_p_stCreateZdxListElement();
p_stZdxList->uwNumberOfZdx=uwNumberOfElements;
for(uwI=0;uwI<uwNumberOfElements;uwI++)
{
p_stGeoZdxList=fn_p_stCreateGeometricZdxListElement();
LST2_M_StaticAddTail(&p_stZdxList->hGeoZdxList,p_stGeoZdxList);
}
return( (ZDX_tdxHandleToZdxList)p_stZdxList );
}
#endif
/*---------------------------------------------------------------------*/
/*
*Add on for binarisation
*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
/* function used by script and not LST2_StaticIsOptimised*/
ZDX_tdxHandleToZoneSetEncapsulation fn_p_stCreateZoneSetEncapsulation()
{
tdstZoneSetEncapsulation * p_stZSE;
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeZoneSetEncapsulation , 0 );
p_stZSE = (tdstZoneSetEncapsulation *)M_p_GameMallocInHLM(sizeof(tdstZoneSetEncapsulation));
LST2_M_StaticInitElement(p_stZSE);
p_stZSE->p_stZoneSetList = NULL;
p_stZSE->uwIndex = 0;
return p_stZSE;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifdef ACTIVE_EDITOR
/* active editor only*/
void fn_vFreeZoneSetEncapsulation(ZDX_tdxHandleToZoneSetEncapsulation _hZSE)
{
MMG_fn_vAddMemoryInfo( MMG_C_lTypeFamily , MMG_C_lSubTypeZoneSetEncapsulation , 0 );
M_GameFreeInHLM( _hZSE );
}
#endif
/*---------------------------------------------------------------------*/
#ifdef ACTIVE_EDITOR
/* active editor only*/
void ZDX_fn_vDestructZdxList(ZDX_tdxHandleToZdxList hZdxList)
{
unsigned short uwI;
tdstGeometricZdxList * p_stGeoZdxList;
tdstGeometricZdxList * p_stGeoZdxListNext;
LST2_M_StaticForEachMovingElementOf(&hZdxList->hGeoZdxList,p_stGeoZdxList,p_stGeoZdxListNext,uwI)
{
LST2_M_StaticIsolate(p_stGeoZdxList);
fn_vFreeGeometricZdxListElement(p_stGeoZdxList);
}
fn_vFreeZdxListElement(hZdxList);
}
#endif
/*---------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
************************************************************************
* Do not add anything after this block of comment
************************************************************************
*----------------------------------------------------------------------*/
#undef D_ZdxStuff_Define_