/*******************************************************/
/**** 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"
 
#include "LDT.h"
 
#define lTagZdmTable							'aTmd'
#define lTagZddTable							'aTdd'
#define lTagZdeTable							'aTed'
#define lTagZdrTable							'aTrd'
#define lTagZddActivationTable		'cAdd'
#define lTagZdeActivationTable		'cAed'
#define lTagZdmActivationTable		'cAmd'
#define lTagZdrActivationTable		'cArd'
#define lTagCharacterPriority			'arah'
#define lTagCollisionFlag					'illo'
#define lTagCollComputeFrequency	'Cllo'
 
 
 
/*****************************************************************
Function name   : fn_iCreateCollSet
Description     : 
Author          : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date   : 13-Oct-98
Modified        : 
Return type     : int 
Argument        : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iCreateCollSet( LDT_tdst_Link *pLink )
{
	MS_tdxHandleToCollSet h_CollSet;
	struct tdstEngineObject_ *p_stEngineObject = (struct tdstEngineObject_ *)pLink->pParent->pObject;
 
    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);
 
	pLink->pObject = h_CollSet;
 
  return 0;
}
 
 
 
/*****************************************************************
Function name   : fn_iLoadCollSet
Description     : 
Author          : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date   : 13-Oct-98
Modified        : 
Return type     : int 
Argument        : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iLoadCollSet( LDT_tdst_Link *pLink )
{
  LDT_tdeParseResult result=ParseResult_BeginSection;
	MS_tdxHandleToCollSet h_CollSet = (MS_tdxHandleToCollSet)pLink->pObject;
	ZDX_tdxHandleToZdxList p_stZdxList = NULL;
	ZDX_tdxHandleToCsaList hCsaList = NULL;
	struct tdstEngineObject_ *p_stEngineObject = (struct tdstEngineObject_ *)pLink->pParent->pObject; 
#if 0
	SCR_tdst_Cxt_Values *p_stValues ;
#endif /*0*/
#if defined(ACTIVE_EDITOR)
	char a255_cLinkKey[255];
	int nLen;
#endif /* ACTIVE_EDITOR */
	
 
  while( result!=ParseResult_EndSection ) 
  {
  	result=LDT_GetNextEntry();
  	switch( result )
  	{
  	  case ParseResult_Entry: /* an entry */
  	  {
  	    char *szEntry=LDT_szGetEntryName();
  	    switch (*(long*)(szEntry+1))
  	    {
  	      case  lTagZdmTable : /*  */
  	      {
						p_stZdxList =(ZDX_tdxHandleToZdxList)LDT_LoadSection(LDT_szGetParam(1));
#if defined (ACTIVE_EDITOR)
						nLen = LDT_ComputeSectionName(pLink, a255_cLinkKey);
						SCR_M_v_Link_SetAdditionalLong(
							SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList, a255_cLinkKey,(unsigned long)p_stZdxList),
							1, nLen); 
		 
#endif /* ACTIVE_EDITOR */
						CS_M_SetZdxList(Zdm, h_CollSet, p_stZdxList);
  	      }
  	      break;
  	      case  lTagZddTable : /*  */
  	      {
						p_stZdxList =(ZDX_tdxHandleToZdxList)LDT_LoadSection(LDT_szGetParam(1));
#if defined (ACTIVE_EDITOR)
						nLen = LDT_ComputeSectionName(pLink, a255_cLinkKey);
						SCR_M_v_Link_SetAdditionalLong(
							SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList, a255_cLinkKey,(unsigned long)p_stZdxList),
							1, nLen); 
		 
#endif /* ACTIVE_EDITOR */
						CS_M_SetZdxList(Zdd, h_CollSet, p_stZdxList);
 
  	      }
  	      break;
  	      case  lTagZdeTable : /*  */
  	      {
						p_stZdxList =(ZDX_tdxHandleToZdxList)LDT_LoadSection(LDT_szGetParam(1));
#if defined (ACTIVE_EDITOR)
						nLen = LDT_ComputeSectionName(pLink, a255_cLinkKey);
						SCR_M_v_Link_SetAdditionalLong(
							SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList, a255_cLinkKey,(unsigned long)p_stZdxList),
							1, nLen); 
		 
#endif /* ACTIVE_EDITOR */
						CS_M_SetZdxList(Zde, h_CollSet, p_stZdxList);
 
  	      }
  	      break;
  	      case  lTagZdrTable : /*  */
  	      {
						p_stZdxList =(ZDX_tdxHandleToZdxList)LDT_LoadSection(LDT_szGetParam(1));
#if defined (ACTIVE_EDITOR)
						nLen = LDT_ComputeSectionName(pLink, a255_cLinkKey);
						SCR_M_v_Link_SetAdditionalLong(
							SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList, a255_cLinkKey,(unsigned long)p_stZdxList),
							1, nLen); 
		 
#endif /* ACTIVE_EDITOR */
						CS_M_SetZdxList(Zdr, h_CollSet, p_stZdxList);
 
  	      }
  	      break; 
  	      case  lTagZddActivationTable : /*  */
  	      {
						hCsaList =(ZDX_tdxHandleToCsaList)LDT_LoadSection(LDT_szGetParam(1)); 
 
#if defined (ACTIVE_EDITOR)
						nLen = LDT_ComputeSectionName(pLink, a255_cLinkKey);
						SCR_M_v_Link_SetAdditionalLong(
							SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList, a255_cLinkKey,(unsigned long)hCsaList),
							1, nLen); 
 
#endif /* ACTIVE_EDITOR */
 
						CS_M_SetActivationList(Zdd,h_CollSet,hCsaList);
 
 
  	      }
  	      break;
  	      case  lTagZdeActivationTable : /*  */
  	      {
 
						hCsaList =(ZDX_tdxHandleToCsaList)LDT_LoadSection(LDT_szGetParam(1)); 
 
#if defined (ACTIVE_EDITOR)
						nLen = LDT_ComputeSectionName(pLink, a255_cLinkKey);
						SCR_M_v_Link_SetAdditionalLong(
							SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList, a255_cLinkKey,(unsigned long)hCsaList),
							1, nLen); 
 
#endif /* ACTIVE_EDITOR */
						CS_M_SetActivationList(Zde,h_CollSet,hCsaList);
 
  	      }
  	      break;
  	      case  lTagZdmActivationTable : /*  */
  	      {
 
						hCsaList =(ZDX_tdxHandleToCsaList)LDT_LoadSection(LDT_szGetParam(1)); 
 
#if defined (ACTIVE_EDITOR)
						nLen = LDT_ComputeSectionName(pLink, a255_cLinkKey);
						SCR_M_v_Link_SetAdditionalLong(
							SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList, a255_cLinkKey,(unsigned long)hCsaList),
							1, nLen); 
 
#endif /* ACTIVE_EDITOR */
						CS_M_SetActivationList(Zdm,h_CollSet,hCsaList);
  	      }
  	      break;
  	      case  lTagZdrActivationTable : /*  */
  	      {
 
						hCsaList =(ZDX_tdxHandleToCsaList)LDT_LoadSection(LDT_szGetParam(1)); 
 
#if defined (ACTIVE_EDITOR)
						nLen = LDT_ComputeSectionName(pLink, a255_cLinkKey);
						SCR_M_v_Link_SetAdditionalLong(
							SCR_fnp_st_Link_SetValue(&g_st3DOSLinkTable.stZDXList, a255_cLinkKey,(unsigned long)hCsaList),
							1, nLen); 
 
#endif /* ACTIVE_EDITOR */
						CS_M_SetActivationList(Zdr,h_CollSet,hCsaList);
 
  	      }
  	      break;
  	      case  lTagCharacterPriority : /*  */
  	      {
						CS_fn_vSetCharacterPriority( h_CollSet,(unsigned char)atoi(LDT_szGetParam(1)) );
  	      }
  	      break;
  	      case  lTagCollisionFlag : /*  */
  	      {
						fn_vCollSetSetCharacterCollisionFlag( h_CollSet,(unsigned char)atoi(LDT_szGetParam(1)) );
  	      }
  	      break;
  	      case  lTagCollComputeFrequency : /*  */
  	      {
						fn_vCollSetSetCollComputeFrequency( h_CollSet,(unsigned char)atoi(LDT_szGetParam(1)) );
  	      }
  	      break;
  	    }
  	  }
  	}
  }
 
 
  return 0;
}
 
