/*=========================================================================
* CollSet.cpp : CollSet's functions
*
*
*
*         CollSet MUST BE REPLACE BY THE C FILENAME
*
*
* Version              1.0
* Creation date        01/10/96
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1996
*=======================================================================*/
/*******************************************************/
/**** For the structures and variables declarations ****/
/*******************************************************/
#define D_CollSet_StructureDefine
#define D_CollSet_VariableDefine
 
#include "ToolsCPA.h"
 
#include "Options/Options.h"
#include "Macros.h"
 
#include "Actions/AllActs.h"
 
#include "GameEng.h"
#include "Structur/Engmode.h"
#include "Structur/MemGame.h"
#include "Structur/ErrGame.h"
#include "Structur/Objects.h"
#include "Structur/GameScpt.h"
#include "Structur/stdobjst.h"
 
#include "ObjInit.h"
#include "ZeMem.h"
#include "Family.h"
#include "ObjType.h"
#include "ZdxStuff.h"
#include "Structur/3DOSLkTb.h"
#include "basic.h"
 
/* ANNECY AV {*/
#define C_ucCollSet_NO_COLLISION_WITH_MAP                   0x01
#define C_ucCollSet_NO_COLLISION_WITH_PROJECTILE            0x02
#define C_ucCollSet_NO_COLLISION_WITH_SECONDARY_CHARACTER   0x04
#define C_ucCollSet_NO_COLLISION_WITH_MAIN_CHARACTER        0x08
#define C_ucCollSet_FORCE_COLLISION_WHEN_NOT_MOVING         0x10
#define C_ucCollSet_NO_COLLISION_WITH_OTHER_SECTORS         0x20
#define C_ucCollSet_NO_COLLISION_ZDE_WITH_PROJECTILE        0x40
/* END ANNECY AV }*/
 
/*-----------------------------------------------------------------------------
 *  Description : CollSet's object action script callback
 *-----------------------------------------------------------------------------
 *  Input :         Object pointer
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
#if defined(GAM_USE_SCRIPT)
SCR_tde_Anl_ReturnValue fn_eCollSetScriptCallBack(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action	_eAction)
{
	SCR_tde_Anl_ReturnValue eReturnValue = SCR_ERV_Anl_NormalReturn;
	MS_tdxHandleToCollSet h_CollSet;
	ZDX_tdxHandleToZdxList p_stZdxList = NULL;
	ZDX_tdxHandleToCsaList hCsaList = NULL;
	char szSectionName[_MAX_PATH+2];
	struct tdstEngineObject_ *p_stEngineObject;
	SCR_tdst_Cxt_Values *p_stValues ;
#if defined(ACTIVE_EDITOR)
	char a255_cLinkKey[255];
#endif /* ACTIVE_EDITOR */
 
	_p_stFile=_p_stFile;
 
	SCR_M_RdL0_GetSectionLong(C_ParentSection,0,struct tdstEngineObject_ *, p_stEngineObject);
 
	if (M_IsTitle)
	{
        MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypeCollSet , p_stEngineObject);
		h_CollSet=fn_h_CollSetRealAlloc();
        MMG_fn_vEndMemoryInfo ();
		p_stEngineObject->h_CollSet=h_CollSet;
		fn_vCollSetSetCharacterCollisionFlag(h_CollSet,(unsigned char)1);
		SCR_M_RdL0_SetSectionLong(C_ThisSection,0,h_CollSet);
	}
	else if (M_IsEntry)
	{
		SCR_M_RdL0_GetSectionLong(C_ThisSection,0,MS_tdxHandleToCollSet,h_CollSet);
		if (M_ActionIs(C_EntryZdmTable))
		{
			M_CheckScriptParamNumber(1);
			strcpy(szSectionName,_ap_szParams[0]);
 
			p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
			if(p_stValues)
			{
				p_stZdxList =(ZDX_tdxHandleToZdxList) (p_stValues->a_ulValues[0]);
#if defined(ACTIVE_EDITOR)
				SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
				SCR_M_v_Link_SetAdditionalLong(
					SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList,
					a255_cLinkKey,(unsigned long)p_stZdxList),
					1,
					strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
#endif /* ACTIVE_EDITOR */
			}
			CS_M_SetZdxList(Zdm,h_CollSet,p_stZdxList);
		}
		else if (M_ActionIs(C_EntryZddTable))
		{
			M_CheckScriptParamNumber(1);
			strcpy(szSectionName,_ap_szParams[0]);
			p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
			if(p_stValues)
			{
				p_stZdxList =(ZDX_tdxHandleToZdxList) (p_stValues->a_ulValues[0]);
#if defined(ACTIVE_EDITOR)
				SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
				SCR_M_v_Link_SetAdditionalLong(
					SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList,
					a255_cLinkKey,(unsigned long)p_stZdxList),
					1,
					strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
#endif /* ACTIVE_EDITOR */
			}
			CS_M_SetZdxList(Zdd,h_CollSet,p_stZdxList);
		}
		else if (M_ActionIs(C_EntryZdeTable))
		{
			M_CheckScriptParamNumber(1);
			strcpy(szSectionName,_ap_szParams[0]);
 
			p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
			if(p_stValues)
			{
				p_stZdxList =(ZDX_tdxHandleToZdxList) (p_stValues->a_ulValues[0]);
#if defined(ACTIVE_EDITOR)
				SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
				SCR_M_v_Link_SetAdditionalLong(
					SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList,
					a255_cLinkKey,(unsigned long)p_stZdxList),
					1,
					strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
#endif /* ACTIVE_EDITOR */
			}
			CS_M_SetZdxList(Zde,h_CollSet,p_stZdxList);
		}
		else if (M_ActionIs(C_EntryZdrTable))
		{
			M_CheckScriptParamNumber(1);
			strcpy(szSectionName,_ap_szParams[0]);
 
			p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
			if(p_stValues)
			{
				p_stZdxList =(ZDX_tdxHandleToZdxList) (p_stValues->a_ulValues[0]);
#if defined(ACTIVE_EDITOR)
				SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
				SCR_M_v_Link_SetAdditionalLong(
					SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList,
					a255_cLinkKey,(unsigned long)p_stZdxList),
					1,
					strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
#endif /* ACTIVE_EDITOR */
			}
			CS_M_SetZdxList(Zdr,h_CollSet,p_stZdxList);
		}
		else if (M_ActionIs(C_EntryZddActivationTable))
		{
			M_CheckScriptParamNumber(1);
			strcpy(szSectionName,_ap_szParams[0]);
 
			p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
			if(p_stValues)
			{
				hCsaList =(ZDX_tdxHandleToCsaList) (p_stValues->a_ulValues[0]);
#if defined(ACTIVE_EDITOR)
				SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
				SCR_M_v_Link_SetAdditionalLong(
					SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stACZList,
					a255_cLinkKey,(unsigned long)hCsaList),
					1,
					strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
#endif /* ACTIVE_EDITOR */
			}
			CS_M_SetActivationList(Zdd,h_CollSet,hCsaList);
		}
		else if (M_ActionIs(C_EntryZdeActivationTable))
		{
			M_CheckScriptParamNumber(1);
			strcpy(szSectionName,_ap_szParams[0]);
 
			p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
			if(p_stValues)
			{
				hCsaList =(ZDX_tdxHandleToCsaList) (p_stValues->a_ulValues[0]);
#if defined(ACTIVE_EDITOR)
				SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
				SCR_M_v_Link_SetAdditionalLong(
					SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stACZList,
					a255_cLinkKey,(unsigned long)hCsaList),
					1,
					strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
#endif /* ACTIVE_EDITOR */
			}
			CS_M_SetActivationList(Zde,h_CollSet,hCsaList);
		}
		else if (M_ActionIs(C_EntryZdmActivationTable))
		{
			M_CheckScriptParamNumber(1);
			strcpy(szSectionName,_ap_szParams[0]);
 
			p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
			if(p_stValues)
			{
				hCsaList =(ZDX_tdxHandleToCsaList) (p_stValues->a_ulValues[0]);
#if defined(ACTIVE_EDITOR)
				SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
				SCR_M_v_Link_SetAdditionalLong(
					SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stACZList,
					a255_cLinkKey,(unsigned long)hCsaList),
					1,
					strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
#endif /* ACTIVE_EDITOR */
			}
			CS_M_SetActivationList(Zdm,h_CollSet,hCsaList);
		}
		else if (M_ActionIs(C_EntryZdrActivationTable))
		{
			M_CheckScriptParamNumber(1);
			strcpy(szSectionName,_ap_szParams[0]);
 
			p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_ap_szParams[0], SCR_CDF_uw_Anl_Normal);
			if(p_stValues)
			{
				hCsaList =(ZDX_tdxHandleToCsaList) (p_stValues->a_ulValues[0]);
#if defined(ACTIVE_EDITOR)
				SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLinkKey);
				SCR_M_v_Link_SetAdditionalLong(
					SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stACZList,
					a255_cLinkKey,(unsigned long)hCsaList),
					1,
					strlen(a255_cLinkKey)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
#endif /* ACTIVE_EDITOR */
			}
			CS_M_SetActivationList(Zdr,h_CollSet,hCsaList);
		}
		else if (M_ActionIs(C_Entry_CharacterPriority))
		{
			M_CheckScriptParamNumber(1);
			CS_fn_vSetCharacterPriority( h_CollSet,(unsigned char)fn_lAToI(_ap_szParams[0]) );
		}
		else if ( M_ActionIs(C_EntryCollisionFlag) )
		{
			M_CheckScriptParamNumber(1);
			fn_vCollSetSetCharacterCollisionFlag( h_CollSet,(unsigned char)fn_lAToI(_ap_szParams[0]) );
		}
        else if ( M_ActionIs(C_EntryCollComputeFrequency) )
        {
            M_CheckScriptParamNumber(1);
            fn_vCollSetSetCollComputeFrequency( h_CollSet,(unsigned char)fn_lAToI(_ap_szParams[0]) );
        }
		else
		{
			M_GameInformationError(E_uwGameScriptCallBackDescriptionUnknownAction);
		}
		SCR_M_RdL0_SetSectionLong(C_ThisSection,0,h_CollSet);
 }
 return(eReturnValue);
}
#endif /* GAM_USE_SCRIPT */
 
/*-----------------------------------------------------------------------------
 *  Description : CollSet's mini-structure sizeof
 *-----------------------------------------------------------------------------
 *  Input :         None
 *  Output :        Size of
 *-----------------------------------------------------------------------------
 *  Creation date : 14/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
unsigned long fn_ulCollSetSizeOf()
{
 return(sizeof(struct tdstCollSet_));
}
 
/*-----------------------------------------------------------------------------
 *  Description : CollSet's object action allocation
 *-----------------------------------------------------------------------------
 *  Input :         Object pointer
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vCollSetAlloc(struct tdstEngineObject_ *p_stObject)
{
 if (p_stObject==NULL)
  M_GameFatalError(E_uwGameMiniStructObjectNull);
 
 if (p_stObject->h_CollSet!=NULL)
  M_GameFatalError(E_uwGameMiniStructAllocAlreadyAlloc);
 
 MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypeCollSet , p_stObject);
 p_stObject->h_CollSet = fn_h_CollSetRealAlloc();
 MMG_fn_vEndMemoryInfo ();
 fn_vCollSetInitValueSAI(p_stObject->h_CollSet);
}
 
/*-----------------------------------------------------------------------------
 *  Description : CollSet's object Real Allocation
 *-----------------------------------------------------------------------------
 *  Input :
 *  Output :        Object pointer
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
MS_tdxHandleToCollSet fn_h_CollSetRealAlloc()
{
	tdstCollSet *h_CollSet;
 
	h_CollSet = (tdstCollSet*)M_p_GameMallocInHLM(sizeof(tdstCollSet));
 
	h_CollSet->ucCharacterPriority = 0;
	h_CollSet->hZddList = NULL;
	h_CollSet->hZdeList = NULL;
	h_CollSet->hZdmList = NULL;
	h_CollSet->hZdrList = NULL;
	h_CollSet->hZddActivationList = NULL;
	h_CollSet->hZdeActivationList = NULL;
	h_CollSet->hZdmActivationList = NULL;
	h_CollSet->hZdrActivationList = NULL;
 
#ifdef MAY_BE_SUPPRESSED
	h_CollSet->hInitialZddList = NULL;
	h_CollSet->hInitialZdeList = NULL;
	h_CollSet->hInitialZdmList = NULL;
	h_CollSet->hZddInitialActivationList = NULL;
	h_CollSet->hZdeInitialActivationList = NULL;
	h_CollSet->hZdmInitialActivationList = NULL;
#endif /* MAY_BE_SUPPRESSED */
 
	/*ANNECY BBB {*/
	h_CollSet->stColliderInfo.ucColliderPriority = 0;
	/*ANNECY BBB }*/
 
	h_CollSet->ulFBZddPriviligedZones	= 0;
	h_CollSet->ulFBZdePriviligedZones	= 0;
	h_CollSet->ulFBZdmPriviligedZones	= 0;
	h_CollSet->ulFBZdrPriviligedZones	= 0;
    h_CollSet->ucCollComputeFrequency   = 1;
 
	return(h_CollSet);
}
 
/*-----------------------------------------------------------------------------
 *  Description : CollSet's object action free
 *-----------------------------------------------------------------------------
 *  Input :         Object pointer
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vCollSetFree(struct tdstEngineObject_ *p_stObject)
{
   if (p_stObject==NULL)
      M_GameFatalError(E_uwGameMiniStructObjectNull);
 
   if (p_stObject->h_CollSet==NULL)
      M_GameFatalError(E_uwGameMiniStructNull);
 
   fn_vCollSetFreeInitValueSAI(p_stObject->h_CollSet);
   MMG_fn_vAddMemoryInfo( MMG_C_lTypeMiniStructure , MMG_C_lSubTypeCollSet , p_stObject );
   M_GameFreeInHLM(p_stObject->h_CollSet);
}
 
/*-----------------------------------------------------------------------------
 *  Description : CollSet's object action initialisation
 *-----------------------------------------------------------------------------
 *  Input :         When this function's called (see ObjInit.h)
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vCollSetInit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit)
{
	if (p_stObject==NULL)
		M_GameFatalError(E_uwGameMiniStructObjectNull);
 
	if (p_stObject->h_CollSet==NULL)
		M_GameFatalError(E_uwGameMiniStructNull);
 
	switch(eObjectInit)
	{
 	 case OTI_AlwaysCreated:
		 break;
	 case OTI_MapLoaded:
         fn_vCollSetSavedValueSAI(p_stObject->h_CollSet);
	 case OTI_LoadSavedGame:
	 case OTI_WhenGameStart:
		 fn_vCollSetInitValueSAI(p_stObject->h_CollSet);
		 p_stObject->h_CollSet->stColliderInfo.ucColliderPriority = 0;
		 p_stObject->h_CollSet->ulFBZddPriviligedZones	= 0;
		 p_stObject->h_CollSet->ulFBZdePriviligedZones	= 0;
		 p_stObject->h_CollSet->ulFBZdmPriviligedZones	= 0;
		 p_stObject->h_CollSet->ulFBZdrPriviligedZones	= 0;
		 /* Testing integrity of activation lists*/
/* Oliv' - 21/06/1999 - On U64, we assume Editor did its job well ;-) */
#ifndef D_THROW_ZSE_INDEX
		 fn_vCorrectAllActivationLists(p_stObject);
		 /*fn_vUpdateAllZoneSetForCharacter(fn_h_StandardGameGetSuperObject(p_stObject->h_StandardGame));*/
#endif /* D_THROW_ZSE_INDEX */
/* EndOfOliv' */
		 break;
	 case OTI_PlayerDead:
	 case OTI_ReinitTheMap:
		 p_stObject->h_CollSet->stColliderInfo.ucColliderPriority = 0;
		 p_stObject->h_CollSet->ulFBZddPriviligedZones	= 0;
		 p_stObject->h_CollSet->ulFBZdePriviligedZones	= 0;
		 p_stObject->h_CollSet->ulFBZdmPriviligedZones	= 0;
		 p_stObject->h_CollSet->ulFBZdrPriviligedZones	= 0;
		 break;
	}
}
 
/*-----------------------------------------------------------------------------
 *  Description : CollSet's object action desinitialisation
 *-----------------------------------------------------------------------------
 *  Input :         When this function's called (see ObjInit.h)
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vCollSetDesinit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit)
{
	if (p_stObject==NULL)
		M_GameFatalError(E_uwGameMiniStructObjectNull);
 
	if (p_stObject->h_CollSet==NULL)
		M_GameFatalError(E_uwGameMiniStructNull);
 
	switch(eObjectInit)
	{
	case OTI_ReinitTheMap:
		break;
	case OTI_MapLoaded:
		break;
	case OTI_AlwaysCreated:
	case OTI_PlayerDead:
		break;
	default:
   break;
	}
}
 
/*-----------------------------------------------------------------------------
 *  Description : CollSet's object copy clone action
 *-----------------------------------------------------------------------------
 *  Input :         Handle to destination, handle to source
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 30/06/97            Author : Olivier Jourdan
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vCollSetCopyClone(struct tdstEngineObject_ * _p_stObjectDest,struct tdstEngineObject_ * _p_stObjectSrc)
{
	/* If CollSet doesn't contains pointers to structure that may be*/
	/* changed during the game, this function must only be a :*/
	memcpy(
		_p_stObjectDest->h_CollSet,
		_p_stObjectSrc->h_CollSet,
		fn_ulCollSetSizeOf()
		/*ANNECY BBB {*/
		/*do not copy the internal datae, because these are only communication handling variables*/
		- sizeof(struct stColliderInfo_)
		/*ANNECY BBB }*/
 
		);
}
 
/*ANNECY BBB {*/
unsigned char fn_ucCollSetGetColliderPriority(MS_tdxHandleToCollSet _hCollSet)
{
	return _hCollSet->stColliderInfo.ucColliderPriority;
}
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned char fn_ucCollSetGetColliderPrioritySO (HIE_tdxHandleToSuperObject _hSuperObject)
{
  MS_tdxHandleToCollSet h_CollSet = _hSuperObject ? M_GetMSHandle(_hSuperObject,CollSet) : NULL;
	return (unsigned char) (h_CollSet ? fn_ucCollSetGetColliderPriority(h_CollSet) : (unsigned char) 0);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
 
unsigned char fn_ucCollSetGetColliderType(MS_tdxHandleToCollSet _hCollSet)
{
	return _hCollSet->stColliderInfo.ucColliderType;
}
 
MTH3D_tdstVector fn_stCollSetGetColliderVector(MS_tdxHandleToCollSet _hCollSet, short _wIndex)
{
	MTH3D_tdstVector stNullVect = { MTH_C_ZERO, MTH_C_ZERO, MTH_C_ZERO };
 
	return ( _wIndex >= 0 && _wIndex < C_wCollsetNbCollisionVectors )
	? _hCollSet->stColliderInfo.a_stColliderVectors[_wIndex]
	: stNullVect;
}
 
MTH_tdxReal fn_xCollSetGetColliderReal(MS_tdxHandleToCollSet _hCollSet, short _wIndex)
{
	return ( _wIndex >= 0 && _wIndex < C_wCollsetNbCollisionReals )
	? _hCollSet->stColliderInfo.a_xColliderReals[_wIndex]
	: MTH_C_ZERO;
}
 
void fn_vCollSetSetColliderPriority(MS_tdxHandleToCollSet _hCollSet, unsigned char _ucPri)
{
	_hCollSet->stColliderInfo.ucColliderPriority = _ucPri;
}
 
void fn_vCollSetSetColliderType(MS_tdxHandleToCollSet _hCollSet, unsigned char _ucType)
{
	_hCollSet->stColliderInfo.ucColliderType = _ucType;
}
 
void fn_vCollSetSetColliderVector(MS_tdxHandleToCollSet _hCollSet, short _wIndex, MTH3D_tdstVector *_p_stVector)
{
	if ( _wIndex >= 0 && _wIndex < C_wCollsetNbCollisionVectors )
		_hCollSet->stColliderInfo.a_stColliderVectors[_wIndex] = *_p_stVector;
}
 
void fn_vCollSetSetColliderReal(MS_tdxHandleToCollSet _hCollSet, short _wIndex, MTH_tdxReal _xReal)
{
	if ( _wIndex >= 0 && _wIndex < C_wCollsetNbCollisionReals )
		_hCollSet->stColliderInfo.a_xColliderReals[_wIndex] = _xReal;
}
/*ANNECY BBB }*/
 
/*--------------------------------------------------------------------*/
ZDX_tdxHandleToZdxList CS_fn_hGetZdxList(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj)
{
   if( !M_GetMSHandle(hSuperObj,CollSet) )
      return NULL;
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      return( CS_M_GetZdxList(Zdd,M_GetMSHandle(hSuperObj,CollSet)) );
      break;
   case C_ucTypeZde:
      return( CS_M_GetZdxList(Zde,M_GetMSHandle(hSuperObj,CollSet)) );
      break;
   case C_ucTypeZdm:
      return( CS_M_GetZdxList(Zdm,M_GetMSHandle(hSuperObj,CollSet)) );
      break;
   case C_ucTypeZdr:
      return( CS_M_GetZdxList(Zdr,M_GetMSHandle(hSuperObj,CollSet)) );
      break;
   default:
      return NULL;
      break;
   }
}
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void CS_fn_vSetZdxList(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj,ZDX_tdxHandleToZdxList hZdxList)
{
   if( !M_GetMSHandle(hSuperObj,CollSet) )		return;
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      CS_M_SetZdxList(Zdd,M_GetMSHandle(hSuperObj,CollSet),hZdxList);
      break;
   case C_ucTypeZde:
      CS_M_SetZdxList(Zde,M_GetMSHandle(hSuperObj,CollSet),hZdxList);
      break;
   case C_ucTypeZdm:
      CS_M_SetZdxList(Zdm,M_GetMSHandle(hSuperObj,CollSet),hZdxList);
      break;
   case C_ucTypeZdr:
      CS_M_SetZdxList(Zdr,M_GetMSHandle(hSuperObj,CollSet),hZdxList);
      break;
   }
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
/*--------------------------------------------------------------------*/
ZDX_tdxHandleToCsaList CS_fn_hGetActivationList(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj)
{
    MS_tdxHandleToCollSet h_CollSet = hSuperObj ? M_GetMSHandle(hSuperObj,CollSet) : NULL;
 
    return( h_CollSet ? CS_fn_hGetActivationListInCollSet(ucZoneType,h_CollSet) : NULL);
}
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void CS_fn_vSetActivationList(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj,ZDX_tdxHandleToCsaList hCsaList)
{
    MS_tdxHandleToCollSet h_CollSet = hSuperObj ? M_GetMSHandle(hSuperObj,CollSet) : NULL;
	if( h_CollSet )
		CS_fn_vSetActivationListInCollSet(ucZoneType,h_CollSet,hCsaList);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
/*--------------------------------------------------------------------*/
ZDX_tdxHandleToCsaList CS_fn_hGetActivationListInCollSet(unsigned char ucZoneType,MS_tdxHandleToCollSet hCollSet)
{
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      return( CS_M_GetActivationList(Zdd,hCollSet) );
      break;
   case C_ucTypeZde:
      return( CS_M_GetActivationList(Zde,hCollSet) );
      break;
   case C_ucTypeZdm:
      return( CS_M_GetActivationList(Zdm,hCollSet) );
      break;
   case C_ucTypeZdr:
      return( CS_M_GetActivationList(Zdr,hCollSet) );
      break;
   default:
      return NULL;
      break;
   }
}
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void CS_fn_vSetActivationListInCollSet(unsigned char ucZoneType,MS_tdxHandleToCollSet hCollSet,ZDX_tdxHandleToCsaList hCsaList)
{
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      CS_M_SetActivationList(Zdd,hCollSet,hCsaList);
      break;
   case C_ucTypeZde:
      CS_M_SetActivationList(Zde,hCollSet,hCsaList);
      break;
   case C_ucTypeZdm:
      CS_M_SetActivationList(Zdm,hCollSet,hCsaList);
      break;
   case C_ucTypeZdr:
      CS_M_SetActivationList(Zdr,hCollSet,hCsaList);
      break;
   }
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
/*--------------------------------------------------------------------*/
unsigned char CS_fn_ucGetCharacterPriority(MS_tdxHandleToCollSet _hCollSet)
{
   return( _hCollSet->ucCharacterPriority );
}
/*--------------------------------------------------------------------*/
void CS_fn_vSetCharacterPriority(MS_tdxHandleToCollSet hCollSet,unsigned char _ucPriority)
{
   hCollSet->ucCharacterPriority = _ucPriority;
}
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned char fn_ucCollSetGetCharacterCollisionFlag(MS_tdxHandleToCollSet _hCollSet)
{
   return ( _hCollSet->ucCollisionFlag );
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
/*--------------------------------------------------------------------*/
void fn_vCollSetSetCharacterCollisionFlag(MS_tdxHandleToCollSet _hCollSet,unsigned char _ucCollisionFlag)
{
   _hCollSet->ucCollisionFlag = _ucCollisionFlag;
}
 
/*--------------------------------------------------------------------*/
/* ANNECY AV {*/
ACP_tdxBool fn_bCollSetGetCharacterNoCollisionWithMap (MS_tdxHandleToCollSet _hCollSet)
{
    return (ACP_tdxBool) (_hCollSet->ucCollisionFlag & C_ucCollSet_NO_COLLISION_WITH_MAP);
}
 
/*--------------------------------------------------------------------*/
ACP_tdxBool fn_bCollSetGetCharacterNoCollisionWithProjectile (MS_tdxHandleToCollSet _hCollSet)
{
    return (ACP_tdxBool) (_hCollSet->ucCollisionFlag & C_ucCollSet_NO_COLLISION_WITH_PROJECTILE);
}
 
/*--------------------------------------------------------------------*/
ACP_tdxBool fn_bCollSetGetCharacterNoCollisionWithSecondaryCharacter (MS_tdxHandleToCollSet _hCollSet)
{
    return (ACP_tdxBool) (_hCollSet->ucCollisionFlag & C_ucCollSet_NO_COLLISION_WITH_SECONDARY_CHARACTER);
}
 
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
ACP_tdxBool fn_bCollSetGetCharacterForceCollisionWhenNotMoving (MS_tdxHandleToCollSet _hCollSet)
{
    return (ACP_tdxBool) (_hCollSet->ucCollisionFlag & C_ucCollSet_FORCE_COLLISION_WHEN_NOT_MOVING);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
/*--------------------------------------------------------------------*/
ACP_tdxBool fn_bCollSetGetCharacterNoCollisionWithMainCharacter (MS_tdxHandleToCollSet _hCollSet)
{
    return (ACP_tdxBool) (_hCollSet->ucCollisionFlag & C_ucCollSet_NO_COLLISION_WITH_MAIN_CHARACTER);
}
 
/*--------------------------------------------------------------------*/
ACP_tdxBool fn_bCollSetGetCharacterNoCollisionWithOtherSectors (MS_tdxHandleToCollSet _hCollSet)
{
    return (ACP_tdxBool) (_hCollSet->ucCollisionFlag & C_ucCollSet_NO_COLLISION_WITH_OTHER_SECTORS);
}
 
/*--------------------------------------------------------------------*/
ACP_tdxBool fn_bCollSetGetCharacterNoCollisionZdeWithProjectile (MS_tdxHandleToCollSet _hCollSet)
{
    return (ACP_tdxBool) (_hCollSet->ucCollisionFlag & C_ucCollSet_NO_COLLISION_ZDE_WITH_PROJECTILE);
}
 
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
void fn_vCollSetSetCharacterNoCollisionWithMap (MS_tdxHandleToCollSet _hCollSet, ACP_tdxBool _bValue)
{
    if (_bValue)  _hCollSet->ucCollisionFlag |=   C_ucCollSet_NO_COLLISION_WITH_MAP;
            else  _hCollSet->ucCollisionFlag &= ~ C_ucCollSet_NO_COLLISION_WITH_MAP;
}
 
/*--------------------------------------------------------------------*/
void fn_vCollSetSetCharacterNoCollisionWithProjectile (MS_tdxHandleToCollSet _hCollSet, ACP_tdxBool _bValue)
{
    if (_bValue)  _hCollSet->ucCollisionFlag |=   C_ucCollSet_NO_COLLISION_WITH_PROJECTILE;
            else  _hCollSet->ucCollisionFlag &= ~ C_ucCollSet_NO_COLLISION_WITH_PROJECTILE;
}
 
/*--------------------------------------------------------------------*/
void fn_vCollSetSetCharacterNoCollisionWithSecondaryCharacter (MS_tdxHandleToCollSet _hCollSet, ACP_tdxBool _bValue)
{
    if (_bValue)  _hCollSet->ucCollisionFlag |=   C_ucCollSet_NO_COLLISION_WITH_SECONDARY_CHARACTER;
            else  _hCollSet->ucCollisionFlag &= ~ C_ucCollSet_NO_COLLISION_WITH_SECONDARY_CHARACTER;
}
 
/*--------------------------------------------------------------------*/
void fn_vCollSetSetCharacterNoCollisionWithMainCharacter (MS_tdxHandleToCollSet _hCollSet, ACP_tdxBool _bValue)
{
    if (_bValue)  _hCollSet->ucCollisionFlag |=   C_ucCollSet_NO_COLLISION_WITH_MAIN_CHARACTER;
            else  _hCollSet->ucCollisionFlag &= ~ C_ucCollSet_NO_COLLISION_WITH_MAIN_CHARACTER;
}
 
/*--------------------------------------------------------------------*/
void fn_vCollSetSetCharacterNoCollisionWithOtherSectors (MS_tdxHandleToCollSet _hCollSet, ACP_tdxBool _bValue)
{
    if (_bValue)  _hCollSet->ucCollisionFlag |=   C_ucCollSet_NO_COLLISION_WITH_OTHER_SECTORS;
            else  _hCollSet->ucCollisionFlag &= ~ C_ucCollSet_NO_COLLISION_WITH_OTHER_SECTORS;
}
 
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vCollSetSetCharacterForceCollisionWhenNotMoving (MS_tdxHandleToCollSet _hCollSet, ACP_tdxBool _bValue)
{
    if (_bValue)  _hCollSet->ucCollisionFlag |=   C_ucCollSet_FORCE_COLLISION_WHEN_NOT_MOVING;
            else  _hCollSet->ucCollisionFlag &= ~ C_ucCollSet_FORCE_COLLISION_WHEN_NOT_MOVING;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
/*--------------------------------------------------------------------*/
 
 
void fn_vCollSetSetCharacterNoCollisionZdeWithProjectile (MS_tdxHandleToCollSet _hCollSet, ACP_tdxBool _bValue)
{
    if (_bValue)  _hCollSet->ucCollisionFlag |=   C_ucCollSet_NO_COLLISION_ZDE_WITH_PROJECTILE;
            else  _hCollSet->ucCollisionFlag &= ~ C_ucCollSet_NO_COLLISION_ZDE_WITH_PROJECTILE;
}
 
 
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
ACP_tdxBool fn_bGetCharacterNoCollisionWithMap (HIE_tdxHandleToSuperObject _hSuperObject)
{
    MS_tdxHandleToCollSet h_CollSet = _hSuperObject ? M_GetMSHandle(_hSuperObject,CollSet) : NULL;
 
    return (ACP_tdxBool) (h_CollSet ? h_CollSet -> ucCollisionFlag & C_ucCollSet_NO_COLLISION_WITH_MAP : TRUE);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
/*--------------------------------------------------------------------*/
ACP_tdxBool fn_bGetCharacterForceCollisionWhenNotMoving (HIE_tdxHandleToSuperObject _hSuperObject)
{
    MS_tdxHandleToCollSet h_CollSet = _hSuperObject ? M_GetMSHandle(_hSuperObject,CollSet) : NULL;
 
    return (ACP_tdxBool) (h_CollSet ? h_CollSet -> ucCollisionFlag & C_ucCollSet_FORCE_COLLISION_WHEN_NOT_MOVING : FALSE);
}
 
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vSetCharacterNoCollisionWithMap (HIE_tdxHandleToSuperObject _hSuperObject, ACP_tdxBool _bValue)
{
    MS_tdxHandleToCollSet h_CollSet = _hSuperObject ? M_GetMSHandle(_hSuperObject,CollSet) : NULL;
 
	if (h_CollSet)
	{
		if (_bValue)  M_GetMSHandle (_hSuperObject,CollSet) -> ucCollisionFlag |=   C_ucCollSet_NO_COLLISION_WITH_MAP;
				else  M_GetMSHandle (_hSuperObject,CollSet) -> ucCollisionFlag &= ~ C_ucCollSet_NO_COLLISION_WITH_MAP;
	}
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
/* END ANNECY AV }*/
 
/*--------------------------------------------------------------------*/
void fn_vCollSetSetCollComputeFrequency(MS_tdxHandleToCollSet _hCollSet,unsigned char _ucFrequency)
{
    _hCollSet -> ucCollComputeFrequency = _ucFrequency;
}
 
/*--------------------------------------------------------------------*/
unsigned char fn_ucCollSetGetCollComputeFrequency(MS_tdxHandleToCollSet _hCollSet)
{
    return (unsigned char)(_hCollSet ? _hCollSet -> ucCollComputeFrequency : 1);
}
 
/*--------------------------------------------------------------------*/
unsigned char fn_ucCollSetGetCollComputeFrequencySO(HIE_tdxHandleToSuperObject hSuperObj)
{
    MS_tdxHandleToCollSet h_CollSet = hSuperObj ? M_GetMSHandle(hSuperObj,CollSet) : NULL;
 
    return (unsigned char)( h_CollSet ? fn_ucCollSetGetCollComputeFrequency( h_CollSet ) : 1 );
}
 
/*--------------------------------------------------------------------*/
#ifndef D_THROW_ZSE_INDEX	/* Oliv' - 21/06/1999 */
void fn_vCorrectAllActivationLists(struct tdstEngineObject_ * _p_stObject)
{
   if( _p_stObject->h_CollSet )
   {
      long lNumberOfState;
      MS_tdxHandleToCollSet hCollSet;
      tdstFamily *  hFamily;
 
      hCollSet = _p_stObject->h_CollSet;
      hFamily = (tdstFamily *)fn_h3dDataGetFamily(_p_stObject->h_3dData);
      lNumberOfState = LST2_M_StaticGetNumberOfElements(&hFamily->hForStateArray);
      if( hCollSet->hZddActivationList )
         fn_vCorrectActivationList(hCollSet->hZddActivationList,lNumberOfState);
      if( hCollSet->hZdeActivationList )
         fn_vCorrectActivationList(hCollSet->hZdeActivationList,lNumberOfState);
      if( hCollSet->hZdmActivationList )
         fn_vCorrectActivationList(hCollSet->hZdmActivationList,lNumberOfState);
      if( hCollSet->hZdrActivationList )
         fn_vCorrectActivationList(hCollSet->hZdrActivationList,lNumberOfState);
   }
}
#endif /* D_THROW_ZSE_INDEX */
/*--------------------------------------------------------------------*/
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void GAM_fn_vChangeFather(HIE_tdxHandleToSuperObject _hSprObj, HIE_tdxHandleToSuperObject _hNewFather)
{
	ACP_tdxIndex iIndex;
	HIE_tdxHandleToSuperObject hChild;
	HIE_tdxHandleToSuperObject hPrevChild;
	long lPriority,lPriorityNfc;
	MS_tdxHandleToCollSet	hCollSet;
 
	hCollSet=M_GetMSHandle(_hSprObj,CollSet);
	if(hCollSet!=NULL)
	{
		lPriority=CS_fn_ucGetCharacterPriority(hCollSet);
	}
	else
	{
		lPriority=0;
	}
 
	HIE_fn_vInvalidateSuperObject(&hPrevChild);
	HIE_M_ForEachChildOf(_hNewFather, hChild,iIndex)
	{
 
		hCollSet=M_GetMSHandle(_hSprObj,CollSet);
		if(hCollSet!=NULL)
		{
			lPriorityNfc=CS_fn_ucGetCharacterPriority(hCollSet);
		}
		else
		{
			lPriorityNfc=0;
		}
 
		if((HIE_fn_ulGetSuperObjectType(hChild)==HIE_C_ulActor)&&(lPriority>lPriorityNfc)) break;
		hPrevChild=hChild;
	}
	if(HIE_fn_bIsSuperObjectValid(hChild))
	{
		LST2_M_DynamicInsertBetween(_hSprObj, hPrevChild, hChild);
	}
	else
	{
		LST2_M_DynamicAddTail(_hNewFather, _hSprObj);
	}
	HIE_fn_vComputeNewRelativeMatrix(_hSprObj);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
 
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
 
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
#ifdef MAY_BE_SUPPRESSED
 
ZDX_tdxHandleToZdxList CS_fn_hGetZdxInitialList(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj)
{
	MS_tdxHandleToCollSet h_CollSet = hSuperObj ? M_GetMSHandle(hSuperObj,CollSet) : NULL;
 
	if( !h_CollSet )	return NULL;
 
	switch(ucZoneType)
	{
	case C_ucTypeZdd:
		return( CS_M_GetZdxInitialList(Zdd,h_CollSet) );
		break;
	case C_ucTypeZde:
		return( CS_M_GetZdxInitialList(Zde,h_CollSet) );
		break;
	case C_ucTypeZdm:
		return( CS_M_GetZdxInitialList(Zdm,h_CollSet) );
		break;
	default:
		return NULL;
		break;
	}
}
 
void CS_fn_vSetZdxInitialList(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj,ZDX_tdxHandleToZdxList hZdxList)
{
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      CS_M_SetZdxInitialList(Zdd,M_GetMSHandle(hSuperObj,CollSet),hZdxList);
      break;
   case C_ucTypeZde:
      CS_M_SetZdxInitialList(Zde,M_GetMSHandle(hSuperObj,CollSet),hZdxList);
      break;
   case C_ucTypeZdm:
      CS_M_SetZdxInitialList(Zdm,M_GetMSHandle(hSuperObj,CollSet),hZdxList);
      break;
   }
}
 
ZDX_tdxHandleToCsaList CS_fn_hGetActivationInitialList(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj)
{
	MS_tdxHandleToCollSet h_CollSet = hSuperObj ? M_GetMSHandle(hSuperObj,CollSet) : NULL;
    return( h_CollSet ? CS_fn_hGetActivationInitialListInCollSet(ucZoneType,h_CollSet) : NULL );
}
 
void CS_fn_vSetActivationInitialList(unsigned char ucZoneType,HIE_tdxHandleToSuperObject hSuperObj,ZDX_tdxHandleToCsaList hCsaList)
{
	MS_tdxHandleToCollSet h_CollSet = hSuperObj ? M_GetMSHandle(hSuperObj,CollSet) : NULL;
	if (h_CollSet)
		CS_fn_vSetActivationInitialListInCollSet(ucZoneType,h_CollSet,hCsaList);
}
 
struct tdstZdxList_ * CS_fn_hGetZdxListInCollSet(unsigned char ucZoneType,MS_tdxHandleToCollSet hCollSet)
{
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      return( CS_M_GetZdxList(Zdd,hCollSet) );
      break;
   case C_ucTypeZde:
      return( CS_M_GetZdxList(Zde,hCollSet) );
      break;
   case C_ucTypeZdm:
      return( CS_M_GetZdxList(Zdm,hCollSet) );
      break;
   case C_ucTypeZdr:
      return( CS_M_GetZdxList(Zdr,hCollSet) );
      break;
   default:
      return NULL;
      break;
   }
}
 
struct tdstZdxList_ * CS_fn_hGetZdxInitialListInCollSet(unsigned char ucZoneType,MS_tdxHandleToCollSet hCollSet)
{
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      return( CS_M_GetZdxInitialList(Zdd,hCollSet) );
      break;
   case C_ucTypeZde:
      return( CS_M_GetZdxInitialList(Zde,hCollSet) );
      break;
   case C_ucTypeZdm:
      return( CS_M_GetZdxInitialList(Zdm,hCollSet) );
      break;
   default:
      return NULL;
      break;
   }
}
 
void CS_fn_vSetZdxListInCollSet(unsigned char ucZoneType,MS_tdxHandleToCollSet hCollSet,struct tdstZdxList_ * hZdxList)
{
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      CS_M_SetZdxList(Zdd,hCollSet,hZdxList);
      break;
   case C_ucTypeZde:
      CS_M_SetZdxList(Zde,hCollSet,hZdxList);
      break;
   case C_ucTypeZdm:
      CS_M_SetZdxList(Zdm,hCollSet,hZdxList);
      break;
   case C_ucTypeZdr:
      CS_M_SetZdxList(Zdr,hCollSet,hZdxList);
      break;
   }
}
 
void CS_fn_vSetZdxInitialListInCollSet(unsigned char ucZoneType,MS_tdxHandleToCollSet hCollSet,struct tdstZdxList_ * hZdxList)
{
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      CS_M_SetZdxInitialList(Zdd,hCollSet,hZdxList);
      break;
   case C_ucTypeZde:
      CS_M_SetZdxInitialList(Zde,hCollSet,hZdxList);
      break;
   case C_ucTypeZdm:
      CS_M_SetZdxInitialList(Zdm,hCollSet,hZdxList);
      break;
   }
}
 
ZDX_tdxHandleToCsaList CS_fn_hGetActivationInitialListInCollSet(unsigned char ucZoneType,MS_tdxHandleToCollSet hCollSet)
{
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      return( CS_M_GetActivationInitialList(Zdd,hCollSet) );
      break;
   case C_ucTypeZde:
      return( CS_M_GetActivationInitialList(Zde,hCollSet) );
      break;
   case C_ucTypeZdm:
      return( CS_M_GetActivationInitialList(Zdm,hCollSet) );
      break;
   default:
      return NULL;
      break;
   }
}
 
void CS_fn_vSetActivationInitialListInCollSet(unsigned char ucZoneType,MS_tdxHandleToCollSet hCollSet,ZDX_tdxHandleToCsaList hCsaList)
{
   switch(ucZoneType)
   {
   case C_ucTypeZdd:
      CS_M_SetActivationInitialList(Zdd,hCollSet,hCsaList);
      break;
   case C_ucTypeZde:
      CS_M_SetActivationInitialList(Zde,hCollSet,hCsaList);
      break;
   case C_ucTypeZdm:
      CS_M_SetActivationInitialList(Zdm,hCollSet,hCsaList);
      break;
   }
}
 
#endif /* MAY_BE_SUPPRESSED */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
 
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/*-------------------------------------------------------------------
 * Functions for optimisation
 *-------------------------------------------------------------------*/
void fn_vSetCurrentZoneSetOfType(unsigned char _ucZoneType,MS_tdxHandleToCollSet _hCollSet,ZDX_tdxHandleToZoneSetList _hCurrentZoneSet)
{
   switch( _ucZoneType )
   {
   case C_ucTypeZdd:
      _hCollSet->hZddCurrentActivation = _hCurrentZoneSet;
      break;
   case C_ucTypeZdr:
      _hCollSet->hZdrCurrentActivation = _hCurrentZoneSet;
      break;
   case C_ucTypeZde:
      _hCollSet->hZdeCurrentActivation = _hCurrentZoneSet;
      break;
   case C_ucTypeZdm:
      _hCollSet->hZdmCurrentActivation = _hCurrentZoneSet;
      break;
   }
}
 
/*--------------------------------------------------------------------*/
ZDX_tdxHandleToZoneSetList fn_hGetCurrentZoneSetOfType(unsigned char _ucZoneType,MS_tdxHandleToCollSet _hCollSet)
{
   switch( _ucZoneType )
   {
   case C_ucTypeZdd:
      return( _hCollSet->hZddCurrentActivation );
      break;
   case C_ucTypeZdr:
      return( _hCollSet->hZdrCurrentActivation );
      break;
   case C_ucTypeZde:
      return( _hCollSet->hZdeCurrentActivation );
      break;
   case C_ucTypeZdm:
      return( _hCollSet->hZdmCurrentActivation );
      break;
   }
/* Oliv' - Portage v14 - avoid warnings*/
#ifdef U64
	return NULL;
#endif
/* EndOfOliv'*/
}
 
/*--------------------------------------------------------------------*/
unsigned long CS_fn_ulGetPrivilegedActivationZoneInCollSet(unsigned char _ucZoneType,MS_tdxHandleToCollSet _hCollSet)
{
   switch( _ucZoneType )
   {
   case C_ucTypeZdd:
      return CS_M_GetPrivilegedZone(Zdd,_hCollSet);
      break;
   case C_ucTypeZdr:
      return CS_M_GetPrivilegedZone(Zdr,_hCollSet);
      break;
   case C_ucTypeZde:
      return CS_M_GetPrivilegedZone(Zde,_hCollSet);
      break;
   case C_ucTypeZdm:
      return CS_M_GetPrivilegedZone(Zdm,_hCollSet);
      break;
   }
/* Oliv' - Portage v14 - avoid warnings*/
#ifdef U64
	return 0L;
#endif
/* EndOfOliv'*/
}
 
/*--------------------------------------------------------------------*/
void CS_fn_vSetPrivilegedActivationZoneInCollSet(unsigned char _ucZoneType,MS_tdxHandleToCollSet _hCollSet, unsigned long _ulFB)
{
   switch( _ucZoneType )
   {
   case C_ucTypeZdd:
      CS_M_SetPrivilegedZone(Zdd,_hCollSet,_ulFB);
      break;
   case C_ucTypeZdr:
      CS_M_SetPrivilegedZone(Zdr,_hCollSet,_ulFB);
      break;
   case C_ucTypeZde:
      CS_M_SetPrivilegedZone(Zde,_hCollSet,_ulFB);
      break;
   case C_ucTypeZdm:
      CS_M_SetPrivilegedZone(Zdm,_hCollSet,_ulFB);
      break;
   }
}
 
/*--------------------------------------------------------------------*/
void CS_fn_vSetPrivilegedActivationZone(unsigned char _ucZoneType,MS_tdxHandleToCollSet _hCollSet,short _wIndex, tdeCollSetPrivilegedActivation _ePrivilege)
{
	unsigned long ulFB;
	short		  wDecal;
 
	wDecal = (short)(_wIndex<<1);	/* 2 bits by zone*/
	ulFB   = CS_fn_ulGetPrivilegedActivationZoneInCollSet(_ucZoneType,_hCollSet);
	switch(_ePrivilege)
	{
	case edmPriviligedDefault:
		ulFB &= ~((long)(3 << wDecal));	/* forces the 2 bits to 00*/
		break;
	case edmPriviligedActivated:
		ulFB &= ~((long)(3 << wDecal));	/* forces the 2 bits to 00*/
		ulFB |= (1 << wDecal);			/* forces the 2 bits to 01*/
		break;
	case edmPriviligedDisactivated:		/* forces the 2 bits to 00*/
		ulFB &= ~((long)(3 << wDecal));	/* forces the 2 bits to 10*/
		ulFB |= (2 << wDecal);
		break;
	default:
   break;
	}
	CS_fn_vSetPrivilegedActivationZoneInCollSet(_ucZoneType,_hCollSet,ulFB);
}
 
/*--------------------------------------------------------------------*/
tdeCollSetPrivilegedActivation CS_fn_eGetPrivilegedActivationZone(unsigned char _ucZoneType,MS_tdxHandleToCollSet _hCollSet,short _wIndex)
{
	unsigned long ulFB;
	unsigned char ucFlags;
	short		  wDecal;
 
/* ANNECY MT - 18/09/98 {*/
	ulFB    = CS_fn_ulGetPrivilegedActivationZoneInCollSet(_ucZoneType,_hCollSet);
 
	if(!ulFB)		return edmPriviligedDefault;
 
	wDecal  = (short)(_wIndex<<1);	/* 2 bits by zone*/
	ulFB   &= (3 << wDecal);
	ucFlags	= (unsigned char)(ulFB >> wDecal);
/* END ANNECY MT }*/
 
	switch(ucFlags)
	{
	case 0:	/* 00*/
		return edmPriviligedDefault;
		break;
	case 1:	/* 01*/
		return edmPriviligedActivated;
		break;
	case 2:	/* 10*/
		return edmPriviligedDisactivated;
		break;
	}
	return edmNumberOfPrivilegedActivation;
}
 
/*--------------------------------------------------------------------*/
#define CS_M_SAIInitFlags		(SAI_eInitWhenReinitTheMap|SAI_eInitWhenMapLoaded|SAI_eInitWhenNewGameStart)
#define CS_M_SAISaveFlags		(SAI_eLevelSaveCurrentValue)
 
/*--------------------------------------------------------------------*/
void fn_vCollSetInitValueSAI(MS_tdxHandleToCollSet _hCollSet)
{
    SAI_fn_bInsertCharInTable((void*)&_hCollSet->ucCollisionFlag,		CS_M_SAIInitFlags);
    SAI_fn_bInsertCharInTable((void*)&_hCollSet->ucCollComputeFrequency,CS_M_SAIInitFlags);
}
 
/*--------------------------------------------------------------------*/
void fn_vCollSetSavedValueSAI(MS_tdxHandleToCollSet _hCollSet)
{
#if 0
    SAI_fn_bInsertCharInTable((void*)&_hCollSet->ucCollisionFlag,		CS_M_SAISaveFlags);
    SAI_fn_bInsertCharInTable((void*)&_hCollSet->ucCollComputeFrequency,CS_M_SAISaveFlags);
#endif /* 0 */
}
 
/*--------------------------------------------------------------------*/
void fn_vCollSetFreeInitValueSAI(MS_tdxHandleToCollSet _hCollSet)
{
    SAI_fn_bRemoveValueFromTable((void*)&_hCollSet->ucCollisionFlag,		CS_M_SAIInitFlags);
    SAI_fn_bRemoveValueFromTable((void*)&_hCollSet->ucCollComputeFrequency,	CS_M_SAIInitFlags);
 
#if 0
    SAI_fn_bRemoveValueFromTable((void*)&_hCollSet->ucCollisionFlag,		CS_M_SAISaveFlags);
    SAI_fn_bRemoveValueFromTable((void*)&_hCollSet->ucCollComputeFrequency,	CS_M_SAISaveFlags);
#endif /* 0 */
}
 
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vCollSetReInitCharacterCollisionFlag(MS_tdxHandleToCollSet _hCollSet)
{
    SAI_fn_bInitOneValueWhen((void*)&_hCollSet->ucCollisionFlag,			CS_M_SAIInitFlags);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
/*--------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vCollSetReInitCollComputeFrequency(MS_tdxHandleToCollSet _hCollSet)
{
    SAI_fn_bInitOneValueWhen((void*)&_hCollSet->ucCollComputeFrequency,		CS_M_SAIInitFlags);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
#ifdef ACTIVE_EDITOR
 
unsigned char *fn_p_ucCollSetGetCharacterCollisionFlagInit(MS_tdxHandleToCollSet _hCollSet)
{
    return (unsigned char*)SAI_fn_p_vGetTableValuePointerOf((void*)&_hCollSet->ucCollisionFlag,			CS_M_SAIInitFlags);
}
 
/*--------------------------------------------------------------------*/
unsigned char *fn_p_ucCollSetGetCollComputeFrequencyInit(MS_tdxHandleToCollSet _hCollSet)
{
    return (unsigned char*)SAI_fn_p_vGetTableValuePointerOf((void*)&_hCollSet->ucCollComputeFrequency,	CS_M_SAIInitFlags);
}
 
#endif /* ACTIVE_EDITOR */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
 
