reman3/Rayman_X/cpa/tempgrp/AI/AIBase/Intell.c

1964 lines
69 KiB
C
Raw Blame History

/*---------------------------------------------------------------------------*/
/* Intell.c : Test pour le module d'intelligence.*/
/* auteur : Olivier Didelot.*/
/* date : 06/08/1996*/
/* date : 09/01/1997 O.C. mise en place des floats (Real)*/
/* 970115 : Vector and new DsgVar Perso management, (Fabien Morales) */
/* new Field 'Position' in Perso */
/* 970120 : fnc fn_vInterpretComportNPerso (Fabien Morales) */
/* Func_list management debugging*/
/* January 27,1997 : adding Way and WP evaluation ( Albert Pais )*/
/* modify : Olivier Couvreur 04/02/1997 Lint 20 warnings (enum switch line 128 and 273) excepted those specified at the end of AIMacros.h*/
/* modify : Fabien Morales 12/02/1997 Module & DsgVarId node types */
/* modify : Olivier Couvreur 26/02/1997 modification for usage of macro in schedule so that it works + lint check*/
/* modify : Olivier Couvreur 05/03/1997 M_TestActionReturn + lint ok except M_AI_DEBUG_ASSERT_WARNING*/
/* modify : Olivier Couvreur 25/03/1997 REVERSE_RULES support*/
/* modify : Olivier Couvreur 03/04/1997 add button support*/
/* modify : Olivier Couvreur 23/04/97 MMG + DIR*/
/* modify : Olivier Couvreur 25/05/97 mask for ZDE */
/*---------------------------------------------------------------------------*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#define __DeclareGlobalVariableErrAI_h__
#include "AI_Erm.h"
#undef __DeclareGlobalVariableErrAI_h__
#define __DeclareGlobalVariableMmgAI_h__
#include "AI_Mmg.h"
#undef __DeclareGlobalVariableMmgAI_h__
#include "AI_Struc.h"
#include "DsgMem.h"
#include "StrIntel.h"
#include "Action.h"
#include "specif/ActTable.h"
#include "GetSet.h"
#include "Convert.h"
#include "specif/AITools.h"
#include "safe.h"
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
#include "AID_Erm.h"
#include "specif/AID_Trac.h"
#endif /*ACTIVE_AIDEBUG*/
#if !defined(U64)
#include "EnumAct.h" /* tables of action names*/
#include "EnumCond.h" /* tables of conditions names*/
#include "EnumKey.h" /* tables of keywords names*/
#include "EnumFunc.h" /* tables of functions names*/
#include "EnumOper.h" /* tables of operator*/
#include "EnumProc.h" /* tables of Procedure.*/
#include "EnumFild.h" /* tables of fields*/
#endif
#ifdef PROFILE_IA
#include "tmr.h"
#endif /* PROFILE_IA*/
#define __DeclareGlobalVariableIntell_h__
#include "Intell.h"
#undef __DeclareGlobalVariableIntell_h__
//XB 12/04/99
//#if defined(__DEBUG_AI__)
#if defined(__DEBUG_AI__) || defined(TEST_CYCLING_COMPORT)
//End XB
/* Debug cycling comport*/
#define NB_MAX_COMPORT_TO_SCAN 20
#define NB_MAX_SAME_COMPORT 3
/* array of saving comportements for one frame.*/
struct {
tdstComport *p_stComport;
char cNbFoundComport;
} g_a_p_stComport[NB_MAX_COMPORT_TO_SCAN];
char g_cNbComportSeen;
//XB 12/04/99
//#endif /* __DEBUG_AI__*/
#endif /* __DEBUG_AI__ || TEST_CYCLING_COMPORT */
//End XB
//XB 12/04/99
#ifdef U64
#include "intell.cxx"
#endif /* U64 */
//End XB
/* True if we deal with the Schedule*/
unsigned char ucIsInSchedule = FALSE;
#ifdef __cplusplus
extern "C"
{
#endif
extern int iNumLoop; /* used in GAM, so we must declare it as a C variable!*/
#ifdef __cplusplus
}
#endif
/*extern int iNumLoop;*/
/* True if we deal with a Macro.*/
unsigned char g_ucIsInMacro = 0; /* if g_ucIsInMacro != 0 then we deal with a macro.*/
tdstNodeInterpret *g_p_stTreeMacro = NULL;
#ifdef PROFILE_IA
extern void fn_vCondComputeTime(unsigned long ulCurrentTime, unsigned long ulTime, enum tdeCondId_ eCondId);
extern void fn_vCondSaveTime(unsigned long ulTime, enum tdeCondId_ eCondId);
extern void fn_vFuncComputeTime(unsigned long ulCurrentTime, unsigned long ulTime, enum tdeFuncId_ eFuncId);
extern void fn_vFuncSaveTime(unsigned long ulTime, enum tdeFuncId_ eFuncId);
extern void fn_vProcComputeTime(unsigned long ulCurrentTime, unsigned long ulTime, enum tdeProcedureId_ eProcedurId);
extern void fn_vProcSaveTime(unsigned long ulTime, enum tdeProcedureId_ eProcedurId);
unsigned long p_ulTime[255];
unsigned long ulIndice = 0;
FILE *file;
#endif /* PROFILE_IA*/
/****************************************************************************************************************************/
/*** DR ***/
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
#include "AI_Proto.h"
AI_tdstMind *p_stCurrentMind=NULL;
struct AI_tdstMind_ *fn_p_stGetCurrentMind()
{
return(p_stCurrentMind);
}
void fn_v_SetCurrentMind(struct AI_tdstMind_ *p_stMind)
{
p_stCurrentMind=p_stMind;
}
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
unsigned char bStopAIEngineFlag=0;
void fn_vSetStopAIEngineFlag()
{
bStopAIEngineFlag=1;
AI_M_ucErrorFlag(p_stCurrentMind)=1;
fn_vForceEditor();
}
void fn_vReSetStopAIEngineFlag()
{
bStopAIEngineFlag=0;
}
unsigned char fn_ucGetStopAIEngineFlag()
{
return(bStopAIEngineFlag);
}
unsigned char fn_ucGetErrorFlag(HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
AI_tdstMind *p_stMind;
if (M_GetMSHandle((p_SuperObjPerso), Brain) == NULL)
return 0;
else
{
p_stMind = AI_M_stGetMindOfSuperObj(p_SuperObjPerso);
if (p_stMind == NULL)
return 0;
else
return AI_M_ucErrorFlag(p_stMind);
}
}
#endif /* !defined(U64_AIDEBUG)*/
#endif /*(defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)*/
/* for editor only */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vRESET_STOP_AI_ENGINE_FLAG()
{
#if defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)
fn_vReSetStopAIEngineFlag();
#endif
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/****************************************************************************************************************************/
/* function pointer array */
typedef struct tdstTypeEntry_
{
tdp_fn_p_stEvalTypePtr p_fn_p_stEvalTypePtr;
} tdstTypeEntry;
/* pointer prototypes*/
#define M_DEFINE_TYPE_INTERPRET(a,bbbb,c,d) static tdstNodeInterpret *##bbbb(HIE_tdxHandleToSuperObject , tdstNodeInterpret *, tdstGetSetParam *);
#include "DefType.h"
#undef M_DEFINE_TYPE_INTERPRET
/* pointer array*/
#define M_DEFINE_TYPE_INTERPRET(a,b,c,d) b,
tdstTypeEntry a_stTypeTable[E_ti_NbTypes]=
{
#include "DefType.h"
};
#undef M_DEFINE_TYPE_INTERPRET
/****************************************************************************************************************************/
/* E_ti_Macro*/
static tdstNodeInterpret *fn_p_stEvalMacro(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
unsigned char ucActionReturn;
tdstNodeInterpret *p_stTreeMacro, *p_stTreeSave;
tdstMacro *p_stMacro = M_p_stMacroInterpret(p_stTree);
unsigned char ucIndTabAction;
#if defined(ACTIVE_AIDEBUG)
unsigned short uwIndex;
uwIndex = AIDebug_M_PrepareMacroRef
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
#endif
p_stTreeSave=g_p_stTreeMacro;
g_p_stTreeMacro=p_stTree;
g_ucIsInMacro++;
ucIndTabAction = fn_ucIsRuleInActionTable(g_p_stIntelligence, g_ucNRule);
if (ucIndTabAction >= M_ActionTableNbEntries(g_p_stIntelligence))
{
// If this macro is at its beginning (there is no reference in the action table). This test is useful
// if a perso A change the comport of a perso B, while the perso have a macro not finished.
// In this case we must reinit the macro (current = init).
M_GetNodeInterpret(M_GetMacroCurrentTree(p_stMacro)) = M_GetNodeInterpret(M_GetMacroInitTree(p_stMacro));
}
else
{
tdstNodeInterpret *p_stTreeTmp;
p_stTreeTmp = fn_p_stGetTableAction(g_p_stIntelligence, ucIndTabAction);
if (p_stTreeTmp != g_p_stTreeMacro)
// There is an entry in Action Table but this is not this macro.
M_GetNodeInterpret(M_GetMacroCurrentTree(p_stMacro)) = M_GetNodeInterpret(M_GetMacroInitTree(p_stMacro));
}
p_stTreeMacro = M_GetNodeInterpret(M_GetMacroCurrentTree(p_stMacro));
fn_p_stIntelligenceEvalTreeEngine(p_SuperObjPerso, p_stTreeMacro, p_stValue);
ucActionReturn = (unsigned char) M_GetSetParam_ActionReturnValue(p_stValue);
g_ucIsInMacro--;
if (M_TestActionReturn(ucActionReturn,C_TREE_FINISHED))
{
// End of Macro
M_GetNodeInterpret(M_GetMacroCurrentTree(p_stMacro)) = M_GetNodeInterpret(M_GetMacroInitTree(p_stMacro));
M_Full_GetSetParam_ActionReturn(p_stValue, C_ACTION_ENGINE_CONTINUE);
// If there is another Macro in the stack (this macro have been called by an another macro).
g_p_stTreeMacro=p_stTreeSave;
return (++p_stTree);
}
else
if (M_TestActionReturn(ucActionReturn,C_ACTION_CHANGE_COMPORT))
{
M_GetNodeInterpret(M_GetMacroCurrentTree(p_stMacro)) = M_GetNodeInterpret(M_GetMacroInitTree(p_stMacro));
g_p_stTreeMacro=p_stTreeSave;
return (++p_stTree);
}
else
{
ucIndTabAction = fn_ucIsRuleInActionTable(g_p_stIntelligence, g_ucNRule);
if (ucIndTabAction < M_ActionTableNbEntries(g_p_stIntelligence))
{
tdstNodeInterpret *p_stTreeTmp;
p_stTreeTmp = fn_p_stGetTableAction(g_p_stIntelligence, ucIndTabAction);
if (M_GetTypeInterpret(p_stTreeTmp) != E_ti_MacroRef)
{
/* This is the first frame for this MetaAction.*/
M_GetNodeInterpret(M_GetMacroCurrentTree(p_stMacro)) = p_stTreeTmp;
/* remove current rule and action from action table*/
/*fn_vUnuseCurrentActionTableEntry(g_p_stIntelligence);*/
/* put MacroRef node in action table.*/
fn_vUnuseCurrentActionTableEntry(g_p_stIntelligence);
/* put rule and action in action table*/
fn_vUseCurrentActionTableEntry(g_p_stIntelligence, g_ucNRule, g_p_stTreeMacro);
/* XB 20/05/1999 */
#ifndef D_THROW_COMPLEX_ACTION_TABLE
//M_ActionTableNumNode(g_p_stIntelligence, ucIndTabAction) = g_p_stTreeMacro;
#else /* D_THROW_COMPLEX_ACTION_TABLE */
//M_ActionTableNumNode0(g_p_stIntelligence) = g_p_stTreeMacro;
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
/* End XB 20/05/1999 */
}
g_p_stTreeMacro=p_stTreeSave;
}
}
return(p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_Color*/
static tdstNodeInterpret *fn_p_stEvalColor(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_ColorValue(p_stValue,M_ColorValueInterpret(p_stTree));
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_ModelRef*/
static tdstNodeInterpret *fn_p_stEvalModelRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_p_stModel(p_stValue,M_p_stModelInterpret(p_stTree));
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_Field */
static tdstNodeInterpret *fn_p_stEvalField(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
/* Field of structur Perso.*/
if (fn_ucGetFieldValue(M_eFieldIdInterpret(p_stTree), p_SuperObjPerso, p_stValue) == C_INVALID_GET)
{
#if defined(__DEBUG_AI__)
fn_vTestGetDsgVarOrField(1,0,0,M_eFieldIdInterpret(p_stTree),p_SuperObjPerso ,p_stValue);
#else
M_AIFatalError(E_uwAIFatalNotValidField);
#endif
}
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetField
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
#endif /*ACTIVE_AIDEBUG*/
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_DsgVar*/
#if defined(__DEBUG_AI__)
void fn_vTestGetDsgVarOrField(unsigned char choice,unsigned char ucVarId,unsigned char ucIndex,tdeFieldId eFieldId,HIE_tdxHandleToSuperObject p_SuperObjPerso ,tdstGetSetParam *p_stValue)
{
AI_tdstMind* p_stMind=NULL;
char MyMsg[256]="";
char TypeMsg[50]="";
char ActorName[256]="";
ucIndex=ucIndex;
if (M_GetMSHandle(p_SuperObjPerso, Brain))
p_stMind = AI_M_stGetMindOfSuperObj(p_SuperObjPerso);
if (fn_ucIsAnAlwaysObject(M_GetEngineObject(p_SuperObjPerso))) /*BART : to recupair the type of the perso !*/
{
if (p_stMind)
sprintf(ActorName, "ALWAYS : %s", strchr(M_GetNameComport(M_GetCurrentComport(M_GetIntellOrReflex(p_stMind))), '\\')+1 );
else
sprintf(ActorName, "Unknown ALWAYS" );
*strchr(ActorName, '\\') = 0;
}
else
{
if (p_stMind)
strcpy(ActorName, AI_M_szGetPersoName(p_stMind));
else
strcpy(ActorName,"Unknown" );
}
if (!choice)
{
sprintf(TypeMsg,"variable no %d",ucVarId);
}
else
{
sprintf(TypeMsg,"field no %d",eFieldId);
}
if (M_GetSetParam_Type(p_stValue)==E_vt_Perso)
{
if (!fn_ucGetDontCheckNULLFlag())
{
sprintf(MyMsg,"Perso %s from p_stMind (%s) contains NULL.\n",TypeMsg,ActorName);/* in Comport : %s\n",TypeMsg,ActorName , M_GetNameComport(M_GetCurrentComport(M_GetIntellOrReflex(p_stMind))) );*/
}
}
else if (M_GetSetParam_Type(p_stValue)==E_vt_WayPoint)
{
if (!fn_ucGetDontCheckNULLFlag())
{
sprintf(MyMsg,"Waypoint %s from p_stMind (%s) contains NULL.\n",TypeMsg,ActorName);/* in Comport : %s\n",TypeMsg,ActorName , M_GetNameComport(M_GetCurrentComport(M_GetIntellOrReflex(p_stMind))) );*/
}
}
else if (M_GetSetParam_Type(p_stValue)==E_vt_Comport)
{
sprintf(MyMsg,"Comport %s from p_stMind (%s) contains NULL.\n",TypeMsg,ActorName);/* in Comport : %s\n",TypeMsg,ActorName , M_GetNameComport(M_GetCurrentComport(M_GetIntellOrReflex(p_stMind))) );*/
}
else if (M_GetSetParam_Type(p_stValue)==E_vt_Action)
{
if (!fn_ucGetDontCheckNULLFlag())
{
sprintf(MyMsg,"Action %s from p_stMind (%s) contains NULL.\n",TypeMsg,ActorName);/* in Comport : %s\n",TypeMsg,ActorName , M_GetNameComport(M_GetCurrentComport(M_GetIntellOrReflex(p_stMind))) );*/
}
}
else if (M_GetSetParam_Type(p_stValue)==E_vt_Text)
{
if (!fn_ucGetDontCheckNULLFlag())
{
sprintf(MyMsg,"Text %s from p_stMind (%s) contains invalid text.\n",TypeMsg,ActorName);/* in Comport : %s\n",TypeMsg,ActorName , M_GetNameComport(M_GetCurrentComport(M_GetIntellOrReflex(p_stMind))) );*/
}
}
else if (M_GetSetParam_Type(p_stValue)==E_vt_GameMaterial)
{
if (!fn_ucGetDontCheckNULLFlag())
{
sprintf(MyMsg,"GMT %s from p_stMind (%s) contains NULL.\n",TypeMsg,ActorName);/* in Comport : %s\n",TypeMsg,ActorName , M_GetNameComport(M_GetCurrentComport(M_GetIntellOrReflex(p_stMind))) );*/
}
}
else if (M_GetSetParam_Type(p_stValue)!=E_vt_Float) /* jt : no check with float */
{
sprintf(MyMsg,"Can't get %s from p_stMind (%s).\n",TypeMsg,ActorName);/* in Comport : %s\n",TypeMsg,ActorName , M_GetNameComport(M_GetCurrentComport(M_GetIntellOrReflex(p_stMind))) );*/
}
/* error*/
if (strlen(MyMsg))
{
SAF_M_AssertWithMsg(FALSE, MyMsg);
#if defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningScriptError,C_ucErmOpenInfoWindow,MyMsg);
fn_vSetStopAIEngineFlag();
#else
M_AIFatalErrorMsg(E_uwAIFatalInvalidParameter,MyMsg);
#endif /* ACTIVE_EXEC_CHECKING && ACTIVE_EDITOR*/
}
}
#endif /* __DEBUG_AI__*/
/****************************************************************************************************************************/
/* E_ti_DsgVarRef*/
static tdstNodeInterpret *fn_p_stEvalDsgVarRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
unsigned char ucId=(unsigned char) M_ucVarIdInterpret(p_stTree);
/*AI_tdstMind *p_stMind=AI_M_stGetMindOfSuperObj(p_SuperObjPerso);*/
if (fn_ucGetDsgVar(ucId,0,AI_M_stGetMindOfSuperObj(p_SuperObjPerso),p_stValue) == C_INVALID_GET)
{
#if defined(__DEBUG_AI__)
fn_vTestGetDsgVarOrField(0,ucId,0,(tdeFieldId) 0,p_SuperObjPerso ,p_stValue); /*BART*/
#endif
}
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetDsgVar
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
#endif /*ACTIVE_AIDEBUG*/
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_DsgVar*/
/*
static tdstNodeInterpret *fn_p_stEvalDsgVar(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
return(fn_p_stEvalDsgVarRef(p_SuperObjPerso, p_stTree, p_stValue));
}
*/
/****************************************************************************************************************************/
/* E_ti_Constant*/
static tdstNodeInterpret *fn_p_stEvalConstant(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_Integer(p_stValue,M_lValueInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetConstant( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif /*ACTIVE_AIDEBUG*/
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_Button*/
static tdstNodeInterpret *fn_p_stEvalButton(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_Button(p_stValue,M_hInputHandleIdInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetButton
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
#endif /*ACTIVE_AIDEBUG*/
return(++p_stTree);
}
/****************************************************************************************************************************/
/* Shaitan Clean Env {*/
/*
// E_ti_EnvironmentRef
static tdstNodeInterpret *fn_p_stEvalEnvironmentRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_GetSetParam_EnvironmentValue(p_stValue) = M_EnvironmentInterpret(p_stTree);
M_GetSetParam_Type(p_stValue) = E_vt_Environment;
#if defined(ACTIVE_AIDEBUG)
AIDebug_M_SetEnvironmentRef( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
*/
/* End Shaitan Clan Env }*/
/****************************************************************************************************************************/
/* E_ti_SuperObjectRef*/
static tdstNodeInterpret *fn_p_stEvalSuperObjectRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_GetSetParam_SuperObjectValue(p_stValue) = M_SuperObjectInterpret(p_stTree);
M_GetSetParam_Type(p_stValue) = E_vt_SuperObject;
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
/* to change */
AIDebug_M_SetSectorRef( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* Shaitan Clean Env {*/
/*
// E_ti_SurfaceRef
static tdstNodeInterpret *fn_p_stEvalSurfaceRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_GetSetParam_SurfaceValue(p_stValue) = M_SurfaceInterpret(p_stTree);
M_GetSetParam_Type(p_stValue) = E_vt_Surface;
#if defined(ACTIVE_AIDEBUG)
AIDebug_M_SetSurfaceRef( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
*/
/* End Shaitan Clan Env }*/
static tdstNodeInterpret *fn_p_stEvalObjectTableRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_GetSetParam_hObjectTable(p_stValue) = M_ObjectTableInterpret(p_stTree);
M_GetSetParam_Type(p_stValue) = E_vt_ObjectTable;
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_PersoRef*/
static tdstNodeInterpret *fn_p_stEvalPersoRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_GetSetParam_p_stEngineObjValue(p_stValue) = M_p_stPersoRefInterpret(p_stTree);
M_GetSetParam_Type(p_stValue) = E_vt_Perso;
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetPersoRef( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_ActionRef*/
static tdstNodeInterpret *fn_p_stEvalActionRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_GetSetParam_ActionValue(p_stValue) = M_ActionInterpret(p_stTree);
M_GetSetParam_Type(p_stValue) = E_vt_Action;
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetActionRef( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_Real*/
static tdstNodeInterpret *fn_p_stEvalReal(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_Float(p_stValue,M_xValueInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetReal( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_Vector*/
tdstNodeInterpret *fn_p_stEvalVector(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
MTH_tdxReal xX,xY,xZ;
#if defined(ACTIVE_AIDEBUG)
unsigned short uwIndex;
uwIndex = AIDebug_M_SetVector
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
/* skip unused*/
p_stTree++;
/* get x,y or z*/
M_EvalNextParameter(p_stValue);
xX=M_ReturnParam_xValue(p_stValue);
M_EvalNextParameter(p_stValue);
xY=M_ReturnParam_xValue(p_stValue);
M_EvalNextParameter(p_stValue);
xZ=M_ReturnParam_xValue(p_stValue);
/* define vector*/
MTH3D_M_vSetVectorElements (&M_GetSetParam_stVertexValue(p_stValue), xX, xY, xZ);
M_GetSetParam_Type(p_stValue)=E_vt_Vector;
AIDebug_M_UpdateGetSetParam
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
uwIndex,
p_stValue
);
return(p_stTree);
#else
/* skip unused*/
p_stTree++;
/* get x,y or z*/
M_EvalNextParameter(p_stValue);
xX=M_ReturnParam_xValue(p_stValue);
M_EvalNextParameter(p_stValue);
xY=M_ReturnParam_xValue(p_stValue);
M_EvalNextParameter(p_stValue);
xZ=M_ReturnParam_xValue(p_stValue);
/* define vector*/
MTH3D_M_vSetVectorElements (&M_GetSetParam_stVertexValue(p_stValue), xX, xY, xZ);
M_GetSetParam_Type(p_stValue)=E_vt_Vector;
return(p_stTree);
#endif
}
/****************************************************************************************************************************/
/* case E_ti_ConstantVector*/
static tdstNodeInterpret *fn_p_stEvalConstantVector(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_p_stVertex(p_stValue,M_p_stVectorInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetConstantVector( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_WayPointRef*/
static tdstNodeInterpret *fn_p_stEvalWayPointRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_WayPoint(p_stValue,M_lWayPointInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetWayPoint( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_Module*/
static tdstNodeInterpret *fn_p_stEvalModuleRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_Module(p_stValue,M_lModuleInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetModule( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_DsgVarId*/
static tdstNodeInterpret *fn_p_stEvalDsgVarId(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_DsgVarId(p_stValue,M_lDsgVarIdInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetDsgVarId( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_Mask*/
static tdstNodeInterpret *fn_p_stEvalMask(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_Mask(p_stValue,M_xMaskInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetMask( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_String*/
static tdstNodeInterpret *fn_p_stEvalString(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_String(p_stValue, M_szStringInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetString( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_LipsSynchroRef*/
static tdstNodeInterpret *fn_p_stEvalLipsSynchroRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_hLipsSynchro(p_stValue, M_hLipSynchroHandleIdInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetLipsSynchroRef( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_SoundEventRef*/
static tdstNodeInterpret *fn_p_stEvalSoundEventRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_SoundEvent(p_stValue, M_SoundEventInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetSoundEventRef( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_FamilyRef*/
static tdstNodeInterpret *fn_p_stEvalFamilyRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_hFamily(p_stValue, M_hFamilyHandleIdInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetFamilyRef( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_EndOfTree*/
static tdstNodeInterpret *fn_p_stEvalEndOfTree(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_ActionReturn(p_stValue,C_TREE_FINISHED);
return(p_stTree); /* warning : no ++ here*/
}
/****************************************************************************************************************************/
/* E_ti_BeginMacro*/
/* TEMPORAIRE*/
static tdstNodeInterpret *fn_p_stEvalBeginMacro(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_ActionReturn(p_stValue, C_ACTION_ENGINE_CONTINUE);
return(++p_stTree);
}
/* E_ti_EndMacro*/
static tdstNodeInterpret *fn_p_stEvalEndMacro(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_ActionReturn(p_stValue, C_ACTION_ENGINE_CONTINUE);
return(++p_stTree);
}
/* FIN TEMPORAIRE*/
/****************************************************************************************************************************/
/* E_ti_ComportRef*/
static tdstNodeInterpret *fn_p_stEvalComportRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_pComport(p_stValue, M_ComportInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetComport( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_TextRef*/
static tdstNodeInterpret *fn_p_stEvalTextRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_hText(p_stValue, M_TextInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetTextRef( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_ParticleGenerator*/
/* JO 09/10/97*/
static tdstNodeInterpret *fn_p_stEvalParticleGenerator(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_hParticleGenerator(p_stValue, M_ParticleGeneratorInterpret(p_stTree));
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetParticleGenerator( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), p_stValue, p_stTree );
#endif
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_GameMaterialRef*/
static tdstNodeInterpret *fn_p_stEvalGameMaterialRef(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_hGameMaterial(p_stValue, M_GameMaterialInterpret(p_stTree));
return(++p_stTree);
}
/*ANNECY CT 22/01/98*/
/****************************************************************************************************************************/
/* E_ti_Light*/
static tdstNodeInterpret *fn_p_stEvalLight(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_Light(p_stValue,M_p_stLightInterpret(p_stTree));
return(++p_stTree);
}
/*ENDANNECY CT}*/
/*ANNECY Bart 02/02/98 {*/
/****************************************************************************************************************************/
/* E_ti_Caps*/
static tdstNodeInterpret *fn_p_stEvalCaps(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_Caps(p_stValue, M_ulCapsInterpret(p_stTree));
return(++p_stTree);
}
/****************************************************************************************************************************/
/* E_ti_Graph*/
static tdstNodeInterpret *fn_p_stEvalGraph(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
M_Full_GetSetParam_Graph(p_stValue,M_p_stGraphInterpret(p_stTree));
return(++p_stTree);
}
/*ENDANNECY Bart }*/
/****************************************************************************************************************************/
/* default*/
static tdstNodeInterpret *fn_p_stEvalNULL(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
p_SuperObjPerso=p_SuperObjPerso;
p_stValue=p_stValue;
#if defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)
fn_vSetStopAIEngineFlag();
#else
#if defined(__DEBUG_AI__)
M_AIFatalError(E_uwAIFatalInvalidParameter);
#endif
#endif
return(++p_stTree);
}
/*****************************************************************************
* Eval parameter :
******************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdstNodeInterpret *fn_p_stEvalParameter(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
tdeTypeInterpret eType=M_GetTypeInterpret(p_stTree);
tdp_fn_p_stEvalTypePtr p_fn_p_stPtr=a_stTypeTable[eType].p_fn_p_stEvalTypePtr;
p_stTree=p_fn_p_stPtr(p_SuperObjPerso,p_stTree,p_stValue);
return(p_stTree);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*****************************************************************************
* Eval KeyWord and return the tree after evaluation.
*****************************************************************************/
static tdstNodeInterpret *fn_p_stEvalKeyWord(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
#if defined(ACTIVE_AIDEBUG)
enum tdeKeyWordId_ eKeyWordId=M_eKeyWordIdInterpret(p_stTree);
tdp_fn_p_stKeyWordFunctionPtr p_fn_p_stKeyWordFunctionPtr;
AIDebug_M_SetKeyWord
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
p_stTree ++;
p_fn_p_stKeyWordFunctionPtr=fn_p_fn_pGetKeyWordFunctionPtr(eKeyWordId);
return(p_fn_p_stKeyWordFunctionPtr(p_SuperObjPerso,p_stTree,p_stValue));
#else
/* Get KeyWord function pointer*/
enum tdeKeyWordId_ eKeyWordId=M_eKeyWordIdInterpret(p_stTree++);
tdp_fn_p_stKeyWordFunctionPtr p_fn_p_stKeyWordFunctionPtr=fn_p_fn_pGetKeyWordFunctionPtr(eKeyWordId);
/* Call KeyWord function pointer*/
return(p_fn_p_stKeyWordFunctionPtr(p_SuperObjPerso,p_stTree,p_stValue));
#endif
}
/*****************************************************************************
* Eval condition and return the tree after evaluation.
*****************************************************************************/
static tdstNodeInterpret *fn_p_stEvalCondition(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
/* Get fonction pointer*/
#if defined(ACTIVE_AIDEBUG)
unsigned short uwIndex;
tdp_fn_p_stConditionFunctionPtr p_fn_p_stConditionFunctionPtr;
long lValue=(long) FALSE;
enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree);
uwIndex = AIDebug_M_PrepareCondition
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
p_stTree ++;
p_fn_p_stConditionFunctionPtr = fn_p_fn_pGetConditionFunctionPtr(eCondId);
p_stTree = p_fn_p_stConditionFunctionPtr(p_SuperObjPerso,p_stTree,&lValue);
M_Full_GetSetParam_Integer(p_stValue, ((lValue !=FALSE)?TRUE:FALSE) );
AIDebug_M_UpdateGetSetParam
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
uwIndex,
p_stValue
);
return(p_stTree);
#else
long lValue=(long) FALSE;
enum tdeCondId_ eCondId=M_eCondIdInterpret(p_stTree++);
#ifdef PROFILE_IA
unsigned long ulTime;
tdp_fn_p_stConditionFunctionPtr p_fn_p_stConditionFunctionPtr=fn_p_fn_pGetConditionFunctionPtr(eCondId);
ulTime = TMR_fn_ulFastGetInternalCounter();
fn_vCondSaveTime(ulTime, eCondId);
/* call condition with function pointer*/
p_stTree = p_fn_p_stConditionFunctionPtr(p_SuperObjPerso,p_stTree,&lValue);
fn_vCondComputeTime(TMR_fn_ulFastGetInternalCounter(), ulTime, eCondId);
/* important*/
M_Full_GetSetParam_Integer(p_stValue, ((lValue !=FALSE)?TRUE:FALSE) );
#else
tdp_fn_p_stConditionFunctionPtr p_fn_p_stConditionFunctionPtr=fn_p_fn_pGetConditionFunctionPtr(eCondId);
/* call condition with function pointer*/
p_stTree = p_fn_p_stConditionFunctionPtr(p_SuperObjPerso,p_stTree,&lValue);
/* important*/
M_Full_GetSetParam_Integer(p_stValue, ((lValue !=FALSE)?TRUE:FALSE) );
#endif /* PROFILE_IA*/
return(p_stTree);
#endif
}
/*****************************************************************************
* Eval a Function and return the tree after evaluation.
*****************************************************************************/
static tdstNodeInterpret *fn_p_stEvalFunction(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
unsigned short uwIndex;
tdeFuncId eFuncId=M_eFuncIdInterpret(p_stTree);
tdp_fn_p_stFunctionFunctionPtr p_fn_p_stFunctionFunctionPtr;
tdstNodeInterpret * p_stResult;
uwIndex = AIDebug_M_PrepareFunction
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
p_stTree ++;
p_fn_p_stFunctionFunctionPtr = fn_p_fn_pGetFunctionFunctionPtr(eFuncId);
p_stResult = p_fn_p_stFunctionFunctionPtr(p_SuperObjPerso,p_stTree,p_stValue);
AIDebug_M_UpdateGetSetParam
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
uwIndex,
p_stValue
);
return p_stResult;
#else
#ifdef PROFILE_IA
unsigned long ulTime;
tdstNodeInterpret *Tree;
/* get function pointer*/
tdeFuncId eFuncId=M_eFuncIdInterpret(p_stTree++);
tdp_fn_p_stFunctionFunctionPtr p_fn_p_stFunctionFunctionPtr=fn_p_fn_pGetFunctionFunctionPtr(eFuncId);
/* call function with function pointer*/
ulTime = TMR_fn_ulFastGetInternalCounter();
fn_vFuncSaveTime(ulTime, eFuncId);
Tree = p_fn_p_stFunctionFunctionPtr(p_SuperObjPerso,p_stTree,p_stValue);
fn_vFuncComputeTime(TMR_fn_ulFastGetInternalCounter(), ulTime, eFuncId);
return Tree;
#else
/* get function pointer*/
tdeFuncId eFuncId=M_eFuncIdInterpret(p_stTree++);
tdp_fn_p_stFunctionFunctionPtr p_fn_p_stFunctionFunctionPtr=fn_p_fn_pGetFunctionFunctionPtr(eFuncId);
/* call function with function pointer*/
return p_fn_p_stFunctionFunctionPtr(p_SuperObjPerso,p_stTree,p_stValue);
#endif /* PROFILE_IA*/
#endif
}
/*****************************************************************************
* Eval an Operator and return the tree after evaluation.
*****************************************************************************/
static tdstNodeInterpret *fn_p_stEvalOperator(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
#if defined(ACTIVE_AIDEBUG)
unsigned short uwIndex;
tdeOperatorId eOperatorId=M_eOperatorIdInterpret(p_stTree);
tdp_fn_p_stOperatorFunctionPtr p_fn_p_stOperatorFunctionPtr;
tdstNodeInterpret * p_stResult;
uwIndex = AIDebug_M_PrepareOperator
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
p_stTree ++;
p_fn_p_stOperatorFunctionPtr=fn_p_fn_pGetOperatorFunctionPtr(eOperatorId);
p_stResult = p_fn_p_stOperatorFunctionPtr(p_SuperObjPerso,p_stTree,p_stValue);
AIDebug_M_UpdateGetSetParam
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
uwIndex,
p_stValue
);
return p_stResult;
#else
/* Get operator function pointer*/
tdeOperatorId eOperatorId=M_eOperatorIdInterpret(p_stTree++);
tdp_fn_p_stOperatorFunctionPtr p_fn_p_stOperatorFunctionPtr=fn_p_fn_pGetOperatorFunctionPtr(eOperatorId);
/* Call operator function pointer*/
return(p_fn_p_stOperatorFunctionPtr(p_SuperObjPerso,p_stTree,p_stValue));
#endif
}
tducActionReturn ucProcedureActionReturn=C_ACTION_ENGINE_CONTINUE;
void fn_vSetProcedureActionReturn(tducActionReturn ucActionReturn)
{
ucProcedureActionReturn=ucActionReturn;
}
tducActionReturn fn_ucGetProcedureActionReturn()
{
return(ucProcedureActionReturn);
}
static tdstNodeInterpret *fn_p_stEvalProcedure(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
tdeProcedureId eProcedureId=M_eProcedureIdInterpret(p_stTree);
tdp_fn_p_stProcedureFunctionPtr p_fn_p_stProcedureFunctionPtr;
#if defined(ACTIVE_AIDEBUG)
AI_tdstMind *p_stMind=AI_M_stGetMindOfSuperObj(p_SuperObjPerso);
AIDebug_M_SetProcedure
(
p_stMind,
p_stValue,
p_stTree
);
#endif
#ifdef PROFILE_IA
unsigned long ulTime;
#endif /* PROFILE_IA*/
/* get procedure function pointer*/
p_fn_p_stProcedureFunctionPtr=fn_p_fn_pGetProcedureFunctionPtr(eProcedureId);
/* set procedure action return : C_ACTION_ENGINE_CONTINUE as a default*/
fn_vSetProcedureActionReturn(C_ACTION_ENGINE_CONTINUE);
/* call procedure function pointer*/
#ifdef PROFILE_IA
ulTime = TMR_fn_ulFastGetInternalCounter();
fn_vProcSaveTime(ulTime, eProcedureId);
#endif /* PROFILE_IA*/
p_stTree=p_fn_p_stProcedureFunctionPtr(p_SuperObjPerso,++p_stTree);
#ifdef PROFILE_IA
fn_vProcComputeTime(TMR_fn_ulFastGetInternalCounter(), ulTime, eProcedureId);
#endif /* PROFILE_IA*/
/* very important to inform engine about actionreturn value*/
M_Full_GetSetParam_ActionReturn(p_stValue, fn_ucGetProcedureActionReturn() & ~C_ACTION_FINISHED);
return(p_stTree);
}
/*****************************************************************************
* Swap every parameter wich have its depth less than the current depth.
******************************************************************************
* Parameters: - p_stTree : The tree.
******************************************************************************/
tdstNodeInterpret *fn_p_stSwapNextParameter(tdstNodeInterpret *p_stTree)
{
unsigned char ucDepth = M_DepthInterpret(p_stTree);
p_stTree++;
while ( (M_DepthInterpret(p_stTree) >= ucDepth)
&& (!M_IsTheEndOfTree(p_stTree)))
p_stTree++;
return p_stTree;
}
tdstNodeInterpret *fn_p_stSwapNextParameter2(tdstNodeInterpret *p_stTree)
{
/*a little different '>=' becomes '>' */
unsigned char ucDepth = M_DepthInterpret(p_stTree-1);
while ( (M_DepthInterpret(p_stTree) > ucDepth)
&& (!M_IsTheEndOfTree(p_stTree)))
p_stTree++;
return(p_stTree);
}
tdstNodeInterpret *fn_p_stSkipThisArgument(tdstNodeInterpret *p_stTree)
{
/*get its depth */
unsigned char ucDepth = M_DepthInterpret(p_stTree);
p_stTree ++; /* fetch next node (with a higher or same depth)*/
/*skip nodes until we get to the same depth*/
while ( (M_DepthInterpret(p_stTree) > ucDepth) && (!M_IsTheEndOfTree(p_stTree)))
p_stTree++;
return(p_stTree);
}
/*****************************************************************************
* Eval a MetaAction and return the tree after evaluation.
*****************************************************************************/
static tducActionReturn fn_ucComputeActionNextPerso(HIE_tdxHandleToSuperObject p_SuperObjPerso, enum tdeMetaActionId_ eMetaActionId)
{
tdp_fn_ucMetaActionFunctionPtr p_fn_ucMetaActionFunctionPtr=fn_p_fn_pGetMetaActionFunctionPtr(eMetaActionId);
return(p_fn_ucMetaActionFunctionPtr(p_SuperObjPerso));
}
tdstNodeInterpret *fn_p_stComputeActionStartPerso(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, enum tdeMetaActionId_ eMetaActionId, tdstGetSetParam *p_stValue)
{
tdp_fn_p_stMetaActionInitFunctionPtr p_fn_ucMetaActionInitFunctionPtr=fn_p_fn_pGetMetaActionInitFunctionPtr(eMetaActionId);
p_stTree=p_fn_ucMetaActionInitFunctionPtr(p_SuperObjPerso, p_stTree);
#if defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)
if (AI_M_ucErrorFlag(AI_M_stGetMindOfSuperObj(p_SuperObjPerso)))
{
M_Full_GetSetParam_ActionReturn(p_stValue, (C_ACTION_FINISHED | C_ACTION_ENGINE_STOP));
return((p_stTree));
}
#endif
M_Full_GetSetParam_ActionReturn(p_stValue,(long) fn_ucComputeActionNextPerso(p_SuperObjPerso, eMetaActionId));
return p_stTree;
}
static tdstNodeInterpret *fn_p_stEvalMetaAction(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
tdstNodeInterpret *p_stTreeForActionTable = (g_ucIsInMacro != 0)?g_p_stTreeMacro:p_stTree;
#if defined(ACTIVE_AIDEBUG)
enum tdeMetaActionId_ eMetaActionId;
unsigned short uwIndex;
tdstNodeInterpret* p_stNode = NULL;
SAF_M_AssertWithMsg(iNumLoop == 0, "Il est strictement interdit d'appeler une meta-action <20> l'int<6E>rieur d'une boucle!");
SAF_M_AssertWithMsg(g_ucIsInMacro <= 1, "Il est strictement interdit d'appeler une meta-action <20> l'int<6E>rieur d'une subroutine imbriqu<71>e!");
/* look for rule and action in action table*/
#ifndef D_THROW_COMPLEX_ACTION_TABLE
if ((M_ActionTableCurrentEntry(g_p_stIntelligence)
=
fn_ucIsRuleAndNodeInActionTable(g_p_stIntelligence, g_ucNRule, p_stTreeForActionTable))<M_ActionTableNbEntries(g_p_stIntelligence))
#else /* D_THROW_COMPLEX_ACTION_TABLE */
if (fn_ucIsRuleAndNodeInActionTable(g_p_stIntelligence, g_ucNRule, p_stTreeForActionTable)<M_ActionTableNbEntries(g_p_stIntelligence))
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
{
eMetaActionId = M_eMetaActionIdInterpret(p_stTree);
uwIndex = AIDebug_M_PrepareMetaAction
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
/* Swap all the parameter for this function.*/
#if defined(OPTIMIZE_SWAP_PARAMETER)
if(M_NodeToSkip(p_stTree))
{
p_stTree+=M_NodeToSkip(p_stTree);
}
else
{
tdstNodeInterpret *p_stTreeInit=p_stTree;
p_stTree = fn_p_stSwapNextParameter2(p_stTree+1);
M_NodeToSkip(p_stTreeInit)=(unsigned short) (p_stTree-p_stTreeInit);
}
#else
p_stTree++;
p_stTree = fn_p_stSwapNextParameter2(p_stTree);
#endif
/* execute action without init*/
M_Full_GetSetParam_ActionReturn(p_stValue, (long) fn_ucComputeActionNextPerso(p_SuperObjPerso, eMetaActionId) );
bSomethingDone = TRUE; /* Do not make schedule.*/
AIDebug_M_UpdateGetSetParam
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
uwIndex,
p_stValue
);
return p_stTree;
}
else
{
/*XB*/
fn_vUnuseAllRulesWhichHaveGreaterNumRule(g_p_stIntelligence,g_ucNRule);
/*End XB*/
#ifndef D_THROW_COMPLEX_ACTION_TABLE
if ((M_ActionTableCurrentEntry(g_p_stIntelligence)
=
#else /* D_THROW_COMPLEX_ACTION_TABLE */
if ((
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
fn_ucFindPlaceInActionTable(g_p_stIntelligence))<M_ActionTableNbEntries(g_p_stIntelligence))
{
/* put rule and action in action table*/
fn_vUseCurrentActionTableEntry(g_p_stIntelligence, g_ucNRule, p_stTree);
/* execute action with init*/
uwIndex = AIDebug_M_PrepareBeginMetaAction
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
p_stValue,
p_stTree
);
eMetaActionId = M_eMetaActionIdInterpret(p_stTree);
p_stTree++;
bSomethingDone = TRUE; /* Do not make schedule. */
p_stNode = (fn_p_stComputeActionStartPerso(p_SuperObjPerso, p_stTree, eMetaActionId, p_stValue));
AIDebug_M_UpdateGetSetParam
(
AI_M_stGetMindOfSuperObj(p_SuperObjPerso),
uwIndex,
p_stValue
);
return p_stNode;
}
else
{
/* error : action table too small*/
#ifdef U64
M_PrintfStopErrorN64(("Not enough space in action table\n"));
#endif
M_AIFatalError(E_uwAIActionTableTooSmall);
M_Full_GetSetParam_ActionReturn(p_stValue,0);
return 0;
}
}
#else /*ACTIVE_AIDEBUG*/
enum tdeMetaActionId_ eMetaActionId;
/* look for rule and action in action table*/
/* XB 20/05/1999 */
#ifndef D_THROW_COMPLEX_ACTION_TABLE
if ((M_ActionTableCurrentEntry(g_p_stIntelligence)
=
fn_ucIsRuleAndNodeInActionTable(g_p_stIntelligence, g_ucNRule, p_stTreeForActionTable))<M_ActionTableNbEntries(g_p_stIntelligence))
#else /* D_THROW_COMPLEX_ACTION_TABLE */
if (fn_ucIsRuleAndNodeInActionTable(g_p_stIntelligence, g_ucNRule, p_stTreeForActionTable)<M_ActionTableNbEntries(g_p_stIntelligence))
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
/* End XB 20/05/1999 */
{
eMetaActionId = M_eMetaActionIdInterpret(p_stTree);
/* Swap all the parameter for this function.*/
#if defined(OPTIMIZE_SWAP_PARAMETER)
if(M_NodeToSkip(p_stTree))
{
p_stTree+=M_NodeToSkip(p_stTree);
}
else
{
tdstNodeInterpret *p_stTreeInit=p_stTree;
p_stTree = fn_p_stSwapNextParameter2(p_stTree+1);
M_NodeToSkip(p_stTreeInit)=(unsigned short) (p_stTree-p_stTreeInit);
}
#else
p_stTree++;
p_stTree = fn_p_stSwapNextParameter2(p_stTree);
#endif
/* execute action without init*/
M_Full_GetSetParam_ActionReturn(p_stValue, (long) fn_ucComputeActionNextPerso(p_SuperObjPerso, eMetaActionId) );
bSomethingDone = TRUE; /* Do not make schedule.*/
return p_stTree;
}
else
{
/*XB*/
fn_vUnuseAllRulesWhichHaveGreaterNumRule(g_p_stIntelligence,g_ucNRule);
/*End XB*/
/* XB 20/05/1999 */
#ifndef D_THROW_COMPLEX_ACTION_TABLE
if ((M_ActionTableCurrentEntry(g_p_stIntelligence)
=fn_ucFindPlaceInActionTable(g_p_stIntelligence))<M_ActionTableNbEntries(g_p_stIntelligence))
#else /* D_THROW_COMPLEX_ACTION_TABLE */
if (fn_ucFindPlaceInActionTable(g_p_stIntelligence)<M_ActionTableNbEntries(g_p_stIntelligence))
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
/* End XB 20/05/1999 */
{
/* put rule and action in action table*/
fn_vUseCurrentActionTableEntry(g_p_stIntelligence, g_ucNRule, p_stTree);
/* execute action with init*/
eMetaActionId = M_eMetaActionIdInterpret(p_stTree);
p_stTree++;
bSomethingDone = TRUE; /* Do not make schedule. */
return(fn_p_stComputeActionStartPerso(p_SuperObjPerso, p_stTree, eMetaActionId, p_stValue));
}
else
{
#ifdef U64
M_PrintfStopErrorN64(("Not enough space in action table\n"));
#endif
M_AIFatalError(E_uwAIActionTableTooSmall);
M_Full_GetSetParam_ActionReturn(p_stValue,0);
return 0;
}
}
#endif /*ACTIVE_AIDEBUG*/
}
tdstNodeInterpret *fn_p_stEvalTree(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
#if defined(__DEBUG_AI__)
tdstNodeInterpret *p_stReturnedTree;
#endif
#ifdef ACTIVE_EDITOR /*BART*/
/*int nCount;*/
char* pMsg;
char szMyDescription[1024];
/*tdeTypeInterpret eType;*/
#endif /*ACTIVE_EDITOR*/
#if defined(__DEBUG_AI__)
tdeTypeInterpret eType=M_GetTypeInterpret(p_stTree);
tdp_fn_p_stEvalTypePtr p_fn_p_stPtr=a_stTypeTable[eType].p_fn_p_stEvalTypePtr;
#endif
#if defined(ACTIVE_AIDEBUG) && !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
if( M_GetBreakPoint(p_stTree) && AIDebug_fn_bGetEnable(AI_M_stGetMindOfSuperObj(p_SuperObjPerso)) )
{
bStopAIEngineFlag=1;
fn_vForceEditor();
M_Full_GetSetParam_ActionReturn((p_stValue), (C_ACTION_FINISHED | C_ACTION_ENGINE_STOP));
return p_stTree;
}
#endif /*ACTIVE_AIDEBUG && !U64_AIDEBUG*/
#if defined(__DEBUG_AI__)
#pragma warning (disable : 4611)
SAF_M_Try /*BART*/
#pragma warning (default : 4611)
p_stReturnedTree = p_fn_p_stPtr(p_SuperObjPerso,p_stTree,p_stValue);
SAF_M_CatchWithMsg(pMsg) /* BART*/
#ifdef ACTIVE_EDITOR
/*eType = M_GetTypeInterpret(p_stTree);*/
if (eType == E_ti_KeyWord)
sprintf(szMyDescription, "KeyWord : %s\n ->%s", szFindKeyWordEditorNameFromId(M_eKeyWordIdInterpret(p_stTree)), pMsg);
else if (eType == E_ti_Condition)
sprintf(szMyDescription, "Condition : %s\n ->%s", szFindConditionEditorNameFromId(M_eCondIdInterpret(p_stTree)), pMsg);
else if (eType == E_ti_Operator)
sprintf(szMyDescription, "Operator : %s\n ->%s", szFindOperatorEditorNameFromId(M_eOperatorIdInterpret(p_stTree)), pMsg);
else if (eType == E_ti_Function)
sprintf(szMyDescription, "Function : %s\n ->%s", szFindFunctionEditorNameFromId(M_eFuncIdInterpret(p_stTree)), pMsg);
else if (eType == E_ti_Procedure)
sprintf(szMyDescription, "Procedure : %s\n ->%s", szFindProcedureEditorNameFromId(M_eProcedureIdInterpret(p_stTree)), pMsg);
else if (eType == E_ti_MetaAction)
sprintf(szMyDescription, "MetaAction : %s\n ->%s", szFindMetaActionEditorNameFromId(M_eMetaActionIdInterpret(p_stTree)), pMsg);
else if (eType == E_ti_Field)
sprintf(szMyDescription, "Field : %s\n ->%s", szFindFieldEditorNameFromId(M_eFieldIdInterpret(p_stTree)), pMsg);
else
sprintf(szMyDescription, "\n ->%s", pMsg);
strcpy(pMsg, szMyDescription);
#endif /*ACTIVE_EDITOR*/
SAF_M_EndCatch /*BART*/
return(p_stReturnedTree);
#else
return(a_stTypeTable[M_GetTypeInterpret(p_stTree)].p_fn_p_stEvalTypePtr(p_SuperObjPerso,p_stTree,p_stValue));
#endif
}
/*****************************************************************************
*
******************************************************************************
* Parameters:
*
******************************************************************************/
unsigned char fn_ucIsThereAnotherCommand(tdstNodeInterpret *p_stTree, unsigned char ucDepth)
{
return (M_DepthInterpret(p_stTree) == ucDepth);
}
/*****************************************************************************
* Compute the Action type return.
******************************************************************************
* Parameters:
* - p_stValue : Action type return by EvalTree.
******************************************************************************/
static unsigned char fn_ucGetActionReturn(tdstGetSetParam *p_stValue, tdstNodeInterpret *p_stTree, unsigned char ucDepth)
{
/* Modif Ylg*/
unsigned char ucActionReturn = (unsigned char) M_GetSetParam_ActionReturnValue(p_stValue);
/* Blocking action management*/
/* if Action Return was specified by SetActionReturn function before the next action. */
if (! M_TestActionReturn(g_ucNewActionReturn,C_ACTION_ENGINE_NOTDEFINED))
{
/* If this is not the SetActionReturn procedure which is treated.*/
if(!g_ucUseDefaultActionReturn)
{
/* if the action is not finished or if there is another instruction after this one.*/
if (!( M_TestActionReturn(ucActionReturn,C_ACTION_FINISHED)
&& fn_ucIsThereAnotherCommand(p_stTree, ucDepth)
))
{
/* keep only these bits */
ucActionReturn &= (C_ACTION_CHANGE_COMPORT | C_TREE_FINISHED | C_ACTION_FINISHED);
/* and use the bits defined in g_ucNewActionReturn*/
ucActionReturn |= g_ucNewActionReturn;
}
/* the other actions will not take in account g_ucNewActionReturn any longer */
g_ucNewActionReturn = C_ACTION_ENGINE_NOTDEFINED;
g_ucUseDefaultActionReturn = TRUE;
}
else
/* g_ucNewActionReturn will be used next time */
g_ucUseDefaultActionReturn = FALSE;
}
return ucActionReturn;
}
#ifdef __DEBUG_AI__
/*****************************************************************************
* Test if there is a cycle in comportement changing.
******************************************************************************
* Parameters:
* - p_stIntelligence : Intelligence of Perso.
******************************************************************************/
static unsigned char fn_ucTestCycleComport(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstIntelligence *p_stIntelligence)
{
tdstComport *p_stNewComport= M_GetCurrentComport(p_stIntelligence); /* new comportement */
unsigned char ucFoundComport = FALSE;
char i;
char j;
char szMsgErr[512];
/* scanning the array of comportements to check if the new comport has been already met.*/
for (i = 0; i < g_cNbComportSeen; i++)
{
ucFoundComport = (g_a_p_stComport[i].p_stComport == p_stNewComport) ? TRUE : FALSE ;
if (ucFoundComport)
{
if (g_a_p_stComport[i].cNbFoundComport >= NB_MAX_SAME_COMPORT)
{
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningCycleComport, C_ucErmOpenInfoWindow, M_GetNameComport(p_stNewComport));
for (j = 0; j < g_cNbComportSeen;j ++)
{
sprintf(szMsgErr, "%s (%d fois) \n", M_GetNameComport(g_a_p_stComport[j].p_stComport), g_a_p_stComport[j].cNbFoundComport+1);
Erm_fn_v_Printsz(szMsgErr);
}
#if defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)
fn_vSetStopAIEngineFlag();
#endif
return TRUE;
}
else
g_a_p_stComport[i].cNbFoundComport++;
}
}
if (!ucFoundComport)
{
if (g_cNbComportSeen < NB_MAX_COMPORT_TO_SCAN)
{
g_a_p_stComport[g_cNbComportSeen].cNbFoundComport = 1;
g_a_p_stComport[g_cNbComportSeen].p_stComport = p_stNewComport;
g_cNbComportSeen++;
}
else
{
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningArrayCyclingComportTooSmall, C_ucErmOpenInfoWindow, NULL);
return TRUE;
}
}
return FALSE;
}
#endif /* __DEBUG_AI__*/
/*****************************************************************************
* Engine for Tree evaluation.
* If Tree is finished then return C_TREE_FINISHED.
* If there is an action wich stop the Engine then return C_ACTION_ENGINE_STOP
******************************************************************************
* Parameters:
* - p_SuperObjPerso : SuperObject.
* - p_stIntelligence : Intelligence of Perso.
* - p_stTree : Tree Interpret.
******************************************************************************/
tdstNodeInterpret *fn_p_stIntelligenceEvalTreeEngine(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, tdstGetSetParam *p_stValue)
{
/* Modif YLG*/
tducActionReturn ucActionReturn;
unsigned char ucDepthInit;/* = M_DepthInterpret(p_stTree);*/
//XB 14/04/99
#if defined(U64) && (!defined(FINAL_VERSION) || defined(D_CHECK_AI_FPCO))
{
tdeTypeInterpret eType=M_GetTypeInterpret(p_stTree);
if((eType!=E_ti_Procedure) &&
(eType!=E_ti_MetaAction) &&
(eType!=E_ti_KeyWord) &&
(eType!=E_ti_Operator) &&
(eType!=E_ti_MacroRef))
{
M_PrintfStopErrorN64(("IntelligenceEvalTreeEngine : not a good node"));
}
}
#endif /* defined(U64) && (!defined(FINAL_VERSION) || defined(D_CHECK_AI_FPCO)) */
//End XB 14/04/99
ComputeActionReturn : /* As life can be simple with some "goto" !!! (this is the last one, I swear it)*/
ucDepthInit = M_DepthInterpret(p_stTree);
M_EvalNextParameter(p_stValue);
ucActionReturn = fn_ucGetActionReturn(p_stValue, p_stTree, ucDepthInit);
if ( (M_TestActionReturn(ucActionReturn,C_TREE_FINISHED))
|| (M_TestActionReturn(ucActionReturn,C_ACTION_CHANGE_COMPORT))
)
{
M_Full_GetSetParam_ActionReturn(p_stValue, ucActionReturn);
return p_stTree;
}
/* Not C_TREE_FINISHED and not C_ACTION_CHANGE_COMPORT.*/
/* ----------------------------------------------------*/
/* Length of life of Action*/
/* ----------------------------------------------------*/
if (M_TestActionReturn(ucActionReturn,C_ACTION_FINISHED))
{
/* remove current rule and action from action table*/
fn_vUnuseCurrentActionTableEntry(g_p_stIntelligence);
}
/* Else this is C_ACTION_NOT_FINISHED and do nothing !*/
/* ----------------------------------------------------*/
/* Influence of Action on evaluation engine*/
/* ----------------------------------------------------*/
if (M_TestActionReturn(ucActionReturn,C_ACTION_ENGINE_STOP))
{
fn_vUnuseAllRulesWhichHaveGreaterNumRule(g_p_stIntelligence,g_ucNRule);
}
else
{
/* Very important : Be careful that C_ACTION_ENGINE_CONTINUE = 0.*/
/* Continue evaluation.*/
if (M_IsTheEndOfTree(p_stTree))
{
ucActionReturn = C_TREE_FINISHED;
}
else
if (!M_TestActionReturn(ucActionReturn,C_ACTION_ENGINE_STOP_RULE))
{
/* Evaluate the next Node.*/
if (ucIsInSchedule)
M_GetCurrentSchedule(g_p_stIntelligence) = p_stTree;
goto ComputeActionReturn;
}
/* else return C_ACTION_ENGINE_STOP_RULE*/
}
M_Full_GetSetParam_ActionReturn(p_stValue, ucActionReturn);
return p_stTree;
}
/*****************************************************************************
* Eval all the rules of Intelligence.
******************************************************************************
* Parameters:
* - p_SuperObjPerso : SuperObject.
* - p_stIntelligence : Intelligence of Perso.
******************************************************************************/
static unsigned char fn_ucIntelligenceRulesEngine(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstIntelligence *p_stIntelligence)
{
char cNRule;
unsigned char ucIndTabAction;
tdstGetSetParam stValue;
unsigned char ucReturn; /* = C_TREE_FINISHED;*/
tdstNodeInterpret *p_stTree;
char cNIntelligenceRule;
unsigned char ucTableNbEntries;
g_p_stIntelligence = p_stIntelligence;
ucIsInSchedule = FALSE;
BeginComport : /* As life can be simple with some "goto" !!! (this is the last one, I swear it)*/
cNIntelligenceRule = (char) (M_GetNbRules(p_stIntelligence)-1);
ucTableNbEntries = M_ActionTableNbEntries(p_stIntelligence);
/* Loop on every rules of Intelligence.*/
for (cNRule = 0; cNRule<= cNIntelligenceRule; cNRule++)
{
g_ucNRule = (unsigned char) (cNRule+1); /* +1 because 0 is take by the Schedule.*/
/* Oliv' -*/
#ifdef U64_AIDEBUG
AIDebug_M_SetCurrentRule( AI_M_stGetMindOfSuperObj(p_SuperObjPerso), g_ucNRule );
#endif
/* EndOfOliv'*/
/*-----------------------------*/
/* Deal with the Action Table.*/
/*-----------------------------*/
ucIndTabAction = fn_ucIsRuleInActionTable(p_stIntelligence, g_ucNRule);
if (ucIndTabAction < ucTableNbEntries)
p_stTree = fn_p_stGetTableAction(p_stIntelligence, ucIndTabAction);
else
p_stTree = M_GetNodeInterpretN(M_GetRuleN(p_stIntelligence, cNRule), 0);
/* Eval the current rule.*/
p_stTree = fn_p_stIntelligenceEvalTreeEngine(p_SuperObjPerso, p_stTree, &stValue);
ucReturn = (unsigned char) M_GetSetParam_ActionReturnValue(&stValue);
if (M_TestActionReturn(ucReturn,C_ACTION_ENGINE_STOP))
{
return C_ACTION_ENGINE_STOP;
}
if (M_TestActionReturn(ucReturn,C_ACTION_CHANGE_COMPORT))
{
//XB 12/04/99
//#if defined(__DEBUG_AI__)
#if defined(__DEBUG_AI__) || defined(TEST_CYCLING_COMPORT)
//End XB
if (fn_ucTestCycleComport(p_SuperObjPerso,g_p_stIntelligence))
return (C_ACTION_ENGINE_STOP | C_ACTION_CHANGE_COMPORT);
//XB 12/04/99
//#endif /* __DEBUG_AI__*/
#endif /* __DEBUG_AI__ || TEST_CYCLING_COMPORT */
//End XB
bSomethingDone = FALSE;
goto BeginComport;
}
if (!M_TestActionReturn(ucReturn, C_TREE_FINISHED))
return C_ACTION_ENGINE_CONTINUE;
/* If this is C_ACTION_ENGINE_STOP_RULE then continue the loop.*/
}
return C_ACTION_ENGINE_CONTINUE;
}
/*****************************************************************************
* Eval all the Schedule of Intelligence.
******************************************************************************
* Parameters:
* - p_SuperObjPerso : SuperObject.
* - p_stIntelligence : Intelligence of Perso.
******************************************************************************/
static unsigned char fn_ucIntelligenceScheduleEngine(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstIntelligence *p_stIntelligence)
{
/* Modif YLG */
tdstNodeInterpret *p_stTree;
unsigned char ucIndTabAction;
tdstGetSetParam stValue;
unsigned char ucReturn;
g_p_stIntelligence = p_stIntelligence;
ucIsInSchedule = TRUE;
p_stTree = M_GetCurrentSchedule(p_stIntelligence);
if (p_stTree == NULL)
/* There is no Schedule.*/
return C_TREE_FINISHED;
g_ucNRule = 0; /* 0 is reserved for the schedule.*/
/*-----------------------------*/
/* Deal with the Action Table.*/
/*-----------------------------*/
ucIndTabAction = fn_ucIsRuleInActionTable(p_stIntelligence, g_ucNRule);
if (ucIndTabAction < M_ActionTableNbEntries(p_stIntelligence))
{
p_stTree = fn_p_stGetTableAction(p_stIntelligence, ucIndTabAction);
}
/* This is the end of schedule*/
if (M_IsTheEndOfTree(p_stTree))
{
p_stTree=M_GetTreeComportSchedule(M_GetCurrentComport(p_stIntelligence));
}
/* Eval Shedule.*/
p_stTree = fn_p_stIntelligenceEvalTreeEngine(p_SuperObjPerso, p_stTree, &stValue);
ucReturn = (unsigned char) M_GetSetParam_ActionReturnValue(&stValue);
if (M_TestActionReturn(ucReturn,C_ACTION_CHANGE_COMPORT))
{
//XB 12/04/99
//#if defined(__DEBUG_AI__)
#if defined(__DEBUG_AI__) || defined(TEST_CYCLING_COMPORT)
//End XB
if (fn_ucTestCycleComport(p_SuperObjPerso,g_p_stIntelligence))
return (C_ACTION_ENGINE_STOP | C_ACTION_CHANGE_COMPORT);
//XB 12/04/99
//#endif /* __DEBUG_AI__*/
#endif /* __DEBUG_AI__ || TEST_CYCLING_COMPORT */
//End XB
}
if ( (!M_TestActionReturn(ucReturn,C_ACTION_CHANGE_COMPORT))
&& (!M_TestActionReturn(ucReturn,C_ACTION_ENGINE_STOP_RULE))
)
{
M_GetCurrentSchedule(p_stIntelligence) = p_stTree;
}
return ucReturn;
}
/*****************************************************************************
* Compute Schedule Interruption : Find where schedule has to restart !!!!!
******************************************************************************
* Parameters:
* - p_stIntelligence : Intelligence of Perso.
******************************************************************************/
static void fn_vComputeScheduleInterrupt(tdstIntelligence *p_stIntelligence)
{
/* YLG MODIF*/
unsigned char ucIndTabAction = fn_ucIsRuleInActionTable(p_stIntelligence, 0);
/* check if an action from schedule is in action table*/
if (ucIndTabAction < M_ActionTableNbEntries(p_stIntelligence))
{
/* Reinit schedule at the beginning of the found action */
M_GetCurrentSchedule(p_stIntelligence) = fn_p_stGetTableAction(p_stIntelligence, ucIndTabAction);
/* Remove all actions started during schedule before interruption*/
fn_vUnuseAllRulesFromSchedule(p_stIntelligence);
}
}
int iStopOn = 793;
int iCurrentIntell = 0;
/* Return TRUE if a MetaAction (no immediate) have been done.*/
ACP_tdxBool fn_bIntelligenceEngine(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstIntelligence *p_stIntelligence)
{
/* Modif ylg*/
ACP_tdxBool ReturnValue = FALSE;
unsigned char ucReturn;
#if (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG)
fn_v_SetCurrentMind(AI_M_stGetMindOfSuperObj(p_SuperObjPerso));
#if !defined(U64_AIDEBUG) /* Oliv' - 23/11/1998*/
if ((AI_M_ucErrorFlag(AI_M_stGetMindOfSuperObj(p_SuperObjPerso))) || fn_ucGetStopAIEngineFlag())
{
return FALSE;
}
#endif /* !defined(U64_AIDEBUG) */
#endif /* (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG) */
{
MS_tdxHandleToStandardGame hStdGame;
if ((hStdGame = M_GetMSHandle(p_SuperObjPerso,StandardGame)) != NULL )
{
iCurrentIntell = fn_otStandardGameGetPersonalType(hStdGame);
// Generate some harmless code so can place a breakpoint
if (iCurrentIntell == iStopOn)
ReturnValue = FALSE;
}
}
//XB 12/04/99
//#if defined(__DEBUG_AI__)
#if defined(__DEBUG_AI__) || defined(TEST_CYCLING_COMPORT)
//End XB
/* Debug cycling comport*/
/* init first comportement at the current frame*/
g_cNbComportSeen = 1;
g_a_p_stComport[0].p_stComport = M_GetCurrentComport(p_stIntelligence);
g_a_p_stComport[0].cNbFoundComport = 1;
//XB 12/04/99
//#endif /* __DEBUG_AI__*/
#endif /* __DEBUG_AI__ || TEST_CYCLING_COMPORT */
//End XB
do
{
/* do rules*/
bSomethingDone = FALSE;
ucReturn = fn_ucIntelligenceRulesEngine(p_SuperObjPerso, p_stIntelligence);
if (!M_TestActionReturn(ucReturn,C_ACTION_CHANGE_COMPORT))
{
/* if something was done in rules dynamics (if schedule has been interrupted)*/
/* or has found stop engine action */
if ( M_TestActionReturn(ucReturn,C_ACTION_ENGINE_STOP)
|| bSomethingDone)
/* Find where schedule has to restart !!!!!*/
fn_vComputeScheduleInterrupt(p_stIntelligence);
else
/* Schedule has not been interrupted by rules so do schedule.*/
ucReturn = fn_ucIntelligenceScheduleEngine(p_SuperObjPerso, p_stIntelligence);
}
ReturnValue |= bSomethingDone;
}
while ( M_TestActionReturn(ucReturn,C_ACTION_CHANGE_COMPORT)
&& !M_TestActionReturn(ucReturn,C_ACTION_ENGINE_STOP)
);
/* Oliv' - we need a bigger message - 13/01/1999*/
#ifndef U64
SAF_M_AssertWithMsg(iNumLoop == 0, "Boucle d'IA non termin<69>e en fin de trame...");
#else
#if !defined(RETAIL) || defined(USE_MONITOR)
{
char szTxt[64];
MS_tdxHandleToStandardGame hStdGame;
if( (hStdGame = M_GetMSHandle(p_SuperObjPerso,StandardGame)) != NULL )
sprintf( szTxt, "Boucle d'IA non terminee\nPerso %d", (int)fn_otStandardGameGetPersonalType(hStdGame) );
else
sprintf( szTxt, "Boucle d'IA non terminee\nPerso sans StdGame" );
SAF_M_AssertWithMsg( iNumLoop == 0, szTxt );
}
#endif
#endif
/* EndOfOliv'*/
return ReturnValue;
}