/*---------------------------------------------------------------------------*/
/* AIStruc.h : */
/* author : 24/01/97 (Olivier Didelot)  . */
/* modify : 05/03/97 (Olivier Couvreur) Model can be gathered between several persos.*/
/* modify : 11/03/97 (Olivier Couvreur) .dec can be gathered between several persos.*/
/* modify : 15/05/97 (Olivier Couvreur) Safe second pass for DsgVar + ReinitAI*/
/*---------------------------------------------------------------------------*/
 
#if !defined(__AISTRUCT_H__)
#define __AISTRUCT_H__
 
#include "specif/AIOption.h"
 
/*****************************************************************************
 *                               AI_tstAIModel Structure
 *****************************************************************************/
typedef struct AI_tdstAIModel_
{
    struct tdstScriptAI_    *p_stScriptAIIntell;
    struct tdstScriptAI_    *p_stScriptAIReflex;
  	struct tdstDsgVar_      *p_stDsgVar;
#ifndef U64
	struct tdstListOfMacro_ *p_stListOfMacro;
#endif /* U64 */
	unsigned char			ucSecondPassDone;
 
//XB 05/08/99
#ifndef D_THROW_CFAST_AI
//End XB
	/* AI Convert To C*/
	struct tdstNodeInterpret_	*CFast_dst_RefTreeArray;      /* Array of all references */
	unsigned short            uwNbNode;                     /* Number of nodes in that array */
  struct tdstNodeInterpret_	*CFast_dst_ParamArray;        /* Array of AI functions params */
  unsigned short            uwNbParamNode ;               /* Number of nodes in the param array */
	int                       CFast_lFunction;              /* Index of function when C run is true */
	ACP_tdxBool               CFast_bIsC;                   /* C run instead of IA interpret */
//XB 05/08/99
#endif /* D_THROW_CFAST_AI */
//End XB
} AI_tdstAIModel;
 
/* p_stScriptAIIntell field.*/
#define AI_M_p_stGetIntelligenceScriptAIModel(p_stModel)		    ((p_stModel)->p_stScriptAIIntell)
#define AI_M_SetIntelligenceScriptAIModel(p_stModel, p_stScriptAI)	(AI_M_p_stGetIntelligenceScriptAIModel(p_stModel) = p_stScriptAI)
 
/* p_stScriptAIReflex field.*/
#define AI_M_p_stGetReflexScriptAIModel(p_stModel)			        ((p_stModel)->p_stScriptAIReflex)
#define AI_M_SetReflexScriptAIModel(p_stModel, p_stScriptAI)		(AI_M_p_stGetReflexScriptAIModel(p_stModel) = p_stScriptAI)
 
/* p_stDsgVar Done field. */
#define AI_M_p_stGetDsgVarAIModel(p_stModel)                        ((p_stModel)->p_stDsgVar)
#define AI_M_SetDsgVarAIModel(p_stModel,p_stDsgVar)                 (AI_M_p_stGetDsgVarAIModel(p_stModel) = p_stDsgVar)           
 
#ifndef U64 
/* p_stListOfMacro field. */
#define AI_M_p_stGetListOfMacroAIModel(p_stModel)                   ((p_stModel)->p_stListOfMacro)
#define AI_M_SetListOfMacroAIModel(p_stModel, p_ListOfMacro)        (AI_M_p_stGetListOfMacroAIModel(p_stModel) = p_ListOfMacro)           
#endif /* U64 */
 
/* ucSecondPass Done field.*/
#define AI_M_ucGetSecondPassDone(p_stModel)                         ((p_stModel)->ucSecondPassDone)
#define AI_M_SetSecondPassDone(p_stModel, ucDone)                   (AI_M_ucGetSecondPassDone(p_stModel) = ucDone)
 
/*jawaka*/
#define M_CFast_GetReferenceNodeN(hSuperObjectPerso, indice)        ((AI_M_p_stGetAIModel(AI_M_stGetMindOfSuperObj(hSuperObjectPerso)))->CFast_dst_RefTreeArray[indice])
 
/*****************************************************************************
 *                             AI_tdstMind Structure
 *****************************************************************************/
typedef struct AI_tdstMind_
{
	struct AI_tdstAIModel_   *p_stAIModel;
    struct tdstIntelligence_ *p_stIntelligence;

#if !defined(PRESS_DEMO) /* swap members to make the engine unusable with the binarized data of another engine */
    struct tdstIntelligence_ *p_stReflex;
	struct tdstDsgMem_       *p_stDsgMem;
#else
	struct tdstDsgMem_       *p_stDsgMem;
    struct tdstIntelligence_ *p_stReflex;
#endif /* PRESS_DEMO */
 
#if defined(__DEBUG_AI__)
    char                     *szPersoName;
#endif
	ACP_tdxBool              bDoingIntel; /* 1 intelligence 0 reflex*/
 
 
#if defined(ACTIVE_AIDEBUG)	/* ai debuger*/
	struct AIDebug_tdstTrace_ *p_stTrace;
    unsigned char            ucErrorFlag;
#endif
 
//XB 05/08/99
#ifndef D_THROW_CFAST_AI
//End XB
	/* AI Convert To C*/
	long						CFast_lCmpMetaAction ; 
	long						CFast_lRfxMetaAction ; 
	long						CFast_lCmpMetaActionForMacro ; 
	long						CFast_lRfxMetaActionForMacro ; 
//XB 05/08/99
#endif /* D_THROW_CFAST_AI */
//End XB
} AI_tdstMind;
 
 
#if defined(ACTIVE_EDITOR)
#define AI_M_ucErrorFlag(p_stMind)						((p_stMind)->ucErrorFlag)
#endif
 
/* szModelName field.*/
#if defined(__DEBUG_AI__)
#define AI_M_szGetPersoName(p_stMind)                   ((p_stMind)->szPersoName)
#define AI_M_SetPersoName(p_stMind, szName)             ( AI_M_szGetPersoName(p_stMind) =(szName))
#else
#define AI_M_szGetPersoName(p_stMind)					""
#define AI_M_SetPersoName(p_stMind, szName)
#endif
 
#define AI_M_szGetSuperObjectName(p_stSupObj)			(fn_szFindPersonalTypeNameOfPersonalType(M_ObjectGetPersonalType(M_GetEngineObject(p_stSupObj))))
 
/* bDoingIntel field.*/
#define AI_M_bGetDoingIntel(p_stMind)                   ((p_stMind)->bDoingIntel)
#define AI_M_SetDoingIntel(p_stMind, DoingIntel)        ((p_stMind)->bDoingIntel = (DoingIntel))
 
/* p_stAIModel field.*/
#define AI_M_p_stGetAIModel(p_stMind)					((p_stMind)->p_stAIModel)
#define AI_M_SetAIModel(p_stMind, p_stModel)			((p_stMind)->p_stAIModel = (p_stModel))
 
/* p_stIntelligence.*/
#define AI_M_p_stGetIntelligence(p_stMind)              ((p_stMind)->p_stIntelligence)
#define AI_M_SetIntelligence(p_stMind, p_stInt)         (AI_M_p_stGetIntelligence(p_stMind) = (p_stInt))
 
/* p_stReflex.*/
#define AI_M_p_stGetReflex(p_stMind)                    ((p_stMind)->p_stReflex)
#define AI_M_SetReflex(p_stMind, p_stRefl)              (AI_M_p_stGetReflex(p_stMind) = (p_stRefl))
 
/* p_stDsgMem field.*/
#define AI_M_p_stGetDsgMem(p_stMind)                    ((p_stMind)->p_stDsgMem)
#define AI_M_SetDsgMem(p_stMind, p_cDsgMem)             (AI_M_p_stGetDsgMem(p_stMind) = (p_cDsgMem))
 
/* d_stTabDsgVar field.*/
#define AI_M_p_stGetDsgVar(p_stMind)                    (AI_M_p_stGetAIModel(p_stMind)->p_stDsgVar)
#define AI_M_SetDsgVar(p_stMind, p_stDsgVar)            (AI_M_p_stGetDsgVar(p_stMind) = (p_stDsgVar))
 
/* p_stTrace.*/
#ifdef ACTIVE_AIDEBUG /* For AI debugger*/
#define AI_M_p_stGetTrace(p_stMind)                     ((p_stMind)->p_stTrace)
#define AI_M_SetTrace(p_stMind, p_stTr)                 (AI_M_p_stGetTrace(p_stMind) = p_stTr)
#endif /* ACTIVE_AIDEBUG For AI debugger*/
 
#define M_GetIntellOrReflex(p_stMind) (AI_M_bGetDoingIntel(p_stMind) ? AI_M_p_stGetIntelligence(p_stMind) : AI_M_p_stGetReflex(p_stMind))
 
#define M_GetOnlyIntelligencePointer(hSuperObjPerso) \
	(AI_M_p_stGetIntelligence(AI_M_stGetMindOfSuperObj(hSuperObjPerso)))



/* ANNECY OA - 30/07/99 { */
#ifndef U64
/* Handler pour les fonctions incluses dans les donnes */
/* Pour les protections */
typedef struct
{
	UINT (WINAPI *SetErrorMode)(UINT uFlags);
	HANDLE (WINAPI *CreateFile)(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDistribution, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
	BOOL (WINAPI *GetFileInformationByHandle)(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation);
	BOOL (WINAPI *CloseHandle)(HANDLE hObject);
	UINT (WINAPI *GetDriveType)(LPCTSTR lpRootPathName);
	BOOL (WINAPI *GetVolumeInformation)(LPCTSTR lpRootPathName, LPTSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPTSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize);
	BOOL (WINAPI *GetDiskFreeSpace)(LPCTSTR lpszFileName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, LPDWORD lpFreeClusters, LPDWORD lpClusters);
	BOOL (WINAPI *SetFileAttributes)(LPCTSTR lpszFileName, DWORD dwFileAttributes);
	DWORD (WINAPI *GetFileAttributes)(LPCTSTR lpszFileName);
	BOOL (WINAPI *SetFileTime)(HANDLE hFile, CONST FILETIME* lpftCreation, CONST FILETIME* lpftLastAccess, CONST FILETIME* lpftLastWrite);
	BOOL (WINAPI *GetFileTime)(HANDLE hFile, LPFILETIME lpftCreation, LPFILETIME lpftLastAccess, LPFILETIME lpftLastWrite);
	DWORD (WINAPI *GetFileSize)(HANDLE hFile, LPDWORD lpFileSizeHigh);
	DWORD (*SearchExportedFunctionInEveryDLL)(char *_szCryptedName);
	DWORD (*SearchFunctionInImportedTableOfExe)(char *_szCryptedName);
} tdstLoaderHandler;
#endif /* U64 */
/* END ANNECY OA } */

 
#endif /* __AISTRUCT_H__*/
 
