reman3/Rayman_X/cpa/Appli/Max23Dos/src/ZooLoad.c

166 lines
5.0 KiB
C

/*=========================================================================
*
* Zooload.c - loading functions for ZOO file
*
* Version 1.0
* Revision date
*
*=======================================================================*/
#include "ZooLoad.h"
#include "conventi.h"
//--- Global statics --------------------------------------------------------
int gs_iNb=0;
//--------------------------------------------------------------------
/****************************************************************************
* Description: register the loading function for the ZOO file
*
* Parameters:
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
void MLT_vInitZOOLoad()
{
SCR_fn_v_RdL0_RegisterCallback(M_CS, MLT_xLoadCS,SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_RdL0_RegisterCallback(M_AllCollideSets, MLT_xLoadAllCollideSets,SCR_CRC_c_RdL0_ForSection);
gs_iNb = 0;
}
/****************************************************************************
* Description: load AllCollideSets section in ZOO file
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadAllCollideSets(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
MLT_tdstZoo *p_stZoo;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
p_stZoo = (MLT_tdstZoo*)calloc(1,sizeof(MLT_tdstZoo));
SCR_M_RdL0_SetSectionLong(0,0,(unsigned long)p_stZoo);
SCR_M_RdL0_SetContextLong(0,0,(unsigned long)p_stZoo);
break;
case SCR_EA_Anl_Entry:
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: load CS sub-section in ZOO file
*
* Parameters: p_stFile : script file pointer
* szAction : section or entry name
* szParams : parameters
* cType : action type
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
SCR_tde_Anl_ReturnValue MLT_xLoadCS(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
MLT_tdstZoo *p_stZoo;
xString sFile, sAction, sIdent;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
SCR_M_RdL0_GetContextLong(-1,0,MLT_tdstZoo*,p_stZoo);
SCR_fn_v_RdL0_SplitSectionName(SCR_M_RdL0_GetCompleteSectionNameR(0), sFile, sAction, sIdent);
if (!MLT_bExistIn(p_stZoo->sCS, sIdent))
strcpy(p_stZoo->sCS[gs_iNb], sIdent);
strcpy(p_stZoo->sZDR[gs_iNb], "");
strcpy(p_stZoo->sZDM[gs_iNb], "");
strcpy(p_stZoo->sZDE[gs_iNb], "");
strcpy(p_stZoo->sZDD[gs_iNb], "");
gs_iNb++;
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetContextLong(-1,0,MLT_tdstZoo*,p_stZoo);
if (strcmp(szAction,M_ZOOActionZDR)==0)
{
strcpy(p_stZoo->sZDR[gs_iNb-1], szParams[0]);
}
if (strcmp(szAction,M_ZOOActionZDM)==0)
{
strcpy(p_stZoo->sZDM[gs_iNb-1], szParams[0]);
}
if (strcmp(szAction,M_ZOOActionZDE)==0)
{
strcpy(p_stZoo->sZDE[gs_iNb-1], szParams[0]);
}
if (strcmp(szAction,M_ZOOActionZDD)==0)
{
strcpy(p_stZoo->sZDD[gs_iNb-1], szParams[0]);
}
break;
case SCR_EA_Anl_EndSection:
break;
}
return SCR_ERV_Anl_NormalReturn;
}
/****************************************************************************
* Description: search given zone in the array
*
* Parameters: p_sArray : array of existing zones
* sIdent1 : zone to search for
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
BOOL MLT_bExistIn (xString *p_sArray, xString sIdent1)
{
int i;
for (i=0; i<gs_iNb; i++)
{
if (!strcmp(p_sArray[i], sIdent1))
return TRUE;
}
return FALSE;
}
/****************************************************************************
* Description: find index ofthe given zone in the array
*
* Parameters: sIdent : zone to search for
* p_stZoo : array of existing zones
*---------------------------------------------------------------------------
* Revision date: Author:
*****************************************************************************/
int MLT_iIndex (xString sIdent, MLT_tdstZoo* p_stZoo)
{
int i;
for (i=0; i<gs_iNb; i++)
{
if (!strcmp(sIdent, p_stZoo->sCS[i]))
return i;
}
return -1;
}