reman3/Rayman_X/cpa/tempgrp/GAM/State.c

381 lines
11 KiB
C

/*=========================================================================
* State.c : This module contain all models functions
* This is a part of the Game project.
*
* Version 1.0
* Creation date 04/02/97
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1997
*=======================================================================*/
/*******************************************************/
/**** For the structures and variables declarations ****/
/*******************************************************/
#define D_State_Define
#include "ToolsCPA.h"
#include "Options/Options.h"
#include "Macros.h"
#include "Actions/AllActs.h"
#include "Structur/MemGame.h"
#include "Structur/ErrGame.h"
#include "Structur/Objects.h"
#include "Structur/GameScpt.h"
#include "Structur/MemGame.h"
#include "Structur/StdObjSt.h"
#include "Structur/EngMode.h"
#include "Structur/3DOSLkTb.h"
#include "PlayAnim/PLA_dbg.h"
#include "Structur/State.h"
#include "ZeMem.h"
#define MAX_STATE_SIZE 64*1024
/*-----------------------------------------------------------------------------
* Description : State's mini-structure sizeof
*-----------------------------------------------------------------------------
* Input : None
* Output : Size of
*-----------------------------------------------------------------------------
* Creation date : 04/02/97 Author : DAVID Sebastien (Gizmo)
*-----------------------------------------------------------------------------
* Modification date : Modification Author :
* Modifications :
*---------------------------------------------------------------------------*/
/* ************* STATE *************/
unsigned long fn_ulStateSizeOf()
{
return(sizeof(struct tdstState_));
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdxHandleToState fn_h_StateAlloc()
{
tdxHandleToState h_State;
h_State = (tdxHandleToState)M_p_GameMallocInHLM(fn_ulStateSizeOf());
/* init the State structure*/
h_State->p_stAnim = NULL;
LST2_M_StaticInitAnchor(&h_State->hForTransitionArray);
LST2_M_StaticInitAnchor(&h_State->hForProhibitArray);
h_State->h_NextState = NULL;
h_State->ucRepeatAnimation = 0;
h_State->ucTransitionStatusFlag = C_ucProhibitedState;
h_State->scSpeedAnim = 1;
h_State->h_LinkedMechanicsIdCard = NULL;
h_State->ucCustomBits = 0;
return(h_State);
}
void fn_h_StateFree(tdxHandleToState h_State)
{
M_GameFreeInHLM(h_State);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* ************ Transitional State ************** */
unsigned long fn_ulTransitionSizeOf()
{
return(sizeof(struct tdstTransition_));
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdxHandleToTransition fn_h_TransitionAlloc()
{
tdxHandleToTransition h_Transition;
h_Transition = (tdxHandleToTransition)M_p_GameMallocInHLM(fn_ulTransitionSizeOf());
return(h_Transition);
}
void fn_h_TransitionFree(tdxHandleToTransition h_Transition)
{
M_GameFreeInHLM(h_Transition);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* ************ Prohibited State ************** */
unsigned long fn_ulProhibitSizeOf()
{
return(sizeof(struct tdstProhibit_));
}
tdxHandleToProhibit fn_h_ProhibitAlloc()
{
tdxHandleToProhibit h_Prohibit;
h_Prohibit = (tdxHandleToProhibit)M_p_GameMallocInHLM(fn_ulProhibitSizeOf());
return(h_Prohibit);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_h_ProhibitFree(tdxHandleToProhibit h_Prohibit)
{
M_GameFreeInHLM(h_Prohibit);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*-----------------------------------------------------------------------------
* Description : State access functions
*-----------------------------------------------------------------------------
* Input : tdxHandleToState + (value)
* Output : (value or pointer)
*-----------------------------------------------------------------------------
* Creation date : 07/02/97 Author : DAVID Sebastien (Gizmo)
*-----------------------------------------------------------------------------
* Modification date : Modification Author :
* Modifications :
*---------------------------------------------------------------------------*/
/********** Debug name ********************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
char* fn_p_szGetStateName(tdxHandleToState h_State)
{
#ifdef _DEBUG_STRING_FOR_PLA_
return (h_State->szStateName);
#else
return NULL;
#endif
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/********** Anim ********************/
struct tdstAnim3d_* fn_p_stGetAnimInState(tdxHandleToState h_State)
{
return(h_State->p_stAnim);
}
void fn_vSetAnimInState(tdxHandleToState h_State,struct tdstAnim3d_ *p_stAnim)
{
h_State->p_stAnim = p_stAnim;
}
/*************** NextState *******************/
tdxHandleToState fn_hGetNextStateInState(tdxHandleToState h_State)
{
return(h_State->h_NextState);
}
void fn_vSetNextStateInState(tdxHandleToState h_State,tdxHandleToState h_NextState)
{
h_State->h_NextState = h_NextState;
}
/*********** RepeatAnimation *******************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned char fn_ucGetRepeatAnimationInState(tdxHandleToState h_State)
{
return(h_State->ucRepeatAnimation);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
void fn_vSetRepeatAnimationInState(tdxHandleToState h_State,unsigned char ucRepeatAnimation)
{
h_State->ucRepeatAnimation = ucRepeatAnimation;
}
/*********** TransitionStatusFlag *******************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned char fn_ucGetTransitionStatusFlagInState(tdxHandleToState h_State)
{
return(h_State->ucTransitionStatusFlag);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
void fn_vSetTransitionStatusFlagInState(tdxHandleToState h_State,unsigned char ucTransitionStatusFlag)
{
h_State->ucTransitionStatusFlag = ucTransitionStatusFlag;
}
/*********** SpeedAnim *******************/
signed char fn_scGetSpeedInState(tdxHandleToState h_State)
{
return(h_State->scSpeedAnim);
}
void fn_vSetSpeedInState(tdxHandleToState h_State,signed char scSpeedAnim)
{
h_State->scSpeedAnim = scSpeedAnim;
}
/* ************* MechanicsIdCard *************/
DNM_tdxHandleToMecIdentityCard fn_hGetStateMechanicsIdCard(tdxHandleToState h_State)
{
return(h_State->h_LinkedMechanicsIdCard);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vSetStateMechanicsIdCard(tdxHandleToState h_State,DNM_tdxHandleToMecIdentityCard h_LinkedMechanicsIdCard)
{
h_State->h_LinkedMechanicsIdCard = h_LinkedMechanicsIdCard;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* ANNECY MT - 24/11/98 {*/
/* ******* CustomBits *******/
unsigned char fn_ucGetStateCustomBits(tdxHandleToState h_State)
{
return(h_State->ucCustomBits);
}
void fn_vSetStateCustomBits(tdxHandleToState h_State,unsigned char ucCustomBits)
{
h_State->ucCustomBits = ucCustomBits;
}
/* END ANNECY MT }*/
/*-----------------------------------------------------------------------------
* Description : Transition access functions
*-----------------------------------------------------------------------------
* Input : tdxHandleToTransition + (value)
* Output : (value or pointer)
*-----------------------------------------------------------------------------
* Creation date : 07/02/97 Author : DAVID Sebastien (Gizmo)
*-----------------------------------------------------------------------------
* Modification date : Modification Author :
* Modifications :
*---------------------------------------------------------------------------*/
/*************** TargetState *******************/
tdxHandleToState fn_hGetTargetStateInTransition(tdxHandleToTransition h_Transition)
{
return(h_Transition->h_TargetState);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vSetTargetStateInTransition(tdxHandleToTransition h_Transition,tdxHandleToState h_TargetState)
{
h_Transition->h_TargetState = h_TargetState;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*************** StateToGo *******************/
tdxHandleToState fn_hGetStateToGoInTransition(tdxHandleToTransition h_Transition)
{
return(h_Transition->h_StateToGo);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vSetStateToGoInTransition(tdxHandleToTransition h_Transition,tdxHandleToState h_StateToGo)
{
h_Transition->h_StateToGo = h_StateToGo;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*ANNECY CT 11/02/98{*/
/*************** LinkingType *******************/
unsigned char fn_ucGetLinkingTypeInTransition(tdxHandleToTransition h_Transition)
{
return(h_Transition->ucLinkingType);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vSetLinkingTypeInTransition(tdxHandleToTransition h_Transition,unsigned char ucLinkingType)
{
h_Transition->ucLinkingType = ucLinkingType;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*ENDANNECY CT}*/
/*************** TEST StateToGo *******************/
/*ANNECY CT 11/02/98{*/
/*tdxHandleToState fn_hIfExistTransitionalWithTargetState(tdxHandleToState h_State, tdxHandleToState h_TargetState)*/
tdxHandleToTransition fn_hIfExistTransitionalWithTargetState(tdxHandleToState h_State, tdxHandleToState h_TargetState)
/*ENDANNECY CT}*/
/* AR9808 Function changed to be compatible with optimized static lists*/
{
int i;
struct tdstTransition_ *p_stTransition;
LST2_M_StaticForEachElementOf(&h_State->hForTransitionArray, p_stTransition, i)
{
if (fn_hGetTargetStateInTransition(p_stTransition) == h_TargetState)
{
return p_stTransition;
}
}
return NULL;
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdxHandleToState fn_hGetProhibitedStateInProhibit( tdxHandleToProhibit _hProhibit )
{
return ( _hProhibit ? _hProhibit -> h_ProhibitedState : NULL );
}
void fn_vSetProhibitedStateInProhibit( tdxHandleToProhibit _hProhibit, tdxHandleToState _hState )
{
_hProhibit -> h_ProhibitedState = _hState;
}
/*************** GET for EDITOR *******************/
/* AR9808 : Modif for optimized lists compatibility*/
tdxHandleToTransition fn_hGetTransitionalWithTargetState( tdxHandleToState _hState, tdxHandleToState _hTargetState )
{
tdxHandleToTransition hTransition;
int i,max;
hTransition = LST2_M_StaticGetFirstElement( & _hState -> hForTransitionArray );
max=LST2_M_StaticGetNumberOfElements(& _hState -> hForTransitionArray);
i=0;
while( hTransition && (i<max)) /* For optimized lists*/
{
if( fn_hGetTargetStateInTransition( hTransition ) == _hTargetState)
{
return( hTransition );
}
hTransition = LST2_M_StaticGetNextElement( hTransition );
++i;
}
return(NULL);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*************** TEST ProhibitedState *******************/
/* AR9808 : Modif for optimized lists compatibility*/
long fn_hIfExistProhibitedState(tdxHandleToState h_State, tdxHandleToState h_TargetState)
{
struct tdstProhibit_ *p_stProhibit;
int i,max;
p_stProhibit = (struct tdstProhibit_ *) LST2_M_StaticGetFirstElement(&h_State->hForProhibitArray);
max=LST2_M_StaticGetNumberOfElements(&h_State->hForProhibitArray);
i=0;
while((p_stProhibit != NULL)&&(i<max)) /* For optimized lists*/
{
if(p_stProhibit->h_ProhibitedState == h_TargetState)
{
return(1);
}
p_stProhibit = (struct tdstProhibit_ *) LST2_M_StaticGetNextElement(p_stProhibit);
++i;
}
return(0);
}
/*-------------------------------------------------------------------
* End Of file
*-----------------------------------------------------------------*/