Add rayman2 source files
This commit is contained in:
815
Rayman_X/cpa/tempgrp/GMT/PC/GmtLoad.c
Normal file
815
Rayman_X/cpa/tempgrp/GMT/PC/GmtLoad.c
Normal file
@@ -0,0 +1,815 @@
|
||||
/* (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.
|
||||
*/
|
||||
|
396
Rayman_X/cpa/tempgrp/GMT/PC/GmtZnLod.c
Normal file
396
Rayman_X/cpa/tempgrp/GMT/PC/GmtZnLod.c
Normal file
@@ -0,0 +1,396 @@
|
||||
/* (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);
|
||||
}
|
||||
*/
|
75
Rayman_X/cpa/tempgrp/GMT/PC/GmtZnLodCB.c
Normal file
75
Rayman_X/cpa/tempgrp/GMT/PC/GmtZnLodCB.c
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "ldt.h"
|
||||
|
||||
/*****************************************************************
|
||||
Name:
|
||||
Description: Create callback for LDT
|
||||
Author: Mircea Petrescu
|
||||
Date: 8/25/98
|
||||
Modified:
|
||||
*****************************************************************/
|
||||
int fn_iCreateCollideMaterial( LDT_tdst_Link *pLink )
|
||||
{
|
||||
GMT_tdxHandleToCollideMaterial h_CollideMaterial;
|
||||
|
||||
h_CollideMaterial = GMT_fn_hCreateCollideMaterial();
|
||||
|
||||
pLink->pObject=(void *)h_CollideMaterial;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
Name:
|
||||
Description: Load callback for LDT
|
||||
Author: Mircea Petrescu
|
||||
Date: 8/25/98
|
||||
Modified:
|
||||
*****************************************************************/
|
||||
int fn_iLoadCollideMaterial( LDT_tdst_Link *pLink )
|
||||
{
|
||||
LDT_tdeParseResult result=ParseResult_BeginSection;
|
||||
GMT_tdxHandleToCollideMaterial _h_CollideMaterial=(GMT_tdxHandleToCollideMaterial)pLink->pObject;
|
||||
char a255_cLongName[255];
|
||||
int iLen;
|
||||
|
||||
iLen=LDT_ComputeSectionName(pLink,a255_cLongName);
|
||||
SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(&g_stGmtZoneLinkTable,
|
||||
a255_cLongName,
|
||||
(unsigned long)_h_CollideMaterial),
|
||||
1,iLen);
|
||||
|
||||
while( result!=ParseResult_EndSection )
|
||||
{
|
||||
result=LDT_GetNextEntry();
|
||||
switch( result )
|
||||
{
|
||||
case ParseResult_Entry: /* an entry */
|
||||
{
|
||||
short wValue;
|
||||
char *szEntry=LDT_szGetEntryName();
|
||||
if( strcmp( szEntry, C_EntryCollideMaterial )!=0 )
|
||||
break;
|
||||
szEntry=LDT_szGetParam(1);
|
||||
switch( *(long *)szEntry )
|
||||
{
|
||||
case 'mdZ' : /* Zdm */
|
||||
GMT_fn_vSetTypeOfCollideMaterial(_h_CollideMaterial,GMT_C_wZDM);
|
||||
break;
|
||||
case 'rdZ' : /* Zdr */
|
||||
GMT_fn_vSetTypeOfCollideMaterial(_h_CollideMaterial,GMT_C_wZDR);
|
||||
break;
|
||||
case 'edZ' : /* Zde */
|
||||
GMT_fn_vSetTypeOfCollideMaterial(_h_CollideMaterial,GMT_C_wZDE);
|
||||
break;
|
||||
case 'ddZ' : /* Zdd */
|
||||
GMT_fn_vSetTypeOfCollideMaterial(_h_CollideMaterial,GMT_C_wZDD);
|
||||
break;
|
||||
}
|
||||
wValue=(short)atoi( LDT_szGetParam( 2 ) );
|
||||
GMT_fn_hSetCollideMaterialIdentifier(_h_CollideMaterial,wValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
89
Rayman_X/cpa/tempgrp/GMT/PC/gmtloadCB.c
Normal file
89
Rayman_X/cpa/tempgrp/GMT/PC/gmtloadCB.c
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "LDT.h"
|
||||
|
||||
/*****************************************************************
|
||||
Name:
|
||||
Description: Create callback for LDT
|
||||
Author: Mircea Petrescu
|
||||
Date: 8/13/98
|
||||
Modified:
|
||||
*****************************************************************/
|
||||
int fn_iCreateGameMaterial( LDT_tdst_Link *pLink )
|
||||
{
|
||||
GMT_tdxHandleToGameMaterial h_GameMaterial= GMT_fn_hCreateGameMaterial();
|
||||
pLink->pObject=(void *)h_GameMaterial;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
Name:
|
||||
Description: Load callback for LDT
|
||||
Author: Mircea Petrescu
|
||||
Date: 8/13/98
|
||||
Modified:
|
||||
*****************************************************************/
|
||||
int fn_iLoadGameMaterial( LDT_tdst_Link *pLink )
|
||||
{
|
||||
LDT_tdeParseResult result=ParseResult_BeginSection;
|
||||
GMT_tdxHandleToGameMaterial h_GameMaterial=(GMT_tdxHandleToGameMaterial)pLink->pObject;
|
||||
char a255_cLongName[256];
|
||||
int iLen=LDT_ComputeSectionName(pLink,a255_cLongName);
|
||||
SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(
|
||||
&g_stGmtLinkTable, a255_cLongName, (long)h_GameMaterial)
|
||||
,1 , iLen);
|
||||
|
||||
|
||||
while( result!=ParseResult_EndSection )
|
||||
{
|
||||
result=LDT_GetNextEntry();
|
||||
switch( result )
|
||||
{
|
||||
case ParseResult_Entry: /* an entry */
|
||||
{
|
||||
char *szEntry=LDT_szGetEntryName();
|
||||
switch (*(long*)szEntry)
|
||||
{
|
||||
case 'usiV' : /* VisualMat */
|
||||
{
|
||||
ACP_tdxHandleOfMaterial hVisualMat;
|
||||
hVisualMat=(ACP_tdxHandleOfMaterial)LDT_LoadSection( LDT_szGetParam(1) );
|
||||
GMT_fn_vSetVisualMaterial(h_GameMaterial,hVisualMat);
|
||||
}
|
||||
break;
|
||||
case 'hceM' : /* MechanicalMat */
|
||||
{
|
||||
SCR_tdst_Cxt_Values *p_stValues ;
|
||||
unsigned long ulResult;
|
||||
|
||||
/* Call the call back for the other properties into the .miv file */
|
||||
/* and put the handles into the structure GameMaterial Handled */
|
||||
|
||||
GMT_fn_vSetMechanicsMaterial(h_GameMaterial,(DNM_tdxHandleToMecMatCharacteristics)LDT_LoadSection( LDT_szGetParam(1) ));
|
||||
|
||||
}
|
||||
break;
|
||||
case 'lloC' : /* CollideMat */
|
||||
{
|
||||
|
||||
/* Call the call back for the other properties into the .miv file */
|
||||
/* and put the handles into the structure GameMaterial Handled */
|
||||
|
||||
GMT_fn_vSetCollideMaterial(h_GameMaterial,(GMT_tdxHandleToCollideMaterial)LDT_LoadSection(LDT_szGetParam(1)));
|
||||
}
|
||||
break;
|
||||
case 'nuoS' : /* SoundType */
|
||||
{
|
||||
GMT_fn_vSetSoundMaterial(h_GameMaterial,(long)atoi( LDT_szGetParam( 1 ) ));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user