/*---------------------------------------------------------------------------*/
/* DsgMem.cpp : 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 :	List functions debugging + AddList				(Fabien Morales) */
/* 970204 : */
/* 970212 :	Vector designer variable type				    (Fabien Morales) */
/* modify : Olivier Couvreur*/
/* date   : 18/02/1997  CPA_EXPORT + new functions for editor*/
/* Modify : Alb*/
/* Date   : March 21,1997 Ways&Waypoints modificiations*/
/* modify : Olivier Couvreur 23/04/97 MMG + DIR*/
/* modify : Olivier Couvreur 24/04/97 Clean InitDsgVar for Xavier*/
/* modify : Olivier Couvreur 25/04/97 Initialisation DsgVar perso and Vector for .dec et .iai*/
/* modify : Olivier Couvreur 15/05/97 Support for special dsgVar init values for each perso*/
/* modify : Olivier Couvreur 27/05/1997  ZDD + ZDE stuff*/
/*---------------------------------------------------------------------------*/
#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"
 
#include "SAFE.h"
 
#if defined(AI_USE_SCRIPT)
 
void fn_vInitDsgVarValue(void *p_MyVarAddr,tdeDsgVarTypeId eDsgVarTypeId,char * szParams[])
{
	switch (eDsgVarTypeId)
	{
/*ANNECY Bart 05/02/98 {*/
	case eDsgVarType_Caps:
		*((C_TypeOfCaps *)p_MyVarAddr) = (C_TypeOfCaps) 0;
		if (szParams[2]!=NULL)
		{
			/* si pas "CapaNull" ni '0'*/
			if ( (stricmp(szParams[2], "CapaNull"/*szFindKeyWordScriptNameFromId(eKeyWord_CapsNull)*/)) && (stricmp(szParams[2], "0") ) )
			{
				char* dummy;
				*((C_TypeOfCaps *)p_MyVarAddr) = (C_TypeOfCaps) strtoul(szParams[2], &dummy, 2);
			}
		}
		break;
		
	case eDsgVarType_Graph:	
		*((C_TypeOfGraph *)p_MyVarAddr) = (C_TypeOfGraph) NULL;
		/* si pas "NoGraph" ni '0'*/
		if (szParams[2]!=NULL)
		{
			if ( (stricmp(szParams[2], "NoGraph"/*szFindKeyWordScriptNameFromId(eKeyWord_NoGraph)*/)) && (stricmp(szParams[2], "0") ) )
			{
/* ANNECY MT - 16/09/98 {*/
				char szForScript[256];				
				sprintf(szForScript, "%s\\%s\\%s.%s^%s:%s", fn_szGetLevelsDataPath(), fn_p_szGetLevelName(), fn_p_szGetLevelName(), C_ScriptWayPointSuffixe, C_SectionWPGraphDescription, szParams[2]);
				*((C_TypeOfGraph *)p_MyVarAddr) = (C_TypeOfGraph) SCR_fnp_st_Link_CreateOrGetLinkFromKey(WPG_fnp_Graph_GetLinkTable(),szForScript);
/* END ANNECY MT }*/
			}
		}
		break;
/*ENDANNECY Bart }*/
	case eDsgVarType_Boolean:	
		*((C_TypeOfBoolean *)p_MyVarAddr) = (C_TypeOfBoolean) atoi(szParams[2]);
		break;
	case eDsgVarType__128To127:	
		*((C_TypeOf_128To127 *)p_MyVarAddr) = (C_TypeOf_128To127) atoi(szParams[2]);
		break;
	case eDsgVarType_0To255:	
		*((C_TypeOf0To255 *)p_MyVarAddr) = (C_TypeOf0To255) atoi(szParams[2]);
		break;
	case eDsgVarType__32768To32767:	
		*((C_TypeOf_32768To32767 *)p_MyVarAddr) = (C_TypeOf_32768To32767) atoi(szParams[2]);
		break;
	case eDsgVarType_0To65535:								   
		*((C_TypeOf0To65535 *)p_MyVarAddr) = (C_TypeOf0To65535) atoi(szParams[2]);
		break;
	case eDsgVarType_Integer:								   
		*((C_TypeOfInteger *)p_MyVarAddr) = (C_TypeOfInteger) atoi(szParams[2]);
		break;
	case eDsgVarType_PositiveInteger:								   
		*((C_TypeOfPositiveInteger *)p_MyVarAddr) = (C_TypeOfPositiveInteger) atoi(szParams[2]);
		break;
	case eDsgVarType_Float:								   
		*((C_TypeOfFloat *)p_MyVarAddr) = MTH_M_xFloatToReal((float) atof(szParams[2])); 
		break;
	case eDsgVarType_WayPoint:								   
		*((C_TypeOfWayPoint *)p_MyVarAddr) = (C_TypeOfWayPoint) WP_C_hWayPointInvalid;
		if (szParams[2]!=NULL)
		{
			/* si pas "nowhere" ni '0' "*/
			if ( (stricmp(szParams[2], "Nowhere")) && (stricmp(szParams[2], "0") ) )
			{
				char szForScript[256];
				
				strcpy(szForScript,fn_szGetLevelsDataPath());
				strcat(szForScript,"\\");
				strcat(szForScript,szParams[2]);
/* ANNECY MT - 16/09/98 {*/
				*((C_TypeOfWayPoint *)p_MyVarAddr) = (C_TypeOfWayPoint) SCR_fnp_st_Link_CreateOrGetLinkFromKey(WP_fnp_WayPoint_GetLinkTable(),szForScript);
/* END ANNECY MT }*/
			}
		}
		break;
	case eDsgVarType_Action :
		*((C_TypeOfAction *)p_MyVarAddr) = (C_TypeOfAction) NULL;
		
		if (szParams[2]!=NULL)
		{
			/* si pas "nocomport" ni '0' "*/
			if ( (stricmp(szParams[2], "NoAction")) && (stricmp(szParams[2], "0") ) )
			{
				char szForScript[256];
				strcpy(szForScript,fn_szGetFamiliesDataPath());
				strcat(szForScript,"\\");
				strcat(szForScript,szParams[2]);
				
				*((C_TypeOfAction *)p_MyVarAddr) = (C_TypeOfAction) SCR_fnp_st_Link_CreateOrGetLinkFromKey(&g_st3DOSLinkTable.stState, szForScript);
			}
		}
		break;
		
	case eDsgVarType_Comport :
		*((C_TypeOfComport *)p_MyVarAddr) = (C_TypeOfComport) NULL;
		
		if (szParams[2]!=NULL)
		{
			/* si pas "nocomport" ni '0' "*/
			if ( (stricmp(szParams[2], "NoComport")) && (stricmp(szParams[2], "0") ) )
			{
				char szForScript[256];
				SCR_tdst_Link_Value *p_stLinkValue;
				
				strcpy(szForScript,fn_szGetFamiliesDataPath());
				strcat(szForScript,"\\");
				
				/* Reference Compatibility : 2,3,4 <-> 2^3:4*/
				if (szParams[3]!=NULL)
				{	
					SCR_fn_v_RdL0_ComputeSectionName(&szForScript[strlen(szForScript)], szParams[2], szParams[3], szParams[4]);
				}
				else
				{
					strcat(szForScript,szParams[2]);
				}
				p_stLinkValue = SCR_fnp_st_Link_CreateOrGetLinkFromKey(&g_stComportLinkTable, szForScript);
				SCR_M_v_Link_SetAdditionalLong(p_stLinkValue, 4, 0);
				*((C_TypeOfComport *)p_MyVarAddr) = (C_TypeOfComport)p_stLinkValue;
			}
		}
		break;
		
	case eDsgVarType_Perso:								   
		*((C_TypeOfPerso *)p_MyVarAddr) = (C_TypeOfPerso) NULL;
		
		if (szParams[2]!=NULL)
		{
			/* si pas "nobody" ni '0' "*/
			if ( (stricmp(szParams[2], "Nobody")) && (stricmp(szParams[2], "0") ) )
			{
				char szForScript[256];
				strcpy(szForScript,fn_szGetCharactersDataPath());
				strcat(szForScript,"\\");
				
				/* Reference Compatibility : 2,3,4 <-> 2^3:4*/
				if (szParams[3]!=NULL)
				{	
					SCR_fn_v_RdL0_ComputeSectionName(&szForScript[strlen(szForScript)], szParams[2], szParams[3], szParams[4]);
				}
				else
				{
					strcat(szForScript,szParams[2]);
				} 
				
				*((C_TypeOfPerso *)p_MyVarAddr) = (C_TypeOfPerso) SCR_fnp_st_Link_CreateOrGetLinkFromKey(&g_st3DOSLinkTable.stCharacter, szForScript);
			}
		}
		break;

/* ANNECY OA - 13/08/99 { */
#ifndef U64		
	case eDsgVarType_SuperObject:								   
		*((C_TypeOfSuperObject *)p_MyVarAddr) = (C_TypeOfSuperObject) NULL;
		
		if (szParams[2]!=NULL)
		{
			/* si pas "nobody" ni '0' "*/
			if ( (stricmp(szParams[2], "NoSuperObject")) && (stricmp(szParams[2], "0") ) )
			{
				char szForScript[256];
				strcpy(szForScript,fn_szGetCharactersDataPath());
				strcat(szForScript,"\\");
				
				/* Reference Compatibility : 2,3,4 <-> 2^3:4*/
				if (szParams[3]!=NULL)
				{	
					SCR_fn_v_RdL0_ComputeSectionName(&szForScript[strlen(szForScript)], szParams[2], szParams[3], szParams[4]);
				}
				else
				{
					strcat(szForScript,szParams[2]);
				} 
				
				*((C_TypeOfSuperObject *)p_MyVarAddr) = (C_TypeOfSuperObject) SCR_fnp_st_Link_CreateOrGetLinkFromKey(HIE_fn_p_stGetSuperObjectLinkTable(), szForScript);
			}
		}
		break;
#endif
/* END ANNECY OA } */
		
	case eDsgVarType_GameMaterial:
		*((C_TypeOfGameMaterial *)p_MyVarAddr) = (C_TypeOfGameMaterial) NULL;
		if (szParams[2]!=NULL)
		{
			/* si pas "nomaterial" ni '0' "*/
			if ( (stricmp(szParams[2], "NoMaterial")) && (stricmp(szParams[2], "0") ) )
			{
				char szForScript[256];
				strcpy(szForScript,fn_szGetGameMaterialDataPath());
				strcat(szForScript,"\\");
				strcat(szForScript,szParams[2]);
				*((C_TypeOfGameMaterial *)p_MyVarAddr) = (C_TypeOfGameMaterial) SCR_fnp_st_Link_CreateOrGetLinkFromKey(GMT_fn_p_stGetLinkTable(), szForScript);
			}
		}
		break;
		
	case eDsgVarType_List:
		{
			unsigned char ucNbEltMax;
			ucNbEltMax = (unsigned char) atoi(szParams[2]);
			M_InitList((tdstList *)p_MyVarAddr, ucNbEltMax);
		}
		break;
		
	case eDsgVarType_PersoArray:
		fn_vInitArray((tdstArray *)p_MyVarAddr,eDsgVarType_Perso,(unsigned char) atoi(szParams[2]),szParams);
		break;
	case eDsgVarType_VectorArray:
		fn_vInitArray((tdstArray *)p_MyVarAddr,eDsgVarType_Vector,(unsigned char) atoi(szParams[2]),szParams);
		break;
	case eDsgVarType_FloatArray:
		fn_vInitArray((tdstArray *)p_MyVarAddr,eDsgVarType_Float,(unsigned char) atoi(szParams[2]),szParams);
		break;
	case eDsgVarType_IntegerArray:
		fn_vInitArray((tdstArray *)p_MyVarAddr,eDsgVarType_Integer,(unsigned char) atoi(szParams[2]),szParams);
		break;
	case eDsgVarType_WayPointArray:
		fn_vInitArray((tdstArray *)p_MyVarAddr,eDsgVarType_WayPoint,(unsigned char) atoi(szParams[2]),szParams);
		break;
	case eDsgVarType_TextArray:
		fn_vInitArray((tdstArray *)p_MyVarAddr,eDsgVarType_Text,(unsigned char) atoi(szParams[2]),szParams);
		break;
	case eDsgVarType_Text:
		*((C_TypeOfText *)p_MyVarAddr) = FON_fn_hGetTextHandle(szParams[2]);
		break;
	case eDsgVarType_Vector:
		{
			MTH3D_tdstVector *p_stVector=(C_TypeOfVector *)p_MyVarAddr;
			MTH_tdxReal xTemp;
			
			/* init x*/
			xTemp=MTH_C_ZERO; 
			if (szParams[2]!=NULL)
			{
				xTemp=MTH_M_xFloatToReal((float) atof(szParams[2]));
			}
			MTH3D_M_vSetXofVector(p_stVector,xTemp);
			
			/* init y*/
			xTemp=MTH_C_ZERO; 
			if (szParams[3]!=NULL)
			{
				xTemp=MTH_M_xFloatToReal((float) atof(szParams[3]));
			}
			MTH3D_M_vSetYofVector(p_stVector,xTemp);
			
			/* init z*/
			xTemp=MTH_C_ZERO; 
			if (szParams[4]!=NULL)
			{
				xTemp=MTH_M_xFloatToReal((float) atof(szParams[4]));
			}
			MTH3D_M_vSetZofVector(p_stVector,xTemp);
		} 
		break;
#if defined(__DEBUG_AI__)
	default:
		M_AIFatalError (E_uwAIFatalWrongTypeVar);
		break;
#endif
	}
}
 
/* in perso : current value*/
void fn_vInitDsgVar(AI_tdstMind *p_stMind,unsigned char ucDsgVarId,tdeDsgVarTypeId eDsgVarTypeId, char * szParams[])
{
  fn_vInitDsgVarValue((void*) M_GetDsgVarAddr(p_stMind,ucDsgVarId),eDsgVarTypeId,szParams);
}
 
/* in perso : special init value*/
void fn_vInitDsgVarInit(AI_tdstMind *p_stMind,unsigned char ucDsgVarId,tdeDsgVarTypeId eDsgVarTypeId, char * szParams[])
{
  fn_vInitDsgVarValue((void*) M_GetDsgVarAddrInit(p_stMind,ucDsgVarId),eDsgVarTypeId,szParams);
}
 
/* in perso : special init value for array*/
void fn_vInitDsgVarArrayInit(AI_tdstMind *p_stMind,unsigned char ucDsgVarId,unsigned char ucIndex, tdeDsgVarTypeId eDsgVarTypeId, char * szParams[])
{
  /* check the element*/
  tdstArray *p_stArray =(tdstArray*) M_GetDsgVarAddrInit(p_stMind,ucDsgVarId);
  char *p_MyVarAddr=(char*) M_ARRAY_ELEMENT(p_stArray,ucIndex);
  fn_vInitDsgVarValue(p_MyVarAddr,eDsgVarTypeId,szParams);
}
 
/* in model : init value*/
void fn_vInitDsgVarDefault(AI_tdstMind *p_stMind,unsigned char ucDsgVarId,tdeDsgVarTypeId eDsgVarTypeId, char * szParams[])
{
   M_GetDsgVarType(p_stMind,ucDsgVarId)=eDsgVarTypeId;
   fn_vInitDsgVarValue((void*) M_GetDsgVarAddrDefault(p_stMind,ucDsgVarId),eDsgVarTypeId,szParams);
}
#endif 
 
unsigned long fn_ulSizeOfDsgVar(tdeDsgVarTypeId eDsgVarTypeId, unsigned char ucNbElt)
{
    switch (eDsgVarTypeId)
	{
/*ANNECY Bart 05/02/98 {*/
    case eDsgVarType_Caps:
        return ( C_SizeOfCaps);
    case eDsgVarType_Graph:
        return ( C_SizeOfGraph);
/*ENDANNECY Bart }*/
    case eDsgVarType_Boolean:
        return ( C_SizeOfBoolean);
    case eDsgVarType__128To127:
        return (C_SizeOf_128To127);
    case eDsgVarType_0To255:
        return (C_SizeOf0To255);
    case eDsgVarType__32768To32767:
        return (C_SizeOf_32768To32767);
    case eDsgVarType_0To65535:
        return (C_SizeOf0To65535);
    case eDsgVarType_Integer:
        return (C_SizeOfInteger);
    case eDsgVarType_PositiveInteger:
        return (C_SizeOfPositiveInteger);
    case eDsgVarType_Float:
        return (C_SizeOfFloat);
    case eDsgVarType_WayPoint:
        return (C_SizeOfWayPoint);
    case eDsgVarType_Perso:
        return (C_SizeOfPerso);
/* ANNECY OA - 13/08/99 { */
#ifndef U64		
    case eDsgVarType_SuperObject:
        return (C_SizeOfSuperObject);
#endif
/* END ANNECY OA } */
    case eDsgVarType_Text:
        return(C_SizeOfText);
    case eDsgVarType_List:
        return (C_SizeOfList1+ (ucNbElt-1)*C_SizeOfPersoInList);
    case eDsgVarType_Vector:
	  return (C_SizeOfVector);
	case eDsgVarType_Action :
	   return (C_SizeOfAction);
	case eDsgVarType_Comport :
	   return(C_SizeOfComport);
 	case eDsgVarType_GameMaterial:
		return(C_SizeOfGameMaterial);
//FB120399 corrected by AR9905
	case eDsgVarType_VectorArray:
#if defined(OPTIMIZED_ARRAY)
  		return(C_SizeOfArray1 - sizeof(C_TypeOfArrayElement)+ (ARRAY_FACTOR*ucNbElt*C_SizeOfArrayElement));
#endif
	case eDsgVarType_PersoArray:
	case eDsgVarType_FloatArray:
	case eDsgVarType_IntegerArray:
	case eDsgVarType_WayPointArray:
	case eDsgVarType_TextArray:
		return(C_SizeOfArray1+ (ucNbElt-1)*C_SizeOfArrayElement);
 
   default:
#if defined(__DEBUG_AI__)
        M_AIFatalError (E_uwAIFatalWrongTypeVar);
#endif
        return 0;
		break;
 
    }
}
 
/*
#if defined(ACTIVE_EDITOR)
tdeVariableType fn_eGetDsgVarType(unsigned char ucId, AI_tdstMind *p_stPerso)
{
#if defined(__DEBUG_AI__)    
    if ( (AI_M_p_stGetDsgMem(p_stPerso) == NULL) || (AI_M_p_stGetDsgVar(p_stPerso)==NULL) || (ucId >= M_GetNbDsgVar(p_stPerso)) )
    {
        M_AIFatalError (E_uwAIFatalNotValidDsgVarId); 
    }
#endif
    return(M_GetDsgVarType(p_stPerso,ucId));
}
endif
*/
 
 
/*******************************************************************************************************************/
/* Get Functions to access DsgVar                                                                                  */
/*******************************************************************************************************************/
/* eDsgVarType_Float*/
unsigned char fn_ucGetDsgVarFloat(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	MTH_tdxReal xValue=(C_TypeOfFloat) (*((C_TypeOfFloat *)pMyVarAddr));
    ucIndex=ucIndex;
	M_Full_GetSetParam_Float(p_stGetSetParam,xValue);
	return(C_VALID_GET);
}
 
/* eDsgVarType_Perso*/
unsigned char fn_ucGetDsgVarPerso(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    C_TypeOfPerso hSuperObjectPerso =(C_TypeOfPerso) (*((C_TypeOfPerso *)pMyVarAddr));
    ucIndex=ucIndex;
	M_Full_GetSetParam_Perso(p_stGetSetParam,hSuperObjectPerso);
	if (hSuperObjectPerso==NULL) 
		return(C_INVALID_GET);
	return(C_VALID_GET);
}
 
/* ANNECY OA - 13/08/99 { */
/* eDsgVarType_SuperObject*/
#ifndef U64		
unsigned char fn_ucGetDsgVarSuperObject(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    C_TypeOfSuperObject hSuperObject =(C_TypeOfSuperObject) (*((C_TypeOfSuperObject *)pMyVarAddr));
    ucIndex=ucIndex;
	M_Full_GetSetParam_SuperObject(p_stGetSetParam,hSuperObject);
	if (hSuperObject==NULL) 
		return(C_INVALID_GET);
	return(C_VALID_GET);
}
#endif
/* END ANNECY OA } */

/* eDsgVarType_Vector*/
unsigned char fn_ucGetDsgVarVector(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	MTH3D_tdstVector *p_stVertex=(C_TypeOfVector *)pMyVarAddr;
    ucIndex=ucIndex;
	M_Full_GetSetParam_p_stVertex(p_stGetSetParam,p_stVertex);
	return(C_VALID_GET);
}
 
/*ANNECY Bart 05/02/98 {*/
/* eDsgVarType_Caps*/
unsigned char fn_ucGetDsgVarCaps(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    C_TypeOfCaps ulCaps=(*((C_TypeOfCaps *)pMyVarAddr));
    ucIndex=ucIndex;
    M_Full_GetSetParam_Caps(p_stGetSetParam, ulCaps);
 
    return(C_VALID_GET);
}
 
/* eDsgVarType_Graph*/
unsigned char fn_ucGetDsgVarGraph(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    C_TypeOfGraph hGraph=(*((C_TypeOfGraph *)pMyVarAddr)); /* = WP_tdHandleOfGraph ?*/
    ucIndex=ucIndex;
    M_Full_GetSetParam_Graph(p_stGetSetParam, hGraph);
 
    /* //ANNECY Bart 11/02/98
    if (hGraph == NULL) // ???? WP_C_hGraphInvalid ????
       return(C_INVALID_GET);
    */
    return(C_VALID_GET);
}
/*ENDANNECY Bart }*/
 
/* eDsgVarType_WayPoint*/
unsigned char fn_ucGetDsgVarWayPoint(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    C_TypeOfWayPoint hWayPoint=(*((C_TypeOfWayPoint *)pMyVarAddr));
    ucIndex=ucIndex;
    M_Full_GetSetParam_WayPoint(p_stGetSetParam,hWayPoint);
 
    /*if (hWayPoint==WP_C_hWayPointInvalid) // Bart : to allow a WP to equal to NoWhere ...*/
       /*return(C_INVALID_GET);               */
    return(C_VALID_GET);
}
 
/* eDsgVarType_Action*/
unsigned char fn_ucGetDsgVarAction(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    C_TypeOfAction hAction =(C_TypeOfAction) (*((C_TypeOfAction *)pMyVarAddr));
    M_Full_GetSetParam_Action(p_stGetSetParam,hAction);
    ucIndex=ucIndex;
    if (hAction==NULL) 
       return(C_INVALID_GET);               
    return(C_VALID_GET);
}
 
/* eDsgVarType_Comport*/
unsigned char fn_ucGetDsgVarComport(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    C_TypeOfComport p_stComport =(C_TypeOfComport) (*((C_TypeOfComport *)pMyVarAddr));
    ucIndex=ucIndex;
	M_Full_GetSetParam_pComport(p_stGetSetParam,p_stComport);
   	if (p_stComport==NULL) 
       return(C_INVALID_GET);               
    return(C_VALID_GET);
}
 
/* eDsgVarType_Text*/
unsigned char fn_ucGetDsgVarText(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    C_TypeOfText hText=(C_TypeOfText) (*((C_TypeOfText *)pMyVarAddr));
    ucIndex=ucIndex;
    M_Full_GetSetParam_hText(p_stGetSetParam,hText);
  if ( hText == FON_C_xInvalidTextHandle )
       return(C_INVALID_GET);
    return(C_VALID_GET);
}
 
/* eDsgVarType_List*/
unsigned char fn_ucGetDsgVarList(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    ucIndex=ucIndex;
    M_Full_GetSetParam_List(p_stGetSetParam,((C_TypeOfList1 *)pMyVarAddr) );
    return(C_VALID_GET);
}
 
/* eDsgVarType_Boolean*/
unsigned char fn_ucGetDsgVarBoolean(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    long lValue=( (long) (* ((C_TypeOfBoolean *)pMyVarAddr) ) );
    ucIndex=ucIndex;
    M_Full_GetSetParam_Integer(p_stGetSetParam,lValue);
    return(C_VALID_GET);
}
 
/* eDsgVarType__128To127*/
unsigned char fn_ucGetDsgVar_128To127(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
    long lValue=( (long) (* ((C_TypeOf_128To127 *)pMyVarAddr) ) );
    ucIndex=ucIndex;
    M_Full_GetSetParam_Integer(p_stGetSetParam,lValue);
    return(C_VALID_GET);
}
 
/* eDsgVarType_0To255*/
unsigned char fn_ucGetDsgVar0To255(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	long lValue=( (long) (* ((C_TypeOf0To255 *)pMyVarAddr) ) );
	ucIndex=ucIndex;
	M_Full_GetSetParam_Integer(p_stGetSetParam,lValue);
	return(C_VALID_GET);
}
/* eDsgVarType__32768To32767*/
unsigned char fn_ucGetDsgVar_32768To32767(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	long lValue=( (long) (* ((C_TypeOf_32768To32767 *)pMyVarAddr) ) );
	ucIndex=ucIndex;
	M_Full_GetSetParam_Integer(p_stGetSetParam,lValue);
	return(C_VALID_GET);
}
/* eDsgVarType_0To65535*/
unsigned char fn_ucGetDsgVar0To65535(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	long lValue=( (long) (* ((C_TypeOf0To65535 *)pMyVarAddr) ) );
	ucIndex=ucIndex;
	M_Full_GetSetParam_Integer(p_stGetSetParam,lValue);
	return(C_VALID_GET);
}
           
/* eDsgVarType_Integer*/
unsigned char fn_ucGetDsgVarInteger(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	long lValue=( (long) (* ((C_TypeOfInteger *)pMyVarAddr) ) );
	ucIndex=ucIndex;
	M_Full_GetSetParam_Integer(p_stGetSetParam,lValue);
	return(C_VALID_GET);
}
       
/* eDsgVarType_PositiveInteger*/
unsigned char fn_ucGetDsgVarPositiveInteger(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	long lValue=( (long) (* ((C_TypeOfPositiveInteger *)pMyVarAddr) ) );
	ucIndex=ucIndex;
	M_Full_GetSetParam_Integer(p_stGetSetParam,lValue);
	return(C_VALID_GET);
}
 
/* eDsgVarType_GameMaterial*/
unsigned char fn_ucGetDsgVarGameMaterial(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	C_TypeOfGameMaterial hGameMaterial=( (C_TypeOfGameMaterial) ( *((C_TypeOfGameMaterial *)pMyVarAddr) ) );
	ucIndex=ucIndex;
	M_Full_GetSetParam_hGameMaterial(p_stGetSetParam,hGameMaterial);
	if (GMT_fn_b_ulIsValid(hGameMaterial))
		return(C_INVALID_GET);
	return(C_VALID_GET);
}
 
/* eDsgVarType_PersoArray*/
/* eDsgVarType_VectorArray*/
/* eDsgVarType_FloatArray*/
/* eDsgVarType_IntegerArray*/
/* eDsgVarType_WayPointArray*/
/* eDsgVarType_TextArray*/
unsigned char fn_ucGetDsgVarArray(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	unsigned char ret=C_INVALID_GET;
	tdstArray *p_stArray=(tdstArray*) pMyVarAddr;
	tdeDsgVarTypeId eDsgVarTypeId=M_ARRAY_TYPE(p_stArray);
#if defined(__DEBUG_AI__)
	if (ucIndex<M_ARRAY_SIZE(p_stArray))
#endif
	{
		tdp_fn_ucGetDsgVarFunctionPtr p_fn_ucGetDsgVar=fn_p_fn_pGetDsgVarGetFunctionPtr(eDsgVarTypeId);
		ret=p_fn_ucGetDsgVar((void *) M_ARRAY_ELEMENT(p_stArray,ucIndex),0,p_stGetSetParam);
	}
#if defined(__DEBUG_AI__)
	else
	{
		char  Message[255];
		
		sprintf(Message, "Size of Array=%d, index=%d ", M_ARRAY_SIZE(p_stArray), ucIndex);
		SAF_M_AssertWithMsg(FALSE,Message)
	}
#endif /*(__DEBUG_AI__)*/
	return(ret);
}
 
#if !defined(ACTIVE_EDITOR)
static 
#endif
unsigned char fn_ucGetDsgVarValue(void *pMyVarAddr,unsigned char ucIndex,tdeDsgVarTypeId eDsgVarTypeId,tdstGetSetParam *p_stGetSetParam)		  
{
	tdp_fn_ucGetDsgVarFunctionPtr p_fn_ucGetDsgVar=fn_p_fn_pGetDsgVarGetFunctionPtr(eDsgVarTypeId);
#if defined(__DEBUG_AI__)
	M_GetSetParam_Clear(p_stGetSetParam);
#endif
	return(p_fn_ucGetDsgVar(pMyVarAddr,ucIndex,p_stGetSetParam));
}
 
unsigned char fn_ucGetDsgVar(unsigned char ucId, unsigned char ucIndex,AI_tdstMind *p_stPerso,tdstGetSetParam *p_stGetSetParam)		  
{
  return(fn_ucGetDsgVarValue((void*) M_GetDsgVarAddr(p_stPerso,ucId),ucIndex,M_GetDsgVarType(p_stPerso,ucId),p_stGetSetParam));
}
 
#if defined(__DEBUG_AI__)
unsigned char fn_ucGetDsgVarInit(unsigned char ucId, unsigned char ucIndex,AI_tdstMind *p_stPerso,tdstGetSetParam *p_stGetSetParam)		  
{
  void *p_VarAddr;
  if (M_GetDsgMemBufferInit(p_stPerso)==NULL)
  {
    p_VarAddr=(void*) M_GetDsgVarAddrDefault(p_stPerso,ucId);
  }
  else
  {
    p_VarAddr=(void*) M_GetDsgVarAddrInit(p_stPerso,ucId);
  }
  return(fn_ucGetDsgVarValue(p_VarAddr,ucIndex,M_GetDsgVarType(p_stPerso,ucId),p_stGetSetParam));
}
#endif
 
/*******************************************************************************************************************/
/* Set Functions to access DsgVar                                                                                  */
/*******************************************************************************************************************/
 
/* whaouh ! */
#if defined(__DEBUG_AI__)
	static unsigned char g_ucTruncated=0;
	static unsigned char g_ucRetValue=C_INVALID_SET;
 
    #define M_INIT_TRUNCATED() g_ucTruncated=0;g_ucRetValue=C_INVALID_SET;
		
/*ANNECY jt {*/
/*	#define M_WARNING_TRUNCATED(ucId,p_stPerso) \*/
/*	    if (g_ucTruncated) \*/
/*		{ \*/
/*			char MyMsg[200]; \*/
/*			sprintf(MyMsg,"Variable no %d from p_stMind (%s)\n",(ucId),AI_M_szGetPersoName((p_stPerso)) ); \*/
/*			M_AIWarningErrorAndNeverStopForDebug(E_uwAIWarningTruncateAffectation, C_ucErmNoOpenInfoWindow,MyMsg); \*/
/*		} \*/
/*		return(g_ucRetValue);*/
	#define M_WARNING_TRUNCATED(ucId,p_stPerso) return(g_ucRetValue);
/*ENDANNECY jt }*/
 
	#define M_WARNING_TRUNCATED_2() return(g_ucRetValue);
 
	#define M_TRUNCATED_RETURN_OR_BREAK(n) g_ucRetValue=(n) 
 
	#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(p_stGetSetParam,expression,a,b) \
		g_ucTruncated=fn_ucIsThereFloatIfYesConvertItToInteger(p_stGetSetParam); \
		if (!g_ucTruncated) \
		{ \
			long lValue=M_GetSetParam_lValue(p_stGetSetParam); \
			g_ucTruncated=##expression(lValue,a,b); \
		}
 
#else
    #define M_INIT_TRUNCATED() 
	#define M_WARNING_TRUNCATED(ucId,p_stPerso) 
	#define M_TRUNCATED_RETURN_OR_BREAK(n) return(n)
	#define M_TEST_TRUNCATED(p_stGetSetParam,expression,a,b) (void) fn_ucIsThereFloatIfYesConvertItToInteger(p_stGetSetParam)
#endif
 
/* eDsgVarType_Float*/
unsigned char fn_ucSetDsgVarFloat(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
  ucIndex=ucIndex;
  *((C_TypeOfFloat *)pMyVarAddr) = (C_TypeOfFloat)  M_ReturnParam_xValue(p_stGetSetParam);
  return(C_VALID_SET);
}
 
/* eDsgVarType_Perso*/
unsigned char fn_ucSetDsgVarPerso(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
   tdstEngineObject *p_stObject=M_GetSetParam_p_stEngineObjValue(p_stGetSetParam);
   ucIndex=ucIndex;
   if (p_stObject!=NULL)
   {
	  *((C_TypeOfPerso *)pMyVarAddr) = (C_TypeOfPerso) M_GetSuperObject(p_stObject);
/*      return(C_VALID_SET);*/
   }
   else
   {
	  *((C_TypeOfPerso *)pMyVarAddr) = NULL;
/*      return(C_INVALID_SET);*/
   }
      return(C_VALID_SET);
}

 
/* ANNECY OA - 13/08/99 { */
/* eDsgVarType_SuperObject*/
#ifndef U64		
unsigned char fn_ucSetDsgVarSuperObject(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
   tdstEngineObject *p_stObject=M_GetSetParam_p_stEngineObjValue(p_stGetSetParam);
   ucIndex=ucIndex;
   if (p_stObject!=NULL)
   {
	  *((C_TypeOfSuperObject *)pMyVarAddr) = (C_TypeOfSuperObject) M_GetSuperObject(p_stObject);
/*      return(C_VALID_SET);*/
   }
   else
   {
	  *((C_TypeOfSuperObject *)pMyVarAddr) = NULL;
/*      return(C_INVALID_SET);*/
   }
      return(C_VALID_SET);
}
#endif 
/* END ANNECY OA } */

/* eDsgVarType_Action*/
unsigned char fn_ucSetDsgVarAction(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
   C_TypeOfAction hAction = M_GetSetParam_Dsg_Action(p_stGetSetParam);
   ucIndex=ucIndex;
   *((C_TypeOfAction *)pMyVarAddr)=(C_TypeOfAction) hAction;
   /*if (hAction==NULL) 
 	 return(C_INVALID_SET);*/
   return(C_VALID_SET);
}
 
/* eDsgVarType_Comport*/
unsigned char fn_ucSetDsgVarComport(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
   C_TypeOfComport p_stComport = M_GetSetParam_Dsg_Comport(p_stGetSetParam);
   ucIndex=ucIndex;
   *((C_TypeOfComport *)pMyVarAddr) = (C_TypeOfComport) p_stComport;
   if (p_stComport==NULL) 
 	 return(C_INVALID_SET);
   return(C_VALID_SET);
}
 
/* eDsgVarType_Vector*/
unsigned char fn_ucSetDsgVarVector(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
   MTH3D_tdstVector *p_stVertex = &M_GetSetParam_stVertexValue(p_stGetSetParam);
   ucIndex=ucIndex;
   MTH3D_M_vCopyVector(((C_TypeOfVector *)pMyVarAddr),p_stVertex);
   return(C_VALID_SET);
}
 
/* eDsgVarType_Text*/
unsigned char fn_ucSetDsgVarText(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
  C_TypeOfText hText = M_GetSetParam_Dsg_Text(p_stGetSetParam);
  ucIndex=ucIndex;
  *((C_TypeOfText *)pMyVarAddr) = (C_TypeOfText) hText;
/*  if (!hText)*/
/*   return(C_INVALID_SET);*/
   return(C_VALID_SET);
}
 
/*ANNECY Bart 05/02/98 {*/
/* eDsgVarType_Caps*/
unsigned char fn_ucSetDsgVarCaps(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	C_TypeOfCaps ulCaps = M_GetSetParam_Dsg_Caps(p_stGetSetParam);
	ucIndex=ucIndex;
	*((C_TypeOfCaps *)pMyVarAddr) = (C_TypeOfCaps) ulCaps;
 
  return(C_VALID_SET);
}
 
/* eDsgVarType_Graph*/
unsigned char fn_ucSetDsgVarGraph(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	C_TypeOfGraph hGraph = M_GetSetParam_Dsg_Graph(p_stGetSetParam);
	ucIndex=ucIndex;
	*((C_TypeOfGraph *)pMyVarAddr) = (C_TypeOfGraph) hGraph;
/*	if (hGraph==NULL) */
/* 	 return(C_INVALID_SET);*/
    return(C_VALID_SET);
}
/*ENDANNECY Bart }*/
 
 
/* eDsgVarType_WayPoint*/
unsigned char fn_ucSetDsgVarWayPoint(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	C_TypeOfWayPoint hWayPoint = M_GetSetParam_Dsg_WayPoint(p_stGetSetParam);
	ucIndex=ucIndex;
	*((C_TypeOfWayPoint *)pMyVarAddr) = (C_TypeOfWayPoint) hWayPoint;
/*	if (hWayPoint==WP_C_hWayPointInvalid)*/
/* 	 return(C_INVALID_SET);*/
    return(C_VALID_SET);
}
 
/* eDsgVarType_List*/
unsigned char fn_ucSetDsgVarList(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	tdstList *p_SrcList = (tdstList *) M_GetSetParam_Dsg_List(p_stGetSetParam);
	tdstList *p_TgtList = (tdstList *)pMyVarAddr;			
                    
	ucIndex=ucIndex;
	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);
 
/*
  // copy the list (beginning at the address lValue) in the designer list variable
  tdstList *p_SrcList = (tdstList *) M_GetSetParam_Dsg_List(p_stGetSetParam);
  tdsrList *p_TgtList = (tdstList *)pMyVarAddr;			
  HIE_tdxHandleToSuperObject *p_p_SrcPerso, *p_p_TgtPerso;
                    
  p_TgtList->ucNbElt = (unsigned char) M_Min(p_SrcList->ucNbElt, p_TgtList->ucMaxSize);
                    
  M_InitScanList(p_SrcList, p_p_SrcPerso);
  M_InitScanList(p_TgtList, p_p_TgtPerso);
                    
  while (M_EndingCondScanList(p_SrcList, p_p_SrcPerso))
  {
     *p_p_TgtPerso = *p_p_SrcPerso;
     M_GoNextScanList(p_SrcList, p_p_SrcPerso);
     M_GoNextScanList(p_TgtList, p_p_TgtPerso);
  }
*/
  return(C_VALID_SET);
}
 
/* eDsgVarType_Boolean*/
unsigned char fn_ucSetDsgVarBoolean(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	M_TEST_TRUNCATED(p_stGetSetParam, M_INF_SUP, 0, 1);
	ucIndex=ucIndex;
	*((C_TypeOfBoolean *)pMyVarAddr) = (C_TypeOfBoolean) M_GetSetParam_Dsg_Boolean(p_stGetSetParam);
	return(C_VALID_SET);
}
 
/* eDsgVarType__128To127*/
unsigned char fn_ucSetDsgVar_128To127(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	M_TEST_TRUNCATED(p_stGetSetParam, M_INF_SUP, -128, 127);
	ucIndex=ucIndex;
	*((C_TypeOf_128To127 *)pMyVarAddr) = (C_TypeOf_128To127) M_GetSetParam_Dsg__128To127(p_stGetSetParam);
	return(C_VALID_SET);
}
 
/* eDsgVarType_0To255*/
unsigned char fn_ucSetDsgVar0To255(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	M_TEST_TRUNCATED(p_stGetSetParam, M_INF_SUP, 0, 255);
	ucIndex=ucIndex;
	*((C_TypeOf0To255 *)pMyVarAddr) = (C_TypeOf0To255) M_GetSetParam_Dsg_0To255(p_stGetSetParam);
	return(C_VALID_SET);
}
 
/* eDsgVarType__32768To32767*/
unsigned char fn_ucSetDsgVar_32768To32767(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	M_TEST_TRUNCATED(p_stGetSetParam, M_INF_SUP, -32768, 32767);
	ucIndex=ucIndex;
	*((C_TypeOf_32768To32767 *)pMyVarAddr) = (C_TypeOf_32768To32767) M_GetSetParam_Dsg__32768To32767(p_stGetSetParam);	
	return(C_VALID_SET);
}
 
/* eDsgVarType_0To65535*/
unsigned char fn_ucSetDsgVar0To65535(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	M_TEST_TRUNCATED(p_stGetSetParam, M_INF_SUP, 0, 65535);
	ucIndex=ucIndex;
	*((C_TypeOf0To65535 *)(pMyVarAddr)) = (C_TypeOf0To65535) M_GetSetParam_Dsg__32768To32767(p_stGetSetParam);	
	return(C_VALID_SET);
}
 
/* eDsgVarType_Integer*/
unsigned char fn_ucSetDsgVarInteger(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	M_TEST_TRUNCATED(p_stGetSetParam, M_NONE, 0, 0);
	ucIndex=ucIndex;
	*((C_TypeOfInteger *)(pMyVarAddr)) = (C_TypeOfInteger) M_GetSetParam_Dsg_Integer(p_stGetSetParam);
	return(C_VALID_SET);
}
            
/* eDsgVarType_PositiveInteger*/
unsigned char fn_ucSetDsgVarPositiveInteger(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	M_TEST_TRUNCATED(p_stGetSetParam, M_INF, 0, 0);
	ucIndex=ucIndex;
	*((C_TypeOfPositiveInteger *)(pMyVarAddr)) = (C_TypeOfPositiveInteger) M_GetSetParam_Dsg_PositiveInteger(p_stGetSetParam);
	return(C_VALID_SET);
}
 
/* eDsgVarType_GameMaterial*/
unsigned char fn_ucSetDsgVarGameMaterial(void *pMyVarAddr,unsigned char ucIndex,tdstGetSetParam *p_stGetSetParam)
{
	C_TypeOfGameMaterial hGameMaterial=M_GetSetParam_Dsg_GameMaterial(p_stGetSetParam);
	ucIndex=ucIndex;
	*((C_TypeOfGameMaterial *)pMyVarAddr) = (C_TypeOfGameMaterial) hGameMaterial;
	if (hGameMaterial==NULL)
 		 return(C_INVALID_SET);
	return(C_VALID_SET);
}
 
/* eDsgVarType_PersoArray*/
/* eDsgVarType_VectorArray*/
/* eDsgVarType_FloatArray*/
/* eDsgVarType_IntegerArray*/
/* eDsgVarType_WayPointArray*/
/* eDsgVarType_TextArray*/
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);
 
/*FB220199*/
#if defined(U64) && !defined(RETAIL)
	if (ucIndex>=M_ARRAY_SIZE(p_stArray))
	{
		osSyncPrintf("ucIndex : %d; Size : %d\n", ucIndex, M_ARRAY_SIZE(p_stArray));
#ifdef CODEWARRIOR		
		asm {breakc 0xFF}
#else
		asm ("break 0xFF");
#endif		
	}
#endif
 
#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);
		}
#if defined(__DEBUG_AI__)
		else
		{
			char  Message[255];
			
			sprintf(Message, "Size of Array=%d, index=%d ", M_ARRAY_SIZE(p_stArray), ucIndex);
			SAF_M_AssertWithMsg(FALSE,Message)
		}
	/*}*/
#endif /*(__DEBUG_AI__)*/
 
	return(ret);
}
 
#if defined(ACTIVE_EDITOR)
unsigned char fn_ucSetDsgVarValue(void *pMyVarAddr,unsigned char ucIndex,tdeDsgVarTypeId eDsgVarTypeId,tdstGetSetParam *p_stGetSetParam)
{
	tdp_fn_ucSetDsgVarFunctionPtr p_fn_ucSetDsgVar=fn_p_fn_pGetDsgVarSetFunctionPtr(eDsgVarTypeId);
 
	M_INIT_TRUNCATED();
	M_TRUNCATED_RETURN_OR_BREAK(p_fn_ucSetDsgVar(pMyVarAddr,ucIndex,p_stGetSetParam));
	M_WARNING_TRUNCATED_2();
}
#endif
 
unsigned char fn_ucSetDsgVar(unsigned char ucId, unsigned char ucIndex,AI_tdstMind *p_stPerso, tdstGetSetParam *p_stGetSetParam)
{
	tdeDsgVarTypeId eDsgVarTypeId=M_GetDsgVarType(p_stPerso,ucId);
	tdp_fn_ucSetDsgVarFunctionPtr p_fn_ucSetDsgVar=fn_p_fn_pGetDsgVarSetFunctionPtr(eDsgVarTypeId);
    void *pMyVarAddr=(void*) M_GetDsgVarAddr(p_stPerso,ucId);
 
	M_INIT_TRUNCATED();
	M_TRUNCATED_RETURN_OR_BREAK(p_fn_ucSetDsgVar(pMyVarAddr,ucIndex,p_stGetSetParam));
	M_WARNING_TRUNCATED(ucId,p_stPerso);
}
 
/*XB 99/02/08*/
/*Strange isn't it ?????*/
/*#include "List.c"*/
/*#include "Array.c"*/
/*End XB*/
