816 lines
31 KiB
C
816 lines
31 KiB
C
/* (c) Ubi R&D 1997*/
|
|
/* See Alain Robin for any comment or question*/
|
|
|
|
/****************************************************************************/
|
|
/* INCLUDES */
|
|
/****************************************************************************/
|
|
#include "acp_base.h"
|
|
#include "cpa_std.h"
|
|
|
|
#define __DeclareGlobalVariableGmtLnkTb_h__
|
|
#include "GmtLnkTb.h"
|
|
#undef __DeclareGlobalVariableGmtLnkTb_h__
|
|
|
|
#include "MTH.h"
|
|
#include "SCR.h"
|
|
#include "DPT.h"
|
|
/*#include "BIN.h"*/
|
|
#include "GEO.h"
|
|
#include "GLI.h"
|
|
|
|
#include "GmtStruc.h"
|
|
#include "GmtFunct.h"
|
|
#include "GmtProto.h"
|
|
#include "GmtLoad.h"
|
|
#include "GmtZnLod.h"
|
|
|
|
#include "MEC/DNMLdMat.h"
|
|
#include "MEC/DNMLkMat.h"
|
|
|
|
/*////////////////////////////////////////////////////////////////////////////
|
|
// Description : GMT_fn_vAddEntryIntoLinkTable
|
|
// Add an entry into the link table of the game material module
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// 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_vAddEntryIntoLinkTable(unsigned long _ulValue)
|
|
{
|
|
/* char* szSectionName;
|
|
// char* szPathName;
|
|
char szCompleteName[255];
|
|
char* p_cSubString; */
|
|
|
|
/* szSectionName=strchr(SCR_M_RdL0_GetCompleteSectionNameR(0), '^');
|
|
szPathName=fn_szGetGameMaterialDataPath();
|
|
strcpy(szCompleteName,szPathName);
|
|
strcat(szCompleteName,"\\");
|
|
strcat(szCompleteName,szSectionName); */ /* Old data organisation*/
|
|
/* strcpy(szCompleteName,szSectionName);*/
|
|
/* strcpy(szCompleteName, SCR_M_RdL0_GetOpenFileNameR(0));
|
|
strcat(szCompleteName, szSectionName);
|
|
|
|
SCR_fnp_st_Link_SetValue(&g_stGmtLinkTable,szCompleteName,_ulValue);
|
|
|
|
// Compute index of short name
|
|
p_cSubString=strstr(szCompleteName,SCR_M_RdL0_GetCompleteSectionNameR(0));
|
|
if(p_cSubString!=NULL)
|
|
{
|
|
SCR_tdst_Link_Value* pValue;
|
|
pValue=SCR_fnp_st_Link_SearchKey(&g_stGmtLinkTable,szCompleteName);
|
|
SCR_M_v_Link_SetAdditionalLong(pValue,1,(ACP_tdxIndex)(p_cSubString-szCompleteName));
|
|
} */
|
|
|
|
char a255_cLongName[255];
|
|
|
|
SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLongName);
|
|
SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(&g_stGmtLinkTable,
|
|
a255_cLongName,
|
|
_ulValue),1,
|
|
strlen(a255_cLongName)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
|
|
}
|
|
|
|
/*////////////////////////////////////////////////////////////////////////////
|
|
// Description : fn_eScriptFillGameMaterial
|
|
// Fills in a game material
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Methods : None
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Input : Handle to the game material + script inputs
|
|
// Output : scripts output
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Creation date : 26 Feb 97 Author: Alain Robin
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
////////////////////////////////////////////////////////////////////////////*/
|
|
SCR_tde_Anl_ReturnValue fn_eScriptFillGameMaterial(
|
|
GMT_tdxHandleToGameMaterial _h_GameMaterial,
|
|
char *szAction,
|
|
char *d_szPars[],
|
|
SCR_tde_Anl_Action eAction
|
|
)
|
|
{
|
|
/* char *szPath;*/
|
|
char szCompleteName[255];
|
|
SCR_tde_Anl_ReturnValue eReturnValue = R_SCRIPT_NormalReturn;
|
|
|
|
if(!strcmp(szAction,C_EntryVisualGameMaterialToLoad))
|
|
{
|
|
SCR_tdst_Cxt_Values *p_stValues ;
|
|
unsigned long ulResult;
|
|
ACP_tdxHandleOfMaterial hVisualMat;
|
|
|
|
/* Construct the complete file name */
|
|
if(*d_szPars[0]!='*')
|
|
{
|
|
/* szPath=fn_szGetVisualMaterialDataPath();
|
|
strcpy(szCompleteName,szPath);
|
|
strcat(szCompleteName,"\\");
|
|
strcat(szCompleteName,d_szPars[0]); */ /* Old organisation*/
|
|
strcpy(szCompleteName,d_szPars[0]);
|
|
}
|
|
else
|
|
strcpy(szCompleteName,d_szPars[0]);
|
|
|
|
/* Call the callback of visual material */
|
|
/* And Put the Handle in the structure GameMaterial Handled */
|
|
|
|
p_stValues = SCR_fnp_st_RdL0_AnalyseSection(szCompleteName,SCR_CDF_uw_Anl_Normal);
|
|
if(p_stValues)
|
|
{
|
|
ulResult = p_stValues->a_ulValues[0];
|
|
hVisualMat=(ACP_tdxHandleOfMaterial)ulResult;
|
|
GMT_fn_vSetVisualMaterial(_h_GameMaterial,hVisualMat);
|
|
}
|
|
}
|
|
else if(!strcmp(szAction,C_EntryMechanicalMaterialToLoad))
|
|
{
|
|
SCR_tdst_Cxt_Values *p_stValues ;
|
|
unsigned long ulResult;
|
|
|
|
/* Construct the complete file name */
|
|
if(*d_szPars[0]!='*')
|
|
{
|
|
/* szPath=fn_szGetMechanicsMaterialDataPath();
|
|
strcpy(szCompleteName,szPath);
|
|
strcat(szCompleteName,"\\");
|
|
strcat(szCompleteName,d_szPars[0]); */
|
|
strcpy(szCompleteName,d_szPars[0]);
|
|
}
|
|
else
|
|
strcpy(szCompleteName,d_szPars[0]);
|
|
|
|
/* Call the call back for the other properties into the .miv file */
|
|
/* and put the handles into the structure GameMaterial Handled */
|
|
|
|
p_stValues = SCR_fnp_st_RdL0_AnalyseSection(szCompleteName,SCR_CDF_uw_Anl_Normal);
|
|
if(p_stValues)
|
|
{
|
|
ulResult = p_stValues->a_ulValues[0];
|
|
GMT_fn_vSetMechanicsMaterial(_h_GameMaterial,(DNM_tdxHandleToMecMatCharacteristics)ulResult);
|
|
}
|
|
}
|
|
else if(!strcmp(szAction,C_EntryCollideMaterialToLoad))
|
|
{
|
|
SCR_tdst_Cxt_Values *p_stValues ;
|
|
unsigned long ulResult;
|
|
|
|
/* Construct the complete file name */
|
|
if(*d_szPars[0]!='*')
|
|
{
|
|
/* szPath=fn_szGetCollideMaterialDataPath();
|
|
strcpy(szCompleteName,szPath);
|
|
strcat(szCompleteName,"\\");
|
|
strcat(szCompleteName,d_szPars[0]); */
|
|
strcpy(szCompleteName,d_szPars[0]);
|
|
}
|
|
else
|
|
strcpy(szCompleteName,d_szPars[0]);
|
|
|
|
/* Call the call back for the other properties into the .miv file */
|
|
/* and put the handles into the structure GameMaterial Handled */
|
|
|
|
p_stValues = SCR_fnp_st_RdL0_AnalyseSection(szCompleteName,SCR_CDF_uw_Anl_Normal);
|
|
if(p_stValues)
|
|
{
|
|
ulResult = p_stValues->a_ulValues[0];
|
|
GMT_fn_vSetCollideMaterial(_h_GameMaterial,(GMT_tdxHandleToCollideMaterial)ulResult);
|
|
}
|
|
}
|
|
else if(!strcmp(szAction,C_EntrySoundMaterial))
|
|
{
|
|
long lValue;
|
|
|
|
lValue=(long)atoi(d_szPars[0]);
|
|
GMT_fn_vSetSoundMaterial(_h_GameMaterial,lValue);
|
|
}
|
|
/*else if(!strcmp(szAction,C_Entry?)) */
|
|
/*{ */
|
|
/* Call The CallBackOf? */
|
|
/*} */
|
|
else
|
|
{
|
|
/* Manage the Treatment of an Error */
|
|
/* To be Done */
|
|
}
|
|
return(eReturnValue);
|
|
}
|
|
|
|
/*////////////////////////////////////////////////////////////////////////////
|
|
// Description : fn_eScriptCallBackGameMaterial
|
|
// Reads the script file describing a game material
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Methods : None
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Input : script input
|
|
// Output : script output
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Creation date : 26 Feb 97 Author: Alain Robin
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
////////////////////////////////////////////////////////////////////////////*/
|
|
SCR_tde_Anl_ReturnValue fn_eScriptCallBackGameMaterial(
|
|
SCR_tdst_File_Description *p_stHandle,
|
|
char *szAction,
|
|
char *d_szPars[],
|
|
SCR_tde_Anl_Action eAction)
|
|
{
|
|
GMT_tdxHandleToGameMaterial h_GameMaterial;
|
|
SCR_tde_Anl_ReturnValue eReturnValue = R_SCRIPT_NormalReturn;
|
|
|
|
if(eAction==C_SCRIPT_Section)
|
|
{
|
|
/* If a section is detected */
|
|
/* Allocates */
|
|
h_GameMaterial = GMT_fn_hCreateGameMaterial();
|
|
|
|
SCR_M_RdL0_SetSectionLong(0, 0, (unsigned long)(h_GameMaterial))
|
|
GMT_fn_vAddEntryIntoLinkTable((unsigned long)h_GameMaterial);
|
|
}
|
|
else if(eAction==C_SCRIPT_Entry)
|
|
{
|
|
/*--------------------------*/
|
|
/* Fills the game material */
|
|
/*--------------------------*/
|
|
SCR_M_RdL0_GetSectionLong(0, 0, GMT_tdxHandleToGameMaterial, h_GameMaterial)
|
|
|
|
fn_eScriptFillGameMaterial(
|
|
h_GameMaterial,
|
|
szAction,
|
|
d_szPars,
|
|
eAction);
|
|
}
|
|
else if(eAction==C_SCRIPT_EndSection)
|
|
{
|
|
/* Store loaded GMT */
|
|
SCR_M_RdL0_GetSectionLong(0, 0, GMT_tdxHandleToGameMaterial, h_GameMaterial)
|
|
/* fbolefeysot - 01/10/98*/
|
|
/* remove init values in GMT{*/
|
|
/* h_GameMaterial->p_stInitialValues = GMT_fn_hCreateGameMaterial();
|
|
memcpy(h_GameMaterial->p_stInitialValues,h_GameMaterial,sizeof(struct GMT_tdstGameMaterial_));
|
|
h_GameMaterial->p_stInitialValues->p_stInitialValues=NULL;
|
|
*/
|
|
/*END fbolefeysot}*/
|
|
|
|
}
|
|
return(eReturnValue);
|
|
}
|
|
|
|
/*////////////////////////////////////////////////////////////////////////////
|
|
// Description : GMT_fn_vInitLoadGameMaterial
|
|
// Loading process initialization
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Methods : Register the callback
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Input :
|
|
// Output :
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Creation date : 27 Feb 97 Author: Alain Robin
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Modifications : Init the link table
|
|
// Modification date : 01 Apr 97 Modification author : Alain Robin
|
|
////////////////////////////////////////////////////////////////////////////*/
|
|
void GMT_fn_vInitLoadGameMaterial(void)
|
|
{
|
|
/* SCR_fn_v_RdL0_RegisterCallback(C_SectionGameMaterial,fn_eScriptCallBackGameMaterial, SCR_CRC_c_RdL0_ForSection);
|
|
DNM_fn_vInitLoadMecMatCharacteristics(); // Register the mechanic callback
|
|
GMT_fn_vInitLoadCollideMaterial(); // Register collide material
|
|
SCR_fn_v_Link_InitTable(&g_stGmtLinkTable); */
|
|
if(GMT_p_fn_vVirtualInitLoadGameMaterial!=NULL)
|
|
GMT_p_fn_vVirtualInitLoadGameMaterial();
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------/
|
|
// Description : GMT_fn_vDeleteGMTEntryWithPriority
|
|
------------------------------------------------------------------------------
|
|
// Methods :
|
|
------------------------------------------------------------------------------
|
|
// Input :
|
|
// Output :
|
|
------------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
------------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author : Alain Robin
|
|
---------------------------------------------------------------------------/*/
|
|
void GMT_fn_vDeleteGMTEntryWithPriority(unsigned char ucPrioMin, unsigned char ucPrioMax)
|
|
{
|
|
SCR_fn_v_Link_DeleteEntryWithPriority(&g_stGmtLinkTable,ucPrioMin,ucPrioMax);
|
|
}
|
|
|
|
/*////////////////////////////////////////////////////////////////////////////
|
|
// Description : GMT_fn_p_stGetLinkTable
|
|
// Get the link table of the game material module
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Methods : Nothing to say
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Input :
|
|
// Output : A pointer to the static link table
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Creation date : 01 Apr 97 Author: Alain Robin
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
////////////////////////////////////////////////////////////////////////////*/
|
|
REF_tdstLinkTable* GMT_fn_p_stGetLinkTable()
|
|
{
|
|
return &g_stGmtLinkTable;
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_hLoadGameMaterial
|
|
// Load a game 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 game material
|
|
//----------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
//----------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
----------------------------------------------------------------------------*/
|
|
GMT_tdxHandleToGameMaterial GMT_fn_hLoadGameMaterial(char* _szSectionName)
|
|
{
|
|
SCR_tdst_Cxt_Values *p_stValues ;
|
|
SCR_tdst_Link_Value *p_stLinkValue = NULL;
|
|
unsigned long ulResult;
|
|
unsigned int uiPos;
|
|
|
|
|
|
uiPos = 0;
|
|
SCR_M_DyAr_GetNextElement(SCR_tdst_Link_Value, uiPos, p_stLinkValue,SCR_M_st_Link_GetDynamicArray(GMT_fn_p_stGetLinkTable()));
|
|
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(GMT_fn_p_stGetLinkTable()));
|
|
}
|
|
|
|
/* p_stLinkValue=BIN_fn_p_stSearchShortKey(GMT_fn_p_stGetLinkTable(),_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_tdxHandleToGameMaterial)ulResult;
|
|
}
|
|
else
|
|
return (GMT_tdxHandleToGameMaterial)GMT_C_ulInvalidHandle;
|
|
}
|
|
else return (GMT_tdxHandleToGameMaterial)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_vPrepareSaveBinaryBloc()
|
|
{
|
|
BIN_fn_vCreateBinaryIds(&g_stGmtLinkTable,BIN_C_GMTID);
|
|
|
|
// Now, the structures under the game material
|
|
GLI_fn_vPrepareSaveMaterialBinaryBloc(); // For visual mat
|
|
DNM_fn_vPrepareSaveMaterialBinaryBloc(); // for mechanics
|
|
GMT_fn_vPrepareSaveCollideBinaryBloc(); // For collision
|
|
}
|
|
*/
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_vWriteBinaryBloc
|
|
//----------------------------------------------------------------------------
|
|
// Methods : Write the binary bloc into a buffer and flush the buffer into a
|
|
// file.
|
|
//----------------------------------------------------------------------------
|
|
// Input : _hGmtMaterial : Handle to the game material to save
|
|
// _p_cBuffer : Binarisation buffer
|
|
// Output : The length of the data written
|
|
//----------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
//----------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
----------------------------------------------------------------------------*/
|
|
/*
|
|
unsigned long GMT_fn_ulWriteBinaryBloc(unsigned long _ulGmtMaterial,char* _p_cBuffer)
|
|
{
|
|
char* p_cBuffer=_p_cBuffer;
|
|
GMT_tdxHandleToGameMaterial hGameMaterial;
|
|
ACP_tdxHandleOfMaterial hVisualMaterial;
|
|
|
|
hGameMaterial=(GMT_tdxHandleToGameMaterial)_ulGmtMaterial;
|
|
|
|
// Visual
|
|
hVisualMaterial=GMT_fn_hGetVisualMaterial(hGameMaterial);
|
|
|
|
p_cBuffer=BIN_fn_p_cPutPointer(p_cBuffer,(unsigned long)hVisualMaterial, GLI_p_stGetLinkTableOfVisualMaterial());
|
|
|
|
// Mechanics
|
|
if(DNM_fn_bIsMatCharacteristicsValid(GMT_fn_hGetMechanicsMaterial(hGameMaterial)))
|
|
{
|
|
p_cBuffer=BIN_fn_p_cPutPointer(p_cBuffer,(unsigned long)GMT_fn_hGetMechanicsMaterial(hGameMaterial),
|
|
DNM_fn_p_stGetLinkTableOfMecMatCharacteristics());
|
|
}
|
|
else
|
|
{
|
|
p_cBuffer=BIN_fn_p_cPutLong(p_cBuffer,(long)0);
|
|
}
|
|
|
|
// Sound
|
|
p_cBuffer=BIN_fn_p_cPutLong(p_cBuffer,GMT_fn_hGetSoundMaterial(hGameMaterial));
|
|
|
|
// Collide
|
|
if(GMT_fn_hGetCollideMaterial(hGameMaterial)!=GMT_C_InvalidCollideMaterial)
|
|
{
|
|
p_cBuffer=BIN_fn_p_cPutPointer(p_cBuffer,(unsigned long)GMT_fn_hGetCollideMaterial(hGameMaterial),
|
|
&g_stGmtZoneLinkTable);
|
|
}
|
|
else
|
|
{
|
|
p_cBuffer=BIN_fn_p_cPutLong(p_cBuffer,(long)0);
|
|
}
|
|
|
|
// The place for the initial values
|
|
p_cBuffer=BIN_fn_p_cPutLong(p_cBuffer,0);
|
|
|
|
return p_cBuffer-_p_cBuffer;
|
|
}
|
|
*/
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_vWriteAllGameMaterialBinaryBlocs
|
|
//----------------------------------------------------------------------------
|
|
// Methods : Write all the game materials into a binary file.
|
|
//----------------------------------------------------------------------------
|
|
// Input : _szBinaryFileName : Name of the binary file
|
|
// Output :
|
|
//----------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
//----------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
----------------------------------------------------------------------------*/
|
|
/*
|
|
void GMT_fn_vWriteAllGameMaterialBinaryBlocs(char* _szBinaryFileName)
|
|
{
|
|
GMT_fn_vPrepareSaveBinaryBloc();
|
|
BIN_fn_vPutBinaryDataIntoFileFromLinkTable( (char*)_szBinaryFileName,
|
|
&g_stGmtLinkTable,
|
|
sizeof(GMT_tdstGameMaterial),
|
|
GMT_fn_ulWriteBinaryBloc);
|
|
}
|
|
*/
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_vRestorePointerFromIds
|
|
//----------------------------------------------------------------------------
|
|
// Methods : Write all the game materials into a binary file.
|
|
//----------------------------------------------------------------------------
|
|
// Input : _ulPointer : Pointer to the structure to be restored
|
|
// Output :
|
|
//----------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
//----------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
----------------------------------------------------------------------------*/
|
|
/*
|
|
void GMT_fn_vRestorePointerFromIds(unsigned long _ulPointer)
|
|
{
|
|
unsigned long ulId;
|
|
GMT_tdxHandleToGameMaterial hGameMaterial=(GMT_tdxHandleToGameMaterial)_ulPointer;
|
|
|
|
// Visual
|
|
ulId=(unsigned long)GMT_fn_hGetVisualMaterial(hGameMaterial);
|
|
if(ulId!=0)
|
|
{
|
|
BIN_fn_p_cGetPointer((char*)&hGameMaterial->hVisualMaterial,(unsigned long*)&hGameMaterial->hVisualMaterial,
|
|
GLI_p_stGetLinkTableOfVisualMaterial());
|
|
}
|
|
else
|
|
{
|
|
// We must create a default material
|
|
ACP_tdxHandleOfMaterial hVisualMat;
|
|
GLI_xCreateMaterial(&hVisualMat);
|
|
GMT_fn_vSetVisualMaterial(hGameMaterial,hVisualMat);
|
|
}
|
|
|
|
// Mechanics
|
|
ulId=(unsigned long)GMT_fn_hGetMechanicsMaterial(hGameMaterial);
|
|
if(ulId!=0)
|
|
{
|
|
BIN_fn_p_cGetPointer((char*)&hGameMaterial->hMechanicsMaterial,(unsigned long*)&hGameMaterial->hMechanicsMaterial,
|
|
DNM_fn_p_stGetLinkTableOfMecMatCharacteristics());
|
|
}
|
|
else
|
|
DNM_fn_vInvalidateMatCharacteristics(&(hGameMaterial->hMechanicsMaterial));
|
|
|
|
// Collide
|
|
ulId=(unsigned long)GMT_fn_hGetCollideMaterial(hGameMaterial);
|
|
if(ulId!=0)
|
|
{
|
|
BIN_fn_p_cGetPointer((char*)&hGameMaterial->hCollideMaterial,(unsigned long*)&hGameMaterial->hCollideMaterial,
|
|
&g_stGmtZoneLinkTable);
|
|
}
|
|
else
|
|
GMT_fn_vSetCollideMaterial(hGameMaterial,GMT_C_InvalidCollideMaterial);
|
|
|
|
// Set initial values
|
|
hGameMaterial->p_stInitialValues = GMT_fn_hCreateGameMaterial();
|
|
memcpy(hGameMaterial->p_stInitialValues,hGameMaterial,sizeof(struct GMT_tdstGameMaterial_));
|
|
hGameMaterial->p_stInitialValues->p_stInitialValues=NULL;
|
|
}
|
|
*/
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_vReadBinaryBloc
|
|
//----------------------------------------------------------------------------
|
|
// Methods : Write the binary bloc into a buffer and flush the buffer into a
|
|
// file.
|
|
//----------------------------------------------------------------------------
|
|
// Input : _hGmtMaterial : Handle to the game material to save
|
|
// _p_cBuffer : Binarisation buffer
|
|
// _szBinaryFileName : Name of the binary file
|
|
// Output : The length of the data written
|
|
//----------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
//----------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
----------------------------------------------------------------------------*/
|
|
/*
|
|
unsigned long GMT_fn_ulReadBinaryBloc(char* _p_cLoadedBuffer,unsigned long _ulLoadedBufferSize)
|
|
{
|
|
GMT_tdxHandleToGameMaterial hNewGameMaterial=NULL;
|
|
|
|
GEO_M_CPAMalloc(hNewGameMaterial,GMT_tdxHandleToGameMaterial,sizeof(struct GMT_tdstGameMaterial_),E_uwGEONotEnoughtMemory);
|
|
memcpy((char*)hNewGameMaterial,_p_cLoadedBuffer,_ulLoadedBufferSize);
|
|
GMT_fn_vRestorePointerFromIds((unsigned long)hNewGameMaterial);
|
|
return (unsigned long)hNewGameMaterial;
|
|
}
|
|
*/
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_ulGetStructureSize
|
|
//----------------------------------------------------------------------------
|
|
// Methods : return the structure size
|
|
//----------------------------------------------------------------------------
|
|
// Input :
|
|
// Output : the size
|
|
//----------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
//----------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
----------------------------------------------------------------------------*/
|
|
unsigned long GMT_fn_ulGetStructureSize()
|
|
{
|
|
return sizeof(GMT_tdstGameMaterial);
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_vReadAllGameMaterialBinaryBlocs
|
|
//----------------------------------------------------------------------------
|
|
// Methods : Reads all the game materials from a binary file.
|
|
//----------------------------------------------------------------------------
|
|
// Input : _szBinaryFileName : Name of the binary file
|
|
// Output :
|
|
//----------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
//----------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
----------------------------------------------------------------------------*/
|
|
/*
|
|
void GMT_fn_vReadAllGameMaterialBinaryBlocs(char* _szBinaryFileName)
|
|
{
|
|
BIN_fn_vReadDataFromLinkTable(GMT_fn_p_stGetLinkTable(),
|
|
GMT_fn_ulReadBinaryBloc,
|
|
GMT_fn_ulGetStructureSize(),
|
|
_szBinaryFileName);
|
|
}
|
|
*/
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_p_cGeneralAllocationFunction
|
|
//----------------------------------------------------------------------------
|
|
// Methods : Allocate a bloc to read a bloc of game materials
|
|
//----------------------------------------------------------------------------
|
|
// Input : _ulSize : size to be allocated
|
|
// Output :
|
|
//----------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
//----------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
----------------------------------------------------------------------------*/
|
|
char* GMT_fn_p_cGeneralAllocationFunction(unsigned long _ulSize)
|
|
{
|
|
char* p_cbuffer;
|
|
|
|
MMG_fn_vAddMemoryInfo( MMG_C_lTypeGMT , MMG_C_lSubTypeMain , 0 );
|
|
GEO_M_CPAMalloc(p_cbuffer,char*,_ulSize,E_uwGEONotEnoughtMemory);
|
|
return p_cbuffer;
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_vReadAllGameMaterialBinaryBlocs2
|
|
//----------------------------------------------------------------------------
|
|
// Methods : Reads all the game materials from a binary file.(Version 2).
|
|
// With this method, all the gmt are allocated in 1 time
|
|
//----------------------------------------------------------------------------
|
|
// Input : _szBinaryFileName : Name of the binary file
|
|
// Output :
|
|
//----------------------------------------------------------------------------
|
|
// Creation date : Aug 97 Author: Alain Robin
|
|
//----------------------------------------------------------------------------
|
|
// Modifications :
|
|
// Modification date : Modification author :
|
|
----------------------------------------------------------------------------*/
|
|
/*
|
|
void GMT_fn_vReadAllGameMaterialBinaryBlocs2(char* _szBinaryFileName)
|
|
{
|
|
BIN_fn_vReadDataFromLinkTableWithoutAllocation(GMT_fn_p_stGetLinkTable(),
|
|
GMT_fn_vRestorePointerFromIds,
|
|
GMT_fn_ulGetStructureSize(),
|
|
_szBinaryFileName,
|
|
GMT_fn_p_cGeneralAllocationFunction);
|
|
}
|
|
*/
|
|
|
|
/*
|
|
BEGIN OS 25.02.98
|
|
Callbacks for bin files.
|
|
*/
|
|
|
|
/*----------------------------------------------------------------------------
|
|
// Description : GMT_fn_hLoadGameMaterial
|
|
// Load a game material from the scripts or from the binary bloc
|
|
//----------------------------------------------------------------------------
|
|
//----------------------------------------------------------------------------*/
|
|
/*
|
|
GMT_tdxHandleToGameMaterial GMT_fn_hLoadBinGameMaterial(char* _szSectionName)
|
|
{
|
|
SCR_tdst_Cxt_Values *p_stValues ;
|
|
SCR_tdst_Link_Value *p_stLinkValue;
|
|
unsigned long ulResult;
|
|
|
|
p_stLinkValue=BIN_fn_p_stSearchShortKey(GMT_fn_p_stGetLinkTable(),_szSectionName);
|
|
if(p_stLinkValue==NULL)
|
|
{
|
|
p_stValues = SCR_fnp_st_Bin_GetREFERENCE( _szSectionName );
|
|
if(p_stValues)
|
|
{
|
|
ulResult = SCR_M_ul_RdL0_ExtractLongValue(p_stValues,0);
|
|
return (GMT_tdxHandleToGameMaterial)ulResult;
|
|
}
|
|
else
|
|
return (GMT_tdxHandleToGameMaterial)GMT_C_ulInvalidHandle;
|
|
}
|
|
else return (GMT_tdxHandleToGameMaterial)p_stLinkValue->ulValue;
|
|
}
|
|
*/
|
|
/*////////////////////////////////////////////////////////////////////////////
|
|
// Description : fn_eScriptCallBackBinGameMaterial
|
|
// Reads the script file describing a game material
|
|
/////////////////////////////////////////////////////////////////////////////*/
|
|
/*
|
|
SCR_tde_Anl_ReturnValue fn_eScriptCallBackBinGameMaterial(
|
|
SCR_tdst_File_Description *_p_stFile,
|
|
char *szAction,
|
|
char *d_szPars[],
|
|
SCR_tde_Anl_Action eAction)
|
|
{
|
|
GMT_tdxHandleToGameMaterial h_GameMaterial;
|
|
char chTag;
|
|
SCR_tde_Anl_ReturnValue eReturnValue = R_SCRIPT_NormalReturn;
|
|
|
|
if( eAction != SCR_EA_Anl_BeginSection )
|
|
{
|
|
// do whatever ...
|
|
return SCR_ERV_Anl_NormalReturn;
|
|
}
|
|
|
|
SCR_fn_v_Bin_BeginSection(_p_stFile);
|
|
|
|
// Allocates
|
|
h_GameMaterial = GMT_fn_hCreateGameMaterial();
|
|
|
|
SCR_M_RdL0_SetSectionLong(0, 0, (unsigned long)(h_GameMaterial))
|
|
GMT_fn_vAddEntryIntoLinkTable((unsigned long)h_GameMaterial);
|
|
|
|
do{
|
|
chTag=SCR_fn_ch_Bin_GetCHAR( _p_stFile );
|
|
switch (chTag)
|
|
{
|
|
case 0: //VisualMat
|
|
{
|
|
SCR_tdst_Cxt_Values *p_stValues ;
|
|
unsigned long ulResult;
|
|
ACP_tdxHandleOfMaterial hVisualMat;
|
|
char szName[MAX_PATH];
|
|
|
|
SCR_fn_sz_Bin_GetREFERENCE2Buffer( _p_stFile, szName );
|
|
// Call the callback of visual material
|
|
// And Put the Handle in the structure GameMaterial Handled
|
|
p_stValues = SCR_fnp_st_Bin_GetREFERENCE( szName );;
|
|
|
|
|
|
if(p_stValues)
|
|
{
|
|
ulResult = p_stValues->a_ulValues[0];
|
|
hVisualMat=(ACP_tdxHandleOfMaterial)ulResult;
|
|
GMT_fn_vSetVisualMaterial(h_GameMaterial,hVisualMat);
|
|
}
|
|
|
|
}
|
|
break;
|
|
case 1: //MechanicalMat
|
|
{
|
|
SCR_tdst_Cxt_Values *p_stValues ;
|
|
unsigned long ulResult;
|
|
char szName[MAX_PATH];
|
|
|
|
|
|
SCR_fn_sz_Bin_GetREFERENCE2Buffer( _p_stFile, szName );
|
|
|
|
// Call the call back for the other properties into the .miv file
|
|
// and put the handles into the structure GameMaterial Handled
|
|
|
|
p_stValues = SCR_fnp_st_Bin_GetREFERENCE( szName );;
|
|
if(p_stValues)
|
|
{
|
|
ulResult = p_stValues->a_ulValues[0];
|
|
GMT_fn_vSetMechanicsMaterial(h_GameMaterial,(DNM_tdxHandleToMecMatCharacteristics)ulResult);
|
|
}
|
|
|
|
}
|
|
break;
|
|
case 2: //CollideMat
|
|
{
|
|
SCR_tdst_Cxt_Values *p_stValues ;
|
|
unsigned long ulResult;
|
|
char szName[MAX_PATH];
|
|
|
|
SCR_fn_sz_Bin_GetREFERENCE2Buffer( _p_stFile, szName );
|
|
|
|
// Call the call back for the other properties into the .miv file
|
|
// and put the handles into the structure GameMaterial Handled
|
|
|
|
p_stValues = SCR_fnp_st_Bin_GetREFERENCE( szName );;
|
|
if(p_stValues)
|
|
{
|
|
ulResult = p_stValues->a_ulValues[0];
|
|
GMT_fn_vSetCollideMaterial(h_GameMaterial,(GMT_tdxHandleToCollideMaterial)ulResult);
|
|
}
|
|
|
|
}
|
|
break;
|
|
case 3: //SoundType
|
|
{
|
|
long lValue;
|
|
|
|
lValue = SCR_fn_l_Bin_GetLONG( _p_stFile );
|
|
GMT_fn_vSetSoundMaterial(h_GameMaterial,lValue);
|
|
|
|
}
|
|
break;
|
|
}
|
|
}while (chTag!=-1);
|
|
|
|
|
|
h_GameMaterial->p_stInitialValues = GMT_fn_hCreateGameMaterial();
|
|
|
|
memcpy(h_GameMaterial->p_stInitialValues,h_GameMaterial,sizeof(struct GMT_tdstGameMaterial_));
|
|
|
|
h_GameMaterial->p_stInitialValues->p_stInitialValues=NULL;
|
|
|
|
SCR_fn_v_Bin_EndSection(_p_stFile);
|
|
|
|
return(eReturnValue);
|
|
}
|
|
*/
|
|
|
|
/*
|
|
END OS 25.02.98
|
|
Callbacks for bin files.
|
|
*/
|
|
|