/*
 =======================================================================================
  Name        : Always.h
 
  Author      : Francois Mahieu		Date :20/08/96
 
  Description : This module contain all always functions, This is a part of the Game project.
 =======================================================================================
  Modification -> Author : Michael            Date : 07/02/97
  Description : New LST_M_??? Macros 
 =======================================================================================
 */
 
#if !defined(__ALWAYS_H__)
#define __ALWAYS_H__
 
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
 
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
#include "GAM/Header.h"
 
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
#if defined(__cplusplus)
extern "C"
{
#endif /* __cplusplus */
 
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
/*
 =======================================================================================
	Structures 
 =======================================================================================
 */
 
/* 
 * This structure is used for chain list of always models ***
 */
typedef struct tdstAlwaysModelList_
{
	LST2_M_DynamicElementDeclaration(ALW_tdxHandleToModelList)
	tdObjectType				otObjectModelType;				/* Always object type */
	struct tdstEngineObject_	*p_stAlwaysObject;				/* Pointer to a object structure than contain all object informations */
} tdstAlwaysModelList;
 
/*
 * general structure to manage with always
 */
typedef struct tdstAlways_
{
	unsigned long				ulMaxNumberOfAlways;								/* number max of always*/
	LST2_M_DynamicAnchorDeclaration(ALW_tdxHandleToModelList) ALW_h_LstAlwaysModel;	/* all always models*/
 	HIE_tdxHandleToSuperObject	d_stAlwaysSuperObject;								/* array of generated always*/
	struct tdstEngineObject_	*d_stAlwaysEngineObjectInit;
	HIE_tdxHandleToSuperObject	*d_hAlwaysGenerator;									/* list of generators*/
#if defined(ACTIVE_EDITOR)
	ACP_tdxBool					*d_bIsReferencedInLevel;
#endif
} tdstAlways;
 
/*
 =======================================================================================
	Functions
 =======================================================================================
 */
 
/*
 * init/desinit global structure
 */
void fn_vFirstInitAlwaysStructure();
void fn_vLastDesinitAlwaysStructure();
 
/*
 * list of always models management
 */
extern CPA_EXPORT	void fn_vAddAnAlwaysModel(struct tdstEngineObject_ *p_stAlwaysObject);
void fn_vKillAllAlwaysModel();
void fn_vInitAlwaysModel(enum tdeObjectTreeInit_ eObjIniType);
extern CPA_EXPORT	unsigned char fn_ucIsAnAlwaysObject(struct tdstEngineObject_ *p_stEngineObject);
extern CPA_EXPORT	unsigned char fn_ucIsAnAlwaysModel(struct tdstEngineObject_ *p_stEngineObject);
 
/*
 * list of always management
 */
HIE_tdxHandleToSuperObject fn_p_stAllocateAlways
							(
								tdObjectType otObjectModelType,
								HIE_tdxHandleToSuperObject p_stFatherSuperObject,
								HIE_tdxHandleToSuperObject _hGenerator,
								unsigned short uwAction,
								POS_tdstCompletePosition *p_stMatrix
							);
void fn_vKillAlwaysByPersonalType(tdObjectType otPersonalType);
void fn_vKillAlways(struct tdstEngineObject_ *p_stAlwaysObject);
void fn_vKillAllAlways();
 
/*
 * special function for always
 */
void fn_vInitMindForAlways(void);
void fn_vKillAllAlwaysInNonActiveSectors(void);
 
extern CPA_EXPORT unsigned char fn_ucIsAlwaysGeneratedByMe( HIE_tdxHandleToSuperObject _hAlways, HIE_tdxHandleToSuperObject _hGenerator );
extern CPA_EXPORT unsigned long fn_ulGetNumberOfAlwaysBelongingToMe(HIE_tdxHandleToSuperObject	_hGenerator);

#ifndef U64 
void fn_vClearUnusedAlwaysInDemoMode();
#endif /* U64 */
/*
 =======================================================================================
	Globals
 =======================================================================================
 */
EXTERN tdstAlways g_stAlways
#if defined(D_GameGlobals)
	= {  0L, NULL, NULL, 0L, NULL, NULL, NULL}
#endif /* D_GameGlobals */
;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
#if defined(__cplusplus)
}
#endif /* __cplusplus */
 
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
#endif /* __ALWAYS_H__ */
 
