reman3/Rayman_X/cpa/tempgrp/AI/AIGame/ConvOper.c

283 lines
8.8 KiB
C

#if defined(_AI_LIB_)
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Erm.h"
#include "Convert.h"
#include "EnumOper.h"
#if defined(OPTIMIZED_COMMAND)
#include "ProtOper.h"
#endif
#else
#include <string.h>
#include "specif/AIOption.h"
#include "ConvCst.h"
#include "EnumOper.h"
#include "ConvOper.h"
#endif /* _AI_LIB_*/
#define C_MAX_SIZE_OPERATOR_EDITOR_NAME 4
#define C_MAX_SIZE_OPERATOR_SCRIPT_NAME 26
#define C_MAX_OPERATOR_NB_IN_PARAM 2
#define C_MAX_OPERATOR_NB_OUT_PARAM 1
typedef struct tdstOperatorEntry_
{
#if defined(ACTIVE_EDITOR)
/* Operator string used in editor*/
char szOperatorEditorName[C_MAX_SIZE_OPERATOR_EDITOR_NAME+1];
#endif /* ACTIVE_EDITOR*/
#if defined (AI_USE_SCRIPT)
/* Operator string used in script*/
char szOperatorScriptName[C_MAX_SIZE_OPERATOR_SCRIPT_NAME+1];
#endif /* AI_USE_SCRIPT */
#if defined(_AI_LIB_)
/* pointer on Operator function*/
tdp_fn_p_stOperatorFunctionPtr p_fn_p_stOperatorFunction;
#endif /* _AI_LIB_*/
#if defined(ACTIVE_EDITOR)
/* list of Operator parameters (taken from szAutorizedTypeParam) in parameter*/
char szOperatorTypeInParam[C_MAX_OPERATOR_NB_IN_PARAM+1];
/* out parameter*/
char szOperatorTypeOutParam[C_MAX_OPERATOR_NB_OUT_PARAM+1];
#endif /* ACTIVE_EDITOR*/
} tdstOperatorEntry;
tdstOperatorEntry a_stOperatorTable[eNbOperator]
#if defined(OPTIMIZED_COMMAND)
=
{
#if defined (AI_USE_SCRIPT)
/* Conditions initialisation*/
#if defined(_AI_LIB_)
#if defined(ACTIVE_EDITOR)
#define M_DEFINE_OPERATOR(a,b,c,d,e,f) { b,c,d,e,f },
#else
#define M_DEFINE_OPERATOR(a,b,c,d,e,f) { c,d },
#endif /* ACTIVE_EDITOR*/
#else
#if defined(ACTIVE_EDITOR)
#define M_DEFINE_OPERATOR(a,b,c,d,e,f) { b,c,e,f },
#else
#define M_DEFINE_OPERATOR(a,b,c,d,e,f) { c },
#endif /* ACTIVE_EDITOR*/
#endif
#include "DefOper.h"
#undef M_DEFINE_OPERATOR
}
#else /* AI_USE_SCRIPT */
/* Conditions initialisation*/
#if defined(_AI_LIB_)
#if defined(ACTIVE_EDITOR)
#define M_DEFINE_OPERATOR(a,b,c,d,e,f) { b,d },
#else
#define M_DEFINE_OPERATOR(a,b,c,d,e,f) { d },
#endif /* ACTIVE_EDITOR*/
#else
#if defined(ACTIVE_EDITOR)
#define M_DEFINE_OPERATOR(a,b,c,d,e,f) { b },
#else
#define M_DEFINE_OPERATOR(a,b,c,d,e,f) { },
#endif /* ACTIVE_EDITOR*/
#endif
#include "DefOper.h"
#undef M_DEFINE_OPERATOR
}
#endif /* AI_USE_SCRIPT */
#endif /* OPTIMIZED_COMMAND*/
;
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
enum tdeOperatorId_ fn_eGetNbOperator()
{
return(eNbOperator);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#if defined(_AI_LIB_)
tdp_fn_p_stOperatorFunctionPtr fn_p_fn_pGetOperatorFunctionPtr(enum tdeOperatorId_ eOperatorId)
{
return(a_stOperatorTable[eOperatorId].p_fn_p_stOperatorFunction);
}
#endif /* _AI_LIB_*/
#if defined(ACTIVE_EDITOR)
char *szGetOperatorTypeInParamFromId(enum tdeOperatorId_ eOperatorId)
{
return(a_stOperatorTable[eOperatorId].szOperatorTypeInParam);
}
char *szGetOperatorTypeOutParamFromId(enum tdeOperatorId_ eOperatorId)
{
return(a_stOperatorTable[eOperatorId].szOperatorTypeOutParam);
}
enum tdeOperatorId_ fn_eFindOperatorIdFromEditorName(char *szOperator)
{
short wOperatorEntry;
for(wOperatorEntry=0;wOperatorEntry<fn_eGetNbOperator();wOperatorEntry++)
{
if (!stricmp(a_stOperatorTable[wOperatorEntry].szOperatorEditorName,szOperator))
{
return((enum tdeOperatorId_) wOperatorEntry);
}
}
return(fn_eGetNbOperator());
}
char *szFindOperatorEditorNameFromId(enum tdeOperatorId_ eOperatorId)
{
return(a_stOperatorTable[eOperatorId].szOperatorEditorName);
}
char *szFindOperatorScriptNameFromId(enum tdeOperatorId_ eOperatorId)
{
return(a_stOperatorTable[eOperatorId].szOperatorScriptName);
}
#endif /* ACTIVE_EDITOR*/
#if defined (AI_USE_SCRIPT)
enum tdeOperatorId_ fn_eFindOperatorIdFromScriptName(char *szOperator)
{
short wOperatorEntry;
for(wOperatorEntry=0;wOperatorEntry<fn_eGetNbOperator();wOperatorEntry++)
{
if (!stricmp(a_stOperatorTable[wOperatorEntry].szOperatorScriptName,szOperator))
{
return((enum tdeOperatorId_) wOperatorEntry);
}
}
return(fn_eGetNbOperator());
}
#endif /* AI_USE_SCRIPT */
#if !defined(OPTIMIZED_COMMAND)
#if defined(ACTIVE_EDITOR)
void fn_vDefineOperatorEntry(enum tdeOperatorId_ eOperatorId,char *szOperatorEditorName,char *szOperatorScriptName,tdp_fn_p_stOperatorFunctionPtr p_fn_p_stOperatorFunction,char *szOperatorTypeInParam,char *szOperatorTypeOutParam)
#else
void fn_vDefineOperatorEntry(enum tdeOperatorId_ eOperatorId,char *szOperatorScriptName,tdp_fn_p_stOperatorFunctionPtr p_fn_p_stOperatorFunction,char *szOperatorTypeInParam,char *szOperatorTypeOutParam)
#endif /* ACTIVE_EDITOR*/
{
if (
(eOperatorId<fn_eGetNbOperator())
#if defined(ACTIVE_EDITOR)
&&(strlen(szOperatorEditorName)<=C_MAX_SIZE_OPERATOR_EDITOR_NAME)
#endif /* ACTIVE_EDITOR*/
&&(strlen(szOperatorScriptName)<=C_MAX_SIZE_OPERATOR_SCRIPT_NAME)
#if defined(ACTIVE_EDITOR)
&&(strlen(szOperatorTypeInParam)<=C_MAX_OPERATOR_NB_IN_PARAM)
&&(fn_ucCheckTypeParam(szOperatorTypeInParam))
&&(strlen(szOperatorTypeOutParam)<=C_MAX_OPERATOR_NB_OUT_PARAM)
&&(fn_ucCheckTypeParam(szOperatorTypeOutParam))
#endif /* ACTIVE_EDITOR*/
)
{
#if defined(ACTIVE_EDITOR)
strcpy(a_stOperatorTable[eOperatorId].szOperatorEditorName,szOperatorEditorName);
#endif /* ACTIVE_EDITOR*/
strcpy(a_stOperatorTable[eOperatorId].szOperatorScriptName,szOperatorScriptName);
a_stOperatorTable[eOperatorId].p_fn_p_stOperatorFunction=p_fn_p_stOperatorFunction;
#if defined(ACTIVE_EDITOR)
strcpy(a_stOperatorTable[eOperatorId].szOperatorTypeInParam,szOperatorTypeInParam);
strcpy(a_stOperatorTable[eOperatorId].szOperatorTypeOutParam,szOperatorTypeOutParam);
#else
szOperatorTypeInParam=szOperatorTypeInParam;
szOperatorTypeOutParam=szOperatorTypeOutParam;
#endif /* ACTIVE_EDITOR*/
}
else
{
char str[C_MAX_LENGTH_STRING];
sprintf(str,"Error while defining %s operator in %s\n",szOperatorScriptName,__FILE__);
M_AIFatalErrorMsg(E_uwAIFatalNotValidOperator,str);
}
}
#endif /* OPTIMIZED_COMMAND*/
#if !defined(OPTIMIZED_COMMAND)
#if defined(__DEBUG_AI__)
void fn_vInitOperatorTable(tdp_fn_p_stOperatorFunctionPtr fn_p_stDefaultOperatorFunctionPointer)
{
short wOperatorEntry;
for(wOperatorEntry=0;wOperatorEntry<fn_eGetNbOperator();wOperatorEntry++)
{
fn_vDefineOperatorEntry(M_OPERATOR_ENTRY((enum tdeOperatorId_) wOperatorEntry,"","",fn_p_stDefaultOperatorFunctionPointer,USE_NO_PARAM,USE_NO_PARAM));
}
}
void fn_vCheckOperatorTable(tdp_fn_p_stOperatorFunctionPtr fn_p_stDefaultOperatorFunctionPointer)
{
short wOperatorEntry;
char str[C_MAX_LENGTH_STRING];
size_t lLen;
size_t lMaxLengthScriptName=0;
#if defined(ACTIVE_EDITOR)
size_t lMaxLengthEditorName=0;
size_t lMaxLengthInParam=0;
size_t lMaxLengthOutParam=0;
#endif /* ACTIVE_EDITOR*/
for(wOperatorEntry=0;wOperatorEntry<fn_eGetNbOperator();wOperatorEntry++)
{
if (fn_p_fn_pGetOperatorFunctionPtr((enum tdeOperatorId_) wOperatorEntry)==fn_p_stDefaultOperatorFunctionPointer)
{
sprintf(str,"Error while defining %s operator in %s\n",a_stOperatorTable[wOperatorEntry].szOperatorScriptName,__FILE__);
M_AIFatalErrorMsg(E_uwAIFatalNotValidOperator,str);
}
if ((lLen=strlen(a_stOperatorTable[wOperatorEntry].szOperatorScriptName))>lMaxLengthScriptName)
{
lMaxLengthScriptName=lLen;
}
#if defined(ACTIVE_EDITOR)
if ((lLen=strlen(a_stOperatorTable[wOperatorEntry].szOperatorEditorName))>lMaxLengthEditorName)
{
lMaxLengthEditorName=lLen;
}
if ((lLen=strlen(a_stOperatorTable[wOperatorEntry].szOperatorTypeInParam))>lMaxLengthInParam)
{
lMaxLengthInParam=lLen;
}
if ((lLen=strlen(a_stOperatorTable[wOperatorEntry].szOperatorTypeOutParam))>lMaxLengthOutParam)
{
lMaxLengthOutParam=lLen;
}
#endif /* ACTIVE_EDITOR*/
}
#if !defined(U64)
{
if (lMaxLengthScriptName<C_MAX_SIZE_OPERATOR_SCRIPT_NAME)
{
sprintf(str,"*** AI : You should reduce C_MAX_SIZE_OPERATOR_SCRIPT_NAME in %s to %d\n",__FILE__,lMaxLengthScriptName);
OutputDebugString(str);
}
#if defined(ACTIVE_EDITOR)
if (lMaxLengthEditorName<C_MAX_SIZE_OPERATOR_EDITOR_NAME)
{
sprintf(str,"*** AI : You should reduce C_MAX_SIZE_OPERATOR_EDITOR_NAME in %s to %d\n",__FILE__,lMaxLengthEditorName);
OutputDebugString(str);
}
if (lMaxLengthInParam<C_MAX_OPERATOR_NB_IN_PARAM)
{
sprintf(str,"*** AI : You should reduce C_MAX_OPERATOR_NB_IN_PARAM in %s to %d\n",__FILE__,lMaxLengthInParam);
OutputDebugString(str);
}
if (lMaxLengthOutParam<C_MAX_OPERATOR_NB_OUT_PARAM)
{
sprintf(str,"*** AI : You should reduce C_MAX_OPERATOR_NB_OUT_PARAM in %s to %d\n",__FILE__,lMaxLengthOutParam);
OutputDebugString(str);
}
#endif /* ACTIVE_EDITOR*/
}
#endif /* U64*/
}
#endif /* __DEBUG_AI__*/
#endif /* OPTIMIZED_COMMAND*/