/* (c) Ubi R&D 1997*/ /* See Alain Robin for any comment or question*/ /****************************************************************************/ /* INCLUDES */ /****************************************************************************/ #include "acp_base.h" #include "cpa_std.h" #include "MTH.h" #include "SCR.h" /*#include "BIN.h"*/ #include "GEO.h" #include "GmtStruc.h" #include "GmtFunct.h" #include "GmtProto.h" #include "GmtZnLod.h" #include "GmtLoad.h" #include "GmtLnkTb.h" #include "MEC/DNMLdMat.h" /*---------------------------------------------------------------------------/ // Description : GMT_fn_vAddEntryIntoZoneLinkTable // Add an entry into the link table of the collide material ------------------------------------------------------------------------------ // Methods : Private function ------------------------------------------------------------------------------ // Input : _ulValue : value of the handle to the created game material // Output : ------------------------------------------------------------------------------ // Creation date : 01 Apr 97 Author: Alain Robin ------------------------------------------------------------------------------ // Modifications : // Modification date : Modification author : ---------------------------------------------------------------------------/*/ void GMT_fn_vAddEntryIntoZoneLinkTable(unsigned long _ulValue) { char a255_cLongName[255]; /* char* szSectionName;*/ SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLongName); SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(&g_stGmtZoneLinkTable, a255_cLongName, _ulValue),1, strlen(a255_cLongName)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0))); /* szSectionName=SCR_M_RdL0_GetCompleteSectionNameR(0); SCR_fnp_st_Link_SetValue(&g_stGmtZoneLinkTable,szSectionName,_ulValue); */ } /*---------------------------------------------------------------------------/ // Description : fn_eScriptFillCollideMaterial // Fills in a collide material ------------------------------------------------------------------------------ // Methods : None ------------------------------------------------------------------------------ // Input : Handle to the collide material + script inputs // Output : scripts output ------------------------------------------------------------------------------ // Creation date : 04 Apr 97 Author: Alain Robin ------------------------------------------------------------------------------ // Modifications : // Modification date : Modification author : ---------------------------------------------------------------------------/*/ SCR_tde_Anl_ReturnValue fn_eScriptFillCollideMaterial( GMT_tdxHandleToCollideMaterial _h_CollideMaterial, char *szAction, char *d_szPars[], SCR_tde_Anl_Action eAction ) { SCRIPT_tdeReturnValue eReturnValue = R_SCRIPT_NormalReturn; if(!strcmp(szAction,C_EntryCollideMaterial)) { short wValue; if(strcmp(d_szPars[0],GMT_C_szZDM)==0) GMT_fn_vSetTypeOfCollideMaterial(_h_CollideMaterial,GMT_C_wZDM); else if(strcmp(d_szPars[0],GMT_C_szZDR)==0) GMT_fn_vSetTypeOfCollideMaterial(_h_CollideMaterial,GMT_C_wZDR); else if(strcmp(d_szPars[0],GMT_C_szZDE)==0) GMT_fn_vSetTypeOfCollideMaterial(_h_CollideMaterial,GMT_C_wZDE); else if(strcmp(d_szPars[0],GMT_C_szZDD)==0) GMT_fn_vSetTypeOfCollideMaterial(_h_CollideMaterial,GMT_C_wZDD); /* else syntax error */ wValue=(short)atoi(d_szPars[1]); GMT_fn_hSetCollideMaterialIdentifier(_h_CollideMaterial,wValue); } /*else if(!strcmp(szAction,C_Entry?)) */ /*{ */ /* Call The CallBackOf? */ /*} */ else { /* Manage the Treatment of an Error */ /* To be Done */ } return(eReturnValue); } /*---------------------------------------------------------------------------/ // Description : fn_eScriptCallBackCollideMaterial // Reads the script file describing a game material ------------------------------------------------------------------------------ // Methods : None ------------------------------------------------------------------------------ // Input : script input // Output : script output ------------------------------------------------------------------------------ // Creation date : 04 Apr 97 Author: Alain Robin ------------------------------------------------------------------------------ // Modifications : // Modification date : Modification author : ---------------------------------------------------------------------------/*/ SCR_tde_Anl_ReturnValue fn_eScriptCallBackCollideMaterial( SCR_tdst_File_Description *p_stHandle, char *szAction, char *d_szPars[], SCR_tde_Anl_Action eAction) { GMT_tdxHandleToCollideMaterial h_CollideMaterial; SCRIPT_tdeReturnValue eReturnValue = R_SCRIPT_NormalReturn; if(eAction==C_SCRIPT_Section) { /* If a section is detected */ /* Allocates */ h_CollideMaterial = GMT_fn_hCreateCollideMaterial(); SCR_M_RdL0_SetSectionLong(0, 0, (unsigned long)(h_CollideMaterial)) GMT_fn_vAddEntryIntoZoneLinkTable((unsigned long)h_CollideMaterial); } else if(eAction==C_SCRIPT_Entry) { /*----------------------------*/ /* Fills the collide material */ /*----------------------------*/ SCR_M_RdL0_GetSectionLong(0, 0, GMT_tdxHandleToCollideMaterial, h_CollideMaterial) fn_eScriptFillCollideMaterial( h_CollideMaterial, szAction, d_szPars, eAction); } return(eReturnValue); } /*---------------------------------------------------------------------------/ // Description : GMT_fn_vInitLoadCollideMaterial // Loading process initialization ------------------------------------------------------------------------------ // Methods : Register the callback ------------------------------------------------------------------------------ // Input : // Output : ------------------------------------------------------------------------------ // Creation date : 04 Apr 97 Author: Alain Robin ------------------------------------------------------------------------------ // Modifications : // Modification date : Modification author : Alain Robin ---------------------------------------------------------------------------/*/ void GMT_fn_vInitLoadCollideMaterial() { SCR_fn_v_RdL0_RegisterCallback(C_SectionCollideMaterial,fn_eScriptCallBackCollideMaterial, SCR_CRC_c_RdL0_ForSection); SCR_fn_v_Link_InitTable(&g_stGmtZoneLinkTable); } /*---------------------------------------------------------------------------/ // Description : GMT_fn_vDeleteEntryWithPriority ------------------------------------------------------------------------------ // Methods : ------------------------------------------------------------------------------ // Input : // Output : ------------------------------------------------------------------------------ // Creation date : Aug 97 Author: Alain Robin ------------------------------------------------------------------------------ // Modifications : // Modification date : Modification author : Alain Robin ---------------------------------------------------------------------------/*/ void GMT_fn_vDeleteCMTEntryWithPriority(unsigned char ucPrioMin, unsigned char ucPrioMax) { SCR_fn_v_Link_DeleteEntryWithPriority(&g_stGmtZoneLinkTable,ucPrioMin,ucPrioMax); } /*---------------------------------------------------------------------------/ // Description : GMT_fn_p_stGetZoneLinkTable // Get the link table of the collide material module ------------------------------------------------------------------------------ // Methods : Nothing to say ------------------------------------------------------------------------------ // Input : // Output : A pointer to the static link table ------------------------------------------------------------------------------ // Creation date : 07 Apr 97 Author: Alain Robin ------------------------------------------------------------------------------ // Modifications : // Modification date : Modification author : ---------------------------------------------------------------------------/*/ REF_tdstLinkTable* GMT_fn_p_stGetZoneLinkTable() { return &g_stGmtZoneLinkTable; } /*---------------------------------------------------------------------------- // Description : GMT_fn_hLoadCollideMaterial // Load a collide material from the scripts or from the binary bloc //---------------------------------------------------------------------------- // Methods : For the moment, use the script //---------------------------------------------------------------------------- // Input : _szSectionName : Name of the section to load // Output : A handle to the loaded collide material //---------------------------------------------------------------------------- // Creation date : Aug 97 Author: Alain Robin //---------------------------------------------------------------------------- // Modifications : // Modification date : Modification author : ----------------------------------------------------------------------------*/ GMT_tdxHandleToCollideMaterial GMT_fn_hLoadCollideMaterial(char* _szSectionName) { SCR_tdst_Cxt_Values *p_stValues ; SCR_tdst_Link_Value *p_stLinkValue; unsigned long ulResult; unsigned int uiPos; uiPos = 0; SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stLinkValue,SCR_M_st_Link_GetDynamicArray(&g_stGmtZoneLinkTable)); while(p_stLinkValue) { if(!strcmpi(SCR_M_p_sz_Link_GetKey(p_stLinkValue) + SCR_M_ul_Link_GetAdditionalLong(p_stLinkValue,1),_szSectionName)) break; uiPos++; SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stLinkValue,SCR_M_st_Link_GetDynamicArray(&g_stGmtZoneLinkTable)); } /* p_stLinkValue=BIN_fn_p_stSearchShortKey(&g_stGmtZoneLinkTable,_szSectionName);*/ if(p_stLinkValue==NULL) { p_stValues = SCR_fnp_st_RdL0_AnalyseSection(_szSectionName,SCR_CDF_uw_Anl_Normal); if(p_stValues) { ulResult = SCR_M_ul_RdL0_ExtractLongValue(p_stValues,0); return (GMT_tdxHandleToCollideMaterial)ulResult; } else return GMT_C_InvalidCollideMaterial; } else return (GMT_tdxHandleToCollideMaterial)p_stLinkValue->ulValue; } /*---------------------------------------------------------------------------- // Description : GMT_fn_vPrepareSaveBinaryBloc //---------------------------------------------------------------------------- // Methods : Prepare data for a binary save and call the save structure // function for all loaded gmt //---------------------------------------------------------------------------- // Input : // Output : //---------------------------------------------------------------------------- // Creation date : Aug 97 Author: Alain Robin //---------------------------------------------------------------------------- // Modifications : // Modification date : Modification author : ----------------------------------------------------------------------------*/ /* void GMT_fn_vPrepareSaveCollideBinaryBloc() { BIN_fn_vCreateBinaryIds(&g_stGmtZoneLinkTable,BIN_C_CMTID); } */ /*---------------------------------------------------------------------------- // Description : GMT_fn_ulWriteCMTBinaryBloc //---------------------------------------------------------------------------- // Methods : Write the binary bloc for the collide material //---------------------------------------------------------------------------- // Input : _ulStructAdress : Address of the structure to be written // _p_cDestBuffer : Output buffer // Output : The length of the data written //---------------------------------------------------------------------------- // Creation date : Aug 97 Author: Alain Robin //---------------------------------------------------------------------------- // Modifications : // Modification date : Modification author : ----------------------------------------------------------------------------*/ /* unsigned long GMT_fn_ulWriteCMTBinaryBloc(unsigned long _ulStructAdress, char* _p_cDestBuffer) { GMT_tdstCollideMaterial *p_stCollideMat; char* p_cBufferPointer=_p_cDestBuffer; p_stCollideMat=(GMT_tdstCollideMaterial*)_ulStructAdress; p_cBufferPointer=BIN_fn_p_cPutShort(p_cBufferPointer,p_stCollideMat->wTypeOfZone); p_cBufferPointer=BIN_fn_p_cPutShort(p_cBufferPointer,p_stCollideMat->xIdentifier); return p_cBufferPointer-_p_cDestBuffer; } */ /*---------------------------------------------------------------------------- // Description : GMT_fn_vWriteAllCMTBinaryBlocs //---------------------------------------------------------------------------- // Methods : Write all the binary bloc for the collide material //---------------------------------------------------------------------------- // Input : _szBinaryFileName // Output : //---------------------------------------------------------------------------- // Creation date : Aug 97 Author: Alain Robin //---------------------------------------------------------------------------- // Modifications : // Modification date : Modification author : ----------------------------------------------------------------------------*/ /* void GMT_fn_vWriteAllCMTBinaryBlocs(char* _szBinaryFileName) { GMT_fn_vPrepareSaveCollideBinaryBloc(); BIN_fn_vPutBinaryDataIntoFileFromLinkTable(_szBinaryFileName,&g_stGmtZoneLinkTable, sizeof(GMT_tdstCollideMaterial),GMT_fn_ulWriteCMTBinaryBloc); } */ /*---------------------------------------------------------------------------- // Description : GMT_fn_ulReadBinaryBloc //---------------------------------------------------------------------------- // Methods : Read a the binary bloc for the collide material //---------------------------------------------------------------------------- // Input : _p_cLoadedBuffer : Input buffer // _ulLoadedBufferSize : Size of the loaded buffer // Output : The address of the allocated bloc //---------------------------------------------------------------------------- // Creation date : Aug 97 Author: Alain Robin //---------------------------------------------------------------------------- // Modifications : // Modification date : Modification author : ----------------------------------------------------------------------------*/ /* unsigned long GMT_fn_ulReadCMTBinaryBloc(char* _p_cLoadedBuffer,unsigned long _ulLoadedBufferSize) { GMT_tdxHandleToCollideMaterial hNewCollideMaterial=NULL; GEO_M_CPAMalloc(hNewCollideMaterial,GMT_tdxHandleToCollideMaterial,sizeof(struct GMT_tdstCollideMaterial_),E_uwGEONotEnoughtMemory); memcpy((char*)hNewCollideMaterial,_p_cLoadedBuffer,_ulLoadedBufferSize); return (unsigned long)hNewCollideMaterial; } */ /*---------------------------------------------------------------------------- // Description : GMT_fn_vReadAllCMTBinaryBlocs //---------------------------------------------------------------------------- // Methods : Read all the binary blocs for the collide material //---------------------------------------------------------------------------- // Input : _szBinaryFileName : The binary file name // Output : //---------------------------------------------------------------------------- // Creation date : Aug 97 Author: Alain Robin //---------------------------------------------------------------------------- // Modifications : // Modification date : Modification author : ----------------------------------------------------------------------------*/ /* void GMT_fn_vReadAllCMTBinaryBlocs(char* _szBinaryFileName) { BIN_fn_vReadDataFromLinkTable(&g_stGmtZoneLinkTable,GMT_fn_ulReadCMTBinaryBloc, sizeof(struct GMT_tdstCollideMaterial_), _szBinaryFileName); } */ /*---------------------------------------------------------------------------- // Description : GMT_fn_vReadAllCMTBinaryBlocs //---------------------------------------------------------------------------- // Methods : Read all the binary blocs for the collide material //---------------------------------------------------------------------------- // Input : _szBinaryFileName : The binary file name // Output : //---------------------------------------------------------------------------- // Creation date : Aug 97 Author: Alain Robin //---------------------------------------------------------------------------- // Modifications : // Modification date : Modification author : ----------------------------------------------------------------------------*/ /* void GMT_fn_vReadAllCMTBinaryBlocs2(char* _szBinaryFileName) { BIN_fn_vReadDataFromLinkTableWithoutAllocation(&g_stGmtZoneLinkTable,NULL, sizeof(struct GMT_tdstCollideMaterial_), _szBinaryFileName, GMT_fn_p_cGeneralAllocationFunction); } */