#define D_AlwAct_StructureDefine
/*----------------------------------------------------------------------
 * Includes
 *--------------------------------------------------------------------*/
 
#include "ToolsCPA.h"
 
#include "macros.h"
#include "GameEng.h"
#include "AlwAct.h"
#include "Actions/AllActs.h"
#include "Structur/GameScpt.h"
#include "Structur/ErrGame.h"
#include "Structur/MemGame.h"
#include "Structur/StdObjSt.h"
#include "Structur/EngMode.h"
#include "Structur/Objects.h"
#include "Zemem.h"
 
 
/* --------------------------------
- Get Set accessors
----------------------------------*/
/*--------------------------------------------------------------------*/
void fn_vSetCharacterInAlwaysActiveCharacterNode(tdxHandleToAlwaysActiveCharacterNode hCharNode,HIE_tdxHandleToSuperObject hCharacter)
{
	tdstAlwaysActiveCharacter *p_stCharNode;
 
	p_stCharNode = (tdstAlwaysActiveCharacter *)hCharNode;
	p_stCharNode->hAlwActSuperObject = hCharacter;
}
/*--------------------------------------------------------------------*/
HIE_tdxHandleToSuperObject fn_hGetCharacterInAlwaysActiveCharacterNode(tdxHandleToAlwaysActiveCharacterNode hCharNode)
{
	tdstAlwaysActiveCharacter *p_stCharNode;
 
	p_stCharNode = (tdstAlwaysActiveCharacter *)hCharNode;
	return (p_stCharNode->hAlwActSuperObject);
}
 
 
/*---------------------------------------
- Functions for the lists
-----------------------------------------*/
 
 
void fn_vAddCharacterInAlwaysActiveCharacterList(HIE_tdxHandleToSuperObject hCharacter)
{
	tdxHandleToAlwaysActiveCharacterNode hCharNode;
	tdstAlwaysActiveCharacter *p_stCharNode;
 
    MMG_fn_vAddMemoryInfo( MMG_C_lTypeGAM , MMG_C_lSubTypeAlwaysActiveChar , 0);
	p_stCharNode=(tdstAlwaysActiveCharacter *)M_p_GameMallocInHLM(sizeof(tdstAlwaysActiveCharacter));
	LST2_M_DynamicInitElement(p_stCharNode);
	hCharNode = (tdxHandleToAlwaysActiveCharacterNode )p_stCharNode;
	fn_vSetCharacterInAlwaysActiveCharacterNode(hCharNode,hCharacter);
	LST2_M_DynamicAddTail(&g_stEngineStructure.hAlwaysActiveCharactersList,hCharNode);
	/*
     *  Update Misc Flags
	*/
/* ANNECY MT - 12/10/98 {*/
    fn_vStandardGameSetAlwaysActive(M_GetMSHandle(hCharacter,StandardGame),TRUE);
/* END ANNECY MT }*/
}
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vRemoveCharacterFromAlwaysActiveCharacterList(HIE_tdxHandleToSuperObject hCharacter)
{
	tdxHandleToAlwaysActiveCharacterNode hCharNode;
	short i;
 
	M_ForEachAlwaysActiveCharacterNode(hCharNode,i)
	{
		if(fn_hGetCharacterInAlwaysActiveCharacterNode(hCharNode) == hCharacter)
		{
			LST2_M_DynamicIsolate(hCharNode);
            MMG_fn_vAddMemoryInfo( MMG_C_lTypeGAM , MMG_C_lSubTypeAlwaysActiveChar , 0);
			M_GameFreeInHLM((tdstAlwaysActiveCharacter *)hCharNode);
			break;
		}
	}
	/*
     *  Update Misc Flags
	*/
/* ANNECY MT - 12/10/98 {*/
    fn_vStandardGameSetAlwaysActive(M_GetMSHandle(hCharacter,StandardGame),FALSE);
/* END ANNECY MT }*/
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
ACP_tdxBool fn_bGetIfCharacterIsInAlwaysActiveCharacterList(HIE_tdxHandleToSuperObject hCharacter)
{
/* ANNECY MT - 12/10/98 {*/
    return (fn_bStandardGameIsAlwaysActive(M_GetMSHandle(hCharacter,StandardGame)));
/* END ANNECY MT }*/
}
 
 
tdxHandleToAlwaysActiveCharacterNode fn_hGetFirstAlwaysActiveCharNode()
{
   return( LST2_M_DynamicGetFirstElement(&g_stEngineStructure.hAlwaysActiveCharactersList));
}
 
tdxHandleToAlwaysActiveCharacterNode fn_hGetNextAlwaysActiveCharNode(tdxHandleToAlwaysActiveCharacterNode hCharNode)
{
	return( LST2_M_DynamicGetNextElement(hCharNode) );
}
 
#undef D_AlwAct_StructureDefine
