/*****************
loadCB.c
Ver 1.0

LDT version of 
collision set
loading
*****************/

#include "ldt.h"

/*****************************************************************
Name: 
Description: Create callback for LDT
Author: Mircea Petrescu
Date: 6/29/98
Modified: 
*****************************************************************/
int CS_iCreateGeneral( LDT_tdst_Link *pLink )
{
  PCS_tdxHandleToPhysicalCollSet _hCollideSet;

  _hCollideSet = PCS_fn_hCreatePhysicalCollideSet(1);


  pLink->pObject=(void *)_hCollideSet;
  return 0;
}

/*****************************************************************
Name: 
Description: Load callback for LDT
Author: Mircea Petrescu
Date: 6/29/98
Modified: 
*****************************************************************/
extern HREF g_hRefPO;

#define iPOGeneral_VS 0
#define iCSGeneral_ZDR 1

int CS_iLoadGeneral( LDT_tdst_Link *pLink )
{
  LDT_tdeParseResult result=ParseResult_BeginSection;
  PCS_tdxHandleToPhysicalCollSet _hCollideSet=( PCS_tdxHandleToPhysicalCollSet )pLink->pObject;
  ACP_tdxHandleOfObject   _hGeometricObject;
  int iLen;
  char sz_LongPathForLinkTable[256];

  iLen=LDT_ComputeSectionName(pLink, sz_LongPathForLinkTable);
  SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(&CS_g_stLinkTable,sz_LongPathForLinkTable,(unsigned long)_hCollideSet),1,iLen);

  while( result!=ParseResult_EndSection ) 
  {
  	result=LDT_GetNextEntry();
  	switch( result )
  	{
  	  case ParseResult_Entry: /* an entry */
  	  {
  	    char *szEntry=LDT_szGetEntryName();
  	    switch (*(long*)szEntry)
  	    {
  	      case 'RDZ' : /* ZDR */
  	      {
  			_hGeometricObject = GLI_pLoadGeometricInFile( LDT_szGetParam( 1 ) );
			LDT_AddToRefsTable( g_hRefPO, pLink, iCSGeneral_ZDR, 0); //1, (long)_hGeometricObject );
  	      }
  	      break;
  	      case 'EDZ' : /* ZDE */
  	      {
  			_hGeometricObject = GLI_pLoadGeometricInFile( LDT_szGetParam( 1 ) );
			PCS_fn_vSetZdeGeoObjOfPhysicalCollSet(_hCollideSet,_hGeometricObject);
  	      }
  	      break;
  	      case 'DDZ' : /* ZDD */
  	      {
  			_hGeometricObject = GLI_pLoadGeometricInFile( LDT_szGetParam( 1 ) );
			PCS_fn_vSetZddGeoObjOfPhysicalCollSet(_hCollideSet,_hGeometricObject);
  	      }
  	      break;
  	    }
  	  }
	  break;
	  case ParseResult_BeginSection: /* a subsection */
		  LDT_LoadSection( NULL );
  	}
  }

  return 0;
}


/*-----------------------------------------------------------------------------
/*-----------------------------------------------------------------------------
 *  Description : Used to register all script callback functions
 *-----------------------------------------------------------------------------
 *  Creation date : 05/05/97            Author : Sebastien DAVID (Gïzmo)
 *-----------------------------------------------------------------------------*/
void CS_fn_vRegisterAllScriptSections(void)
{
#if !defined(U64)
	LDT_RegisterType( C_Section_CSGeneral, CS_iCreateGeneral, CS_iLoadGeneral, LDT_REG_SECTION );
#endif /* U64 */
}
