Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

View File

@@ -0,0 +1,227 @@
/*///////////////////*/
/* macro for Error //*/
/*///////////////////*/
#ifndef __AIMACROS_H__
#define __AIMACROS_H__
#if defined(__DEBUG_AI__)
#define D_MmgAITestBeforeFree
#endif
#ifdef __FATAL_ERR_AI__
/* This allow us to save about 600 Ko in the release lib
#define M_AIFatalError(FatalErrorNum) \
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, FatalErrorNum, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);
#define M_AIFatalErrorMsg(FatalErrorNum,szMsg) \
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, FatalErrorNum, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, szMsg);
*/
void fn_vOnAIErm_M_UpdateLastError(unsigned short FatalErrorNum,char *szMsg);
#define M_AIFatalErrorMsg(FatalErrorNum,szMsg) fn_vOnAIErm_M_UpdateLastError(FatalErrorNum,szMsg)
#define M_AIFatalError(FatalErrorNum) M_AIFatalErrorMsg(FatalErrorNum,NULL)
#else /*__FATAL_ERR_AI__*/
#define M_AIFatalError(FatalErrorNum) /*nothing to do*/
#define M_AIFatalErrorMsg(FatalErrorNum,szMsg) /*nothing to do*/
#endif /*__FATAL_ERR_AI__*/
#ifdef __WARNING_ERR_AI__
#define M_AIWarningError(ErrorNum, ucOpenInfoWindow)\
/* ----------------*/\
{ \
if (ErrorNum > E_uwAIStartOfWarning) \
{ \
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, ErrorNum, C_lErmNoDebugData, ucOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
} \
else \
{ \
M_AIFatalError(E_uwAIFatalNotAFatalError);\
} \
}
#else /*__WARNING_ERR_AI__ */
//XB 10/08/99
#define M_AIWarningError(ErrorNum, uwOpenInfoWindow)/*\
{ \
if (ErrorNum < E_uwAIStartOfWarning) \
M_AIFatalError(E_uwAIFatalNotAFatalError);\
}*/
#endif /*__WARNING_ERR_AI__ */
#ifdef __WARNING_ERR_AI__
#define M_AIWarningErrorAndAllowStopForDebug(ErrorNum, ucOpenInfoWindow, szMytxt)\
/* ----------------*/\
{ \
if (ErrorNum > E_uwAIStartOfWarning) \
{ \
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, ErrorNum, C_lErmNoDebugData, ucOpenInfoWindow, C_ucAllowStopForDebug, szMytxt);\
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
} \
else \
{ \
M_AIFatalError(E_uwAIFatalNotAFatalError);\
} \
}
#define M_AIWarningErrorAndNeverStopForDebug(ErrorNum, ucOpenInfoWindow, szMytxt)\
/* ----------------*/\
{ \
if (ErrorNum > E_uwAIStartOfWarning) \
{ \
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, ErrorNum, C_lErmNoDebugData, ucOpenInfoWindow, C_ucNeverStopForDebug, szMytxt);\
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
} \
else \
{ \
M_AIFatalError(E_uwAIFatalNotAFatalError);\
} \
}
#else /*__WARNING_ERR_AI__ */
//XB 10/08/99
#define M_AIWarningErrorAndAllowStopForDebug(ErrorNum, uwOpenInfoWindow, szMytxt)/*\
{ \
if (ErrorNum < E_uwAIStartOfWarning) \
M_AIFatalError(E_uwAIFatalNotAFatalError);\
}*/
//XB 10/08/99
#define M_AIWarningErrorAndNeverStopForDebug(ErrorNum, uwOpenInfoWindow, szMytxt)/*\
{ \
if (ErrorNum < E_uwAIStartOfWarning) \
M_AIFatalError(E_uwAIFatalNotAFatalError);\
}*/
#endif /*__WARNING_ERR_AI__ */
#ifdef __FATAL_ERR_AI__
#define M_AIIfErrorUpdateFatalError(UsedModule, ErrorNum)\
/* ---------------------------*/\
if (Erm_M_uwCheckError(UsedModule, C_ucErmDefaultChannel)){\
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
M_AIFatalError(ErrorNum);\
}
#else /*__FATAL_ERR_AI__ */
#define M_AIIfErrorUpdateFatalError(UsedModule, ErrorNum) /*nothing to do*/
#endif /*__FATAL_ERR_AI__*/
#ifdef __WARNING_ERR_AI__
#define M_AIIfErrorUpdateWarningError(UsedModule, ErrorNum, uwOpenInfoWindow)\
/* -----------------------------*/\
if (Erm_M_uwCheckError(UsedModule, C_ucErmDefaultChannel)){\
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
M_AIWarningError(ErrorNum, uwOpenInfoWindow);\
}
#else /*__WARNING_ERR_AI__*/
#define M_AIIfErrorUpdateWarningError(UsedModule, ErrorNum, uwOpenInfoWindow) /*nothing to do*/
#endif /*__WARNING_ERR_AI__*/
/* ALB January 1997 */
#ifdef __DEBUG_AI__
#define M_AI_DEBUG_ASSERT(bCond,ErrorRaised)\
if(!(bCond))\
{\
M_AIFatalError(ErrorRaised);\
}
#define M_AI_DEBUG_ASSERT_WARNING(bCond,ErrorRaised)\
if(!(bCond))\
{\
M_AIWarningError(ErrorRaised, C_ucErmNoOpenInfoWindow); \
}
#define M_AI_MemSet(pBuffer,cCharToSet,ucSizeOfMem)\
if(pBuffer)\
{\
memset(pBuffer,cCharToSet,ucSizeOfMem);\
}
#else /*__DEBUG_AI__*/
#define M_AI_DEBUG_ASSERT(bCond,ErrorRaised)
#define M_AI_DEBUG_ASSERT_WARNING(bCond,ErrorRaised)
#define M_AI_MemSet(pBuffer,cCharToSet,ucSizeOfMem)
#endif /*__DEBUG_AI__*/
/* ALB END */
/*////////////////////*/
/* macro for Memory //*/
/*////////////////////*/
#define MODE_STATIC_MEM_FOR_AI
#ifdef MODE_STATIC_MEM_FOR_AI
#define M_AIChooseMemoryBlock() Mmg_M_SetModeAlloc4Ch(AI,(unsigned char)AI_g_ucMemoryBlockUsed,C_ucMmgDefaultChannel)
#else
#define M_AIChooseMemoryBlock() Mmg_M_SetModeAlloc4Ch(AI,E_ucDynamic,C_ucMmgDefaultChannel)
#endif /* MODE_STATIC_MEM_FOR_AI*/
void fn_vErrorOnAIAlloc(void);
/*M_AIIfErrorUpdateFatalError(Mmg, E_uwAIFatalFailedAllocationMem);*/
void fn_vErrorOnAIFree(void);
/*M_AIIfErrorUpdateWarningError (Mmg, E_uwAIWarningCanNotFree, C_ucErmOpenInfoWindow);*/
/* M_AIChooseMemoryBlock();*/
/* Var = (cast) Mmg_fn_p_vAlloc4Ch(ucSize,C_ucMmgDefaultChannel);*/
#ifndef U64
#define M_AIAlloc(Var, cast, ucSize)\
{\
Var = (cast)AI_fn_p_vTrueAlloc(ucSize);\
AI_fn_vMemoryLogFile(Var,AI_C_ActionMalloc,__FILE__,__LINE__); \
fn_vErrorOnAIAlloc(); \
}
#else /* !U64 */
#define M_AIAlloc(Var, cast, ucSize)\
{\
Var = (cast)AI_fn_p_vTrueAlloc(ucSize);\
fn_vErrorOnAIAlloc(); \
}
#endif /* !U64 */
/* M_AIChooseMemoryBlock();*/
/* Var = (cast) Mmg_fn_p_vRealloc4Ch(AdrScr,ucSize,C_ucMmgDefaultChannel);*/
#ifndef U64
#define M_AIReAlloc(Var,AdrScr,cast, ucSize)\
{\
Var = (cast) AI_fn_p_vTrueRealloc(AdrScr,ucSize);\
AI_fn_vMemoryLogFile(Var,AI_C_ActionRealloc,__FILE__,__LINE__); \
fn_vErrorOnAIAlloc(); \
}
#else /* !U64 */
#define M_AIReAlloc(Var,AdrScr,cast, ucSize)\
{\
Var = (cast) AI_fn_p_vTrueRealloc(AdrScr,ucSize);\
fn_vErrorOnAIAlloc(); \
}
#endif /* !U64 */
/* M_AIChooseMemoryBlock();*/
/* Mmg_fn_vFree4Ch(p_cAdr,C_ucMmgDefaultChannel);*/
#ifndef U64
#define M_AIFree(p_cAdr) \
{\
AI_fn_vMemoryLogFile(p_cAdr,AI_C_ActionFree,__FILE__,__LINE__); \
AI_fn_vTrueFree(p_cAdr);\
fn_vErrorOnAIFree(); \
p_cAdr=NULL; \
}
#else /* !U64 */
#define M_AIFree(p_cAdr) \
{\
AI_fn_vTrueFree(p_cAdr);\
fn_vErrorOnAIFree(); \
p_cAdr=NULL; \
}
#endif /* !U64 */
#endif /* __AIMACROS_H__*/

View File

@@ -0,0 +1,89 @@
/*---------------------------------------------------------------------------*/
/* AIUseCPA.h : CPA include for AI.*/
/* auteur : Olivier Didelot.*/
/* date : 28/01/1997*/
/*---------------------------------------------------------------------------*/
#ifndef __AIUSECPA_H__
#define __AIUSECPA_H__
/****************************************
* Here is the list of disabled WARNING *
****************************************/
#if defined(VISUAL)
/*#pragma warning(disable:4010) // single-line comment contains line-continuation character **/
/*#pragma warning(disable:4702) // unreachable code */
#pragma warning(disable:4244) /* conversion from 'type1' to 'type2', possible loss of data **/
#pragma warning(disable:4514) /* unreferenced inline function has been removed*/
#pragma warning(disable:4201) /* nonstandard extension used : nameless struct/union*/
#pragma warning(disable:4127) /* conditional expression is constant*/
#pragma warning(disable:4214) /* nonstandard extension used : bit field types other than int*/
#pragma warning(disable:4115) /* named type definition in parentheses*/
#if !defined(__cplusplus)
#pragma warning(disable:4032) /* formal parameter 1 has different type when promoted*/
#endif
#pragma warning(disable:4206) /* nonstandard extension used : translation unit is empty*/
#endif /*VISUAL*/
#include "ACP_Base.h"
#include "GMT.h"
#include "MMG.h" /* MemoryManaGer*/
#include "ERM.h" /* ErrorManager*/
#include "SCR.h" /* SCRipt*/
#include "GEO.h"
#include "GLI.h"
#include "COL.h"
#include "SPO.h" /*"Hie.h"*/
#include "MEC.h" /* Mechanic*/
#include "LST.h" /* LiST*/
#ifdef USE_IPT_DX5
#include "IPT_DX5.h" /* InPuT (absolutely before GAM.h)*/
#else /* USE_IPT_WIN */
#include "IPT.h" /* InPuT (absolutely before GAM.h)*/
#endif /* USE_IPT_WIN */
#include "PCS.h" /* Physical Collide Set */
#include "RND.h" /* RaNDom*/
/*XB980428*/
/*#include "VIG.h" // Vignette*/
/*End XB*/
/* Shaitan Clean Env {*/
/*#include "SRF.h" // Surface*/
/* End Shaitan Clan Env }*/
/*#include "FON.h" // Font*/
#include "SND.h" /* SND*/
#define ENV_FRIEND
/* Shaitan Clean Env {*/
/*#include "ENV.h" // ENV*/
/* End Shaitan Clan Env }*/
#include "SCT.h" /* SeCTor*/
#include "FIL.h" /* SeCTor*/
/* in order to compile AI in C++ and link with GAM in C*/
#if defined(__cplusplus)
extern "C"
{
#endif
#ifndef D_THROW_PRT
#include "PRT.h"
#endif /* D_THROW_PRT */
#include "GAM.h" /* GAMe*/
#ifndef U64
#include "DPT.h" /* DataPaTh*/
#endif
#if defined(__cplusplus)
}
#endif
/*#ifdef AI_USE_BINARY*/
/*#include "BIN.h" */
/*#endif /* AI_USE_BINARY */
#include "HDL.h"
#include "SAI.h"
/*#include "cpa_std.h"*/
#undef EXTERN
#undef extern
#endif /* __AIUSECPA_H__*/

View File

@@ -0,0 +1,281 @@
/*///////////////////////////////////////////////////////////*/
/* //*/
/* Management of the Module : AI (Intelligence) //*/
/* //*/
/*///////////////////////////////////////////////////////////*/
/* //*/
/* abbreviation of the module-name. Used in macro is 'AI' //*/
/* //*/
/*///////////////////////////////////////////////////////////*/
#ifndef __ERRAI_H__
#define __ERRAI_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define C_szAIVersion "AI V5.0.0" /* The format is XXX Va.b.c with Xxx is the Tag of the module */
#define C_szAIFullName "Artificial Intelligence"/* the complete and clear name of the module */
#define C_szAIDate "Dec 5 1997" /*The format is "Mmm dd yyyy".You can use __DATE__ but be careful that you have the control of the compilation*/
#ifndef __ERM_H__
#include "ERM.h"
#endif /*__ERM_H__*/
/*----------*/
/* Constant*/
/*----------*/
/* error of the AI Module*/
typedef enum e_uwAIErrNumber_{
E_uwAIFatalErr = 0,
#ifdef __FATAL_ERR_AI__
/* -----------------*/
E_uwAIFatalNotAFatalError,
E_uwAIFatalTooMuchCond,
E_uwAIFatalTooMuchAction,
E_uwAIFatalTooMuchParamCond,
E_uwAIFatalTooMuchParamAction,
E_uwAIFatalNoEltInStackCond,
E_uwAIFatalTooMuchEltInStackCond,
E_uwAIFatalWrongParamCond,
E_uwAIFatalWrongParamAction,
E_uwAIFatalNotValidField,
E_uwAIFatalInvalidAction,
E_uwAIFatalFailedAllocationMem,
E_uwAIFatalWrongTypeVar,
E_uwAIFatalPersoListFull,
E_uwAIFatalPbPersoListInsert,
E_uwAIFatalPbDeleteInPersoList,
E_uwAIFatalUnknownFieldName,
E_uwAIFatalUnknownFunc,
/*E_uwAIFatalUnknownFuncList,*/
E_uwAIFatalUnknownProcedure,
E_uwAIFatalUnknownCond,
E_uwAIFatalNotValidPriority,
E_uwAIFatalUnknownKeyWord,
E_uwAIFatalTooMuchNode,
E_uwAIActionTableTooSmall,
E_uwAIBadLeftInAffectation,
E_uwAIFatalBadComportNumber,
E_uwAIFatalBadNodeNumber,
E_uwAIFatalBadRuleNumber,
E_uwAIFatalNodeNotInRule,
E_uwAIFatalRuleNotInComport,
E_uwAIFatalComportNotInIntelligence,
E_uwAIFatalCantFindPerso,
E_uwAIFatalUnknownNode,
E_uwAIFatalInvalidAccessToField,
E_uwAIFatalInvalidAccessToDsgVar,
E_uwAIFatalInvalidAccessToFieldOrDsgVar,
E_uwAIFatalNotAGoodAction,
E_uwAIFatalWrongTypeParamAction,
E_uwAIFatalNotValidFunction,
E_uwAIFatalNotValidProcedure,
E_uwAIFatalNotValidDsgVarId,
E_uwAIFatalNotValidOperator,
E_uwAIFatalNotValidCondition,
E_uwAIFatalUnknownOperator,
E_uwAIFatalInvalidParameter,
E_uwAIFatalInvalidWPValue,
E_uwAIFatalArrayAlreadyFull,
E_uwAIFatalArrayEmpty,
E_uwAIFatalAssertionFailure,
E_uwAIFatalTypeLinkInvalid,
E_uwAIFatalDynTypeLinkInvalid,
E_uwAIFatalWayPositionInvalid,
E_uwAIFatalWayFirstLinkMustBeLine,
E_uwAIFatalNullVectorNotAllowed,
E_uwAIFatalBadEntryAIModel,
E_uwAIWrongOperatorInLeftAffect,
E_uwAIDivisionByZero,
E_uwAIFatalNoDynamics,
E_uwAIFatalUnknownButton,
E_uwAIFatalReferenceNotLoaded,
E_uwAIFatalScriptError,
E_uwAIFatalNotMSCamera,
E_uwAIFatalInvalidUseOfUltraOperator,
E_uwAIFatalInvalidModelCast,
E_uwAIFatalInvalidDsgvarSaveType,
#endif /*__FATAL_ERR_AI__*/
E_uwAIStartOfWarning,/* important constant, it allows to recognize if an error is fatal or not.*/
#ifdef __WARNING_ERR_AI__
/* -------------------*/
E_uwAIWarningCanNotFree,/*!!y*/
E_uwAIWarningTruncateAffectation,/*!!y*/
E_uwAIWarningBadType,
E_uwAIWarningChangeToCurrentComport,
E_uwAIWarningCycleComport,
E_uwAIWarningArrayCyclingComportTooSmall,
E_uwAIWarningExecuteActionInt,
E_uwAIWarningComportOfAnotherPerso,
E_uwAIDebugDynamicAllocation,
E_uwAIWarningScriptError,
E_uwAIWarningEngineGoto,
E_uwAIWarningChannelNotControlled, /*ANNECY BBB: is fatal for engine, but not in editor mode*/
#if defined(ACTIVE_EDITOR)
E_uwAIWarningUnknownCond,
E_uwAIWarningUnknownFieldName,
E_uwAIWarningUnknownOperator,
E_uwAIWarningUnknownFunc,
E_uwAIWarningUnknownProcedure,
E_uwAIWarningUnknownKeyWord,
E_uwAIWarningInvalidAction,
E_uwAIWarningUnknownNode,
E_uwAIWarningReferenceNotLoaded,
E_uwAIWarningWrongParamAction,
E_uwAIWarningInvalidUseOfUltraOperator,
E_uwAIWarningWrongTypeVar,
#endif
#endif /*__WARNING_ERR_AI__*/
E_uwAIErrNumber
} e_uwAIErrNumber;
/*------------------*/
/* Global Variables*/
/*------------------*/
#undef EXTERN_ERRAI
#undef extern
#ifndef __DeclareGlobalVariableErrAI_h__
#define EXTERN_ERRAI extern /*external declaration*/
#else /*__DeclareGlobalVariableErrAI_h__*/
#define EXTERN_ERRAI /*replace by nothing : we have to declare*/
#endif /*__DeclareGlobalVariableErrAI_h__*/
EXTERN_ERRAI unsigned char g_ucAIModuleId /*number of identification of the Erm module*/
#ifdef __DeclareGlobalVariableErrAI_h__
= C_ucModuleNotInitialized
#endif /*__DeclareGlobalVariableErrAI_h__*/
;
#ifdef __ERROR_STRINGS__
EXTERN_ERRAI char * g_a_szAIInformationModule []
#if defined(__DeclareGlobalVariableErrAI_h__) && !defined(CPA_WANTS_IMPORT)
= {C_szAIVersion, C_szAIFullName, C_szAIDate}
#endif /*__DeclareGlobalVariableErrAI_h__ && CPA_WANTS_IMPORT*/
;
EXTERN_ERRAI char * g_szAIModuleName /* Obliged syntax 'g_sz'+[Abbreviation of ModuleName]+'ModuleName'*/
#ifdef __DeclareGlobalVariableErrAI_h__
= "Module AI"
#endif /*__DeclareGlobalVariableErrAI_h__*/
;
EXTERN_ERRAI /*struct!!y!!*/ tdstErrorMsg/*_!!y!!*/ g_a_stAITabErr [] /* Obliged syntax 'g_a_st'+[Abbreviation of ModuleName]+'TabErr'*/
#ifdef __DeclareGlobalVariableErrAI_h__/*Call from main program*/
={
#ifdef __FATAL_ERR_AI__
/* -------------*/
E_uwAIFatalNotAFatalError, "This is not a valide AI fatal error",
E_uwAIFatalTooMuchCond, "Too much Conditions Loaded",
E_uwAIFatalTooMuchAction, "Too much Actions Loaded",
E_uwAIFatalTooMuchParamCond, "Too much parameters for the Condition",
E_uwAIFatalTooMuchParamAction, "Too much parameters for the Action",
E_uwAIFatalNoEltInStackCond, "There is no element in condition stack",
E_uwAIFatalTooMuchEltInStackCond, "Too much elements in condition stack",
E_uwAIFatalWrongParamCond, "Wrong number of parameter in the Condition",
E_uwAIFatalWrongParamAction, "Wrong number of parameter",
E_uwAIFatalNotValidField, "Wrong field in perso struct",
E_uwAIFatalInvalidAction, "Invalid action",
E_uwAIFatalFailedAllocationMem, "Problem during an allocation memory",
E_uwAIFatalWrongTypeVar, "Script Read Problem: The type of the variable is not valid",
E_uwAIFatalPersoListFull, "The Perso List is Full",
E_uwAIFatalPbPersoListInsert, "The insert position in the Perso List is not available",
E_uwAIFatalPbDeleteInPersoList, "Wrong specified position in the Perso list! Can not delete the perso",
E_uwAIFatalUnknownFieldName, "Unknown Field Name",
E_uwAIFatalUnknownFunc, "Unknown Function Name",
E_uwAIFatalUnknownProcedure, "Unknown Procedure name",
E_uwAIFatalUnknownCond, "Unknown Condition Name",
E_uwAIFatalNotValidPriority, "Priority of rule must be greater than 0",
E_uwAIFatalUnknownKeyWord, "Unknown KeyWord Name",
E_uwAIFatalTooMuchNode, "Too much Node Interpret Loaded",
E_uwAIActionTableTooSmall, "Action table is too small",
E_uwAIBadLeftInAffectation, "Bad Type for left operand in affectation",
E_uwAIFatalBadComportNumber,"Bad comportment number",
E_uwAIFatalBadNodeNumber,"Bad node number",
E_uwAIFatalBadRuleNumber,"Bad rule number",
E_uwAIFatalNodeNotInRule,"CreateNode section not in CreateRule section",
E_uwAIFatalRuleNotInComport,"CreateRule section not in CreateComport section",
E_uwAIFatalComportNotInIntelligence,"CreateComport section not in CreateIntelligence section",
E_uwAIFatalCantFindPerso, "Can't find perso",
E_uwAIFatalUnknownNode,"Unknown node",
E_uwAIFatalInvalidAccessToField, "Invalid access to field",
E_uwAIFatalInvalidAccessToDsgVar,"Invalid access to dsgvar",
E_uwAIFatalInvalidAccessToFieldOrDsgVar,"Invalid access to dsgvar or field",
E_uwAIFatalNotAGoodAction, "Not a good action to change to",
E_uwAIFatalWrongTypeParamAction, "Wrong type for action's parameter",
E_uwAIFatalNotValidFunction, "This is not a valid Function",
E_uwAIFatalNotValidProcedure, "This is not a valid Procedure",
E_uwAIFatalNotValidDsgVarId, "Wrong Variable Designer ID",
E_uwAIFatalNotValidOperator, "This is not a valid operator",
E_uwAIFatalNotValidCondition, "This is not a valid condition",
E_uwAIFatalUnknownOperator, "Unknown operator",
E_uwAIFatalInvalidParameter,"A function parameter is invalid",
E_uwAIFatalInvalidWPValue, "WP handle is invalid",
E_uwAIFatalArrayAlreadyFull,"Attempt to add an element to the array though it is already full",
E_uwAIFatalArrayEmpty,"Attempt to access to an element in the array though it is empty",
E_uwAIFatalAssertionFailure,"Assertion failure",
E_uwAIFatalTypeLinkInvalid,"The type of the link is invalid",
E_uwAIFatalDynTypeLinkInvalid,"The dynamic type of the link is invalid",
E_uwAIFatalWayPositionInvalid,"The position specified for the access of a WP or a link in the way is invalid",
E_uwAIFatalWayFirstLinkMustBeLine,"The first link must be a line (only for mode NbrOfLink = NbrOf WP)",
E_uwAIFatalNullVectorNotAllowed,"Null vector is not allowed for this function",
E_uwAIFatalBadEntryAIModel, "Bad entry in AIModel Script",
E_uwAIWrongOperatorInLeftAffect, "Wrong operator in left parameter of affect function",
E_uwAIDivisionByZero,"Division by zero",
E_uwAIFatalNoDynamics, "No Dynamics found",
E_uwAIFatalUnknownButton, "Button not defined",
E_uwAIFatalReferenceNotLoaded,"Reference not loaded",
E_uwAIFatalScriptError, "There was an error in the script",
E_uwAIFatalNotMSCamera, "Super Object is not a camera",
E_uwAIFatalInvalidUseOfUltraOperator, "Invalid use of Ultra operator",
E_uwAIFatalInvalidModelCast,"Invalid model cast",
E_uwAIFatalInvalidDsgvarSaveType,"Invalid save type for designer variable",
#endif /*__FATAL_ERR_AI__*/
#ifdef __WARNING_ERR_AI__
/* ----------------*/
E_uwAIWarningCanNotFree, "Memory problem for free",
E_uwAIWarningTruncateAffectation, "Strange a (out of range) designer variable has been truncated ",
E_uwAIWarningBadType,"Field or variable designer have not correct type to store the passed value",
E_uwAIWarningChangeToCurrentComport, "Change comport to the same comport",
E_uwAIWarningCycleComport, "Cycle in comportement changing",
E_uwAIWarningArrayCyclingComportTooSmall, "The array for cycling comport is too small",
E_uwAIWarningExecuteActionInt, "The execute action has interrupted",
E_uwAIWarningComportOfAnotherPerso,"This comport doesn't belong to perso",
E_uwAIDebugDynamicAllocation,"Debug version : dynamic allocation in bloc AI (don't forget to increase the bloc)",
E_uwAIWarningScriptError ,"This is a warning about AI script",
E_uwAIWarningEngineGoto,"Wrong use of EngineGoto",
E_uwAIWarningChannelNotControlled, "Call of a repositionning procedure on an uncontrolled channel",
#if defined(ACTIVE_EDITOR) /* usefull for ACTIVE_1STPASS_CHECKING*/
E_uwAIWarningUnknownCond ,"Unknown Condition Name",
E_uwAIWarningUnknownFieldName ,"Unknown Field Name",
E_uwAIWarningUnknownOperator ,"Unknown Operator Name",
E_uwAIWarningUnknownFunc ,"Unknown Function Name",
E_uwAIWarningUnknownProcedure ,"Unknown Procedure name",
E_uwAIWarningUnknownKeyWord ,"Unknown Keyword name",
E_uwAIWarningInvalidAction ,"Unknown Action name",
E_uwAIWarningUnknownNode ,"Unknown Node",
E_uwAIWarningReferenceNotLoaded,"Reference not loaded",
E_uwAIWarningWrongParamAction ,"Wrong number of parameter",
E_uwAIWarningInvalidUseOfUltraOperator,"Invalid use of Ultra operator",
E_uwAIWarningWrongTypeVar ,"Script Read Problem: The type of the variable is not valid",
#endif
#endif /*__WARNING_ERR_AI__*/
0xFFFF, "\0"/*fin*/
};
#endif /*__DeclareGlobalVariableErrAI_h__*/
;
#undef extern
#endif /*__ERROR_STRINGS__*/
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /*__ERRAI_H__*/

View File

@@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*/
/* AIFunct.c : */
/* author : Olivier Didelot.*/
/* date : 30/01/1997*/
/*---------------------------------------------------------------------------*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "AI_Struc.h"
#include "AI_Funct.h"
char* AI_fn_pszGetActorName (HIE_tdxHandleToSuperObject hSupObj)
{
AI_tdxHandleToMind hMind;
if (!M_GetMSHandle((hSupObj), Brain)) return NULL;
hMind = AI_M_stGetMindOfSuperObj (hSupObj);
if (!hMind) return NULL;
return AI_M_szGetPersoName(hMind);
}
char* AI_fn_pszGetFamilyName (HIE_tdxHandleToSuperObject hSupObj, char* szBuffer)
{
MS_tdxHandleTo3dData h_3dData;
tdxHandleToState hInitialState;
char cCar;
long lCounter;
h_3dData = M_GetMSHandle(hSupObj,3dData);
if (!h_3dData) return NULL;
hInitialState = fn_h3dDataGetInitialState (h_3dData);
if (!hInitialState) return NULL;
strcpy ( szBuffer, fn_p_szGetStateName(hInitialState) );
for (lCounter=0 ;; lCounter++)
{
cCar = szBuffer[lCounter];
if (cCar==0) return NULL;
if (cCar==' ')
{
szBuffer[lCounter]=0;
return szBuffer;
}
}
return NULL;
}

View File

@@ -0,0 +1,51 @@
/*///////////////////////////////////////////////////////////*/
/* //*/
/* Memory Management of the Module : AI //*/
/* // */
/* File Name : MmgAI.h //*/
/* Date : 703/10/96 //*/
/* Author : First_Name Last_Name //*/
/* //*/
/*///////////////////////////////////////////////////////////*/
/****************************************/
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
/****************************************/
#ifndef __MmgAI_H__
#define __MmgAI_H__
enum e_ucAIStaticBlocks
{
E_ucAIBlockFix,
E_ucAIBlockLevel,
E_ucAIMaxBlocksNb /* maximum number of static block, You have to follow this syntax 'E_uc+ Abbreviation Module +MaxBlocksNb'*/
};
#undef EXTERN_MEMAI
#undef extern
#ifdef __DeclareGlobalVariableMmgAI_h__
#define EXTERN_MEMAI /*nothing*/
#else /* no __DeclareGlobalVariableMmgAI_h__*/
#define EXTERN_MEMAI extern
#endif /*__DeclareGlobalVariableMmgAI_h__*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
EXTERN_MEMAI CPA_EXPORT tdstBlockInfo g_a_stAIBlocksInfo[E_ucAIMaxBlocksNb];
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifdef __DYNAMIC_MALLOC_ALLOWED__
#ifdef __DEBUG_MALLOC_MODE__
EXTERN_MEMAI CPA_EXPORT tdstDynInfo g_stAIDynInfo;
#endif /*__DEBUG_MALLOC_MODE__*/
#endif /*__DYNAMIC_MALLOC_ALLOWED__*/
#endif /*__MmgAI_H__*/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,165 @@
/*---------------------------------------------------------------------------*/
/* Action parameters functions and macros for intelligence engine*/
/* author : Olivier Couvreur*/
/* date : 7/11/1996*/
/* modify : Fabien MORALES*/
/* date : 29/01/1997 Vertex param*/
/* modify : Olivier Couvreur*/
/* date : 03/02/1997 Lint 0 warnings*/
/* modify : Olivier Couvreur*/
/* date : 09/02/1997 error handling*/
/* modify : Olivier Couvreur 23/04/97 MMG + DIR*/
/*---------------------------------------------------------------------------*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Erm.h"
#include "StrIntel.h"
#include "AI_Struc.h"
#include "specif/ActTable.h"
/* XB 20/05/1999 */
#ifndef D_THROW_COMPLEX_ACTION_TABLE
#define M_ActionParam(n) M_ActionTableParam((n),M_ActionTableCurrentEntry(n))
/* En Bref un truc du genre*/
/* M_ActionParam(p_stIntellOrReflex)*/
/* =*/
/* p_stIntelligence->stActionTable.a_stEntry[p_stIntelligence->stActionTable.ucCurrentEntry].stActionParam*/
#else /* D_THROW_COMPLEX_ACTION_TABLE */
#define M_ActionParam(n) M_ActionTableParam0((n))
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
/* End XB 20/05/1999 */
#define M_InternalSetActionParam(p_SuperObjPerso, ucN, Value, AccesMacro) \
tdstIntelligence *p_stIntellOrReflex = M_GetIntellOrReflex(AI_M_stGetMindOfSuperObj((p_SuperObjPerso))); \
##AccesMacro(&M_ActionParam(p_stIntellOrReflex).a_uParam[(ucN)]) = (Value);
#if defined(__DEBUG_AI__)
#define M_SetActionParam(p_SuperObjPerso, ucN, Value, AccesMacro) \
if (ucN<C_MAX_NB_PARAM) \
{\
M_InternalSetActionParam(p_SuperObjPerso, ucN, Value, AccesMacro); \
}\
else\
{\
M_AIFatalError(E_uwAIFatalInvalidParameter);\
}
#else
#define M_SetActionParam(p_SuperObjPerso, ucN, Value, AccesMacro) M_InternalSetActionParam(p_SuperObjPerso, ucN, Value, AccesMacro);
#endif /* __DEBUG_AI__*/
#define M_InternalGetActionParam(p_SuperObjPerso, ucN, AccesMacro) \
tdstIntelligence *p_stIntellOrReflex = M_GetIntellOrReflex(AI_M_stGetMindOfSuperObj((p_SuperObjPerso))); \
return(##AccesMacro(&M_ActionParam(p_stIntellOrReflex).a_uParam[(ucN)]));
#if defined(__DEBUG_AI__)
#define M_GetActionParam(p_SuperObjPerso, ucN, DefaultReturnValue, AccesMacro) \
if (ucN<C_MAX_NB_PARAM) \
{\
M_InternalGetActionParam(p_SuperObjPerso, ucN, AccesMacro); \
}\
else\
{\
M_AIFatalError(E_uwAIFatalInvalidParameter);\
return DefaultReturnValue; \
}
#else
#define M_GetActionParam(p_SuperObjPerso, ucN, DefaultReturnValue, AccesMacro) M_InternalGetActionParam(p_SuperObjPerso, ucN, AccesMacro);
#endif /* __DEBUG_AI__*/
/****************************************************************************************/
/* ACCESS TO ACTION PARAMETERS */
/****************************************************************************************/
/* REAL_PARAM*/
void fn_vSetActionParamxValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso, MTH_tdxReal xValue)
{
M_SetActionParam(p_SuperObjPerso, ucN, xValue, M_tduGetSetParam_xValue);
}
MTH_tdxReal fn_xGetActionParamxValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
M_GetActionParam(p_SuperObjPerso, ucN, MTH_M_xLongToReal(0), M_tduGetSetParam_xValue);
}
/* CGHT */
/* LIPSYNCHRO_PARAM*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vSetActionParamhLipsSynchro(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso,tdxHandleOfLipsSynchroTable hLipsSynchro)
{
M_SetActionParam(p_SuperObjPerso, ucN, hLipsSynchro, M_tduGetSetParam_hLipsSynchro);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdxHandleOfLipsSynchroTable fn_p_stGetActionParamhLipsSynchro(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
M_GetActionParam(p_SuperObjPerso, ucN, NULL, M_tduGetSetParam_hLipsSynchro);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* CONSTANT_PARAM*/
void fn_vSetActionParamlValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso, long lValue)
{
M_SetActionParam(p_SuperObjPerso, ucN, lValue, M_tduGetSetParam_lValue);
}
long fn_lGetActionParamlValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
M_GetActionParam(p_SuperObjPerso, ucN, 0, M_tduGetSetParam_lValue);
}
/* ACTION_PARAM*/
void fn_vSetActionParamStateValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso, tdxHandleToState hState)
{
M_SetActionParam(p_SuperObjPerso, ucN, hState, M_tduGetSetParam_HandleToState);
}
tdxHandleToState fn_xGetActionParamStateValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
M_GetActionParam(p_SuperObjPerso, ucN, NULL, M_tduGetSetParam_HandleToState);
}
/* VERTEX_PARAM*/
void fn_vSetActionParamp_stVertex(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso, MTH3D_tdstVector *p_stVertex)
{
#if defined(__DEBUG_AI__)
if (ucN < C_MAX_NB_PARAM)
{
#endif
tdstIntelligence *p_stIntellOrReflex = M_GetIntellOrReflex(AI_M_stGetMindOfSuperObj(p_SuperObjPerso));
MTH3D_M_vCopyVector( &M_tduGetSetParam_stVertexValue(&M_ActionParam(p_stIntellOrReflex).a_uParam[ucN]), p_stVertex );
#if defined(__DEBUG_AI__)
}
else
{
M_AIFatalError(E_uwAIFatalInvalidParameter);
}
#endif
}
MTH3D_tdstVector *fn_p_stGetActionParamp_stVertex(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
tdstIntelligence *p_stIntellOrReflex = M_GetIntellOrReflex(AI_M_stGetMindOfSuperObj(p_SuperObjPerso));
#if defined(__DEBUG_AI__)
if (ucN < C_MAX_NB_PARAM)
{
#endif
return(&M_tduGetSetParam_stVertexValue(&M_ActionParam(p_stIntellOrReflex).a_uParam[ucN]) );
#if defined(__DEBUG_AI__)
}
else
{
M_AIFatalError(E_uwAIFatalInvalidParameter);
return(NULL);
}
#endif
}

View File

@@ -0,0 +1,48 @@
/*---------------------------------------------------------------------------*/
/* Action parameters functions and macros for intelligence engine*/
/* author : Olivier Couvreur*/
/* date : 7/11/1996*/
/* modify : Fabien MORALES*/
/* date : 29/01/1997 Vertex param*/
/* modify : Olivier COUVREUR*/
/* date : 10/02/1997 error handling + */
/* modify : Fabien MORALES*/
/* date : 05/02/1997 Several Vertex params*/
/* modify : Fabien MORALES*/
/* date : 12/02/1997 Several long params*/
/*---------------------------------------------------------------------------*/
#if !defined(__ACTPARAM_H__)
#define __ACTPARAM_H__
#include "Convert.h"
#include "Strintel.h"
typedef struct tdstActionParam_
{
tduGetSetParam a_uParam[C_MAX_NB_PARAM];
} tdstActionParam;
/* real*/
void fn_vSetActionParamxValue(unsigned char ucN,HIE_tdxHandleToSuperObject p_SuperObjPerso, MTH_tdxReal xValue);
MTH_tdxReal fn_xGetActionParamxValue(unsigned char ucN,HIE_tdxHandleToSuperObject p_SuperObjPerso);
/* lips synchro CGHT*/
void fn_vSetActionParamhLipsSynchro(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso,tdxHandleOfLipsSynchroTable hLipsSynchro);
tdxHandleOfLipsSynchroTable fn_p_stGetActionParamhLipsSynchro(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso);
/* constant*/
void fn_vSetActionParamlValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso, long lValue);
long fn_lGetActionParamlValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso);
/* Vertex */
void fn_vSetActionParamp_stVertex(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso, MTH3D_tdstVector *p_stVertex);
MTH3D_tdstVector *fn_p_stGetActionParamp_stVertex(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso);
/* Action*/
void fn_vSetActionParamStateValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso, tdxHandleToState hState);
tdxHandleToState fn_xGetActionParamStateValue(unsigned char ucN, HIE_tdxHandleToSuperObject p_SuperObjPerso);
#endif

View File

@@ -0,0 +1,494 @@
/*---------------------------------------------------------------------------*/
/* Action table functions for intelligence engine*/
/* author : Olivier Couvreur*/
/* modify : 07/11/96 Olivier Couvreur */
/* modify : 03/02/97 Olivier Couvreur Lint 0 warnings */
/* modify : 26/02/97 Olivier Couvreur added Schedule support + Lint 0 warnings*/
/* modify : 05/03/97 Olivier Couvreur added Schedule function + Lint 0 warnings*/
/* modify : 25/03/97 Olivier Couvreur added REVERSE_RULES support + optimizations (not yet activated)*/
/*---------------------------------------------------------------------------*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "specif/ActTable.h"
#include "StrIntel.h"
#include "Action.h"
/*****************************************************************************************************/
/* here we can have more than one action in action table */
/* XB 20/05/1999 */
#ifndef D_THROW_COMPLEX_ACTION_TABLE
/* OPTIMIZE_ACTION_TABLE is defined in AIOption.h*/
/* check if a rule is in action table : return entry number*/
unsigned char fn_ucIsRuleInActionTable(tdstIntelligence *p_stIntelligence,unsigned char ucNumRule)
{
/* Modif YLG*/
unsigned char ucNbEntries;
ucNbEntries = M_ActionTableNbEntries(p_stIntelligence);
if (M_IsActionTableUsed(p_stIntelligence))
{
unsigned char ucCurrentEntry;
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntryN(p_stIntelligence, 0));
for (ucCurrentEntry=0;ucCurrentEntry<ucNbEntries;ucCurrentEntry++, p_stEntry++)
{
if (p_stEntry->bUsed)
{
if (p_stEntry->ucNumRule==ucNumRule)
{
return(ucCurrentEntry);
}
}
}
}
return (ucNbEntries);
}
/* check if a rule and a node are in action table : return entry number*/
unsigned char fn_ucIsRuleAndNodeInActionTable(tdstIntelligence *p_stIntelligence,unsigned char ucNumRule,tdstNodeInterpret *p_stNode)
{
/* Modif YLG*/
unsigned char ucNbEntries;
ucNbEntries = M_ActionTableNbEntries(p_stIntelligence);
if (M_IsActionTableUsed(p_stIntelligence))
{
unsigned char ucCurrentEntry;
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntryN(p_stIntelligence, 0));
for (ucCurrentEntry=0;ucCurrentEntry<ucNbEntries;ucCurrentEntry++, p_stEntry++)
{
/* if (M_ActionTableUseFlag(p_stIntelligence,ucCurrentEntry))*/
if (p_stEntry->bUsed)
{
/* if (M_ActionTableNumRule(p_stIntelligence,ucCurrentEntry)==ucNumRule)*/
if (p_stEntry->ucNumRule==ucNumRule)
{
/* if (M_ActionTableNumNode(p_stIntelligence,ucCurrentEntry)==p_stNode)*/
if (p_stEntry->p_stNode ==p_stNode)
{
return(ucCurrentEntry);
}
}
}
}
}
/* return(M_ActionTableNbEntries(p_stIntelligence));*/
return (ucNbEntries);
}
/* find a free entry in action table : return entry number*/
unsigned char fn_ucFindPlaceInActionTable(tdstIntelligence *p_stIntelligence)
{
/* Modif YLG*/
unsigned char ucCurrentEntry;
unsigned char ucNbEntries;
ucNbEntries = M_ActionTableNbEntries(p_stIntelligence);
/* if (M_ActionTableNbEntriesUsed(p_stIntelligence)<M_ActionTableNbEntries(p_stIntelligence))*/
if (M_ActionTableNbEntriesUsed(p_stIntelligence)<ucNbEntries)
{
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntryN(p_stIntelligence, 0));
/* for (ucCurrentEntry=0;ucCurrentEntry<M_ActionTableNbEntries(p_stIntelligence);ucCurrentEntry++)*/
for (ucCurrentEntry=0;ucCurrentEntry<ucNbEntries;ucCurrentEntry++,p_stEntry++)
{
/* if (!M_ActionTableUseFlag(p_stIntelligence,ucCurrentEntry))*/
if (!p_stEntry->bUsed)
{
return(ucCurrentEntry);
}
}
}
/* return(M_ActionTableNbEntries(p_stIntelligence));*/
return (ucNbEntries);
}
static void fn_vInitActionTableEntry(tdstIntelligence *p_stIntelligence,unsigned char ucNEntry,unsigned char ucNumRule,tdstNodeInterpret *p_stNode,unsigned char bfUsed)
{
/* modif YLG*/
M_ActionTableUseActionReturn(p_stIntelligence,ucNEntry) = g_ucUseDefaultActionReturn;
M_ActionTableNewActionReturn(p_stIntelligence,ucNEntry) = g_ucNewActionReturn;
M_ActionTableUseFlag(p_stIntelligence,ucNEntry)=bfUsed;
M_ActionTableNumNode(p_stIntelligence,ucNEntry)=p_stNode;
M_ActionTableNumRule(p_stIntelligence,ucNEntry)=ucNumRule;
memset(&(M_ActionTableParam(p_stIntelligence,ucNEntry)),0,sizeof(M_ActionTableParam(p_stIntelligence,ucNEntry)));
}
#if !defined(OPTIMIZE_ACTION_TABLE)
/* internal function*/
void fn_vUpdateActionTable(tdstIntelligence *p_stIntelligence)
{
unsigned char ucCurrentEntry;
M_ActionTableNbEntriesUsed(p_stIntelligence)=0;
for (ucCurrentEntry=0;ucCurrentEntry<M_ActionTableNbEntries(p_stIntelligence);ucCurrentEntry++)
{
if (M_ActionTableUseFlag(p_stIntelligence,ucCurrentEntry))
{
/*update NbEntriesUsed */
M_ActionTableNbEntriesUsed(p_stIntelligence)+=1;
}
}
}
#endif
/* use current entry in action table*/
void fn_vUseCurrentActionTableEntry(tdstIntelligence *p_stIntelligence,unsigned char ucNRule,tdstNodeInterpret *p_stNode)
{
#if defined(OPTIMIZE_ACTION_TABLE)
unsigned char ucCurrentEntry=M_ActionTableCurrentEntry(p_stIntelligence);
if (!M_ActionTableUseFlag(p_stIntelligence,ucCurrentEntry))
{
fn_vInitActionTableEntry(p_stIntelligence,ucCurrentEntry,ucNRule,p_stNode,1);
M_ActionTableNbEntriesUsed(p_stIntelligence)++;
}
#else
/* reinit current entry in action table*/
fn_vInitActionTableEntry(p_stIntelligence,M_ActionTableCurrentEntry(p_stIntelligence),ucNRule,p_stNode,1);
/* update action table*/
fn_vUpdateActionTable(p_stIntelligence);
#endif /* reinit current entry in action table*/
}
/* free current entry in action table*/
void fn_vUnuseCurrentActionTableEntry(tdstIntelligence *p_stIntelligence)
{
/* YLG Modif*/
#if defined(OPTIMIZE_ACTION_TABLE)
unsigned char ucCurrentEntry=M_ActionTableCurrentEntry(p_stIntelligence);
if (M_ActionTableUseFlag(p_stIntelligence,ucCurrentEntry))
{
fn_vInitActionTableEntry(p_stIntelligence,ucCurrentEntry,0,NULL,0);
M_ActionTableNbEntriesUsed(p_stIntelligence)--;
}
#else
/* reinit current entry in action table*/
fn_vInitActionTableEntry(p_stIntelligence,M_ActionTableCurrentEntry(p_stIntelligence),0,NULL,0);
/* update action table*/
fn_vUpdateActionTable(p_stIntelligence);
#endif
}
void fn_vUnuseAllRulesWhichHaveGreaterNumRule(struct tdstIntelligence_ *p_stIntelligence,unsigned char ucNumRule)
{
/* Modif YLG*/
unsigned char ucNbEntries;
ucNbEntries = M_ActionTableNbEntries(p_stIntelligence);
/* action table not used*/
if (M_IsActionTableUsed(p_stIntelligence))
{
unsigned char ucCurrentEntry;
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntryN(p_stIntelligence, 0));
for (ucCurrentEntry=0;ucCurrentEntry<ucNbEntries;ucCurrentEntry++, p_stEntry++)
{
/* if (M_ActionTableUseFlag(p_stIntelligence,ucCurrentEntry))*/
if (p_stEntry->bUsed)
{
if (
/* exclude rule from schedule*/
/* (M_ActionTableNumRule(p_stIntelligence,ucCurrentEntry)>0)*/
/* &&(M_ActionTableNumRule(p_stIntelligence,ucCurrentEntry)>ucNumRule)*/
p_stEntry -> ucNumRule > ucNumRule
)
{
fn_vInitActionTableEntry(p_stIntelligence,ucCurrentEntry,0,NULL,0);
M_ActionTableNbEntriesUsed(p_stIntelligence)--;
}
}
}
/* update action table*/
#if !defined(OPTIMIZE_ACTION_TABLE)
fn_vUpdateActionTable(p_stIntelligence);
#endif
}
}
void fn_vUnuseAllRulesFromSchedule(struct tdstIntelligence_ *p_stIntelligence)
{
/* Modif YLG*/
unsigned char ucNbEntries;
/* action table not used*/
if (M_IsActionTableUsed(p_stIntelligence))
{
unsigned char ucCurrentEntry;
struct tdstActionTableEntry_ *p_stEntry;
ucNbEntries = M_ActionTableNbEntries(p_stIntelligence);
p_stEntry = &(M_ActionTableEntryN(p_stIntelligence, 0));
/* for (ucCurrentEntry=0;ucCurrentEntry<M_ActionTableNbEntries(p_stIntelligence);ucCurrentEntry++)*/
for (ucCurrentEntry=0;ucCurrentEntry<ucNbEntries;ucCurrentEntry++, p_stEntry++)
{
/* if (M_ActionTableUseFlag(p_stIntelligence,ucCurrentEntry))*/
if (p_stEntry->bUsed)
{
/* only rule from schedule*/
/* if (M_ActionTableNumRule(p_stIntelligence,ucCurrentEntry)==0)*/
if (p_stEntry->ucNumRule==0)
{
fn_vInitActionTableEntry(p_stIntelligence,ucCurrentEntry,0,NULL,0);
/*M_ActionTableNbEntriesUsed(p_stIntelligence)--;*/
ucNbEntries --;
}
}
}
M_ActionTableNbEntriesUsed(p_stIntelligence) = ucNbEntries;
#if !defined(OPTIMIZE_ACTION_TABLE)
/* update action table*/
fn_vUpdateActionTable(p_stIntelligence);
#endif
}
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdstNodeInterpret *fn_p_stGetScheduleFromActionTableAndClearIt(tdstIntelligence *p_stIntelligence)
{
/* MOdif ylg*/
tdstNodeInterpret *p_stFoundSchedule=NULL;
unsigned char ucNbEntries;
/* action table not used*/
if (M_IsActionTableUsed(p_stIntelligence))
{
unsigned char ucCurrentEntry;
struct tdstActionTableEntry_ *p_stEntry;
ucNbEntries = M_ActionTableNbEntries(p_stIntelligence);
p_stEntry = &(M_ActionTableEntryN(p_stIntelligence, 0));
/* loop in action table*/
/* for (ucCurrentEntry=0;ucCurrentEntry<M_ActionTableNbEntries(p_stIntelligence);ucCurrentEntry++)*/
for (ucCurrentEntry=0;ucCurrentEntry<ucNbEntries;ucCurrentEntry++, p_stEntry++)
{
/* is this entry used ?*/
/* if (M_ActionTableUseFlag(p_stIntelligence,ucCurrentEntry))*/
if (p_stEntry->bUsed)
{
/* is this entry belonging to schedule (==0) ?*/
/*if (M_ActionTableNumRule(p_stIntelligence,ucCurrentEntry)==0)*/
if (p_stEntry->ucNumRule==0)
{
/* keep the first one found*/
/*
if (p_stFoundSchedule==NULL)
{
p_stFoundSchedule=M_ActionTableNumNode(p_stIntelligence,ucCurrentEntry);
}
*/
/* keep the first one found or the first one in the schedule*/
/* if ( (p_stFoundSchedule==NULL) || (M_ActionTableNumNode(p_stIntelligence,ucCurrentEntry)<p_stFoundSchedule) )*/
if ( (p_stFoundSchedule==NULL) || (p_stEntry->p_stNode<p_stFoundSchedule) )
{
/* p_stFoundSchedule=M_ActionTableNumNode(p_stIntelligence,ucCurrentEntry);*/
p_stFoundSchedule=p_stEntry->p_stNode;
}
/* clear schedule entry*/
fn_vInitActionTableEntry(p_stIntelligence,ucCurrentEntry,0,NULL,0);
/* M_ActionTableNbEntriesUsed(p_stIntelligence)--;*/
ucNbEntries --;
}
}
}
M_ActionTableNbEntriesUsed(p_stIntelligence) = ucNbEntries;
#if !defined(OPTIMIZE_ACTION_TABLE)
/* update action table*/
fn_vUpdateActionTable(p_stIntelligence);
#endif
}
return(p_stFoundSchedule);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* used by InitPerso*/
void fn_vInitActionTable(tdstIntelligence *p_stIntelligence)
{
/* Modif YLG*/
unsigned char ucNEntry;
unsigned char ucNbEntries;
M_ActionTableNbEntriesUsed(p_stIntelligence)=0;
M_ActionTableCurrentEntry(p_stIntelligence)=0;
ucNbEntries = M_ActionTableNbEntries(p_stIntelligence);
/* for (ucNEntry=0;ucNEntry<M_ActionTableNbEntries(p_stIntelligence);ucNEntry++)*/
for (ucNEntry=0;ucNEntry<ucNbEntries;ucNEntry++)
{
fn_vInitActionTableEntry(p_stIntelligence,ucNEntry,0,NULL,0);
}
}
tdstNodeInterpret *fn_p_stGetTableAction(tdstIntelligence *p_stIntelligence, unsigned char ucNEntry)
{
/* Modif YLG*/
/* fn_vSetUseDefaultActionReturnValue(M_ActionTableUseActionReturn(p_stIntelligence,ucNEntry));*/
g_ucUseDefaultActionReturn = M_ActionTableUseActionReturn(p_stIntelligence,ucNEntry);
/* fn_vSetNewActionReturnValue(M_ActionTableNewActionReturn(p_stIntelligence,ucNEntry));*/
g_ucNewActionReturn = M_ActionTableNewActionReturn(p_stIntelligence,ucNEntry);
return M_ActionTableNumNode(p_stIntelligence, ucNEntry);
}
/*****************************************************************************************************/
/* here only one action in action table */
#else /* D_THROW_COMPLEX_ACTION_TABLE */
/* check if a rule is in action table : return entry number*/
unsigned char fn_ucIsRuleInActionTable(tdstIntelligence *p_stIntelligence,unsigned char ucNumRule)
{
if(M_ActionTable(p_stIntelligence))
{
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntry0(p_stIntelligence));
if((p_stEntry->bUsed == TRUE) &&
(p_stEntry->ucNumRule == ucNumRule))
{
return 0;
}
}
return 1;
}
/* check if a rule and a node are in action table : return entry number*/
unsigned char fn_ucIsRuleAndNodeInActionTable(tdstIntelligence *p_stIntelligence,unsigned char ucNumRule,tdstNodeInterpret *p_stNode)
{
if(M_ActionTable(p_stIntelligence))
{
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntry0(p_stIntelligence));
if((p_stEntry->bUsed == TRUE) &&
(p_stEntry->ucNumRule == ucNumRule) &&
(p_stEntry->p_stNode == p_stNode))
{
return 0;
}
}
return 1;
}
/* find a free entry in action table : return entry number*/
unsigned char fn_ucFindPlaceInActionTable(tdstIntelligence *p_stIntelligence)
{
if(M_ActionTable(p_stIntelligence))
{
if(!(M_ActionTableUseFlag0(p_stIntelligence)))
{
return 0;
}
}
return 1;
}
static void fn_vInitActionTableEntry(tdstIntelligence *p_stIntelligence,unsigned char ucNumRule,tdstNodeInterpret *p_stNode,unsigned char bfUsed)
{
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntry0(p_stIntelligence));
p_stEntry->bUseDefaultActionReturn=g_ucUseDefaultActionReturn;
p_stEntry->ucNewActionReturn=g_ucNewActionReturn;
p_stEntry->bUsed=bfUsed;
p_stEntry->p_stNode=p_stNode;
p_stEntry->ucNumRule=ucNumRule;
memset(&(p_stEntry->stActionParam),0,sizeof(p_stEntry->stActionParam));
}
/* use current entry in action table*/
void fn_vUseCurrentActionTableEntry(tdstIntelligence *p_stIntelligence,unsigned char ucNRule,tdstNodeInterpret *p_stNode)
{
if(!M_ActionTableUseFlag0(p_stIntelligence))
{
fn_vInitActionTableEntry(p_stIntelligence,ucNRule,p_stNode,1);
}
}
/* free current entry in action table*/
void fn_vUnuseCurrentActionTableEntry(tdstIntelligence *p_stIntelligence)
{
if (M_ActionTableUseFlag0(p_stIntelligence))
{
fn_vInitActionTableEntry(p_stIntelligence,0,NULL,0);
}
}
void fn_vUnuseAllRulesWhichHaveGreaterNumRule(struct tdstIntelligence_ *p_stIntelligence,unsigned char ucNumRule)
{
if(M_ActionTable(p_stIntelligence))
{
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntry0(p_stIntelligence));
if((p_stEntry->bUsed) &&
(p_stEntry->ucNumRule>ucNumRule))
{
fn_vInitActionTableEntry(p_stIntelligence,0,NULL,0);
}
}
}
void fn_vUnuseAllRulesFromSchedule(struct tdstIntelligence_ *p_stIntelligence)
{
if (M_ActionTable(p_stIntelligence))
{
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntry0(p_stIntelligence));
/* only rule from schedule*/
if((p_stEntry->bUsed) &&
(p_stEntry->ucNumRule==0))
{
fn_vInitActionTableEntry(p_stIntelligence,0,NULL,0);
}
}
}
/* used by InitPerso*/
void fn_vInitActionTable(tdstIntelligence *p_stIntelligence)
{
if(M_ActionTable(p_stIntelligence))
{
fn_vInitActionTableEntry(p_stIntelligence,0,NULL,0);
}
}
tdstNodeInterpret *fn_p_stGetTableAction(tdstIntelligence *p_stIntelligence, unsigned char ucNEntry)
{
struct tdstActionTableEntry_ *p_stEntry;
p_stEntry = &(M_ActionTableEntry0(p_stIntelligence));
g_ucUseDefaultActionReturn = p_stEntry->bUseDefaultActionReturn;
g_ucNewActionReturn = p_stEntry->ucNewActionReturn;
return p_stEntry->p_stNode;
}
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
/* End XB 20/05/1999 */

View File

@@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*/
/* Action.cpp : Definition of general Action.*/
/* auteur : Olivier Didelot 15/10/1996*/
/* modify : Olivier Didelot 27/12/1996*/
/* modify : Olivier Couvreur 20/01/1997 Support for script and editor names + parameter types*/
/* modify : Fabien MORALES 21/01/1997 Blocking actions management*/
/* modify : Fabien MORALES 29/01/1997 Vertex param*/
/* modify : Olivier Couvreur 04/02/1997 Lint 0 warnings */
/* modify : Olivier Couvreur 10/02/1997 Great enhancement for automatic init support*/
/* modify : Fabien MORALES 12/02/1997 Module & DsgVarId param types*/
/* modify : Olivier Couvreur 21/02/1997 Handle uppercase and lowaercase type string for editor*/
/* modify : Olivier Couvreur 26/02/1997 Lint check + call to fn_vInitModuleAcionEntries + suppres fn_p_stFindObjectRec & fn_p_stFindObjectInWorld*/
/* modify : Olivier Couvreur 25/03/1997 ACTIVE_EDITOR support*/
/*---------------------------------------------------------------------------*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Erm.h"
#include "StrIntel.h"
#include "ActParam.h"
#include "Intell.h"
#include "Convert.h"
#include "Action.h"
#include "EnumAct.h"
/*XB*/
#include <ctype.h> /*for toupper*/
/*End XB*/
/* Action Return : to block the next action*/
unsigned char g_ucNewActionReturn; /* to set the action type using the script*/
unsigned char g_ucUseDefaultActionReturn; /* the g_ucNewActionReturn is not taking into account*/
/****************************************************************************************/
/* ACTIONS */
/****************************************************************************************/
/* to handle meta-action parameters*/
tdstNodeInterpret *fn_p_stDefaultActionInit(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree)
{
char *szTypeParam=NULL;
unsigned char ucNbParam=0;
enum tdeMetaActionId_ eMetaActionId=M_eMetaActionIdInterpret(p_stTree-1);
szTypeParam=szGetMetaActionTypeInParamFromId(eMetaActionId);
ucNbParam= (unsigned char) strlen(szTypeParam);
/*Chiant pour la generation du C*/
/*#if defined(__DEBUG_AI__)*/
/* M_VerifyNbParamAction(p_stTree,ucNbParam);*/
/*#endif // __DEBUG_AI__*/
if (ucNbParam!=0)
{
tdstGetSetParam stParam;
char cType;
unsigned char ucParam=0;
for (ucParam=0;ucParam<ucNbParam;ucParam++)
{
M_EvalNextParameter(&stParam);
/* toupper important*/
cType=(char) toupper(szTypeParam[ucParam]);
/**************************/
/* Long action param*/
/************************* */
if (cType==STRING1_TO_CHAR(C_LONG_PARAM))
{
M_Verify2TypesOfParamAction(&stParam, E_vt_Integer,E_vt_Float);
fn_vSetActionParamlValue(ucParam, p_SuperObjPerso, M_ReturnParam_lValue(&stParam));
}
/**************************/
/* Real action param*/
/**************************/
else if (cType==STRING1_TO_CHAR(C_REAL_PARAM))
{
M_Verify2TypesOfParamAction(&stParam, E_vt_Integer,E_vt_Float);
fn_vSetActionParamxValue(ucParam, p_SuperObjPerso, M_ReturnParam_xValue(&stParam));
}
/**************************/
/* Vector action param*/
/**************************/
else if (cType==STRING1_TO_CHAR(C_VECTOR_PARAM))
{
M_VerifyTypeOfParamAction(&stParam, E_vt_Vector);
fn_vSetActionParamp_stVertex(ucParam, p_SuperObjPerso, &M_GetSetParam_stVertexValue(&stParam));
}
#ifdef D_USE_LIPSYNC
/******************************/
/* Lips Synchro param * CGHT **/
/******************************/
else if (cType==STRING1_TO_CHAR(C_LIPSYNCHRO_PARAM))
{
M_VerifyTypeOfParamAction(&stParam, E_vt_LipsSynchro);
fn_vSetActionParamhLipsSynchro(ucParam,p_SuperObjPerso, M_GetSetParam_hLipsSynchro(&stParam));
}
#endif /* D_USE_LIPSYNC */
/**************************/
/* Action action param*/
/**************************/
else if (cType==STRING1_TO_CHAR(C_ACTION_PARAM))
{
M_VerifyTypeOfParamAction(&stParam, E_vt_Action);
fn_vSetActionParamStateValue(ucParam, p_SuperObjPerso, M_GetSetParam_ActionValue(&stParam));
}
}
}
return p_stTree;
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tducActionReturn fn_ucDefaultAction(HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
p_SuperObjPerso=p_SuperObjPerso; /* for lint*/
return (C_ACTION_FINISHED | C_ACTION_ENGINE_CONTINUE);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/****************************************************************************************/
/* to call once before anything else related to metaaction */
/****************************************************************************************/
#if !defined(OPTIMIZED_COMMAND)
#include "ProtAct.h"
void fn_vInitMetaActionEntries(void)
{
/* Init*/
#if defined(__DEBUG_AI__)
fn_vInitMetaActionTable(fn_p_stDefaultActionInit,fn_ucDefaultAction);
#endif /* __DEBUG_AI__*/
#define M_DEFINE_METAACTION(a,b,english,c,d,e,f) fn_vDefineMetaActionEntry(M_METAACTION_ENTRY(a,b,english,c,d,e,f));
#include "DefAct.h"
#undef M_DEFINE_METAACTION
#if defined(__DEBUG_AI__)
fn_vCheckMetaActionTable(fn_p_stDefaultActionInit,fn_ucDefaultAction);
#endif /* __DEBUG_AI__*/
}
#endif /* OPTIMIZED_COMMAND*/

View File

@@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------*/
/* Array.c : Typed array for AI.*/
/* author : Olivier Couvreur 28/11/1997*/
/*---------------------------------------------------------------------------*/
/* included in DsgMem.c so excluded from build in VC project*/
#include "AIUseCPA.h"
#include "AI_Mmg.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Erm.h"
#include "Convert.h"
#include "gsparam.h"
#include "Array.h"
#include "dsgmem.h"
/*XB*/
#if defined(AI_USE_SCRIPT)
/*End XB*/
extern void fn_vInitDsgVarValue(void *p_MyVarAddr,tdeDsgVarTypeId eDsgVarTypeId,char * szParams[]);
void fn_vInitArray(struct tdstArray_ *p_stArray,enum tdeDsgVarTypeId_ eDsgVarType,unsigned char ucNbElements,char *szParams[])
{
M_ARRAY_SIZE(p_stArray)=ucNbElements;
M_ARRAY_TYPE(p_stArray)=eDsgVarType;
M_ARRAY_CLEAR(p_stArray);
if (szParams!=NULL)
{
char ucIndex=0;
char *p_MyVarAddr;
char **ptr=szParams+1;
while(ptr[2]!=NULL)
{
if (ucIndex<ucNbElements)
{
p_MyVarAddr=(char*) M_ARRAY_ELEMENT(p_stArray,ucIndex);
fn_vInitDsgVarValue(p_MyVarAddr,eDsgVarType,ptr);
if (eDsgVarType==eDsgVarType_Vector)
{
/*ptr+=3;*/
ptr++;
if (ptr[2]!=NULL) ptr++;
if (ptr[2]!=NULL) ptr++;
}
else
{
ptr++;
}
ucIndex++;
}
else
{
break;
}
}
}
}
/*XB*/
#endif /* AI_USE_SCRIPT */
/*End XB*/

View File

@@ -0,0 +1,476 @@
#define D_Brain_StructureDefine
#include "AIUseCPA.h"
#include "TypePtr.h"
#include "CFast.h"
#include "EnumProc.h"
#include "EnumCond.h"
#include "EnumAct.h"
#include "EnumFunc.h"
#include "EnumFild.h"
#include "EnumOper.h"
#include "EnumKey.h"
#include "ActConst.h"
#include "DsgMem.h"
#include "DsgMemC.h"
#include "Specif\AItools.h"
#ifndef U64
#include "sna.h"
#endif
//XB 05/08/99
#ifndef D_THROW_CFAST_AI
//End XB
extern void fn_vSetUltraOperatorPerso(HIE_tdxHandleToSuperObject hCurrentSuperObjPerso,HIE_tdxHandleToSuperObject hNewCurrentSuperObjPerso);
extern tdstNodeInterpret *fn_p_stOperatorGetPerso(HIE_tdxHandleToSuperObject p_SuperObjPerso, tdstNodeInterpret *p_stTree, HIE_tdxHandleToSuperObject *hSuperObjPersoFound) ;
extern void fn_vSetProcedureActionReturn(tducActionReturn ucActionReturn);
extern tducActionReturn fn_ucGetProcedureActionReturn(void);
tdstGetSetParam CFast_g_a_stParam[CFast_lMaxTreeDepth] ;
tdstNodeInterpret CFast_g_a_stPseudoTree[7][CFast_lMaxTreeDepth] ;
/*long CFast_g_a_lLong[CFast_lMaxTreeDepth] ;*/
tdp_fn_p_stConditionFunctionPtr CFast_g_p_fn_CondPtr ;
tdp_fn_p_stOperatorFunctionPtr CFast_g_p_fn_OpPtr ;
tdp_fn_p_stProcedureFunctionPtr CFast_g_p_fn_ProcPtr ;
tdp_fn_p_stFunctionFunctionPtr CFast_g_p_fn_FuncPtr ;
tdp_fn_p_stKeyWordFunctionPtr CFast_g_p_fn_KeyWordPtr ;
tdp_fn_p_stMetaActionInitFunctionPtr CFast_g_p_fn_MetaInitPtr ;
tdp_fn_ucMetaActionFunctionPtr CFast_g_p_fn_MetaPtr ;
ACP_tdxBool CFast_g_bProcessReflex ;
ACP_tdxBool CFast_g_bMetaActionInRfx ;
tdeTypeInterpret CFast_g_aEvt2Eti[] = {
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Real,
E_ti_String,
E_ti_WayPointRef,
E_ti_PersoRef,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_Constant,
E_ti_ConstantVector,
E_ti_Module,
E_ti_DsgVarRef,
E_ti_ActionRef,
E_ti_Button,
E_ti_Mask,
E_ti_Constant,
E_ti_LipsSynchroRef,
E_ti_ObjectTableRef,
E_ti_SuperObjectRef,
E_ti_Constant,
E_ti_FamilyRef,
E_ti_SoundEventRef,
E_ti_ComportRef,
E_ti_Constant,
E_ti_Constant,
E_ti_ParticleGenerator,
E_ti_GameMaterialRef,
E_ti_Color,
E_ti_ModelRef,
E_ti_Constant,
E_ti_Light,
E_ti_Caps,
E_ti_Graph
} ;
/* Mind of current perso */
AI_tdstMind *p_stGlobalMind;
struct tdstNodeInterpret_ *gp_stRefTree;
struct tdstNodeInterpret_ *gp_stPseudoTree;
HIE_tdxHandleToSuperObject g_hSuperObjectPerso;
char *p_cGlobalDsgMemBuffer;
tdstDsgVarInfo *p_stGlobalDsgVarInfo;
#define M_LocalGetDsgVarAddr(mind, ind) (p_cLocalDsgMemBuffer + p_stLocalDsgVarInfo[ind].ulOffsetInDsgMem)
/*#define M_LocalGetDsgVarAddr(mind, ind) (p_cLocalVarsArray[ind])*/
#ifdef __DEBUG_AI__
#ifdef ACTIVE_EDITOR
#define CFast_M_MakeNode(val, type, skip, depth, bpt) { {{(enum tdeCondId_)val}}, (tdeTypeInterpret)type, skip, depth }
#else
#define CFast_M_MakeNode(val, type, skip, depth, bpt) { {{(enum tdeCondId_)val}}, (tdeTypeInterpret)type, skip, depth }
#endif /* ACTIVE_EDITOR */
#else
#define CFast_M_MakeNode(val, type, skip, depth, bpt) { val, skip, depth, type }
#endif /* __DEBUG_AI__ */
#ifdef U64
#define CFast_M_MakeRef(a, b, c, d) { b, c, d }
#else
#define CFast_M_MakeRef(a, b, c, d) { b }
#endif
#ifdef U64
void CFast_vCalcAllCodeSizes(void) {
/*
long i = 0 ;
while( CFast_gast_ArrayFunctions[i].ml_SizeOfTree != 0L )
{
CFast_gast_ArrayFunctions[i].ml_SizeOfCode -= (long)(CFast_gast_ArrayFunctions[i].mfnv_Function);
i++ ;
}
*/
}
#endif /* U64 */
/***************************************/
void CFast_fn_vSetUltraOperatorPersoRef(int i)
{
fn_vSetUltraOperatorPerso(g_hSuperObjectPerso, M_GetSuperObject(M_p_stPersoRefInterpret(gp_stRefTree + i))) ;
}
/***************************************/
void CFast_fn_vSetUltraOperatorMainActor(void) {
fn_vSetUltraOperatorPerso(g_hSuperObjectPerso, MC_fn_hGetCharacterInMainCharacterNode(MC_fn_hGetFirstMainCharNode())) ;
}
/***************************************/
/*void CFast_fn_vSetUltraOperatorWorld(void) {
fn_vSetUltraOperatorPerso(g_hSuperObjectPerso, g_stEngineStructure.h_WorldCaracter) ;
}*/
/***************************************/
void CFast_fn_vSetUltraOperatorPersoVar(int i)
{
HIE_tdxHandleToSuperObject hNewCurrentSuperObjPerso;
tdstNodeInterpret stTmpTree;
M_SetTypeInterpret(&stTmpTree, E_ti_DsgVarRef);
M_lValueInterpret(&stTmpTree) = i;
fn_p_stOperatorGetPerso(g_hSuperObjectPerso,&stTmpTree,&hNewCurrentSuperObjPerso);
fn_vSetUltraOperatorPerso(g_hSuperObjectPerso, hNewCurrentSuperObjPerso);
}
/***************************************/
void CFast_memcpy(int i, int j, int k)
{
long *pdest = (long *) &CFast_g_a_stPseudoTree[i][j], *psrc = (long *) (gp_stRefTree + k);
#if defined(__DEBUG_AI__)
memcpy(pdest, psrc, sizeof(tdstNodeInterpret));
#else
/* Size of tdstNodeInterpret in release is 8 */
*pdest++ = *psrc++;
*pdest++ = *psrc++;
#endif
}
/***************************************/
void CFast_CallFunction1_Static(int iInd)
{
a_stFunctionTable[M_eFuncIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[1]) ;
}
void CFast_CallFunction2_Static(int iInd)
{
a_stFunctionTable[M_eFuncIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[2]) ;
}
void CFast_CallFunction3_Static(int iInd)
{
a_stFunctionTable[M_eFuncIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[3]) ;
}
void CFast_CallFunction4_Static(int iInd)
{
a_stFunctionTable[M_eFuncIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[4]) ;
}
void CFast_CallFunction5_Static(int iInd)
{
a_stFunctionTable[M_eFuncIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[5]) ;
}
void CFast_CallFunction6_Static(int iInd)
{
a_stFunctionTable[M_eFuncIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[6]) ;
}
void CFast_CallFunction7_Static(int iInd)
{
a_stFunctionTable[M_eFuncIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[7]) ;
}
void CFast_CallFunction8_Static(int iInd)
{
a_stFunctionTable[M_eFuncIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[8]) ;
}
void CFast_CallFunction9_Static(int iInd)
{
a_stFunctionTable[M_eFuncIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[9]) ;
}
void CFast_CallFunction1_NoStatic(void)
{
a_stFunctionTable[M_eFuncIdInterpret(CFast_g_a_stPseudoTree[E_ti_Function])].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Function]+1, &CFast_g_a_stParam[1]) ;
}
void CFast_CallFunction2_NoStatic(void)
{
a_stFunctionTable[M_eFuncIdInterpret(CFast_g_a_stPseudoTree[E_ti_Function])].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Function]+1, &CFast_g_a_stParam[2]) ;
}
void CFast_CallFunction3_NoStatic(void)
{
a_stFunctionTable[M_eFuncIdInterpret(CFast_g_a_stPseudoTree[E_ti_Function])].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Function]+1, &CFast_g_a_stParam[3]) ;
}
void CFast_CallFunction4_NoStatic(void)
{
a_stFunctionTable[M_eFuncIdInterpret(CFast_g_a_stPseudoTree[E_ti_Function])].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Function]+1, &CFast_g_a_stParam[4]) ;
}
void CFast_CallFunction5_NoStatic(void)
{
a_stFunctionTable[M_eFuncIdInterpret(CFast_g_a_stPseudoTree[E_ti_Function])].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Function]+1, &CFast_g_a_stParam[5]) ;
}
void CFast_CallFunction6_NoStatic(void)
{
a_stFunctionTable[M_eFuncIdInterpret(CFast_g_a_stPseudoTree[E_ti_Function])].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Function]+1, &CFast_g_a_stParam[6]) ;
}
void CFast_CallFunction7_NoStatic(void)
{
a_stFunctionTable[M_eFuncIdInterpret(CFast_g_a_stPseudoTree[E_ti_Function])].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Function]+1, &CFast_g_a_stParam[7]) ;
}
void CFast_CallFunction8_NoStatic(void)
{
a_stFunctionTable[M_eFuncIdInterpret(CFast_g_a_stPseudoTree[E_ti_Function])].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Function]+1, &CFast_g_a_stParam[8]) ;
}
void CFast_CallFunction9_NoStatic(void)
{
a_stFunctionTable[M_eFuncIdInterpret(CFast_g_a_stPseudoTree[E_ti_Function])].p_fn_p_stFunctionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Function]+1, &CFast_g_a_stParam[9]) ;
}
/***************************************/
long CFast_CallCondition_Static(int iInd)
{
long temp;
a_stConditionTable[M_eCondIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stConditionFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &temp) ;
return temp;
}
long CFast_CallCondition_NoStatic(void)
{
long temp;
a_stConditionTable[M_eCondIdInterpret(CFast_g_a_stPseudoTree[E_ti_Condition])].p_fn_p_stConditionFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Condition]+1, &temp) ;
return temp;
}
/***************************************/
void CFast_CallVector0_Static (int iInd) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, gp_stPseudoTree+iInd, &CFast_g_a_stParam[0]) ;
}
void CFast_CallVector1_Static (int iInd) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, gp_stPseudoTree+iInd, &CFast_g_a_stParam[1]) ;
}
void CFast_CallVector2_Static (int iInd) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, gp_stPseudoTree+iInd, &CFast_g_a_stParam[2]) ;
}
void CFast_CallVector3_Static (int iInd) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, gp_stPseudoTree+iInd, &CFast_g_a_stParam[3]) ;
}
void CFast_CallVector4_Static (int iInd) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, gp_stPseudoTree+iInd, &CFast_g_a_stParam[4]) ;
}
void CFast_CallVector5_Static (int iInd) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, gp_stPseudoTree+iInd, &CFast_g_a_stParam[5]) ;
}
void CFast_CallVector6_Static (int iInd) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, gp_stPseudoTree+iInd, &CFast_g_a_stParam[6]) ;
}
void CFast_CallVector7_Static (int iInd) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, gp_stPseudoTree+iInd, &CFast_g_a_stParam[7]) ;
}
void CFast_CallVector8_Static (int iInd) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, gp_stPseudoTree+iInd, &CFast_g_a_stParam[8]) ;
}
void CFast_CallVector0_NoStatic (void) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[6], &CFast_g_a_stParam[0]) ;
}
void CFast_CallVector1_NoStatic (void) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[6], &CFast_g_a_stParam[1]) ;
}
void CFast_CallVector2_NoStatic (void) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[6], &CFast_g_a_stParam[2]) ;
}
void CFast_CallVector3_NoStatic (void) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[6], &CFast_g_a_stParam[3]) ;
}
void CFast_CallVector4_NoStatic (void) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[6], &CFast_g_a_stParam[4]) ;
}
void CFast_CallVector5_NoStatic (void) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[6], &CFast_g_a_stParam[5]) ;
}
void CFast_CallVector6_NoStatic (void) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[6], &CFast_g_a_stParam[6]) ;
}
void CFast_CallVector7_NoStatic (void) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[6], &CFast_g_a_stParam[7]) ;
}
void CFast_CallVector8_NoStatic (void) {
a_stTypeTable[E_ti_Vector].p_fn_p_stEvalTypePtr(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[6], &CFast_g_a_stParam[8]) ;
}
/***************************************/
void CFast_CallOperator0_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[0]) ;
}
void CFast_CallOperator1_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[1]) ;
}
void CFast_CallOperator2_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[2]) ;
}
void CFast_CallOperator3_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[3]) ;
}
void CFast_CallOperator4_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[4]) ;
}
void CFast_CallOperator5_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[5]) ;
}
void CFast_CallOperator6_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[6]) ;
}
void CFast_CallOperator7_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[7]) ;
}
void CFast_CallOperator8_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[8]) ;
}
void CFast_CallOperator9_Static(int iInd)
{
a_stOperatorTable[M_eOperatorIdInterpret(gp_stPseudoTree+iInd)].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, gp_stPseudoTree+iInd+1, &CFast_g_a_stParam[9]) ;
}
void CFast_CallOperator0_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[0]) ;
}
void CFast_CallOperator1_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[1]) ;
}
void CFast_CallOperator2_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[2]) ;
}
void CFast_CallOperator3_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[3]) ;
}
void CFast_CallOperator4_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[4]) ;
}
void CFast_CallOperator5_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[5]) ;
}
void CFast_CallOperator6_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[6]) ;
}
void CFast_CallOperator7_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[7]) ;
}
void CFast_CallOperator8_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[8]) ;
}
void CFast_CallOperator9_NoStatic(void)
{
a_stOperatorTable[M_eOperatorIdInterpret(CFast_g_a_stPseudoTree[E_ti_Operator])].p_fn_p_stOperatorFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Operator]+1, &CFast_g_a_stParam[9]) ;
}
/***************************************/
void CFast_CallProcedure_Static(int iInd)
{
a_stProcedureTable[M_eProcedureIdInterpret(gp_stPseudoTree + iInd)].p_fn_p_stProcedureFunction(g_hSuperObjectPerso, gp_stPseudoTree + iInd+1) ;
}
void CFast_CallProcedure_NoStatic(void)
{
a_stProcedureTable[M_eProcedureIdInterpret(CFast_g_a_stPseudoTree[E_ti_Procedure])].p_fn_p_stProcedureFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_Procedure]+1) ;
}
/***************************************/
void CFast_CallMetaActionInit_Static(int iInd)
{
a_stMetaActionTable[M_eMetaActionIdInterpret(gp_stPseudoTree + iInd)].p_fn_p_stMetaActionInitFunction(g_hSuperObjectPerso, gp_stPseudoTree + iInd+1) ;
}
void CFast_CallMetaActionInit_NoStatic(void)
{
a_stMetaActionTable[M_eMetaActionIdInterpret(CFast_g_a_stPseudoTree[E_ti_MetaAction])].p_fn_p_stMetaActionInitFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_MetaAction]+1) ;
}
/***************************************/
unsigned char CFast_CallMetaAction(int iFunc)
{
return a_stMetaActionTable[iFunc].p_fn_ucMetaActionFunction(g_hSuperObjectPerso) ;
}
/***************************************/
void CFast_CallKeyword_Static(int iInd, int iReturn)
{
a_stKeyWordTable[M_eKeyWordIdInterpret(gp_stPseudoTree + iInd)].p_fn_p_stKeyWordFunction(g_hSuperObjectPerso, gp_stPseudoTree + iInd + 1, &CFast_g_a_stParam[iReturn]) ;
}
void CFast_CallKeyword_NoStatic(int iReturn)
{
a_stKeyWordTable[M_eKeyWordIdInterpret(CFast_g_a_stPseudoTree[E_ti_KeyWord])].p_fn_p_stKeyWordFunction(g_hSuperObjectPerso, CFast_g_a_stPseudoTree[E_ti_KeyWord] + 1, &CFast_g_a_stParam[iReturn]) ;
}
void CFast_vInitStaticTree (struct tdstNodeInterpret_ *p_stStaticTree, long lSize,
struct tdstNodeInterpret_ *p_stRefTree ){
long i;
for ( i=0 ; i<lSize ; i++, p_stStaticTree++ ) {
if ( M_GetTypeInterpret(p_stStaticTree) == E_ti_Unknown ) {
memcpy ( p_stStaticTree,
&p_stRefTree[M_lValueInterpret(p_stStaticTree)],
sizeof(struct tdstNodeInterpret_) ) ;
#ifndef U64
/* special processing for sound, because the pointers points to dynamically allocated memory */
if( M_GetTypeInterpret(p_stStaticTree) == E_ti_SoundEventRef
&& SNA_fn_ucGetLoadType()==SNA_SAVE_SNAPSHOT )
/* we save the id of the sound event and the pointer */
SNA_fn_vWriteSoundEntryInSoundTableFile(
SND_fn_ulGetEventBinIdFromPointer(M_SoundEventInterpret(p_stStaticTree)),
(unsigned long)&(M_SoundEventInterpret(p_stStaticTree)) );
#endif
}
}
}
/*
******************************************************************
* INCLUDE ALL ALL .CXX FOR MODELS
******************************************************************
*/
#ifndef U64
#define DEBUG_CFAST
#define U64_IA_EN_C
#else
/*#define U64_IA_EN_C*/
#endif
#ifndef CODEWARRIOR
#pragma warning(disable : 4101)
#endif
#include "CFastf.cxx"
#ifndef CODEWARRIOR
#pragma warning(default: 4101)
#endif
//XB 05/08/99
#endif /* D_THROW_CFAST_AI */
//End XB

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,486 @@
/*---------------------------------------------------------------------------*/
/* DsgMemC.cpp : Definition of variables (Translation of AI in code C)*/
/* auteur : Yann Le GUYADER*/
/*---------------------------------------------------------------------------*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Erm.h"
#include "AI_Struc.h"
/* 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 "Intell.h" /* for the fn_lEvalTree declaration*/
#include "DsgMem.h"
#include "ReadRule.h"
#include "Convert.h"
#include "specif/AITools.h"
//XB 05/08/99
#ifndef D_THROW_CFAST_AI
//End XB
#include "DsgMemC.h"
extern AI_tdstMind *p_stGlobalMind;
/*******************************************************************************************************************/
/* Get Functions to access DsgVar */
/*******************************************************************************************************************/
/*
MTH_tdxReal CFast_fn_xGetDsgVarFloat(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return ((MTH_tdxReal) (*(MTH_tdxReal *)M_GetDsgVarAddr(p_stPerso,ucId)));
}
C_TypeOfPerso CFast_fn_hGetDsgVarPerso(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return ((C_TypeOfPerso) *(C_TypeOfPerso *)M_GetDsgVarAddr(p_stPerso,ucId));
}
// eDsgVarType_Vector
MTH3D_tdstVector *CFast_fn_p_stGetDsgVarVector(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return ((MTH3D_tdstVector *)(M_GetDsgVarAddr(p_stPerso,ucId)));
}
// eDsgVarType_Caps
unsigned long CFast_fn_ucGetDsgVarCaps(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return (*((unsigned long *)(M_GetDsgVarAddr(p_stPerso,ucId))));
}
// eDsgVarType_Graph
C_TypeOfGraph CFast_fn_hGetDsgVarGraph(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return(*((C_TypeOfGraph *)M_GetDsgVarAddr(p_stPerso,ucId)));
}
// eDsgVarType_WayPoint
C_TypeOfWayPoint CFast_fn_hGetDsgVarWayPoint(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return (*((C_TypeOfWayPoint *)M_GetDsgVarAddr(p_stPerso,ucId)));
}
// eDsgVarType_Action
C_TypeOfAction CFast_fn_xGetDsgVarAction(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return (*((C_TypeOfAction *)M_GetDsgVarAddr(p_stPerso,ucId)));
}
// eDsgVarType_Comport
C_TypeOfComport CFast_fn_xGetDsgVarComport(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return (*((C_TypeOfComport *)M_GetDsgVarAddr(p_stPerso,ucId)));
}
// eDsgVarType_List
C_TypeOfList1 * CFast_fn_p_xGetDsgVarList(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return((C_TypeOfList1 *)M_GetDsgVarAddr(p_stPerso,ucId));
}
// eDsgVarType_Boolean
long CFast_fn_lGetDsgVarBoolean(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return((long) (* ((C_TypeOfBoolean *)M_GetDsgVarAddr(p_stPerso,ucId))));
}
// eDsgVarType__128To127
long CFast_fn_lGetDsgVar_128To127(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return( (long) (* ((C_TypeOf_128To127 *)M_GetDsgVarAddr(p_stPerso,ucId)) ) );
}
// eDsgVarType_0To255
long CFast_fn_lGetDsgVar0To255(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return( (long) (* ((C_TypeOf0To255 *)M_GetDsgVarAddr(p_stPerso,ucId)) ) );
}
// eDsgVarType__32768To32767
long CFast_fn_lGetDsgVar_32768To32767(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return( (long) (* ((C_TypeOf_32768To32767 *)M_GetDsgVarAddr(p_stPerso,ucId)) ) );
}
// eDsgVarType_0To65535
long CFast_fn_lGetDsgVar0To65535(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return((long)(*((C_TypeOf0To65535 *)M_GetDsgVarAddr(p_stPerso,ucId))));
}
// eDsgVarType_Integer
long CFast_fn_lGetDsgVarInteger(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return ( (long) (* ((C_TypeOfInteger *)M_GetDsgVarAddr(p_stPerso,ucId)) ) );
}
// eDsgVarType_PositiveInteger
long CFast_fn_lGetDsgVarPositiveInteger(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return ( (long) (* ((C_TypeOfPositiveInteger *)M_GetDsgVarAddr(p_stPerso,ucId)) ) );
}
// eDsgVarType_GameMaterial
C_TypeOfGameMaterial CFast_fn_xGetDsgVarGameMaterial(unsigned char ucId, AI_tdstMind *p_stPerso)
{
return ( (C_TypeOfGameMaterial) ( *((C_TypeOfGameMaterial *)M_GetDsgVarAddr(p_stPerso,ucId)) ) );
}
*/
/* eDsgVarType_PersoArray*/
/* eDsgVarType_VectorArray*/
/* eDsgVarType_FloatArray*/
/* eDsgVarType_IntegerArray*/
/* eDsgVarType_WayPointArray*/
/* eDsgVarType_TextArray*/
HIE_tdxHandleToSuperObject CFast_fn_hGetDsgVarPersoArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex)
{
return(M_tduGetSetParam_hSuperObject((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex))));
}
MTH3D_tdstVector *CFast_fn_p_stGetDsgVarVectorArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex)
{
#if defined(OPTIMIZED_ARRAY)
return((MTH3D_tdstVector *)(M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex)));
#else
return(&M_tduGetSetParam_stVertexValue((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex))));
#endif
}
MTH_tdxReal CFast_fn_xGetDsgVarFloatArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex)
{
return(M_tduGetSetParam_xValue((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex))));
}
long CFast_fn_lGetDsgVarIntegerArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex)
{
return(M_tduGetSetParam_lValue((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex))));
}
C_TypeOfWayPoint CFast_fn_hGetDsgVarWayPointArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex)
{
return(M_tduGetSetParam_hWayPoint((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex))));
}
char *CFast_fn_p_szGetDsgVarTextArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex)
{
return(M_tduGetSetParam_szString((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex))));
}
/*******************************************************************************************************************/
/* Set Functions to access DsgVar */
/*******************************************************************************************************************/
/* eDsgVarType_Float*/
void CFast_fn_vSetDsgVarFloat(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfFloat xValue)
{
*((C_TypeOfFloat *)M_GetDsgVarAddr(p_stPerso,ucId)) = ((C_TypeOfFloat) xValue);
}
void LocalCFast_fn_vSetDsgVarFloat(unsigned char ucId, C_TypeOfFloat xValue)
{
*((C_TypeOfFloat *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) = ((C_TypeOfFloat) xValue);
}
/* eDsgVarType_Perso*/
void CFast_fn_vSetDsgVarPerso(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfPerso hPerso)
{
*(C_TypeOfPerso *)(M_GetDsgVarAddr(p_stPerso,ucId)) = hPerso;
}
void LocalCFast_fn_vSetDsgVarPerso(unsigned char ucId, C_TypeOfPerso hPerso)
{
*(C_TypeOfPerso *)(M_GetDsgVarAddr(p_stGlobalMind,ucId)) = hPerso;
}
/* eDsgVarType_Perso*/
void CFast_fn_vSetDsgVarPersoWithEngine(unsigned char ucId, AI_tdstMind *p_stPerso, struct tdstEngineObject_ *hPerso)
{
if (hPerso)
*(C_TypeOfPerso *)(M_GetDsgVarAddr(p_stPerso,ucId)) = (C_TypeOfPerso)M_GetSuperObject(hPerso);
else
*(C_TypeOfPerso *)(M_GetDsgVarAddr(p_stPerso,ucId)) = (C_TypeOfPerso) NULL;
}
void LocalCFast_fn_vSetDsgVarPersoWithEngine(unsigned char ucId, struct tdstEngineObject_ *hPerso)
{
if (hPerso)
*(C_TypeOfPerso *)(M_GetDsgVarAddr(p_stGlobalMind,ucId)) = (C_TypeOfPerso)M_GetSuperObject(hPerso);
else
*(C_TypeOfPerso *)(M_GetDsgVarAddr(p_stGlobalMind,ucId)) = (C_TypeOfPerso) NULL;
}
/* eDsgVarType_Action*/
void CFast_fn_vSetDsgVarAction(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfAction hAction)
{
*((C_TypeOfAction *)M_GetDsgVarAddr(p_stPerso,ucId))= hAction;
}
void LocalCFast_fn_vSetDsgVarAction(unsigned char ucId,C_TypeOfAction hAction)
{
*((C_TypeOfAction *)M_GetDsgVarAddr(p_stGlobalMind,ucId))= hAction;
}
/* eDsgVarType_Comport*/
void CFast_fn_vSetDsgVarComport(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfComport p_stComport)
{
*((C_TypeOfComport *)M_GetDsgVarAddr(p_stPerso,ucId)) = (C_TypeOfComport) p_stComport;
}
void LocalCFast_fn_vSetDsgVarComport(unsigned char ucId, C_TypeOfComport p_stComport)
{
*((C_TypeOfComport *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) = (C_TypeOfComport) p_stComport;
}
/* eDsgVarType_Vector*/
void CFast_fn_vSetDsgVarVector(unsigned char ucId, AI_tdstMind *p_stPerso,MTH3D_tdstVector *p_stVertex)
{
MTH3D_M_vCopyVector(((C_TypeOfVector *)M_GetDsgVarAddr(p_stPerso,ucId)),p_stVertex);
}
void LocalCFast_fn_vSetDsgVarVector(unsigned char ucId, MTH3D_tdstVector *p_stVertex)
{
MTH3D_M_vCopyVector(((C_TypeOfVector *)M_GetDsgVarAddr(p_stGlobalMind,ucId)),p_stVertex);
}
/* eDsgVarType_Caps*/
void CFast_fn_vSetDsgVarCaps(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfCaps ulCaps)
{
*((C_TypeOfCaps *)M_GetDsgVarAddr(p_stPerso,ucId)) =ulCaps;
}
void LocalCFast_fn_vSetDsgVarCaps(unsigned char ucId, C_TypeOfCaps ulCaps)
{
*((C_TypeOfCaps *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) =ulCaps;
}
/* eDsgVarType_Graph*/
void CFast_fn_vSetDsgVarGraph(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfGraph hGraph)
{
*((C_TypeOfGraph *)M_GetDsgVarAddr(p_stPerso,ucId)) = hGraph;
}
void LocalCFast_fn_vSetDsgVarGraph(unsigned char ucId,C_TypeOfGraph hGraph)
{
*((C_TypeOfGraph *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) = hGraph;
}
/* eDsgVarType_WayPoint*/
void CFast_fn_vSetDsgVarWayPoint(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfWayPoint hWayPoint)
{
*((C_TypeOfWayPoint *)M_GetDsgVarAddr(p_stPerso,ucId)) = hWayPoint;
}
void LocalCFast_fn_vSetDsgVarWayPoint(unsigned char ucId, C_TypeOfWayPoint hWayPoint)
{
*((C_TypeOfWayPoint *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) = hWayPoint;
}
/* eDsgVarType_List*/
void CFast_fn_vSetDsgVarList(unsigned char ucId, AI_tdstMind *p_stPerso, tdstList *p_SrcList)
{
tdstList *p_TgtList = (tdstList *)M_GetDsgVarAddr(p_stPerso,ucId);
p_TgtList->ucNbElt = (unsigned char) M_Min(p_SrcList->ucNbElt, p_TgtList->ucMaxSize);
memcpy((void*) p_TgtList->d_TabElt,(void*) p_SrcList->d_TabElt,p_TgtList->ucNbElt*C_SizeOfPersoInList);
}
void LocalCFast_fn_vSetDsgVarList(unsigned char ucId, tdstList *p_SrcList)
{
tdstList *p_TgtList = (tdstList *)M_GetDsgVarAddr(p_stGlobalMind,ucId);
p_TgtList->ucNbElt = (unsigned char) M_Min(p_SrcList->ucNbElt, p_TgtList->ucMaxSize);
memcpy((void*) p_TgtList->d_TabElt,(void*) p_SrcList->d_TabElt,p_TgtList->ucNbElt*C_SizeOfPersoInList);
}
/* eDsgVarType_Boolean*/
void CFast_fn_vSetDsgVarBoolean(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfBoolean bValue)
{
*((C_TypeOfBoolean *)M_GetDsgVarAddr(p_stPerso,ucId)) = (C_TypeOfBoolean) bValue;
}
void LocalCFast_fn_vSetDsgVarBoolean(unsigned char ucId, C_TypeOfBoolean bValue)
{
*((C_TypeOfBoolean *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) = (C_TypeOfBoolean) bValue;
}
/* eDsgVarType__128To127*/
void CFast_fn_vSetDsgVar_128To127(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue)
{
*((C_TypeOf_128To127 *)M_GetDsgVarAddr(p_stPerso,ucId)) = (C_TypeOf_128To127) lValue;
}
void LocalCFast_fn_vSetDsgVar_128To127(unsigned char ucId, long lValue)
{
*((C_TypeOf_128To127 *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) = (C_TypeOf_128To127) lValue;
}
/* eDsgVarType_0To255*/
void CFast_fn_vSetDsgVar0To255(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue)
{
*((C_TypeOf0To255 *)M_GetDsgVarAddr(p_stPerso,ucId)) = (C_TypeOf0To255) lValue;
}
void LocalCFast_fn_vSetDsgVar0To255(unsigned char ucId, long lValue)
{
*((C_TypeOf0To255 *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) = (C_TypeOf0To255) lValue;
}
/* eDsgVarType__32768To32767*/
void CFast_fn_vSetDsgVar_32768To32767(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue)
{
*((C_TypeOf_32768To32767 *)M_GetDsgVarAddr(p_stPerso,ucId)) = (C_TypeOf_32768To32767) lValue;
}
void LocalCFast_fn_vSetDsgVar_32768To32767(unsigned char ucId, long lValue)
{
*((C_TypeOf_32768To32767 *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) = (C_TypeOf_32768To32767) lValue;
}
/* eDsgVarType_0To65535*/
void CFast_fn_vSetDsgVar0To65535(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue)
{
*((C_TypeOf0To65535 *)(M_GetDsgVarAddr(p_stPerso,ucId))) = (C_TypeOf0To65535) lValue;
}
void LocalCFast_fn_vSetDsgVar0To65535(unsigned char ucId, long lValue)
{
*((C_TypeOf0To65535 *)(M_GetDsgVarAddr(p_stGlobalMind,ucId))) = (C_TypeOf0To65535) lValue;
}
/* eDsgVarType_Integer*/
void CFast_fn_vSetDsgVarInteger(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue)
{
*((C_TypeOfInteger *)(M_GetDsgVarAddr(p_stPerso,ucId))) = (C_TypeOfInteger) lValue;
}
void LocalCFast_fn_vSetDsgVarInteger(unsigned char ucId, long lValue)
{
*((C_TypeOfInteger *)(M_GetDsgVarAddr(p_stGlobalMind,ucId))) = (C_TypeOfInteger) lValue;
}
/* eDsgVarType_PositiveInteger*/
void CFast_fn_vSetDsgVarPositiveInteger(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue)
{
*((C_TypeOfPositiveInteger *)(M_GetDsgVarAddr(p_stPerso,ucId))) = (C_TypeOfPositiveInteger) lValue;
}
void LocalCFast_fn_vSetDsgVarPositiveInteger(unsigned char ucId, long lValue)
{
*((C_TypeOfPositiveInteger *)(M_GetDsgVarAddr(p_stGlobalMind,ucId))) = (C_TypeOfPositiveInteger) lValue;
}
/* eDsgVarType_GameMaterial*/
void CFast_fn_vSetDsgVarGameMaterial(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfGameMaterial hGameMaterial)
{
*((C_TypeOfGameMaterial *)M_GetDsgVarAddr(p_stPerso,ucId)) = hGameMaterial;
}
void LocalCFast_fn_vSetDsgVarGameMaterial(unsigned char ucId, C_TypeOfGameMaterial hGameMaterial)
{
*((C_TypeOfGameMaterial *)M_GetDsgVarAddr(p_stGlobalMind,ucId)) = hGameMaterial;
}
/* eDsgVarType_PersoArray*/
void CFast_fn_vSetDsgVarPersoArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, C_TypeOfPerso hPerso)
{
( M_tduGetSetParam_hSuperObject((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex)))) = hPerso;
}
void LocalCFast_fn_vSetDsgVarPersoArray(unsigned char ucId, unsigned char ucTabIndex, C_TypeOfPerso hPerso)
{
( M_tduGetSetParam_hSuperObject((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stGlobalMind,ucId),ucTabIndex)))) = hPerso;
}
void CFast_fn_vSetDsgVarPersoArrayWithEngine(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, struct tdstEngineObject_ *hPerso)
{
if (hPerso)
( M_tduGetSetParam_hSuperObject((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex)))) = (C_TypeOfPerso)M_GetSuperObject(hPerso);
else
( M_tduGetSetParam_hSuperObject((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex)))) = (C_TypeOfPerso) NULL;
}
void LocalCFast_fn_vSetDsgVarPersoArrayWithEngine(unsigned char ucId, unsigned char ucTabIndex, struct tdstEngineObject_ *hPerso)
{
if (hPerso)
( M_tduGetSetParam_hSuperObject((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stGlobalMind,ucId),ucTabIndex)))) = (C_TypeOfPerso)M_GetSuperObject(hPerso);
else
( M_tduGetSetParam_hSuperObject((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stGlobalMind,ucId),ucTabIndex)))) = (C_TypeOfPerso) NULL;
}
/* eDsgVarType_VectorArray*/
void CFast_fn_vSetDsgVarVectorArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, MTH3D_tdstVector *p_stVector)
{
#if defined(OPTIMIZED_ARRAY)
MTH3D_M_vCopyVector((MTH3D_tdstVector *)(M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex)), p_stVector);
#else
MTH3D_M_vCopyVector((MTH3D_tdstVector *)(&M_tduGetSetParam_stVectorValue((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex)))), p_stVector);
#endif
}
void LocalCFast_fn_vSetDsgVarVectorArray(unsigned char ucId, unsigned char ucTabIndex, MTH3D_tdstVector *p_stVector)
{
#if defined(OPTIMIZED_ARRAY)
MTH3D_M_vCopyVector((MTH3D_tdstVector *)(M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stGlobalMind,ucId),ucTabIndex)), p_stVector);
#else
MTH3D_M_vCopyVector((MTH3D_tdstVector *)(&M_tduGetSetParam_stVectorValue((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stGlobalMind,ucId),ucTabIndex)))), p_stVector);
#endif
}
/* eDsgVarType_FloatArray*/
void CFast_fn_vSetDsgVarFloatArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, MTH_tdxReal xValue)
{
*((MTH_tdxReal *)&M_tduGetSetParam_xValue((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex)))) = xValue;
}
void LocalCFast_fn_vSetDsgVarFloatArray(unsigned char ucId, unsigned char ucTabIndex, MTH_tdxReal xValue)
{
*((MTH_tdxReal *)&M_tduGetSetParam_xValue((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stGlobalMind,ucId),ucTabIndex)))) = xValue;
}
/* eDsgVarType_IntegerArray*/
void CFast_fn_vSetDsgVarIntegerArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, long lValue)
{
*((long *)&M_tduGetSetParam_lValue((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex)))) = lValue;
}
void LocalCFast_fn_vSetDsgVarIntegerArray(unsigned char ucId, unsigned char ucTabIndex, long lValue)
{
*((long *)&M_tduGetSetParam_lValue((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stGlobalMind,ucId),ucTabIndex)))) = lValue;
}
/* eDsgVarType_WayPointArray*/
void CFast_fn_vSetDsgVarWayPointArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, C_TypeOfWayPoint hWayPoint)
{
*((C_TypeOfWayPoint *)&M_tduGetSetParam_hWayPoint((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex))))= hWayPoint;
}
void LocalCFast_fn_vSetDsgVarWayPointArray(unsigned char ucId, unsigned char ucTabIndex, C_TypeOfWayPoint hWayPoint)
{
*((C_TypeOfWayPoint *)&M_tduGetSetParam_hWayPoint((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stGlobalMind,ucId),ucTabIndex))))= hWayPoint;
}
/* eDsgVarType_TextArray*/
void CFast_fn_vSetDsgVarTextArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, char *p_szString)
{
strcpy(((char *)M_tduGetSetParam_szString((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stPerso,ucId),ucTabIndex)))), p_szString);
}
void LocalCFast_fn_vSetDsgVarTextArray(unsigned char ucId, unsigned char ucTabIndex, char *p_szString)
{
strcpy(((char *)M_tduGetSetParam_szString((M_ARRAY_ELEMENT((tdstArray*)M_GetDsgVarAddr(p_stGlobalMind,ucId),ucTabIndex)))), p_szString);
}
/* A voir
unsigned char fn_ucSetDsgVarArray(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
unsigned char ret=C_INVALID_SET;
tdstArray *p_stArray=(tdstArray*) pMyVarAddr;
tdeDsgVarTypeId eDsgVarTypeId=M_ARRAY_TYPE(p_stArray);
#if defined(__DEBUG_AI__)
if (M_GetSetParam_Type(p_stGetSetParam)==fn_GetDsgVarType(eDsgVarTypeId))
if (ucIndex<M_ARRAY_SIZE(p_stArray))
#endif
{
tdp_fn_ucSetDsgVarFunctionPtr p_fn_ucSetDsgVar=fn_p_fn_pGetDsgVarSetFunctionPtr(eDsgVarTypeId);
ret=p_fn_ucSetDsgVar((void *) M_ARRAY_ELEMENT(p_stArray,ucIndex),0,p_stGetSetParam);
}
return(ret);
}
*/
//XB 05/08/99
#endif /* D_THROW_CFAST_AI */
//End XB

View File

@@ -0,0 +1,240 @@
#ifndef D_DsgMemC
#define D_DsgMemC
/**************************************/
#if !defined(CPA_EXPORT)
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif /*CPA_WANTS_IMPORT || CPA_WANTS_EXPORT*/
#endif /*CPA_EXPORT*/
/**************************************/
#undef extern
#define EXTERN_AI_DLL extern
/*******************************************************************************/
/*******************************************************************************************************************/
/* Get the real indice of variable */
/*******************************************************************************************************************/
#define M_CFast_ucGetRealIndice(Indice1) (unsigned char)M_lDsgVarIdInterpret(p_stRefTree+Indice1)
#define M_CFast_hGetPersoRef(Indice) (HIE_tdxHandleToSuperObject)M_GetSuperObject(M_p_stPersoRefInterpret(p_stRefTree+Indice))
/*******************************************************************************************************************/
/* Get Functions to access DsgVar */
/*******************************************************************************************************************/
/*
MTH_tdxReal CFast_fn_xGetDsgVarFloat(unsigned char ucId, AI_tdstMind *p_stPerso);
C_TypeOfPerso CFast_fn_hGetDsgVarPerso(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_Vector
MTH3D_tdstVector *CFast_fn_p_stGetDsgVarVector(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_Caps
unsigned long CFast_fn_ucGetDsgVarCaps(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_Graph
C_TypeOfGraph CFast_fn_hGetDsgVarGraph(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_WayPoint
C_TypeOfWayPoint CFast_fn_hGetDsgVarWayPoint(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_Action
C_TypeOfAction CFast_fn_xGetDsgVarAction(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_Comport
C_TypeOfComport CFast_fn_xGetDsgVarComport(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_List
C_TypeOfList1 * CFast_fn_p_xGetDsgVarList(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_Boolean
long CFast_fn_lGetDsgVarBoolean(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType__128To127
long CFast_fn_lGetDsgVar_128To127(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_0To255
long CFast_fn_lGetDsgVar0To255(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType__32768To32767
long CFast_fn_lGetDsgVar_32768To32767(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_0To65535
long CFast_fn_lGetDsgVar0To65535(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_Integer
long CFast_fn_lGetDsgVarInteger(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_PositiveInteger
long CFast_fn_lGetDsgVarPositiveInteger(unsigned char ucId, AI_tdstMind *p_stPerso);
// eDsgVarType_GameMaterial
C_TypeOfGameMaterial CFast_fn_xGetDsgVarGameMaterial(unsigned char ucId, AI_tdstMind *p_stPerso);
*/
#define CFast_fn_xGetDsgVarFloat(ucId, p_stPerso) ((MTH_tdxReal) (*(MTH_tdxReal *)M_GetDsgVarAddr(p_stPerso,ucId)))
#define LocalCFast_fn_xGetDsgVarFloat(ucId) ((MTH_tdxReal) (*(MTH_tdxReal *)M_LocalGetDsgVarAddr(NULL,ucId)))
#define CFast_fn_hGetDsgVarPerso(ucId,p_stPerso) ((C_TypeOfPerso) *(C_TypeOfPerso *)M_GetDsgVarAddr(p_stPerso,ucId))
#define LocalCFast_fn_hGetDsgVarPerso(ucId) ((C_TypeOfPerso) *(C_TypeOfPerso *)M_LocalGetDsgVarAddr(NULL,ucId))
#define CFast_fn_p_stGetDsgVarVector(ucId,p_stPerso) ((MTH3D_tdstVector *)(M_GetDsgVarAddr(p_stPerso,ucId)))
#define LocalCFast_fn_p_stGetDsgVarVector(ucId) ((MTH3D_tdstVector *)(M_LocalGetDsgVarAddr(NULL,ucId)))
#define CFast_fn_ucGetDsgVarCaps(ucId, p_stPerso) (*((unsigned long *)(M_GetDsgVarAddr(p_stPerso,ucId))))
#define LocalCFast_fn_ucGetDsgVarCaps(ucId) (*((unsigned long *)(M_LocalGetDsgVarAddr(NULL,ucId))))
#define CFast_fn_hGetDsgVarGraph(ucId,p_stPerso) (*((C_TypeOfGraph *)M_GetDsgVarAddr(p_stPerso,ucId)))
#define LocalCFast_fn_hGetDsgVarGraph(ucId) (*((C_TypeOfGraph *)M_LocalGetDsgVarAddr(NULL,ucId)))
#define CFast_fn_hGetDsgVarWayPoint(ucId,p_stPerso) (*((C_TypeOfWayPoint *)M_GetDsgVarAddr(p_stPerso,ucId)))
#define LocalCFast_fn_hGetDsgVarWayPoint(ucId) (*((C_TypeOfWayPoint *)M_LocalGetDsgVarAddr(NULL,ucId)))
#define CFast_fn_xGetDsgVarAction(ucId,p_stPerso) (*((C_TypeOfAction *)M_GetDsgVarAddr(p_stPerso,ucId)))
#define LocalCFast_fn_xGetDsgVarAction(ucId) (*((C_TypeOfAction *)M_LocalGetDsgVarAddr(NULL,ucId)))
#define CFast_fn_xGetDsgVarComport(ucId,p_stPerso) (*((C_TypeOfComport *)M_GetDsgVarAddr(p_stPerso,ucId)))
#define LocalCFast_fn_xGetDsgVarComport(ucId) (*((C_TypeOfComport *)M_LocalGetDsgVarAddr(NULL,ucId)))
#define CFast_fn_p_xGetDsgVarList(ucId,p_stPerso) ((struct tdstList_ *)M_GetDsgVarAddr(p_stPerso,ucId))
#define LocalCFast_fn_p_xGetDsgVarList(ucId) ((struct tdstList_ *)M_LocalGetDsgVarAddr(NULL,ucId))
#define CFast_fn_lGetDsgVarBoolean(ucId,p_stPerso) ((long)(*((C_TypeOfBoolean *)M_GetDsgVarAddr(p_stPerso,ucId))))
#define LocalCFast_fn_lGetDsgVarBoolean(ucId) ((long)(*((C_TypeOfBoolean *)M_LocalGetDsgVarAddr(NULL,ucId))))
#define CFast_fn_lGetDsgVar_128To127(ucId,p_stPerso) ( (long)(*((C_TypeOf_128To127 *)M_GetDsgVarAddr(p_stPerso,ucId)) ) )
#define LocalCFast_fn_lGetDsgVar_128To127(ucId) ( (long)(*((C_TypeOf_128To127 *)M_LocalGetDsgVarAddr(NULL,ucId)) ) )
#define CFast_fn_lGetDsgVar0To255(ucId,p_stPerso) ((long)(*((C_TypeOf0To255 *)M_GetDsgVarAddr(p_stPerso,ucId)) ) )
#define LocalCFast_fn_lGetDsgVar0To255(ucId) ((long)(*((C_TypeOf0To255 *)M_LocalGetDsgVarAddr(NULL,ucId)) ) )
#define CFast_fn_lGetDsgVar_32768To32767(ucId,p_stPerso) ((long)(*((C_TypeOf_32768To32767 *)M_GetDsgVarAddr(p_stPerso,ucId)) ) )
#define LocalCFast_fn_lGetDsgVar_32768To32767(ucId) ((long)(*((C_TypeOf_32768To32767 *)M_LocalGetDsgVarAddr(NULL,ucId)) ) )
#define CFast_fn_lGetDsgVar0To65535(ucId,p_stPerso) ((long)(*((C_TypeOf0To65535 *)M_GetDsgVarAddr(p_stPerso,ucId))))
#define LocalCFast_fn_lGetDsgVar0To65535(ucId) ((long)(*((C_TypeOf0To65535 *)M_LocalGetDsgVarAddr(NULL,ucId))))
#define CFast_fn_lGetDsgVarInteger(ucId,p_stPerso) ((long)(*((C_TypeOfInteger *)M_GetDsgVarAddr(p_stPerso,ucId)) ) )
#define LocalCFast_fn_lGetDsgVarInteger(ucId) ((long)(*((C_TypeOfInteger *)M_LocalGetDsgVarAddr(NULL,ucId)) ) )
#define CFast_fn_lGetDsgVarPositiveInteger(ucId,p_stPerso) ((long)(*((C_TypeOfPositiveInteger *)M_GetDsgVarAddr(p_stPerso,ucId)) ) )
#define LocalCFast_fn_lGetDsgVarPositiveInteger(ucId) ((long)(*((C_TypeOfPositiveInteger *)M_LocalGetDsgVarAddr(NULL,ucId)) ) )
#define CFast_fn_xGetDsgVarGameMaterial(ucId,p_stPerso) ((C_TypeOfGameMaterial)(*((C_TypeOfGameMaterial *)M_GetDsgVarAddr(p_stPerso,ucId))))
#define LocalCFast_fn_xGetDsgVarGameMaterial(ucId) ((C_TypeOfGameMaterial)(*((C_TypeOfGameMaterial *)M_LocalGetDsgVarAddr(NULL,ucId))))
HIE_tdxHandleToSuperObject CFast_fn_hGetDsgVarPersoArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex);
HIE_tdxHandleToSuperObject LocalCFast_fn_hGetDsgVarPersoArray(unsigned char ucId, unsigned char ucTabIndex);
MTH3D_tdstVector *CFast_fn_p_stGetDsgVarVectorArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex);
MTH3D_tdstVector *LocalCFast_fn_p_stGetDsgVarVectorArray(unsigned char ucId, unsigned char ucTabIndex);
MTH_tdxReal CFast_fn_xGetDsgVarFloatArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex);
MTH_tdxReal LocalCFast_fn_xGetDsgVarFloatArray(unsigned char ucId, unsigned char ucTabIndex);
long CFast_fn_lGetDsgVarIntegerArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex);
long LocalCFast_fn_lGetDsgVarIntegerArray(unsigned char ucId, unsigned char ucTabIndex);
C_TypeOfWayPoint CFast_fn_hGetDsgVarWayPointArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex);
C_TypeOfWayPoint LocalCFast_fn_hGetDsgVarWayPointArray(unsigned char ucId, unsigned char ucTabIndex);
char *CFast_fn_p_szGetDsgVarTextArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex);
char *LocalCFast_fn_p_szGetDsgVarTextArray(unsigned char ucId, unsigned char ucTabIndex);
/*******************************************************************************************************************/
/* Set Functions to access DsgVar */
/*******************************************************************************************************************/
/* eDsgVarType_Float*/
void CFast_fn_vSetDsgVarFloat(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfFloat xValue);
void LocalCFast_fn_vSetDsgVarFloat(unsigned char ucId, C_TypeOfFloat xValue);
/* eDsgVarType_Perso*/
void CFast_fn_vSetDsgVarPerso(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfPerso hPerso);
void LocalCFast_fn_vSetDsgVarPerso(unsigned char ucId, C_TypeOfPerso hPerso);
void CFast_fn_vSetDsgVarPersoWithEngine(unsigned char ucId, AI_tdstMind *p_stPerso, struct tdstEngineObject_ *hPerso);
void LocalCFast_fn_vSetDsgVarPersoWithEngine(unsigned char ucId, struct tdstEngineObject_ *hPerso);
/* eDsgVarType_Action*/
void CFast_fn_vSetDsgVarAction(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfAction hAction);
void LocalCFast_fn_vSetDsgVarAction(unsigned char ucId, C_TypeOfAction hAction);
/* eDsgVarType_Comport*/
void CFast_fn_vSetDsgVarComport(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfComport p_stComport);
void LocalCFast_fn_vSetDsgVarComport(unsigned char ucId, C_TypeOfComport p_stComport);
/* eDsgVarType_Vector*/
void CFast_fn_vSetDsgVarVector(unsigned char ucId, AI_tdstMind *p_stPerso,MTH3D_tdstVector *p_stVertex);
void LocalCFast_fn_vSetDsgVarVector(unsigned char ucId,MTH3D_tdstVector *p_stVertex);
/* eDsgVarType_Caps*/
void CFast_fn_vSetDsgVarCaps(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfCaps ulCaps);
void LocalCFast_fn_vSetDsgVarCaps(unsigned char ucId, C_TypeOfCaps ulCaps);
/* eDsgVarType_Graph*/
void CFast_fn_vSetDsgVarGraph(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfGraph hGraph);
void LocalCFast_fn_vSetDsgVarGraph(unsigned char ucId, C_TypeOfGraph hGraph);
/* eDsgVarType_WayPoint*/
void CFast_fn_vSetDsgVarWayPoint(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfWayPoint hWayPoint);
void LocalCFast_fn_vSetDsgVarWayPoint(unsigned char ucId, C_TypeOfWayPoint hWayPoint);
/* eDsgVarType_List*/
void CFast_fn_vSetDsgVarList(unsigned char ucId, AI_tdstMind *p_stPerso, tdstList *p_SrcList);
void LocalCFast_fn_vSetDsgVarList(unsigned char ucId, tdstList *p_SrcList);
/* eDsgVarType_Boolean*/
void CFast_fn_vSetDsgVarBoolean(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfBoolean bValue);
void LocalCFast_fn_vSetDsgVarBoolean(unsigned char ucId, C_TypeOfBoolean bValue);
/* eDsgVarType__128To127*/
void CFast_fn_vSetDsgVar_128To127(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue);
void LocalCFast_fn_vSetDsgVar_128To127(unsigned char ucId, long lValue);
/* eDsgVarType_0To255*/
void CFast_fn_vSetDsgVar0To255(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue);
void LocalCFast_fn_vSetDsgVar0To255(unsigned char ucId, long lValue);
/* eDsgVarType__32768To32767*/
void CFast_fn_vSetDsgVar_32768To32767(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue);
void LocalCFast_fn_vSetDsgVar_32768To32767(unsigned char ucId, long lValue);
/* eDsgVarType_0To65535*/
void CFast_fn_vSetDsgVar0To65535(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue);
void LocalCFast_fn_vSetDsgVar0To65535(unsigned char ucId, long lValue);
/* eDsgVarType_Integer*/
void CFast_fn_vSetDsgVarInteger(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue);
void LocalCFast_fn_vSetDsgVarInteger(unsigned char ucId, long lValue);
/* eDsgVarType_PositiveInteger*/
void CFast_fn_vSetDsgVarPositiveInteger(unsigned char ucId, AI_tdstMind *p_stPerso, long lValue);
void LocalCFast_fn_vSetDsgVarPositiveInteger(unsigned char ucId, long lValue);
/* eDsgVarType_GameMaterial*/
void CFast_fn_vSetDsgVarGameMaterial(unsigned char ucId, AI_tdstMind *p_stPerso, C_TypeOfGameMaterial hGameMaterial);
void LocalCFast_fn_vSetDsgVarGameMaterial(unsigned char ucId, C_TypeOfGameMaterial hGameMaterial);
void CFast_fn_vSetDsgVarPersoArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, C_TypeOfPerso hPerso);
void CFast_fn_vSetDsgVarPersoArrayWithEngine(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, struct tdstEngineObject_ *hPerso) ;
void CFast_fn_vSetDsgVarVectorArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, MTH3D_tdstVector *p_stVector);
void CFast_fn_vSetDsgVarFloatArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, MTH_tdxReal xValue);
void CFast_fn_vSetDsgVarIntegerArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, long lValue);
void CFast_fn_vSetDsgVarWayPointArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, C_TypeOfWayPoint hWayPoint);
void CFast_fn_vSetDsgVarTextArray(unsigned char ucId, AI_tdstMind *p_stPerso, unsigned char ucTabIndex, char *p_szString);
void LocalCFast_fn_vSetDsgVarPersoArray(unsigned char ucId, unsigned char ucTabIndex, C_TypeOfPerso hPerso);
void LocalCFast_fn_vSetDsgVarPersoArrayWithEngine(unsigned char ucId, unsigned char ucTabIndex, struct tdstEngineObject_ *hPerso);
void LocalCFast_fn_vSetDsgVarVectorArray(unsigned char ucId, unsigned char ucTabIndex, MTH3D_tdstVector *p_stVector);
void LocalCFast_fn_vSetDsgVarFloatArray(unsigned char ucId, unsigned char ucTabIndex, MTH_tdxReal xValue);
void LocalCFast_fn_vSetDsgVarIntegerArray(unsigned char ucId, unsigned char ucTabIndex, long lValue);
void LocalCFast_fn_vSetDsgVarWayPointArray(unsigned char ucId, unsigned char ucTabIndex, C_TypeOfWayPoint hWayPoint);
void LocalCFast_fn_vSetDsgVarTextArray(unsigned char ucId, unsigned char ucTabIndex, char *p_szString);
/*******************************************************************************/
#undef EXTERN_AI_DLL
#endif /*D_DsgMem*/

View File

@@ -0,0 +1,320 @@
/*-----------------------------------------------------------------------------
* Description : AI - handle acces to field value in Perso structure
*-----------------------------------------------------------------------------
* Creation date : 23/10/96 Author : Olivier Couvreur
*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Erm.h"
#include "AI_Struc.h"
#include "StrIntel.h"
#include "Convert.h"
#include "specif/AiTools.h"
/*
unsigned char fn_ucSetFieldValue(enum tdeFieldId_ eFieldId, HIE_tdxHandleToSuperObject hSuperObjPerso, struct tdstGetSetParam_ *p_stGetSetParam)
{
enum tdeVariableType_ eType;
tdstGetSetParam stTempGetSetParam;
tdp_fn_cSetFunctionPtr p_fn_cSetFieldFunction;
eType=fn_eGetFieldType(eFieldId);
switch (eType)
{
case E_vt_Float:
{
M_Full_GetSetParam_Float(&stTempGetSetParam,M_ReturnParam_xValue(p_stGetSetParam));
}
break;
case E_vt_Vector:
{
M_Full_GetSetParam_p_stVertex(&stTempGetSetParam,&M_GetSetParam_stVertexValue(p_stGetSetParam));
}
break;
case E_vt_Perso:
{
M_Full_GetSetParam_Perso(&stTempGetSetParam,M_GetSetParam_p_stSupObjValue(p_stGetSetParam));
}
break;
default:
{
M_Full_GetSetParam_Integer(&stTempGetSetParam,M_ReturnParam_lValue(p_stGetSetParam));
#if defined(__DEBUG_AI__)
{
unsigned char ucTruncated=(unsigned char) (M_GetSetParam_Type(p_stGetSetParam)==E_vt_Float);
long lValue=M_GetSetParam_lValue(&stTempGetSetParam);
switch (eType)
{
case E_vt__128To127:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<-128) || (lValue>127) );
break;
case E_vt_0To255:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<0) || (lValue>255) );
break;
case E_vt__32768To32767:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<-32768) || (lValue>32767) );
break;
case E_vt_0To65535:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<0) || (lValue>65535) );
break;
case E_vt_PositiveInteger:
if (!ucTruncated) ucTruncated = (unsigned char) (lValue<0);
break;
case E_vt_Boolean:
case E_vt_1bit:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<0) || (lValue>1) );
break;
case E_vt_2bit:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<0) || (lValue>3) );
break;
case E_vt_3bit:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<0) || (lValue>7) );
break;
case E_vt_4bit:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<0) || (lValue>15) );
break;
case E_vt_5bit:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<0) || (lValue>31) );
break;
case E_vt_6bit:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<0) || (lValue>63) );
break;
case E_vt_7bit:
if (!ucTruncated) ucTruncated = (unsigned char) ( (lValue<0) || (lValue>127) );
break;
case E_vt_None:
default:
break;
}
if (ucTruncated)
{
char MyMsg[100];
sprintf(MyMsg,"Field id %d from p_stMind %p (%s)\n",eFieldId,hSuperObjPerso,AI_M_szGetPersoName(AI_M_stGetMindOfSuperObj(hSuperObjPerso)) );
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningTruncateAffectation, C_ucErmNoOpenInfoWindow,MyMsg);
}
}
#endif
}
}
p_fn_cSetFieldFunction=fn_p_fn_pGetFieldSetFunctionPtr(eFieldId);
return(p_fn_cSetFieldFunction(hSuperObjPerso,&stTempGetSetParam));
}
*/
/*
unsigned char fn_ucGetFieldValue(enum tdeFieldId_ eFieldId, HIE_tdxHandleToSuperObject hSuperObjPerso, struct tdstGetSetParam_ *p_stGetSetParam)
{
enum tdeVariableType_ eType;
tdp_fn_cGetFunctionPtr p_fn_cGetFieldFunction;
char ret=C_INVALID_SET;
//extremly important
M_GetSetParam_Clear(p_stGetSetParam);
p_fn_cGetFieldFunction=fn_p_fn_pGetFieldGetFunctionPtr(eFieldId);
ret=p_fn_cGetFieldFunction(hSuperObjPerso,p_stGetSetParam);
eType=fn_eGetFieldType(eFieldId);
switch (eType)
{
case E_vt_Float:
{
MTH_tdxReal xValue=M_GetSetParam_xValue(p_stGetSetParam);
M_Full_GetSetParam_Float(p_stGetSetParam,xValue);
}
break;
case E_vt_Vector:
{
MTH3D_tdstVector *p_stVertex= &M_GetSetParam_stVertexValue(p_stGetSetParam);
M_Full_GetSetParam_p_stVertex(p_stGetSetParam,p_stVertex);
}
break;
case E_vt_Perso:
{
HIE_tdxHandleToSuperObject hTempSuperObjPerso;
hTempSuperObjPerso= M_GetSetParam_p_stSupObjValue(p_stGetSetParam);
M_Full_GetSetParam_Perso(p_stGetSetParam,hTempSuperObjPerso);
}
break;
default:
{
long lValue=0;
// important pour les valeurs sign<67>es qui ne remplissent pas la structure GetSetParam
switch(eType)
{
case E_vt__128To127:
lValue=(long) M_GetSetParam_cValue(p_stGetSetParam);
break;
case E_vt__32768To32767:
lValue=(long) M_GetSetParam_wValue(p_stGetSetParam);
break;
default:
lValue=M_GetSetParam_lValue(p_stGetSetParam);
break;
}
M_Full_GetSetParam_Integer(p_stGetSetParam,lValue);
}
}
return(ret);
}
*/
/* Set ****************************************/
#if defined(__DEBUG_AI__)
unsigned char g_ucFieldTruncated=0;
#define M_INIT_TRUNCATED_FIELD() g_ucFieldTruncated=0;
#define M_NONE(x,a,b) 0
#define M_INF(x,a,b) ((x)<(a))
#define M_SUP(x,a,b) ((x)>(a))
#define M_INF_SUP(x,a,b) ( M_INF(x,a,0) || M_SUP(x,b,0) )
#define M_TEST_TRUNCATED_FIELD(p_stGetSetParam,expression,a,b) \
g_ucFieldTruncated=fn_ucIsThereFloatIfYesConvertItToInteger(p_stGetSetParam); \
if (!g_ucFieldTruncated) \
{ \
long lValue=M_GetSetParam_lValue(p_stGetSetParam); \
g_ucFieldTruncated=##expression(lValue,a,b); \
}
#define M_CHECK_TRUNCATED_FIELD(eFieldId,p_stPerso) \
if (g_ucFieldTruncated) \
{ \
char MyMsg[200]; \
sprintf(MyMsg,"Field %d from p_stMind (%s)\n",(eFieldId),AI_M_szGetPersoName(AI_M_stGetMindOfSuperObj(p_stPerso)) ); \
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningTruncateAffectation, C_ucErmNoOpenInfoWindow,MyMsg); \
}
#else
#define M_INIT_TRUNCATED_FIELD()
#define M_TEST_TRUNCATED_FIELD(p_stGetSetParam,expression,a,b) (void) fn_ucIsThereFloatIfYesConvertItToInteger(p_stGetSetParam);
#define M_CHECK_TRUNCATED_FIELD(eFieldId,p_stPerso)
#endif
void fn_vSetFieldTypeComport(struct tdstGetSetParam_ *p_stGetSetParam)
{
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(p_stGetSetParam,E_vt_Comport);
#endif
}
void fn_vSetFieldTypeVector(struct tdstGetSetParam_ *p_stGetSetParam)
{
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(p_stGetSetParam,E_vt_Vector);
#endif
p_stGetSetParam=p_stGetSetParam;
}
void fn_vSetFieldTypeFloat(struct tdstGetSetParam_ *p_stGetSetParam)
{
if (!M_IsFloatType(p_stGetSetParam))
{
M_Full_GetSetParam_Float(p_stGetSetParam,MTH_M_xLongToReal(M_GetSetParam_lValue(p_stGetSetParam)));
}
}
void fn_vSetFieldTypeInteger(struct tdstGetSetParam_ *p_stGetSetParam)
{
fn_ucIsThereFloatIfYesConvertItToInteger(p_stGetSetParam);
}
void fn_vSetFieldType0To255(struct tdstGetSetParam_ *p_stGetSetParam)
{
M_TEST_TRUNCATED_FIELD(p_stGetSetParam, M_INF_SUP, 0, 255);
}
unsigned char fn_ucSetFieldValue(enum tdeFieldId_ eFieldId, HIE_tdxHandleToSuperObject hSuperObjPerso, struct tdstGetSetParam_ *p_stGetSetParam)
{
enum tdeFieldTypeId_ eFieldType=fn_eGetEngineFieldType(eFieldId);
tdp_fn_cSetFunctionPtr p_fn_cSetFieldFunction=fn_p_fn_pGetFieldSetFunctionPtr(eFieldId);
tdp_fn_vSetTypeFunctionPtr p_fn_vSetFieldTypeFunction=fn_p_fn_pGetFieldTypeSetFunctionPtr(eFieldType);
M_INIT_TRUNCATED_FIELD();
/* pre process*/
p_fn_vSetFieldTypeFunction(p_stGetSetParam);
M_CHECK_TRUNCATED_FIELD(eFieldId,hSuperObjPerso);
/* write field*/
return(p_fn_cSetFieldFunction(hSuperObjPerso,p_stGetSetParam));
}
/* Get ******************/
void fn_vGetFieldTypeComport(struct tdstGetSetParam_ *p_stGetSetParam)
{
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(p_stGetSetParam,E_vt_Comport);
#endif
}
void fn_vGetFieldTypeVector(struct tdstGetSetParam_ *p_stGetSetParam)
{
#if defined(__DEBUG_AI__)
M_VerifyTypeOfParamAction(p_stGetSetParam,E_vt_Vector);
#endif
p_stGetSetParam=p_stGetSetParam;
}
void fn_vGetFieldTypeFloat(struct tdstGetSetParam_ *p_stGetSetParam)
{
if (!M_IsFloatType(p_stGetSetParam))
{
M_Full_GetSetParam_Float(p_stGetSetParam,MTH_M_xLongToReal(M_GetSetParam_lValue(p_stGetSetParam)));
}
}
void fn_vGetFieldTypeInteger(struct tdstGetSetParam_ *p_stGetSetParam)
{
if (M_IsFloatType(p_stGetSetParam))
{
M_Full_GetSetParam_Integer(p_stGetSetParam,MTH_M_xRealToLong(M_GetSetParam_xValue(p_stGetSetParam)));
}
}
void fn_vGetFieldType0To255(struct tdstGetSetParam_ *p_stGetSetParam)
{
if (M_IsFloatType(p_stGetSetParam))
{
M_Full_GetSetParam_Integer(p_stGetSetParam,MTH_M_xRealToLong(M_GetSetParam_xValue(p_stGetSetParam)));
}
}
unsigned char fn_ucGetFieldValue(enum tdeFieldId_ eFieldId, HIE_tdxHandleToSuperObject hSuperObjPerso, struct tdstGetSetParam_ *p_stGetSetParam)
{
enum tdeFieldTypeId_ eFieldType=fn_eGetEngineFieldType(eFieldId);
tdp_fn_cGetFunctionPtr p_fn_cGetFieldFunction=fn_p_fn_pGetFieldGetFunctionPtr(eFieldId);
tdp_fn_vGetTypeFunctionPtr p_fn_vGetFieldTypeFunction=fn_p_fn_pGetFieldTypeGetFunctionPtr(eFieldType);
char ret=C_INVALID_SET;
/*extremly important*/
M_GetSetParam_Clear(p_stGetSetParam);
/* read fields*/
ret=p_fn_cGetFieldFunction(hSuperObjPerso,p_stGetSetParam);
if (ret==C_VALID_GET)
{
/* post process*/
p_fn_vGetFieldTypeFunction(p_stGetSetParam);
}
return(ret);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,124 @@
/*---------------------------------------------------------------------------*/
/* Intell.h : Test pour le module d'intelligence.*/
/* auteur : Olivier Didelot.*/
/* date : 07/08/1996*/
/* 970120 : fnc fn_vInterpretComportNPerso (Fabien Morales) */
/*---------------------------------------------------------------------------*/
#if !defined(__INTELL_H__)
#define __INTELL_H__
struct tdstGetSetParam_;
struct tdstIntelligence_;
#if defined(ACTIVE_EDITOR)
/* to active error intercepting while running : not finished yet*/
#define ACTIVE_EXEC_CHECKING
#if defined(ACTIVE_EXEC_CHECKING)
/*#pragma message("ACTIVE_EXEC_CHECKING is defined ==> editor will run automaticaly if an error occured in AI while running");*/
#endif
#endif
/*///////////////////////////////////////////////////////////////////////////*/
/* PLEASE Never use p_stEvalTree directly, but use theses macros instead ! //*/
/*///////////////////////////////////////////////////////////////////////////*/
/* Oliv' - 27/11/1998*/
#ifdef U64_AIDEBUG
struct AI_tdstMind_ *fn_p_stGetCurrentMind();
void fn_v_SetCurrentMind(struct AI_tdstMind_ *p_stMind);
#endif /* U64_AIDEBUG */
/* EndOfOliv'*/
/*** DR ***/
#if ( (defined(ACTIVE_EXEC_CHECKING) && defined(ACTIVE_EDITOR)) || defined(ACTIVE_AIDEBUG) ) && !defined(U64_AIDEBUG)
void fn_vSetStopAIEngineFlag();
/*void fn_vReSetStopAIEngineFlag(); *** DR ****/
unsigned char fn_ucGetStopAIEngineFlag();
struct AI_tdstMind_ *fn_p_stGetCurrentMind();
void fn_v_SetCurrentMind(struct AI_tdstMind_ *p_stMind);
unsigned char fn_ucGetErrorFlag(HIE_tdxHandleToSuperObject p_SuperObjPerso);
#include "ActConst.h"
#include "AI_Struc.h"
#define M_EvalOneParameter(p_SuperObjPerso,p_stTreeOut,p_stTreeIn,p_stParam) \
if ( (!fn_ucGetErrorFlag(p_SuperObjPerso)) && (!fn_ucGetStopAIEngineFlag()) ) \
(p_stTreeOut) = fn_p_stEvalTree( (p_SuperObjPerso), (p_stTreeIn), (p_stParam) ); \
if ( (fn_ucGetErrorFlag(p_SuperObjPerso)) || fn_ucGetStopAIEngineFlag() ) \
{ \
M_Full_GetSetParam_ActionReturn((p_stParam), (C_ACTION_FINISHED | C_ACTION_ENGINE_STOP)); \
return((p_stTreeOut)); \
}
#else
#define M_EvalOneParameter(p_SuperObjPerso,p_stTreeOut,p_stTreeIn,p_stParam) \
(p_stTreeOut) = fn_p_stEvalTree( (p_SuperObjPerso), (p_stTreeIn), (p_stParam) );
#endif
#define M_EvalTwoParameters(p_SuperObjPerso,p_stTreeOut,p_stTreeIn,p_stParam1,p_stParam2) \
M_EvalOneParameter((p_SuperObjPerso),(p_stTreeOut),(p_stTreeIn),(p_stParam1)); \
M_EvalOneParameter((p_SuperObjPerso),(p_stTreeOut),(p_stTreeIn),(p_stParam2)); \
#define M_EvalNextParameter(p_stValue) \
M_EvalOneParameter(p_SuperObjPerso,p_stTree,p_stTree,(p_stValue)) \
#define M_EvalNextTwoParameter() \
M_EvalNextParameter(&stParam1); \
M_EvalNextParameter(&stParam2);
#define M_vEvalNextVarId(p_stResultMind, ucResultVarId) \
{ \
HIE_tdxHandleToSuperObject p_stResultOwnerPerso; \
if ( M_GetTypeInterpret(p_stTree) == E_ti_Operator ) /* if the dsgvar is passed through an ultra operator, parse it */ \
{ \
/* make sure it is an ultra operator */ \
SAF_M_AssertWithMsg((M_eOperatorIdInterpret(p_stTree) == eOperator_Dot),"the argument is not a dsgvar reference"); \
/* skip the operator node to go to the arguments */ \
p_stTree ++; \
/* get the perso argument of the ultra operator */ \
p_stTree = fn_p_stOperatorGetPerso(p_SuperObjPerso,p_stTree,&p_stResultOwnerPerso); \
} \
else \
/* the dsgvar reference is owned by the calling instance */ \
p_stResultOwnerPerso = p_SuperObjPerso; \
\
/* get the mind of the owning perso (where the dsgvar is stored */ \
p_stResultMind = AI_M_stGetMindOfSuperObj(p_stResultOwnerPerso); \
/* get the dsgvar index (the second argument of the ultra operator if relevant */ \
ucResultVarId = M_ucVarIdInterpret(p_stTree); \
p_stTree ++; \
}
struct tdstNodeInterpret_ *fn_p_stSwapNextParameter(struct tdstNodeInterpret_ *p_stTree);
struct tdstNodeInterpret_ *fn_p_stSwapNextParameter2(struct tdstNodeInterpret_ *p_stTree);
struct tdstNodeInterpret_ *fn_p_stSkipThisArgument(struct tdstNodeInterpret_ *p_stTree);
struct tdstNodeInterpret_ *fn_p_stEvalTree(HIE_tdxHandleToSuperObject p_SuperObjPerso, struct tdstNodeInterpret_ *p_stTree, struct tdstGetSetParam_ *p_stValue);
struct tdstNodeInterpret_ *fn_p_stIntelligenceEvalTreeEngine(HIE_tdxHandleToSuperObject p_SuperObjPerso, struct tdstNodeInterpret_ *p_stTree, struct tdstGetSetParam_ *p_stValue);
ACP_tdxBool fn_bIntelligenceEngine(HIE_tdxHandleToSuperObject p_SuperObjPerso, struct tdstIntelligence_ *p_stIntelligence);
#if defined(__DEBUG_AI__)
void fn_vTestGetDsgVarOrField(unsigned char choice,unsigned char ucVarId,unsigned char ucIndex,enum tdeFieldId_ eFieldId,HIE_tdxHandleToSuperObject p_SuperObjPerso ,struct tdstGetSetParam_ *p_stValue);
#endif
#include "TypePtr.h"
void fn_vSetProcedureActionReturn(tducActionReturn ucActionReturn);
tducActionReturn fn_ucGetProcedureActionReturn(void); /*AR980313*/
/*////////////////////*/
/* Global Variables //*/
/*////////////////////*/
#undef EXTERN
#undef extern
#if !defined(__DeclareGlobalVariableIntell_h__)
#define EXTERN extern
#else
#define EXTERN
#endif /*__DeclareGlobalVariableIntell_h__*/
EXTERN struct tdstIntelligence_ *g_p_stIntelligence;
EXTERN unsigned char g_ucNRule;
EXTERN ACP_tdxBool bSomethingDone;
#endif /* __INTELL_H__*/

View File

@@ -0,0 +1,595 @@
/*---------------------------------------------------------------------------*/
/* List.c : perso list for AI.*/
/* author : Olivier Couvreur 28/11/1997*/
/*---------------------------------------------------------------------------*/
/* included in DsgMem.c so excluded from build in VC project*/
#include "AIUseCPA.h"
#include "AI_Mmg.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Erm.h"
#include "Convert.h"
#include "ai_struc.h"
#include "List.h"
/*XB*/
#include "Intell.h"
/*End XB*/
#include "gsparam.h"
/***********************************************************************************************************************/
/* LIST */
/***********************************************************************************************************************/
/* Body of functions for List of Perso*/
/*/////////////////////////////////////*/
void fn_vPutInList (tdstList *p_List, HIE_tdxHandleToSuperObject p_Perso)
/* -------------*/
/* add perso at the end.*/
{
if (p_List->ucNbElt < p_List->ucMaxSize){
p_List->d_TabElt[p_List->ucNbElt++]=p_Perso;
}
else {
M_AIFatalError(E_uwAIFatalPersoListFull);
}
}
void fn_vInsertPersoAtPositionInList (tdstList *p_List, HIE_tdxHandleToSuperObject p_Perso, unsigned char ucPosition)
/* -------------------------------*/
/*ucPosition belows [0,p_List->ucNbElt+1] & ucPosition < C_ucSizeOfMaximalList*/
{
unsigned char ucI;
ucPosition = (unsigned char) M_Min (p_List->ucNbElt+1, ucPosition);
if (p_List->ucNbElt < p_List->ucMaxSize){
/* shift back the all element from ucPosition to the of the list*/
for (ucI=p_List->ucNbElt; ucI>ucPosition; ucI--){
p_List->d_TabElt [ucI]= p_List->d_TabElt[ucI-1];
}
p_List->d_TabElt[ucPosition]=p_Perso;
p_List->ucNbElt++;
}
else {
M_AIFatalError(E_uwAIFatalPersoListFull);
}
}
Bool fn_bFindPersoInList(tdstList *p_List, HIE_tdxHandleToSuperObject p_Perso)
/* -------------------*/
/* return TRUE if the perso was found*/
/* return FALSE if the perso was not found*/
{
unsigned char ucPosition;
/* No element in list */
if (p_List->ucNbElt==0)
return 0;
for (ucPosition=0; (ucPosition < p_List->ucNbElt) && ( p_List->d_TabElt[ucPosition] != p_Perso); ucPosition++) {}; /*{} for lint */
/*if (ucPosition == p_List->ucNbElt)*/
/*return 0;*/
/*return ((Bool) (p_List->d_TabElt[ucPosition] == p_Perso) );*/
return ((Bool) (ucPosition < p_List->ucNbElt) );
}
/*
----------------------------------------------------------------------------------------
Description : fn_bFindModelInList
Returns (Bool ) TRUE if one perso of the model has been found in the list, else FALSE
----------------------------------------------------------------------------------------
Author : Fred 'Bart' Compagnon
Date : 07/05/98
----------------------------------------------------------------------------------------
*/
Bool fn_bFindModelInList(tdstList *p_List, AI_tdstAIModel *_p_stModel)
{
unsigned char ucPosition;
/* No element in list */
if (p_List->ucNbElt==0)
return 0;
for (
ucPosition=0;
(ucPosition < p_List->ucNbElt)
&& ( AI_M_p_stGetAIModel(M_pstGetMindOfBrain(M_GetMSHandle(p_List->d_TabElt[ucPosition],Brain))) != _p_stModel );
ucPosition++)
{}; /*{} for lint */
/*if (ucPosition == p_List->ucNbElt)*/
/*return 0;*/
/*return ((Bool) (AI_M_p_stGetAIModel(M_pstGetMindOfBrain(M_GetMSHandle(p_List->d_TabElt[ucPosition],Brain))) == _p_stModel) );*/
return ((Bool) (ucPosition < p_List->ucNbElt) );
}
/*
----------------------------------------------------------------------------------------
Description : fn_bFindFamilyInList
Returns (Bool ) TRUE if one perso of the family has been found in the list, else FALSE
----------------------------------------------------------------------------------------
Author : Fred 'Bart#02' Compagnon
Date : 07/05/98
----------------------------------------------------------------------------------------
*/
Bool fn_bFindFamilyInList(tdstList *p_List, tdxHandleToFamilyList hFamily)
{
unsigned char ucPosition;
/* No element in list */
if (p_List->ucNbElt==0)
return 0;
for (
ucPosition=0;
(ucPosition < p_List->ucNbElt)
&& ( fn_h3dDataGetFamily( M_GetMSHandle( p_List->d_TabElt[ucPosition], 3dData) ) != hFamily );
ucPosition++)
{}; /*{} for lint */
/*if (ucPosition == p_List->ucNbElt)*/
/*return 0;*/
/*return ((Bool) ( fn_h3dDataGetFamily( M_GetMSHandle( p_List->d_TabElt[ucPosition], 3dData) ) == hFamily ) );*/
return ((Bool) (ucPosition < p_List->ucNbElt) );
}
Bool fn_bFindPersoAndDeleteInList (tdstList *p_List, HIE_tdxHandleToSuperObject p_Perso)
/* ----------------------------*/
/* return TRUE if the perso was found and delete*/
/* return FALSE if the perso was not found*/
{
unsigned char ucI;
unsigned char ucPosition;
for (ucPosition=0; (ucPosition < p_List->ucNbElt) && (p_List->d_TabElt[ucPosition] != p_Perso); ucPosition++) {}; /*{} for lint*/
if (p_List->d_TabElt[ucPosition] == p_Perso){
/* shift back the all element from ucPosition to the of the list*/
for (ucI=ucPosition; ucI<=p_List->ucNbElt-2; ucI++){
p_List->d_TabElt[ucI]= p_List->d_TabElt[ucI+1];
}
p_List->ucNbElt--;
return 1; /*TRUE*/
}
else return 0; /*FALSE*/
}
void fn_vDeletePersoAtPositionInList (tdstList *p_List, unsigned char ucPosition)
/*ucPosition belows [0,p_List->ucNbElt-1] & ucPosition < C_ucSizeOfMaximalList
if ucPosition = C_ucEndOfList d*/
{
unsigned char ucI;
if (ucPosition == C_ucEndOfList) ucPosition = (unsigned char) (p_List->ucNbElt-1);
if (ucPosition <= p_List->ucNbElt-1){
/* shift back the all element from ucPosition to the of the list*/
for (ucI=ucPosition; ucI<=p_List->ucNbElt-2; ucI++){
p_List->d_TabElt[ucI]= p_List->d_TabElt[ucI+1];
}
p_List->ucNbElt--;
}
else{
#ifdef __FATAL_ERR_AI__
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, E_uwAIFatalPbDeleteInPersoList, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);
#endif /*__FATAL_ERR_AI__*/
}
}
void fn_vSortListByFamily(tdstList *p_List, tdxHandleToFamilyList hFamily)
{
unsigned char ucI, ucJ = 0;
HIE_tdxHandleToSuperObject a_hSupObjElt[C_ucSizeOfMaximalList],hSupObjElt;
tdxHandleToFamilyList hFamilyElt;
/* Find SupObj of the good family and put it in a_hSupObjElt.*/
for (ucI = 0; ucI < M_ucNbEltInList(p_List); ucI++)
{
hSupObjElt = p_List->d_TabElt[ucI];
hFamilyElt = fn_h3dDataGetFamily(M_GetMSHandle(hSupObjElt,3dData));
if (hFamilyElt == hFamily)
a_hSupObjElt[ucJ++] = hSupObjElt;
}
/* Keep in the List only SupObj in a_hSupObjElt.*/
M_ClearList(p_List);
for (ucI = 0; ucI < ucJ; ucI++)
{
fn_vPutInList(p_List, a_hSupObjElt[ucI]);
}
}
void fn_vSortListByModel(tdstList *p_stList, AI_tdstAIModel *_p_stModel)
{
HIE_tdxHandleToSuperObject hPerso;
unsigned char ucPos = 0;
HIE_tdxHandleToSuperObject a_hSupObjElt[C_ucSizeOfMaximalList];
unsigned char ucI, ucJ = 0;
hPerso = fn_p_stGetPersoInList(p_stList, ucPos);
while(hPerso)
{
if
(
(M_GetMSHandle(hPerso,Brain))
&& (AI_M_p_stGetAIModel(M_pstGetMindOfBrain(M_GetMSHandle(hPerso,Brain))) == _p_stModel)
)
a_hSupObjElt[ucJ++] = hPerso;
ucPos++;
hPerso = fn_p_stGetPersoInList(p_stList, ucPos);
}
/* Keep in the List only SupObj in a_hSupObjElt.*/
M_ClearList(p_stList);
for (ucI = 0; ucI < ucJ; ucI++)
{
fn_vPutInList(p_stList, a_hSupObjElt[ucI]);
}
}
void fn_vUnionList (tdstList *p_ListA, tdstList *p_ListB, tdstList *p_ListC)
/* -------------*/
/* A <- B U C*/
{
unsigned char ucI, ucJ;
HIE_tdxHandleToSuperObject p_Perso;
/* A <- B*/
for (ucI = 0; ucI < p_ListB->ucNbElt; ucI++)
{
fn_vPutInList(p_ListA, p_ListB->d_TabElt[ucI]);
}
/*A <- A + (C-B)*/
for (ucI = 0; ucI < p_ListC->ucNbElt; ucI++){
p_Perso = p_ListC->d_TabElt[ucI];
/* test if p_Perso is in ListB*/
for ( ucJ=0;
(ucJ< p_ListB->ucNbElt) && (p_ListB->d_TabElt[ucJ] != p_Perso);
ucJ++) {}; /*{} for lint*/
if (p_ListB->d_TabElt[ucJ] != p_Perso)
{
fn_vPutInList(p_ListA,p_Perso);
}
}
}
void fn_vInterList (tdstList *p_ListA, tdstList *p_ListB, tdstList *p_ListC)
/* -------------*/
/* A <- B inter C*/
{
unsigned char ucB, ucC;
HIE_tdxHandleToSuperObject p_Perso;
for (ucB=0; ucB<p_ListB->ucNbElt; ucB++)
{
p_Perso = p_ListB->d_TabElt[ucB];
for (ucC=0; ucC<p_ListC->ucNbElt; ucC++)
{
if (p_ListC->d_TabElt[ucC] == p_Perso)
{
fn_vPutInList(p_ListA,p_Perso);
break;
}
}
}
}
void fn_vDiffList (tdstList *p_ListA, tdstList *p_ListB, tdstList *p_ListC)
/* ------------*/
/* A <- B - C*/
{
unsigned char ucB, ucC;
HIE_tdxHandleToSuperObject p_Perso;
for (ucB=0; ucB<p_ListB->ucNbElt; ucB++)
{
p_Perso = p_ListB->d_TabElt[ucB];
for ( ucC=0;
(ucC< p_ListC->ucNbElt) && (p_ListC->d_TabElt[ucC] != p_Perso);
ucC++) {}; /*{} for lint*/
if (p_ListC->d_TabElt[ucC] != p_Perso)
{
fn_vPutInList(p_ListA,p_Perso);
}
}
}
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Description: fn_vAddList*/
/* Add the content of the a listB in a ListA, without double*/
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Methods: A <- A + (B-A) */
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Input: HIE_tdxHandleToSuperObject p_SuperObjPerso*/
/* tdstNodeInterpret *p_stTree*/
/* tdstGetSetParam *p_stValue*/
/* Output: tdstNodeInterpret * : tree*/
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Creation date: Jan.14, 1997 Author: Fabien MORALES*/
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Modifications:*/
/* Modification date: Modification Author: Fabien MORALES*/
/*/////////////////////////////////////////////////////////////////////////////////*/
void fn_vAddList (tdstList *p_ListA, tdstList *p_ListB)
{
unsigned char ucA, ucB, ucSizeA;
HIE_tdxHandleToSuperObject hPerso;
ucSizeA = p_ListA->ucNbElt;
for (ucB = 0; ucB < p_ListB->ucNbElt; ucB++)
{
hPerso = p_ListB->d_TabElt[ucB];
/* test if hPerso is already in List A*/
/* (ucSizeA) we consider that there is no double in listB */
for (ucA = 0; (ucA<ucSizeA) && p_ListA->d_TabElt[ucA] != hPerso; ucA++) {}; /*{} for lint*/
/* add it in List A*/
if (p_ListA->d_TabElt[ucA] != hPerso)
{
fn_vPutInList(p_ListA,hPerso);
}
}
}
HIE_tdxHandleToSuperObject g_a_hPersoInZone[C_ucSizeOfMaximalList];
void fn_vAffectZddInList(tdstList *p_List, HIE_tdxHandleToSuperObject p_stPerso,
unsigned char ucModulOrCharact, ACP_tdxIndex xZoneId)
{
unsigned short uwI, uwNbDetectedPerso;
M_ClearList(p_List);
uwNbDetectedPerso = M_ucGetMaxSizeOfList(p_List);
fn_vGetAllObjectsInZdd(p_stPerso, ucModulOrCharact, (unsigned char)xZoneId, g_a_hPersoInZone, &uwNbDetectedPerso);
for (uwI=0; uwI < uwNbDetectedPerso; uwI++)
fn_vPutInList(p_List, g_a_hPersoInZone[uwI]);
}
void fn_vAffectZdeInList(tdstList *p_List, HIE_tdxHandleToSuperObject p_stPerso,
unsigned char ucModulOrCharact, ACP_tdxIndex xZoneId, GMT_tdxMask xMask)
{
unsigned short uwI, uwNbDetectedPerso;
M_ClearList(p_List);
uwNbDetectedPerso = M_ucGetMaxSizeOfList(p_List);
fn_vGetAllCharactersInContactWithThisZde(p_stPerso, ucModulOrCharact, (unsigned char)xZoneId, g_a_hPersoInZone, &uwNbDetectedPerso, (unsigned short) xMask);
for (uwI=0; uwI < uwNbDetectedPerso; uwI++)
fn_vPutInList(p_List, g_a_hPersoInZone[uwI]);
}
#if !defined(_AI_EXCLUDE_NEVER_USED_) /* MT {*/
/* used only by 1 ia function that is not used...*/
void fn_vAffectTypeZdeWithTypeZdeInList(tdstList *p_List, HIE_tdxHandleToSuperObject p_stPerso, GMT_tdxMask xPersoMask, GMT_tdxMask xOthersMask)
{
unsigned short uwI, uwNbDetectedPerso;
M_ClearList(p_List);
uwNbDetectedPerso = M_ucGetMaxSizeOfList(p_List);
fn_vThisTypeVsThisType(p_stPerso,xPersoMask,xOthersMask,g_a_hPersoInZone,&uwNbDetectedPerso);
for (uwI=0; uwI < uwNbDetectedPerso; uwI++)
fn_vPutInList(p_List, g_a_hPersoInZone[uwI]);
}
#endif
unsigned char fn_ucAtLeastOnePersoInZdd(HIE_tdxHandleToSuperObject p_stPerso, unsigned char ucModulOrCharact, ACP_tdxIndex xZoneId)
{
unsigned short uwNbDetectedPerso = 1;
fn_vGetAllObjectsInZdd(p_stPerso, ucModulOrCharact, (unsigned char)xZoneId, g_a_hPersoInZone, &uwNbDetectedPerso);
return((unsigned char) (uwNbDetectedPerso!=0));
}
unsigned char fn_ucAtLeastOnePersoInZde(HIE_tdxHandleToSuperObject p_stPerso, unsigned char ucModulOrCharact, ACP_tdxIndex xZoneId, GMT_tdxMask xMask)
{
unsigned short uwNbDetectedPerso = 1;
fn_vGetAllCharactersInContactWithThisZde(p_stPerso, ucModulOrCharact, (unsigned char)xZoneId, g_a_hPersoInZone, &uwNbDetectedPerso, (unsigned short) xMask);
return((unsigned char) (uwNbDetectedPerso!=0));
}
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Description: fn_p_stGetPersoInList*/
/* get the Perso pointer at the given position in the list*/
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Methods: */
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Input: tdstList *p_List*/
/* unsigned char ucPosition*/
/* Output: HIE_tdxHandleToSuperObject : return handle could be NULL */
/* if bad position is specified*/
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Creation date: Jan 1997 Author: Fabien MORALES*/
/*/////////////////////////////////////////////////////////////////////////////////*/
/* Modifications:*/
/* Modification date: Modification Author: Fabien MORALES*/
/*/////////////////////////////////////////////////////////////////////////////////*/
HIE_tdxHandleToSuperObject fn_p_stGetPersoInList(tdstList *p_List, unsigned char ucPosition)
/* -------------------*/
{
/* empty list ?*/
if (p_List->ucNbElt==0)
return NULL;
/* Bad position in list ? */
if ((ucPosition>=p_List->ucNbElt) && (ucPosition!=C_ucEndOfList))
return NULL;
/* last elem ?*/
if (ucPosition==C_ucEndOfList)
return p_List->d_TabElt[p_List->ucNbElt-1];
else
return p_List->d_TabElt[ucPosition];
}
/* function to implement the ListSelect operator (with b_cInverse=0) and */
/* the ListUnselect operator (with b_cInverse=1).*/
struct tdstNodeInterpret_ * fn_p_stListSelect(tdstList * p_List, char b_cInverse, struct tdstNodeInterpret_ *p_stTree)
{
HIE_tdxHandleToSuperObject *p_p_stPerso;
tdstList stWorkList;
char b_cCondResult;
struct tdstNodeInterpret_ * p_stTreeSv = p_stTree;
tdstGetSetParam stParam;
M_InitScanList(p_List, p_p_stPerso);
M_ClearList (&stWorkList);
while (M_EndingCondScanList(p_List, p_p_stPerso)){
/* eval the condition*/
M_EvalOneParameter(*p_p_stPerso,p_stTree,p_stTreeSv,&stParam);
b_cCondResult = (char) M_GetSetParam_lValue(&stParam);
if (b_cCondResult ^ b_cInverse)
fn_vPutInList (&stWorkList, *p_p_stPerso);
M_GoNextScanList(p_List, p_p_stPerso);
}
/*copy the worklist into the p_List*/
memcpy (p_List, &stWorkList, sizeof (tdstList1) + (stWorkList.ucNbElt -1) * C_SizeOfPersoInList);
return (p_stTree);
}
/*
struct tdstNodeInterpret_ * fn_p_stListSort (tdstList * p_List, unsigned char ucWantedNbElt, char b_cIncrease, struct tdstNodeInterpret_ *p_stTree)
{
HIE_tdxHandleToSuperObject *p_p_stPerso;
HIE_tdxHandleToSuperObject p_stPerso;
unsigned char ucI, ucJ;
long a_lCriteraResult[C_ucSizeOfMaximalList];
long *p_lCriteraResult;
long lValue;
unsigned char ucId = 0;
struct tdstNodeInterpret_ * p_stTreeSv = p_stTree;
tdstGetSetParam stParam;
M_InitScanList(p_List, p_p_stPerso);
p_lCriteraResult = a_lCriteraResult;
// eval every critera
while (M_EndingCondScanList(p_List, p_p_stPerso)){
M_EvalOneParameter(*p_p_stPerso,p_stTree,p_stTreeSv,&stParam);
*(p_lCriteraResult++) = M_GetSetParam_lValue(&stParam);
M_GoNextScanList(p_List, p_p_stPerso);
}
if (b_cIncrease == 0){// sort for decrease case
lValue = 0;
for (ucI=0; (ucI < p_List->ucNbElt-1) && (ucI < ucWantedNbElt); ucI++){
for (ucJ = ucI; ucJ<p_List->ucNbElt; ucJ++){
if (a_lCriteraResult[ucJ]>lValue){
lValue = a_lCriteraResult[ucJ];
ucId = ucJ;
}
}
// permut in order to move up the max
a_lCriteraResult[ucId] = a_lCriteraResult[ucI];
//a_lCriteraResult[ucI] = lValue; // just for debug !!
p_stPerso = p_List->d_TabElt[ucId];
p_List->d_TabElt[ucId] = p_List->d_TabElt[ucI];
p_List->d_TabElt[ucI] = p_stPerso;
}
}
else{// sort for increase case
lValue = (long) 0xFFFFFFFF;
for (ucI=0; (ucI < p_List->ucNbElt-1) && (ucI < ucWantedNbElt); ucI++){
for (ucJ = ucI; ucJ<p_List->ucNbElt; ucJ++){
if (a_lCriteraResult[ucJ]<lValue){
lValue = a_lCriteraResult[ucJ];
ucId = ucJ;
}
}
// permut in order to move up the min
a_lCriteraResult[ucId] = a_lCriteraResult[ucI];
p_stPerso = p_List->d_TabElt[ucId];
p_List->d_TabElt[ucId] = p_List->d_TabElt[ucI];
p_List->d_TabElt[ucI] = p_stPerso;
}
}
p_List->ucNbElt = (unsigned char) M_Min(p_List->ucNbElt, ucWantedNbElt);
return (p_stTree);
}
*/
struct tdstNodeInterpret_ * fn_p_stListSort (tdstList * p_List, unsigned char ucWantedNbElt, char b_cIncrease, struct tdstNodeInterpret_ *p_stTree)
{
HIE_tdxHandleToSuperObject *p_p_stPerso;
HIE_tdxHandleToSuperObject p_stPerso;
unsigned char ucI, ucJ;
MTH_tdxReal a_xCriteraResult[C_ucSizeOfMaximalList];
MTH_tdxReal *p_xCriteraResult;
MTH_tdxReal xValue;
unsigned char ucId = 0;
struct tdstNodeInterpret_ * p_stTreeSv = p_stTree;
tdstGetSetParam stParam;
M_InitScanList(p_List, p_p_stPerso);
p_xCriteraResult = a_xCriteraResult;
/* eval every critera*/
while (M_EndingCondScanList(p_List, p_p_stPerso)){
M_EvalOneParameter(*p_p_stPerso,p_stTree,p_stTreeSv,&stParam);
*(p_xCriteraResult++) = M_ReturnParam_xValue(&stParam);
M_GoNextScanList(p_List, p_p_stPerso);
}
if (b_cIncrease == 0)
{/* sort for decrease case*/
xValue=MTH_C_InfinitMinus;
for (ucI=0; (ucI < p_List->ucNbElt-1) && (ucI < ucWantedNbElt); ucI++)
{
for (ucJ = ucI; ucJ<p_List->ucNbElt; ucJ++)
{
if (a_xCriteraResult[ucJ]>xValue)
{
xValue = a_xCriteraResult[ucJ];
ucId = ucJ;
}
}
/* permut in order to move up the max */
a_xCriteraResult[ucId] = a_xCriteraResult[ucI];
/*a_lCriteraResult[ucI] = lValue; // just for debug !!*/
p_stPerso = p_List->d_TabElt[ucId];
p_List->d_TabElt[ucId] = p_List->d_TabElt[ucI];
p_List->d_TabElt[ucI] = p_stPerso;
}
}
else
{/* sort for increase case*/
/*lValue = (long) 0xFFFFFFFF;*/
xValue= MTH_C_InfinitPlus;
for (ucI=0; (ucI < p_List->ucNbElt-1) && (ucI < ucWantedNbElt); ucI++)
{
for (ucJ = ucI; ucJ<p_List->ucNbElt; ucJ++)
{
if (a_xCriteraResult[ucJ]<xValue)
{
xValue = a_xCriteraResult[ucJ];
ucId = ucJ;
}
}
/* permut in order to move up the min*/
a_xCriteraResult[ucId] = a_xCriteraResult[ucI];
p_stPerso = p_List->d_TabElt[ucId];
p_List->d_TabElt[ucId] = p_List->d_TabElt[ucI];
p_List->d_TabElt[ucI] = p_stPerso;
}
}
p_List->ucNbElt = (unsigned char) M_Min(p_List->ucNbElt, ucWantedNbElt);
return (p_stTree);
}

View File

@@ -0,0 +1,108 @@
/*
------------------------------------------------------------------------------------------
HEADER FILE FOR :
Error definition file for mathematic module
------------------------------------------------------------------------------------------
File Name :
ErrMth.h
------------------------------------------------------------------------------------------
Creation :
* Date :
Feburary 18,1997
* Author :
Albert Pais
------------------------------------------------------------------------------------------
Contents :
This file contains definition for the error management concerning the mathematical
module
------------------------------------------------------------------------------------------
Modification :
* Date :
* Author :
* Modify :
------------------------------------------------------------------------------------------
*/
#ifndef __ERRMTH_H__
#define __ERRMTH_H__
#define C_szXxxVersion "MTH V5.0.0" /* The format is XXX Va.b.c with Xxx is the Tag of the module */
#define C_szXxxFullName "Module Mathematic for AI"/* the complete and clear name of the module */
#define C_szXxxDate __DATE__ /*The format is "Mmm dd yyyy".You can use __DATE__ but be careful that you have the control of the compilation*/
/*----------*/
/* Constant */
/*----------*/
/* error of the MTH Module*/
typedef enum e_uwMTHErrNumber_{
E_uwMTHFatalErr = 0,
#ifdef __FATAL_ERR_MTH__
/* -----------------*/
E_uwMTHFatalNotAFatalError,
E_uwMTHFatalInvalidParameter,
E_uwMTHFatalAssertionFailure,
E_uwMTHFatalFailedAllocationMem,
#endif /*__FATAL_ERR_MTH__*/
E_uwMTHStartOfWarning,/* important constant, it allows to recognize if an error is fatal or not.*/
E_uwMTHWarningCanNotFree,
#ifdef __WARNING_ERR_MTH__
/* -------------------*/
#endif /*__WARNING_ERR_MTH__*/
E_uwMTHErrNumber
} e_uwMTHErrNumber;
/*------------------*/
/* Global Variables*/
/*------------------*/
#undef EXTERN
#undef extern
#ifndef __DeclareGlobalVariableErrMth_h__
#define EXTERN_ERRMTH extern /*external declaration*/
#else /*__DeclareGlobalVariableErrMth_h__*/
#define EXTERN_ERRMTH /*replace by nothing : we have to declare*/
#endif /*__DeclareGlobalVariableErrMth_h__*/
EXTERN_ERRMTH unsigned char g_ucMTHModuleId /*number of identification of the Erm module*/
#ifdef __DeclareGlobalVariableErrMth_h__
= C_ucModuleNotInitialized
#endif /*__DeclareGlobalVariableErrMth_h__*/
;
#ifdef __ERROR_STRINGS__
EXTERN_ERRMTH CPA_EXPORT char * g_a_szMTHInformationModule []
#if defined(__DeclareGlobalVariableErrMth_h__) && !defined(CPA_WANTS_IMPORT)
= {C_szXxxVersion, C_szXxxFullName, C_szXxxDate}
#endif /*__DeclareGlobalVariableErrMth_h__ && CPA_WANTS_IMPORT*/
;
EXTERN_ERRMTH char * g_szMTHModuleName /* Obliged syntax 'g_sz'+[Abbreviation of ModuleName]+'ModuleName'*/
#ifdef __DeclareGlobalVariableErrMth_h__
= "Module Mathematic"
#endif /*__DeclareGlobalVariableErrMth_h__*/
;
EXTERN_ERRMTH /*struct!!y!!*/ tdstErrorMsg/*_!!y!!*/ g_a_stMTHTabErr [] /* Obliged syntax 'g_a_st'+[Abbreviation of ModuleName]+'TabErr'*/
#ifdef __DeclareGlobalVariableErrMth_h__/*Call from main program*/
={
#ifdef __FATAL_ERR_MTH__
E_uwMTHFatalNotAFatalError,"This not a valid mth fatal error",
E_uwMTHFatalInvalidParameter,"One or more parameters are invalid",
E_uwMTHFatalAssertionFailure,"Assertions failed",
E_uwMTHFatalFailedAllocationMem,"Allocation failure in module MTH",
/* -------------*/
#endif /*__FATAL_ERR_MTH__*/
#ifdef __WARNING_ERR_MTH__
E_uwMTHWarningCanNotFree,"Free failure in module MTH",
/* ----------------*/
#endif /*__WARNING_ERR_MTH__*/
0xFFFF, "\0"/*fin*/
};
#endif /*__DeclareGlobalVariableErrMth_h__*/
;
#undef extern
#endif /*__ERROR_STRINGS__*/
#endif /*__ERRMTH_H__*/

View File

@@ -0,0 +1,216 @@
/*
------------------------------------------------------------------------------------------
HEADER FILE FOR :
Macros definition for mathematical module
------------------------------------------------------------------------------------------
File Name :
Mth_Macr.h
------------------------------------------------------------------------------------------
Creation :
* Date :
February 18,1997
* Author :
Albert PAIS
------------------------------------------------------------------------------------------
Contents :
This file defines somes macros used in MTH library
------------------------------------------------------------------------------------------
Modification :
* Date :
* Author :
* Modify :
------------------------------------------------------------------------------------------
*/
#if !defined(__MTHMACROS_TYPES__)
#define __MTHMACROS_TYPES__
#if !defined(ONLY_TYPES)
#define MTHMACROS_UNDEF
#define ONLY_TYPES
#endif /* !ONLY_TYPES */
/*
------------------------------------------------------------------------------------------
INCLUDE FILES :
------------------------------------------------------------------------------------------
*/
/*
----------------------------------------
File Name :
Mth_Opt.h
----------------------------------------
Required for :
Mathematical options.
----------------------------------------
*/
#include "Mth_Opt.h"
#if defined(MTHMACROS_UNDEF)
#undef ONLY_TYPES
#undef MTHMACROS_UNDEF
#endif /* !MTHMACROS_UNDEF */
/*
------------------------------------------------------------------------------------------
TYPE DEFINITION :
If enumerate :
M_BeginDeclareEnumerate(<type>)
M_EndDeclareEnumerate(<type>, <basic type>)
------------------------------------------------------------------------------------------
*/
#endif /* !__MTHMACROS_TYPES__ */
#if !defined(ONLY_TYPES)
#if !defined(__MTHMACROS_VARS__)
#define __MTHMACROS_VARS__
#undef EXTERN
#undef extern
#if !defined(GLOBALS)
#define EXTERN extern
#else /* !GLOBALS */
#define EXTERN
#endif /* !GLOBALS */
/*
------------------------------------------------------------------------------------------
MACROS-CONSTANT DECLARATION:
------------------------------------------------------------------------------------------
*/
#undef extern
#endif /* !__MTHMACROS_VARS__ */
#if !defined (__MTHMACROS_PROTOS__)
#define __MTHMACROS_PROTOS__
/*
------------------------------------------------------------------------------------------
MACROS-FUNCTIONS DECLARATION:
------------------------------------------------------------------------------------------
*/
/*////////////////////*/
/* macro for Error //*/
/*////////////////////*/
#ifdef __FATAL_ERR_MTH__
#define M_MTH_FatalError(FatalErrorNum) \
Erm_M_UpdateLastError(MTH, C_ucErmDefaultChannel, FatalErrorNum, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, NULL);
#else /*__FATAL_ERR_MTH__*/
#define M_MTH_FatalError(FatalErrorNum)
#endif /*__FATAL_ERR_MTH__*/
#ifdef __WARNING_ERR_MTH__
#define M_MTH_WarningError(ErrorNum, ucOpenInfoWindow)\
/* ----------------*/\
{ \
if (ErrorNum > E_uwMTHStartOfWarning) \
{ \
Erm_M_UpdateLastError(MTH, C_ucErmDefaultChannel, ErrorNum, C_lErmNoDebugData, ucOpenInfoWindow, C_ucAllowStopForDebug, NULL);\
} \
else \
{ \
M_MTH_FatalError(E_uwMTHFatalNotAFatalError);\
} \
}
#else /*__WARNING_ERR_MTH__*/
#define M_MTH_WarningError(ErrorNum, uwOpenInfoWindow)\
{ \
if (ErrorNum < E_uwMTHStartOfWarning) \
M_MTH_FatalError(E_uwMTHFatalNotAFatalError);\
}
#endif /*__WARNING_ERR_MTH__*/
#ifdef __FATAL_ERR_MTH__
#define M_MTH_IfErrorUpdateFatalError(UsedModule, ErrorNum)\
/* ---------------------------*/\
if (Erm_M_uwCheckError(UsedModule, C_ucErmDefaultChannel)){\
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
M_MTH_FatalError(ErrorNum);\
}
#else /*__FATAL_ERR_MTH__*/
#define M_MTH_IfErrorUpdateFatalError(UsedModule, ErrorNum)
#endif /*__FATAL_ERR_MTH__*/
#ifdef __WARNING_ERR_MTH__
#define M_MTH_IfErrorUpdateWarningError(UsedModule, ErrorNum, uwOpenInfoWindow)\
/* -----------------------------*/\
if (Erm_M_uwCheckError(UsedModule, C_ucErmDefaultChannel)){\
Erm_M_ClearLastError(C_ucErmDefaultChannel);\
M_MTH_WarningError(ErrorNum, uwOpenInfoWindow);\
}
#else /*__WARNING_ERR_MTH__*/
#define M_MTH_IfErrorUpdateWarningError(UsedModule, ErrorNum, uwOpenInfoWindow)
#endif /*__WARNING_ERR_MTH__*/
/*////////////////////*/
/* macro for Memory //*/
/*////////////////////*/
#ifdef MODE_STATIC_MEM_FOR_MTH
#define M_MTH_InitMem() Mmg_M_SetModeAlloc4Ch(MTH, E_ucMTHBlock1,C_ucMmgDefaultChannel)
#else
#define M_MTH_InitMem() Mmg_M_SetModeAlloc4Ch(MTH, E_ucDynamic,C_ucMmgDefaultChannel)
#endif /* MODE_STATIC_MEM_FOR_MTH*/
#define M_MTH_Alloc(Var, cast, ucSize)\
{\
M_MTH_InitMem();\
Var = (cast) Mmg_fn_p_vAlloc4Ch(ucSize,C_ucMmgDefaultChannel);\
M_MTH_IfErrorUpdateFatalError(Mmg, E_uwMTHFatalFailedAllocationMem);\
}
#define M_MTH_AllocWithoutInitMem(Var, cast, ucSize)\
{\
Var = (cast) Mmg_fn_p_vAlloc4Ch(ucSize,C_ucMmgDefaultChannel);\
M_MTH_IfErrorUpdateFatalError(Mmg, E_uwMTHFatalFailedAllocationMem);\
}
#define M_MTHRealloc(Var, AdrSrc, cast, ucSize)\
{\
M_MTH_InitMem();\
Var = (cast) Mmg_fn_p_vRealloc4Ch(AdrSrc, ucSize,C_ucMmgDefaultChannel);\
M_MTH_IfErrorUpdateFatalError(Mmg, E_uwMTHFatalFailedAllocationMem);\
}
#define M_MTHReallocWithoutInitMem(Var, AdrSrc, cast, ucSize)\
{\
Var = (cast) Mmg_fn_p_vRealloc4Ch(AdrSrc, ucSize,C_ucMmgDefaultChannel);\
M_MTH_IfErrorUpdateFatalError(Mmg, E_uwMTHFatalFailedAllocationMem);\
}
#define M_MTHFree(p_cAdr) \
{\
M_MTH_InitMem();\
Mmg_fn_vFree4Ch(p_cAdr,C_ucMmgDefaultChannel);\
M_MTH_IfErrorUpdateWarningError(Mmg, E_uwMTHWarningCanNotFree, C_ucErmOpenInfoWindow);\
p_cAdr=NULL; \
}
#define M_MTHFreeWithoutInitMem(p_cAdr) \
{\
Mmg_fn_vFree4Ch(p_cAdr,C_ucMmgDefaultChannel);\
M_MTHIfErrorUpdateWarningError (Mmg, E_uwMTHWarningCanNotFree, C_ucErmOpenInfoWindow);\
p_cAdr=NULL; \
}
#ifdef MTH_M_DEBUG
#define MTH_M_ASSERT(_Expression,_eErrorCode)\
if(!(_Expression))\
{\
M_MTH_FatalError(_eErrorCode);\
}
#else /* MTH_M_DEBUG */
#define MTH_M_ASSERT(_Expression,_eErrorCode)
#endif /* MTH_M_DEBUG */
/*
------------------------------------------------------------------------------------------
FUNCTIONS DECLARATION:
------------------------------------------------------------------------------------------
*/
#endif /* !__MTHMACROS_PROTOS__ */
#endif /* !ONLY_TYPES */

View File

@@ -0,0 +1,134 @@
/*
------------------------------------------------------------------------------------------
IMPLEMENTATION FILE FOR :
Main file for mathematical module
------------------------------------------------------------------------------------------
File Name :
MthMain.c
------------------------------------------------------------------------------------------
Creation Date :
February 18,1997
Author :
Albert PAIS
------------------------------------------------------------------------------------------
Contents :
This file contains main implementation for mathematical module
------------------------------------------------------------------------------------------
Remarks :
At the creation date, it is used to implemant mathematical error and memory management
module only.
------------------------------------------------------------------------------------------
See Also :
ErrMth.h for error management definition
MemMth.h for memory management definition
------------------------------------------------------------------------------------------
*/
/*
------------------------------------------------------------------------------------------
INCLUDE FILES :
------------------------------------------------------------------------------------------
*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
/*
----------------------------------------
File Name :
Mth_Opt.h
----------------------------------------
Required for :
Definition of MTH module option
----------------------------------------
*/
#include "Mth_Opt.h"
/*
----------------------------------------
File Name :
Mth_Erm.h
----------------------------------------
Required for :
Error file definition
----------------------------------------
*/
#define __DeclareGlobalVariableErrMth_h__
#include "Mth_Erm.h"
#undef __DeclareGlobalVariableErrMth_h__
/*
----------------------------------------
File Name :
Mth_Mmg.h
----------------------------------------
Required for :
Memory file definition
----------------------------------------
*/
#define __DeclareGlobalVariableMemMth_h__
#include "Mth_Mmg.h"
#undef __DeclareGlobalVariableMemMth_h__
/*
----------------------------------------
File Name :
Mth_Misc.h
----------------------------------------
Required for :
Miscellaneous definition.
----------------------------------------
*/
#define MTH_MISC_GLOBALS
#include "Mth_Misc.h"
#undef MTH_MISC_GLOBALS
void MTH_fnv_InitModule(unsigned long _ulMemorySizePerBlock)
{
#ifdef MODE_STATIC_MEM_FOR_MTH
unsigned char c_ucCurrentBlock;
#else
_ulMemorySizePerBlock=_ulMemorySizePerBlock;
#endif /* MODE_STATIC_MEM_FOR_MTH */
/* Init error module :*/
Erm_M_InitErrMsg(MTH);
/* init memory module */
Mmg_M_InitMmg(MTH);
#ifdef MODE_STATIC_MEM_FOR_MTH
/* initialise blocks :*/
for
(
c_ucCurrentBlock = 0;
c_ucCurrentBlock<E_ucMTHMaxBlocksNb;
c_ucCurrentBlock++
)
{
Mmg_M_InitBlock(MTH,c_ucCurrentBlock,_ulMemorySizePerBlock*1024);
}
#endif /* MODE_STATIC_MEM_FOR_MTH */
}
void MTH_fnv_DesinitModule(void)
{
#ifdef MODE_STATIC_MEM_FOR_MTH
unsigned char c_ucCurrentBlock;
#endif /* MODE_STATIC_MEM_FOR_MTH */
/* desinit previous allocated blocks !*/
#ifdef MODE_STATIC_MEM_FOR_MTH
for(c_ucCurrentBlock=0;c_ucCurrentBlock;c_ucCurrentBlock++)
{
MTH_M_FreeBlock(MTH,c_ucCurrentBlock);
}
#endif /* MODE_STATIC_MEM_FOR_MTH */
}
#ifndef FINAL_VERSION
void MTH_PrintUsedStaticMemory()
{
Mmg_M_PrintUsedStaticMemoryInModule(MTH);
}
#endif /* FINAL_VERSION */

View File

@@ -0,0 +1,120 @@
/*
------------------------------------------------------------------------------------------
HEADER FILE FOR :
Miscellaneous definition for mathematical module
------------------------------------------------------------------------------------------
File Name :
Mth_Misc.h
------------------------------------------------------------------------------------------
Creation :
* Date :
February 28,1997
* Author :
Albert PAIS
------------------------------------------------------------------------------------------
Contents :
This file defines miscellaneous structure, macros and functions
of the mathematical module
------------------------------------------------------------------------------------------
Modification :
* Date :
* Author :
* Modify :
------------------------------------------------------------------------------------------
*/
#if !defined(__MTHMISC_TYPES__)
#define __MTHMISC_TYPES__
#if !defined(ONLY_TYPES)
#define MTHMISC_UNDEF
#define ONLY_TYPES
#endif /* !ONLY_TYPES */
/*
------------------------------------------------------------------------------------------
INCLUDE FILES :
------------------------------------------------------------------------------------------
*/
#if defined(MTHMISC_UNDEF)
#undef ONLY_TYPES
#undef MTHMISC_UNDEF
#endif /* !MTHMISC_UNDEF */
/*
------------------------------------------------------------------------------------------
TYPE DEFINITION :
If enumerate :
M_BeginDeclareEnumerate(<type>)
M_EndDeclareEnumerate(<type>, <basic type>)
------------------------------------------------------------------------------------------
*/
#endif /* !__MTHMISC_TYPES__ */
#if !defined(ONLY_TYPES)
#if !defined(__MTHMISC_VARS__)
#define __MTHMISC_VARS__
#undef MTH_MISC_EXTERN
#undef extern
#if !defined(MTH_MISC_GLOBALS)
#define MTH_MISC_EXTERN extern
#else /* !GLOBALS */
#define MTH_MISC_EXTERN
#endif /* !GLOBALS */
/*
------------------------------------------------------------------------------------------
VARIABLE DECLARATION :
<type> <variable name>
#if defined(GLOBALS)
= <initial values>
#endif
;
------------------------------------------------------------------------------------------
*/
/*
------------------------------------------------------------------------------------------
MACROS-CONSTANT DECLARATION:
------------------------------------------------------------------------------------------
*/
#endif /* !__MTHMISC_VARS__ */
#if !defined (__MTHMISC_PROTOS__)
#define __MTHMISC_PROTOS__
/* For DLLs who are using this module : */
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
/*
------------------------------------------------------------------------------------------
MACROS-FUNCTIONS DECLARATION:
------------------------------------------------------------------------------------------
*/
/*
------------------------------------------------------------------------------------------
FUNCTIONS DECLARATION:
------------------------------------------------------------------------------------------
*/
MTH_MISC_EXTERN CPA_EXPORT void MTH_fnv_InitModule(unsigned long);
MTH_MISC_EXTERN CPA_EXPORT void MTH_fnv_DesinitModule(void);
MTH_MISC_EXTERN CPA_EXPORT void MTH_PrintUsedStaticMemory(void);
#endif /* !__MTHMISC_PROTOS__ */
#endif /* !ONLY_TYPES */

View File

@@ -0,0 +1,66 @@
/*
------------------------------------------------------------------------------------------
HEADER FILE FOR :
memory definition file for mathematic module
------------------------------------------------------------------------------------------
File Name :
MemMth.h
------------------------------------------------------------------------------------------
Creation :
* Date :
Feburary 18,1997
* Author :
Albert Pais
------------------------------------------------------------------------------------------
Contents :
This file contains definition for the memory management concerning the mathematical
module
------------------------------------------------------------------------------------------
Modification :
* Date :
* Author :
* Modify :
------------------------------------------------------------------------------------------
*/
/****************************************/
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
/****************************************/
#ifndef __MemMth_H__
#define __MemMth_H__
enum e_ucMthStaticBlocks{
E_ucMTHBlock1, /* Not used now*/
E_ucMTHMaxBlocksNb /* maximum number of static block, You have to follow this syntax 'E_uc+ Abbreviation Module +MaxBlocksNb'*/
};
#undef EXTERN
#undef extern
#ifdef __DeclareGlobalVariableMemMth_h__
#define EXTERN /*nothing*/
#else /* no __DeclareGlobalVariableMemMth_h__*/
#define EXTERN extern
#endif /*__DeclareGlobalVariableMemMth_h__*/
EXTERN CPA_EXPORT tdstBlockInfo g_a_stMTHBlocksInfo[E_ucMTHMaxBlocksNb];
#ifdef __DYNAMIC_MALLOC_ALLOWED__
#ifdef __DEBUG_MALLOC_MODE__
EXTERN CPA_EXPORT tdstDynInfo g_stMTHDynInfo;
#endif /*__DEBUG_MALLOC_MODE__*/
#endif /*__DYNAMIC_MALLOC_ALLOWED__*/
#undef extern
#endif /*__MemMth_H__*/

View File

@@ -0,0 +1,42 @@
/*
------------------------------------------------------------------------------------------
HEADER FILE FOR :
Option for MTH Module
------------------------------------------------------------------------------------------
File Name :
Mth_Opt.h
------------------------------------------------------------------------------------------
Creation :
* Date :
February 18,1997
* Author :
Albert Pais
------------------------------------------------------------------------------------------
Contents :
This files defines main option for the mathematical module
------------------------------------------------------------------------------------------
Modification :
* Date :
* Author :
* Modify :
------------------------------------------------------------------------------------------
*/
#if !defined(__MTHOPT_H__)
#define __MTHOPT_H__
/* For fatal errors :*/
#define __FATAL_ERR_MTH__
/* #undef __FATAL_ERR_MTH__*/
/* for warning errors :*/
#define __WARNING_ERR_MTH__
/*#undef __WARNING_ERR_MTH__*/
/* for static/dynamic memory management :*/
/*#define MODE_STATIC_MEM_FOR_MTH*/
#undef MODE_STATIC_MEM_FOR_MTH
/* debug/Ndebug mode :*/
#define MTH_M_DEBUG
/*#undef MTH_M_DEBUG*/
#endif

View File

@@ -0,0 +1,466 @@
//#include <Windows.h>
/*
INFORMATINOS SUR LES LECTEURS
*/
/* Renvoie le numero de serie crypte du lecteur passe en parametre */
#define M_SNCryptKey 13
#define M_CDSerialNumberWanted (long)((long)2183834492*(long)M_SNCryptKey)
long fn_lVolumeSerialNumber(char *_szFileName, tdstLoaderHandler *stHandler)
{
BY_HANDLE_FILE_INFORMATION stBHFI;
HANDLE hFile;
UINT uiMode;
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
hFile = stHandler->CreateFile(_szFileName, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
stHandler->SetErrorMode(uiMode);
if (hFile != INVALID_HANDLE_VALUE)
{
if (stHandler->GetFileInformationByHandle(hFile, &stBHFI))
{
stHandler->CloseHandle (hFile);
return (stBHFI.dwVolumeSerialNumber * M_SNCryptKey);
}
stHandler->CloseHandle (hFile);
}
return (long)2832043;
}
/* Renvoie le typde du lecteur passe en parametre */
#define M_CDDriveTypeWanted DRIVE_CDROM
long fn_lDriveType(char *_szFileName, tdstLoaderHandler *stHandler)
{
UINT uiMode;
long lResult;
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
lResult = stHandler->GetDriveType(_szFileName);
stHandler->SetErrorMode(uiMode);
return lResult;
}
/* Renvoie une valeur de hashage correspondant au label du lecteur passe en parametre */
#define M_CDLabelWanted -1323110684
long fn_lDriveLabel(char *_szFileName, tdstLoaderHandler *stHandler)
{
UINT uiMode;
char xBuffer[255], *pBuffer;
long lResult = 0;
pBuffer = xBuffer;
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
stHandler->GetVolumeInformation(_szFileName, pBuffer, 255, NULL, NULL, NULL, NULL, 0);
stHandler->SetErrorMode(uiMode);
/* Hash code du label... */
while (*pBuffer != 0)
{
lResult = (lResult << 5) + lResult + tolower(*pBuffer);
++pBuffer;
}
return lResult;
}
/* Renvoie le file systeme crypte du lecteur passe en parametre */
#define M_CDFSCryptKey 2759
#define M_CDFSWanted 1397113923L * M_CDFSCryptKey /* "CDFS"*/
long fn_lDriveFsType(char *_szFileName, tdstLoaderHandler *stHandler)
{
UINT uiMode;
char xBuffer[10];
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
stHandler->GetVolumeInformation(_szFileName, NULL, NULL, NULL, NULL, NULL, xBuffer, 10);
stHandler->SetErrorMode(uiMode);
return *((long *)xBuffer) * M_CDFSCryptKey;
}
/* Renvoie l'espace libre crypte en cluster du lecteur passe en parametre */
#define M_SFCryptKey 2533
#define M_CDFreeClusterWanted 0+M_SFCryptKey
long fn_lDriveFreeSpace(char *_szFileName, tdstLoaderHandler *stHandler)
{
UINT uiMode;
DWORD dwInfos[4];
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
stHandler->GetDiskFreeSpace(_szFileName, &dwInfos[0], &dwInfos[1], &dwInfos[2], &dwInfos[3]);
stHandler->SetErrorMode(uiMode);
return dwInfos[2] + M_SFCryptKey;
}
/* Renvoie le nombre de secteurs par cluster du lecteur passe en parametre */
#define M_SPCCryptKey 1937
#define M_CDSectorsPerClusterWanted 1*M_SPCCryptKey
long fn_lDriveSectorsPerCluster(char *_szFileName, tdstLoaderHandler *stHandler)
{
UINT uiMode;
DWORD dwInfos[4];
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
stHandler->GetDiskFreeSpace(_szFileName, &dwInfos[0], &dwInfos[1], &dwInfos[2], &dwInfos[3]);
stHandler->SetErrorMode(uiMode);
return dwInfos[0] * M_SPCCryptKey;
}
/* Renvoie le nombre de bytes par secteur du lecteur passe en parametre */
#define M_BPSCryptKey 9701
#define M_CDBytesPerSectorWanted 2048*M_BPSCryptKey
long fn_lDriveBytesPerSector(char *_szFileName, tdstLoaderHandler *stHandler)
{
UINT uiMode;
DWORD dwInfos[4];
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
stHandler->GetDiskFreeSpace(_szFileName, &dwInfos[0], &dwInfos[1], &dwInfos[2], &dwInfos[3]);
stHandler->SetErrorMode(uiMode);
return dwInfos[1] * M_BPSCryptKey;
}
/* Renvoie le nombre de clusters du lecteur passe en parametre */
#define M_NCCryptKey 10497
#define M_CDClustersWanted 186225*M_NCCryptKey
long fn_lDriveClusters(char *_szFileName, tdstLoaderHandler *stHandler)
{
UINT uiMode;
DWORD dwInfos[4];
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
stHandler->GetDiskFreeSpace(_szFileName, &dwInfos[0], &dwInfos[1], &dwInfos[2], &dwInfos[3]);
stHandler->SetErrorMode(uiMode);
return dwInfos[3] * M_NCCryptKey;
}
/*
INFORMATINOS SUR LES FICHIERS
*/
/* Renvoie les attributs cryptes du fichier passe en parametre */
#define M_FCACryptKey 57931
long fn_lFileChangeAttribut(char *_szFileName, tdstLoaderHandler *stHandler)
{
UINT uiMode;
long lResult;
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
stHandler->SetFileAttributes(_szFileName, FILE_ATTRIBUTE_NORMAL);
lResult = stHandler->GetFileAttributes(_szFileName);
stHandler->SetErrorMode(uiMode);
return lResult * M_FCACryptKey;
}
/* Test en ecriture le fichier et renvoie 1 en cas de succes (donc d'erreur pour le protection :)*/
long fn_lFileWriteable(char *_szFileName, tdstLoaderHandler *stHandler)
{
HANDLE hFile;
UINT uiMode;
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
hFile = stHandler->CreateFile(_szFileName , GENERIC_WRITE , 0 , NULL , CREATE_ALWAYS , FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, NULL);
stHandler->SetErrorMode(uiMode);
if( hFile != INVALID_HANDLE_VALUE)
{
stHandler->CloseHandle (hFile);
return 1;
}
else
{
return 0;
}
}
/* Renvoie la taille cryptee du fichier passe en parametre */
#define M_FSCryptKey 53791
long fn_lFileSize(char *_szFileName, tdstLoaderHandler *stHandler)
{
DWORD iResult;
HANDLE hFile;
UINT uiMode;
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
hFile = stHandler->CreateFile(_szFileName, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
stHandler->SetErrorMode(uiMode);
if (hFile != INVALID_HANDLE_VALUE)
{
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
iResult = stHandler->GetFileSize(hFile, NULL);
stHandler->CloseHandle (hFile);
stHandler->SetErrorMode(uiMode);
return iResult*M_FSCryptKey;
}
return M_FSCryptKey;
}
/* Renvoie l'heure de derniere modification, cryptee, du fichier passe en parametre */
#define M_FTCryptKey 53791
long fn_lFileTime(char *_szFileName, tdstLoaderHandler *stHandler)
{
DWORD dwResult[2];
HANDLE hFile;
UINT uiMode;
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
hFile = stHandler->CreateFile(_szFileName, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
stHandler->SetErrorMode(uiMode);
if (hFile != INVALID_HANDLE_VALUE)
{
uiMode = stHandler->SetErrorMode(SEM_FAILCRITICALERRORS);
stHandler->GetFileTime(hFile, NULL, NULL, (LPFILETIME)dwResult);
--dwResult[0];
stHandler->SetFileTime(hFile, NULL, NULL, (LPFILETIME)dwResult);
stHandler->GetFileTime(hFile, NULL, NULL, (LPFILETIME)dwResult);
stHandler->SetErrorMode(uiMode);
return ((dwResult[0] * M_FTCryptKey) << 16) + dwResult[1];
}
return M_FTCryptKey;
}
/*
VERIFICATION DU SYSTEME
*/
#define M_SoftIceWanted 83
long fn_lSoftIcePresent(char *_szFileName, tdstLoaderHandler *stHandler)
{
HANDLE hFile = stHandler->CreateFile(_szFileName ,
GENERIC_READ,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if( hFile != INVALID_HANDLE_VALUE )
{
stHandler->CloseHandle(hFile);
return M_SoftIceWanted-11;
}
return M_SoftIceWanted;
}
#define M_DHCryptKey 3036172749
long fn_lDllHooked(char *_szFunctionName, tdstLoaderHandler *stHandler)
{
return stHandler->SearchExportedFunctionInEveryDLL(_szFunctionName) * M_DHCryptKey;
}
#define M_FHCryptKey 3036172749
long fn_lFunctionHooked(char *_szFunctionName, tdstLoaderHandler *stHandler)
{
DWORD dwAddress;
return dwAddress = stHandler->SearchFunctionInImportedTableOfExe(_szFunctionName) + M_FHCryptKey;
}
/* Should be the last!!!!! */
long fn_lLAST_FUNCTION(char *_szFileName, tdstLoaderHandler *stHandler)
{
return 0;
}
/* ATTENTION : les fonction doivent etre declares dans le tableau DANS L'ORDRE d'apparition dans le fichier!!!!
En effet on utilise le pointeur suivant dans le tableau pour connaitre la taille de la fonction
precedante...
Ce n'est pas tres joli, mais c'est la seule maniere automatique :(
*/
ptrFunction g_ListOfProtectionFunctions[50] =
{
/*00*/ &fn_lVolumeSerialNumber,
/*01*/ &fn_lDriveType,
/*02*/ &fn_lDriveLabel,
/*03*/ &fn_lDriveFsType,
/*04*/ &fn_lDriveFreeSpace,
/*05*/ &fn_lDriveSectorsPerCluster,
/*06*/ &fn_lDriveBytesPerSector,
/*07*/ &fn_lDriveClusters,
/*08*/ &fn_lFileChangeAttribut,
/*09*/ &fn_lFileWriteable,
/*10*/ &fn_lFileSize,
/*11*/ &fn_lFileTime,
/*12*/ &fn_lSoftIcePresent,
/*13*/ &fn_lDllHooked,
/*14*/ &fn_lFunctionHooked,
/*15*/ &fn_lLAST_FUNCTION, /* Should be the last!!!!! */
NULL
};
/* Le tableau suivant contient la liste des fonctions associes a leur parametre et resultat voulu.
Le numero d'ordre correspond au type dans les modele de protection (+100 pour les actifs et +200
pour les passifs).
*/
#define M_FileAttributeRO FILE_ATTRIBUTE_READONLY*M_FCACryptKey
#include"PTC/PTC_abc.h" /* Pour les noms des fonctions dll cryptes */
tdstProtectionsInit g_ProtectionFunctions[100] =
{
/* Tests direct du CD */
/*00*/ &fn_lVolumeSerialNumber, M_CDSerialNumberWanted, "A:\\", 1,
/*01*/ &fn_lDriveType, M_CDDriveTypeWanted, "A:\\", 1,
/*02*/ &fn_lDriveLabel, M_CDLabelWanted, "A:\\", 1,
/*03*/ &fn_lDriveFsType, M_CDFSWanted, "A:\\", 1,
/*04*/ &fn_lDriveFreeSpace, M_CDFreeClusterWanted, "A:\\", 1,
/*05*/ &fn_lDriveSectorsPerCluster, M_CDSectorsPerClusterWanted, "A:\\", 1,
/*06*/ &fn_lDriveBytesPerSector, M_CDBytesPerSectorWanted, "A:\\", 1,
/*07*/ &fn_lDriveClusters, M_CDClustersWanted, "A:\\", 1,
/* Tests sur des fichiers presents sur le CD */
/*08*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\Rayman2.ico", 1,
/*09*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\Dll\\APMP5SVR.dll", 1,
/*10*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*11*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*12*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*13*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*14*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*15*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*16*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*17*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*18*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*19*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*20*/ &fn_lFileChangeAttribut, M_FileAttributeRO, "A:\\", 1,
/*21*/ &fn_lFileWriteable, 0, "A:\\BinData\\game.dsb", 1,
/*22*/ &fn_lFileWriteable, 0, "A:\\Setup.exe", 1,
/*23*/ &fn_lFileWriteable, 0, "A:\\Autorun.inf", 1,
/*24*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*25*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*26*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*27*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*28*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*29*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*30*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*31*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*32*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*33*/ &fn_lFileWriteable, 0, "A:\\", 1,
/*34*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\BinData\\textures.cnt", 1,
/*35*/ &fn_lFileSize, 729088*M_FSCryptKey, "A:\\SetupUbi.exe", 1,
/*36*/ &fn_lFileSize, 921644*M_FSCryptKey, "A:\\InstData\\Rayman.tga", 1,
/*37*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*38*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*39*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*40*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*41*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*42*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*43*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*44*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*45*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*46*/ &fn_lFileSize, 1812*M_FSCryptKey, "A:\\", 1,
/*47*/ &fn_lFileTime, 0, "A:\\Lisezmoi.txt", 1,
/*48*/ &fn_lFileTime, 0, "A:\\Dll\\GliDetectDll.dll", 1,
/*49*/ &fn_lFileTime, 0, "A:\\", 1,
/*50*/ &fn_lFileTime, 0, "A:\\", 1,
/*51*/ &fn_lFileTime, 0, "A:\\", 1,
/*52*/ &fn_lFileTime, 0, "A:\\", 1,
/*53*/ &fn_lFileTime, 0, "A:\\", 1,
/*54*/ &fn_lFileTime, 0, "A:\\", 1,
/*55*/ &fn_lFileTime, 0, "A:\\", 1,
/*56*/ &fn_lFileTime, 0, "A:\\", 1,
/*57*/ &fn_lFileTime, 0, "A:\\", 1,
/*58*/ &fn_lFileTime, 0, "A:\\", 1,
/*59*/ &fn_lFileTime, 0, "A:\\", 1,
/* Test de softice */
/*60*/ &fn_lSoftIcePresent, M_SoftIceWanted, "\\\\.\\SICE", 0,
/*61*/ &fn_lSoftIcePresent, M_SoftIceWanted, "\\\\.\\SIWVID", 0,
/* Tests des fonctions potentiellement hookee */
/*62*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_CreateFileAName, 0,
/*63*/ &fn_lFunctionHooked, 0, PTC_C_CreateFileAName, 0,
/*64*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_WriteFileName, 0,
/*65*/ &fn_lFunctionHooked, 0, PTC_C_WriteFileName, 0,
/*66*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_ReadFileName, 0,
/*67*/ &fn_lFunctionHooked, 0, PTC_C_ReadFileName, 0,
/*68*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_CloseHandleName, 0,
/*69*/ &fn_lFunctionHooked, 0, PTC_C_CloseHandleName, 0,
/*70/ &fn_lDllHooked, M_FHCryptKey, PTC_C_SetErrorModeName, 0,
/*71*/ &fn_lFunctionHooked, 0, PTC_C_SetErrorModeName, 0,
/*72*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_GetFileInformationByHandleName,0,
/*73*/ &fn_lFunctionHooked, 0, PTC_C_GetFileInformationByHandleName,0,
/*74*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_GetDiskFreeSpaceAName, 0,
/*75*/ &fn_lFunctionHooked, 0, PTC_C_GetDiskFreeSpaceAName, 0,
/*76*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_SetFileAttributsAName, 0,
/*77*/ &fn_lFunctionHooked, 0, PTC_C_SetFileAttributsAName, 0,
/*78*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_GetFileAttributsAName, 0,
/*79*/ &fn_lFunctionHooked, 0, PTC_C_GetFileAttributsAName, 0,
/*80*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_GetFileTimeName, 0,
/*81*/ &fn_lFunctionHooked, 0, PTC_C_GetFileTimeName, 0,
/*82*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_SetFileTimeName, 0,
/*83*/ &fn_lFunctionHooked, 0, PTC_C_SetFileTimeName, 0,
/*84*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_SetFilePointerName, 0,
/*85*/ &fn_lFunctionHooked, 0, PTC_C_SetFilePointerName, 0,
/*86*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_FlushFileBufferName, 0,
/*87*/ &fn_lFunctionHooked, 0, PTC_C_FlushFileBufferName, 0,
/*88*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_GetDriveTypeAName, 0,
/*89*/ &fn_lFunctionHooked, 0, PTC_C_GetDriveTypeAName, 0,
/*90*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_GetVolumeInformationAName,0,
/*91*/ &fn_lFunctionHooked, 0, PTC_C_GetVolumeInformationAName,0,
/*92*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_GetFileSizeName, 0,
/*93*/ &fn_lFunctionHooked, 0, PTC_C_GetFileSizeName, 0,
/*94*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_GetLogicalDriveStringsAName,0,
/*95*/ &fn_lFunctionHooked, 0, PTC_C_GetLogicalDriveStringsAName,0,
/*96*/ &fn_lDllHooked, M_FHCryptKey, PTC_C_LoadLibraryAName, 0,
/*97*/ &fn_lFunctionHooked, 0, PTC_C_LoadLibraryAName, 0,
};
/* &fn_lSoftIcePresent, M_SoftIceWanted, "\\\\.\\NTICE", 0,*/

View File

@@ -0,0 +1,997 @@
/*---------------------------------------------------------------------------*/
/* Strintel.cpp : Definition des fonctions utiles pour manipuler les structures*/
/* de donn<6E>e du module d'intelligence.*/
/* auhor : Olivier Didelot 08/08/96*/
/* modify : Olivier Didelot 21/10/96*/
/* .....???????????*/
/* modify : Olivier Couvreur 04/02/97 Lint 0 warnings excepted those specified at the end of AIMacros.h*/
/* modify : Olivier Couvreur 14/02/97 Creation of Deallocation functions*/
/* modify : Olivier Couvreur 18/02/97 CPA_EXPORT + new functions for editor*/
/* modify : Olivier Couvreur 05/03/97 Model can be gathered between several perso + Alloc and Free functions rewritten + Lint*/
/* modify : Olivier Couvreur 11/03/97 .dec can be gathered between several perso + Alloc and Free functions rewritten + Lint*/
/* modify : Olivier Couvreur 25/03/97 NbNode is not an unsigned char anymore + NoComportInit support + minor changes for editor*/
/* modify : Olivier Couvreur 29/04/97 Init Comport and .IAI support + DsgVar Perso*/
/*---------------------------------------------------------------------------*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Mmg.h"
#include "AI_Erm.h"
#include "AI_Struc.h"
#include "AI_Proto.h"
#include "DsgMem.h"
#include "specif/ActTable.h"
#include "StrIntel.h"
#include "Intell.h"
#include "Convert.h"
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
#include "AID_Erm.h"
#include "specif/AID_Trac.h"
#endif /*ACTIVE_AIDEBUG*/
void fn_vOnAIErm_M_UpdateLastError(unsigned short FatalErrorNum,char *szMsg)
{
Erm_M_UpdateLastError(AI, C_ucErmDefaultChannel, FatalErrorNum, C_lErmNoDebugData, C_ucErmOpenInfoWindow, C_ucAllowStopForDebug, szMsg);
}
void fn_vErrorOnAIAlloc()
{
M_AIIfErrorUpdateFatalError(Mmg, E_uwAIFatalFailedAllocationMem);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vErrorOnAIFree()
{
M_AIIfErrorUpdateWarningError (Mmg, E_uwAIWarningCanNotFree, C_ucErmOpenInfoWindow);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
void fn_vReinitComport(tdstIntelligence *p_stIntelligence)
{
(void) fn_ucChangeComportIntell(p_stIntelligence, (tdstComport *)M_GetNoComportInit(p_stIntelligence));
M_GetPrevComport(p_stIntelligence) = M_GetCurrentComport(p_stIntelligence);
}
unsigned char fn_ucChangeComportIntell(tdstIntelligence *p_stIntelligence, tdstComport *p_stComport)
{
#if defined(__DEBUG_AI__)
long lComport=(p_stComport-M_GetComport(p_stIntelligence));
if ( (lComport<0) || (lComport>=(long) M_GetNbComport(p_stIntelligence)) )
{
M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningComportOfAnotherPerso, C_ucErmOpenInfoWindow,M_GetNameComport(p_stComport));
#if defined(ACTIVE_EDITOR) && defined(ACTIVE_EXEC_CHECKING)
fn_vSetStopAIEngineFlag();
#endif
return(FALSE);
}
else
#endif
{
M_GetPrevComport(p_stIntelligence) = M_GetCurrentComport(p_stIntelligence);
M_GetCurrentComport(p_stIntelligence) = p_stComport;
fn_vInitActionTable(p_stIntelligence);
/* Update new schedule.*/
if (M_GetComportSchedule(p_stComport) == NULL)
M_GetCurrentSchedule(p_stIntelligence) = NULL;
else
M_GetCurrentSchedule(p_stIntelligence) = M_GetTreeComportSchedule(p_stComport);
#if defined(ACTIVE_AIDEBUG) /*** DR ***/
AIDebug_M_SetCurrentComport( fn_p_stGetCurrentMind(), p_stComport );
#endif /*ACTIVE_AIDEBUG*/
}
return(TRUE);
}
unsigned char fn_ucGetTreeNbParam(tdstNodeInterpret *p_stTree)
{
unsigned char ucNbParam=0;
unsigned char ucDepth = M_DepthInterpret(p_stTree-1);
while ( (M_DepthInterpret(p_stTree) > ucDepth)
&& (!M_IsTheEndOfTree(p_stTree)))
{
if (M_DepthInterpret(p_stTree)==ucDepth+1)
{
ucNbParam++;
}
p_stTree++;
}
return(ucNbParam);
}
#if defined(OPTIMIZE_NB_NODES)
unsigned short fn_uwGetNbNodeInterpret(struct tdstTreeInterpret_ *p_stTreeInterpret)
{
tdstNodeInterpret *p_stTree,*p_stTreeInit;
p_stTree=p_stTreeInit=M_GetNodeInterpret(p_stTreeInterpret);
if (p_stTree==NULL) return(0);
while(!M_IsTheEndOfTree(p_stTree)) p_stTree++;
p_stTree++;
return ((unsigned short) (p_stTree-p_stTreeInit) );
}
#endif /* OPTIMIZE_NB_NODES*/
/**************************************************************/
/* AI init functions used by allocations */
/**************************************************************/
//#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
void fn_vInitMacro(tdstMacro *p_stMacro)
{
M_GetMacroInitTree(p_stMacro) = NULL;
M_GetMacroCurrentTree(p_stMacro) = M_GetMacroInitTree(p_stMacro);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vInitListOfMacro(tdstListOfMacro *p_stListOfMacro, unsigned char ucNbMacro)
{
M_GetMacro(p_stListOfMacro) = NULL;
M_GetNbMacro(p_stListOfMacro) = ucNbMacro;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
void fn_vInitComport(tdstComport *p_stComport)
{
M_GetComportNbRules(p_stComport)=0;
M_GetComportRules(p_stComport) = NULL;
M_GetComportSchedule(p_stComport) = NULL;
}
void fn_vInitRule(tdstTreeInterpret *p_stRule)
{
M_SetNbNodeInterpret(p_stRule,0);
M_GetNodeInterpret(p_stRule)=NULL;
}
void fn_vInitNodeInterpret(tdstNodeInterpret *p_stNode, long lVal,
tdeTypeInterpret eTypeInterpret, unsigned char ucDepth)
{
M_ClearNodeInterpret(p_stNode);
M_DepthInterpret(p_stNode)=ucDepth;
M_lValueInterpret(p_stNode)=lVal;
M_SetTypeInterpret(p_stNode,eTypeInterpret);
#if defined(OPTIMIZE_SWAP_PARAMETER)
M_NodeToSkip(p_stNode)=0;
#endif
#if defined( ACTIVE_AIDEBUG )
M_SetBreakPoint(p_stNode,FALSE);
#endif /*ACTIVE_AIDEBUG*/
}
#ifdef ACTIVE_EDITOR
/**************************************************************/
/* AI desallocation functions : */
/**************************************************************/
char CFast_g_bNoNeedForFreeNodeContent = 0;
/*********************************************************************************************/
void fn_vFreeNodeContent(tdstNodeInterpret *p_stNode)
{
/* is there node ?*/
if (p_stNode!=NULL)
{
if (M_GetTypeInterpret(p_stNode) == E_ti_String)
{
if (M_szStringInterpret(p_stNode) != NULL)
{
M_AIFree(M_szStringInterpret(p_stNode));
}
}
else if (M_GetTypeInterpret(p_stNode) == E_ti_ConstantVector)
{
if (M_p_stVectorInterpret(p_stNode) != NULL)
{
M_AIFree(M_p_stVectorInterpret(p_stNode));
}
}
fn_vInitNodeInterpret(p_stNode,0,(tdeTypeInterpret) 0,0);
}
}
/* free an array of nodes */
void fn_vFreeNodeInterpretAll(tdstNodeInterpret **p_p_stNode,unsigned short uwNbNodes)
{
/* is there node ?*/
if (*p_p_stNode!=NULL)
{
unsigned short i;
/* free nodes content*/
if ( !CFast_g_bNoNeedForFreeNodeContent ) {
for (i=0;i<uwNbNodes;i++)
{
fn_vFreeNodeContent(&((*p_p_stNode)[i]));
}
}
/* free node itself*/
M_AIFree(*p_p_stNode);
*p_p_stNode=NULL;
}
}
/*********************************************************************************************/
/* free rule content*/
void fn_vFreeRuleContent(tdstTreeInterpret *p_stRules)
{
/* is there rule ?*/
if (p_stRules!=NULL)
{
/* free nodes*/
fn_vFreeNodeInterpretAll(&M_GetNodeInterpret(p_stRules),M_GetNbNodeInterpret(p_stRules));
fn_vInitRule(p_stRules);
}
}
/* free a rule and all its nodes*/
void fn_vFreeRuleAll(tdstTreeInterpret **p_p_stRules,unsigned char ucNbRules)
{
/* is there rule ?*/
if (*p_p_stRules!=NULL)
{
unsigned char i;
/* free rule content (nodes)*/
for(i=0;i<ucNbRules;i++)
{
fn_vFreeRuleContent(&((*p_p_stRules)[i]));
}
/* free rule itself*/
M_AIFree(*p_p_stRules);
*p_p_stRules=NULL;
}
}
/*********************************************************************************************/
/* free schedule content*/
void fn_vFreeScheduleContent(tdstTreeInterpret *p_stSchedule)
{
/* is there schedule ?*/
if (p_stSchedule!=NULL)
{
/* free nodes*/
fn_vFreeNodeInterpretAll(&M_GetNodeInterpret(p_stSchedule),M_GetNbNodeInterpret(p_stSchedule));
fn_vInitRule(p_stSchedule);
}
}
void fn_vFreeScheduleAll(tdstTreeInterpret **p_p_stSchedule)
{
/* is there schedule ?*/
if (*p_p_stSchedule!=NULL)
{
/* free Schedule content (nodes)*/
fn_vFreeScheduleContent(*p_p_stSchedule);
/* free schedule itself*/
M_AIFree(*p_p_stSchedule);
*p_p_stSchedule=NULL;
}
}
/*********************************************************************************************/
/* free a comport content, all its rules, and its schedule*/
void fn_vFreeComportContent(tdstComport *p_stComport)
{
if (p_stComport!=NULL)
{
/* free rules */
fn_vFreeRuleAll(&M_GetComportRules(p_stComport),M_GetComportNbRules(p_stComport));
/* free schedule */
fn_vFreeScheduleAll(&M_GetComportSchedule(p_stComport));
/* clear */
fn_vInitComport(p_stComport);
}
}
void fn_vFreeComportAll(tdstComport **p_p_stComport,unsigned long ulNbComport)
{
/* is there comport ?*/
if (*p_p_stComport!=NULL)
{
unsigned long i;
/* free comport content*/
for (i=0;i<ulNbComport;i++)
{
fn_vFreeComportContent(&((*p_p_stComport)[i]));
}
/* free comport itself*/
M_AIFree(*p_p_stComport);
*p_p_stComport=NULL;
}
}
/*********************************************************************************************/
void fn_vFreeSubroutineContent ( tdstMacro * p_stSubroutine )
{
if ( p_stSubroutine != NULL )
{
fn_vFreeRuleAll ( & M_GetMacroInitTree ( p_stSubroutine ) , 1 ) ;
}
}
/* free a list of Subroutines */
void fn_vFreeSubroutinesAll(tdstListOfMacro **p_stListSubroutines)
{
if ( * p_stListSubroutines != NULL )
{
int i ;
/* free the subroutines */
for ( i = 0 ; i < M_GetNbMacro ( ( * p_stListSubroutines ) ) ; i ++ )
fn_vFreeSubroutineContent ( M_GetMacroN ( * p_stListSubroutines , i) ) ;
/* and free the list itself */
M_AIFree ( * p_stListSubroutines ) ;
* p_stListSubroutines = NULL ;
}
}
/*********************************************************************************************/
void fn_vFreeScriptAIContent(tdstScriptAI *p_stScriptAI)
{
/* is there ScriptAI ?*/
if (p_stScriptAI!=NULL)
{
fn_vFreeComportAll(&M_GetScriptAIComport(p_stScriptAI),M_GetScriptAINbComport(p_stScriptAI));
}
}
/* free a ScriptAI and all its comport*/
void fn_vFreeScriptAIAll(tdstScriptAI **p_p_stScriptAI)
{
/* is there ScriptAI ?*/
if (*p_p_stScriptAI!=NULL)
{
/* free ScriptAI content (comport)*/
fn_vFreeScriptAIContent(*p_p_stScriptAI);
/* free ScriptAI itself*/
M_AIFree(*p_p_stScriptAI);
*p_p_stScriptAI=NULL;
}
}
/*********************************************************************************************/
/* free model content*/
void fn_vFreeAIModelContent(AI_tdstAIModel *p_stAIModel)
{
/* is there Model ?*/
if (p_stAIModel!=NULL)
{
/* free the intelligence */
fn_vFreeScriptAIAll(&AI_M_p_stGetIntelligenceScriptAIModel(p_stAIModel));
/* free the reflexes */
fn_vFreeScriptAIAll(&AI_M_p_stGetReflexScriptAIModel(p_stAIModel));
/* free the subroutines */
fn_vFreeSubroutinesAll(&AI_M_p_stGetListOfMacroAIModel(p_stAIModel)) ;
}
}
/* free a model and its 2 ScriptAI*/
void fn_vFreeAIModelAll(AI_tdstAIModel **p_p_stAIModel)
{
/* is there model ?*/
if (*p_p_stAIModel!=NULL)
{
/* free ScriptAI content (comport)*/
fn_vFreeAIModelContent(*p_p_stAIModel);
/* CFast, is there a RefTree*/
if ((*p_p_stAIModel)->CFast_dst_RefTreeArray != NULL) {
fn_vFreeNodeInterpretAll(&(*p_p_stAIModel)->CFast_dst_RefTreeArray, (*p_p_stAIModel)->uwNbNode) ;
}
/* CFast, is there a ParamTree*/
if ((*p_p_stAIModel)->CFast_dst_ParamArray != NULL) {
CFast_g_bNoNeedForFreeNodeContent = 1 ;
fn_vFreeNodeInterpretAll(&(*p_p_stAIModel)->CFast_dst_ParamArray, (*p_p_stAIModel)->uwNbParamNode) ;
CFast_g_bNoNeedForFreeNodeContent = 0 ;
}
/* free ScriptAI itself*/
M_AIFree(*p_p_stAIModel);
*p_p_stAIModel=NULL;
}
}
/*********************************************************************************************/
/* free action table entry content*/
void fn_vFreeActionTableEntryContent(tdstActionTableEntry *p_stActionTableEntry)
{
/* are there actiontable entries ?*/
if (p_stActionTableEntry!=NULL)
{
/* nothing to do */
}
}
void fn_vFreeActionTableEntryAll(tdstActionTableEntry **p_p_stActionTableEntry,unsigned ucActionTableNbEntry)
{
/* is there comport ?*/
if (*p_p_stActionTableEntry!=NULL)
{
unsigned char i;
/* free comport content*/
for (i=0;i<ucActionTableNbEntry;i++)
{
fn_vFreeActionTableEntryContent(&((*p_p_stActionTableEntry)[i]));
}
/* free comport itself*/
M_AIFree(*p_p_stActionTableEntry);
*p_p_stActionTableEntry=NULL;
}
}
/***************************************************************************/
void fn_vFreeActionTableContent(tdstActionTable *p_stActionTable)
{
/* is there action table ?*/
if (p_stActionTable!=NULL)
{
fn_vFreeActionTableEntryAll(&M_TableEntry(p_stActionTable),M_TableNbEntries(p_stActionTable));
}
}
/* free action table from intelligence*/
void fn_vFreeActionTableAll(tdstActionTable **p_p_stActionTable)
{
/* is there action table ?*/
if (*p_p_stActionTable!=NULL)
{
/* free action table content*/
fn_vFreeActionTableContent(*p_p_stActionTable);
/* free action table itself*/
M_AIFree(*p_p_stActionTable);
*p_p_stActionTable=NULL;
}
}
/*****************************************************************************/
/* free intelligence content*/
void fn_vFreeIntelligenceContent(tdstIntelligence *p_stIntelligence)
{
if (p_stIntelligence!=NULL)
{
fn_vFreeActionTableAll(&M_ActionTable(p_stIntelligence));
M_GetCurrentSchedule(p_stIntelligence)=NULL;
M_GetCurrentComport(p_stIntelligence)=NULL;
M_GetPrevComport(p_stIntelligence)=NULL;
p_stIntelligence->p_p_stScriptAI=NULL;
}
}
/* free intelligence*/
void fn_vFreeIntelligenceAll(tdstIntelligence **p_p_stIntelligence)
{
/* is there intelligence ?*/
if (*p_p_stIntelligence!=NULL)
{
fn_vFreeIntelligenceContent(*p_p_stIntelligence);
/* free intelligence itself*/
M_AIFree(*p_p_stIntelligence);
*p_p_stIntelligence=NULL;
}
}
/* free reflex*/
void fn_vFreeReflexAll(tdstIntelligence **p_p_stReflex)
{
fn_vFreeIntelligenceAll(p_p_stReflex);
}
/********************************************************************************************/
/* free mind content*/
void fn_vFreeMindContent(AI_tdstMind *p_stMind)
{
if (p_stMind!=NULL)
{
/* before model*/
/* free designer variable from mind*/
fn_vFreeDesignerVariable(p_stMind);
/* free AI model*/
/* fn_vFreeAIModelAll(&AI_M_p_stGetAIModel(p_stMind));*/
/* free intelligence from mind*/
fn_vFreeIntelligenceAll(&AI_M_p_stGetIntelligence(p_stMind));
/* free reflex from mind*/
fn_vFreeReflexAll(&AI_M_p_stGetReflex(p_stMind));
}
}
/* free mind all*/
void fn_vFreeMindAll(AI_tdstMind **p_p_stMind)
{
if (*p_p_stMind!=NULL)
{
/* free mind content*/
fn_vFreeMindContent(*p_p_stMind);
/* free mind itself*/
M_AIFree(*p_p_stMind);
*p_p_stMind=NULL;
}
}
#endif /* ACTIVE_EDITOR*/
/**************************************************************/
/* AI allocation functions : */
/**************************************************************/
/**************************************************************/
/* AI allocation functions for macros : */
/**************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdstListOfMacro *fn_p_stAllocListOfMacro(unsigned char ucNbMacro)
{
tdstListOfMacro *p_stListOfMacro=NULL;
/*XB980430*/
/* tdstMacro *p_stMacro=NULL;*/
/*End XB*/
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeMacro , NULL);
M_AIAlloc(p_stListOfMacro, tdstListOfMacro *, sizeof(tdstListOfMacro));
fn_vInitListOfMacro(p_stListOfMacro, ucNbMacro);
if (ucNbMacro!=0)
{
unsigned long i;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeMacro , NULL);
M_AIAlloc(M_GetMacro(p_stListOfMacro), tdstMacro *, ucNbMacro*sizeof(tdstMacro));
for (i=0;i<ucNbMacro;i++)
{
fn_vInitMacro(M_GetMacroN(p_stListOfMacro, i));
}
}
return(p_stListOfMacro);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vAllocListOfMacro(struct AI_tdstMind_ *p_stMind, unsigned char ucNbMacro)
{
AI_M_SetListOfMacroAIModel(AI_M_p_stGetAIModel(p_stMind), fn_p_stAllocListOfMacro(ucNbMacro));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vAllocNodeMacro(tdstMacro *p_stMacro, unsigned short uwNbNode)
{
MMG_fn_vBeginMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeNodeMacro , NULL);
M_AIAlloc(M_GetMacroInitTree(p_stMacro), tdstTreeInterpret *, sizeof(tdstTreeInterpret));
M_GetNodeInterpret(M_GetMacroInitTree(p_stMacro)) = fn_p_stAllocNodeInterpret(uwNbNode);;
M_SetNbNodeInterpret(M_GetMacroInitTree(p_stMacro),uwNbNode);
M_AIAlloc(M_GetMacroCurrentTree(p_stMacro), tdstTreeInterpret *, sizeof(tdstTreeInterpret))
M_GetNodeInterpret(M_GetMacroCurrentTree(p_stMacro)) = M_GetNodeInterpret(M_GetMacroInitTree(p_stMacro));
MMG_fn_vEndMemoryInfo ();
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
tdstComport *fn_p_stAllocComport(unsigned long ulNbComport)
{
tdstComport *p_stComport=NULL;
if (ulNbComport!=0)
{
unsigned long i;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeComport , NULL);
M_AIAlloc(p_stComport,tdstComport *,ulNbComport*sizeof(tdstComport));
for (i=0;i<ulNbComport;i++)
{
fn_vInitComport(&(p_stComport[i]));
//XB 05/08/99
#ifndef D_THROW_CFAST_AI
//End XB
p_stComport[i].CFast_lMyIndex = i;
//XB 05/08/99
#endif /* D_THROW_CFAST_AI */
//End XB
}
}
return(p_stComport);
}
tdstTreeInterpret *fn_p_stAllocRule(unsigned char ucNbRules)
{
tdstTreeInterpret *p_stRules=NULL;
if (ucNbRules!=0)
{
unsigned char i;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeRule , NULL);
M_AIAlloc(p_stRules, tdstTreeInterpret *,ucNbRules*sizeof(tdstTreeInterpret));
for (i=0;i<ucNbRules;i++)
{
fn_vInitRule(&(p_stRules[i]));
}
}
return(p_stRules);
}
tdstNodeInterpret *fn_p_stAllocNodeInterpret(unsigned short uwNbNode)
{
tdstNodeInterpret *p_stNodeInterpret=NULL;
if (uwNbNode!=0)
{
unsigned short i;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeNodeInterpret , NULL);
M_AIAlloc(p_stNodeInterpret, tdstNodeInterpret *, uwNbNode*sizeof(tdstNodeInterpret));
for (i=0;i<uwNbNode;i++)
{
fn_vInitNodeInterpret(&(p_stNodeInterpret[i]), 0, (tdeTypeInterpret)0, 0);
}
}
return(p_stNodeInterpret);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdstTreeInterpret *fn_p_stAllocSchedule(unsigned short uwNbNode)
{
tdstTreeInterpret *p_stSchedule=NULL;
/* allocate 1 rule*/
p_stSchedule=fn_p_stAllocRule(1);
/* allocate node*/
M_GetNodeInterpret(p_stSchedule)=fn_p_stAllocNodeInterpret(uwNbNode);
M_SetNbNodeInterpret(p_stSchedule,uwNbNode);
return(p_stSchedule);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* XB 20/05/1999 */
#ifndef D_THROW_COMPLEX_ACTION_TABLE
tdstActionTableEntry *fn_p_stAllocActionTableEntry(unsigned char ucActionTableNbEntry)
{
tdstActionTableEntry *p_stActionTableEntry=NULL;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeActionTableEntry , NULL);
M_AIAlloc(p_stActionTableEntry,tdstActionTableEntry *,ucActionTableNbEntry*sizeof(tdstActionTableEntry));
return(p_stActionTableEntry);
}
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
/* End XB 20/05/1999 */
extern unsigned char g_ucUseDefaultActionReturn;
extern unsigned char g_ucNewActionReturn;
tdstActionTable *fn_p_stAllocActionTable(unsigned char ucActionTableNbEntry)
{
tdstActionTableEntry *p_stEntry;
tdstActionTable *p_stActionTable=NULL;
/* XB 20/05/1999 */
#ifndef D_THROW_COMPLEX_ACTION_TABLE
unsigned char ucNEntry;
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
/* End XB 20/05/1999 */
/* XB 21/05/1999 */
#ifdef D_THROW_COMPLEX_ACTION_TABLE
if(ucActionTableNbEntry!=0)
{
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeActionTable , NULL);
M_AIAlloc(p_stActionTable,tdstActionTable *,sizeof(tdstActionTable));
#ifdef D_THROW_COMPLEX_ACTION_TABLE
}
else
{
return NULL;
}
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
/* End XB 21/05/1999 */
/* XB 20/05/1999 */
#ifndef D_THROW_COMPLEX_ACTION_TABLE
M_TableNbEntries(p_stActionTable)=ucActionTableNbEntry;
M_TableEntry(p_stActionTable)=fn_p_stAllocActionTableEntry(ucActionTableNbEntry);
/*//*/
/* ANNECY MT - 17/09/98 { initializes the table*/
p_stActionTable->ucNbEntriesUsed=0;
p_stActionTable->ucCurrentEntry=0;
/**/
for (ucNEntry=0,p_stEntry=M_TableEntry(p_stActionTable);ucNEntry<ucActionTableNbEntry;ucNEntry++,p_stEntry++)
{
p_stEntry -> bUseDefaultActionReturn = g_ucUseDefaultActionReturn;
p_stEntry -> ucNewActionReturn = g_ucNewActionReturn;
}
/* END ANNECY MT }*/
/*//*/
#else /* D_THROW_COMPLEX_ACTION_TABLE */
p_stEntry = &(p_stActionTable->stEntry);
p_stEntry->bUseDefaultActionReturn=g_ucUseDefaultActionReturn;
p_stEntry->ucNewActionReturn=g_ucNewActionReturn;
#endif /* D_THROW_COMPLEX_ACTION_TABLE */
/* End XB 20/05/1999 */
return(p_stActionTable);
}
AI_tdstAIModel *fn_p_stAllocAIModel()
{
AI_tdstAIModel *p_stAIModel=NULL;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeModel , NULL);
M_AIAlloc(p_stAIModel, AI_tdstAIModel *, sizeof(AI_tdstAIModel));
AI_M_SetIntelligenceScriptAIModel(p_stAIModel, NULL);
AI_M_SetReflexScriptAIModel(p_stAIModel, NULL);
AI_M_SetDsgVarAIModel(p_stAIModel,NULL);
#ifndef U64
AI_M_SetListOfMacroAIModel(p_stAIModel,NULL);
#endif /* U64 */
AI_M_SetSecondPassDone(p_stAIModel,0);
//XB 05/08/99
#ifndef D_THROW_CFAST_AI
//End XB
p_stAIModel->CFast_dst_RefTreeArray = NULL; /* BART ?*/
p_stAIModel->uwNbNode = 0; /* BART ?*/
p_stAIModel->CFast_dst_ParamArray = NULL ;
p_stAIModel->uwNbParamNode = 0 ;
p_stAIModel->CFast_lFunction = 0;
//XB 05/08/99
#endif /* D_THROW_CFAST_AI */
//End XB
return(p_stAIModel);
}
tdstScriptAI *fn_p_stAllocScriptAI(unsigned char ucActionTableNbEntry)
{
tdstScriptAI *p_stScriptAI=NULL;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeScriptAI , NULL);
M_AIAlloc(p_stScriptAI, tdstScriptAI *, sizeof(tdstScriptAI));
M_GetScriptAINbComport(p_stScriptAI)=0;
M_GetScriptAIComport(p_stScriptAI)=NULL;
M_GetScriptAIActionTableNbEntry(p_stScriptAI)=ucActionTableNbEntry;
M_GetScriptAINoComportInitDefault(p_stScriptAI)=0;
return(p_stScriptAI);
}
tdstIntelligence *fn_p_stAllocIntelligence(tdstScriptAI **p_p_stScriptAI,unsigned char ucActionTableNbEntry)
{
tdstIntelligence *p_stIntelligence=NULL;
if (M_GetScriptAINbComport(*p_p_stScriptAI)!=0)
{
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeIntelligence , NULL);
M_AIAlloc(p_stIntelligence, tdstIntelligence *, sizeof(tdstIntelligence));
/* link intelligence to its model*/
p_stIntelligence->p_p_stScriptAI=p_p_stScriptAI; /* faire macro*/
/* initialise with default comport*/
M_GetNoComportInit(p_stIntelligence)=M_GetScriptAINoComportInitDefault(*p_p_stScriptAI);
M_ActionTable(p_stIntelligence)=fn_p_stAllocActionTable(ucActionTableNbEntry);
/* ANNECY MT - 18/09/98 { fn_p_stAllocActionTable() initializes the table now*/
/*fn_vInitActionTable(p_stIntelligence);*/
/* END ANNECY MT }*/
}
return(p_stIntelligence);
}
#ifdef ACTIVE_EDITOR
/*********************/
/* DESIGNER VARAIBLE */
/*********************/
void fn_vFreeDsgVarInfoContent(tdstDsgVarInfo *p_stDsgVarInfo)
{
if (p_stDsgVarInfo!=NULL)
{
p_stDsgVarInfo->ulOffsetInDsgMem=0;
p_stDsgVarInfo->eDsgVarTypeId=eNbDsgVarType;
}
}
void fn_vFreeDsgVarInfoAll(tdstDsgVarInfo **p_p_stDsgVarInfo,unsigned char ucNbDsgVar)
{
if (*p_p_stDsgVarInfo!=NULL)
{
unsigned char i;
/* free DsgVarContent*/
for(i=0;i<ucNbDsgVar;i++)
{
fn_vFreeDsgVarInfoContent(&((*p_p_stDsgVarInfo)[i]));
}
/* free DsgVar itself*/
M_AIFree(*p_p_stDsgVarInfo);
*p_p_stDsgVarInfo=NULL;
}
}
void fn_vFreeDsgVarContent(tdstDsgVar *p_stDsgVar)
{
if (p_stDsgVar!=NULL)
{
fn_vFreeDsgMemBuffer(&(p_stDsgVar->p_cDsgMemDefaultInit));
fn_vFreeDsgVarInfoAll(&(p_stDsgVar->p_stDsgVarInfo),p_stDsgVar->ucNbDsgVar);
p_stDsgVar->ulSize=0;
p_stDsgVar->ucNbDsgVar=0;
}
}
void fn_vFreeDsgVarAll(tdstDsgVar **p_p_stDsgVar)
{
if (*p_p_stDsgVar!=NULL)
{
fn_vFreeDsgVarContent(*p_p_stDsgVar);
M_AIFree(*p_p_stDsgVar);
*p_p_stDsgVar=NULL;
}
}
void fn_vFreeDsgMemBuffer(char **p_p_cDsgMemBuffer)
{
if (*p_p_cDsgMemBuffer!=NULL)
{
M_AIFree(*p_p_cDsgMemBuffer);
*p_p_cDsgMemBuffer=NULL;
}
}
void fn_vFreeDsgMemContent(tdstDsgMem *p_stDsgMem)
{
if (p_stDsgMem!=NULL)
{
fn_vFreeDsgMemBuffer(&(p_stDsgMem->p_cDsgMemBufferInit));
fn_vFreeDsgMemBuffer(&(p_stDsgMem->p_cDsgMemBuffer));
}
}
void fn_vFreeDsgMemAll(tdstDsgMem **p_p_stDsgMem)
{
if (*p_p_stDsgMem!=NULL)
{
fn_vFreeDsgMemContent(*p_p_stDsgMem);
M_AIFree(*p_p_stDsgMem);
*p_p_stDsgMem=NULL;
}
}
void fn_vFreeDesignerVariable(AI_tdstMind *p_stMind)
{
if (M_GetDsgMem(p_stMind)!=NULL)
{
if(M_GetDsgVar(p_stMind)!=NULL)
{
fn_vFreeDsgVarAll(&M_GetDsgVar(p_stMind));
}
fn_vFreeDsgMemAll(&M_GetDsgMem(p_stMind));
}
}
#endif /* ACTIVE_EDITOR*/
tdstDsgVarInfo *fn_p_stAllocDsgVarInfo(unsigned char ucNbDsgVar)
{
unsigned char i;
tdstDsgVarInfo *p_stDsgVarInfo=NULL;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeDsgVarInfo , NULL);
M_AIAlloc(p_stDsgVarInfo,tdstDsgVarInfo *,ucNbDsgVar*sizeof(tdstDsgVarInfo));
for (i=0;i<ucNbDsgVar;i++)
{
p_stDsgVarInfo[i].ulOffsetInDsgMem=0;
p_stDsgVarInfo[i].eDsgVarTypeId=eNbDsgVarType;
p_stDsgVarInfo[i].eSaveType=fn_eFindSaveTypeFromSaveTypeNumber(fn_ucDefaultSaveTypeNumber());
p_stDsgVarInfo[i].eInitType=fn_eFindInitTypeFromInitTypeNumber(fn_ucDefaultInitTypeNumber());
}
return(p_stDsgVarInfo);
}
tdstDsgVar *fn_p_stAllocDsgVar(unsigned long ulSize,unsigned char ucNbDsgVar)
{
tdstDsgVar *p_stDsgVar=NULL;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeDsgVar , NULL);
M_AIAlloc(p_stDsgVar,tdstDsgVar *,sizeof(tdstDsgVar));
p_stDsgVar->p_cDsgMemDefaultInit=fn_p_cAllocDsgMemBuffer(ulSize);
p_stDsgVar->p_stDsgVarInfo=fn_p_stAllocDsgVarInfo(ucNbDsgVar);
p_stDsgVar->ulSize=ulSize;
p_stDsgVar->ucNbDsgVar=ucNbDsgVar;
return(p_stDsgVar);
}
char *fn_p_cAllocDsgMemBuffer(unsigned long ulSize)
{
char *p_cDsgMemBuffer=NULL;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeDsgMemBuffer , NULL);
M_AIAlloc(p_cDsgMemBuffer,char *,ulSize*sizeof(char));
/* memset(p_cDsgMemBuffer,0,ulSize); AR9904 Already done in the alloc function */
return(p_cDsgMemBuffer);
}
tdstDsgMem *fn_p_stAllocDsgMem(tdstDsgVar **p_p_stDsgVar,unsigned long ulSize)
{
tdstDsgMem *p_stDsgMem=NULL;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeDsgMem , NULL);
M_AIAlloc(p_stDsgMem,tdstDsgMem*,sizeof(tdstDsgMem));
/* link DsgMem to its model : dont forget it*/
p_stDsgMem->p_p_stDsgVar=p_p_stDsgVar;
/* no specific values by default */
p_stDsgMem->p_cDsgMemBufferInit=NULL;
/* zone which stores current DsgVarValues : Set during 2nd pass*/
p_stDsgMem->p_cDsgMemBuffer=fn_p_cAllocDsgMemBuffer(ulSize);
return(p_stDsgMem);
}
void fn_vAllocVariableDesigner(AI_tdstMind *p_stMind,unsigned long ulSizeDsgMem,unsigned char ucNbDsgVar)
{
if ( (ulSizeDsgMem!=0) && (ucNbDsgVar!=0) )
{
/* note : instruction order is important*/
/* obliged to use these macros instead of those defined in dsgmem.h*/
/* because at this moment p_p_stDsgVar in tdstDsgMem (in tdstMind) is not allocated yet*/
AI_M_p_stGetDsgVar(p_stMind)=fn_p_stAllocDsgVar(ulSizeDsgMem,ucNbDsgVar);
AI_M_p_stGetDsgMem(p_stMind)=fn_p_stAllocDsgMem(&AI_M_p_stGetDsgVar(p_stMind),ulSizeDsgMem);
}
else
{
AI_M_p_stGetDsgVar(p_stMind)=NULL;
AI_M_p_stGetDsgMem(p_stMind)=NULL;
}
}
void fn_vCreateNodeString(tdstNodeInterpret *p_stNode, char *szString)
{
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeNodeString , NULL);
/* don't forget +1 because of the terminal zero*/
M_AIAlloc(M_szStringInterpret(p_stNode), char *, (strlen(szString)+1)*sizeof(char));
strcpy(M_szStringInterpret(p_stNode), szString);
M_SetTypeInterpret(p_stNode,E_ti_String);
}
void fn_vCreateNodeVector(struct tdstNodeInterpret_ *p_stNode)
{
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeNodeVector , NULL);
M_AIAlloc(M_p_stVectorInterpret(p_stNode), MTH3D_tdstVector *, sizeof(MTH3D_tdstVector));
MTH3D_M_vNullVector(M_p_stVectorInterpret(p_stNode));
M_SetTypeInterpret(p_stNode,E_ti_ConstantVector);
}

View File

@@ -0,0 +1,293 @@
/*********************************************************/
/* Module used to display Waypoints in the Game engine*/
/* */
/* Author : Marc Fascia - Annecy*/
/* Date : 02 / 03 / 1998*/
/**/
/*********************************************************/
#define _WP_D_WAYPOINT_FRIEND_
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AIUseCPA.h"
#include "AI_Mmg.h"
#include "AI_Erm.h"
#include "AI_Proto.h"
#include "WPEngDsp.h"
#include "WPWayPt.h"
#include "WP_Handl.h"
#include "WP_Func.h"
#ifndef U64
static GEO_tdstGeometricObject * p_stGeoModel;
static GEO_tdstGeometricObject * p_stGeoCurr;
#endif
#ifdef __cplusplus
extern "C"{
#endif
#if !defined(PRESS_DEMO)
extern void DisplayPolices (char * _szText , long _lX , long _lY);
#else
#define DisplayPolices(a,b,c)
#endif /* PRESS_DEMO */
extern void GLI_vEndOfGeometricLoad( void );
/*bart990209 : extern void GLI_vDownLoadTexture( void );*/
#ifndef U64
/*static*/ unsigned char ucIsInitDone = 0;
#endif
#ifdef __cplusplus
}
#endif
#if !defined(U64) && !defined(RETAIL)
/***********************************************************************************************/
/* Name : WP_InitGeoModel*/
/* Description : Loads the Geo Obj used to display the WP from .mod file */
/* Author : Marc FASCIA*/
/* Date : 04/03/98*/
/***********************************************************************************************/
GEO_tdstGeometricObject * WP_InitGeoModel()
{
GEO_tdstGeometricObject * p_stLoaded;
p_stLoaded = (GEO_tdstGeometricObject *) SCR_M_ul_RdL0_ExtractLongValue(
SCR_fnp_st_RdL0_AnalyseSection( "GameData\\World\\Graphics\\Objects\\Banks\\Waypoints\\wp.mod^Geometric:Box01", SCR_CDF_uw_Anl_ForceAnalyse ),
0 );
return p_stLoaded;
}
/* LOL #endif*/
/***********************************************************************************************/
/* Name : WP_SendWaypointsToViewport*/
/* Description : Displays the Geo Objs for WP*/
/* Author : Marc FASCIA*/
/* Date : 04/03/98*/
/* Optimized ? : No*/
/***********************************************************************************************/
void WP_SendWaypointsToViewport( GLD_tdstViewportAttributes * p_stViewport, unsigned long ulDrawMask )
{
WP_tdstWayPoint * p_stWaypt;
ACP_tdxIndex xNbVertices;
unsigned int uiPos;
SCR_tdst_Link_Value * pLinkValue = NULL;
SCR_tdst_Link_Table * pLinkTable;
char szText[ 255 ];
/*--- First time we are here ??? ---*/
if( !ucIsInitDone )
{
/*--- Loading Goe Objs from file ---*/
p_stGeoModel = WP_InitGeoModel();
p_stGeoCurr = WP_InitGeoModel();
GLI_vEndofGeometricLoad();
ucIsInitDone = 1;
}
/*--- gettink back the Waypoints linktable*/
pLinkTable = WP_fnp_WayPoint_GetLinkTable();
/*--- First element*/
uiPos = 0;
SCR_M_DyAr_GetNextElement( SCR_tdst_Link_Value, uiPos, pLinkValue, SCR_M_st_Link_GetDynamicArray(pLinkTable) )
while (pLinkValue)
{
/*--- Getting the Waypoint handle*/
p_stWaypt = (WP_tdstWayPoint *) SCR_M_ul_Link_GetValue( pLinkValue );
for( xNbVertices = 0 ; xNbVertices < p_stGeoCurr->xNbPoints ; xNbVertices++ )
{
/*--- Translates the current object at the waypoint position*/
MTH3D_M_vAddVector( &(p_stGeoCurr->d_stListOfPoints[ xNbVertices ]),
&(p_stGeoModel->d_stListOfPoints[ xNbVertices ]),
&(p_stWaypt->m_stVertex) );
}
/*--- Translates the center of BV of object*/
MTH3D_M_vAddVector( &p_stGeoCurr->xBoudingSphereCenter, &p_stGeoModel->xBoudingSphereCenter, &p_stWaypt->m_stVertex );
/*--- Sends the object to the Display Routines*/
GLI_xSendObjectToViewportWithLights( p_stViewport, p_stGeoCurr, ulDrawMask );
/*--- Next Linked Value*/
uiPos++;
SCR_M_DyAr_GetNextElement( SCR_tdst_Link_Value, uiPos, pLinkValue, SCR_M_st_Link_GetDynamicArray(pLinkTable) )
}
sprintf( szText, "[P] Display Waypoints" );
DisplayPolices( (char *)szText, 450, 450 );
}
/* LOL */
#endif /* U64 */
/*--------------------------------------------------------------
-------------------- OLD VERSION -----------------------------
--------------------------------------------------------------
#include "SPO\HieSpObj.h"
static HIE_tdstSuperObject * p_stWaypointsSPO;
static unsigned char s_ucWPDisplayNotInitialized = 1;
//*********************************************************************************************
// Name : WP_InitWaypointSPO
// Description : Creates the SPO that will contain all the GEO Objs for the WP
// Author : Marc FASCIA
// Date : 04/03/98
// Optimized ? : No
//*********************************************************************************************
HIE_tdstSuperObject * WP_InitSPO()
{
MTH3D_tdstMatrix stIdMatrix;
MTH3D_tdstVector stZeroVector;
POS_stCompletePosition stCompletePos;
HIE_tdstSuperObject * p_stSPO;
//--- Creates the SPO in memory
p_stSPO = HIE_fn_hCreateSuperObject();
//--- Inits the Position ---
MTH3D_M_vNullVector( &stZeroVector );
MTH3D_M_vSetIdentityMatrix( &stIdMatrix );
POS_fn_vSetTransformMatrix( &stCompletePos, &stIdMatrix.stCol_0, &stIdMatrix.stCol_1, &stIdMatrix.stCol_2 );
POS_fn_vSetRotationMatrix( &stCompletePos, &stIdMatrix.stCol_0, &stIdMatrix.stCol_1, &stIdMatrix.stCol_2 );
POS_fn_vSetTranslationVector( &stCompletePos, &stZeroVector );
HIE_fn_vSetSuperObjectMatrix( p_stSPO, &stCompletePos );
return p_stSPO;
}
//*********************************************************************************************
// Name : WP_InitWPModel
// Description : Loads the GEO Obj primitive displayed for each WP
// Author : Marc FASCIA
// Date : 04/03/98
// Optimized ? : No
//*********************************************************************************************
GEO_tdstGeometricObject * WP_InitWPModel()
{
GEO_tdstGeometricObject * p_stLoaded;
p_stLoaded = (GEO_tdstGeometricObject *) SCR_M_ul_RdL0_ExtractLongValue(
SCR_fnp_st_RdL0_AnalyseSection( "GameData\\World\\Levels\\morbide\\morbide.mod^Geometric:Box01", SCR_CDF_uw_Anl_ForceAnalyse ),
0 );
return p_stLoaded;
}
//*********************************************************************************************
// Name : WP_FillWaypointsSPO
// Description : Links the Geo Objs with the WP SPO
// Author : Marc FASCIA
// Date : 04/03/98
// Optimized ? : No
//*********************************************************************************************
void WP_FillWaypointSPO()
{
WP_tdstWayPoint * p_stWaypt;
ACP_tdxIndex xNbVertices;
unsigned int uiPos;
SCR_tdst_Link_Value * pLinkValue;
SCR_tdst_Link_Table * pLinkTable;
GEO_tdstGeometricObject * p_stCurrGeoObj;
static HIE_tdstSuperObject * p_stCurrSPO;
//--- gettink back the Waypoints linktable
pLinkTable = WP_fnp_WayPoint_GetLinkTable();
//--- First element
uiPos = 0;
SCR_M_DyAr_GetNextElement( SCR_tdst_Link_Value, uiPos, pLinkValue, SCR_M_st_Link_GetDynamicArray(pLinkTable) )
while (pLinkValue)
{
//--- Getting the Waypoint handle
p_stWaypt = (WP_tdstWayPoint *) SCR_M_ul_Link_GetValue( pLinkValue );
//--- Creates the Geo Obj and the SPO
p_stCurrGeoObj = WP_InitWPModel();
p_stCurrSPO = WP_InitSPO();
//--- Links it to its own SPO ---
HIE_fn_vSetSuperObjectObjectAndType( p_stWaypointsSPO, p_stCurrGeoObj, C_ucPhysical );
//--- Creates SPO hierarchy ---
HIE_fn_vSuperObjectAddTail( p_stWaypointsSPO, p_stCurrSPO );
for( xNbVertices = 0 ; xNbVertices < p_stCurrGeoObj->xNbPoints ; xNbVertices++ )
{
//--- Translates the Model object at the waypoint position
MTH3D_M_vAddVector( &(p_stCurrGeoObj->d_stListOfPoints[ xNbVertices ]),
&(p_stCurrGeoObj->d_stListOfPoints[ xNbVertices ]),
&(p_stWaypt->m_stVertex) );
}
//--- Sends the object to the Display Routines
// GLI_xSendObjectToViewportWithLights( p_stViewport, p_stCurrGeoObj, ulDrawMask );
//--- Next Linked Value
uiPos++;
SCR_M_DyAr_GetNextElement( SCR_tdst_Link_Value, uiPos, pLinkValue, SCR_M_st_Link_GetDynamicArray(pLinkTable) )
}
}
//*********************************************************************************************
// Name : WP_WPAttachInHierarchy
// Description : Adds the WP SPO in the SPO hierarchy
// Author : Marc FASCIA
// Date : 04/03/98
// Optimized ? : No
//*********************************************************************************************
void WP_WPAttachInHierarchy( HIE_tdstSuperObject * p_stRootSPO )
{
//--- We need to load the Model the first time
if( s_ucWPDisplayNotInitialized )
{
//--- Init of the Waypoints root spo ---
p_stWaypointsSPO = WP_InitSPO();
HIE_fn_vSetSuperObjectObjectAndType( p_stWaypointsSPO, NULL, C_ucNoAction );
WP_FillWaypointSPO();
//--- Now the hierarchy has been built ---
s_ucWPDisplayNotInitialized = 0;
}
//--- Linking this branch to the static tree ---
HIE_fn_vSuperObjectAddTail( p_stRootSPO, p_stWaypointsSPO );
}
//*********************************************************************************************
// Name : WP_WPIsolateFromHierarchy
// Description : Removes the WP SPO in the SPO hierarchy
// Author : Marc FASCIA
// Date : 04/03/98
// Optimized ? : No
//*********************************************************************************************
void WP_WPIsolateFromHierarchy()
{
//--- Cutting the Waypoint branch from the static tree ---
HIE_fn_vIsolate( p_stWaypointsSPO );
}
*/

View File

@@ -0,0 +1,957 @@
#include "AIUseCPA.h"
#include "Mth.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Mmg.h"
#include "AI_Erm.h"
/* in order to compile AI in C++ and link with GAM in C*/
#include "AI_Proto.h"
#define _WP_D_DEFINE_WAYPOINTS_
#include "WP_Handl.h"
/* in order to compile AI in C++ and link with GAM in C*/
#include "WP_Func.h"
#undef _WP_D_DEFINE_WAYPOINTS_
#define _WP_D_WAYPOINT_FRIEND_
#define WP_D_WAYPOINT_GLOBALS_
#include "WPWayPt.h"
#undef WP_D_WAYPOINT_GLOBALS_
#undef _WP_D_WAYPOINT_FRIEND_
#include "WPgraphe.h"
// FBF N64-format pour coords, et logfile dans x:\exe\geodump.log{
#ifdef U64CONVERTETLOG
#ifdef __cplusplus
extern "C"
{
#endif
extern float fScale;
extern FILE *dump;
#ifdef __cplusplus
}
#endif
#endif //U64CONVERTLOG
// } fin N64-format
/*
------------------------------------------------------------------------------------------
GLOBAL VARIABLES DECLARATION:
------------------------------------------------------------------------------------------
*/
#if defined(AI_USE_SCRIPT)
static SCR_tdst_Link_Table WP_gs_stWayPointLinkTable;
#endif /* AI_USE_SCRIPT */
#if defined(ACTIVE_EDITOR)
static unsigned long gs_Way_ulNbOfWarnings = 0;
static FILE *gs_fWpWarningsFile = NULL;
#endif
/*
------------------------------------------------------------------------------------------
FUNCTIONS AND MACROS-FUNCTIONS DECLARATION:
------------------------------------------------------------------------------------------
*/
#define WP_M_vWayPointMalloc(_Var,_Type,_Size) M_AIAlloc(_Var,_Type,_Size)
#define WP_M_vWayPointFree(_Var) M_AIFree(_Var)
#define WP_M_vWayPointMemset(_Var,_Char,_Size) M_AI_MemSet(_Var,_Char,_Size)
#define WP_M_vWayPointRealloc(_Var,_AdrSrc,_Type,_Size) M_AIRealloc(_Var,_AdrSrc,_Type,_Size)
#define WP_M_vWayPointAssert(_Expr,_Error) M_AI_DEBUG_ASSERT(_Expr,_Error)
#define WP_M_vWayPointFatalError(_Error) M_AIFatalError(_Error)
/* Bart:
#define WP_M_vWayPointWarningError(_Error) M_AIWarningError(_Error)
*/
/*ANNECY Bart 21/01/98 {*/
#define WP_M_vWayPointWarningError(_Error, _ucOpenInfoWindow) M_AIWarningError(_Error, _ucOpenInfoWindow)
/*ENDANNECY Bart }*/
#define WP_M_vWayPointIfErrorUpdateError(_Module,_NewError) M_AIIfErrorUpdateFatalError(_Module,_NewError)
WP_tdhWayPoint WP_fnh_WayPoint_Create(void)
{
WP_tdhWayPoint hNewWayPoint=NULL;
/* Allocate a new waypoint */
WP_M_vWayPointMalloc(hNewWayPoint,WP_tdhWayPoint,WP_M_uwWayPointSizeOf());
if(hNewWayPoint)
{
WP_M_vWayPointMemset(hNewWayPoint,0xa,WP_M_uwWayPointSizeOf());
/*WP_M_vWayPointSetUsedCount(hNewWayPoint,0);*/
WP_M_vWayPointSetSuperObject(hNewWayPoint,0);
return hNewWayPoint;
}
else
return WP_C_hWayPointInvalid;
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_Destroy
(WP_tdhWayPoint _hOldWayPoint)
{
WP_M_vWayPointAssert(_hOldWayPoint!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);
WP_M_vWayPointFree(_hOldWayPoint);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
void WP_fnv_WayPoint_AddRef
(WP_tdhWayPoint _hWayPoint)
{
_hWayPoint = _hWayPoint;
/* WP_M_vWayPointAssert(_hWayPoint!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);*/
/* WP_M_vWayPointSetUsedCount(_hWayPoint,(unsigned char) (WP_M_ucWayPointGetUsedCount(_hWayPoint)+1));*/
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_Release
(WP_tdhWayPoint _hWayPoint)
{
_hWayPoint = _hWayPoint;
/*WP_M_vWayPointAssert(_hWayPoint!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);*/
/*WP_M_vWayPointSetUsedCount(_hWayPoint,(unsigned char) (WP_M_ucWayPointGetUsedCount(_hWayPoint)-1));*/
/*if(!WP_M_ucWayPointGetUsedCount(_hWayPoint))*/
/*{*/
/* WP_fnv_WayPoint_Destroy(_hWayPoint);*/
/*}*/
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
WP_tdhWayPoint WP_fnh_WayPoint_Build
(
MTH3D_tdstVector*_pstVector,
MTH_tdxReal _xRadius,
HIE_tdxHandleToSuperObject _hSuperObject
)
{
WP_tdhWayPoint hNewWayPoint;
hNewWayPoint = WP_fnh_WayPoint_Create();
if(hNewWayPoint!=WP_C_hWayPointInvalid)
{
WP_M_vWayPointSetVertex(hNewWayPoint,_pstVector);
WP_M_vWayPointSetRadius(hNewWayPoint,_xRadius);
WP_M_vWayPointSetSuperObject(hNewWayPoint,_hSuperObject);
return hNewWayPoint;
}
else
return WP_C_hWayPointInvalid;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
WP_tdhWayPoint WP_fnh_WayPoint_Duplicate
(WP_tdhWayPoint _hWayPointSrc)
{
MTH3D_tdstVector stVertex;
WP_M_vWayPointAssert(_hWayPointSrc!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);
WP_M_vWayPointGetVertex(_hWayPointSrc,&stVertex);
return WP_fnh_WayPoint_Build
(
&stVertex,
WP_M_xWayPointGetRadius(_hWayPointSrc),
WP_M_hWayPointGetSuperObject(_hWayPointSrc)
);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_Copy
(
WP_tdhWayPoint _hWayPointDest,
WP_tdhWayPoint _hWayPointSrc
)
{
MTH3D_tdstVector stVertex;
WP_M_vWayPointAssert
(
(_hWayPointDest!=WP_C_hWayPointInvalid)
&&(_hWayPointSrc!=WP_C_hWayPointInvalid),
E_uwAIFatalInvalidParameter
);
WP_M_vWayPointGetVertex(_hWayPointSrc,&stVertex);
WP_M_vWayPointSetVertex(_hWayPointDest,&stVertex);
WP_M_vWayPointSetRadius
(
_hWayPointDest,
WP_M_xWayPointGetRadius(_hWayPointSrc)
);
WP_M_vWayPointSetSuperObject
(
_hWayPointDest,
WP_M_hWayPointGetSuperObject(_hWayPointDest)
);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned short WP_fnuw_WayPoint_SizeOf(void)
{
/*
Using the macro makes it compulsory to define the function
with the _WP_D_WAYPOINT_FRIEND_ compilation directive, in order to
be sure that the structure is known at this level.
*/
return WP_M_uwWayPointSizeOf();
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
void WP_fnv_WayPoint_GetVertex
(
WP_tdhWayPoint _hWayPoint,
MTH3D_tdstVector*_pstVector
)
{
WP_M_vWayPointAssert
(
(_hWayPoint!=WP_C_hWayPointInvalid)
&&(_pstVector),
E_uwAIFatalInvalidParameter
);
/*
Using the macro makes it compulsory to define the function
with the _WP_D_WAYPOINT_FRIEND_ compilation directive, in order to
be sure that the structure is known at this level.
*/
WP_M_vWayPointGetVertex(_hWayPoint,_pstVector);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_SetVertex
(
WP_tdhWayPoint _hWayPoint,
MTH3D_tdstVector*_pstNewVector
)
{
WP_M_vWayPointAssert
(
(_hWayPoint!=WP_C_hWayPointInvalid)
&&(_pstNewVector),
E_uwAIFatalInvalidParameter
);
/*
Using the macro makes it compulsory to define the function
with the _WP_D_WAYPOINT_FRIEND_ compilation directive, in order to
be sure that the structure is known at this level.
*/
WP_M_vWayPointSetVertex(_hWayPoint,_pstNewVector);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
MTH_tdxReal WP_fnx_WayPoint_GetRadius
(WP_tdhWayPoint _hWayPoint)
{
WP_M_vWayPointAssert(_hWayPoint!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);
/*
Using the macro makes it compulsory to define the function
with the _WP_D_WAYPOINT_FRIEND_ compilation directive, in order to
be sure that the structure is known at this level.
*/
return WP_M_xWayPointGetRadius(_hWayPoint);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_SetRadius
(
WP_tdhWayPoint _hWayPoint,
MTH_tdxReal _xNewRadius
)
{
WP_M_vWayPointAssert(_hWayPoint!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);
/*
Using the macro makes it compulsory to define the function
with the _WP_D_WAYPOINT_FRIEND_ compilation directive, in order to
be sure that the structure is known at this level.
*/
WP_M_vWayPointSetRadius(_hWayPoint,_xNewRadius);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
HIE_tdxHandleToSuperObject WP_fnh_WayPoint_GetSuperObject
(WP_tdhWayPoint _hWayPoint)
{
WP_M_vWayPointAssert(_hWayPoint!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);
/*
Using the macro makes it compulsory to define the function
with the _WP_D_WAYPOINT_FRIEND_ compilation directive, in order to
be sure that the structure is known at this level.
*/
return WP_M_hWayPointGetSuperObject(_hWayPoint);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_SetSuperObject
(
WP_tdhWayPoint _hWayPoint,
HIE_tdxHandleToSuperObject _hNewSuperObject
)
{
WP_M_vWayPointAssert(_hWayPoint!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);
/*
Using the macro makes it compulsory to define the function
with the _WP_D_WAYPOINT_FRIEND_ compilation directive, in order to
be sure that the structure is known at this level.
*/
WP_M_vWayPointSetSuperObject(_hWayPoint,_hNewSuperObject);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_Invalidate
(WP_tdhWayPoint*_p_hWayPoint)
{
WP_M_vWayPointAssert(_p_hWayPoint,E_uwAIFatalInvalidParameter);
*_p_hWayPoint = WP_C_hWayPointInvalid;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
ACP_tdxBool WP_fnb_WayPoint_IsValid
(WP_tdhWayPoint _hWayPoint)
{
return _hWayPoint != WP_C_hWayPointInvalid;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
ACP_tdxBool WP_fnb_WayPoint_IsInvalid
(WP_tdhWayPoint _hWayPoint)
{
return _hWayPoint == WP_C_hWayPointInvalid;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
ACP_tdxBool WP_fnb_WayPoint_IsDynamic
(WP_tdhWayPoint _hWayPoint)
{
WP_M_vWayPointAssert(_hWayPoint!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);
return WP_M_hWayPointGetSuperObject(_hWayPoint)!=(HIE_tdxHandleToSuperObject)0;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
ACP_tdxBool WP_fnb_WayPoint_IsStatic
(WP_tdhWayPoint _hWayPoint)
{
WP_M_vWayPointAssert(_hWayPoint!=WP_C_hWayPointInvalid,E_uwAIFatalInvalidParameter);
return WP_M_hWayPointGetSuperObject(_hWayPoint)==(HIE_tdxHandleToSuperObject)0;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#undef extern
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vCreateGeoWayPoint(WP_tdstWayPoint *p_stWayPt)
{
p_stWayPt = p_stWayPt;
/*MTH3D_tdstVector stPosWP;
WP_M_vWayPointGetVertex(p_stWayPt, &stPosWP);
p_stWayPt->m_p_stGeoObj = fn_pCreateSphere(MTH3D_M_xGetXofVector(&stPosWP),MTH3D_M_xGetYofVector(&stPosWP),
MTH3D_M_xGetZofVector(&stPosWP),WP_M_xWayPointGetRadius(p_stWayPt));
*/
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vDrawWayPoint(WP_tdstWayPoint *p_stWayPt)
{
p_stWayPt = p_stWayPt;
/*POS_tdstCompletePosition stMatrix;
POS_fn_vSetIdentityMatrix(&stMatrix);
HIE_fn_bLoadMatrix(&stMatrix);
GLI_xSendObjectToViewport(&gs_stViewportAttr, p_stWayPt->m_p_stGeoObj,
gp_stLight, GLI_C_lAllIsEnable-GLI_C_lIsNotDrawCollideInformation);
HIE_fn_vPopMatrix();*/
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#if defined(AI_USE_SCRIPT)
SCR_tde_Anl_ReturnValue WP_fne_WayPoint_ScriptCallBackLoad
(
SCR_tdst_File_Description *_p_fFile,
char *_szAction,
char *_szParams[],
SCR_tde_Anl_Action _cType
)
{
/* ANNECY MT - 16/09/98 {*/
static struct tdstEngineObject_ *hObjectParent;
static MTH3D_tdstVector stVertex;
static MTH_tdxReal xRadius;
_p_fFile=_p_fFile;
switch (_cType)
{
case SCR_EA_Anl_BeginSection:
MTH3D_M_vNullVector(&stVertex);
xRadius = MTH_C_ZERO;
hObjectParent = NULL;
break;
case SCR_EA_Anl_Entry:
if (stricmp(_szAction,"Vertex")==0)
{
/* load the vertex*/
stVertex.xX = MTH_M_xFloatToReal((float) atof(_szParams[0]));
stVertex.xY = MTH_M_xFloatToReal((float) atof(_szParams[1]));
stVertex.xZ = MTH_M_xFloatToReal((float) atof(_szParams[2]));
}
else if (stricmp(_szAction,"Radius")==0)
{
xRadius = MTH_M_xFloatToReal((float) atof(_szParams[0]));
}
else if (stricmp(_szAction,"Father")==0)
{
char szForScript[256];
SCR_tdst_Link_Value *p_stValue;
strcpy(szForScript,fn_szGetLevelsDataPath());
strcat(szForScript,"\\");
strcat(szForScript,_szParams[0]);
p_stValue = SCR_fnp_st_Link_CreateOrGetLinkFromKey(&g_st3DOSLinkTable.stCharacter, szForScript);
if(SCR_M_e_Link_GetState(p_stValue)==SCR_ELS_Link_Initialized)
{
hObjectParent = (struct tdstEngineObject_*)SCR_M_ul_Link_GetValue(p_stValue);
}
#ifndef U64
#ifdef _DEBUG
if(hObjectParent==NULL)
{
char szText[255];
/* Oliv' - Portage v15 - Please don't let accentuated characters be the last one of a string ! gcc sucks !!!*/
/* So I added a space character at the end*/
/* sprintf(szText,"Le WayPoint %s a pour p<>re l'acteur %s non charg<72>" , SCR_M_RdL0_GetCompleteSectionNameR(0), _szParams[0]);*/
sprintf(szText,"Le WayPoint %s a pour p<>re l'acteur %s non charg<72> " , SCR_M_RdL0_GetCompleteSectionNameR(0), _szParams[0]);
/* EndOfOliv' - Thnx :-)*/
MessageBox(NULL , szText , "ERROR" , MB_OK+MB_ICONERROR);
}
#endif /*_DEBUG*/
#endif /* U64*/
}
break;
case SCR_EA_Anl_EndSection:
{
WP_tdhWayPoint hWaypoint;
char szCompleteName [255];
char szWaypointName[255];
MTH3D_tdstVector stAbsolutePosition;
HIE_tdxHandleToSuperObject h_SOSector;
HIE_tdxHandleToSuperObject hSuperObjParent;
/* compute absolute position usinf father position if needed*/
if(hObjectParent)
{
POS_tdxHandleToPosition hGlobalMatrix;
hSuperObjParent = M_GetSuperObject(hObjectParent);
hGlobalMatrix = fn_p_st3dDataGetMatrix (hObjectParent->h_3dData);
POS_fn_vMulMatrixVertex( &stAbsolutePosition, hGlobalMatrix, &stVertex );
}
else
{
MTH3D_M_vCopyVector( &stAbsolutePosition, &stVertex );
hSuperObjParent = NULL;
}
if(fn_lGetSubMapNumber() != 0)
{
/* is waypoint into map ???*/
h_SOSector=SECT_fn_hResearchInWhatSectorIAm(SECT_hFatherSector,&stAbsolutePosition);
if (SECT_fn_bIsThisSectorUniverse(h_SOSector))
{
#if defined(ACTIVE_EDITOR)
char szText[255];
sprintf(szText,"The WayPoint %s is in the sector Universe" , SCR_M_RdL0_GetCompleteSectionNameR(0));
gs_Way_ulNbOfWarnings++;
if(gs_Way_ulNbOfWarnings==1)
{
MessageBox(NULL , szText , "ERROR" , MB_OK+MB_ICONERROR);
}
else
{
if(!gs_fWpWarningsFile)
{
gs_fWpWarningsFile = fopen ("WpWarnings.log","at");
if( gs_fWpWarningsFile )
{
fprintf( gs_fWpWarningsFile,"==============================================================================\n");
fprintf( gs_fWpWarningsFile,"Map : %s Submap : %02d\n" , fn_p_szGetLevelName() , GAM_M_GetSubMap(fn_lGetSubMapNumber()) );
fprintf( gs_fWpWarningsFile,"==============================================================================\n");
}
}
if(gs_fWpWarningsFile)
{
fprintf (gs_fWpWarningsFile , "%s\n" , szText);
}
}
#endif
return(SCR_ERV_Anl_NormalReturn);
}
}
/* create waypoint*/
hWaypoint = WP_fnh_WayPoint_Create();
WP_fnv_WayPoint_AddRef(hWaypoint);
SCR_M_RdL0_SetSectionLong(0, 0, (unsigned long)hWaypoint);
/* update Link Table*/
strcpy(szWaypointName,SCR_M_RdL0_GetCompleteSectionNameR(0));
strcpy(szCompleteName,fn_szGetLevelsDataPath());
strcat(szCompleteName,"\\");
strcat(szCompleteName,szWaypointName);
SCR_fnp_st_Link_SetValue( &WP_gs_stWayPointLinkTable, szCompleteName, (unsigned long)hWaypoint );
/* Set father*/
WP_M_vWayPointSetSuperObject(hWaypoint,hSuperObjParent);
/* Set radius*/
// FBF N64-format pour coords, et logfile dans x:\exe\geodump.log{
#ifdef U64CONVERTETLOG
xRadius = (float) (( (long)( (xRadius*fScale) + 0.5) ) / fScale);
stVertex.xX = (float) (( (long)( (stVertex.xX*fScale) + 0.5) ) / fScale);
stVertex.xY = (float) (( (long)( (stVertex.xY*fScale) + 0.5) ) / fScale);
stVertex.xZ = (float) (( (long)( (stVertex.xZ*fScale) + 0.5) ) / fScale);
fprintf(dump,"---------waypoint %s\nRadius: %f\nposition : %f,%f,%f\n",szWaypointName,xRadius,stVertex.xX,stVertex.xY,stVertex.xZ);
fflush(dump);
#endif //U64CONVERTLOG
// } fin N64-format
WP_M_vWayPointSetRadius(hWaypoint,xRadius);
/* Set position*/
WP_M_vWayPointSetVertex(hWaypoint, &stVertex);
fn_vCreateGeoWayPoint((WP_tdstWayPoint *)hWaypoint);
break;
}
case SCR_EA_Anl_AlreadyAnalysed:
{
WP_tdhWayPoint hWaypoint;
SCR_M_RdL0_GetSectionLong(0, 0, WP_tdhWayPoint, hWaypoint);
WP_fnv_WayPoint_AddRef(hWaypoint);
}
break;
}
return SCR_ERV_Anl_NormalReturn;
/* END ANNECY MT }*/
}
/*
----------------------------------------------------------------------------------------
Description : WP_fn_vReloadWPGraph
called by the command console to reinit one (or more) graph script
szNameOfGraph -> giving by the console, it's the name of the graph to reload
----------------------------------------------------------------------------------------
Author : Fred 'Bart' Compagnon
Date : 19/01/98
----------------------------------------------------------------------------------------
*/
/* script only*/
void WP_fn_vReloadWPGraph(char* szNameOfGraph)
{
char szLevelName[255];
char szWPSectionName[255];
char sz255Error[255];
/*WPG_fn_vDestroyAllGraph () ; // made in fn_vTreatCommandLine() cf. GAM\commands.c*/
strcpy(szLevelName, fn_p_szGetLevelName());
sprintf(szWPSectionName, "%s\\%s.%s^%s:%s", szLevelName, szLevelName, C_ScriptWayPointSuffixe, C_SectionWPGraphDescription, szNameOfGraph);
if (SCR_fn_c_RdL0_IsSectionExists(szWPSectionName))
{
SCR_fnp_st_RdL0_AnalyseSection(szWPSectionName, SCR_CDF_uw_Anl_ForceAnalyse);
}
else
{
sprintf(sz255Error, "unknown Name of WPGraph (%s) !", szNameOfGraph);
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
}
}
/*
----------------------------------------------------------------------------------------
Description : WP_fne_WPGraph_ScriptCallBackLoad
to read the WPGraph section in the script
----------------------------------------------------------------------------------------
Author : Fred 'Bart' Compagnon
Date : 19/01/98
----------------------------------------------------------------------------------------
*/
/* script only*/
SCR_tde_Anl_ReturnValue WP_fne_WPGraph_ScriptCallBackLoad(SCR_tdst_File_Description *_p_fFile, char *_szAction, char *_szParams[], SCR_tde_Anl_Action _cType)
{
SCR_tde_Anl_ReturnValue eReturnValue = SCR_ERV_Anl_NormalReturn;
WP_tdHandleOfGraph hGraph = NULL;
char sz255Error[255];
switch (_cType)
{
case SCR_EA_Anl_BeginSection:
if (_szAction[0] == 0)
{
sprintf(sz255Error, "invalid Name for WPGraph !");
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
return SCR_ERV_Anl_TerminateCurrentSection;
}
if (strlen(_szParams[0]) == 0)
{
sprintf(sz255Error, "invalid Reference for WPGraph (%s) !", _szAction);
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
return SCR_ERV_Anl_TerminateCurrentSection;
}
hGraph = WPG_fn_hCreate(_szAction, _szParams[0]);
WPG_fn_vAddGlobalGraph(hGraph) ;
SCR_M_RdL0_SetSectionLong(0, 0, (unsigned long)hGraph);
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetSectionLong(0, 0, WP_tdHandleOfGraph, hGraph);
break;
case SCR_EA_Anl_EndSection:
SCR_M_RdL0_GetSectionLong(0, 0, WP_tdHandleOfGraph, hGraph);
break;
case SCR_EA_Anl_AlreadyAnalysed:
SCR_M_RdL0_GetSectionLong(0, 0, WP_tdHandleOfGraph, hGraph);
break;
}
return eReturnValue;
}
/*
----------------------------------------------------------------------------------------
Description : GetWPFromName
_szName -> Name of the WayPoint
_hGraph -> handle to the graph
Returns (WP_tdhWayPoint ) handle to the WayPoint
----------------------------------------------------------------------------------------
Author : Fred 'Bart' Compagnon
Date : 19/01/98
----------------------------------------------------------------------------------------
*/
/* script only*/
WP_tdhWayPoint GetWPFromName(char* _szName, WP_tdHandleOfGraph _hGraph)
{
char szCompleteName[255];
WP_tdhWayPoint hWayPoint = NULL;
SCR_tdst_Link_Value *p_stLinkValue=NULL;
char sz255Error[255];
strcpy(szCompleteName, fn_szGetLevelsDataPath());
strcat(szCompleteName,"\\");
strcat(szCompleteName, _hGraph->m_szReferenceSection);
strcat(szCompleteName, _szName);
p_stLinkValue = SCR_fnp_st_Link_SearchKey(WP_fnp_WayPoint_GetLinkTable(), szCompleteName);
if ( (p_stLinkValue!=NULL) && (SCR_M_e_Link_GetState(p_stLinkValue)!=SCR_ELS_Link_NotInitialized) )
{
hWayPoint = (WP_tdhWayPoint)(p_stLinkValue->ulValue);
}
else
{
sprintf(sz255Error, "Invalid Link Table for WPGraphe : %s", szCompleteName);
if(fn_lGetSubMapNumber() == 0)
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
#if defined(ACTIVE_EDITOR)
if(gs_fWpWarningsFile != NULL)
fprintf (gs_fWpWarningsFile , "%s\n" , sz255Error);
#endif
}
return(hWayPoint);
}
/*
----------------------------------------------------------------------------------------
Description : WP_fne_WPSommet_ScriptCallBackLoad
to read the WPSommet section in the script
----------------------------------------------------------------------------------------
Author : Fred 'Bart' Compagnon
Date : 19/02/98
----------------------------------------------------------------------------------------
*/
/* script only*/
SCR_tde_Anl_ReturnValue WP_fne_WPSommet_ScriptCallBackLoad(SCR_tdst_File_Description *_p_fFile, char *_szAction, char *_szParams[], SCR_tde_Anl_Action _cType)
{
SCR_tde_Anl_ReturnValue eReturnValue = SCR_ERV_Anl_NormalReturn;
WP_tdHandleOfGraph hGraph;
WP_tdhWayPoint hWayPoint, hDstWayPoint;
unsigned long ulCapability;
long lWeight, lTypeOfWP;
char sz255Error[255];
char* dummy;
switch (_cType)
{
case SCR_EA_Anl_BeginSection:
SCR_M_RdL0_GetSectionLong(-1, 0, WP_tdHandleOfGraph, hGraph);
hWayPoint = GetWPFromName(_szAction, hGraph);
if (!hWayPoint)
{
sprintf(sz255Error, "unknown WayPoint (%s) in WPGraph !", _szAction);
#if defined(ACTIVE_EDITOR)
if(gs_fWpWarningsFile != NULL)
fprintf (gs_fWpWarningsFile , "%s\n" , sz255Error);
#endif
if(fn_lGetSubMapNumber() == 0)
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
return SCR_ERV_Anl_TerminateCurrentSection;
}
WPG_fn_lAddWayPointIfNotExists(hGraph, hWayPoint, 0L);/* first ignore the Type Of WP*/
if (_szParams[0])
{ /* then change the Type Of WP, if one ! !*/
lTypeOfWP = (long) strtoul(_szParams[0], &dummy, 2);
WPG_fn_lChangeTypeOfWP (hGraph, hWayPoint, lTypeOfWP); /*BART*/
}
SCR_M_RdL0_SetSectionLong(0, 0, (unsigned long)hWayPoint);
break;
case SCR_EA_Anl_Entry:
SCR_M_RdL0_GetSectionLong(-1, 0, WP_tdHandleOfGraph, hGraph);
SCR_M_RdL0_GetSectionLong(0, 0, WP_tdhWayPoint, hWayPoint);
hDstWayPoint = GetWPFromName(_szAction, hGraph);
if (!hDstWayPoint)
{
sprintf(sz255Error, "unknown WayPoint (%s) in WPGraph !", _szAction);
#if defined(ACTIVE_EDITOR)
if(gs_fWpWarningsFile != NULL)
fprintf (gs_fWpWarningsFile , "%s\n" , sz255Error);
#endif
if(fn_lGetSubMapNumber() == 0)
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
return SCR_ERV_Anl_TerminateCurrentSection;
}
WPG_fn_lAddWayPointIfNotExists(hGraph, hDstWayPoint, 0L); /* ignore the Type Of WP*/
lWeight = atoi(_szParams[0]);
ulCapability = strtoul(_szParams[1], &dummy, 2);
WPG_fn_lAddArcToWayPoint (hGraph, hWayPoint, hDstWayPoint, lWeight, ulCapability);
break;
case SCR_EA_Anl_EndSection:
SCR_M_RdL0_GetSectionLong(0, 0, WP_tdhWayPoint, hWayPoint);
break;
case SCR_EA_Anl_AlreadyAnalysed:
SCR_M_RdL0_GetSectionLong(0, 0, WP_tdhWayPoint, hWayPoint);
break;
}
return eReturnValue;
}
/* script only*/
SCR_tde_Anl_ReturnValue WP_fne_WayPoint_ScriptSubSectionCallBackLoad
(
SCR_tdst_File_Description*_p_fFile,
char*_szAction,
char*_d_szParams[],
SCR_tde_Anl_Action _eAction
)
{
_p_fFile=_p_fFile;
_szAction=_szAction;
_d_szParams=_d_szParams;
_eAction=_eAction;
/* test just to export the function*/
return SCR_ERV_Anl_NormalReturn;
}
/* script only*/
SCR_tdst_Link_Value* WP_fnh_WayPoint_GetLoaded
(
char *_szWPRefName
)
{
/* check parameter validity :*/
WP_M_vWayPointAssert(_szWPRefName,E_uwAIFatalInvalidParameter);
return SCR_fnp_st_Link_CreateOrGetLinkFromKey
(
&WP_gs_stWayPointLinkTable,
_szWPRefName
);
}
#endif /* AI_USE_SCRIPT */
void WP_fnv_WayPoint_ComputeLocation( WP_tdhWayPoint _hWayPoint, MTH3D_tdstVector*_p_stVertex)
{
MTH3D_tdstVector stWPVertex;
POS_tdxHandleToPosition hGlobalMatrix;
WP_M_vWayPointAssert ( (_hWayPoint!=WP_C_hWayPointInvalid) && (_p_stVertex), E_uwAIFatalInvalidParameter );
/* cas des Waypoints dynamiques, c'est a dire qui bougent (rare...) */
if (WP_M_hWayPointGetSuperObject(_hWayPoint))
{
WP_M_vWayPointGetVertex(_hWayPoint,&stWPVertex);
hGlobalMatrix = HIE_fn_hGetSuperObjectGlobalMatrix (WP_M_hWayPointGetSuperObject(_hWayPoint));
POS_fn_vMulMatrixVertex( _p_stVertex, HIE_fn_hGetSuperObjectGlobalMatrix (WP_M_hWayPointGetSuperObject(_hWayPoint)), &stWPVertex );
}
else
WP_M_vWayPointGetVertex(_hWayPoint,_p_stVertex);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_InitLinkTable(void)
{
#if defined(AI_USE_SCRIPT)
SCR_fn_v_Link_InitTable(&WP_gs_stWayPointLinkTable);
#endif /* AI_USE_SCRIPT */
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_CloseLinkTable(void)
{
#if defined(AI_USE_SCRIPT)
SCR_fn_v_Link_CloseTable(&WP_gs_stWayPointLinkTable);
#endif /* AI_USE_SCRIPT */
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#if defined(AI_USE_SCRIPT)
SCR_tdst_Link_Table* WP_fnp_WayPoint_GetLinkTable (void)
{
return &WP_gs_stWayPointLinkTable;
}
#endif /* AI_USE_SCRIPT */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_SecondPass(WP_tdhWayPoint _hWayPoint)
{
#if defined(AI_USE_SCRIPT)
if(WP_M_hWayPointGetSuperObject(_hWayPoint))
{
WP_M_vWayPointAssert
(
(SCR_M_e_Link_GetState((SCR_tdst_Link_Value *)
(WP_M_hWayPointGetSuperObject(_hWayPoint))) == SCR_ELS_Link_Initialized),
E_uwAIFatalReferenceNotLoaded
);
/* retrieve the father handle : */
WP_M_vWayPointSetSuperObject
(
_hWayPoint,
M_GetSuperObject(
(struct tdstEngineObject_*)
(SCR_M_ul_Link_GetValue((SCR_tdst_Link_Value *)
(WP_M_hWayPointGetSuperObject(_hWayPoint)))
)
)
);
}
#endif /* AI_USE_SCRIPT */
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#if defined(AI_USE_SCRIPT)
WP_tdhWayPoint WP_fnh_WayPoint_GetHandleFromLinkTable
(SCR_tdst_Link_Value*_p_stLinkValue)
{
WP_tdhWayPoint hWayPoint;
WP_M_vWayPointAssert
(
(SCR_M_e_Link_GetState(_p_stLinkValue) == SCR_ELS_Link_Initialized),
E_uwAIFatalReferenceNotLoaded
);
hWayPoint = (WP_tdhWayPoint)SCR_M_ul_Link_GetValue(_p_stLinkValue);
/* WP_fnv_WayPoint_SecondPass(hWayPoint); del by jt*/
return hWayPoint;
}
#endif /* AI_USE_SCRIPT */
/* add by jt*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WP_fnv_WayPoint_LinkTableSecondPass(void)
{
#if defined(ACTIVE_EDITOR)
if( (fn_lGetSubMapNumber() != 0) && gs_Way_ulNbOfWarnings > 1)
{
MessageBox(NULL , "Some Waypoints are in the Sector Universe.\n Please see the 'WpWarnings.log' file" , "ERROR" , MB_OK);
}
if(gs_fWpWarningsFile)
{
fprintf ( gs_fWpWarningsFile , "==============================================================================\n\n");
fclose (gs_fWpWarningsFile);
}
gs_fWpWarningsFile = NULL;
gs_Way_ulNbOfWarnings = 0;
#endif
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */

View File

@@ -0,0 +1,398 @@
/*
----------------------------------------
File Name :
AIUseCPA.h
----------------------------------------
Required for :
ACP basic definitions.
----------------------------------------
*/
#include "AIUseCPA.h"
/*
----------------------------------------
File Name :
AIMacros.h
----------------------------------------
Required for :
AI main macros definitions.
----------------------------------------
*/
#include "AIMacros.h"
/* in order to compile AI in C++ and link with GAM in C*/
#include "AI_Proto.h"
#define _WP_D_DEFINE_WAYPOINTS_
#include "WP_Handl.h"
/* in order to compile AI in C++ and link with GAM in C*/
#include "WP_Func.h"
#undef _WP_D_DEFINE_WAYPOINTS_
#define _WP_D_WPARC_FREIND_
#include "WParc.h"
#undef _WP_D_WPARC_FREIND_
#define _WP_D_WAYPOINT_FRIEND_
#define WP_D_WAYPOINT_GLOBALS_
#include "WPWayPt.h"
#undef WP_D_WAYPOINT_GLOBALS_
#undef _WP_D_WAYPOINT_FRIEND_
/*****************************************************
* Function : WPARCLST_fn_hInit
* Description : initialise a WParc list to an empty
* list. it also allocate memory for the
* list.
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
WP_tdHandleOfListOfArc WPARCLST_fn_hInit (void)
{
WP_tdHandleOfListOfArc hList ;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeListOfArc , NULL);
#ifdef U64
/* on U64, AI is a block without free, so alloc in TMP*/
hList = (WP_tdHandleOfListOfArc) TMP_M_p_Malloc(sizeof(WP_tdstListOfArc));
#else
M_AIAlloc(hList, WP_tdHandleOfListOfArc, sizeof(WP_tdstListOfArc)) ;
#endif
if ( hList )
LST2_M_DynamicInitAnchor(&hList->m_hArc) ;
return (hList) ;
}
/*****************************************************
* Function : WPARCLST_fn_vDestroy
* Description : free memory allocated for the list
* and destroy each element of the list
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
void WPARCLST_fn_vDestroy (WP_tdHandleOfListOfArc hList)
{
WP_tdHandleOfArc hElement, hNextElement ;
int i ;
if ( hList )
{
LST2_M_DynamicForEachMovingElementOf(&hList->m_hArc, hElement, hNextElement, i)
{
LST2_M_DynamicIsolate(hElement) ;
WPARC_fn_vDestroyArc (hElement) ;
}
#ifdef U64
/* on U64, AI block is replaced by TMP block, so free in TMP*/
TMP_M_Free(hList);
#else
M_AIFree(hList);
#endif
hList = NULL; /* BART ?*/
}
}
/*****************************************************
* Function : WPARCLST_fn_vAdd
* Description : add a new element at the end of the
* list.
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
void WPARCLST_fn_vAdd (WP_tdHandleOfListOfArc hListOfArc, WP_tdhGraphNode hNode,
long lWeight, unsigned long ulCapability)
{
WP_tdHandleOfArc hNewArc ;
char bOK=0;
int i;
WP_tdHandleOfArc hElement;
if ( hListOfArc )
{
LST2_M_DynamicForEachElementOf(&hListOfArc->m_hArc, hElement, i) /* if already exists !*/
{
if (hElement->m_hNode == hNode)
{
hElement->m_ulCapabilityInit = ulCapability;
hElement->m_ulCapability = ulCapability;
hElement->m_lWeightInit = lWeight;
hElement->m_lWeight = lWeight;
bOK = 1;
break;
}
}
if (bOK == 0)
{
hNewArc = WPARC_CreateArc (hNode, lWeight, ulCapability) ;
if ( hNewArc ) {
LST2_M_DynamicAddTail( &hListOfArc->m_hArc, hNewArc ) ;
}
}
}
}
/*****************************************************
* Function : WPARCLST_fn_vRemove
* Description : remove an element from the list
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void WPARCLST_fn_vRemove (WP_tdHandleOfListOfArc hList, WP_tdhGraphNode hNode ) {
WP_tdHandleOfArc hElement, hNextElement ;
int i ;
if ( hList ) {
LST2_M_DynamicForEachMovingElementOf(&hList->m_hArc, hElement, hNextElement, i) {
if ( hElement->m_hNode == hNode ) {
LST2_M_DynamicIsolate(hElement) ;
WPARC_fn_vDestroyArc (hElement) ;
break ;
}
}
}
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*****************************************************
* Function : WPARCLST_fn_lChangeCapabilities
* Description : change the Capability of an existing arc
* return -1 if the link doesn't exist
* return 0 if the Capability has been change
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
long WPARCLST_fn_lChangeCapabilities (WP_tdHandleOfListOfArc hListOfArc, WP_tdhGraphNode hNode, unsigned long ulCapability, long lValue) {
WP_tdHandleOfArc hElement ;
int i ;
if ( hListOfArc && hNode ) {
LST2_M_DynamicForEachElementOf(&hListOfArc->m_hArc, hElement, i) {
if ( hElement->m_hNode == hNode ) {
switch (lValue)
{
case 0:
case 2:
hElement->m_ulCapability |= ulCapability; /* add the type*/
break;
case 1:
case 3:
hElement->m_ulCapability = ulCapability; /* change all the types field*/
break;
case 4:
hElement->m_ulCapability &= ~ulCapability;; /* sub the type*/
break;
case 5:
hElement->m_ulCapability = 0; /* erase all the types field*/
break;
}
return (0) ;
}
}
}
return (-1) ;
}
/*****************************************************
* Function : WPARCLST_fn_lGetCapabilities
* Description : get the Capabilities of an existing arc
* return -1 if the link doesn't exist
* return 0 otherwise
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
long WPARCLST_fn_lGetCapabilities (WP_tdHandleOfListOfArc hListOfArc,
WP_tdhGraphNode hNode, unsigned long* p_ulCapability) {
WP_tdHandleOfArc hElement ;
int i ;
if ( hListOfArc && hNode ) {
LST2_M_DynamicForEachElementOf(&hListOfArc->m_hArc, hElement, i) {
if ( hElement->m_hNode == hNode ) {
*p_ulCapability = hElement->m_ulCapability ;
return (0) ;
}
}
}
return (-1) ;
}
long WPARCLST_fn_lChangeWeight (WP_tdHandleOfListOfArc hListOfArc, WP_tdhGraphNode hNode, long lWeight) {
WP_tdHandleOfArc hElement ;
int i ;
if ( hListOfArc && hNode ) {
LST2_M_DynamicForEachElementOf(&hListOfArc->m_hArc, hElement, i) {
if ( hElement->m_hNode == hNode ) {
hElement->m_lWeight = lWeight;
return (0) ;
}
}
}
return (-1) ;
}
long WPARCLST_fn_lGetWeight (WP_tdHandleOfListOfArc hListOfArc,
WP_tdhGraphNode hNode, long *p_lWeight) {
WP_tdHandleOfArc hElement ;
int i ;
if ( hListOfArc && hNode ) {
LST2_M_DynamicForEachElementOf(&hListOfArc->m_hArc, hElement, i) {
if ( hElement->m_hNode == hNode ) {
*p_lWeight = hElement->m_lWeight ;
return (0) ;
}
}
}
return (-1) ;
}
/*****************************************************
* Function : WPARC_CreateArc
* Description : allocate memory for an Element and
* set his value
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
WP_tdHandleOfArc WPARC_CreateArc (WP_tdhGraphNode hNode, long lWeight, unsigned long ulCapability)
{
WP_tdHandleOfArc hNewArc ;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeAI , MMG_C_lSubTypeArc , NULL);
#ifdef U64
/* on U64, AI is a block without free, so alloc in TMP*/
hNewArc = (WP_tdHandleOfArc) TMP_M_p_Malloc(sizeof(WP_tdstWayArc));
#else
M_AIAlloc ( hNewArc, WP_tdHandleOfArc, sizeof ( WP_tdstWayArc ) ) ;
#endif
if ( hNewArc )
{
LST2_M_DynamicInitElement(hNewArc) ;
hNewArc->m_hNode = hNode ;
hNewArc->m_ulCapabilityInit = ulCapability ;
hNewArc->m_ulCapability = ulCapability ;
hNewArc->m_lWeightInit = lWeight ;
hNewArc->m_lWeight = lWeight ;
}
return (hNewArc) ;
}
void WPARC_fn_vDestroyArc(WP_tdHandleOfArc hArc)
{
if ( hArc )
{
#ifdef U64
/* on U64, AI block is replaced by TMP block, so free in TMP*/
TMP_M_Free(hArc);
#else
M_AIFree(hArc) ;
#endif
hArc = NULL;
}
}
/*****************************************************
* Function : WPARC_fn_lSetWeight
* Description : access function, set the Weight
* field
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
long WPARC_fn_lSetWeight (WP_tdHandleOfArc hArc, long lWeight) {
if ( hArc ) {
hArc->m_lWeightInit = lWeight;
return ( !(hArc->m_lWeight = lWeight) ) ;
}
return (-1) ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*****************************************************
* Function : WPARC_fn_lGetWeight
* Description : access function, get the Weight
* field
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
long WPARC_fn_lGetWeight (WP_tdHandleOfArc hArc) {
if ( hArc )
return (hArc->m_lWeight) ;
return (-1) ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*****************************************************
* Function : WPARC_fn_lSetCapability
* Description : access function, set the Capability field
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
long WPARC_fn_lSetCapability (WP_tdHandleOfArc hArc, unsigned long ulCapability) {
if ( hArc ) {
hArc->m_ulCapabilityInit = ulCapability;
return ( !(hArc->m_ulCapability = ulCapability) ) ;
}
return (-1) ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* Function : WPARC_fn_lAddCapability
//return ( !(hArc->m_ulCapability |= ulCapability) ) ;
hArc->m_ulCapability |= ulCapability;
*/
/* Function : WPARC_fn_lSubCapability
//return ( !(hArc->m_ulCapability ^=ulCapability) ) ;
hArc->m_ulCapability -= (hArc->m_ulCapability & ulCapability);
*/
/*****************************************************
* Function : WPARC_fn_ulGetCapability
* Description : access function, get the Capability field
*****************************************************
* Author : Jean-Marc Drouaud
* Date : 13/01/98
*****************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned long WPARC_fn_ulGetCapability (WP_tdHandleOfArc hArc) {
if ( hArc )
return ( hArc->m_ulCapability ) ;
return ((unsigned long)0) ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,285 @@
/*BEGIN FS 10/8/98*/
#include "Ldt.h"
/*END FS 10/8/98*/
/*BEGIN FS 9/14/98*/
/*#if defined(AI_USE_SCRIPT)*/
/*----------------------------------------------------------------------
* Description: callback for WayPoint section from .WP script file
*----------------------------------------------------------------------
* Input:
* Output:
*----------------------------------------------------------------------
* Author: FS
* Creation date:9/14/98
* Modif date:
*----------------------------------------------------------------------*/
int LoadWP_WayPoint( LDT_tdst_Link *pLink )
{
LDT_tdeParseResult result=ParseResult_BeginSection;
char *szEntryName;
/* ANNECY MT - 16/09/98 {*/
WP_tdhWayPoint hWaypoint;
char szCompleteName [255];
/* char szWaypointName[255];*/
MTH3D_tdstVector stAbsolutePosition;
HIE_tdxHandleToSuperObject h_SOSector;
HIE_tdxHandleToSuperObject hSuperObjParent;
static struct tdstEngineObject_ *hObjectParent;
static MTH3D_tdstVector stVertex;
static MTH_tdxReal xRadius;
/*Working for BeginSection*/
MTH3D_M_vNullVector(&stVertex);
xRadius = MTH_C_ZERO;
hObjectParent = NULL;
/* Working for Entries*/
result=LDT_GetNextEntry();
while( result!=ParseResult_EndSection )
{
szEntryName=LDT_szGetEntryName();
switch (*(long*)(szEntryName))
{
case 'treV': /*"Vertex"*/
/* load the vertex*/
stVertex.xX = MTH_M_xFloatToReal((float) atof(LDT_szGetParam(1)));
stVertex.xY = MTH_M_xFloatToReal((float) atof(LDT_szGetParam(2)));
stVertex.xZ = MTH_M_xFloatToReal((float) atof(LDT_szGetParam(3)));
break;
case 'idaR': /*"Radius"*/
/* load the radius */
xRadius = MTH_M_xFloatToReal((float) atof(LDT_szGetParam(1)));
break;
case 'htaF': /*"Father"*/
char szForScript[256];
SCR_tdst_Link_Value *p_stValue;
strcpy(szForScript,fn_szGetLevelsDataPath());
strcat(szForScript,"\\");
strcat(szForScript,LDT_szGetParam(1));
p_stValue = SCR_fnp_st_Link_CreateOrGetLinkFromKey(&g_st3DOSLinkTable.stCharacter, szForScript);
if(SCR_M_e_Link_GetState(p_stValue)==SCR_ELS_Link_Initialized)
hObjectParent = (struct tdstEngineObject_*)SCR_M_ul_Link_GetValue(p_stValue);
if(hObjectParent==NULL)
{
#ifdef _DEBUG
char szText[255],szSectionName[255];
LDT_ComputeSectionName(pLink,szSectionName);
sprintf(szText,"Le WayPoint %s a pour p<>re l'acteur %s non charg<72>",szSectionName,LDT_szGetParam(1));
MessageBox(NULL , szText , "ERROR" , MB_OK+MB_ICONERROR);
#endif
}
break;
}/*endswitch*/
result=LDT_GetNextEntry();
}/*endwhile*/
/*Working for EndSection*/
/* compute absolute position usinf father position if needed*/
if(hObjectParent)
{
POS_tdxHandleToPosition hGlobalMatrix;
hSuperObjParent = M_GetSuperObject(hObjectParent);
hGlobalMatrix = fn_p_st3dDataGetMatrix (hObjectParent->h_3dData);
POS_fn_vMulMatrixVertex( &stAbsolutePosition, hGlobalMatrix, &stVertex );
}
else
{
MTH3D_M_vCopyVector( &stAbsolutePosition, &stVertex );
hSuperObjParent = NULL;
}
/* is waypoint into map ???*/
h_SOSector=SECT_fn_hResearchInWhatSectorIAm(SECT_hFatherSector,&stAbsolutePosition);
if (SECT_fn_bIsThisSectorUniverse(h_SOSector))
{
#ifdef _DEBUG
char szText[255],szSectionName[255];
LDT_ComputeSectionName(pLink,szSectionName);
sprintf(szText,"Le WayPoint %s est dans le secteur Univers",szSectionName);
MessageBox(NULL , szText , "ERROR" , MB_OK+MB_ICONERROR);
#else
return 0;
#endif
}
/* create waypoint*/
hWaypoint = WP_fnh_WayPoint_Create();
WP_fnv_WayPoint_AddRef(hWaypoint);
/*!!! CE VREA AICI (CORELAT CU AlreadyAnalysed)*/
/* SCR_M_RdL0_SetSectionLong(0, 0, (unsigned long)hWaypoint);*/
/* update Link Table*/
LDT_ComputeSectionName(pLink,szCompleteName);
/*strcpy(szWaypointName,szCompleteName);*/
/*strcpy(szCompleteName,fn_szGetLevelsDataPath());*/
/*strcat(szCompleteName,"\\");*/
/*strcat(szCompleteName,szWaypointName);*/
SCR_fnp_st_Link_SetValue( &WP_gs_stWayPointLinkTable, szCompleteName, (unsigned long)hWaypoint );
/* Set father*/
WP_M_vWayPointSetSuperObject(hWaypoint,hSuperObjParent);
/* Set radius*/
WP_M_vWayPointSetRadius(hWaypoint,xRadius);
/* Set position*/
WP_M_vWayPointSetVertex(hWaypoint, &stVertex);
fn_vCreateGeoWayPoint((WP_tdstWayPoint *)hWaypoint);
return 0;
}
/*#endif /* AI_USE_SCRIPT */
/*END FS 9/14/98*/
/*BEGIN FS 9/14/98*/
/*#if defined(AI_USE_SCRIPT)*/
/*----------------------------------------------------------------------
* Description: callback for WPGraph section from .WP sript file
*----------------------------------------------------------------------
* Input:
* Output:
*----------------------------------------------------------------------
* Author: FS
* Creation date:9/14/98
* Modif date:
*----------------------------------------------------------------------*/
int LoadWP_Graph( LDT_tdst_Link *pLink )
{
LDT_tdeParseResult result=ParseResult_BeginSection;
char *szSectionName;
WP_tdHandleOfGraph hGraph = NULL;
char sz255Error[255];
szSectionName=LDT_szGetSectionName();
if (strlen(szSectionName)==0)
{
sprintf(sz255Error, "invalid Name for WPGraph !");
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
while( LDT_GetNextEntry()!=ParseResult_EndSection );
return -1;
}
if (LDT_iGetNbParams()<1)
{
sprintf(sz255Error, "invalid Reference for WPGraph (%s) !", szSectionName);
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
while( LDT_GetNextEntry()!=ParseResult_EndSection );
return -1;
}
hGraph = WPG_fn_hCreate(szSectionName,LDT_szGetParam(1));
WPG_fn_vAddGlobalGraph(hGraph) ;
pLink->pObject=hGraph;
/* read the next line in script file*/
result=LDT_GetNextEntry();
while( result!=ParseResult_EndSection )
{
/* Load WpSommet SubSection of WpGraph section*/
LDT_LoadSection(NULL);
result=LDT_GetNextEntry();
}
return 0;
}
/*#endif /* AI_USE_SCRIPT */
/*END FS 9/14/98*/
/*BEGIN FS 9/14/98*/
/*#if defined(AI_USE_SCRIPT)*/
/*----------------------------------------------------------------------
* Description: callback for ... of ... sript file
*----------------------------------------------------------------------
* Input:
* Output:
*----------------------------------------------------------------------
* Author: FS
* Creation date:9/14/98
* Modif date:
*----------------------------------------------------------------------*/
int LoadWP_Sommet( LDT_tdst_Link *pLink )
{
LDT_tdeParseResult result=ParseResult_BeginSection;
char *szSectionName, *szEntryName, *szParam1=NULL;
WP_tdHandleOfGraph hGraph;
WP_tdhWayPoint hWayPoint, hDstWayPoint;
long lCapacity, lValuation, lTypeOfWP;
char sz255Error[255];
char* dummy;
/*Working for BeginSection*/
hGraph=(WP_tdHandleOfGraph)pLink->pParent->pObject;
szSectionName=LDT_szGetSectionName();
hWayPoint = GetWPFromName(szSectionName, hGraph);
if (!hWayPoint)
{
sprintf(sz255Error, "unknown WayPoint (%s) in WPGraph !", szSectionName);
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
while( LDT_GetNextEntry()!=ParseResult_EndSection );
return -1;
}
WPG_fn_lAddWayPointIfNotExists(hGraph, hWayPoint, 0L);/* first ignore the Type Of WP*/
if (LDT_iGetNbParams()>1)
{ /* then change the Type Of WP, if one ! !*/
lTypeOfWP = (long) strtoul(LDT_szGetParam(1), &dummy, 2);
WPG_fn_lChangeTypeOfWP (hGraph, hWayPoint, lTypeOfWP); /*BART*/
}
/*Working for Entries*/
result=LDT_GetNextEntry();
while( result!=ParseResult_EndSection )
{
szEntryName=LDT_szGetEntryName();
hDstWayPoint = GetWPFromName(szEntryName, hGraph);
if (!hDstWayPoint)
{
sprintf(sz255Error, "unknown WayPoint (%s) in WPGraph !", szEntryName);
M_AIWarningErrorAndAllowStopForDebug(E_uwAIWarningScriptError, C_ucErmOpenInfoWindow, sz255Error);
while( LDT_GetNextEntry()!=ParseResult_EndSection );
return -1;
}
WPG_fn_lAddWayPointIfNotExists(hGraph, hDstWayPoint, 0L); /* ignore the Type Of WP*/
lValuation = atoi(LDT_szGetParam(1));
lCapacity = (long) strtoul(LDT_szGetParam(2), &dummy, 2);
WPG_fn_lAddArcToWayPoint (hGraph, hWayPoint, hDstWayPoint, lValuation, lCapacity);
result=LDT_GetNextEntry();
}
return 0;
}
/*#endif /* AI_USE_SCRIPT */
/*END FS 9/14/98*/
/*BEGIN FS 9/14/98*/
/*----------------------------------------------------------------------
* Description: callback for Isolate and InWay sections from .WP sript file
*----------------------------------------------------------------------
* Input:
* Output:
*----------------------------------------------------------------------
* Author: FS
* Creation date:9/14/98
* Modif date:
*----------------------------------------------------------------------*/
/*#if defined(AI_USE_SCRIPT)*/
int LoadWP_Isolate_InWay( LDT_tdst_Link *pLink )
{
LDT_tdeParseResult result=ParseResult_BeginSection;
while((result=LDT_GetNextEntry())!=ParseResult_EndSection )
{
/* Load WayPoint SubSection of Isolate section*/
if(result == ParseResult_BeginSection)
LDT_LoadSection(NULL);
}
return 0;
}
/*#endif /* AI_USE_SCRIPT */
/*END FS 9/14/98*/

View File

@@ -0,0 +1,9 @@
/* Generated file. Do not modified.*/
#ifdef U64_IA_EN_C
#endif /* U64_IA_EN_C */
/*$*/
CFast_tdst_ArrayFunctions CFast_gast_ArrayFunctions[] =
{
CFast_M_MakeRef(NULL, NULL, 0, NULL),
CFast_M_MakeRef(NULL, NULL, 0, NULL)
};

View File

@@ -0,0 +1,102 @@
/*---------------------------------------------------------------------------*/
/* Action table functions and macros for intelligence engine*/
/* author : 22/12/96 Olivier Couvreur*/
/* modify : 07/11/96 Olivier Couvreur */
/* modify : 03/02/97 Olivier Couvreur Lint 0 warnings */
/* modify : 26/02/97 Olivier Couvreur added Schedule support + Lint 0 warnings*/
/* modify : 05/03/97 Olivier Couvreur added Schedule function + Lint 0 warnings*/
/* modify : 25/03/97 Olivier Couvreur added REVERSE_RULES support + optimizations (not yet activated)*/
/*---------------------------------------------------------------------------*/
#if !defined(__ACTTABLE_H__)
#define __ACTTABLE_H__
#define DEFAULT_ACTION_TABLE_NB_ENTRIES 3
#define MIN_ACTION_TABLE_NB_ENTRIES 2
#define MAX_ACTION_TABLE_NB_ENTRIES 5
#if defined(U64)
#include "AIUseCPA.h"
#include "StrIntel.h"
#endif
#include "ActParam.h"
typedef struct tdstActionTableEntry_
{
/* action parameter*/
struct tdstActionParam_ stActionParam;
/* action node pointer*/
struct tdstNodeInterpret_ *p_stNode;
/* 1 if entry is used*/
unsigned char bUsed;
/* rule number*/
unsigned char ucNumRule;
unsigned char bUseDefaultActionReturn;
unsigned char ucNewActionReturn;
} tdstActionTableEntry;
typedef struct tdstActionTable_
{
struct tdstActionTableEntry_ *p_stEntry;
/* nb possible actions*/
unsigned char ucNbEntries;
/* nb actions not immediate*/
unsigned char ucNbEntriesUsed;
/* for parameter acces : cf actparam.cpp*/
unsigned char ucCurrentEntry;
} tdstActionTable;
#define M_ActionTable(p_stInt) ((p_stInt)->p_stActionTable)
#define M_ActionTableCurrentEntry(p_stInt) (M_ActionTable(p_stInt)->ucCurrentEntry)
#define M_ActionTableNbEntriesUsed(p_stInt) (M_ActionTable(p_stInt)->ucNbEntriesUsed)
#define M_TableNbEntries(p_stTable) ((p_stTable)->ucNbEntries)
#define M_ActionTableNbEntries(p_stInt) (M_TableNbEntries(M_ActionTable(p_stInt)))
#define M_IsActionTableUsed(p_stInt) ((M_ActionTableNbEntriesUsed(p_stInt)!=0)?TRUE:FALSE)
#define M_TableEntry(p_stTable) ((p_stTable)->p_stEntry)
#define M_ActionTableEntry(p_stInt) (M_TableEntry(M_ActionTable(p_stInt)))
#define M_ActionTableEntryN(p_stInt, N) (M_TableEntry(M_ActionTable(p_stInt))[(N)])
#define M_ActionTableNumRule(p_stInt, N) (M_ActionTableEntryN(p_stInt, N).ucNumRule)
#define M_ActionTableNumNode(p_stInt, N) (M_ActionTableEntryN(p_stInt, N).p_stNode)
#define M_ActionTableUseFlag(p_stInt, N) (M_ActionTableEntryN(p_stInt, N).bUsed)
#define M_ActionTableParam(p_stInt, N) (M_ActionTableEntryN(p_stInt, N).stActionParam)
#define M_ActionTableUseActionReturn(p_stInt, N) (M_ActionTableEntryN(p_stInt, N).bUseDefaultActionReturn)
#define M_ActionTableNewActionReturn(p_stInt, N) (M_ActionTableEntryN(p_stInt, N).ucNewActionReturn)
unsigned char fn_ucIsRuleInActionTable(struct tdstIntelligence_ *p_stIntelligence,unsigned char ucNumRule);
unsigned char fn_ucIsRuleAndNodeInActionTable(struct tdstIntelligence_ *p_stIntelligence,unsigned char ucNumRule,struct tdstNodeInterpret_ *p_stNode);
unsigned char fn_ucFindPlaceInActionTable(struct tdstIntelligence_ *p_stIntelligence);
void fn_vUseCurrentActionTableEntry(struct tdstIntelligence_ *p_stIntelligence,unsigned char ucNRule,struct tdstNodeInterpret_ *p_stNode);
void fn_vUnuseCurrentActionTableEntry(struct tdstIntelligence_ *p_stIntelligence);
void fn_vUnuseAllRulesWhichHaveGreaterNumRule(struct tdstIntelligence_ *p_stIntelligence,unsigned char ucNumRule);
void fn_vUnuseAllRulesFromSchedule(struct tdstIntelligence_ *p_stIntelligence);
struct tdstNodeInterpret_ *fn_p_stGetScheduleFromActionTableAndClearIt(struct tdstIntelligence_ *p_stIntelligence);
struct tdstNodeInterpret_ *fn_p_stGetTableAction(struct tdstIntelligence_ *p_stIntelligence, unsigned char ucNEntry);
/**************************************/
#if !defined(CPA_EXPORT)
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif /*CPA_WANTS_IMPORT || CPA_WANTS_EXPORT*/
#endif /*CPA_EXPORT*/
/**************************************/
#undef extern
#define EXTERN_AI_DLL extern
/***********************************************************************/
EXTERN_AI_DLL CPA_EXPORT void fn_vInitActionTable(struct tdstIntelligence_ *p_stIntelligence);
/*******************************************************************************/
#undef EXTERN_AI_DLL
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff