/*ANNECY BBB 17/10/97 {*/
/*=========================================================================
* AnimEffect.cpp : AnimEffect's functions
*
* //TODO-B 17/10/97: prévenir Vincent quand fini pour la binarisation ?
*
*         AnimEffect MUST BE REPLACE BY THE C FILENAME
*
*
* Version              1.0
* Creation date        01/10/96
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1996
*=======================================================================*/
 
#ifndef D_THROW_ANIM_EFFECT
 
/*******************************************************/
/**** For the structures and variables declarations ****/
/*******************************************************/
#define D_AnimEffect_StructureDefine
#define D_AnimEffect_VariableDefine
 
#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/StdObjSt.h"
#include "Structur/EngMode.h"
 
#include "Basic.h"
#include "ObjInit.h"
#include "ZeMem.h"
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect's object action script callback
 *-----------------------------------------------------------------------------
 *  Input :         Object pointer
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
#if defined(GAM_USE_SCRIPT)
SCR_tde_Anl_ReturnValue fn_eAnimEffectScriptCallback(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction)
{
	SCR_tde_Anl_ReturnValue eReturnValue = SCR_ERV_Anl_NormalReturn;
 MS_tdxHandleToAnimEffect h_AnimEffect;
 struct tdstEngineObject_ *p_stEngineObject;
 
 _p_stFile=_p_stFile;
 
 SCR_M_RdL0_GetSectionLong(C_ParentSection,0,struct tdstEngineObject_ *, p_stEngineObject);
 
  if (M_IsTitle)
  {
    MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypeAnimEffect , p_stEngineObject);
    h_AnimEffect = fn_h_AnimEffectRealAlloc();
    MMG_fn_vEndMemoryInfo ();
    p_stEngineObject->h_AnimEffect = h_AnimEffect;
 
    SCR_M_RdL0_SetSectionLong(C_ThisSection,0,h_AnimEffect);
  }
  else if (M_IsEntry)
  {
    SCR_M_RdL0_GetSectionLong(C_ThisSection,0,MS_tdxHandleToAnimEffect,h_AnimEffect);
 
    if( M_ActionIs(C_EntryAnimEffectShiftPhase) )
    {
      MTH3D_tdstVector stVector;
      M_CheckScriptParamNumber(3);
      MTH3D_M_vSetVectorElements(
        &stVector,
        fn_fAToF(_ap_szParams[0]),
        fn_fAToF(_ap_szParams[1]),
        fn_fAToF(_ap_szParams[2])
      );
      fn_vAnimEffectSetShiftPhase(h_AnimEffect, stVector);
    }
    else if( M_ActionIs(C_EntryAnimEffectShiftMax) )
    {
      MTH3D_tdstVector stVector;
      M_CheckScriptParamNumber(3);
      MTH3D_M_vSetVectorElements(
        &stVector,
        fn_fAToF(_ap_szParams[0]),
        fn_fAToF(_ap_szParams[1]),
        fn_fAToF(_ap_szParams[2])
      );
      fn_vAnimEffectSetShiftMax(h_AnimEffect, stVector);
    }
    else if( M_ActionIs(C_EntryAnimEffectShiftPlus) )
    {
      MTH3D_tdstVector stVector;
      M_CheckScriptParamNumber(3);
      MTH3D_M_vSetVectorElements(
        &stVector,
        fn_fAToF(_ap_szParams[0]),
        fn_fAToF(_ap_szParams[1]),
        fn_fAToF(_ap_szParams[2])
      );
      fn_vAnimEffectSetShiftPlus(h_AnimEffect, stVector);
    }
  }
  return(eReturnValue);
}
#endif /* GAM_USE_SCRIPT */
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect's save structure
 *-----------------------------------------------------------------------------
 *  Input :         SCR_tdst_File_Description *, struct tdstEngineObject_ *
 *  Output :        Void
 *-----------------------------------------------------------------------------
 *  Creation date : 28/02/97            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
/*
void fn_vAnimEffectSaveMiniStructure(SCR_tdst_File_Description *p_stFile,struct tdstEngineObject_ *p_stObject)
{
 char szSection[SCR_CV_ui_Cfg_MaxLenName];
 MS_tdxHandleToAnimEffect h_AnimEffect = p_stObject->h_AnimEffect;
 
 SCR_M_SvL0_SaveBlankLine(p_stFile);
 SCR_M_SvL0_SaveComment(p_stFile, "**** AnimEffect mini-structure definition ****");
 
 sprintf(szSection,"%s:",C_SectionAnimEffectDescription);
 SCR_M_SvL0_SaveBeginSection(p_stFile,szSection,SCR_CC_C_Cfg_EOL);
 
 // ** Put here the saving script functions **	- Oliv' - Portage v15 - 1 warning removed here
 
 SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL)
}
*/
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect's mini-structure sizeof
 *-----------------------------------------------------------------------------
 *  Input :         None
 *  Output :        Size of
 *-----------------------------------------------------------------------------
 *  Creation date : 14/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
unsigned long fn_ulAnimEffectSizeOf()
{
 return(sizeof(struct tdstAnimEffect_));
}
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect's object action allocation
 *-----------------------------------------------------------------------------
 *  Input :         Object pointer
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vAnimEffectAlloc(struct tdstEngineObject_ *p_stObject)
{
 if (p_stObject==NULL)
  M_GameFatalError(E_uwGameMiniStructObjectNull);
 
 if (p_stObject->h_AnimEffect!=NULL)
  M_GameFatalError(E_uwGameMiniStructAllocAlreadyAlloc);
 
 MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypeAnimEffect , p_stObject);
 p_stObject->h_AnimEffect = fn_h_AnimEffectRealAlloc();
 MMG_fn_vEndMemoryInfo ();
 fn_vAnimEffectInitValueSAI(p_stObject->h_AnimEffect);
}
 
MS_tdxHandleToAnimEffect fn_h_AnimEffectRealAlloc()
{
 MS_tdxHandleToAnimEffect h_AnimEffect;
 MTH3D_tdstVector stVector = { 0.0, 0.0, 0.0 };
 
 h_AnimEffect = (MS_tdxHandleToAnimEffect)M_p_GameMallocInHLM(fn_ulAnimEffectSizeOf());
 fn_vAnimEffectSetShiftPhase(h_AnimEffect, stVector);
 fn_vAnimEffectSetShiftMax(h_AnimEffect, stVector);
 fn_vAnimEffectSetShiftPlus(h_AnimEffect, stVector);
 
 return(h_AnimEffect);
}
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect's object action free
 *-----------------------------------------------------------------------------
 *  Input :         Object pointer
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vAnimEffectFree(struct tdstEngineObject_ *p_stObject)
{
 if (p_stObject==NULL)
  M_GameFatalError(E_uwGameMiniStructObjectNull);
 
 if (p_stObject->h_AnimEffect==NULL)
  M_GameFatalError(E_uwGameMiniStructNull);
 
 fn_vAnimEffectFreeInitValueSAI(p_stObject->h_AnimEffect);
 MMG_fn_vAddMemoryInfo( MMG_C_lTypeMiniStructure , MMG_C_lSubTypeAnimEffect , p_stObject );
 M_GameFreeInHLM(p_stObject->h_AnimEffect);
}
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect's object action initialisation
 *-----------------------------------------------------------------------------
 *  Input :         When this function's called (see ObjInit.h)
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vAnimEffectInit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit)
{
 if (p_stObject==NULL)
  M_GameFatalError(E_uwGameMiniStructObjectNull);
 
 if (p_stObject->h_AnimEffect==NULL)
  M_GameFatalError(E_uwGameMiniStructNull);
 
 switch(eObjectInit)
 {
  case OTI_ReinitTheMap:
   break;
  case OTI_LoadSavedGame:
   break;
  case OTI_MapLoaded:
   break;
  case OTI_PlayerDead:
   break;
	default:
   break;
 }
}
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect's object action desinitialisation
 *-----------------------------------------------------------------------------
 *  Input :         When this function's called (see ObjInit.h)
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vAnimEffectDesinit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit)
{
 if (p_stObject==NULL)
  M_GameFatalError(E_uwGameMiniStructObjectNull);
 
 if (p_stObject->h_AnimEffect==NULL)
  M_GameFatalError(E_uwGameMiniStructNull);
 
 switch(eObjectInit)
 {
  case OTI_ReinitTheMap:
   break;
  case OTI_MapLoaded:
   break;
  case OTI_PlayerDead:
   break;
	default:
   break;
 }
}
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect's object copy clone action
 *-----------------------------------------------------------------------------
 *  Input :         Handle to destination, handle to source
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 30/06/97            Author : Olivier Jourdan
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vAnimEffectCopyClone(struct tdstEngineObject_ * _p_stObjectDest,struct tdstEngineObject_ * _p_stObjectSrc)
{
/* If AnimEffect doesn't contains pointers to structure that may be*/
/* changed during the game, this function must only be a :*/
  memcpy(_p_stObjectDest->h_AnimEffect,_p_stObjectSrc->h_AnimEffect,fn_ulAnimEffectSizeOf());
}
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect access functions
 *-----------------------------------------------------------------------------
 *  Input :         MS_tdxHandleToAnimEffect + (value)
 *  Output :        (value or pointer)
 *-----------------------------------------------------------------------------
 *  Creation date : 29/01/97            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
extern CPA_EXPORT MTH3D_tdstVector fn_stAnimEffectGetShiftPhase(MS_tdxHandleToAnimEffect h_AnimEffect)
{
  return h_AnimEffect->stShiftPhase;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
extern CPA_EXPORT MTH3D_tdstVector fn_stAnimEffectGetShiftMax(MS_tdxHandleToAnimEffect h_AnimEffect)
{
  return h_AnimEffect->stShiftMax;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
extern CPA_EXPORT MTH3D_tdstVector fn_stAnimEffectGetShiftPlus(MS_tdxHandleToAnimEffect h_AnimEffect)
{
  return h_AnimEffect->stShiftPlus;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
extern CPA_EXPORT void fn_vAnimEffectSetShiftPhase(MS_tdxHandleToAnimEffect h_AnimEffect,MTH3D_tdstVector _stVector)
{
  h_AnimEffect->stShiftPhase = _stVector;
}
extern CPA_EXPORT void fn_vAnimEffectSetShiftMax(MS_tdxHandleToAnimEffect h_AnimEffect,MTH3D_tdstVector _stVector)
{
  h_AnimEffect->stShiftMax = _stVector;
}
extern CPA_EXPORT void fn_vAnimEffectSetShiftPlus(MS_tdxHandleToAnimEffect h_AnimEffect,MTH3D_tdstVector _stVector)
{
  h_AnimEffect->stShiftPlus = _stVector;
}
 
/*-----------------------------------------------------------------------------
 *  Description : AnimEffect SAI functions
 *-----------------------------------------------------------------------------
 *  Input :         MS_tdxHandleToAnimEffect + (value)
 *  Output :        (value or pointer)
 *-----------------------------------------------------------------------------
 *  Creation date : 29/01/97            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vAnimEffectInitValueSAI(MS_tdxHandleToAnimEffect h_AnimEffect)
{
 /**** Put here the functions :*/
 /****     SAI_fn_bInsertMTHVectorInTable((void*)&_h_AnimEffect->xxx,SAI_eInitWhenPlayerDead|SAI_eInitWhenReinitTheMap|SAI_eInitWhenMapLoaded);*/
 
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vAnimEffectSavedValueSAI(MS_tdxHandleToAnimEffect h_AnimEffect)
{
 /**** Put here the functions :*/
 /****     SAI_fn_bInsertMTHVectorInTable((void*)&p_AnimEffect->xxx,SAI_eSaveCurrentValue);*/
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
void fn_vAnimEffectFreeInitValueSAI(MS_tdxHandleToAnimEffect h_AnimEffect)
{
 /**** Put here the functions :*/
 /*****/
}
 
/*ENDANNECY BBB 17/10/97 }*/
 
#endif /* D_THROW_ANIM_EFFECT */
