2256 lines
77 KiB
C
2256 lines
77 KiB
C
/*---------------------------------------------------------------------------*/
|
||
/* ReadFile.cpp : Manage the reading of rules file.*/
|
||
/* auteur : Olivier Didelot.*/
|
||
/* date : 29/08/1996*/
|
||
/* modify : 09/12/1996*/
|
||
/* modifications majeures : 22/12/96 Olivier Couvreur*/
|
||
/* 970115 : Vector management (Fabien Morales)*/
|
||
/* January 1997 : Adding Way and Waypoint management (Albert Pais)*/
|
||
/* 970131 : InitNode + Lint (Olivier Couvreur)*/
|
||
/* modify : Olivier Couvreur*/
|
||
/* date : 04/02/1997 Lint 0 warnings excepted those specified at the end of AIMacros.h*/
|
||
/* 970212 : Module & DsgVarId node types (Fabien Morales)*/
|
||
/* modify : Olivier Couvreur */
|
||
/* 970503 : C_...String for Editor + M_AIFatalError in InitConvertAndInitNode*/
|
||
/* modify : Olivier Couvreur */
|
||
/* 970503 : Model can be gathered between several perso + nearly all function rewritten to use new allocation functions*/
|
||
/* modify : Alb*/
|
||
/* Date : March 21,1997 : minus ways and waypoints modifications*/
|
||
/* modify : Olivier Couvreur 25/03/1997 NbNode is not an unsigned char anymore + REVERSE_RULES support*/
|
||
/* modify : Olivier Couvreur 03/04/1997 add button support*/
|
||
/* modify : Olivier Couvreur 09/04/1997 add error messages*/
|
||
/* modify : Olivier Couvreur 29/04/97 Init Comport and .IAI support + DsgVar Perso*/
|
||
/* modify : Olivier Couvreur 15/05/97 Support for special dsgVar init values for each perso (no more .IAI , all are transfered in .CAR in section brain )*/
|
||
/*---------------------------------------------------------------------------*/
|
||
#include "AIUseCPA.h"
|
||
|
||
#include "specif/AIOption.h"
|
||
#include "AIMacros.h"
|
||
#include "AI_Erm.h"
|
||
|
||
#include "AI_Struc.h"
|
||
#include "StrIntel.h"
|
||
#include "DsgMem.h"
|
||
#include "specif/ActTable.h"
|
||
#include "Action.h"
|
||
#include "VIG.h"
|
||
|
||
#include "CFast.h"
|
||
|
||
/* For Bin*/
|
||
#include "SNA.h"
|
||
/* MR0912*/
|
||
#include "SNA\SNAsyn.h"
|
||
|
||
/* To activate 1st pass checking : so that editor is lanched if some specific errors occur*/
|
||
#if defined(ACTIVE_EDITOR)
|
||
#define ACTIVE_1STPASS_CHECKING
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
/*#pragma message("ACTIVE_1STPASS_CHECKING is defined ==> editor will run automaticaly if an error occured in AI while loading")*/
|
||
#endif
|
||
#endif
|
||
|
||
/* in order to compile AI in C++ and link with GAM in C and used for fn_vForceEditor*/
|
||
#if defined(__cplusplus) || defined(ACTIVE_1STPASS_CHECKING)
|
||
#include "AI_Proto.h"
|
||
#endif
|
||
|
||
#if defined(__DEBUG_AI__) || defined(ACTIVE_1STPASS_CHECKING)
|
||
#include "EnumAct.h"
|
||
#include "EnumCond.h"
|
||
#include "EnumFunc.h"
|
||
#include "EnumOper.h"
|
||
#include "EnumProc.h"
|
||
#include "EnumFild.h"
|
||
#include "EnumKey.h"
|
||
#endif
|
||
|
||
/* not useful according to lint but i let it*/
|
||
#define _WP_D_DEFINE_WAYPOINTS_
|
||
#include "WP_Handl.h"
|
||
#include "WP_Func.h"
|
||
#undef _WP_D_DEFINE_WAYPOINTS_
|
||
|
||
#include "Convert.h"
|
||
|
||
#define __DeclareGlobalVariableReadRule_h__
|
||
#include "ReadRule.h"
|
||
#undef __DeclareGlobalVariableReadRule_h__
|
||
|
||
/*-------------------------------------------------------------------------------*/
|
||
/* Global Variable definition.*/
|
||
/*-------------------------------------------------------------------------------*/
|
||
|
||
unsigned char ucInIntelligenceSection=FALSE;
|
||
unsigned char ucInComportSection=FALSE;
|
||
unsigned char ucInRuleSection=FALSE;
|
||
|
||
AI_tdstAIModel *p_stLoadedAIModel=NULL;
|
||
AI_tdstMind *p_stLoadedMind=NULL;
|
||
tdstScriptAI *p_stLoadedScriptAI=NULL;
|
||
tdstComport *p_stLoadedComport=NULL;
|
||
tdstTreeInterpret *p_stLoadedRule=NULL;
|
||
tdstNodeInterpret *p_stLoadedNode=NULL;
|
||
tdstTreeInterpret *p_stLoadedSchedule=NULL;
|
||
tdstEngineObject *p_stLoadedEngineObject;
|
||
|
||
typedef struct
|
||
{
|
||
unsigned long ulNbComport;
|
||
unsigned short uwNbNode;
|
||
unsigned char ucNbRules;
|
||
} tdstIntelligenceCounter;
|
||
|
||
/* store values read by script*/
|
||
tdstIntelligenceCounter ScriptCounter;
|
||
/* update values as we fill structures*/
|
||
tdstIntelligenceCounter StructCounter;
|
||
|
||
/*-------------------------------------------------------------------------------*/
|
||
/* Functions definition.*/
|
||
/*-------------------------------------------------------------------------------*/
|
||
|
||
/*****************************************************************************************************************/
|
||
/* FOR EDITOR TO INTERCEPT ERRORS*/
|
||
#if defined(ACTIVE_1STPASS_CHECKING) || defined(__DEBUG_AI__)
|
||
char szForErrorStringAt1stPass[400];
|
||
#endif
|
||
|
||
#if defined(__DEBUG_AI__)
|
||
#define M_StandardMessage(p_stMind,szTitle,szName,BaseMsg) \
|
||
sprintf(szForErrorStringAt1stPass,"%s (%s) in %s",szTitle,szName,AI_M_szGetPersoName((p_stMind))); \
|
||
M_AIFatalErrorMsg(E_uwAIFatal##BaseMsg,szForErrorStringAt1stPass);
|
||
#else
|
||
#define M_StandardMessage(p_stMind,szTitle,szName,BaseMsg)
|
||
#endif
|
||
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
#define M_TestNodeInterpret(p_stMind,M_Condition,szTitle,szName,BaseMsg) \
|
||
if(!(M_Condition)) \
|
||
{ \
|
||
sprintf(szForErrorStringAt1stPass,"%s (%s) in %s",szTitle,szName,AI_M_szGetPersoName((p_stMind))); \
|
||
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarning##BaseMsg,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass); \
|
||
AI_M_ucErrorFlag((p_stMind))=1; \
|
||
fn_vForceEditor(); \
|
||
}
|
||
#elif defined(__DEBUG_AI__)
|
||
#define M_TestNodeInterpret(p_stMind,M_Condition,szTitle,szName,BaseMsg) \
|
||
if(!(M_Condition)) \
|
||
{ \
|
||
M_StandardMessage((p_stMind),szTitle,szName,BaseMsg) \
|
||
}
|
||
#else
|
||
#define M_TestNodeInterpret(p_stMind,M_Condition,szTitle,szName,BaseMsg)
|
||
#endif
|
||
|
||
/*****************************************************************************************************************/
|
||
char szForScript[_MAX_PATH];
|
||
|
||
#if !defined(U64)
|
||
/* To simplify access to link table*/
|
||
SCR_tdst_Link_Value *fn_vLinkWithLinkTable(SCR_tdst_Link_Table *p_stLinkTable, char *szPathToConcatenate, char *szStrToPutInLinkTable,tdstNodeInterpret *p_stNode,tdeTypeInterpret eTypeInterpret,unsigned char ucDepth)
|
||
{
|
||
SCR_tdst_Link_Value *p_stLinkValue;
|
||
char szLocalForScript[_MAX_PATH]="";
|
||
|
||
if (szPathToConcatenate != NULL)
|
||
{
|
||
strcat(szLocalForScript, szPathToConcatenate);
|
||
strcat(szLocalForScript, "\\");
|
||
}
|
||
strcat(szLocalForScript,szStrToPutInLinkTable);
|
||
|
||
p_stLinkValue = SCR_fnp_st_Link_CreateOrGetLinkFromKey( p_stLinkTable, szLocalForScript);
|
||
M_lKeyLinkInterpret(p_stNode) = (long)p_stLinkValue;
|
||
M_SetTypeInterpret(p_stNode, eTypeInterpret);
|
||
M_DepthInterpret(p_stNode)= ucDepth;
|
||
return p_stLinkValue;
|
||
}
|
||
|
||
#define MAX_NODE_STRING_LENGTH 19
|
||
|
||
typedef void (*tdp_fn_vInitNodeFunctionPointer)(struct tdstNodeInterpret_ *p_stNode,char *szParams[]);
|
||
|
||
typedef struct tdstNodeEntry_
|
||
{
|
||
char szNodeName[MAX_NODE_STRING_LENGTH+1];
|
||
tdeTypeInterpret eNodeType;
|
||
tdp_fn_vInitNodeFunctionPointer p_fn_vInitNodeFunctionPointer;
|
||
} tdstNodeEntry;
|
||
|
||
#define M_DEFINE_NODE(a,b,cccc) static void cccc(struct tdstNodeInterpret_ *p_stNode,char *szParams[]);
|
||
#include "DefNode.h"
|
||
#undef M_DEFINE_NODE
|
||
|
||
tdstNodeEntry a_stNodeTable[]=
|
||
{
|
||
#define M_DEFINE_NODE(a,b,c) {a,b,c},
|
||
#include "DefNode.h"
|
||
#undef M_DEFINE_NODE
|
||
};
|
||
|
||
void fn_vConvertAndInitNode(char *szAction,char *szParams[], tdstNodeInterpret *p_stNode,unsigned char ucDepth)
|
||
{
|
||
long i;
|
||
|
||
/* clear node*/
|
||
M_ClearNodeInterpret(p_stNode);
|
||
|
||
/* set depth*/
|
||
M_DepthInterpret(p_stNode)=ucDepth;
|
||
|
||
/* default node type*/
|
||
M_SetTypeInterpret(p_stNode,E_ti_Unknown);
|
||
|
||
for(i=0;i<sizeof(a_stNodeTable)/sizeof(a_stNodeTable[0]);i++)
|
||
{
|
||
if (!stricmp(szAction,a_stNodeTable[i].szNodeName))
|
||
{
|
||
/* set node type*/
|
||
M_SetTypeInterpret(p_stNode,a_stNodeTable[i].eNodeType);
|
||
|
||
/* call init node function*/
|
||
a_stNodeTable[i].p_fn_vInitNodeFunctionPointer(p_stNode,szParams);
|
||
return;
|
||
}
|
||
}
|
||
|
||
/* unknown node*/
|
||
M_lValueInterpret(p_stNode)=0;
|
||
M_TestNodeInterpret(p_stLoadedMind,0,"Unknown name",szAction,UnknownNode);
|
||
}
|
||
|
||
|
||
static void fn_vInitNodeMacroRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
unsigned char ucDepth=0;
|
||
SCR_tdst_Link_Value *p_stLinkValue;
|
||
char szFileName[_MAX_PATH];
|
||
|
||
/* fill the string szForScript.*/
|
||
fn_v_File_ComputeFileSectionName(szParams[0],szFileName,szForScript);
|
||
ucDepth =(unsigned char)atol(szParams[1]);
|
||
p_stLinkValue = fn_vLinkWithLinkTable(&g_stMacroLinkTable, fn_szGetFamiliesDataPath(), szForScript,p_stNode,E_ti_MacroRef,ucDepth);
|
||
}
|
||
|
||
SCR_tde_Anl_ReturnValue fn_eCreateMacros(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
char szForScript[256];
|
||
char szErrorString[100];
|
||
tdstMacro *p_stMacro;
|
||
|
||
p_stFile=p_stFile;/* for lint*/
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
ucInRuleSection=TRUE;
|
||
|
||
/* plus 1 for adding a dummy node at the end of the tree*/
|
||
ScriptCounter.uwNbNode=(unsigned short) (atoi(szParams[1])+1);
|
||
StructCounter.uwNbNode=0;
|
||
|
||
/* allocate Macro*/
|
||
p_stMacro = M_GetMacroN(AI_M_p_stGetListOfMacroAIModel(AI_M_p_stGetAIModel(p_stLoadedMind)), atoi(szParams[0]));
|
||
fn_vAllocNodeMacro(p_stMacro, ScriptCounter.uwNbNode);
|
||
|
||
p_stLoadedNode = M_GetNodeInterpret(M_GetMacroInitTree(p_stMacro));
|
||
|
||
SCR_M_RdL0_ComputeOpenSectionNameR(0,szForScript);
|
||
#ifdef __DEBUG_AI__
|
||
strcpy ( M_GetNameMacro(p_stMacro) , SCR_M_RdL0_GetCompleteSectionNameR(0) ) ;
|
||
#endif
|
||
SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(&g_stMacroLinkTable, szForScript, (unsigned long)p_stMacro), 1,
|
||
strlen(szForScript)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)) );
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection)
|
||
{
|
||
/* add a dummy node at the end of the tree*/
|
||
fn_vInitNodeInterpret(p_stLoadedNode+StructCounter.uwNbNode, 0, E_ti_EndTree, 0);
|
||
|
||
StructCounter.uwNbNode++;
|
||
|
||
if (ScriptCounter.uwNbNode!=StructCounter.uwNbNode)
|
||
{
|
||
sprintf(szErrorString,"Number of nodes in this macro should be (%d)\n", ScriptCounter.uwNbNode);
|
||
M_AIFatalErrorMsg(E_uwAIFatalBadNodeNumber,szErrorString);
|
||
}
|
||
ucInRuleSection=FALSE;
|
||
}
|
||
else
|
||
{
|
||
unsigned char ucDepth=0;
|
||
|
||
if (szParams[1]!=NULL)
|
||
{
|
||
ucDepth=(unsigned char) atol(szParams[1]);
|
||
}
|
||
else
|
||
{
|
||
sprintf(szErrorString,"Depth undefined (node %d schedule comport n. %d)\n",StructCounter.uwNbNode, StructCounter.ulNbComport);
|
||
M_AIFatalErrorMsg(E_uwAIFatalUnknownNode,szErrorString);
|
||
}
|
||
|
||
if (StructCounter.uwNbNode < ScriptCounter.uwNbNode)
|
||
{
|
||
fn_vConvertAndInitNode(szAction,
|
||
szParams,
|
||
p_stLoadedNode+StructCounter.uwNbNode,
|
||
ucDepth);
|
||
StructCounter.uwNbNode++;
|
||
}
|
||
else
|
||
{
|
||
sprintf(szErrorString,"Number of nodes in this macro should be (%d)\n", ScriptCounter.uwNbNode);
|
||
M_AIFatalErrorMsg(E_uwAIFatalBadNodeNumber,szErrorString);
|
||
}
|
||
}
|
||
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
SCR_tde_Anl_ReturnValue fn_eCreateListMacros(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
p_stFile = p_stFile;/* for lint*/
|
||
szAction=szAction;
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
VIG_fn_vAddToProgressBar(1);
|
||
fn_vAllocListOfMacro(p_stLoadedMind, (unsigned char)atoi(szParams[0]));
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection)
|
||
{
|
||
}
|
||
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
static void fn_vInitNodeCondition(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_eCondIdInterpret(p_stNode)=fn_eFindConditionIdFromScriptName(szParams[0]);
|
||
M_TestNodeInterpret(p_stLoadedMind,M_IsConditionIdValid(M_eCondIdInterpret(p_stNode)),"Condition name",szParams[0],UnknownCond);
|
||
}
|
||
|
||
static void fn_vInitNodeField(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_eFieldIdInterpret(p_stNode)=fn_eFindFieldIdFromScriptName(szParams[0]);
|
||
M_TestNodeInterpret(p_stLoadedMind,M_IsFieldIdValid(M_eFieldIdInterpret(p_stNode)),"Field name",szParams[0],UnknownFieldName);
|
||
}
|
||
|
||
static void fn_vInitNodeConstant(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_lValueInterpret(p_stNode)=atol(szParams[0]);
|
||
}
|
||
|
||
static void fn_vInitNodeString(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
fn_vCreateNodeString(p_stNode, szParams[0]);
|
||
}
|
||
|
||
static void fn_vInitNodeButton(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_hInputHandleIdInterpret(p_stNode)=IPT_fn_hGetEntryActionHandle(szParams[0]);
|
||
#if defined(__DEBUG_AI__)
|
||
if(!IPT_fn_bIsAValidEntryActionHandle(M_hInputHandleIdInterpret(p_stNode)))
|
||
{
|
||
M_StandardMessage(p_stLoadedMind,"Button name",szParams[0],UnknownButton);
|
||
}
|
||
#endif
|
||
}
|
||
|
||
static void fn_vInitNodeObjectTableRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
// Shaitan => module list in the level
|
||
SCR_M_RdL0_SetContextLong(C_GrandChildContext, 1, 0);
|
||
// End Shaitan => module list in the level
|
||
/*to make sure the table is loaded*/
|
||
(void) SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal); /* (void) for lint.*/
|
||
/*now we can set the node value with the handle*/
|
||
fn_vLinkWithLinkTable(&TBL_g_stLinkTable, fn_szGetFamiliesDataPath(), szParams[0],p_stNode,E_ti_ObjectTableRef,(unsigned char) atol(szParams[1]));
|
||
}
|
||
|
||
#ifdef D_USE_LIPSYNC
|
||
static void fn_vInitNodeLipSynchroRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
SCR_tdst_Cxt_Values *p_stValues;
|
||
/* MR0912*/
|
||
if (SNA_fn_ucGetLoadType()==SNA_LOAD_SCRIPT)
|
||
{ SCR_M_RdL0_SetContextLong(C_GrandChildContext,1,(long)fn_h3dDataGetFamily(p_stLoadedEngineObject->h_3dData));
|
||
p_stValues = SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal);
|
||
M_hLipSynchroHandleIdInterpret(p_stNode) = (tdxHandleOfLipsSynchroTable)(p_stValues->a_ulValues[0]);
|
||
}
|
||
else
|
||
if (SNA_fn_ucGetLoadType()==SNA_SAVE_SNAPSHOT)
|
||
{ /* Version Hybride*/
|
||
SCR_M_RdL0_SetContextLong(C_GrandChildContext,1,(long)fn_h3dDataGetFamily(p_stLoadedEngineObject->h_3dData));
|
||
p_stValues = SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal);
|
||
/* A voir...*/
|
||
M_hLipSynchroHandleIdInterpret(p_stNode) = (tdxHandleOfLipsSynchroTable)(p_stValues->a_ulValues[0]);
|
||
fn_vWriteLipsSynchroBloc((tdxHandleOfLipsSynchroTable)(p_stValues->a_ulValues[0]),szParams[0]);
|
||
/* End VH*/
|
||
SNA_fn_vWriteLipsSynchEntryInLipsSynchTableFile(szParams[0],(unsigned long)p_stNode);
|
||
}
|
||
}
|
||
#endif /* D_USE_LIPSYNC*/
|
||
|
||
static void fn_vInitNodeSoundEventRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
SCR_tdst_Cxt_Values *p_stValues;
|
||
p_stValues = SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal);
|
||
M_SoundEventInterpret(p_stNode) = (SND_tdxHandleToSoundEvent) (p_stValues->a_ulValues[0]);
|
||
if (SNA_fn_ucGetLoadType()==SNA_SAVE_SNAPSHOT)
|
||
/* we save the id of the sound event and the pointer on the structure that contains the id and the pointer of the sound event */
|
||
SNA_fn_vWriteSoundEntryInSoundTableFile(SND_fn_ulGetEventBinIdFromPointer((SND_tdxHandleToSoundEvent)p_stValues->a_ulValues[0]) ,(unsigned long)&(M_SoundEventInterpret(p_stNode)));
|
||
}
|
||
|
||
static void fn_vInitNodeBeginMacro(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_lValueInterpret(p_stNode) = 0;
|
||
}
|
||
|
||
static void fn_vInitNodeEndMacro(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_lValueInterpret(p_stNode) = 0;
|
||
}
|
||
|
||
static void fn_vInitNodeDsgVar(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_lValueInterpret(p_stNode)=atol(szParams[0]);
|
||
}
|
||
|
||
static void fn_vInitNodeDsgVarRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
fn_vLinkWithLinkTable(&g_stDsgVarLinkTable, fn_szGetFamiliesDataPath(), szParams[0],p_stNode,E_ti_DsgVarRef,(unsigned char) atol(szParams[1]));
|
||
}
|
||
|
||
static void fn_vInitNodeOperator(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_eOperatorIdInterpret(p_stNode)=fn_eFindOperatorIdFromScriptName(szParams[0]);
|
||
M_TestNodeInterpret(p_stLoadedMind,M_IsOperatorIdValid(M_eOperatorIdInterpret(p_stNode)),"Operator name",szParams[0],UnknownOperator);
|
||
}
|
||
|
||
static void fn_vInitNodeFunction(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_eFuncIdInterpret(p_stNode)=fn_eFindFunctionIdFromScriptName(szParams[0]);
|
||
M_TestNodeInterpret(p_stLoadedMind,M_IsFuncIdValid(M_eFuncIdInterpret(p_stNode)),"Function name",szParams[0],UnknownFunc);
|
||
}
|
||
|
||
static void fn_vInitNodeProcedure(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_eProcedureIdInterpret(p_stNode) = fn_eFindProcedureIdFromScriptName(szParams[0]);
|
||
M_TestNodeInterpret(p_stLoadedMind,M_IsProcedureIdValid(M_eProcedureIdInterpret(p_stNode)),"Procedure name",szParams[0],UnknownFunc);
|
||
}
|
||
|
||
static void fn_vInitNodeKeyWord(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_eKeyWordIdInterpret(p_stNode)=fn_eFindKeyWordIdFromScriptName(szParams[0]);
|
||
M_TestNodeInterpret(p_stLoadedMind,M_IsKeyWordIdValid(M_eKeyWordIdInterpret(p_stNode)),"Keyword name",szParams[0],UnknownKeyWord);
|
||
}
|
||
|
||
/*
|
||
static void fn_vInitNodeMetaAction(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_eMetaActionIdInterpret(p_stNode) = fn_eFindMetaActionIdFromScriptName(szParams[0]);
|
||
M_TestNodeInterpret(p_stLoadedMind,M_IsMetaActionIdValid(M_eMetaActionIdInterpret(p_stNode)),"Metaaction name",szParams[0],InvalidAction);
|
||
}
|
||
*/
|
||
#include "enumproc.h"
|
||
static void fn_vInitNodeMetaAction(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_eMetaActionIdInterpret(p_stNode) = fn_eFindMetaActionIdFromScriptName(szParams[0]);
|
||
|
||
/* bidouille temporaire */
|
||
if (!M_IsMetaActionIdValid(M_eMetaActionIdInterpret(p_stNode)))
|
||
{
|
||
char str[256]="Proc";
|
||
char *ptr;
|
||
if ((ptr=strchr(szParams[0],'_'))!=NULL)
|
||
{
|
||
tdeProcedureId eProcId;
|
||
strcat(str,ptr);
|
||
eProcId=fn_eFindProcedureIdFromScriptName(str);
|
||
if (M_IsProcedureIdValid(eProcId))
|
||
{
|
||
M_SetTypeInterpret(p_stNode,E_ti_Procedure);
|
||
M_eProcedureIdInterpret(p_stNode)=eProcId;
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
M_TestNodeInterpret(p_stLoadedMind,M_IsMetaActionIdValid(M_eMetaActionIdInterpret(p_stNode)),"Metaaction name",szParams[0],InvalidAction);
|
||
}
|
||
|
||
static void fn_vInitNodeReal(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_xValueInterpret(p_stNode) = MTH_M_xFloatToReal((float) atof(szParams[0]));
|
||
}
|
||
|
||
static void fn_vInitNodeSuperObjectRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
fn_vLinkWithLinkTable(HIE_fn_p_stGetSuperObjectLinkTable(), fn_szGetLevelsDataPath(), szParams[0],p_stNode,E_ti_SuperObjectRef,(unsigned char) atol(szParams[1]));
|
||
}
|
||
|
||
static void fn_vInitNodeFamilyRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_hFamilyHandleIdInterpret(p_stNode) = fn_hFindOrAddFAmily(fn_otFindOrAddFamilyTypeOfFamilyTypeName(szParams[0]));
|
||
}
|
||
|
||
static void fn_vInitNodeTextRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
/*M_TextInterpret(p_stNode) = FON_fn_hGetTextHandle(szParams[0]);*/
|
||
FON_tdxHandleOfText hText = FON_fn_hGetTextHandle(szParams[0]);
|
||
M_TestNodeInterpret(p_stLoadedMind,(long)hText,"Text Key",szParams[0],ScriptError);
|
||
M_TextInterpret(p_stNode) = hText;
|
||
}
|
||
|
||
static void fn_vInitNodeParticleGenerator(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
SCR_tdst_Cxt_Values *p_stValues;
|
||
|
||
p_stValues = SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal);
|
||
M_ParticleGeneratorInterpret(p_stNode) = (tdxHandleToParticleGenerator)(p_stValues->a_ulValues[0]);
|
||
}
|
||
|
||
static void fn_vInitNodeGameMaterialRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
char szFile[SCR_CV_ui_Cfg_MaxLenName], szAction[SCR_CV_ui_Cfg_MaxLenName], szId[SCR_CV_ui_Cfg_MaxLenName];
|
||
SCR_tdst_File_Open *p_stFile;
|
||
|
||
SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal);
|
||
|
||
SCR_fn_v_RdL0_SplitSectionName(szParams[0], szFile, szAction, szId);
|
||
p_stFile = SCR_fnp_st_RdL0_GetOpenFile(szFile);
|
||
assert(p_stFile);
|
||
SCR_fn_v_RdL0_ComputeSectionName(szFile, p_stFile->stFile.a_szOpenFileName, szAction, szId);
|
||
fn_vLinkWithLinkTable(GMT_fn_p_stGetLinkTable(), NULL, szFile, p_stNode, E_ti_GameMaterialRef, (unsigned char) atol(szParams[1]));
|
||
}
|
||
|
||
static void fn_vInitNodeColor(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_ColorValueInterpret(p_stNode)=atol(szParams[0]);
|
||
}
|
||
|
||
static void fn_vInitNodePersoRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
unsigned char ucDepth=0;
|
||
/* Reference compatibility : 0,1,2 <-> 0^1:2*/
|
||
if (szParams[2]!=NULL)
|
||
{
|
||
SCR_fn_v_RdL0_ComputeSectionName(szForScript, szParams[0], szParams[1], szParams[2]);
|
||
ucDepth=(unsigned char) atol(szParams[3]);
|
||
}
|
||
else
|
||
{
|
||
strcpy(szForScript,szParams[0]);
|
||
ucDepth=(unsigned char) atol(szParams[1]);
|
||
}
|
||
fn_vLinkWithLinkTable(&g_st3DOSLinkTable.stCharacter, fn_szGetCharactersDataPath(), szForScript,p_stNode,E_ti_PersoRef,ucDepth);
|
||
}
|
||
|
||
static void fn_vInitNodeComportRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
unsigned char ucDepth=0;
|
||
SCR_tdst_Link_Value *p_stLinkValue;
|
||
|
||
if (szParams[2]!=NULL)
|
||
{
|
||
SCR_fn_v_RdL0_ComputeSectionName(szForScript, szParams[0], szParams[1], szParams[2]);
|
||
ucDepth=(unsigned char)atol(szParams[3]);
|
||
}
|
||
else
|
||
{
|
||
char szFileName[_MAX_PATH];
|
||
fn_v_File_ComputeFileSectionName(szParams[0],szFileName,szForScript);
|
||
ucDepth =(unsigned char)atol(szParams[1]);
|
||
}
|
||
p_stLinkValue = fn_vLinkWithLinkTable(&g_stComportLinkTable, fn_szGetFamiliesDataPath(), szForScript,p_stNode,E_ti_ComportRef,ucDepth);
|
||
SCR_M_v_Link_SetAdditionalLong(p_stLinkValue, 4, 0);
|
||
}
|
||
|
||
static void fn_vInitNodeModuleRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
/*
|
||
struct tdstFamilyList_ *p_stFamily;
|
||
SCR_tdst_Link_Value * _p_stLinkValue;
|
||
p_stFamily=fn_h3dDataGetFamily(p_stLoadedEngineObject->h_3dData);
|
||
strcpy(szForScript,fn_szFindFamilyTypeNameOfFamilyType(p_stFamily->otObjectFamilyType));
|
||
strcat(szForScript,"-");
|
||
strcat(szForScript,szParams[0]);
|
||
|
||
_p_stLinkValue = SCR_fnp_st_Link_SearchKey(&CHL_g_stLinkTable,szForScript);
|
||
if(_p_stLinkValue)
|
||
{
|
||
M_lModuleInterpret(p_stNode) = (unsigned short)SCR_M_ul_Link_GetValue(_p_stLinkValue);
|
||
}
|
||
else
|
||
{
|
||
M_lModuleInterpret(p_stNode) = (unsigned short)0;
|
||
}
|
||
*/
|
||
fn_vLinkWithLinkTable(&CHL_g_stLinkTable, NULL, szParams[0], p_stNode, E_ti_ModuleRef, (unsigned char) atol(szParams[1]));
|
||
}
|
||
|
||
static void fn_vInitNodeActionRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
fn_vLinkWithLinkTable(&g_st3DOSLinkTable.stState, fn_szGetFamiliesDataPath(), szParams[0],p_stNode,E_ti_ActionRef,(unsigned char) atol(szParams[1]));
|
||
}
|
||
|
||
static void fn_vInitNodeVector(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
/* nothing to do : normal*/
|
||
}
|
||
|
||
static void fn_vInitNodeConstantVector(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
MTH3D_tdstVector *p_stVector;
|
||
MTH_tdxReal xX,xY,xZ;
|
||
|
||
fn_vCreateNodeVector(p_stNode);
|
||
p_stVector=M_p_stVectorInterpret(p_stNode);
|
||
|
||
xX=MTH_M_xFloatToReal((float) atof(szParams[0]));
|
||
xY=MTH_M_xFloatToReal((float) atof(szParams[1]));
|
||
xZ=MTH_M_xFloatToReal((float) atof(szParams[2]));
|
||
|
||
MTH3D_M_vSetVectorElements(p_stVector,xX,xY,xZ);
|
||
M_DepthInterpret(p_stNode)= (unsigned char)atol(szParams[3]);
|
||
}
|
||
|
||
static void fn_vInitNodeWayPoint(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
/* ANNECY MT - 25/09/98 {*/
|
||
char szForScript[256];
|
||
|
||
strcpy(szForScript,fn_szGetLevelsDataPath());
|
||
strcat(szForScript,"\\");
|
||
strcat(szForScript,szParams[0]);
|
||
M_lKeyLinkInterpret(p_stNode) = (long)SCR_fnp_st_Link_CreateOrGetLinkFromKey(WP_fnp_WayPoint_GetLinkTable(),szForScript);
|
||
/* END ANNECY MT }*/
|
||
}
|
||
|
||
static void fn_vInitNodeModule(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_lModuleInterpret(p_stNode)=atol(szParams[0]);
|
||
}
|
||
|
||
static void fn_vInitNodeDsgVarId(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_lDsgVarIdInterpret(p_stNode)=atol(szParams[0]);
|
||
}
|
||
|
||
static void fn_vInitNodeMask(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
M_xMaskInterpret(p_stNode)=(GMT_tdxMask) atol(szParams[0]);
|
||
}
|
||
|
||
static void fn_vInitNodeModelRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
fn_vLinkWithLinkTable(&g_stModelLinkTable, fn_szGetFamiliesDataPath(), szParams[0],p_stNode,E_ti_ModelRef,(unsigned char) atol(szParams[1]));
|
||
}
|
||
|
||
/*ANNECY CT 22/01/98 {*/
|
||
static void fn_vInitNodeLight(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
char a255_csCompleteSectionName [255];
|
||
strcpy(a255_csCompleteSectionName,fn_szGetLevelsDataPath());
|
||
strcat(a255_csCompleteSectionName,"\\");
|
||
strcat(a255_csCompleteSectionName,szParams[0]);
|
||
M_lKeyLinkInterpret(p_stNode) =
|
||
SCR_fnp_st_Link_CreateOrGetLinkFromKey(&gs_stLightLinkTable,a255_csCompleteSectionName)->ulValue;
|
||
}
|
||
/*ENDANNECY CT}*/
|
||
|
||
/*ANNECY Bart 02/02/98 {*/
|
||
static void fn_vInitNodeCaps(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
char* dummy;
|
||
M_ulCapsInterpret(p_stNode) = (unsigned long) strtoul(szParams[0], &dummy, 2);
|
||
}
|
||
|
||
/* ANNECY MT - 25/09/98 {*/
|
||
static void fn_vInitNodeGraph(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
char szForScript[256];
|
||
|
||
sprintf(szForScript, "%s\\%s\\%s.%s^%s:%s", fn_szGetLevelsDataPath(), fn_p_szGetLevelName(), fn_p_szGetLevelName(), C_ScriptWayPointSuffixe, C_SectionWPGraphDescription, szParams[0]);
|
||
M_lKeyLinkInterpret(p_stNode) = (long)SCR_fnp_st_Link_CreateOrGetLinkFromKey(WPG_fnp_Graph_GetLinkTable(),szForScript);
|
||
}
|
||
/* END ANNECY MT }*/
|
||
/*ENDANNECY Bart }*/
|
||
|
||
#define M_GET_AI_DEFINES_DATA_PATH fn_szGetFamiliesDataPath()
|
||
static void fn_vInitNodeConstantRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
SCR_tdst_Link_Value *p_stLinkValue;
|
||
|
||
sprintf(szForScript,"%s\\%s",M_GET_AI_DEFINES_DATA_PATH,szParams[0]);
|
||
p_stLinkValue= SCR_fnp_st_Link_SearchKey(&g_stDefinesLinkTable,szForScript);
|
||
M_TestNodeInterpret(p_stLoadedMind,p_stLinkValue,"Constant Ref",szParams[0],UnknownNode);
|
||
|
||
if (p_stLinkValue!=NULL)
|
||
M_lValueInterpret(p_stNode)=SCR_M_ul_Link_GetValue(p_stLinkValue);
|
||
}
|
||
|
||
static void fn_vInitNodeRealRef(tdstNodeInterpret *p_stNode,char *szParams[])
|
||
{
|
||
SCR_tdst_Link_Value *p_stLinkValue;
|
||
|
||
sprintf(szForScript,"%s\\%s",M_GET_AI_DEFINES_DATA_PATH,szParams[0]);
|
||
p_stLinkValue = SCR_fnp_st_Link_SearchKey(&g_stDefinesLinkTable,szForScript);
|
||
M_TestNodeInterpret(p_stLoadedMind,p_stLinkValue,"Real Ref",szParams[0],UnknownNode);
|
||
|
||
if (p_stLinkValue!=NULL)
|
||
M_lValueInterpret(p_stNode)=SCR_M_ul_Link_GetValue(p_stLinkValue);
|
||
}
|
||
#endif /*U64*/
|
||
|
||
#if !defined(U64)
|
||
SCR_tde_Anl_ReturnValue fn_eCreateRule(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
static char cIsCRR = 0;
|
||
char *psz_Temp;
|
||
char szErrorString[100];
|
||
p_stFile=p_stFile;/* for lint*/
|
||
|
||
/* Determin if it's a CRR */
|
||
psz_Temp = strrchr(p_stFile->a_szFileName, '.');
|
||
if(psz_Temp && !strcmpi(psz_Temp, ".crr"))
|
||
cIsCRR = 1;
|
||
else
|
||
cIsCRR = 0;
|
||
|
||
if (cIsCRR || (ucInComportSection==TRUE))
|
||
{
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
|
||
ucInRuleSection=TRUE;
|
||
|
||
/* plus 1 for adding a dummy node at the end of the tree*/
|
||
ScriptCounter.uwNbNode=(unsigned short) (atoi(szParams[1])+1);
|
||
StructCounter.uwNbNode=0;
|
||
|
||
if (cIsCRR || (StructCounter.ucNbRules < ScriptCounter.ucNbRules))
|
||
{
|
||
/* allocate nodes */
|
||
p_stLoadedNode=fn_p_stAllocNodeInterpret(ScriptCounter.uwNbNode);
|
||
if(cIsCRR)
|
||
{
|
||
p_stLoadedMind->p_stAIModel->CFast_dst_RefTreeArray = p_stLoadedNode;
|
||
p_stLoadedMind->p_stAIModel->uwNbNode = ScriptCounter.uwNbNode;
|
||
}
|
||
else
|
||
{
|
||
M_GetNodeInterpret(p_stLoadedRule)=p_stLoadedNode;
|
||
M_SetNbNodeInterpret(p_stLoadedRule,ScriptCounter.uwNbNode);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
/* error : bad number of rule*/
|
||
sprintf(szErrorString,"Number of rules in this comport (comport n. %d) should be (%d)\n", StructCounter.ulNbComport, ScriptCounter.ucNbRules);
|
||
M_AIFatalErrorMsg(E_uwAIFatalBadRuleNumber,szErrorString);
|
||
}
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection)
|
||
{
|
||
if(!cIsCRR)
|
||
{
|
||
/* add a dummy node at the end of the tree*/
|
||
fn_vInitNodeInterpret( M_GetNodeInterpretN(p_stLoadedRule,StructCounter.uwNbNode), 0, E_ti_EndTree, 0);
|
||
StructCounter.uwNbNode++;
|
||
|
||
if (ScriptCounter.uwNbNode!=StructCounter.uwNbNode)
|
||
{
|
||
sprintf(szErrorString,"Number of nodes in this rule (rule %d comport n. %d) should be (%d)\n",StructCounter.ucNbRules, StructCounter.ulNbComport,ScriptCounter.uwNbNode);
|
||
M_AIFatalErrorMsg(E_uwAIFatalBadNodeNumber,szErrorString);
|
||
}
|
||
|
||
/* hyper important*/
|
||
StructCounter.ucNbRules++;
|
||
p_stLoadedRule= M_GetComportRuleN(p_stLoadedComport,StructCounter.ucNbRules);
|
||
}
|
||
else
|
||
{
|
||
fn_vInitNodeInterpret( p_stLoadedMind->p_stAIModel->CFast_dst_RefTreeArray+StructCounter.uwNbNode, 0, E_ti_EndTree, 0);
|
||
}
|
||
|
||
ucInRuleSection=FALSE;
|
||
}
|
||
else
|
||
{
|
||
unsigned char ucDepth=0;
|
||
|
||
if (szParams[1]!=NULL)
|
||
{
|
||
ucDepth=(unsigned char) atol(szParams[1]);
|
||
}
|
||
else
|
||
{
|
||
sprintf(szErrorString,"Depth undefined (node %d comport n. %d)\n",StructCounter.uwNbNode, StructCounter.ulNbComport);
|
||
M_AIFatalErrorMsg(E_uwAIFatalUnknownNode,szErrorString);
|
||
}
|
||
|
||
if (StructCounter.uwNbNode < ScriptCounter.uwNbNode)
|
||
{
|
||
if(cIsCRR)
|
||
fn_vConvertAndInitNode(szAction, szParams, p_stLoadedMind->p_stAIModel->CFast_dst_RefTreeArray + StructCounter.uwNbNode, ucDepth);
|
||
else
|
||
fn_vConvertAndInitNode(szAction, szParams, M_GetNodeInterpretN(p_stLoadedRule,StructCounter.uwNbNode), ucDepth);
|
||
StructCounter.uwNbNode++;
|
||
}
|
||
else
|
||
{
|
||
M_AIFatalError(E_uwAIFatalBadNodeNumber);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
/*error : CreateRule not in CreateComport*/
|
||
M_AIFatalError(E_uwAIFatalRuleNotInComport);
|
||
}
|
||
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
SCR_tde_Anl_ReturnValue fn_eCreateSchedule(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
char szErrorString[100];
|
||
p_stFile=p_stFile;/* for lint*/
|
||
|
||
if (ucInComportSection==TRUE)
|
||
{
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
ucInRuleSection=TRUE;
|
||
|
||
/* plus 1 for adding a dummy node at the end of the tree*/
|
||
ScriptCounter.uwNbNode=(unsigned short) (atoi(szParams[1])+1);
|
||
StructCounter.uwNbNode=0;
|
||
|
||
/* allocate schedule*/
|
||
p_stLoadedSchedule=fn_p_stAllocSchedule(ScriptCounter.uwNbNode);
|
||
|
||
/* connect schedule to comport*/
|
||
M_GetComportSchedule(p_stLoadedComport)=p_stLoadedSchedule;
|
||
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection)
|
||
{
|
||
/* add a dummy node at the end of the tree*/
|
||
fn_vInitNodeInterpret( M_GetNodeInterpretN(p_stLoadedSchedule,StructCounter.uwNbNode),
|
||
0, E_ti_EndTree, 0);
|
||
|
||
StructCounter.uwNbNode++;
|
||
|
||
if (ScriptCounter.uwNbNode!=StructCounter.uwNbNode)
|
||
{
|
||
sprintf(szErrorString,"Number of nodes in this schedule (comport n. %d) should be (%d)\n", StructCounter.ulNbComport,ScriptCounter.uwNbNode);
|
||
M_AIFatalErrorMsg(E_uwAIFatalBadNodeNumber,szErrorString);
|
||
}
|
||
ucInRuleSection=FALSE;
|
||
}
|
||
else
|
||
{
|
||
unsigned char ucDepth=0;
|
||
|
||
if (szParams[1]!=NULL)
|
||
{
|
||
ucDepth=(unsigned char) atol(szParams[1]);
|
||
}
|
||
else
|
||
{
|
||
sprintf(szErrorString,"Depth undefined (node %d schedule comport n. %d)\n",StructCounter.uwNbNode, StructCounter.ulNbComport);
|
||
M_AIFatalErrorMsg(E_uwAIFatalUnknownNode,szErrorString);
|
||
}
|
||
|
||
if (StructCounter.uwNbNode < ScriptCounter.uwNbNode)
|
||
{
|
||
fn_vConvertAndInitNode(szAction,
|
||
szParams,
|
||
M_GetNodeInterpretN(p_stLoadedSchedule,StructCounter.uwNbNode),
|
||
ucDepth);
|
||
StructCounter.uwNbNode++;
|
||
}
|
||
else
|
||
{
|
||
sprintf(szErrorString,"Number of nodes in this schedule (schedule comport n. %d) should be (%d)\n", StructCounter.ulNbComport,ScriptCounter.uwNbNode);
|
||
M_AIFatalErrorMsg(E_uwAIFatalBadNodeNumber,szErrorString);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
/*error : CreateRule not in CreateComport*/
|
||
sprintf(szErrorString,"Problem (schedule comport n. %d)\n", StructCounter.ulNbComport);
|
||
M_AIFatalErrorMsg(E_uwAIFatalRuleNotInComport,szErrorString);
|
||
}
|
||
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
SCR_tde_Anl_ReturnValue fn_eCreateComport(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
char szForScript[256];
|
||
char szErrorString[100];
|
||
p_stFile = p_stFile;/* for lint*/
|
||
|
||
szAction=szAction;
|
||
|
||
if (ucInIntelligenceSection==TRUE)
|
||
{
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
VIG_fn_vAddToProgressBar(1);
|
||
ucInComportSection=TRUE;
|
||
|
||
/* Nb Rules in this comport*/
|
||
if (szParams[1] != NULL)
|
||
ScriptCounter.ucNbRules=(unsigned char) atoi(szParams[1]);
|
||
else
|
||
ScriptCounter.ucNbRules=(unsigned char) atoi(szParams[0]);
|
||
StructCounter.ucNbRules=0;
|
||
if (StructCounter.ulNbComport < ScriptCounter.ulNbComport)
|
||
{
|
||
p_stLoadedComport=M_GetScriptAIComportN(p_stLoadedScriptAI, StructCounter.ulNbComport);
|
||
|
||
SCR_M_RdL0_ComputeOpenSectionNameR(0,szForScript);
|
||
SCR_M_v_Link_SetAdditionalLong(
|
||
SCR_fnp_st_Link_SetValue(&g_stComportLinkTable, szForScript, (unsigned long)p_stLoadedComport),
|
||
1,
|
||
strlen(szForScript)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0))
|
||
);
|
||
|
||
if (M_GetComportRules(p_stLoadedComport) == NULL)
|
||
{
|
||
#ifndef ACTIVE_EDITOR
|
||
if(p_stLoadedMind->p_stAIModel->CFast_bIsC == 2)
|
||
{
|
||
p_stLoadedRule = NULL;
|
||
ScriptCounter.ucNbRules = 0;
|
||
}
|
||
else
|
||
#endif
|
||
p_stLoadedRule = fn_p_stAllocRule(ScriptCounter.ucNbRules);
|
||
|
||
M_GetComportRules(p_stLoadedComport) = p_stLoadedRule;
|
||
M_GetComportNbRules(p_stLoadedComport) = ScriptCounter.ucNbRules;
|
||
#if defined(__DEBUG_AI__)
|
||
strcpy(M_GetNameComport(p_stLoadedComport), SCR_M_RdL0_GetCompleteSectionNameR(0));
|
||
#endif
|
||
}
|
||
else
|
||
{
|
||
/*error : CreateComport(n) n is bad : already initialized*/
|
||
sprintf(szErrorString,"Problem (comport n. %d : %s)\n", StructCounter.ulNbComport, szAction);
|
||
M_AIFatalErrorMsg(E_uwAIFatalBadComportNumber,szErrorString);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
/*error : CreateIntelligence(n) n is bad : too much comport*/
|
||
sprintf(szErrorString,"Problem (comport n. %d : %s)\n", StructCounter.ulNbComport, szAction);
|
||
M_AIFatalErrorMsg(E_uwAIFatalBadComportNumber,szErrorString);
|
||
}
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection)
|
||
{
|
||
if (ScriptCounter.ucNbRules!=StructCounter.ucNbRules)
|
||
{
|
||
sprintf(szErrorString,"Number of rules in this comport (comport n. %d : %s) should be (%d)\n", StructCounter.ulNbComport, szAction, ScriptCounter.ucNbRules);
|
||
M_AIFatalErrorMsg(E_uwAIFatalBadRuleNumber,szErrorString);
|
||
}
|
||
|
||
StructCounter.ulNbComport++;
|
||
|
||
ucInComportSection=FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
/*error : CreateComport not in CreateIntelligence*/
|
||
M_AIFatalError(E_uwAIFatalComportNotInIntelligence);
|
||
}
|
||
|
||
#ifndef ACTIVE_EDITOR
|
||
if(p_stLoadedMind->p_stAIModel->CFast_bIsC == 2)
|
||
{
|
||
StructCounter.ulNbComport++;
|
||
ucInComportSection=FALSE;
|
||
return SCR_ERV_Anl_TerminateCurrentSection;
|
||
}
|
||
#endif
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
SCR_tde_Anl_ReturnValue fn_eCreateScriptAI(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
p_stFile = p_stFile;/* for lint*/
|
||
|
||
szAction=szAction;
|
||
|
||
if (eType == SCR_EA_Anl_AlreadyAnalysed)
|
||
{
|
||
SCR_M_RdL0_GetSectionLong(0, 0, tdstScriptAI*, p_stLoadedScriptAI);
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
else if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
unsigned char ucActionTableNbEntry=DEFAULT_ACTION_TABLE_NB_ENTRIES;
|
||
unsigned long ulNoComportInitDefault=0;
|
||
|
||
ucInIntelligenceSection=TRUE;
|
||
|
||
/* optional parameter in script*/
|
||
if (szParams[1]!=NULL)
|
||
{
|
||
ucActionTableNbEntry=(unsigned char) atoi(szParams[1]);
|
||
if (ucActionTableNbEntry<MIN_ACTION_TABLE_NB_ENTRIES)
|
||
{
|
||
ucActionTableNbEntry=MIN_ACTION_TABLE_NB_ENTRIES;
|
||
}
|
||
}
|
||
|
||
/* optionnal parameter in script : comportement initial*/
|
||
/* une grosse bidouille : on stocke ce qui est retourn<72> par SCR_fnp_st_Link_CreateOrGetLinkFromKey gr<67>ce <20> M_GetScriptAINoComportInitDefault*/
|
||
/* attention <20> la deuxi<78>me passe dans AI_PROTO.C*/
|
||
if ( (szParams[1]!=NULL) && (szParams[2]!=NULL) )
|
||
{
|
||
char szForScript[_MAX_PATH];
|
||
SCR_tdst_Link_Value *p_stLinkValue;
|
||
|
||
strcpy(szForScript,fn_szGetFamiliesDataPath());
|
||
strcat(szForScript,"\\");
|
||
|
||
SCR_fn_v_RdL0_ComputeSectionName(szForScript+strlen(szForScript), SCR_M_RdL0_GetCompleteSectionNameR(0), "CreateComport", szParams[2]);
|
||
|
||
p_stLinkValue = SCR_fnp_st_Link_CreateOrGetLinkFromKey(&g_stComportLinkTable, szForScript);
|
||
SCR_M_v_Link_SetAdditionalLong(p_stLinkValue, 4, 0);
|
||
ulNoComportInitDefault = (unsigned long) p_stLinkValue;
|
||
}
|
||
|
||
ScriptCounter.ulNbComport=(unsigned long) atoi(szParams[0]);
|
||
StructCounter.ulNbComport=0;
|
||
|
||
if (ScriptCounter.ulNbComport!=0)
|
||
{
|
||
/* alloc script AI*/
|
||
p_stLoadedScriptAI=fn_p_stAllocScriptAI(ucActionTableNbEntry);
|
||
|
||
p_stLoadedComport=fn_p_stAllocComport(ScriptCounter.ulNbComport);
|
||
M_GetScriptAIComport(p_stLoadedScriptAI)=p_stLoadedComport;
|
||
M_GetScriptAINbComport(p_stLoadedScriptAI)=ScriptCounter.ulNbComport;
|
||
M_GetScriptAINoComportInitDefault(p_stLoadedScriptAI)=ulNoComportInitDefault;
|
||
}
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection)
|
||
{
|
||
if (ScriptCounter.ulNbComport!=StructCounter.ulNbComport)
|
||
{
|
||
M_AIFatalError(E_uwAIFatalBadComportNumber);
|
||
}
|
||
SCR_M_RdL0_SetSectionLong(0, 0, (unsigned long)p_stLoadedScriptAI);
|
||
|
||
ucInIntelligenceSection=FALSE;
|
||
}
|
||
else if (M_IsScriptAIReference(szAction))
|
||
{
|
||
(void)SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal); /* (void) for lint.*/
|
||
}
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
#endif /* U64 */
|
||
|
||
|
||
#if !defined(U64)
|
||
unsigned long ulBeginOffset=0; /* For pointer alignement*/
|
||
unsigned long ulEndOffset=0;
|
||
char ucNbWord = 0;
|
||
short *p_wWordMem = NULL;
|
||
short *p_wWordMemInit = NULL;
|
||
|
||
|
||
void fn_vInitDsgVarValue(void *p_MyVarAddr,tdeDsgVarTypeId eDsgVarTypeId,char * szParams[]);
|
||
|
||
SCR_tde_Anl_ReturnValue fn_eCreateVariables(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
#if defined(__DEBUG_AI__)
|
||
char szErrorString[200];
|
||
#endif
|
||
|
||
p_stFile = p_stFile;/* for lint*/
|
||
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
fn_vAllocVariableDesigner(p_stLoadedMind,(unsigned long) atoi(szParams[0]),(unsigned char) atoi(szParams[1]));
|
||
ulBeginOffset=0;
|
||
ucNbWord = 0;
|
||
p_wWordMemInit = p_wWordMem = (short *)malloc(2 * ((unsigned long) atoi(szParams[0])));
|
||
ulEndOffset=(unsigned long) atoi(szParams[0]);
|
||
}
|
||
else if (eType == SCR_EA_Anl_Entry)
|
||
{
|
||
unsigned char ucVarId= (unsigned char) atoi(szParams[0]);
|
||
|
||
if (M_IsTypeSaveVariable(szAction))
|
||
{
|
||
#if defined(__DEBUG_AI__)
|
||
if (ucVarId>=M_GetNbDsgVar(p_stLoadedMind))
|
||
{
|
||
sprintf(szErrorString,"Too many variables defined in %s .DEC (cf variable number %d,%s)\n",AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szParams[1]);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
M_GetDsgVarSaveType(p_stLoadedMind,ucVarId) = fn_eFindSaveTypeFromScriptName(szParams[1], AI_M_szGetPersoName(p_stLoadedMind), ucVarId );
|
||
}
|
||
else if (M_IsTypeInitVariable(szAction))
|
||
{
|
||
#if defined(__DEBUG_AI__)
|
||
if (ucVarId>=M_GetNbDsgVar(p_stLoadedMind))
|
||
{
|
||
sprintf(szErrorString,"Too many variables defined in %s .DEC (cf variable number %d,%s)\n",AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szParams[1]);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
M_GetDsgVarInitType(p_stLoadedMind,ucVarId)=fn_eFindInitTypeFromScriptName(szParams[1]);
|
||
}
|
||
else
|
||
{
|
||
tdeDsgVarTypeId eDsgVarTypeId=fn_eFindDsgVarTypeIdFromScriptName(szAction);
|
||
if (!M_IsDsgVarTypeIdValid(eDsgVarTypeId))
|
||
{
|
||
M_AIFatalError(E_uwAIFatalWrongTypeVar);
|
||
}
|
||
|
||
/* element of an array*/
|
||
if (szParams[1][0]=='@')
|
||
{
|
||
unsigned char ucIndex=(unsigned char) atoi(szParams[0]);
|
||
char szDecFilenameSection[300];
|
||
tdstEngineObject *p_stEngineObject=p_stLoadedEngineObject;
|
||
SCR_tdst_Link_Value *p_stLinkValue=NULL;
|
||
|
||
char *szName=&szParams[1][1]; /* to delete @*/
|
||
|
||
tdeDsgVarTypeId eDsgVarTypeId=fn_eFindDsgVarTypeIdFromScriptName(szAction);
|
||
if (!M_IsDsgVarTypeIdValid(eDsgVarTypeId))
|
||
{
|
||
M_AIFatalError(E_uwAIFatalWrongTypeVar);
|
||
}
|
||
|
||
/* build .dec section*/
|
||
sprintf(szDecFilenameSection,"%s\\%s\\%s\\%s.dec^%s:%s",
|
||
fn_szGetFamiliesDataPath(),
|
||
fn_szFindFamilyTypeNameOfFamilyType(M_ObjectGetFamilyType(p_stLoadedEngineObject)),
|
||
fn_szFindModelTypeNameOfModelType(M_ObjectGetModelType(p_stLoadedEngineObject)),
|
||
fn_szFindModelTypeNameOfModelType(M_ObjectGetModelType(p_stLoadedEngineObject)),
|
||
C_CreateVariables_String,
|
||
szName
|
||
);
|
||
|
||
/* is name known*/
|
||
p_stLinkValue = SCR_fnp_st_Link_SearchKey(&g_stDsgVarLinkTable,szDecFilenameSection);
|
||
if (p_stLinkValue!=NULL)
|
||
{
|
||
/* VarId in bounds*/
|
||
ucVarId=(unsigned char) SCR_M_ul_Link_GetValue(p_stLinkValue);
|
||
if (ucVarId<M_GetNbDsgVar(p_stLoadedMind))
|
||
{
|
||
/* it's an array*/
|
||
if (fn_GetDsgVarType(M_GetDsgVarType(p_stLoadedMind,ucVarId))==E_vt_Array)
|
||
{
|
||
/* of the good type*/
|
||
tdstArray *p_stArray=(tdstArray*) M_GetDsgVarAddrDefault(p_stLoadedMind,ucVarId);
|
||
if (eDsgVarTypeId==M_ARRAY_TYPE(p_stArray))
|
||
{
|
||
/* good index*/
|
||
if (ucIndex<M_ARRAY_SIZE(p_stArray))
|
||
{
|
||
char *p_MyVarAddr=(char*) M_ARRAY_ELEMENT(p_stArray,ucIndex);
|
||
fn_vInitDsgVarValue(p_MyVarAddr,eDsgVarTypeId,szParams);
|
||
}
|
||
#if defined(__DEBUG_AI__)
|
||
else /* element out of bounds*/
|
||
{
|
||
sprintf(szErrorString,"Can't define element %d in %s .DEC (cf variable number %d,%s)\n",ucIndex,AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szName);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
}
|
||
#if defined(__DEBUG_AI__)
|
||
else /* bad type of element for array*/
|
||
{
|
||
sprintf(szErrorString,"Bad type between an array and element %d in %s .DEC (cf variable number %d,%s)\n",ucIndex,AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szName);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
}
|
||
#if defined(__DEBUG_AI__)
|
||
else /* not an array*/
|
||
{
|
||
sprintf(szErrorString,"Not an array in %s .DEC (cf variable number %d,%s)\n",AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szName);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
}
|
||
#if defined(__DEBUG_AI__)
|
||
else /* out of bounds ucVarId*/
|
||
{
|
||
sprintf(szErrorString,"Too many variables defined in %s .DEC (cf variable number %d,%s)\n",AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szName);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
}
|
||
#if defined(__DEBUG_AI__)
|
||
else /* unknown variable*/
|
||
{
|
||
sprintf(szErrorString,"Unknown variable used in %s .DEC (cf variable number %d,%s)\n",AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szName);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
}
|
||
else /* insert DsgVar Name in link table and initialize it*/
|
||
{
|
||
|
||
int lLen;
|
||
|
||
tdeDsgVarTypeId eDsgVarTypeId=fn_eFindDsgVarTypeIdFromScriptName(szAction);
|
||
if (!M_IsDsgVarTypeIdValid(eDsgVarTypeId))
|
||
{
|
||
M_AIFatalError(E_uwAIFatalWrongTypeVar);
|
||
}
|
||
|
||
#if defined(__DEBUG_AI__)
|
||
if (ucVarId>=M_GetNbDsgVar(p_stLoadedMind))
|
||
{
|
||
sprintf(szErrorString,"Too many variables defined in %s .DEC (cf variable number %d,%s)\n",AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szParams[1]);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
|
||
/* Gamedata\World\Level\_Common\Families\NewEd\NewEd1\NewEd1.dec^CreateVariables*/
|
||
SCR_M_RdL0_ComputeOpenSectionNameR(0,szForScript);
|
||
/* NewEd\NewEd1\NewEd1.dec^CreateVariables*/
|
||
lLen=strlen(szForScript)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0));
|
||
|
||
/* add :DsgVarName*/
|
||
strcat(szForScript,":");
|
||
strcat(szForScript,szParams[1]);
|
||
|
||
SCR_M_v_Link_SetAdditionalLong(
|
||
SCR_fnp_st_Link_SetValue(&g_stDsgVarLinkTable, szForScript, (unsigned long)ucVarId),
|
||
1,
|
||
lLen
|
||
);
|
||
|
||
M_SetDsgVarName(p_stLoadedMind,ucVarId,szParams[1])
|
||
|
||
switch (eDsgVarTypeId)
|
||
{
|
||
case eDsgVarType_WayPoint :
|
||
case eDsgVarType_Perso :
|
||
case eDsgVarType_Action :
|
||
case eDsgVarType_Comport :
|
||
case eDsgVarType_Float :
|
||
case eDsgVarType_Text:
|
||
case eDsgVarType_Vector :
|
||
case eDsgVarType_List :
|
||
case eDsgVarType_GameMaterial :
|
||
case eDsgVarType_PersoArray:
|
||
case eDsgVarType_VectorArray:
|
||
case eDsgVarType_FloatArray:
|
||
case eDsgVarType_IntegerArray:
|
||
case eDsgVarType_WayPointArray:
|
||
case eDsgVarType_Graph:
|
||
case eDsgVarType_Caps:
|
||
case eDsgVarType_TextArray:
|
||
case eDsgVarType_Integer:
|
||
case eDsgVarType_PositiveInteger:
|
||
{
|
||
M_GetDsgVarOffset(p_stLoadedMind,ucVarId)=ulBeginOffset;
|
||
/* CAUTION : fn_vInitDsgVarDefault and not fn_vInitDsgVarInit nor fn_vInitDsgVar */
|
||
fn_vInitDsgVarDefault(p_stLoadedMind,ucVarId,eDsgVarTypeId,szParams);
|
||
|
||
if (szParams[2] == NULL)
|
||
ulBeginOffset+=fn_ulSizeOfDsgVar(eDsgVarTypeId, 0);
|
||
else
|
||
ulBeginOffset+=fn_ulSizeOfDsgVar(eDsgVarTypeId,(unsigned char) atoi(szParams[2]));
|
||
|
||
/* check buffer overflow*/
|
||
#if defined(__DEBUG_AI__)
|
||
if (ulBeginOffset>M_GetDsgVarSize(p_stLoadedMind))
|
||
{
|
||
sprintf(szErrorString,"Allocated buffer for DsgMem is too small in %s .DEC (cf variable number %d,%s)\n",AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szParams[1]);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
}
|
||
break;
|
||
case eDsgVarType_0To65535 :
|
||
case eDsgVarType__32768To32767 :
|
||
{
|
||
M_GetDsgVarType(p_stLoadedMind,ucVarId)=eDsgVarTypeId;
|
||
*p_wWordMem++ = ucVarId;
|
||
switch (eDsgVarTypeId)
|
||
{
|
||
case eDsgVarType__32768To32767:
|
||
*p_wWordMem++ = (C_TypeOf_32768To32767) atoi(szParams[2]);
|
||
break;
|
||
case eDsgVarType_0To65535:
|
||
*p_wWordMem++ = (C_TypeOf0To65535) atoi(szParams[2]);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
ucNbWord++;
|
||
}
|
||
break;
|
||
default :
|
||
{
|
||
if (szParams[2] == NULL)
|
||
ulEndOffset-=fn_ulSizeOfDsgVar(eDsgVarTypeId, 0);
|
||
else
|
||
ulEndOffset-=fn_ulSizeOfDsgVar(eDsgVarTypeId,(unsigned char) atoi(szParams[2]));
|
||
|
||
/* check buffer overflow*/
|
||
#if defined(__DEBUG_AI__)
|
||
if (ulEndOffset<0)
|
||
{
|
||
sprintf(szErrorString,"Allocated buffer for DsgMem is too small in %s .DEC (cf variable number %d,%s)\n",AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szParams[1]);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
M_GetDsgVarOffset(p_stLoadedMind,ucVarId)=ulEndOffset;
|
||
/* CAUTION : fn_vInitDsgVarDefault and not fn_vInitDsgVarInit nor fn_vInitDsgVar */
|
||
fn_vInitDsgVarDefault(p_stLoadedMind,ucVarId,eDsgVarTypeId,szParams);
|
||
}
|
||
break;
|
||
} /* Switch*/
|
||
}
|
||
}
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection)
|
||
{
|
||
long ii=0;
|
||
unsigned char ucVarIdWord;
|
||
|
||
if (ucNbWord)
|
||
{
|
||
p_wWordMem = p_wWordMemInit;
|
||
for (ii=0; ii<ucNbWord; ii++)
|
||
{
|
||
ucVarIdWord = (unsigned char)*p_wWordMem++;
|
||
M_GetDsgVarOffset(p_stLoadedMind,ucVarIdWord)=ulBeginOffset;
|
||
ulBeginOffset+=2;
|
||
*(short *)M_GetDsgVarAddr(p_stLoadedMind,ucVarIdWord) = *p_wWordMem++;
|
||
}
|
||
}
|
||
free(p_wWordMemInit);
|
||
#if defined(__DEBUG_AI__)
|
||
if /*(ulEndOffset != ulBeginOffset)*/ (ulBeginOffset>ulEndOffset)
|
||
{
|
||
sprintf(szErrorString,"Allocated buffer for DsgMem corrupted in %s .DEC\n",AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szErrorString);
|
||
}
|
||
#endif
|
||
}
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
|
||
char cErrorInInitVariablesDetected = 0;
|
||
|
||
SCR_tde_Anl_ReturnValue fn_eInitVariables(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
p_stFile = p_stFile;/* for lint*/
|
||
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
/* variables have not been allocated*/
|
||
if (
|
||
(p_stLoadedMind==NULL)
|
||
|| (AI_M_p_stGetDsgVar(p_stLoadedMind)==NULL)
|
||
|| (AI_M_p_stGetDsgMem(p_stLoadedMind)==NULL)
|
||
|| (M_GetDsgMemBufferInit(p_stLoadedMind)!=NULL)
|
||
)
|
||
{
|
||
#if defined(ACTIVE_1STPASS_CHECKING) || defined(__DEBUG_AI__)
|
||
M_TestNodeInterpret(p_stLoadedMind,0,"This perso has no dsgvar anymore, so corresponding .CAR is an old one","",ScriptError);
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
AI_M_ucErrorFlag(p_stLoadedMind)=2;
|
||
#endif
|
||
#else
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,"This perso has no dsgvar anymore, so corresponding .CAR is an old one");
|
||
#endif
|
||
}
|
||
/* not the same sizes as in the .DEC !!!!! ????*/
|
||
else if (
|
||
(M_GetDsgVarSize(p_stLoadedMind)!=(unsigned long) atoi(szParams[0]) )
|
||
||(M_GetNbDsgVar(p_stLoadedMind)!=(unsigned char) atoi(szParams[1]) )
|
||
)
|
||
|
||
{
|
||
/* this is not the correct size*/
|
||
#if defined(__DEBUG_AI__)
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
if(cErrorInInitVariablesDetected == 0)
|
||
{
|
||
cErrorInInitVariablesDetected = 1;
|
||
sprintf(szForErrorStringAt1stPass,"Dsgvar number or size are different in .CAR and .DEC in %s",AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
}
|
||
AI_M_ucErrorFlag(p_stLoadedMind)=1;
|
||
fn_vForceEditor();
|
||
/* M_GetDsgMemBufferInit(p_stLoadedMind)=fn_p_cAllocDsgMemBuffer(M_GetDsgVarSize(p_stLoadedMind));*/
|
||
/* copy it from the model */
|
||
/* memcpy(M_GetDsgMemBufferInit(p_stLoadedMind),M_GetDsgMemDefaultInit(p_stLoadedMind),M_GetDsgVarSize(p_stLoadedMind));*/
|
||
#else
|
||
sprintf(szForErrorStringAt1stPass,"Dsgvar number or size are different in .CAR and .DEC in %s",AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
#endif /* ACTIVE_1STPASS_CHECKING*/
|
||
#else
|
||
/*M_AIFatalErrorMsg(E_uwAIFatalWrongTypeVar,"Dsgvar number or size are different in .CAR and .DEC");*/
|
||
#endif
|
||
}
|
||
/*else*/
|
||
{
|
||
M_GetDsgMemBufferInit(p_stLoadedMind)=fn_p_cAllocDsgMemBuffer(M_GetDsgVarSize(p_stLoadedMind));
|
||
/* copy it from the model */
|
||
memcpy(M_GetDsgMemBufferInit(p_stLoadedMind),M_GetDsgMemDefaultInit(p_stLoadedMind),M_GetDsgVarSize(p_stLoadedMind));
|
||
}
|
||
}
|
||
else if (eType == SCR_EA_Anl_Entry)
|
||
{
|
||
/* si errorflag == 0 ok*/
|
||
/* si errorflag == 1 on peut faire certaines verifs*/
|
||
/* si errorflag == 2 on ne peut rien faire*/
|
||
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
if (AI_M_ucErrorFlag(p_stLoadedMind)!=2)
|
||
#endif
|
||
{
|
||
tdeDsgVarTypeId eDsgVarTypeId=fn_eFindDsgVarTypeIdFromScriptName(szAction);
|
||
unsigned char ucVarId= (unsigned char) atoi(szParams[0]);
|
||
|
||
/* is type known ?*/
|
||
if (M_IsDsgVarTypeIdValid(eDsgVarTypeId))
|
||
{
|
||
char szDecFilenameSection[300];
|
||
tdstEngineObject *p_stEngineObject=p_stLoadedEngineObject;
|
||
SCR_tdst_Link_Value *p_stLinkValue=NULL;
|
||
char cElement=(szParams[1][0]=='@');
|
||
char *szName=&szParams[1][cElement];
|
||
|
||
/* build .dec section*/
|
||
sprintf(szDecFilenameSection,"%s\\%s\\%s\\%s.dec^%s:%s",
|
||
fn_szGetFamiliesDataPath(),
|
||
fn_szFindFamilyTypeNameOfFamilyType(M_ObjectGetFamilyType(p_stLoadedEngineObject)),
|
||
fn_szFindModelTypeNameOfModelType(M_ObjectGetModelType(p_stLoadedEngineObject)),
|
||
fn_szFindModelTypeNameOfModelType(M_ObjectGetModelType(p_stLoadedEngineObject)),
|
||
C_CreateVariables_String,
|
||
szName
|
||
);
|
||
|
||
/* is name known*/
|
||
p_stLinkValue = SCR_fnp_st_Link_SearchKey(&g_stDsgVarLinkTable,szDecFilenameSection);
|
||
if (p_stLinkValue!=NULL)
|
||
{
|
||
ucVarId=(unsigned char) SCR_M_ul_Link_GetValue(p_stLinkValue);
|
||
if (ucVarId<M_GetNbDsgVar(p_stLoadedMind))
|
||
{
|
||
/* for array*/
|
||
if (cElement)
|
||
{
|
||
unsigned char ucIndex=(unsigned char) atoi(szParams[0]);
|
||
if (fn_GetDsgVarType(M_GetDsgVarType(p_stLoadedMind,ucVarId))==E_vt_Array)
|
||
{
|
||
/* of the good type*/
|
||
tdstArray *p_stArray=(tdstArray*) M_GetDsgVarAddrInit(p_stLoadedMind,ucVarId);
|
||
if (eDsgVarTypeId==M_ARRAY_TYPE(p_stArray))
|
||
{
|
||
/* good index*/
|
||
if (ucIndex<M_ARRAY_SIZE(p_stArray))
|
||
{
|
||
char *p_MyVarAddr=(char*) M_ARRAY_ELEMENT(p_stArray,ucIndex);
|
||
fn_vInitDsgVarValue(p_MyVarAddr,eDsgVarTypeId,szParams);
|
||
}
|
||
#if defined(__DEBUG_AI__)
|
||
else /* element out of bounds*/
|
||
{
|
||
sprintf(szForErrorStringAt1stPass,"Can't define element %d in %s .DEC (cf variable number %d,%s)\n",ucIndex,AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szName);
|
||
#if defined(ACTIVE_1STPASS_CHECKING) || defined(__DEBUG_AI__)
|
||
M_TestNodeInterpret(p_stLoadedMind,0,szForErrorStringAt1stPass,szName,WrongTypeVar);
|
||
#else
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szForErrorStringAt1stPass);
|
||
#endif
|
||
}
|
||
#endif
|
||
}
|
||
#if defined(__DEBUG_AI__)
|
||
else /* bad type of element for array*/
|
||
{
|
||
sprintf(szForErrorStringAt1stPass,"Bad type between an array and element %d in %s .DEC (cf variable number %d,%s)\n",ucIndex,AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szName);
|
||
#if defined(ACTIVE_1STPASS_CHECKING) || defined(__DEBUG_AI__)
|
||
M_TestNodeInterpret(p_stLoadedMind,0,szForErrorStringAt1stPass,szName,WrongTypeVar);
|
||
#else
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szForErrorStringAt1stPass);
|
||
#endif
|
||
}
|
||
#endif
|
||
}
|
||
#if defined(__DEBUG_AI__)
|
||
else /* not an array*/
|
||
{
|
||
sprintf(szForErrorStringAt1stPass,"Not an array in %s .CAR (cf variable number %d,%s)\n",AI_M_szGetPersoName(p_stLoadedMind),ucVarId,szName);
|
||
#if defined(ACTIVE_1STPASS_CHECKING) || defined(__DEBUG_AI__)
|
||
M_TestNodeInterpret(p_stLoadedMind,0,szForErrorStringAt1stPass,szName,WrongTypeVar);
|
||
#else
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szForErrorStringAt1stPass);
|
||
#endif
|
||
}
|
||
#endif
|
||
}
|
||
else
|
||
{
|
||
if (eDsgVarTypeId==M_GetDsgVarType(p_stLoadedMind,ucVarId))
|
||
{
|
||
|
||
/* CAUTION : fn_vInitDsgVarInit and not fn_vInitDsgVarDefault nor fn_vInitDsgVar */
|
||
fn_vInitDsgVarInit(p_stLoadedMind,ucVarId,eDsgVarTypeId,szParams);
|
||
#if defined(__DEBUG_AI__)
|
||
/* warning if variable remapped*/
|
||
if (ucVarId!=atoi(szParams[0]))
|
||
{
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
if(cErrorInInitVariablesDetected == 0)
|
||
{
|
||
sprintf(szForErrorStringAt1stPass,"Difference in Dsgvar between .CAR and .DEC [DsgVar (%s) No %s remapped to No %d] in %s",szParams[1],szParams[0],ucVarId,AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
cErrorInInitVariablesDetected = 1;
|
||
}
|
||
AI_M_ucErrorFlag(p_stLoadedMind)=1;
|
||
fn_vForceEditor();
|
||
#else
|
||
sprintf(szForErrorStringAt1stPass,"Difference in Dsgvar between .CAR and .DEC [DsgVar (%s) No %s remapped to No %d] in %s",szParams[1],szParams[0],ucVarId,AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
|
||
#endif /* ACTIVE_1STPASS_CHECKING*/
|
||
}
|
||
#endif /* __DEBUG_AI__*/
|
||
}
|
||
else
|
||
{
|
||
/* error : invalid type between .dec and .car*/
|
||
#if defined(ACTIVE_1STPASS_CHECKING) || defined(__DEBUG_AI__)
|
||
M_TestNodeInterpret(p_stLoadedMind,0,"Difference in Dsgvar between .CAR and .DEC [name is ok, type is bad] ",szParams[1],WrongTypeVar);
|
||
#else
|
||
M_AIFatalErrorMsg(E_uwAIFatalWrongTypeVar,"Difference in Dsgvar between .CAR and .DEC [name is ok, type is bad]");
|
||
#endif /* ACTIVE_1STPASS_CHECKING || __DEBUG_AI__*/
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
/* warning unknown variable id*/
|
||
#if defined(__DEBUG_AI__)
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
if(cErrorInInitVariablesDetected == 0)
|
||
{
|
||
sprintf(szForErrorStringAt1stPass,"Difference in Dsgvar between .CAR and .DEC [Unknown DsgVar Id (%s) so dsgvar %s ignored] in %s",szParams[0],szParams[1],AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
cErrorInInitVariablesDetected = 1;
|
||
}
|
||
AI_M_ucErrorFlag(p_stLoadedMind)=1;
|
||
fn_vForceEditor();
|
||
#else
|
||
sprintf(szForErrorStringAt1stPass,"Difference in Dsgvar between .CAR and .DEC [Unknown DsgVar Id (%s) so dsgvar %s ignored] in %s",szParams[0],szParams[1],AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
#endif /* ACTIVE_1STPASS_CHECKING*/
|
||
#endif /* __DEBUG_AI__*/
|
||
}
|
||
}
|
||
else
|
||
{
|
||
/* warning unknown variable name*/
|
||
#if defined(__DEBUG_AI__)
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
if(cErrorInInitVariablesDetected == 0)
|
||
{
|
||
sprintf(szForErrorStringAt1stPass,"Difference in Dsgvar between .CAR and .DEC [Unknown DsgVar name (%s) No %s ignored] in %s",szParams[1],szParams[0],AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
cErrorInInitVariablesDetected = 1;
|
||
}
|
||
AI_M_ucErrorFlag(p_stLoadedMind)=1;
|
||
fn_vForceEditor();
|
||
#else
|
||
sprintf(szForErrorStringAt1stPass,"Difference in Dsgvar between .CAR and .DEC [Unknown DsgVar name (%s) No %s ignored] in %s",szParams[1],szParams[0],AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
#endif /* ACTIVE_1STPASS_CHECKING*/
|
||
#else
|
||
char szForErrorStringAt1stPass[200];
|
||
sprintf(szForErrorStringAt1stPass,"Difference in Dsgvar between .CAR and .DEC [Unknown DsgVar name (%s) No %s ignored] in %s",szParams[1],szParams[0],AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
#endif /* __DEBUG_AI__*/
|
||
}
|
||
}
|
||
else
|
||
{
|
||
/* error unknown variable type*/
|
||
#if defined(ACTIVE_1STPASS_CHECKING) || defined(__DEBUG_AI__)
|
||
if(cErrorInInitVariablesDetected == 0)
|
||
{
|
||
cErrorInInitVariablesDetected = 1;
|
||
M_TestNodeInterpret(p_stLoadedMind,0,"Unknown variable type",szParams[0],WrongTypeVar);
|
||
}
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
AI_M_ucErrorFlag(p_stLoadedMind)=1;
|
||
#endif
|
||
#else
|
||
M_AIFatalErrorMsg(E_uwAIFatalWrongTypeVar,"Unknown variable type");
|
||
#endif /* ACTIVE_1STPASS_CHECKING || __DEBUG_AI__*/
|
||
}
|
||
}
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection)
|
||
{
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
if (AI_M_ucErrorFlag(p_stLoadedMind) == 2)
|
||
#endif
|
||
{
|
||
/* should not happen now because .CAR contains only necessary init data*/
|
||
#if defined(ACTIVE_EDITOR)
|
||
/* because : if M_GetDsgMemBufferInit content == M_GetDsgMemDefaultInit content then free M_GetDsgMemBufferInit */
|
||
if (!memcmp(M_GetDsgMemBufferInit(p_stLoadedMind),M_GetDsgMemDefaultInit(p_stLoadedMind),M_GetDsgVarSize(p_stLoadedMind)))
|
||
{
|
||
fn_vFreeDsgMemBuffer(&(M_GetDsgMemBufferInit(p_stLoadedMind)));
|
||
}
|
||
#endif
|
||
}
|
||
}
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
#endif /* U64 */
|
||
|
||
|
||
|
||
void fn_vInitComportFromScript(tdstIntelligence *p_stIntelligence,char *szParams[])
|
||
{
|
||
#if !defined(U64)
|
||
char szForScript[_MAX_PATH];
|
||
unsigned long ulNoComportInit=0;
|
||
|
||
strcpy(szForScript,fn_szGetFamiliesDataPath());
|
||
strcat(szForScript,"\\");
|
||
|
||
/*for compatibility with old style*/
|
||
/*0,1,2*/
|
||
if((szParams[0]!=NULL) && (szParams[1]!=NULL) && (szParams[2]!=NULL))
|
||
{
|
||
SCR_tdst_Link_Value *p_stLinkValue;
|
||
|
||
SCR_fn_v_RdL0_ComputeSectionName(szForScript+strlen(szForScript), szParams[0],szParams[1], szParams[2]);
|
||
p_stLinkValue = SCR_fnp_st_Link_CreateOrGetLinkFromKey(&g_stComportLinkTable, szForScript);
|
||
SCR_M_v_Link_SetAdditionalLong(p_stLinkValue, 4, 0);
|
||
ulNoComportInit = (unsigned long)p_stLinkValue;
|
||
}
|
||
else
|
||
/*0^1:2*/
|
||
if(szParams[0]!=NULL)
|
||
{
|
||
char szFileName[_MAX_PATH];
|
||
SCR_tdst_Link_Value *p_stLinkValue;
|
||
|
||
fn_v_File_ComputeFileSectionName(szParams[0],szFileName,szForScript+strlen(szForScript));
|
||
|
||
p_stLinkValue = SCR_fnp_st_Link_CreateOrGetLinkFromKey(&g_stComportLinkTable, szForScript);
|
||
SCR_M_v_Link_SetAdditionalLong(p_stLinkValue, 4, 0);
|
||
ulNoComportInit = (unsigned long) p_stLinkValue;
|
||
}
|
||
M_GetNoComportInit(p_stIntelligence)=ulNoComportInit;
|
||
#endif /* U64 */
|
||
}
|
||
|
||
#if !defined(U64)
|
||
|
||
#if (defined(__DEBUG_AI__) && defined(ACTIVE_1STPASS_CHECKING))
|
||
char cErrorInInitComportReflex = 0;
|
||
#endif
|
||
/* sub section in section brain in .car */
|
||
SCR_tde_Anl_ReturnValue fn_eInitComportReflex(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
p_stFile = p_stFile;/* for lint*/
|
||
szAction=szAction;
|
||
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
if(AI_M_p_stGetReflex(p_stLoadedMind))
|
||
fn_vInitComportFromScript(AI_M_p_stGetReflex(p_stLoadedMind),szParams);
|
||
#if defined(__DEBUG_AI__)
|
||
else
|
||
{
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
if(cErrorInInitComportReflex == 0)
|
||
{
|
||
cErrorInInitComportReflex = 1;
|
||
sprintf(szForErrorStringAt1stPass,"There is an initial Reflex in .CAR but no reflex in model in %s",AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
}
|
||
AI_M_ucErrorFlag(p_stLoadedMind)=1;
|
||
fn_vForceEditor();
|
||
#else
|
||
sprintf(szForErrorStringAt1stPass,"There is an initial Reflex in .CAR but no reflex in model in %s",AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
#endif /* ACTIVE_1STPASS_CHECKING*/
|
||
}
|
||
#endif
|
||
}
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
/* sub section in section brain in .car */
|
||
#if (defined(__DEBUG_AI__) && defined(ACTIVE_1STPASS_CHECKING))
|
||
char cErrorInInitComportIntell = 0;
|
||
#endif
|
||
|
||
SCR_tde_Anl_ReturnValue fn_eInitComportIntell(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
p_stFile = p_stFile;/* for lint*/
|
||
szAction=szAction;
|
||
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
if(AI_M_p_stGetIntelligence(p_stLoadedMind))
|
||
{
|
||
fn_vInitComportFromScript(AI_M_p_stGetIntelligence(p_stLoadedMind),szParams);
|
||
}
|
||
#if defined(__DEBUG_AI__)
|
||
else
|
||
{
|
||
#if defined(ACTIVE_1STPASS_CHECKING)
|
||
if(cErrorInInitComportIntell == 0)
|
||
{
|
||
cErrorInInitComportIntell = 1;
|
||
sprintf(szForErrorStringAt1stPass,"There is an initial Comport in .CAR but no Comport in model in %s",AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
}
|
||
AI_M_ucErrorFlag(p_stLoadedMind)=1;
|
||
fn_vForceEditor();
|
||
#else
|
||
sprintf(szForErrorStringAt1stPass,"There is an initial Comport in .CAR but no Comport in model in %s",AI_M_szGetPersoName(p_stLoadedMind));
|
||
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,szForErrorStringAt1stPass);
|
||
#endif /* ACTIVE_1STPASS_CHECKING*/
|
||
}
|
||
#endif
|
||
}
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
#endif /* U64 */
|
||
|
||
|
||
#if defined(__DEBUG_AI__) || defined(ACTIVE_1STPASS_CHECKING)
|
||
void fn_vCheckTree(AI_tdxHandleToMind p_stMind,tdstTreeInterpret *p_stTree)
|
||
{
|
||
unsigned short i;
|
||
unsigned char len=0;
|
||
tdstNodeInterpret *p_stNode;
|
||
tdeProcedureId eProcedureId;
|
||
tdeFuncId eFuncId;
|
||
tdeCondId eCondId;
|
||
tdeMetaActionId eMetaActionId;
|
||
tdeOperatorId eOperatorId;
|
||
|
||
if (p_stTree != NULL)
|
||
{
|
||
for (i = 0; i < M_GetNbNodeInterpret(p_stTree); i++)
|
||
{
|
||
p_stNode = M_GetNodeInterpretN(p_stTree, i);
|
||
|
||
switch (M_GetTypeInterpret(p_stNode))
|
||
{
|
||
case E_ti_Procedure:
|
||
{
|
||
eProcedureId=M_eProcedureIdInterpret(p_stNode++);
|
||
len=(unsigned char) strlen(szGetProcedureTypeInParamFromId(eProcedureId));
|
||
M_TestNodeInterpret(p_stMind,(fn_ucGetTreeNbParam(p_stNode) == len), "Wrong Parameter Number",szFindProcedureScriptNameFromId(eProcedureId),WrongParamAction);
|
||
}
|
||
break;
|
||
|
||
case E_ti_Function:
|
||
{
|
||
eFuncId=M_eFuncIdInterpret(p_stNode++);
|
||
len=(unsigned char) strlen(szGetFunctionTypeInParamFromId(eFuncId));
|
||
M_TestNodeInterpret(p_stMind,(fn_ucGetTreeNbParam(p_stNode) == len), "Wrong Parameter Number",szFindFunctionScriptNameFromId(eFuncId),WrongParamAction);
|
||
}
|
||
break;
|
||
|
||
case E_ti_Condition:
|
||
{
|
||
eCondId=M_eCondIdInterpret(p_stNode++);
|
||
len=(unsigned char) strlen(szGetConditionTypeInParamFromId(eCondId));
|
||
M_TestNodeInterpret(p_stMind,(fn_ucGetTreeNbParam(p_stNode) == len), "Wrong Parameter Number",szFindConditionScriptNameFromId(eCondId),WrongParamAction);
|
||
}
|
||
break;
|
||
|
||
|
||
case E_ti_MetaAction:
|
||
{
|
||
eMetaActionId=M_eMetaActionIdInterpret(p_stNode++);
|
||
len=(unsigned char) strlen(szGetMetaActionTypeInParamFromId(eMetaActionId));
|
||
M_TestNodeInterpret(p_stMind,(fn_ucGetTreeNbParam(p_stNode) == len), "Wrong Parameter Number",szFindMetaActionScriptNameFromId(eMetaActionId),WrongParamAction);
|
||
}
|
||
break;
|
||
|
||
case E_ti_EndTree:
|
||
M_TestNodeInterpret(p_stMind,(i+1 ==M_GetNbNodeInterpret(p_stTree)), "Misplaced end of tree","",UnknownNode);
|
||
break;
|
||
|
||
case E_ti_Operator:
|
||
{
|
||
|
||
eOperatorId=M_eOperatorIdInterpret(p_stNode++);
|
||
switch(eOperatorId)
|
||
{
|
||
case eOperator_Ultra:
|
||
{
|
||
unsigned char Ok=0;
|
||
char szStr[100]="Must be used with a perso";
|
||
char *szPtr=&szStr[0];
|
||
|
||
if (
|
||
(M_GetTypeInterpret(p_stNode)==E_ti_PersoRef)
|
||
/*
|
||
||(
|
||
(M_GetTypeInterpret(p_stNode)==E_ti_Field) &&
|
||
(fn_eGetEngineFieldType(M_eFieldIdInterpret(p_stNode))==eFieldType_Perso)
|
||
)
|
||
*/
|
||
||(
|
||
(M_GetTypeInterpret(p_stNode)==E_ti_KeyWord) &&
|
||
(
|
||
/*(M_eKeyWordIdInterpret(p_stNode)==eKeyWord_World) ||*/
|
||
(M_eKeyWordIdInterpret(p_stNode)==eKeyWord_MainActor) ||
|
||
(M_eKeyWordIdInterpret(p_stNode)==eKeyWord_Me)
|
||
)
|
||
)
|
||
||
|
||
(
|
||
(M_GetTypeInterpret(p_stNode)==E_ti_DsgVar) &&
|
||
(M_GetDsgVarType(p_stMind,(unsigned char) M_ucVarIdInterpret(p_stNode)) ==eDsgVarType_Perso)
|
||
)
|
||
||
|
||
(
|
||
(M_GetTypeInterpret(p_stNode)==E_ti_DsgVarRef)
|
||
)
|
||
)
|
||
|
||
{
|
||
p_stNode++;
|
||
switch (M_GetTypeInterpret(p_stNode))
|
||
{
|
||
case E_ti_Condition:
|
||
{
|
||
eCondId=M_eCondIdInterpret(p_stNode);
|
||
szPtr=szFindConditionScriptNameFromId(eCondId);
|
||
Ok=fn_ucGetConditionUltraOperator(eCondId);
|
||
}
|
||
break;
|
||
|
||
case E_ti_Function:
|
||
{
|
||
eFuncId=M_eFuncIdInterpret(p_stNode);
|
||
szPtr=szFindFunctionScriptNameFromId(eFuncId);
|
||
Ok=fn_ucGetFunctionUltraOperator(eFuncId);
|
||
}
|
||
break;
|
||
|
||
case E_ti_Procedure:
|
||
{
|
||
eProcedureId=M_eProcedureIdInterpret(p_stNode);
|
||
szPtr=szFindProcedureScriptNameFromId(eProcedureId);
|
||
Ok=fn_ucGetProcedureUltraOperator(eProcedureId);
|
||
}
|
||
break;
|
||
default:
|
||
strcpy(szStr,"Only with Conditions,Functions,Procedures");
|
||
break;
|
||
}
|
||
}
|
||
M_TestNodeInterpret(p_stMind,Ok, "Ultra Operator Error",szPtr,InvalidUseOfUltraOperator);
|
||
}
|
||
break;
|
||
}
|
||
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void fn_vCheckScriptAI(AI_tdstMind *p_stMind,tdstScriptAI *p_stScriptAI)
|
||
{
|
||
if (p_stMind!=NULL)
|
||
{
|
||
if (p_stScriptAI!=NULL)
|
||
{
|
||
unsigned long i;
|
||
unsigned char j;
|
||
tdstComport *p_stComport;
|
||
|
||
/* Loop on comport.*/
|
||
for (i = 0; i < M_GetScriptAINbComport(p_stScriptAI); i++)
|
||
{
|
||
p_stComport = M_GetScriptAIComportN(p_stScriptAI, i);
|
||
|
||
/* Second pass on Schedule.*/
|
||
fn_vCheckTree(p_stMind,M_GetComportSchedule(p_stComport));
|
||
|
||
/* Second pass on Rules.*/
|
||
for (j = 0; j < M_GetComportNbRules(p_stComport); j++)
|
||
{
|
||
fn_vCheckTree(p_stMind,M_GetComportRuleN(p_stComport, j));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endif
|
||
|
||
|
||
tdstScriptAI *fn_p_stReadScriptAI(char *szFileName)
|
||
{
|
||
p_stLoadedScriptAI=NULL;
|
||
#if !defined(U64)
|
||
p_stLoadedComport=NULL;
|
||
p_stLoadedRule=NULL;
|
||
p_stLoadedNode=NULL;
|
||
p_stLoadedSchedule=NULL;
|
||
|
||
(void) SCR_fnp_st_RdL0_AnalyseSection(szFileName, SCR_CDF_uw_Anl_Normal); /* (void) for lint.*/
|
||
#if defined(__DEBUG_AI__) || defined(ACTIVE_1STPASS_CHECKING)
|
||
fn_vCheckScriptAI(p_stLoadedMind,p_stLoadedScriptAI);
|
||
#endif
|
||
#endif /* U64 */
|
||
return(p_stLoadedScriptAI);
|
||
}
|
||
|
||
#if !defined(U64)
|
||
SCR_tde_Anl_ReturnValue fn_eCreateAIModel(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
p_stFile=p_stFile;/* for lint*/
|
||
|
||
szAction=szAction;
|
||
|
||
if (eType == SCR_EA_Anl_AlreadyAnalysed)
|
||
{
|
||
SCR_M_RdL0_GetSectionLong(0, 0, AI_tdstAIModel*, p_stLoadedAIModel);
|
||
|
||
/* hyper important*/
|
||
AI_M_SetAIModel(p_stLoadedMind,p_stLoadedAIModel);
|
||
|
||
/* il faut allouer DsgMem si il y a des variables designer */
|
||
if ( AI_M_p_stGetDsgVar(p_stLoadedMind)!=NULL)
|
||
{
|
||
if (M_GetDsgVarSize(p_stLoadedMind)!=0)
|
||
{
|
||
AI_M_p_stGetDsgMem(p_stLoadedMind)=fn_p_stAllocDsgMem(&AI_M_p_stGetDsgVar(p_stLoadedMind),M_GetDsgVarSize(p_stLoadedMind) );
|
||
}
|
||
}
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
else if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
char szForScript[_MAX_PATH]="";
|
||
p_stLoadedAIModel=fn_p_stAllocAIModel();
|
||
SCR_M_RdL0_SetSectionLong(0, 0, (unsigned long)p_stLoadedAIModel);
|
||
/* hyper important */
|
||
AI_M_SetAIModel(p_stLoadedMind,p_stLoadedAIModel);
|
||
|
||
SCR_M_RdL0_ComputeOpenSectionNameR(0,szForScript);
|
||
SCR_M_v_Link_SetAdditionalLong(
|
||
SCR_fnp_st_Link_SetValue(&g_stModelLinkTable, szForScript, (unsigned long)p_stLoadedAIModel),
|
||
1, strlen(szForScript)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)) );
|
||
/* Some inits */
|
||
p_stLoadedMind->p_stAIModel->CFast_bIsC = 0;
|
||
p_stLoadedMind->p_stAIModel->CFast_lFunction = 0;
|
||
}
|
||
else if (eType == SCR_EA_Anl_Entry)
|
||
{
|
||
if (M_IsIntellAIModel(szAction))
|
||
{
|
||
AI_M_p_stGetIntelligenceScriptAIModel(p_stLoadedAIModel)=fn_p_stReadScriptAI(szParams[0]);
|
||
}
|
||
else if (M_IsReflexAIModel(szAction))
|
||
{
|
||
AI_M_p_stGetReflexScriptAIModel(p_stLoadedAIModel)=fn_p_stReadScriptAI(szParams[0]);
|
||
}
|
||
else if (M_IsVariableDeclarationAIModel(szAction))
|
||
{
|
||
/* read .dec*/
|
||
(void) SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal); /* (void) for lint.*/
|
||
}
|
||
else if (M_IsMacroAIModel(szAction))
|
||
{
|
||
SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal);
|
||
}
|
||
else if (!strcmpi(szAction, "CreateRefAIModel"))
|
||
{
|
||
#ifndef ACTIVE_EDITOR
|
||
/* read .crr*/
|
||
if(SCR_fn_c_RdL0_IsSectionExists(szParams[0]))
|
||
{
|
||
SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal);
|
||
}
|
||
#endif
|
||
}
|
||
else if ( !strcmpi(szAction, "CreateRefTree"))
|
||
{
|
||
#ifndef ACTIVE_EDITOR
|
||
/* read .nod*/
|
||
if(SCR_fn_c_RdL0_IsSectionExists(szParams[0]))
|
||
{
|
||
SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal);
|
||
}
|
||
#endif
|
||
}
|
||
/* Read for C run */
|
||
else if (!strcmpi(szAction, "CFast_IsC"))
|
||
{
|
||
p_stLoadedMind->p_stAIModel->CFast_bIsC = (ACP_tdxBool) fn_lAToI(szParams[0]);
|
||
}
|
||
else if (!strcmpi(szAction, "CFast_FunctionIndex"))
|
||
{
|
||
p_stLoadedMind->p_stAIModel->CFast_lFunction = fn_lAToI(szParams[0]);
|
||
}
|
||
else
|
||
{
|
||
M_AIFatalError(E_uwAIFatalBadEntryAIModel);
|
||
}
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection)
|
||
{
|
||
#if defined(ACTIVE_EDITOR)
|
||
p_stLoadedMind->p_stAIModel->CFast_lFunction = 0;
|
||
#endif
|
||
}
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
char szDefineSection[256];
|
||
SCR_tde_Anl_ReturnValue fn_eCreateAIDefines(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType)
|
||
{
|
||
static lLen=0;
|
||
p_stFile=p_stFile;/* for lint*/
|
||
|
||
szAction=szAction;
|
||
|
||
if (eType == SCR_EA_Anl_BeginSection)
|
||
{
|
||
|
||
strcpy(szDefineSection,SCR_M_RdL0_GetCompleteSectionNameR(0));
|
||
/* Gamedata\World\Level\_Common\Families\Defines.ai^CreateAiDefines*/
|
||
SCR_M_RdL0_ComputeOpenSectionNameR(0,szDefineSection);
|
||
|
||
/* Defines.ai^CreateAiDefines*/
|
||
lLen=strlen(szDefineSection)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0));
|
||
|
||
}
|
||
else if (eType == SCR_EA_Anl_Entry) /* work if data size if <= sizeof(long)*/
|
||
{
|
||
unsigned long ulValue=0;
|
||
/*ANNECY CHRISTOPHE MOFICATION CF XAVIER*/
|
||
unsigned long ulType = 0;
|
||
/*ANNECY END CHRISTOPHE MODIFICATIONS CF XAVIER*/
|
||
|
||
szForScript[0]=0;
|
||
|
||
if (M_IsConstantRef(szAction)) /* ConstantRef*/
|
||
{
|
||
long lValue=(long) atoi(szParams[1]);
|
||
ulValue=*((unsigned long*) &lValue);
|
||
sprintf(szForScript,"%s:%s",szDefineSection,szParams[0]);
|
||
|
||
/*ANNECY CHRISTOPHE MOFICATION CF XAVIER*/
|
||
ulType=E_vt_Integer;
|
||
/*ANNECY END CHRISTOPHE MOFICATION CF XAVIER*/
|
||
}
|
||
else if (M_IsRealRef(szAction)) /* RealRef*/
|
||
{
|
||
MTH_tdxReal xReal=MTH_M_xFloatToReal((float) atof(szParams[1]));
|
||
ulValue=*((long*) &xReal);
|
||
sprintf(szForScript,"%s:%s",szDefineSection,szParams[0]);
|
||
|
||
/*ANNECY CHRISTOPHE MOFICATION CF XAVIER*/
|
||
ulType=E_vt_Float;
|
||
/*ANNECY END CHRISTOPHE MOFICATION CF XAVIER*/
|
||
}
|
||
|
||
if (strlen(szForScript)!=0)
|
||
{
|
||
SCR_tdst_Link_Value *p_stLinkValue = SCR_fnp_st_Link_SearchKey(&g_stDefinesLinkTable,szForScript);
|
||
if (p_stLinkValue==NULL)
|
||
{
|
||
p_stLinkValue=SCR_fnp_st_Link_SetValue(&g_stDefinesLinkTable, szForScript, ulValue);
|
||
SCR_M_v_Link_SetAdditionalLong(p_stLinkValue,1,lLen);
|
||
SCR_M_v_Link_SetAdditionalLong(p_stLinkValue,2,ulType);
|
||
}
|
||
else /* bizarre*/
|
||
{
|
||
if (ulValue!=SCR_M_ul_Link_GetValue(p_stLinkValue))
|
||
{
|
||
sprintf(szForScript,"%s redefinition in %s",szParams[0],szDefineSection);
|
||
M_AIFatalErrorMsg(E_uwAIFatalScriptError,szForScript);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
SCR_tde_Anl_ReturnValue fn_eCreatePseudoTree(SCR_tdst_File_Description *p_stFile, char *szAction, char *szParams[], SCR_tde_Anl_Action eType) {
|
||
static lLen=0;
|
||
static long lNumber = 0 ;
|
||
struct tdstNodeInterpret_ *p_stNode ;
|
||
|
||
if (eType == SCR_EA_Anl_BeginSection) {
|
||
lNumber = 0 ;
|
||
p_stLoadedNode = fn_p_stAllocNodeInterpret((unsigned short)atoi(szParams[0]) );
|
||
}
|
||
else if (eType == SCR_EA_Anl_Entry) {
|
||
if ( !strcmp(szAction, "MakeNode") ) {
|
||
p_stNode = p_stLoadedNode + lNumber ;
|
||
M_SetTypeInterpret(p_stNode, atoi(szParams[1]) ) ;
|
||
M_lValueInterpret(p_stNode) = atoi(szParams[0]) ;
|
||
lNumber++ ;
|
||
}
|
||
}
|
||
else if (eType == SCR_EA_Anl_EndSection){
|
||
p_stLoadedMind->p_stAIModel->CFast_dst_ParamArray = p_stLoadedNode ;
|
||
p_stLoadedMind->p_stAIModel->uwNbParamNode = lNumber ;
|
||
}
|
||
|
||
return SCR_ERV_Anl_NormalReturn;
|
||
}
|
||
|
||
#endif /* U64 */
|
||
|
||
|
||
void fn_vRegisterAllRulesScriptSections(void)
|
||
{
|
||
#if !defined(U64)
|
||
/* .AI*/
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreateAIDefines_String ,fn_eCreateAIDefines , SCR_CRC_c_RdL0_ForSection);
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreateAIModel_String ,fn_eCreateAIModel , SCR_CRC_c_RdL0_ForSection);
|
||
/* .RUL & .RFX*/
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreateIntelligence_String ,fn_eCreateScriptAI , SCR_CRC_c_RdL0_ForSection);
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreateComport_String ,fn_eCreateComport , SCR_CRC_c_RdL0_ForSection);
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreateRule_String ,fn_eCreateRule , SCR_CRC_c_RdL0_ForSection);
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreateSchedule_String ,fn_eCreateSchedule , SCR_CRC_c_RdL0_ForSection);
|
||
/* .DEC*/
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreateVariables_String ,fn_eCreateVariables , SCR_CRC_c_RdL0_ForSection);
|
||
/* .MAC*/
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreateMacro_String ,fn_eCreateMacros , SCR_CRC_c_RdL0_ForSection);
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreateListOfMacro_String ,fn_eCreateListMacros , SCR_CRC_c_RdL0_ForSection);
|
||
/* .CAR*/
|
||
SCR_fn_v_RdL0_RegisterCallback(C_InitVariables_String ,fn_eInitVariables , SCR_CRC_c_RdL0_ForSection);
|
||
SCR_fn_v_RdL0_RegisterCallback(C_InitComportReflex_String ,fn_eInitComportReflex, SCR_CRC_c_RdL0_ForSection);
|
||
SCR_fn_v_RdL0_RegisterCallback(C_InitComportIntelligence_String ,fn_eInitComportIntell, SCR_CRC_c_RdL0_ForSection);
|
||
/* .NOD : CFAST*/
|
||
SCR_fn_v_RdL0_RegisterCallback(C_CreatePseudoTree_String ,fn_eCreatePseudoTree, SCR_CRC_c_RdL0_ForSection);
|
||
#endif /* U64 */
|
||
}
|
||
|
||
/* in fichier Defines.AI <20> mettre dans _Common\Families
|
||
{CreateAIDefines:
|
||
ConstantRef(Super,10)
|
||
RealRef(XX,3.14156)
|
||
RealRef(YY,5.0)
|
||
RealRef(ZZ,10.0)
|
||
}
|
||
*/
|
||
|
||
void fn_vReadAIDefines(char *szDefineFilename)
|
||
{
|
||
#if !defined(U64)
|
||
char szSectionName[_MAX_PATH];
|
||
SCR_fn_v_RdL0_ComputeSectionName(szSectionName,szDefineFilename,C_CreateAIDefines_String,NULL);
|
||
/* not activated for the moment*/
|
||
/*ANNECY CHRISTOPHE MODIFICATIONS CF XB*/
|
||
(void) SCR_fnp_st_RdL0_AnalyseSection(szSectionName, SCR_CDF_uw_Anl_Normal); /* (void) for lint.*/
|
||
/*ANNECY END CHRISTOPHE MODIFICATIONS CF XB*/
|
||
|
||
#endif
|
||
}
|
||
|
||
void fn_vReadAIModel(char *szModelFileName)
|
||
{
|
||
#if !defined(U64)
|
||
char szSectionName[_MAX_PATH];
|
||
tdstScriptAI **p_p_stScriptAI=NULL;
|
||
p_stLoadedAIModel=NULL;
|
||
|
||
SCR_fn_v_RdL0_ComputeSectionName(szSectionName,szModelFileName,C_CreateAIModel_String,NULL);
|
||
(void) SCR_fnp_st_RdL0_AnalyseSection(szSectionName, SCR_CDF_uw_Anl_Normal); /* (void) for lint.*/
|
||
|
||
/* alloc intelligence and link it with its script*/
|
||
p_p_stScriptAI=&AI_M_p_stGetIntelligenceScriptAIModel(p_stLoadedAIModel);
|
||
if (*p_p_stScriptAI!=NULL)
|
||
{
|
||
AI_M_SetIntelligence(p_stLoadedMind,
|
||
fn_p_stAllocIntelligence(
|
||
p_p_stScriptAI,
|
||
M_GetScriptAIActionTableNbEntry(*p_p_stScriptAI)
|
||
)
|
||
);
|
||
}
|
||
|
||
/* Alloc reflex (same structure as intelligence and link it with its script)*/
|
||
p_p_stScriptAI=&AI_M_p_stGetReflexScriptAIModel(p_stLoadedAIModel);
|
||
if (*p_p_stScriptAI!=NULL)
|
||
{
|
||
AI_M_SetReflex(p_stLoadedMind,
|
||
fn_p_stAllocIntelligence(
|
||
p_p_stScriptAI,
|
||
M_GetScriptAIActionTableNbEntry(*p_p_stScriptAI)
|
||
)
|
||
);
|
||
}
|
||
#endif /* U64 */
|
||
}
|
||
|
||
|
||
void fn_vReadAI(AI_tdstMind *p_stMind,char *szIntellFileName,tdstEngineObject *p_stEngineObject)
|
||
{
|
||
/* global variable in this module*/
|
||
p_stLoadedMind = p_stMind;
|
||
p_stLoadedEngineObject=p_stEngineObject;
|
||
|
||
AI_M_SetPersoName(p_stMind, fn_szFindPersonalTypeNameOfPersonalType(M_ObjectGetPersonalType(p_stEngineObject)));
|
||
|
||
fn_vReadAIModel(szIntellFileName);
|
||
}
|
||
|
||
void fn_vLoadCRR(AI_tdstMind *p_stMind, char *szFileName) {
|
||
p_stLoadedMind = p_stMind;
|
||
SCR_fnp_st_RdL0_AnalyseSection(szFileName, SCR_CDF_uw_Anl_ForceAnalyse);
|
||
}
|
||
|
||
SCR_tdst_Link_Value * fn_vGetLinkTableForCRR ( AI_tdstAIModel *p_stAIModel ) {
|
||
return SCR_fnp_st_Link_SearchValue(&g_stModelLinkTable, (long)p_stAIModel) ;
|
||
}
|
||
|
||
void fn_vSetLinkTableForCRR ( SCR_tdst_Link_Value *p_stValue, unsigned long ulValue ) {
|
||
SCR_tde_Link_State eState ;
|
||
char szTemp[2048] ;
|
||
|
||
eState = SCR_M_e_Link_GetState(p_stValue) ;
|
||
strcpy ( szTemp, SCR_M_p_sz_Link_GetKey(p_stValue) ) ;
|
||
SCR_fn_v_Link_DeleteEntry ( &g_stModelLinkTable, p_stValue ) ;
|
||
|
||
SCR_fnp_st_Link_AddEntry( &g_stModelLinkTable, szTemp, ulValue, eState ) ;
|
||
}
|