/*---------------------------------------------------------------------------*/
/* DsgMem.h : Definition of variables in the designer memory.*/
/* auteur : Pierrick CREPY*/
/* date   : 10/1996*/
/* modify : *  12/1996 O.C.*/
/* modify : 09/01/1997 O.C.*/
/* 970115 :	Perso management	(Fabien Morales)*/
/* 970120 :	AddList				(Fabien Morales) */
/* 970120 :	3DPoint are vector type				(Fabien Morales) */
/* 970212 :	Vector designer variable type				    (Fabien Morales) */
/* modify : Olivier Couvreur*/
/* date   : 18/02/1997  CPA_EXPORT + new functions for editor*/
/* modify : Olivier Couvreur : new dsgvar structures*/
/* modify : Olivier Couvreur 27/05/97 ZDD + ZDE*/
/*---------------------------------------------------------------------------*/
 
#ifndef D_DsgMem
#define D_DsgMem
 
/**************************************/
#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
 
/*******************************************************************************/
 
/*  include*/
/* **************/
 
/* defines*/
/* **********/
#define C_TypeOfComport			struct tdstComport_ *
#define C_SizeOfComport			(sizeof(C_TypeOfComport))
 
#define C_TypeOfAction			tdxHandleToState
#define C_SizeOfAction			(sizeof(C_TypeOfAction))
 
#define C_TypeOfText			FON_tdxHandleOfText
#define C_SizeOfText			(sizeof(C_TypeOfText))
 
#define C_TypeOfBoolean			char
#define C_SizeOfBoolean			(sizeof (C_TypeOfBoolean))
 
#define C_TypeOf_128To127		char
#define C_SizeOf_128To127		(sizeof (C_TypeOf_128To127))
 
#define C_TypeOf0To255			unsigned char
#define C_SizeOf0To255			(sizeof (C_TypeOf0To255))
 
#define C_TypeOf_32768To32767	short
#define C_SizeOf_32768To32767	(sizeof (C_TypeOf_32768To32767))
 
#define C_TypeOf0To65535		unsigned short
#define C_SizeOf0To65535		(sizeof (C_TypeOf0To65535))
 
#define C_TypeOfInteger			long
#define C_SizeOfInteger			(sizeof (C_TypeOfInteger))
 
#define C_TypeOfPositiveInteger	unsigned long
#define C_SizeOfPositiveInteger	(sizeof (C_TypeOfInteger))
 
#define C_TypeOfFloat			MTH_tdxReal 
#define C_SizeOfFloat			(sizeof (C_TypeOfFloat))
 
#define C_TypeOfWayPoint		WP_tdhWayPoint
#define C_SizeOfWayPoint		(sizeof (C_TypeOfWayPoint))
 
#define C_TypeOfPerso			HIE_tdxHandleToSuperObject
#define C_SizeOfPerso			(sizeof (C_TypeOfPerso))
 
/* ANNECY OA - 05/08/99 { */
#ifndef U64		
#define C_TypeOfSuperObject		HIE_tdxHandleToSuperObject
#define C_SizeOfSuperObject		(sizeof (C_TypeOfPerso))
#endif
/* END ANNECY OA } */
 
#define C_TypeOfPersoInList		HIE_tdxHandleToSuperObject 
#define C_SizeOfPersoInList		(sizeof (C_TypeOfPersoInList))
 
#define C_TypeOfList1			struct tdstList1_
#define C_SizeOfList1			(sizeof (C_TypeOfList1))
 
#define C_TypeOfVector			struct MTH3D_tdstVector_
#define C_SizeOfVector			(sizeof (C_TypeOfVector))
 
#define C_TypeOfGameMaterial	GMT_tdxHandleToGameMaterial
#define C_SizeOfGameMaterial	(sizeof(C_TypeOfGameMaterial))
 
#define C_TypeOfCaps		unsigned long
#define C_SizeOfCaps		(sizeof (C_TypeOfCaps))
 
#define C_TypeOfGraph		WP_tdHandleOfGraph
#define C_SizeOfGraph		(sizeof (C_TypeOfGraph))
 
/* Types & structures*/
/* *********************/
#include "..\AiBase\Specif\AiOption.h"
#include "GSParam.h"
#include "..\AiGame\EnumVar.h"
 
typedef struct tdstDsgVarInfo_ 
{
  unsigned long ulOffsetInDsgMem;
  tdeDsgVarTypeId eDsgVarTypeId;   
  SAI_tdeFlags    eSaveType;       /* for SAI*/
  tdeObjectTreeInit eInitType;     /* for OTI */
#if defined(ACTIVE_EDITOR)
  char szDsgVarName[256];
#endif
} tdstDsgVarInfo;
 
typedef struct tdstDsgVar_
{
  char *p_cDsgMemDefaultInit;       /* to store model init values*/
  tdstDsgVarInfo *p_stDsgVarInfo;   /* info about each variable designer*/
  unsigned long ulSize;             /* size of this zone*/
  unsigned char ucNbDsgVar;         /* number of variable designer*/
} tdstDsgVar;
 
typedef struct tdstDsgMem_
{
  tdstDsgVar **p_p_stDsgVar;
  char *p_cDsgMemBufferInit;        /* to store init values for each perso*/
  char *p_cDsgMemBuffer;            /* to store current values for each perso*/
} tdstDsgMem;
 
/* for DsgMemBuffer */
#define M_GetDsgMem(p_stMind)              (AI_M_p_stGetDsgMem(p_stMind))
#define M_GetDsgMemBuffer(p_stMind)        (AI_M_p_stGetDsgMem(p_stMind)->p_cDsgMemBuffer)
 
#define M_GetDsgVar(p_stMind)              (*(AI_M_p_stGetDsgMem(p_stMind)->p_p_stDsgVar))
#define M_GetDsgVarInfo(p_stMind,ucId)     (&(M_GetDsgVar(p_stMind)->p_stDsgVarInfo[ucId]))
#define M_GetDsgVarOffset(p_stMind,ucId)   (M_GetDsgVarInfo(p_stMind,ucId)->ulOffsetInDsgMem)
#define M_GetDsgVarAddr(p_stMind,ucId)     (M_GetDsgMemBuffer(p_stMind)+M_GetDsgVarOffset(p_stMind,ucId))
 
#define M_GetDsgVarType(p_stMind,ucId)     (M_GetDsgVarInfo(p_stMind,ucId)->eDsgVarTypeId)
#define M_GetDsgVarSaveType(p_stMind,ucId) (M_GetDsgVarInfo(p_stMind,ucId)->eSaveType)
#define M_GetDsgVarInitType(p_stMind,ucId) (M_GetDsgVarInfo(p_stMind,ucId)->eInitType)
 
#define M_GetDsgVarSize(p_stMind)              (AI_M_p_stGetDsgVar(p_stMind)->ulSize)
#define M_GetNbDsgVar(p_stMind)                (AI_M_p_stGetDsgVar(p_stMind)->ucNbDsgVar)
 
#define M_GetDsgMemDefaultInit(p_stMind)       (AI_M_p_stGetDsgVar(p_stMind)->p_cDsgMemDefaultInit)
#define M_GetDsgMemBufferInit(p_stMind)        (AI_M_p_stGetDsgMem(p_stMind)->p_cDsgMemBufferInit)
 
#define M_GetDsgVarAddrInit(p_stMind,ucId)     (M_GetDsgMemBufferInit(p_stMind)+M_GetDsgVarOffset(p_stMind,ucId))
#define M_GetDsgVarAddrDefault(p_stMind,ucId)  (M_GetDsgMemDefaultInit(p_stMind)+M_GetDsgVarOffset(p_stMind,ucId))
 
#if defined(ACTIVE_EDITOR)
#define M_GetDsgVarName(p_stMind,ucId)				(M_GetDsgVarInfo(p_stMind,ucId)->szDsgVarName)
#define M_SetDsgVarName(p_stMind,ucId,szName)	strcpy((M_GetDsgVarInfo(p_stMind,ucId)->szDsgVarName),szName);
#else
#define M_GetDsgVarName(p_stMind,ucId)				""
#define M_SetDsgVarName(p_stMind,ucId,szName)				
#endif /* ACTIVE_EDITOR*/
 
/* Function prototypes*/
/* *********************/
 
#if defined(AI_USE_SCRIPT)
/* to inittialize current DsgVar values (in perso)*/
EXTERN_AI_DLL CPA_EXPORT void fn_vInitDsgVar(struct AI_tdstMind_ *p_stMind,unsigned char ucDsgVarId, enum tdeDsgVarTypeId_ eDsgVarTypeId, char * szParams[]);
/* to inittialize init DsgVar values (in perso)*/
EXTERN_AI_DLL CPA_EXPORT void fn_vInitDsgVarInit(struct AI_tdstMind_ *p_stMind,unsigned char ucDsgVarId,enum tdeDsgVarTypeId_ eDsgVarTypeId, char * szParams[]);
/* to inittialize init DsgVar values of an array (in perso)*/
EXTERN_AI_DLL CPA_EXPORT void fn_vInitDsgVarArrayInit(struct AI_tdstMind_ *p_stMind,unsigned char ucDsgVarId,unsigned char ucIndex,enum tdeDsgVarTypeId_ eDsgVarTypeId, char * szParams[]);
/* to initialize init DsgVar values (in model)*/
EXTERN_AI_DLL CPA_EXPORT void fn_vInitDsgVarDefault(struct AI_tdstMind_ *p_stMind,unsigned char ucDsgVarId,enum tdeDsgVarTypeId_ eDsgVarTypeId, char * szParams[]);
#endif
 
EXTERN_AI_DLL CPA_EXPORT unsigned long fn_ulSizeOfDsgVar(enum tdeDsgVarTypeId_ eDsgVarTypeId, unsigned char ucNbElt);
 
#if defined(ACTIVE_EDITOR)
EXTERN_AI_DLL CPA_EXPORT unsigned char fn_ucGetDsgVarValue(void *pMyVarAddr,unsigned char ucIndex,tdeDsgVarTypeId eDsgVarTypeId,tdstGetSetParam *p_stGetSetParam);		  
EXTERN_AI_DLL CPA_EXPORT unsigned char fn_ucSetDsgVarValue(void *pMyVarAddr,unsigned char ucIndex,tdeDsgVarTypeId eDsgVarTypeId,tdstGetSetParam *p_stGetSetParam);
#endif
 
unsigned char fn_ucGetDsgVar(unsigned char ucId,unsigned char ucIndex,struct AI_tdstMind_ *p_stPerso,struct tdstGetSetParam_ *p_stGetSetParam);
#if defined(__DEBUG_AI__)
unsigned char fn_ucGetDsgVarInit(unsigned char ucId,unsigned char ucIndex,struct AI_tdstMind_ *p_stPerso,struct tdstGetSetParam_ *p_stGetSetParam);
#endif
unsigned char fn_ucSetDsgVar(unsigned char ucId,unsigned char ucIndex,struct AI_tdstMind_ *p_stPerso,struct tdstGetSetParam_ *p_stGetSetParam);
 
#include "List.h"
#include "Array.h"
 
/*******************************************************************************/
#undef EXTERN_AI_DLL
 
 
#endif /*D_DsgMem*/
