Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
/*=========================================================================
* DspFix.c : Display fix module
* This is a part of the Game project.
*
* Version 1.0
* Creation date 04/05/97
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1997
*=======================================================================*/
#include "ToolsCPA.h"
#include "Options/Options.h"
#include "Macros.h"
#include "Actions/AllActs.h"
#include "Structur/EngMode.h"
#include "Structur/Objects.h"
#include "Structur/ErrGame.h"
#include "MainChar.h"
#include "ChanList.h"
#include "PlayAnim\PlayAnim.h"
#include "DspFix.h"
#include "PRF.h"
/*#include "ago.h"*/
void AGO_vDisplayGAUGES(GLD_tdstViewportAttributes *p_stVpt);
/*extern ACP_tdxBool g_bUseBinaryData;*/
/**************************************************************************/
void fn_vDisplayFix(void)
{
BOOL bEnabledWrite;
#if defined(GAM_VIGNETTE)
if (g_stDisplayVignetteDuringPlaying.bAskToDisplayVignette) {
VIG_fn_vCopyVignetteToBackBuffer(&g_stDisplayVignetteDuringPlaying.stVignette);
}
#endif /* GAM_VIGNETTE */
GLI_ClearZBufferRegion(g_stEngineStructure.stFixViewportAttr.dwLeftInPixForClip,g_stEngineStructure.stFixViewportAttr.dwRightInPixForClip,g_stEngineStructure.stFixViewportAttr.dwTopInPixForClip,g_stEngineStructure.stFixViewportAttr.dwBottomInPixForClip);
GLI_xClearViewingList();
if (!GLD_bRequestWriteToViewport(g_stEngineStructure.hGLDDevice,g_stEngineStructure.hGLDFixViewport, &g_stEngineStructure.stFixViewportAttr, &bEnabledWrite))
M_GameFatalError(E_uwGameCantWriteToViewPort);
PRF_fn_vStopChrono( PRF_C_ulFctDisplaySpecific, PRF_C_pvSendToList );
PRF_fn_vStartChrono( PRF_C_ulFctDisplay, PRF_C_pvMisc );
PRF_fn_vStartChrono( PRF_C_ulFctDisplayCommon, PRF_C_pvSendFix );
GEO_fn_vComputeCameraParametersForCulling( &g_stEngineStructure.stFixViewportAttr, MTH_C_ZERO );
PRF_fn_vStopChrono( PRF_C_ulFctDisplayCommon, PRF_C_pvSendFix );
FPRF_fn_vStopChrono( PRF_C_ulFctDisplay, PRF_C_pvMisc );
PRF_fn_vStartChrono( PRF_C_ulFctDisplaySpecific, PRF_C_pvSendToList );
HIE_fn_bSendSPOToFixViewport ( &g_stEngineStructure.stFixViewportAttr, g_stEngineStructure.ulDisplayMode );
AGO_vDisplayGAUGES( &g_stEngineStructure.stFixViewportAttr );
GLI_xSendListToViewport(&g_stEngineStructure.stFixViewportAttr);
if (!GLD_bWriteToViewportFinished(g_stEngineStructure.hGLDDevice, g_stEngineStructure.hGLDFixViewport))
M_GameFatalError(E_uwGameCantWriteToViewPortFinished);
}
/*************************************************************************/
void fn_vAskToDisplayVignette(char *szName)
{
#if defined(GAM_VIGNETTE)
if (szName) {
g_stDisplayVignetteDuringPlaying.bAskToDisplayVignette = TRUE;
VIG_fn_vPreLoadVignetteInStructure(&g_stDisplayVignetteDuringPlaying.stVignette,szName,GLI_EVF_BGR565_UL);
}
else {
g_stDisplayVignetteDuringPlaying.bAskToDisplayVignette = FALSE;
VIG_fn_vFreeVignette(&g_stDisplayVignetteDuringPlaying.stVignette);
}
#else /* GAM_VIGNETTE */
g_stDisplayVignetteDuringPlaying.bAskToDisplayVignette = FALSE;
#endif /* GAM_VIGNETTE */
}

View File

@@ -0,0 +1,40 @@
/*=========================================================================
* DspFix.c : Display fix module
* This is a part of the Game project.
*
* Version 1.0
* Creation date 04/05/97
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1997
*=======================================================================*/
#if !defined(__DspFix_h__)
#define __DspFix_h__
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
typedef struct tdstDisplayVignetteDuringPlaying_
{
unsigned char bAskToDisplayVignette;
char szName[_MAX_PATH];
#ifdef GAM_VIGNETTE
struct VIG_tdstVignetteStructure_ stVignette;
#endif /* GAM_VIGNETTE */
} tdstDisplayVignetteDuringPlaying;
extern void fn_vAskToDisplayVignette(char *szName);
extern void fn_vDisplayFix(void);
EXTERN tdstDisplayVignetteDuringPlaying g_stDisplayVignetteDuringPlaying;
#if defined(__cplusplus)
}
#endif /* __cplusplus */
#endif /* __DspFix_h__ */

View File

@@ -0,0 +1,702 @@
/*=========================================================================
* GamOpt.c : Game options
* This is a part of the Game project.
*
* Version 1.0
* Creation date 04/05/97
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1997
*=======================================================================*/
#define SCR_DM_OptCFiles
#include "ToolsCPA.h"
#include "Options/Options.h"
#include "Macros.h"
#include "Structur/MemGame.h"
#include "Structur/EngMode.h"
#include "Structur/ErrGame.h"
#include "Structur/GameScpt.h"
#include "Basic.h"
#include "GamOpt.h"
#include "GamSave.h"
#include "micros.h"
#include "Zemem.h"
#include "CMP.h"
/*ANNECY BBB 03/11/97 {*/
tdstGameOptions g_stGameOptions;
/*ENDANNECY BBB 03/11/97 }*/
#ifdef __cplusplus
extern "C" {
#endif
extern signed char g_cJoystickXmin;
extern signed char g_cJoystickXmax;
extern signed char g_cJoystickYmin;
extern signed char g_cJoystickYmax;
#ifndef U64
extern signed char g_cJoystickXcenter;
extern signed char g_cJoystickYcenter;
#endif
#ifdef __cplusplus
}
#endif
/**************** F PEREZ *******************/
extern long g_ucNbSaveGameSlots;
extern char g_a_szSlotNames[4];
extern BOOL fn_bActualizeSlotPos(void);
extern char * fn_bGetStringSlotDate(unsigned long _ulSlotId);
long fn_lGetNbAvailableSlotPc();
long fn_bRecupSlotNum(long lSlotPosId);
BOOL fn_bActualizeSlotListBis(long lNbAvailableSlots);
BOOL fn_bEraseGameInSlotList( long lSlotId);
char * fn_cRecupSlotName(long lSlotId);
long fn_bScanDir( char *p_cDir, BOOL bRecursive);
int fn_iVersionN64_PC(void);
extern StructRecupPosSlot * g_p_LastStructRecupPosSlot;
/****************************************************/
/**************************************************************************/
void fn_vSetDefaultGameOptionsFileName(char *_szFileName)
{
strcpy(g_stGameOptions.szDefaultFileName,_szFileName);
}
/**************************************************************************/
void fn_vSetCurrentGameOptionsFileName(char *_szFileName)
{
strcpy(g_stGameOptions.szCurrentFileName,_szFileName);
}
/**************************************************************************/
unsigned char fn_bSaveCurrentGameOptions(void)
{
unsigned char bReturn = TRUE;
FILE *p_stTempFile;
char szFileName[MAX_PATH];
char szTempFile[_MAX_PATH];
int Version;
#ifndef U64
/*************** FPEREZ ***************/
long lNbSaveGameSlot;
StructRecupPosSlot *p_StructRecupPosSlot;
/*********************************************/
#endif
/*unsigned long lValue;*/
sprintf(szTempFile,"%s/TT.tmp",fn_szGetTempDataPath());
sprintf(szFileName,"%s/%s",fn_szGetOptionsDataPath(),g_stGameOptions.szCurrentFileName);
FIL_fn_bValidatePath(".",szFileName);
remove(szTempFile);
p_stTempFile = fopen(szTempFile,"wb");
if (p_stTempFile!=NULL)
{
long lIndex;
char * szTag = __DATE__ " " __TIME__ ;
/* version that saved the file */
lIndex = strlen ( szTag ) ;
fwrite(&lIndex,1,sizeof(unsigned long),p_stTempFile);
fwrite(szTag,1,lIndex+1,p_stTempFile);
/**** Player name ****/
/*lValue = strlen(g_stGameOptions.szPlayerName);*/
/*fwrite(&lValue,1,sizeof(unsigned long),p_stTempFile);*/
/*fwrite(g_stGameOptions.szPlayerName,lValue,sizeof(char),p_stTempFile);*/
/**** Slot names ****/
/***************** FPEREZ **************************/
#ifndef U64
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if( Version == 1 /* N64 */)
{
for ( lIndex = 0; lIndex < C_ucNbSaveGameSlots; lIndex ++ )
{
fwrite(&g_stGameOptions.a_szSlotNames[lIndex], 1, C_ucSaveGameSlotNameLength + 1, p_stTempFile);
}
}
else if( Version == 2 /* PC */)
{
//lNbSaveGameSlot = fn_lGetNbAvailableSlotsPc();
lNbSaveGameSlot = g_ucNbSaveGameSlots;
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
for ( lIndex = 0; lIndex < lNbSaveGameSlot; lIndex ++ )
{
fwrite( p_StructRecupPosSlot->a_szSlotNames , 1, C_ucSaveGameSlotNameLength + 1, p_stTempFile);
p_StructRecupPosSlot = p_StructRecupPosSlot->pt_NextStructRecupPosSlot;
}
}
#else // PC sans editeur
//lNbSaveGameSlot = fn_lGetNbAvailableSlotsPc();
lNbSaveGameSlot = g_ucNbSaveGameSlots;
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
for ( lIndex = 0; lIndex < lNbSaveGameSlot; lIndex ++ )
{
fwrite( p_StructRecupPosSlot->a_szSlotNames , 1, C_ucSaveGameSlotNameLength + 1, p_stTempFile);
p_StructRecupPosSlot = p_StructRecupPosSlot->pt_NextStructRecupPosSlot;
}
#endif // EDITOR
#else /* U64*/
for ( lIndex = 0; lIndex < C_ucNbSaveGameSlots; lIndex ++ )
{
fwrite(&g_stGameOptions.a_szSlotNames[lIndex], 1, C_ucSaveGameSlotNameLength + 1, p_stTempFile);
}
#endif // U64
/**** Video options ****/
fwrite(&g_stGameOptions.ulDetails,1,sizeof(unsigned long),p_stTempFile);
fwrite(&g_stGameOptions.ulScreenSize,1,sizeof(unsigned long),p_stTempFile);
lIndex = GLI_fn_lGetBrightness() ;
fwrite(&lIndex,1,sizeof(unsigned long),p_stTempFile);
/**** Sound options ****/
fwrite(&g_stGameOptions.ulFxVolume,1,sizeof(unsigned long),p_stTempFile);
fwrite(&g_stGameOptions.ulMusicVolume,1,sizeof(unsigned long),p_stTempFile);
fwrite(&g_stGameOptions.ulVoiceVolume,1,sizeof(unsigned long),p_stTempFile);
#ifdef USE_IPT_DX5
/* Save joystick calibration */
fwrite( &g_cJoystickXmin, sizeof(signed char), 1, p_stTempFile );
fwrite( &g_cJoystickXmax, sizeof(signed char), 1, p_stTempFile );
fwrite( &g_cJoystickYmin, sizeof(signed char), 1, p_stTempFile );
fwrite( &g_cJoystickYmax, sizeof(signed char), 1, p_stTempFile );
#ifndef U64
fwrite( &g_cJoystickXcenter, sizeof(signed char), 1, p_stTempFile );
fwrite( &g_cJoystickYcenter, sizeof(signed char), 1, p_stTempFile );
#endif
#endif
/**** IPT options ****/
IPT_fn_bSaveOptionsInFile(p_stTempFile);
fclose(p_stTempFile);
CMP_fn_vCompressFileIn(szTempFile,szFileName,D_CMP_DIFF);
}
else
bReturn = FALSE;
remove(szTempFile);
return(bReturn);
}
/**************************************************************************/
/* Modif : 25/05/98 Default volume 127 Carlos Torres*/
unsigned char fn_bLoadCurrentGameOptions(void)
{
ACP_tdxBool bReturn = TRUE;
if (!fn_bLoadGameOptions(g_stGameOptions.szCurrentFileName))
{
if (!fn_bLoadDefaultGameOptions())
{
/*fn_vChangePlayerName("NOBODY");*/
bReturn = FALSE;
}
}
/*///////////////////////////////////// en attendant les menus*/
/* default values if no config files:*/
if( !bReturn )
{
long lIndex;
g_stGameOptions.ulFxVolume = 127;
g_stGameOptions.ulVoiceVolume = 127;
g_stGameOptions.ulMusicVolume = 127;
g_stGameOptions.ulDetails = 0;
g_stGameOptions.ulScreenSize = 0;
for ( lIndex = 0; lIndex < C_ucNbSaveGameSlots; lIndex ++ )
{
/* zero-terminated whitespace slot names -> invalid names*/
memset(&g_stGameOptions.a_szSlotNames[lIndex], ' ', C_ucSaveGameSlotNameLength);
g_stGameOptions.a_szSlotNames[lIndex][C_ucSaveGameSlotNameLength] = '\0';
}
}
/*///////////////////////////////////// en attendant les menus*/
return bReturn;
}
/**************************************************************************/
unsigned char fn_bLoadDefaultGameOptions(void)
{
return(fn_bLoadGameOptions(g_stGameOptions.szDefaultFileName));
}
/**************************************************************************/
unsigned char fn_bLoadGameOptions(char *_szFileName)
{
unsigned char bReturn = FALSE;
char szFileName[MAX_PATH];
/*char szTemp[100];*/
FILE *p_stTempFile;
char szTempFile[_MAX_PATH];
int Version;
#ifndef U64
/*************** FPEREZ ***************/
unsigned char a128_cCurrentSlotDir[128];
unsigned char a128_cNextSlotDir[128];
long lNbSaveGameSlot;
StructRecupPosSlot *p_StructRecupPosSlot;
/*********************************************/
#endif
sprintf(szTempFile,"%s/TT.tmp",fn_szGetTempDataPath());
sprintf(szFileName,"%s/%s",fn_szGetOptionsDataPath(),_szFileName);
remove(szTempFile);
if (CMP_fn_bExpandFileIn(szFileName,szTempFile,D_CMP_DIFF))
{
p_stTempFile = fopen(szTempFile,"rb");
if (p_stTempFile!=NULL)
{
long lIndex;
char * szTag = __DATE__ " " __TIME__ , * szTag2 ;
/* version that saved the file */
fread(&lIndex,1,sizeof(unsigned long),p_stTempFile);
szTag2 = alloca(lIndex+1) ;
fread(szTag2,1,lIndex+1,p_stTempFile);
if ( !strcmp(szTag, szTag2) )
{
/**** Player name ****/
/*fread(&lValue,1,sizeof(unsigned long),p_stTempFile);*/
/*fread(szTemp,lValue,sizeof(char),p_stTempFile);*/
/*szTemp[lValue]=0;*/
/*fn_vChangePlayerName(szTemp);*/
/**** Slot names ****/
/***************** FPEREZ **************************/
#ifndef U64
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if( Version == 1 /* N64 */)
{
for ( lIndex = 0; lIndex < C_ucNbSaveGameSlots; lIndex ++ )
{
fread(&g_stGameOptions.a_szSlotNames[lIndex], 1, C_ucSaveGameSlotNameLength + 1, p_stTempFile);
g_stGameOptions.a_szSlotNames[lIndex][C_ucSaveGameSlotNameLength] = '\0'; /* pour assurer*/
}
}
else if( Version == 2 /* PC */)
{
//lNbSaveGameSlot = fn_lGetNbAvailableSlotsPc();
lNbSaveGameSlot = g_ucNbSaveGameSlots;
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
for ( lIndex = 0; lIndex < lNbSaveGameSlot; lIndex ++ )
{
fread( p_StructRecupPosSlot->a_szSlotNames , 1, C_ucSaveGameSlotNameLength + 1, p_stTempFile);
p_StructRecupPosSlot = p_StructRecupPosSlot->pt_NextStructRecupPosSlot;
}
}
#else /* PC sans Editor */
//lNbSaveGameSlot = fn_lGetNbAvailableSlotsPc();
lNbSaveGameSlot = g_ucNbSaveGameSlots;
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
for ( lIndex = 0; lIndex < lNbSaveGameSlot; lIndex ++ )
{
fread( p_StructRecupPosSlot->a_szSlotNames , 1, C_ucSaveGameSlotNameLength + 1, p_stTempFile);
p_StructRecupPosSlot = p_StructRecupPosSlot->pt_NextStructRecupPosSlot;
}
#endif // Editor
#else /* U64*/
for ( lIndex = 0; lIndex < C_ucNbSaveGameSlots; lIndex ++ )
{
fread(&g_stGameOptions.a_szSlotNames[lIndex], 1, C_ucSaveGameSlotNameLength + 1, p_stTempFile);
g_stGameOptions.a_szSlotNames[lIndex][C_ucSaveGameSlotNameLength] = '\0'; /* pour assurer*/
}
#endif //
g_stGameOptions.ulCurrentSlot = 0;
/**** Video options ****/
fread(&g_stGameOptions.ulDetails,1,sizeof(unsigned long),p_stTempFile);
fread(&g_stGameOptions.ulScreenSize,1,sizeof(unsigned long),p_stTempFile);
fread(&lIndex,1,sizeof(unsigned long),p_stTempFile);
GLI_fn_vSetBrightness( lIndex ) ;
/**** Sound options ****/
fread(&g_stGameOptions.ulFxVolume,1,sizeof(unsigned long),p_stTempFile);
fread(&g_stGameOptions.ulMusicVolume,1,sizeof(unsigned long),p_stTempFile);
fread(&g_stGameOptions.ulVoiceVolume,1,sizeof(unsigned long),p_stTempFile);
#ifdef USE_IPT_DX5
/* Read joystick calibration */
fread( &g_cJoystickXmin, sizeof(signed char), 1, p_stTempFile );
fread( &g_cJoystickXmax, sizeof(signed char), 1, p_stTempFile );
fread( &g_cJoystickYmin, sizeof(signed char), 1, p_stTempFile );
fread( &g_cJoystickYmax, sizeof(signed char), 1, p_stTempFile );
#ifndef U64
fread( &g_cJoystickXcenter, sizeof(signed char), 1, p_stTempFile );
fread( &g_cJoystickYcenter, sizeof(signed char), 1, p_stTempFile );
#endif
#endif
/**** IPT options ****/
IPT_fn_bLoadOptionsFromFile(p_stTempFile);
fclose(p_stTempFile);
fn_vValidateAllOption();
bReturn = TRUE;
}
}
}
remove(szTempFile);
return(bReturn);
}
#ifndef U64
//********************** FABPEREZ ************************
long fn_bRecupSlotNum(long lSlotPosId)
{
long lSlotPos = 1;
StructRecupPosSlot *p_CurrentStructRecupPosSlot;
p_CurrentStructRecupPosSlot = g_p_LastStructRecupPosSlot;
while( lSlotPos != lSlotPosId && p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot != NULL)
{
p_CurrentStructRecupPosSlot = p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot;
lSlotPos ++;
}
return p_CurrentStructRecupPosSlot->pos;
}
long fn_bScanDir( char *p_cDir, BOOL bRecursive)
{
struct _finddata_t stFileInfo;
int iHandle;
int i = 0;
long lNbSlotDir = 0;
if ( _chdir(p_cDir) )
return 0 ;
// start scan on directories
iHandle = _findfirst("*.*",&stFileInfo);
if (iHandle == -1)
{
/*if (errno == ENOENT)
{
// no entry... return
return 0;
}
else
{
// real error
sprintf (csText,"error while scanning directories in %s",p_cDir);
MessageBox(NULL,csText,"error",MB_OK );
return -1;
}*/
}
else
{
// file found, loop on all files
do
{
// look if it is a dir
if (stFileInfo.attrib & _A_SUBDIR)
{
if (bRecursive)
{
// directory + recursive, so scan it !
// check if it is not 'this' directory
if (stFileInfo.name[0] != '.')
{
if( strncmp(stFileInfo.name, "Slot", (long) 4) == 0) lNbSlotDir++;
if ( fn_bScanDir( stFileInfo.name, bRecursive) ==-1 )
{
// error !
return -1;
}
else
{
// directory scan successful, come back to current dir
_chdir("..");
}
}
}
}
// loop on find next file
} while (_findnext(iHandle,&stFileInfo) == 0);
// the end, so close handle
_findclose(iHandle);
}
return lNbSlotDir;
}
long fn_lGetNbAvailableSlotsPc()
{
long lNbAvailableSlots = 0;
char a256_cCurDir[255];
int Version =0;
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if ( Version == 0) return 0;
else if ( Version == 1 /* U64 */) return 3;
else if( Version == 2 /* PC */)
{
GetCurrentDirectory( 256, a256_cCurDir);
lNbAvailableSlots = fn_bScanDir( fn_szGetSaveGameDataPath() , TRUE);
SetCurrentDirectory( a256_cCurDir);
fn_bActualizeSlotListBis(lNbAvailableSlots);
}
#else // Version PC Normale
GetCurrentDirectory( 256, a256_cCurDir);
lNbAvailableSlots = fn_bScanDir( fn_szGetSaveGameDataPath() , TRUE);
SetCurrentDirectory( a256_cCurDir);
fn_bActualizeSlotListBis(lNbAvailableSlots);
#endif // ACTIVE_EDITOR
return lNbAvailableSlots;
}
int fn_iVersionN64_PC(void)
{
char a_c255_gsz_Version[255];
FILE *hIni;
int i;
static int Result = 0;
if(Result) return Result;
hIni = fopen("version.ini", "rt");
if(hIni)
{
*a_c255_gsz_Version = '\0';
fgets(a_c255_gsz_Version, 49, hIni);
fclose(hIni);
if( !strnicmp ( a_c255_gsz_Version, "GameDN64", 8) ) Result = 1;
else if ( !strncmp ( a_c255_gsz_Version, "GameDPC", 7) ) Result = 2;
}
return Result;
}
char * fn_cRecupSlotName(long lSlotId)
{
long pos = 1;
StructRecupPosSlot *p_StructRecupPosSlot;
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
while( pos != lSlotId)
{
p_StructRecupPosSlot = p_StructRecupPosSlot->pt_NextStructRecupPosSlot;
pos++;
}
return p_StructRecupPosSlot->a_szSlotNames;
}
BOOL fn_bEraseGameInSlotList( long lSlotId)
{
StructRecupPosSlot *p_CurrentStructRecupPosSlotTmp;
StructRecupPosSlot *p_CurrentStructRecupPosSlot;
int Num = 0;
BOOL Result = TRUE;
// Arret de la recherche sur le slot precedent celui qui va etre effac<61> dans la liste de slot
if( lSlotId > 1)
{
p_CurrentStructRecupPosSlot = g_p_LastStructRecupPosSlot;
p_CurrentStructRecupPosSlotTmp = g_p_LastStructRecupPosSlot;
while( Num != lSlotId-1 && p_CurrentStructRecupPosSlot != NULL)
{
p_CurrentStructRecupPosSlotTmp = p_CurrentStructRecupPosSlot;
p_CurrentStructRecupPosSlot = p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot;
Num++;
}
p_CurrentStructRecupPosSlotTmp->pt_NextStructRecupPosSlot = p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot;
TMP_M_Free(p_CurrentStructRecupPosSlot);
}
else
{
p_CurrentStructRecupPosSlotTmp = g_p_LastStructRecupPosSlot;
TMP_M_Free(g_p_LastStructRecupPosSlot);
g_p_LastStructRecupPosSlot = p_CurrentStructRecupPosSlotTmp->pt_NextStructRecupPosSlot;
}
g_ucNbSaveGameSlots--;
return Result;
}
BOOL fn_bActualizeSlotListBis(long lNbAvailableSlots)
{
StructRecupPosSlot *p_StructRecupPosSlot;
BOOL bResult = FALSE;
if( lNbAvailableSlots != g_ucNbSaveGameSlots )
{
while (lNbAvailableSlots != g_ucNbSaveGameSlots)
{
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
g_p_LastStructRecupPosSlot = (StructRecupPosSlot *) TMP_M_p_Malloc( sizeof(StructRecupPosSlot) );
g_p_LastStructRecupPosSlot->pt_NextStructRecupPosSlot = p_StructRecupPosSlot;
g_p_LastStructRecupPosSlot->pos = ++g_ucNbSaveGameSlots;
strncpy( g_p_LastStructRecupPosSlot->a_szSlotNames, g_a_szSlotNames, 3);
strcpy( g_p_LastStructRecupPosSlot->a_szOldSlotNames, "\\");
}
bResult = fn_bActualizeSlotPos();
}
return bResult;
}
#endif // ! U64
/******************** F PEREZ ********************/
/* FBF {*/
/*
//************************************************************************
void fn_vMenuOptionInitDetails(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
MNU_fn_bSetValue(hMenuItem->uItem.hSlider,(short)g_stGameOptions.ulDetails);
}
//************************************************************************
void fn_vMenuOptionChangeDetailsValue(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
fn_vChangeDetailsValue(MNU_fn_lGetValue(hMenuItem->uItem.hSlider));
}
//************************************************************************
void fn_vMenuOptionInitScreenSize(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
MNU_fn_bSetValue(hMenuItem->uItem.hSlider,(short)g_stGameOptions.ulScreenSize);
}
//************************************************************************
void fn_vMenuOptionChangeScreenSizeValue(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
//ANNECY CB
//fn_vChangeScreenSizeValue(MNU_fn_lGetValue(hMenuItem->uItem.hSlider));
//ENDANNECY
}
//************************************************************************
void fn_vMenuOptionInitMusicVolume(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
MNU_fn_bSetValue(hMenuItem->uItem.hSlider,(short)g_stGameOptions.ulMusicVolume);
}
//************************************************************************
void fn_vMenuOptionChangeMusicVolumeValue(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
fn_vChangeMusicVolumeValue(MNU_fn_lGetValue(hMenuItem->uItem.hSlider));
}
//************************************************************************
void fn_vMenuOptionInitFxVolume(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
MNU_fn_bSetValue(hMenuItem->uItem.hSlider,(short)g_stGameOptions.ulFxVolume);
}
//************************************************************************
void fn_vMenuOptionChangeFxVolumeValue(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
fn_vChangeFxVolumeValue(MNU_fn_lGetValue(hMenuItem->uItem.hSlider));
}
//************************************************************************
void fn_vMenuOptionInitVoiceVolume(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
MNU_fn_bSetValue(hMenuItem->uItem.hSlider,(short)g_stGameOptions.ulVoiceVolume);
}
//************************************************************************
void fn_vMenuOptionChangeVoiceVolumeValue(struct MNU_stMenuItem_ *hMenuItem,char *szText[])
{
fn_vChangeVoiceVolumeValue(MNU_fn_lGetValue(hMenuItem->uItem.hSlider));
}
*/
/* FBF }*/
/**************************************************************************/
/**************************************************************************/
void fn_vValidateAllOption(void)
{
/**** Video options ****/
fn_vChangeDetailsValue(g_stGameOptions.ulDetails);
/*ANNECY CB*/
/* fn_vChangeScreenSizeValue(g_stGameOptions.ulScreenSize);*/
/*END ANNECY*/
/**** Sound options ****/
fn_vChangeMusicVolumeValue(g_stGameOptions.ulMusicVolume);
fn_vChangeFxVolumeValue(g_stGameOptions.ulFxVolume);
#ifdef D_USE_LIPSYNC
fn_vChangeVoiceVolumeValue(g_stGameOptions.ulVoiceVolume);
#endif
}
/**************************************************************************/
/*void fn_vChangePlayerName(char *_szName)
{
GAM_fn_vSetPlayerName(_szName);
}*/
/**************************************************************************/
void fn_vChangeDetailsValue(unsigned long _ulValue)
{
g_stGameOptions.ulDetails = _ulValue;
}
/**************************************************************************/
void fn_vChangeScreenSizeValue(unsigned long _ulValue)
{
/*ANNECY CB*/
#if 0
_ulValue = max(60,min(100,_ulValue));
g_stGameOptions.ulScreenSize = _ulValue;
fn_vChangeViewPortSize(g_stGameOptions.ulScreenSize);
#endif
/*ENDANNECY*/
}
/**************************************************************************/
void fn_vChangeMusicVolumeValue(unsigned long _ulValue)
{
_ulValue = max(0,min(127,_ulValue));
g_stGameOptions.ulMusicVolume = _ulValue;
SND_fn_vSetVolumeLineSound(g_lSoundVolumeLineMusic,g_stGameOptions.ulMusicVolume);
}
/**************************************************************************/
void fn_vChangeFxVolumeValue(unsigned long _ulValue)
{
_ulValue = max(0,min(127,_ulValue));
g_stGameOptions.ulFxVolume = _ulValue;
SND_fn_vSetVolumeLineSound(g_lSoundVolumeLineSound ,g_stGameOptions.ulFxVolume);
}
/**************************************************************************/
#ifdef D_USE_LIPSYNC
void fn_vChangeVoiceVolumeValue(unsigned long _ulValue)
{
_ulValue = max(0,min(127,_ulValue));
g_stGameOptions.ulVoiceVolume = _ulValue;
SND_fn_vSetVolumeLineSound(g_lSoundVolumeLineVoices ,g_stGameOptions.ulVoiceVolume);
}
#endif D_USE_LIPSYNC
/**************************************************************************/
unsigned long fn_ulGetTrameNumber(void) {
return( g_stEngineStructure.stEngineTimer.ulTrameNumber) ;
}

View File

@@ -0,0 +1,829 @@
/*=========================================================================
* GamSave.c : Game save
* This is a part of the Game project.
*
* Version 1.0
* Creation date 03/07/97
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1997
*=======================================================================*/
#define SCR_DM_OptCFiles
#define D_FIL_StructureDefine
#include "ToolsCPA.h"
#include "Options/Options.h"
#include "Macros.h"
#include "Actions/AllActs.h"
#include "Structur/3DOSLktb.h"
#include "Structur/EngMode.h"
#include "Structur/StdObjSt.h"
#include "Structur/Objects.h"
#include "Structur/GameScpt.h"
#include "Structur/ErrGame.h"
#include "Structur/MemGame.h"
#include "gamopt.h"
#include "PlayAnim/PlayAnim.h"
#include "Always.h"
#include "Basic.h"
#include "DspFix.h"
#include "GameEng.h"
#include "GamSave.h"
#include "LoadLvl.h"
#include "ObjInit.h"
#include "ObjType.h"
#include "Zemem.h"
#include "CMP.h"
extern unsigned char FIL_fn_bIsValidPath(char *_szFileName);
const char *g_c_szSlotNames[] = /*extern declared in GamSave.h*/
{
"HiddenSlot",
"Slot1",
"Slot2",
"Slot3"
};
#ifndef U64
/************ FabPerez ***************/
#include <time.h>
#define _MAX_PATH_DIR 128
unsigned char g_ucNbSaveGameSlots = 0;
BOOL g_bIsGameAlreadyExist = FALSE;
//extern StructRecupPosSlot * g_p_LastStructRecupPosSlot;
StructRecupPosSlot * g_p_LastStructRecupPosSlot = NULL;
char g_a_szSlotNames[4] = "\\";
char * fn_bGetStringSlotDate(unsigned long _ulSlotId);
ACP_tdxBool fn_bActualizeSlotList( char *szDstPath, unsigned long _ulSlotId);
ACP_tdxBool fn_bActualizeSlotPos(void);
ACP_tdxBool fn_bCreateSlotDir( char *szDstPath, unsigned long _ulSlotId);
int fn_iCompareSlotDate(unsigned char * CurrentSlotDir, unsigned char * NextSlotDir);
BOOL fn_bGetSlotDate( unsigned char * SlotDate, unsigned long _ulSlotId);
extern int fn_iVersionN64_PC(void);
extern long fn_bRecupSlotNum(long lSlotPosId);
/*************** EndFabPerez **************/
#endif
unsigned char GAM_g_ucSaveGameBeforeChangeLevel = 1;
/**************************************************************************/
unsigned char fn_bPlayerSaveGameAll(void)
{
unsigned char bReturn = TRUE;
char szFileNameGeneral[_MAX_PATH]/*,szFileNameLevel[_MAX_PATH]*/;
sprintf(szFileNameGeneral,"%s\\%s\\General.sav",fn_szGetSaveGameDataPath(),g_c_szSlotNames[0]); /* save in hidden slot*/
bReturn = fn_bPlayerSaveGameGeneral(szFileNameGeneral);
return(bReturn);
}
/**************************************************************************/
unsigned char fn_bLevelSaveGameAll(void)
{
unsigned char bReturn = TRUE;
char szFileName[_MAX_PATH];
sprintf(szFileName,"%s\\%s\\%s_%d.sav",fn_szGetSaveGameDataPath(),g_c_szSlotNames[0],fn_p_szGetLevelName(), GAM_M_GetSubMap(fn_lGetSubMapNumber()));
bReturn = fn_bLevelSaveGameItSelf(szFileName);
return(bReturn);
}
/**************************************************************************/
unsigned char fn_bPlayerSaveGameGeneral(char *_szFileName)
{
return(SAI_fn_ucPlayerSaveValues(_szFileName));
}
/**************************************************************************/
unsigned char fn_bLevelSaveGameItSelf(char *_szFileName)
{
return(SAI_fn_ucLevelSaveValues(_szFileName));
}
/**************************************************************************/
unsigned char fn_bLoadPlayerSaveGameAfterLoadLevel(void)
{
unsigned char bReturn = FALSE;
char szFileName[_MAX_PATH];
sprintf(szFileName,"%s\\%s\\General.sav",fn_szGetSaveGameDataPath(),g_c_szSlotNames[0]); /* save in hidden slot*/
if (SCR_fn_c_RdL0_IsSectionExists(szFileName))
{
/*SAI_fn_ucLoadValues(szFileName);*/
SAI_fn_ucLoadPlayerValues( szFileName );
/* fn_vGameTestMemory();*/
bReturn = TRUE;
}
return(bReturn);
}
/**************************************************************************/
unsigned char fn_bLoadLevelSaveGameAfterLoadLevel(void)
{
unsigned char bReturn = FALSE;
char szFileName[_MAX_PATH];
sprintf(szFileName,"%s\\%s\\%s_%d.sav",fn_szGetSaveGameDataPath(),g_c_szSlotNames[0],fn_p_szGetLevelName(), GAM_M_GetSubMap(fn_lGetSubMapNumber()));
if (SCR_fn_c_RdL0_IsSectionExists(szFileName))
{
/*SAI_fn_ucLoadValues(szFileName);*/
SAI_fn_ucLoadLevelValues( szFileName );
/* fn_vGameTestMemory();*/
bReturn = TRUE;
}
return(bReturn);
}
/**************************************************************************/
ACP_tdxBool fn_bRenameSaveGameSlot(char *_szOldName, char *_szNewName)
{
ACP_tdxBool bReturn = FALSE;
char szOldFileName[_MAX_PATH], szNewFileName[_MAX_PATH];
sprintf(szOldFileName,"%s\\%s",fn_szGetSaveGameDataPath(), _szOldName);
if ( FIL_fn_bIsValidPath(szOldFileName) )
{
sprintf(szNewFileName,"%s\\%s",fn_szGetSaveGameDataPath(), _szNewName);
bReturn = (unsigned char)MoveFile(szOldFileName, szNewFileName);
}
return bReturn;
}
/**************************************************************************/
unsigned char fn_bDestroySavedGame(unsigned long _ulSlotId)
{
unsigned char bReturn = FALSE;
char szFileName[_MAX_PATH];
int Version;
#ifdef U64
if ( !((_ulSlotId >= 1) && (_ulSlotId <= C_ucNbSaveGameSlots)) ) return bReturn;
sprintf(szFileName,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
#else // PC
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if ( Version == 1 /* U64 */)
{
if ( !((_ulSlotId >= 1) && (_ulSlotId <= C_ucNbSaveGameSlots)) ) return bReturn;
sprintf(szFileName,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
}
else if( Version == 2 /* PC */)
{
if( _ulSlotId == 0) sprintf(szFileName,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
else
{
if ( !((_ulSlotId >= 1) && (_ulSlotId <= g_ucNbSaveGameSlots)) ) return bReturn;;
if( !fn_bCreateSlotDir(szFileName, _ulSlotId) ) return FALSE; // Fct PC
}
}
#else // PC sans editeur
if( _ulSlotId == 0) sprintf(szFileName,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
else
{
if ( !((_ulSlotId >= 1) && (_ulSlotId <= g_ucNbSaveGameSlots)) ) return bReturn;;
if( !fn_bCreateSlotDir(szFileName, _ulSlotId) ) return FALSE; // Fct PC
}
#endif // EDITOR
#endif // U64
bReturn = FIL_fn_bDestroyFileOrDirectory(szFileName);
return(bReturn);
}
/**************************************************************************/
/*
----------------------------------------------------------------------------------------
Description : copy directory
Returns (BOOL ) true if success
----------------------------------------------------------------------------------------
*/
BOOL fn_bCopyDirectory(char * _szSrcDir, char * _szDestDir)
{
WIN32_FIND_DATA stFindData;
HANDLE hFind;
char szSrcDir[255];
char szDestDir[255];
char *p_szEndSource;
char *p_szEndTarget;
strcpy(szSrcDir,_szSrcDir);
strcpy(szDestDir,_szDestDir);
p_szEndSource = szSrcDir + strlen( szSrcDir );
p_szEndTarget = szDestDir + strlen( szDestDir );
strcpy( p_szEndSource, "\\*.*" );
if( (hFind = FindFirstFile(szSrcDir, &stFindData )) == INVALID_HANDLE_VALUE)
return FALSE;
do
{
*p_szEndTarget = *p_szEndSource = '\\';
if ( !(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
strcpy( p_szEndSource + 1, stFindData.cFileName );
strcpy( p_szEndTarget + 1, stFindData.cFileName );
if ( !CopyFile( szSrcDir, szDestDir, FALSE ) )
return FALSE;
}
*p_szEndSource = *p_szEndTarget = 0;
} while(FindNextFile( hFind, &stFindData ));
FindClose( hFind );
return TRUE;
}
/**************************************************************************/
/* Delete all files and sub dirs in a directory but not the dir itself (recursive).*/
/* Return TRUE on success or FALSE on error.*/
BOOL fn_bDeleteDirectoryContent( char * _szDir )
{
WIN32_FIND_DATA stFindData;
HANDLE hFind;
char szDir[255];
char *p_szEndString;
strcpy(szDir,_szDir);
p_szEndString = szDir + strlen( szDir );
if( *(p_szEndString-1) == '\\' )
*(p_szEndString-1) = 0;
strcpy( p_szEndString, "\\*.*" );
if( (hFind = FindFirstFile(szDir, &stFindData )) == INVALID_HANDLE_VALUE)
/* Dir does not exist or is empty, return TRUE.*/
return TRUE;
do
{
if ( !(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
strcpy( p_szEndString + 1, stFindData.cFileName );
if ( !DeleteFile( szDir ) )
/* Error deleting file, return FALSE*/
return FALSE;
}
else
if( strcmp(stFindData.cFileName,".") && strcmp(stFindData.cFileName,"..") )
{
strcpy( p_szEndString + 1, stFindData.cFileName );
if( !fn_bDeleteDirectoryContent( szDir ) )
/* Error deleting files in subdir, return FALSE*/
return FALSE;
RemoveDirectory( szDir );
}
} while(FindNextFile( hFind, &stFindData ));
FindClose( hFind );
return TRUE;
}
BOOL fn_bDeleteDirectory( char * _szDir )
{
WIN32_FIND_DATA stFindData;
HANDLE hFind;
char szDir[255];
char *p_szEndString;
strcpy(szDir,_szDir);
/*
p_szEndString = szDir + strlen( szDir );
if( *(p_szEndString-1) == '\\' )
*(p_szEndString-1) = 0;
strcpy( p_szEndString, "\\*.*" );
*/
if( (hFind = FindFirstFile(szDir, &stFindData )) == INVALID_HANDLE_VALUE)
// Dir does not exist or is empty, return TRUE.
return TRUE;
if ( !(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
strcpy( p_szEndString + 1, stFindData.cFileName );
if ( !DeleteFile( szDir ) )
/* Error deleting file, return FALSE*/
return FALSE;
}
FindClose( hFind );
return TRUE;
}
/**************************************************************************/
ACP_tdxBool fn_bSaveGameInSlot(unsigned long _ulSlotId)
{
unsigned char bReturn = FALSE;
char szSrcPath[_MAX_PATH], szDstPath[_MAX_PATH];
int Version;
#ifndef U64
StructRecupPosSlot *p_CurrentStructRecupPosSlot;
int iNum = 1;
#endif // U64
/* if the slot name is valid*/
#ifdef U64
if ( !( ((_ulSlotId >= 1) && (_ulSlotId <= C_ucNbSaveGameSlots)) && GAM_fn_bIsSlotNameValid(g_c_szSlotNames[_ulSlotId]) ) ) return bReturn;
#else // PC
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if( Version == 1 /* N64 */)
{
if ( !( ((_ulSlotId >= 1) && (_ulSlotId <= C_ucNbSaveGameSlots)) && GAM_fn_bIsSlotNameValid(g_c_szSlotNames[_ulSlotId]) ) ) return bReturn;
}
else if( Version == 2 /* PC */)
{
//if( _ulSlotId > g_ucNbSaveGameSlots ) _ulSlotId = g_ucNbSaveGameSlots;
if ( !((_ulSlotId >= 1) && (_ulSlotId <= g_ucNbSaveGameSlots)) ) return bReturn;
}
#else // PC sans editeur
//if( _ulSlotId > g_ucNbSaveGameSlots ) _ulSlotId = g_ucNbSaveGameSlots;
if ( !((_ulSlotId >= 1) && (_ulSlotId <= g_ucNbSaveGameSlots)) ) return bReturn;
#endif // EDITOR
#endif // U64
sprintf(szSrcPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[0]);
/*make sure the source (the hidden slot) exists*/
if ( FIL_fn_bIsValidPath(szSrcPath) )
{
#ifndef U64
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if( Version == 1 /* N64 */)
{
sprintf(szDstPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
}
else if( Version == 2 /* PC */)
{
p_CurrentStructRecupPosSlot = g_p_LastStructRecupPosSlot;
while( iNum != _ulSlotId && g_bIsGameAlreadyExist)
{
p_CurrentStructRecupPosSlot = p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot;
iNum++;
}
_ulSlotId = p_CurrentStructRecupPosSlot->pos;
if( !fn_bCreateSlotDir(szDstPath, _ulSlotId) ) return FALSE; // Fct PC
}
#else // PC sans editeur
p_CurrentStructRecupPosSlot = g_p_LastStructRecupPosSlot;
while( iNum != _ulSlotId && g_bIsGameAlreadyExist)
{
p_CurrentStructRecupPosSlot = p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot;
iNum++;
}
_ulSlotId = p_CurrentStructRecupPosSlot->pos;
if( !fn_bCreateSlotDir(szDstPath, _ulSlotId) ) return FALSE; // Fct PC
#endif // EDITOR
#else // N64
sprintf(szDstPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
#endif // U64
/*make sure the destination is cleaned*/
/* if ( FIL_fn_bDestroyFileOrDirectory(szDstPath) )*/
if ( fn_bDeleteDirectoryContent(szDstPath) )
{
/* create the path to the destination if */
FIL_fn_bValidatePath(szDstPath, "");
/* now copy the contents of the source in the destination, replacing existing files*/
bReturn = fn_bCopyDirectory(szSrcPath, szDstPath);
#ifndef U64
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if( Version == 2 /* PC */) bReturn = fn_bActualizeSlotList(szDstPath, _ulSlotId);
#else // PC sans editeur
bReturn = fn_bActualizeSlotList(szDstPath, _ulSlotId);
#endif // EDITOR
#endif N64
}
#ifndef U64
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if( Version == 2 /* PC */) fn_bSaveCurrentGameOptions();
#else // PC sans editeur
fn_bSaveCurrentGameOptions();
#endif // EDITOR
#endif // U64
}
return(bReturn);
}
/********************************** FabPerez *********************************/
ACP_tdxBool fn_bCreateSlotDir(char *szDstPath, unsigned long _ulSlotId)
{
unsigned char a_cSlotNameDir[_MAX_PATH_DIR] ;
sprintf(a_cSlotNameDir,"%s\\%s%i", fn_szGetSaveGameDataPath(), "Slot", _ulSlotId);
if( strlen(a_cSlotNameDir) > _MAX_PATH_DIR) return FALSE;
else strcpy(szDstPath, a_cSlotNameDir);
return TRUE;
}
ACP_tdxBool fn_bActualizeSlotList( char *szDstPath, unsigned long _ulSlotId)
{
unsigned char a_cSlotNameDir[_MAX_PATH_DIR] ;
unsigned char a_cSlotNameNb[5] = "Slot";
struct StructRecupPosSlot *p_StructRecupPosSlot;
//SAF_M_AssertWithMsg((_ulSlotId >= 1 && _ulSlotId <= g_ucNbSaveGameSlots ),"Slot inexistant");
if( _ulSlotId >=1 && _ulSlotId <= g_ucNbSaveGameSlots) // Slot existe deja
{
fn_bActualizeSlotPos();
}
else // Nouveau Slot
{
if(g_p_LastStructRecupPosSlot != NULL)
{
p_StructRecupPosSlot = g_p_LastStructRecupPosSlot;
g_p_LastStructRecupPosSlot = TMP_M_p_Malloc( sizeof(StructRecupPosSlot) );
g_p_LastStructRecupPosSlot->pt_NextStructRecupPosSlot = p_StructRecupPosSlot;
g_p_LastStructRecupPosSlot->pos = ++g_ucNbSaveGameSlots;
}
}
strncpy( g_p_LastStructRecupPosSlot->a_szSlotNames, g_a_szSlotNames, 3);
strcpy( g_p_LastStructRecupPosSlot->a_szOldSlotNames, "\\");
return TRUE;
}
ACP_tdxBool fn_bActualizeSlotPos(void)
{
int i, j;
BOOL INVERT;
StructRecupPosSlot * p_CurrentStructRecupPosSlot;
StructRecupPosSlot * p_NextStructRecupPosSlot;
unsigned char a128_cCurrentSlotDir[128];
unsigned char a128_cNextSlotDir[128];
char a_c4TmpName[C_ucSaveGameSlotNameLength + 1];
char a_c4TmpOldName[C_ucSaveGameSlotNameLength + 1];
long TmpPos;
i = 0;
INVERT =TRUE;
while( i < g_ucNbSaveGameSlots && INVERT )
{
INVERT = FALSE;
for( j = g_ucNbSaveGameSlots-1 ; j > i ; j--)
{
if( j == g_ucNbSaveGameSlots-1) // Debut en haut de pile
{
p_CurrentStructRecupPosSlot= g_p_LastStructRecupPosSlot->pt_NextStructRecupPosSlot;
p_NextStructRecupPosSlot = g_p_LastStructRecupPosSlot;
}
else // Suite de la liste
{
p_NextStructRecupPosSlot = p_CurrentStructRecupPosSlot;
p_CurrentStructRecupPosSlot = p_NextStructRecupPosSlot->pt_NextStructRecupPosSlot;
}
sprintf( a128_cCurrentSlotDir, "%s\\%s%i", fn_szGetSaveGameDataPath(),"Slot", p_CurrentStructRecupPosSlot->pos);
sprintf( a128_cNextSlotDir, "%s\\%s%i", fn_szGetSaveGameDataPath(),"Slot", p_NextStructRecupPosSlot->pos);
if( fn_iCompareSlotDate(a128_cCurrentSlotDir, a128_cNextSlotDir) )
{
INVERT =TRUE;
TmpPos = p_CurrentStructRecupPosSlot->pos;
strcpy( a_c4TmpName, p_CurrentStructRecupPosSlot->a_szSlotNames);
strcpy( a_c4TmpOldName, p_CurrentStructRecupPosSlot->a_szOldSlotNames);
p_CurrentStructRecupPosSlot->pos = p_NextStructRecupPosSlot->pos;
strcpy(p_CurrentStructRecupPosSlot->a_szSlotNames, p_NextStructRecupPosSlot->a_szSlotNames);
p_NextStructRecupPosSlot->pos = TmpPos;
strcpy( p_NextStructRecupPosSlot->a_szSlotNames, a_c4TmpName);
strcpy( p_NextStructRecupPosSlot->a_szOldSlotNames, a_c4TmpOldName);
} // If
} // For
i++;
} // While
return 1;
}
int fn_iCompareSlotDate(unsigned char * CurrentSlotDir, unsigned char * NextSlotDir)
{
struct _finddata_t c_file_currentslot, c_file_nextslot;
long hFileCurrentSlot, hFileNextSlot;
unsigned char a128_cTextTmp[128];
double fDiffSeconde;
if( (hFileCurrentSlot = _findfirst( CurrentSlotDir, &c_file_currentslot)) == -1L)
{
sprintf(a128_cTextTmp, "Erreur : impossible de lire la date de creation du repertoire : %s", CurrentSlotDir);
if(MessageBox(NULL, a128_cTextTmp, NULL, MB_RETRYCANCEL) != IDRETRY) return -1;
else fn_iCompareSlotDate(CurrentSlotDir, NextSlotDir);
}
else
{
if( (c_file_currentslot.attrib & _A_RDONLY) == _A_RDONLY) _chmod( CurrentSlotDir, _S_IREAD | _S_IWRITE );
if( (hFileNextSlot = _findfirst( NextSlotDir, &c_file_nextslot)) == -1L)
{
sprintf(a128_cTextTmp, "Erreur : impossible de lire la date de creation du repertoire : %s", NextSlotDir);
if(MessageBox(NULL, a128_cTextTmp, NULL, MB_RETRYCANCEL) != IDRETRY) return -1;
else fn_iCompareSlotDate(CurrentSlotDir, NextSlotDir);
}
else
{
fDiffSeconde = difftime( c_file_currentslot.time_write, c_file_nextslot.time_write);
if( fDiffSeconde <= 0) return 0;
}
}
_findclose( hFileCurrentSlot );
_findclose( hFileNextSlot );
return 1;
}
BOOL fn_bGetSlotDate( unsigned char * SlotDate, unsigned long _ulSlotId)
{
struct _finddata_t c_file_slot;
struct tm *Date;
long hFileSlot;
unsigned char a128_cSlotDir[128];
unsigned char a128_cTextTmp[128];
BOOL bReturn = TRUE;
if( !fn_bCreateSlotDir( a128_cSlotDir, _ulSlotId) ) return FALSE;
sprintf(a128_cSlotDir, "%s\\%s", a128_cSlotDir, "general.sav");
if( (hFileSlot = _findfirst( a128_cSlotDir, &c_file_slot)) == -1L)
{
sprintf(a128_cTextTmp, "Erreur : impossible de lire la date de creation du repertoire : %s", a128_cSlotDir);
if(MessageBox(NULL, a128_cTextTmp, NULL, MB_RETRYCANCEL) != IDRETRY) return FALSE;
else fn_bGetSlotDate(a128_cSlotDir, _ulSlotId);
}
else
{
if( (c_file_slot.attrib & _A_RDONLY) == _A_RDONLY) _chmod( a128_cSlotDir, _S_IREAD | _S_IWRITE );
Date = localtime( &c_file_slot.time_write );
sprintf(SlotDate, "%i/%i %i:%i", Date->tm_mday, Date->tm_mon, Date->tm_hour, Date->tm_min);
}
_findclose( hFileSlot );
return(bReturn);
}
char * fn_bGetStringSlotDate(unsigned long _ulSlotId)
{
struct _finddata_t c_file_slot;
struct tm *Date;
long hFileSlot;
unsigned char a128_cSlotDir[128];
unsigned char a128_cTextTmp[128];
char * tmp = NULL;
if( !fn_bCreateSlotDir( a128_cSlotDir, _ulSlotId) ) return tmp;
sprintf(a128_cSlotDir, "%s\\%s", a128_cSlotDir, "general.sav");
if( (hFileSlot = _findfirst( a128_cSlotDir, &c_file_slot)) == -1L)
{
sprintf(a128_cTextTmp, "Erreur : impossible de lire la date de creation du repertoire : %s", a128_cSlotDir);
if(MessageBox(NULL, a128_cTextTmp, NULL, MB_RETRYCANCEL) != IDRETRY) return tmp;
else fn_bGetSlotDate(a128_cSlotDir, _ulSlotId);
}
else
{
if( (c_file_slot.attrib & _A_RDONLY) == _A_RDONLY) _chmod( a128_cSlotDir, _S_IREAD | _S_IWRITE );
Date = localtime( &c_file_slot.time_write );
sprintf(a128_cSlotDir, "%i.%i %i.%i", Date->tm_mday, Date->tm_mon+1, Date->tm_hour, Date->tm_min);
}
_findclose( hFileSlot );
return(tmp = a128_cSlotDir);
}
/******************************* Fin FabPerez *********************************/
/**************************************************************************/
ACP_tdxBool fn_bIsSlotOccupied(unsigned long _ulSlotId)
{
unsigned char bReturn = FALSE;
char szSrcPath[_MAX_PATH];
int Version;
/* Also test for slot 0 (AI can delete hidden slot) */
#ifdef U64
if ( !((_ulSlotId >= 1) && (_ulSlotId <= C_ucNbSaveGameSlots)) ) return bReturn;
sprintf(szSrcPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
#else // PC
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if( Version == 1 /* N64 */)
{
if ( !((_ulSlotId >= 1) && (_ulSlotId <= C_ucNbSaveGameSlots)) ) return bReturn;
sprintf(szSrcPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
}
else if( Version == 2 /* PC */)
{
if ( !((_ulSlotId >= 1) && (_ulSlotId <= g_ucNbSaveGameSlots)) ) return bReturn;
sprintf(szSrcPath,"%s\\Slot%i",fn_szGetSaveGameDataPath(), fn_bRecupSlotNum(_ulSlotId) );
}
#else // PC sans editeur
if ( !((_ulSlotId >= 1) && (_ulSlotId <= g_ucNbSaveGameSlots)) ) return bReturn;
sprintf(szSrcPath,"%s\\Slot%i",fn_szGetSaveGameDataPath(), fn_bRecupSlotNum(_ulSlotId) );
#endif // EDITOR
#endif // U64
bReturn = (unsigned char) FIL_fn_bIsValidPath(szSrcPath);
return bReturn;
}
/**************************************************************************/
/* move the contents of a registered slot to the hidden slot (where the data will be read when the engine initializes)*/
ACP_tdxBool fn_bLoadGameFromSlot(unsigned long _ulSlotId)
{
unsigned char bReturn = FALSE;
int Version;
if ( fn_bIsSlotOccupied (_ulSlotId) )
{
char szSrcPath[_MAX_PATH], szDstPath[_MAX_PATH];
#ifdef U64
sprintf(szSrcPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
#else // PC
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if ( Version == 1 /* U64 */)
{
sprintf(szSrcPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
}
else if( Version == 2 /* PC */)
{
sprintf(szSrcPath,"%s\\Slot%i",fn_szGetSaveGameDataPath(), fn_bRecupSlotNum( _ulSlotId) );
}
#else // PC sans editeur
sprintf(szSrcPath,"%s\\Slot%i",fn_szGetSaveGameDataPath(), fn_bRecupSlotNum( _ulSlotId) );
#endif // EDITOR
#endif // U64
/*make sure the source exists*/
sprintf(szDstPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[0]);
/*make sure the destination is cleaned*/
/* if ( FIL_fn_bDestroyFileOrDirectory(szDstPath) )*/
if ( fn_bDeleteDirectoryContent(szDstPath) )
{
/* create the path to the destination if necessary*/
FIL_fn_bValidatePath(szDstPath, "");
/* now copy the contents of the source in the destination, replacing existing files*/
bReturn = fn_bCopyDirectory(szSrcPath, szDstPath);
}
}
/* Next time we change level, don't save the current game.*/
GAM_g_ucSaveGameBeforeChangeLevel = 0;
return bReturn;
}
/**************************************************************************/
/*erase the contents of the specified slot*/
ACP_tdxBool fn_bEraseGameInSlot(unsigned long _ulSlotId)
{
unsigned char bReturn = TRUE; /*if the slot is already empty, the function is successful*/
int Version;
if ( fn_bIsSlotOccupied(_ulSlotId) )
{
char szPath[_MAX_PATH];
#ifdef U64
sprintf(szPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
bReturn = FIL_fn_bDestroyFileOrDirectory(szPath);
#else /* PC*/
#ifdef ACTIVE_EDITOR
Version = fn_iVersionN64_PC();
if ( Version == 1 /* U64 */)
{
sprintf(szPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSlotId]);
bReturn = FIL_fn_bDestroyFileOrDirectory(szPath);
}
else if( Version == 2 /* PC */)
{
char szSrcPath[_MAX_PATH], szDstPath[_MAX_PATH];
StructRecupPosSlot *p_CurrentStructRecupPosSlot;
sprintf(szSrcPath,"%s\\Slot%i",fn_szGetSaveGameDataPath(), g_ucNbSaveGameSlots );
if(g_ucNbSaveGameSlots != fn_bRecupSlotNum(_ulSlotId) )
{
sprintf(szDstPath,"%s\\Slot%i",fn_szGetSaveGameDataPath(), fn_bRecupSlotNum(_ulSlotId) );
if ( (bReturn = FIL_fn_bValidatePath(szDstPath, "")) != 0 )
{
bReturn = fn_bCopyDirectory(szSrcPath, szDstPath);
}
p_CurrentStructRecupPosSlot = g_p_LastStructRecupPosSlot;
while( p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot != NULL && p_CurrentStructRecupPosSlot->pos != g_ucNbSaveGameSlots)
{
p_CurrentStructRecupPosSlot = p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot;
}
p_CurrentStructRecupPosSlot->pos = fn_bRecupSlotNum(_ulSlotId);
}
bReturn = FIL_fn_bDestroyFileOrDirectory(szSrcPath);
}
#else // Pc sans editor
char szSrcPath[_MAX_PATH], szDstPath[_MAX_PATH];
StructRecupPosSlot *p_CurrentStructRecupPosSlot;
// Copie du repertoire du dernier slot de la list dans le repertoire du slot qui va etre effac<61>
// => pas de trou dans les repertoire rep 1, rep 2 et rep 4 impossible mais bien rep 1 2 et 3
//fn_bCopyGameInSlotFromSlot( fn_bRecupSlotNum(_ulSlotId), fn_bRecupSlotNum( g_ucNbSaveGameSlots));
sprintf(szSrcPath,"%s\\Slot%i",fn_szGetSaveGameDataPath(), g_ucNbSaveGameSlots );
if(g_ucNbSaveGameSlots != fn_bRecupSlotNum(_ulSlotId) )
{
sprintf(szDstPath,"%s\\Slot%i",fn_szGetSaveGameDataPath(), fn_bRecupSlotNum(_ulSlotId) );
// Verif et creation si necessaire de la destination
if ( (bReturn = FIL_fn_bValidatePath(szDstPath, "")) != 0 )
{
bReturn = fn_bCopyDirectory(szSrcPath, szDstPath);
}
// actualise le num du repertoire du dernier slot de la liste
p_CurrentStructRecupPosSlot = g_p_LastStructRecupPosSlot;
while( p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot != NULL && p_CurrentStructRecupPosSlot->pos != g_ucNbSaveGameSlots)
{
p_CurrentStructRecupPosSlot = p_CurrentStructRecupPosSlot->pt_NextStructRecupPosSlot;
}
p_CurrentStructRecupPosSlot->pos = fn_bRecupSlotNum(_ulSlotId);
}
// efface le repertoire du dernier slot de la liste
bReturn = FIL_fn_bDestroyFileOrDirectory(szSrcPath);
#endif // EDITOR
#endif // U64
}
return bReturn;
}
/**************************************************************************/
/*duplicate the contents of the specified slots*/
ACP_tdxBool fn_bCopyGameInSlotFromSlot(unsigned long _ulDstSlotId, unsigned long _ulSrcSlotId)
{
unsigned char bReturn = FALSE;
if
(
fn_bIsSlotOccupied(_ulSrcSlotId) /*we must copy from a non-empty slot*/
&& fn_bEraseGameInSlot(_ulDstSlotId) /*in a cleaned slot*/
)
{
char szSrcPath[_MAX_PATH], szDstPath[_MAX_PATH];
sprintf(szSrcPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulSrcSlotId]);
/*make sure the source exists*/
sprintf(szDstPath,"%s\\%s",fn_szGetSaveGameDataPath(),g_c_szSlotNames[_ulDstSlotId]);
/* create the path to the destination if necessary*/
if ( (bReturn = FIL_fn_bValidatePath(szDstPath, "")) != 0 )
{
/* now copy the contents of the source in the destination, replacing existing files*/
bReturn = fn_bCopyDirectory(szSrcPath, szDstPath);
}
}
return bReturn;
}