/*******************************************************/
/**** For the structures and variables declarations ****/
/*******************************************************/
#define D_3dData_StructureDefine
#define D_3dData_VariableDefine
 
#include "ToolsCPA.h"
 
#include "Options/Options.h"
#include "Macros.h"
 
#include "Structur/StdObjSt.h"
 
#include "Actions/AllActs.h"
 
#include "Structur/3DOSLkTb.h"
#include "Structur/MemGame.h"
#include "Structur/ErrGame.h"
#include "Structur/GameScpt.h"
#include "Structur/EngMode.h"
#include "Structur/Objects.h"
#include "Structur/State.h"
#include "Structur/Anim_s.h"
#include "Structur/objstbls.h"
 
#include "PlayAnim/PlayAnim.h"
 
#include "GameEng.h"
#include "Basic.h"
#include "ChanList.h"
#include "ObjInit.h"
#include "ObjType.h"
#include "ZdxStuff.h"
#include "ZeMem.h"
#include "Family.h"
#include "TBLLoad.h"
 
#include "ldt.h"
 
/*****************************************************************
Name: 
Description: Create callback for LDT
Author: Mircea Petrescu
Date: 8/21/98
Modified: Scripa Ovidiu 09/01/98
*****************************************************************/
int fn_iCreate3dData( LDT_tdst_Link *pLink )
{
  MS_tdxHandleTo3dData h_3dData;
  struct tdstEngineObject_ *p_stEngineObject;
 
	p_stEngineObject=(struct tdstEngineObject_ *)pLink->pParent->pObject;
	
    MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubType3dData , p_stEngineObject);
	h_3dData = fn_h_3dDataRealAlloc();
    MMG_fn_vEndMemoryInfo ();
 
	p_stEngineObject->h_3dData = h_3dData;
 
  pLink->pObject=(void *)h_3dData;
  return 0;
}
 
 
/*****************************************************************
Name: 
Description: Load callback for LDT
Author: Mircea Petrescu
Date: 8/21/98
Modified: Scripa Ovidiu 09/01/98
*****************************************************************/
int fn_iLoad3dData( LDT_tdst_Link *pLink )
{
  LDT_tdeParseResult result=ParseResult_BeginSection;
  MS_tdxHandleTo3dData h_3dData=(MS_tdxHandleTo3dData)pLink->pObject;
	struct tdstEngineObject_ *p_stEngineObject;
	GLD_tdstDeviceAttributes stDevAttrib;
 
	p_stEngineObject = (struct tdstEngineObject_ *)pLink->pParent->pObject;
/*	LST2_M_StaticInitAnchor(&h_3dData->hTestPointList);*/
 
  while( result!=ParseResult_EndSection ) 
  {
  	result=LDT_GetNextEntry();
  	switch( result )
  	{
  	  case ParseResult_Entry: /* an entry */
  	  {
  	    char *szEntry=LDT_szGetEntryName();
  	    switch (*(long*)(szEntry+4))
  	    {
  	      case 'Slai' : /* InitialState */
  	      {
						char szCompletFileName[_MAX_PATH];
						tdxHandleToState h_InitialState;
/*						LDT_tdst_Link* pLink;
 
						pLink = LDT_GetLink(LDT_szGetParam(1));
						if (pLink)
						{
							h_InitialState = (tdxHandleToState)pLink->pObject;		
						}
						else
						{
*/
							strcpy(szCompletFileName,fn_szGetFamiliesDataPath());
							strcat(szCompletFileName,"\\");
							strcat(szCompletFileName,LDT_szGetParam(1));
                MMG_fn_vAddMemoryInfo( MMG_C_lTypeMiniStructure , MMG_C_lSubType3dData , p_stEngineObject);
							h_InitialState = (tdxHandleToState) TMP_M_p_Malloc(strlen(szCompletFileName)+1);
							strcpy((char *)h_InitialState, szCompletFileName);	
/*						}*/
 
		 				fn_v3dDataSetInitialState(h_3dData, h_InitialState);
  	      }
  	      break;
  	      case 'Olai' : /* InitialObjectsTable */
  	      {
						void* p_vLS = NULL;
						if (!LDT_SearchFile(LDT_szGetParam(1),NULL)) /* ??*/
						{
							p_vLS = LDT_LoadSection(LDT_szGetParam(1));
						}
						LDT_SetFileLong(20, (unsigned long)p_vLS);
  	      }
  	      break;
  	      case 'eTwo' : /* ShadowTexture */
  	      {
						GLD_bGetDeviceAttributes(
							g_stEngineStructure.hGLDDevice,&stDevAttrib);
						GLI_xLoadTexture( &h_3dData->p_stShadowTexture,&stDevAttrib,
							LDT_szGetParam(1),
							atoi( LDT_szGetParam( 2 ) ), 
							atoi( LDT_szGetParam( 3 ) ) );
  	      }
  	      break;
  	      case 'aMwo' : /* ShadowMaterial */
  	      {
						h_3dData->p_stShadowMaterial = (GMT_tdxHandleToGameMaterial) LDT_LoadSection( LDT_szGetParam(1) );
  	      }
  	      break;
  	      case 'cSwo' : /* ShadowScale */
  	      {
						fn_v3dDataSetShadowScaleX(h_3dData, (float)atof( LDT_szGetParam( 1 ) ));
						fn_v3dDataSetShadowScaleY(h_3dData, (float)atof( LDT_szGetParam( 2 ) ));
  	      }
  	      break;
  	      case 'eHwo' : /* ShadowHeight */
  	      {
						h_3dData->xSHWHeight = (float)atof( LDT_szGetParam( 1 ) );
  	      }
  	      break;
  	      case 'ksaM' : /* DrawMask */
  	      {
						h_3dData->lDrawMaskInit = h_3dData->lDrawMask = atoi( LDT_szGetParam( 1 ) );
  	      }
  	      break;
  	      case 'moCn' : /* BrainComputationFrequency */
  	      {
  	  			fn_v3dDataSetBrainComputationFrequency(h_3dData,(unsigned char)atoi( LDT_szGetParam( 1 ) ));
			    }
  	      break;
  	      case 'moCt' : /* LightComputationFrequency */
  	      {
						fn_v3dDataSetLightComputationFrequency(h_3dData,(unsigned char)atoi( LDT_szGetParam( 1 ) ));
  	      }
  	      break;
  	    }
  	  }
  	}
  }
 
  return 0;
}
