mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-01-31 05:30:52 +00:00
Move stuff from sys/posix/ and sys/win32/ to sys/common/
All these files were almost identical, so there is no good reason to have them twice.. and change CMakeLists.txt accordingly (Not that this commit won't compile because some #includes are still broken - will be fixed in the next one)
This commit is contained in:
parent
95a1066004
commit
cec460d38c
17 changed files with 0 additions and 2206 deletions
|
@ -712,16 +712,11 @@ file(GLOB_RECURSE WIN32_INCLUDES sys/win32/*.h)
|
|||
#file(GLOB_RECURSE WIN32_SOURCES sys/win32/*.cpp)
|
||||
|
||||
set(WIN32_SOURCES
|
||||
sys/win32/win_achievements.cpp
|
||||
sys/win32/win_glimp.cpp
|
||||
sys/win32/win_input.cpp
|
||||
sys/win32/win_localuser.cpp
|
||||
sys/win32/win_main.cpp
|
||||
sys/win32/win_qgl.cpp
|
||||
sys/win32/win_savegame.cpp
|
||||
sys/win32/win_session_local.cpp
|
||||
sys/win32/win_shared.cpp
|
||||
sys/win32/win_signin.cpp
|
||||
sys/win32/win_snd.cpp
|
||||
sys/win32/win_syscon.cpp
|
||||
sys/win32/win_taskkeyhook.cpp
|
||||
|
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
#pragma hdrstop
|
||||
#include "../../idlib/precompiled.h"
|
||||
|
||||
#include "posix_achievements.h"
|
||||
#include "../sys_session_local.h"
|
||||
|
||||
extern idCVar achievements_Verbose;
|
||||
|
||||
#define STEAM_ACHIEVEMENT_PREFIX "ach_"
|
||||
|
||||
/*
|
||||
========================
|
||||
idAchievementSystemWin::idAchievementSystemWin
|
||||
========================
|
||||
*/
|
||||
idAchievementSystemWin::idAchievementSystemWin()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idAchievementSystemWin::IsInitialized
|
||||
========================
|
||||
*/
|
||||
bool idAchievementSystemWin::IsInitialized()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
idAchievementSystemWin::AchievementUnlock
|
||||
================================
|
||||
*/
|
||||
void idAchievementSystemWin::AchievementUnlock( idLocalUser* user, int achievementID )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idAchievementSystemWin::AchievementLock
|
||||
========================
|
||||
*/
|
||||
void idAchievementSystemWin::AchievementLock( idLocalUser* user, const int achievementID )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idAchievementSystemWin::AchievementLockAll
|
||||
========================
|
||||
*/
|
||||
void idAchievementSystemWin::AchievementLockAll( idLocalUser* user, const int maxId )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idAchievementSystemWin::GetAchievementDescription
|
||||
========================
|
||||
*/
|
||||
bool idAchievementSystemWin::GetAchievementDescription( idLocalUser* user, const int achievementID, achievementDescription_t& data ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idAchievementSystemWin::GetAchievementState
|
||||
========================
|
||||
*/
|
||||
bool idAchievementSystemWin::GetAchievementState( idLocalUser* user, idArray< bool, idAchievementSystem::MAX_ACHIEVEMENTS >& achievements ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
================================
|
||||
idAchievementSystemWin::Pump
|
||||
================================
|
||||
*/
|
||||
void idAchievementSystemWin::Pump()
|
||||
{
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
#ifndef __POSIX_ACHIEVEMENTS_H__
|
||||
#define __POSIX_ACHIEVEMENTS_H__
|
||||
|
||||
/*
|
||||
================================================
|
||||
idAchievementSystemWin
|
||||
================================================
|
||||
*/
|
||||
class idAchievementSystemWin : public idAchievementSystem
|
||||
{
|
||||
public:
|
||||
idAchievementSystemWin();
|
||||
|
||||
bool IsInitialized();
|
||||
void AchievementUnlock( idLocalUser* user, const int achievementID );
|
||||
void AchievementLock( idLocalUser* user, const int achievementID );
|
||||
void AchievementLockAll( idLocalUser* user, const int maxId );
|
||||
void Pump();
|
||||
bool GetAchievementDescription( idLocalUser* user, const int id, achievementDescription_t& data ) const;
|
||||
bool GetAchievementState( idLocalUser* user, idArray< bool, idAchievementSystem::MAX_ACHIEVEMENTS >& achievements ) const;
|
||||
};
|
||||
|
||||
#endif // __POSIX_ACHIEVEMENTS_H__
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#pragma hdrstop
|
||||
#include "../../idlib/precompiled.h"
|
||||
#include "posix_localuser.h"
|
||||
|
||||
extern idCVar win_userPersistent;
|
||||
extern idCVar win_userOnline;
|
||||
extern idCVar win_isInParty;
|
||||
extern idCVar win_partyCount;
|
||||
|
||||
/*
|
||||
========================
|
||||
idLocalUserWin::Init
|
||||
========================
|
||||
*/
|
||||
void idLocalUserWin::Init( int inputDevice_, const char* gamertag_, int numLocalUsers )
|
||||
{
|
||||
if( numLocalUsers == 1 ) // Check for 1, since this is now incremented before we get in here
|
||||
{
|
||||
// This is the master user
|
||||
gamertag = gamertag_;
|
||||
}
|
||||
else
|
||||
{
|
||||
// On steam, we need to generate a name based off the master user for split-screen users.
|
||||
// We use the number of users on the system to generate the name rather than the device
|
||||
// number so that it is always consistently "username (2)" for the second player.
|
||||
gamertag.Format( "%s (%i)", gamertag_, numLocalUsers );
|
||||
}
|
||||
|
||||
inputDevice = inputDevice_;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idLocalUserWin::IsProfileReady
|
||||
========================
|
||||
*/
|
||||
bool idLocalUserWin::IsProfileReady() const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
return win_userPersistent.GetBool();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idLocalUserWin::IsOnline
|
||||
========================
|
||||
*/
|
||||
bool idLocalUserWin::IsOnline() const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
return win_userOnline.GetBool();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idLocalUserWin::IsInParty
|
||||
========================
|
||||
*/
|
||||
bool idLocalUserWin::IsInParty() const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
return win_isInParty.GetBool();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idLocalUserWin::GetPartyCount
|
||||
========================
|
||||
*/
|
||||
int idLocalUserWin::GetPartyCount() const
|
||||
{
|
||||
// TODO: Implement
|
||||
#ifdef _DEBUG
|
||||
return win_partyCount.GetInteger();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idLocalUserWin::VerifyUserState
|
||||
========================
|
||||
*/
|
||||
bool idLocalUserWin::VerifyUserState( winUserState_t& state )
|
||||
{
|
||||
|
||||
if( state.inputDevice != inputDevice )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
#ifndef __POSIX_LOCALUSER_H__
|
||||
#define __POSIX_LOCALUSER_H__
|
||||
|
||||
// This is to quickly get/set the data needed for disc-swapping
|
||||
typedef struct
|
||||
{
|
||||
int inputDevice;
|
||||
} winUserState_t;
|
||||
|
||||
/*
|
||||
================================================
|
||||
idLocalUserWin
|
||||
================================================
|
||||
*/
|
||||
class idLocalUserWin : public idLocalUser
|
||||
{
|
||||
public:
|
||||
static const int MAX_GAMERTAG = 64; // max number of bytes for a gamertag
|
||||
static const int MAX_GAMERTAG_CHARS = 16; // max number of UTF-8 characters to show
|
||||
|
||||
idLocalUserWin() : inputDevice( 0 ) {}
|
||||
|
||||
//==========================================================================================
|
||||
// idLocalUser interface
|
||||
//==========================================================================================
|
||||
virtual bool IsProfileReady() const;
|
||||
virtual bool IsOnline() const;
|
||||
virtual bool IsInParty() const;
|
||||
virtual int GetPartyCount() const;
|
||||
virtual uint32 GetOnlineCaps() const
|
||||
{
|
||||
return ( IsPersistent() && IsOnline() ) ? ( CAP_IS_ONLINE | CAP_CAN_PLAY_ONLINE ) : 0;
|
||||
}
|
||||
virtual int GetInputDevice() const
|
||||
{
|
||||
return inputDevice;
|
||||
}
|
||||
virtual const char* GetGamerTag() const
|
||||
{
|
||||
return gamertag.c_str();
|
||||
}
|
||||
virtual void PumpPlatform() {}
|
||||
|
||||
//==========================================================================================
|
||||
// idLocalUserWin interface
|
||||
//==========================================================================================
|
||||
void SetInputDevice( int inputDevice_ )
|
||||
{
|
||||
inputDevice = inputDevice_;
|
||||
}
|
||||
void SetGamerTag( const char* gamerTag_ )
|
||||
{
|
||||
gamertag = gamerTag_;
|
||||
}
|
||||
winUserState_t GetUserState()
|
||||
{
|
||||
winUserState_t a = { inputDevice };
|
||||
return a;
|
||||
}
|
||||
bool VerifyUserState( winUserState_t& state );
|
||||
|
||||
void Init( int inputDevice_, const char* gamertag_, int numLocalUsers );
|
||||
|
||||
private:
|
||||
idStrStatic< MAX_GAMERTAG > gamertag;
|
||||
int inputDevice;
|
||||
};
|
||||
|
||||
#endif // __POSIX_LOCALUSER_H__
|
|
@ -1,820 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#pragma hdrstop
|
||||
#include "../../idlib/precompiled.h"
|
||||
#include "../sys_session_local.h"
|
||||
#include "../sys_savegame.h"
|
||||
|
||||
idCVar savegame_winInduceDelay( "savegame_winInduceDelay", "0", CVAR_INTEGER, "on windows, this is a delay induced before any file operation occurs" );
|
||||
extern idCVar fs_savepath;
|
||||
extern idCVar saveGame_checksum;
|
||||
extern idCVar savegame_error;
|
||||
|
||||
#define SAVEGAME_SENTINAL 0x12358932
|
||||
|
||||
// RB begin
|
||||
#define ERROR_SUCCESS 0
|
||||
// RB end
|
||||
|
||||
/*
|
||||
========================
|
||||
void Sys_ExecuteSavegameCommandAsync
|
||||
========================
|
||||
*/
|
||||
void Sys_ExecuteSavegameCommandAsyncImpl( idSaveLoadParms* savegameParms )
|
||||
{
|
||||
assert( savegameParms != NULL );
|
||||
|
||||
session->GetSaveGameManager().GetSaveGameThread().data.saveLoadParms = savegameParms;
|
||||
|
||||
if( session->GetSaveGameManager().GetSaveGameThread().GetThreadHandle() == 0 )
|
||||
{
|
||||
session->GetSaveGameManager().GetSaveGameThread().StartWorkerThread( "Savegame", CORE_ANY );
|
||||
}
|
||||
|
||||
session->GetSaveGameManager().GetSaveGameThread().SignalWork();
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idLocalUser * GetLocalUserFromUserId
|
||||
========================
|
||||
*/
|
||||
idLocalUserWin* GetLocalUserFromSaveParms( const saveGameThreadArgs_t& data )
|
||||
{
|
||||
if( ( data.saveLoadParms != NULL ) && ( data.saveLoadParms->inputDeviceId >= 0 ) )
|
||||
{
|
||||
idLocalUser* user = session->GetSignInManager().GetLocalUserByInputDevice( data.saveLoadParms->inputDeviceId );
|
||||
if( user != NULL )
|
||||
{
|
||||
idLocalUserWin* userWin = static_cast< idLocalUserWin* >( user );
|
||||
if( userWin != NULL && data.saveLoadParms->userId == idStr::Hash( userWin->GetGamerTag() ) )
|
||||
{
|
||||
return userWin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSaveGameThread::SaveGame
|
||||
========================
|
||||
*/
|
||||
int idSaveGameThread::Save()
|
||||
{
|
||||
idLocalUserWin* user = GetLocalUserFromSaveParms( data );
|
||||
if( user == NULL )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_INVALID_USER;
|
||||
return -1;
|
||||
}
|
||||
|
||||
idSaveLoadParms* callback = data.saveLoadParms;
|
||||
idStr saveFolder = "savegame";
|
||||
|
||||
saveFolder.AppendPath( callback->directory );
|
||||
|
||||
// Check for the required storage space.
|
||||
int64 requiredSizeBytes = 0;
|
||||
{
|
||||
for( int i = 0; i < callback->files.Num(); i++ )
|
||||
{
|
||||
idFile_SaveGame* file = callback->files[i];
|
||||
requiredSizeBytes += ( file->Length() + sizeof( unsigned int ) ); // uint for checksum
|
||||
if( file->type == SAVEGAMEFILE_PIPELINED )
|
||||
{
|
||||
requiredSizeBytes += MIN_SAVEGAME_SIZE_BYTES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// Check size of previous files if needed
|
||||
// ALL THE FILES RIGHT NOW---- could use pattern later...
|
||||
idStrList filesToDelete;
|
||||
if( ( callback->mode & SAVEGAME_MBF_DELETE_FILES ) && !callback->cancelled )
|
||||
{
|
||||
if( fileSystem->IsFolder( saveFolder.c_str(), "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
idFileList* files = fileSystem->ListFilesTree( saveFolder.c_str(), "*.*" );
|
||||
for( int i = 0; i < files->GetNumFiles(); i++ )
|
||||
{
|
||||
requiredSizeBytes -= fileSystem->GetFileLength( files->GetFile( i ) );
|
||||
filesToDelete.Append( files->GetFile( i ) );
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
}
|
||||
}
|
||||
|
||||
// RB: disabled savegame and profile storage checks, because it fails sometimes without any clear reason
|
||||
/*
|
||||
// Inform user about size required if necessary
|
||||
if( requiredSizeBytes > 0 && !callback->cancelled )
|
||||
{
|
||||
user->StorageSizeAvailable( requiredSizeBytes, callback->requiredSpaceInBytes );
|
||||
if( callback->requiredSpaceInBytes > 0 )
|
||||
{
|
||||
// check to make sure savepath actually exists before erroring
|
||||
idStr directory = fs_savepath.GetString();
|
||||
directory += "\\"; // so it doesn't think the last part is a file and ignores in the directory creation
|
||||
fileSystem->CreateOSPath( directory ); // we can't actually check FileExists in production builds, so just try to create it
|
||||
user->StorageSizeAvailable( requiredSizeBytes, callback->requiredSpaceInBytes );
|
||||
|
||||
if( callback->requiredSpaceInBytes > 0 )
|
||||
{
|
||||
callback->errorCode = SAVEGAME_E_INSUFFICIENT_ROOM;
|
||||
// safe to return, haven't written any files yet
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
// RB end
|
||||
|
||||
// Delete all previous files if needed
|
||||
// ALL THE FILES RIGHT NOW---- could use pattern later...
|
||||
for( int i = 0; i < filesToDelete.Num() && !callback->cancelled; i++ )
|
||||
{
|
||||
fileSystem->RemoveFile( filesToDelete[i].c_str() );
|
||||
}
|
||||
|
||||
// Save the raw files.
|
||||
for( int i = 0; i < callback->files.Num() && ret == ERROR_SUCCESS && !callback->cancelled; i++ )
|
||||
{
|
||||
idFile_SaveGame* file = callback->files[i];
|
||||
|
||||
idStr fileName = saveFolder;
|
||||
fileName.AppendPath( file->GetName() );
|
||||
idStr tempFileName = va( "%s.temp", fileName.c_str() );
|
||||
|
||||
idFile* outputFile = fileSystem->OpenFileWrite( tempFileName, "fs_savePath" );
|
||||
if( outputFile == NULL )
|
||||
{
|
||||
idLib::Warning( "[%s]: Couldn't open file for writing, %s", __FUNCTION__, tempFileName.c_str() );
|
||||
file->error = true;
|
||||
callback->errorCode = SAVEGAME_E_UNKNOWN;
|
||||
ret = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( ( file->type & SAVEGAMEFILE_PIPELINED ) != 0 )
|
||||
{
|
||||
|
||||
idFile_SaveGamePipelined* inputFile = dynamic_cast< idFile_SaveGamePipelined* >( file );
|
||||
assert( inputFile != NULL );
|
||||
|
||||
blockForIO_t block;
|
||||
while( inputFile->NextWriteBlock( & block ) )
|
||||
{
|
||||
if( ( size_t )outputFile->Write( block.data, block.bytes ) != block.bytes )
|
||||
{
|
||||
idLib::Warning( "[%s]: Write failed.", __FUNCTION__ );
|
||||
file->error = true;
|
||||
callback->errorCode = SAVEGAME_E_INSUFFICIENT_ROOM;
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if( ( file->type & SAVEGAMEFILE_BINARY ) || ( file->type & SAVEGAMEFILE_COMPRESSED ) )
|
||||
{
|
||||
if( saveGame_checksum.GetBool() )
|
||||
{
|
||||
unsigned int checksum = MD5_BlockChecksum( file->GetDataPtr(), file->Length() );
|
||||
size_t size = outputFile->WriteBig( checksum );
|
||||
if( size != sizeof( checksum ) )
|
||||
{
|
||||
idLib::Warning( "[%s]: Write failed.", __FUNCTION__ );
|
||||
file->error = true;
|
||||
callback->errorCode = SAVEGAME_E_INSUFFICIENT_ROOM;
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t size = outputFile->Write( file->GetDataPtr(), file->Length() );
|
||||
if( size != ( size_t )file->Length() )
|
||||
{
|
||||
idLib::Warning( "[%s]: Write failed.", __FUNCTION__ );
|
||||
file->error = true;
|
||||
callback->errorCode = SAVEGAME_E_INSUFFICIENT_ROOM;
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
idLib::PrintfIf( saveGame_verbose.GetBool(), "Saved %s (%s)\n", fileName.c_str(), outputFile->GetFullPath() );
|
||||
}
|
||||
}
|
||||
|
||||
delete outputFile;
|
||||
|
||||
if( ret == ERROR_SUCCESS )
|
||||
{
|
||||
// Remove the old file
|
||||
if( !fileSystem->RenameFile( tempFileName, fileName, "fs_savePath" ) )
|
||||
{
|
||||
idLib::Warning( "Could not start to rename temporary file %s to %s.", tempFileName.c_str(), fileName.c_str() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileSystem->RemoveFile( tempFileName );
|
||||
idLib::Warning( "Invalid write to temporary file %s.", tempFileName.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
if( data.saveLoadParms->cancelled )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_CANCELLED;
|
||||
}
|
||||
|
||||
// Removed because it seemed a bit drastic
|
||||
#if 0
|
||||
// If there is an error, delete the partially saved folder
|
||||
if( callback->errorCode != SAVEGAME_E_NONE )
|
||||
{
|
||||
if( fileSystem->IsFolder( saveFolder, "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
idFileList* files = fileSystem->ListFilesTree( saveFolder, "/|*" );
|
||||
for( int i = 0; i < files->GetNumFiles(); i++ )
|
||||
{
|
||||
fileSystem->RemoveFile( files->GetFile( i ) );
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
fileSystem->RemoveDir( saveFolder );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocal::LoadGame
|
||||
========================
|
||||
*/
|
||||
int idSaveGameThread::Load()
|
||||
{
|
||||
idSaveLoadParms* callback = data.saveLoadParms;
|
||||
idStr saveFolder = "savegame";
|
||||
|
||||
saveFolder.AppendPath( callback->directory );
|
||||
|
||||
if( fileSystem->IsFolder( saveFolder, "fs_savePath" ) != FOLDER_YES )
|
||||
{
|
||||
callback->errorCode = SAVEGAME_E_FOLDER_NOT_FOUND;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ERROR_SUCCESS;
|
||||
for( int i = 0; i < callback->files.Num() && ret == ERROR_SUCCESS && !callback->cancelled; i++ )
|
||||
{
|
||||
idFile_SaveGame* file = callback->files[i];
|
||||
|
||||
idStr filename = saveFolder;
|
||||
filename.AppendPath( file->GetName() );
|
||||
|
||||
idFile* inputFile = fileSystem->OpenFileRead( filename.c_str() );
|
||||
if( inputFile == NULL )
|
||||
{
|
||||
file->error = true;
|
||||
if( !( file->type & SAVEGAMEFILE_OPTIONAL ) )
|
||||
{
|
||||
callback->errorCode = SAVEGAME_E_CORRUPTED;
|
||||
ret = -1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if( ( file->type & SAVEGAMEFILE_PIPELINED ) != 0 )
|
||||
{
|
||||
|
||||
idFile_SaveGamePipelined* outputFile = dynamic_cast< idFile_SaveGamePipelined* >( file );
|
||||
assert( outputFile != NULL );
|
||||
|
||||
size_t lastReadBytes = 0;
|
||||
blockForIO_t block;
|
||||
while( outputFile->NextReadBlock( &block, lastReadBytes ) && !callback->cancelled )
|
||||
{
|
||||
lastReadBytes = inputFile->Read( block.data, block.bytes );
|
||||
if( lastReadBytes != block.bytes )
|
||||
{
|
||||
// Notify end-of-file to the save game file which will cause all reads on the
|
||||
// other end of the pipeline to return zero bytes after the pipeline is drained.
|
||||
outputFile->NextReadBlock( NULL, lastReadBytes );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
size_t size = inputFile->Length();
|
||||
|
||||
unsigned int originalChecksum = 0;
|
||||
if( ( file->type & SAVEGAMEFILE_BINARY ) != 0 || ( file->type & SAVEGAMEFILE_COMPRESSED ) != 0 )
|
||||
{
|
||||
if( saveGame_checksum.GetBool() )
|
||||
{
|
||||
if( size >= sizeof( originalChecksum ) )
|
||||
{
|
||||
inputFile->ReadBig( originalChecksum );
|
||||
size -= sizeof( originalChecksum );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file->SetLength( size );
|
||||
|
||||
size_t sizeRead = inputFile->Read( ( void* )file->GetDataPtr(), size );
|
||||
if( sizeRead != size )
|
||||
{
|
||||
file->error = true;
|
||||
callback->errorCode = SAVEGAME_E_CORRUPTED;
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if( ( file->type & SAVEGAMEFILE_BINARY ) != 0 || ( file->type & SAVEGAMEFILE_COMPRESSED ) != 0 )
|
||||
{
|
||||
if( saveGame_checksum.GetBool() )
|
||||
{
|
||||
unsigned int checksum = MD5_BlockChecksum( file->GetDataPtr(), file->Length() );
|
||||
if( checksum != originalChecksum )
|
||||
{
|
||||
file->error = true;
|
||||
callback->errorCode = SAVEGAME_E_CORRUPTED;
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete inputFile;
|
||||
}
|
||||
|
||||
if( data.saveLoadParms->cancelled )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_CANCELLED;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSaveGameThread::Delete
|
||||
|
||||
This deletes a complete savegame directory
|
||||
========================
|
||||
*/
|
||||
int idSaveGameThread::Delete()
|
||||
{
|
||||
idSaveLoadParms* callback = data.saveLoadParms;
|
||||
idStr saveFolder = "savegame";
|
||||
|
||||
saveFolder.AppendPath( callback->directory );
|
||||
|
||||
int ret = ERROR_SUCCESS;
|
||||
if( fileSystem->IsFolder( saveFolder, "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
idFileList* files = fileSystem->ListFilesTree( saveFolder, "/|*" );
|
||||
for( int i = 0; i < files->GetNumFiles() && !callback->cancelled; i++ )
|
||||
{
|
||||
fileSystem->RemoveFile( files->GetFile( i ) );
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
|
||||
fileSystem->RemoveDir( saveFolder );
|
||||
}
|
||||
else
|
||||
{
|
||||
callback->errorCode = SAVEGAME_E_FOLDER_NOT_FOUND;
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if( data.saveLoadParms->cancelled )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_CANCELLED;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSaveGameThread::Enumerate
|
||||
========================
|
||||
*/
|
||||
int idSaveGameThread::Enumerate()
|
||||
{
|
||||
idSaveLoadParms* callback = data.saveLoadParms;
|
||||
idStr saveFolder = "savegame";
|
||||
|
||||
callback->detailList.Clear();
|
||||
|
||||
int ret = ERROR_SUCCESS;
|
||||
if( fileSystem->IsFolder( saveFolder, "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
idFileList* files = fileSystem->ListFilesTree( saveFolder, SAVEGAME_DETAILS_FILENAME );
|
||||
const idStrList& fileList = files->GetList();
|
||||
|
||||
for( int i = 0; i < fileList.Num() && !callback->cancelled; i++ )
|
||||
{
|
||||
idSaveGameDetails* details = callback->detailList.Alloc();
|
||||
// We have more folders on disk than we have room in our save detail list, stop trying to read them in and continue with what we have
|
||||
if( details == NULL )
|
||||
{
|
||||
break;
|
||||
}
|
||||
idStr directory = fileList[i];
|
||||
|
||||
idFile* file = fileSystem->OpenFileRead( directory.c_str() );
|
||||
|
||||
if( file != NULL )
|
||||
{
|
||||
// Read the DETAIL file for the enumerated data
|
||||
if( callback->mode & SAVEGAME_MBF_READ_DETAILS )
|
||||
{
|
||||
if( !SavegameReadDetailsFromFile( file, *details ) )
|
||||
{
|
||||
details->damaged = true;
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// DG: just use the idFile object's timestamp - the windows code gets file attributes and
|
||||
// other complicated stuff like that.. I'm wonderin what that was good for.. this seems to work.
|
||||
details->date = file->Timestamp();
|
||||
// DG end
|
||||
}
|
||||
else
|
||||
{
|
||||
details->damaged = true;
|
||||
}
|
||||
|
||||
// populate the game details struct
|
||||
directory = directory.StripFilename();
|
||||
details->slotName = directory.c_str() + saveFolder.Length() + 1; // Strip off the prefix too
|
||||
// JDC: I hit this all the time assert( fileSystem->IsFolder( directory.c_str(), "fs_savePath" ) == FOLDER_YES );
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
}
|
||||
else
|
||||
{
|
||||
callback->errorCode = SAVEGAME_E_FOLDER_NOT_FOUND;
|
||||
ret = -3;
|
||||
}
|
||||
|
||||
if( data.saveLoadParms->cancelled )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_CANCELLED;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSaveGameThread::EnumerateFiles
|
||||
========================
|
||||
*/
|
||||
int idSaveGameThread::EnumerateFiles()
|
||||
{
|
||||
idSaveLoadParms* callback = data.saveLoadParms;
|
||||
idStr folder = "savegame";
|
||||
|
||||
folder.AppendPath( callback->directory );
|
||||
|
||||
callback->files.Clear();
|
||||
|
||||
int ret = ERROR_SUCCESS;
|
||||
if( fileSystem->IsFolder( folder, "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
// get listing of all the files, but filter out below
|
||||
idFileList* files = fileSystem->ListFilesTree( folder, "*.*" );
|
||||
|
||||
// look for the instance pattern
|
||||
for( int i = 0; i < files->GetNumFiles() && ret == 0 && !callback->cancelled; i++ )
|
||||
{
|
||||
idStr fullFilename = files->GetFile( i );
|
||||
idStr filename = fullFilename;
|
||||
filename.StripPath();
|
||||
|
||||
if( filename.IcmpPrefix( callback->pattern ) != 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( !callback->postPattern.IsEmpty() && filename.Right( callback->postPattern.Length() ).IcmpPrefix( callback->postPattern ) != 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Read the DETAIL file for the enumerated data
|
||||
if( callback->mode & SAVEGAME_MBF_READ_DETAILS )
|
||||
{
|
||||
idSaveGameDetails& details = callback->description;
|
||||
idFile* uncompressed = fileSystem->OpenFileRead( fullFilename.c_str() );
|
||||
|
||||
if( uncompressed == NULL )
|
||||
{
|
||||
details.damaged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !SavegameReadDetailsFromFile( uncompressed, details ) )
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
delete uncompressed;
|
||||
}
|
||||
|
||||
// populate the game details struct
|
||||
details.slotName = callback->directory;
|
||||
assert( fileSystem->IsFolder( details.slotName, "fs_savePath" ) == FOLDER_YES );
|
||||
}
|
||||
|
||||
idFile_SaveGame* file = new( TAG_SAVEGAMES ) idFile_SaveGame( filename, SAVEGAMEFILE_AUTO_DELETE );
|
||||
callback->files.Append( file );
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
}
|
||||
else
|
||||
{
|
||||
callback->errorCode = SAVEGAME_E_FOLDER_NOT_FOUND;
|
||||
ret = -3;
|
||||
}
|
||||
|
||||
if( data.saveLoadParms->cancelled )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_CANCELLED;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSaveGameThread::DeleteFiles
|
||||
========================
|
||||
*/
|
||||
int idSaveGameThread::DeleteFiles()
|
||||
{
|
||||
idSaveLoadParms* callback = data.saveLoadParms;
|
||||
idStr folder = "savegame";
|
||||
|
||||
folder.AppendPath( callback->directory );
|
||||
|
||||
// delete the explicitly requested files first
|
||||
for( int j = 0; j < callback->files.Num() && !callback->cancelled; ++j )
|
||||
{
|
||||
idFile_SaveGame* file = callback->files[j];
|
||||
idStr fullpath = folder;
|
||||
fullpath.AppendPath( file->GetName() );
|
||||
fileSystem->RemoveFile( fullpath );
|
||||
}
|
||||
|
||||
int ret = ERROR_SUCCESS;
|
||||
if( fileSystem->IsFolder( folder, "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
// get listing of all the files, but filter out below
|
||||
idFileList* files = fileSystem->ListFilesTree( folder, "*.*" );
|
||||
|
||||
// look for the instance pattern
|
||||
for( int i = 0; i < files->GetNumFiles() && !callback->cancelled; i++ )
|
||||
{
|
||||
idStr filename = files->GetFile( i );
|
||||
filename.StripPath();
|
||||
|
||||
// If there are post/pre patterns to match, make sure we adhere to the patterns
|
||||
if( callback->pattern.IsEmpty() || ( filename.IcmpPrefix( callback->pattern ) != 0 ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( callback->postPattern.IsEmpty() || ( filename.Right( callback->postPattern.Length() ).IcmpPrefix( callback->postPattern ) != 0 ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fileSystem->RemoveFile( files->GetFile( i ) );
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
}
|
||||
else
|
||||
{
|
||||
callback->errorCode = SAVEGAME_E_FOLDER_NOT_FOUND;
|
||||
ret = -3;
|
||||
}
|
||||
|
||||
if( data.saveLoadParms->cancelled )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_CANCELLED;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSaveGameThread::DeleteAll
|
||||
|
||||
This deletes all savegame directories
|
||||
========================
|
||||
*/
|
||||
int idSaveGameThread::DeleteAll()
|
||||
{
|
||||
idSaveLoadParms* callback = data.saveLoadParms;
|
||||
idStr saveFolder = "savegame";
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if( fileSystem->IsFolder( saveFolder, "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
idFileList* files = fileSystem->ListFilesTree( saveFolder, "/|*" );
|
||||
// remove directories after files
|
||||
for( int i = 0; i < files->GetNumFiles() && !callback->cancelled; i++ )
|
||||
{
|
||||
// contained files should always be first
|
||||
if( fileSystem->IsFolder( files->GetFile( i ), "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
fileSystem->RemoveDir( files->GetFile( i ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fileSystem->RemoveFile( files->GetFile( i ) );
|
||||
}
|
||||
}
|
||||
fileSystem->FreeFileList( files );
|
||||
}
|
||||
else
|
||||
{
|
||||
callback->errorCode = SAVEGAME_E_FOLDER_NOT_FOUND;
|
||||
ret = -3;
|
||||
}
|
||||
|
||||
if( data.saveLoadParms->cancelled )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_CANCELLED;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSaveGameThread::Run
|
||||
========================
|
||||
*/
|
||||
int idSaveGameThread::Run()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
try
|
||||
{
|
||||
idLocalUserWin* user = GetLocalUserFromSaveParms( data );
|
||||
if( user != NULL && !user->IsStorageDeviceAvailable() )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_UNABLE_TO_SELECT_STORAGE_DEVICE;
|
||||
}
|
||||
|
||||
if( savegame_winInduceDelay.GetInteger() > 0 )
|
||||
{
|
||||
Sys_Sleep( savegame_winInduceDelay.GetInteger() );
|
||||
}
|
||||
|
||||
if( data.saveLoadParms->mode & SAVEGAME_MBF_SAVE )
|
||||
{
|
||||
ret = Save();
|
||||
}
|
||||
else if( data.saveLoadParms->mode & SAVEGAME_MBF_LOAD )
|
||||
{
|
||||
ret = Load();
|
||||
}
|
||||
else if( data.saveLoadParms->mode & SAVEGAME_MBF_ENUMERATE )
|
||||
{
|
||||
ret = Enumerate();
|
||||
}
|
||||
else if( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_FOLDER )
|
||||
{
|
||||
ret = Delete();
|
||||
}
|
||||
else if( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_ALL_FOLDERS )
|
||||
{
|
||||
ret = DeleteAll();
|
||||
}
|
||||
else if( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_FILES )
|
||||
{
|
||||
ret = DeleteFiles();
|
||||
}
|
||||
else if( data.saveLoadParms->mode & SAVEGAME_MBF_ENUMERATE_FILES )
|
||||
{
|
||||
ret = EnumerateFiles();
|
||||
}
|
||||
|
||||
// if something failed and no one set an error code, do it now.
|
||||
if( ret != 0 && data.saveLoadParms->errorCode == SAVEGAME_E_NONE )
|
||||
{
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_UNKNOWN;
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
// if anything horrible happens, leave it up to the savegame processors to handle in PostProcess().
|
||||
data.saveLoadParms->errorCode = SAVEGAME_E_UNKNOWN;
|
||||
}
|
||||
|
||||
// Make sure to cancel any save game file pipelines.
|
||||
if( data.saveLoadParms->errorCode != SAVEGAME_E_NONE )
|
||||
{
|
||||
data.saveLoadParms->CancelSaveGameFilePipelines();
|
||||
}
|
||||
|
||||
// Override error if cvar set
|
||||
if( savegame_error.GetInteger() != 0 )
|
||||
{
|
||||
data.saveLoadParms->errorCode = ( saveGameError_t )savegame_error.GetInteger();
|
||||
}
|
||||
|
||||
// Tell the waiting caller that we are done
|
||||
data.saveLoadParms->callbackSignal.Raise();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
Sys_SaveGameCheck
|
||||
========================
|
||||
*/
|
||||
void Sys_SaveGameCheck( bool& exists, bool& autosaveExists )
|
||||
{
|
||||
exists = false;
|
||||
autosaveExists = false;
|
||||
|
||||
const idStr autosaveFolderStr = AddSaveFolderPrefix( SAVEGAME_AUTOSAVE_FOLDER, idSaveGameManager::PACKAGE_GAME );
|
||||
const char* autosaveFolder = autosaveFolderStr.c_str();
|
||||
const char* saveFolder = "savegame";
|
||||
|
||||
if( fileSystem->IsFolder( saveFolder, "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
idFileList* files = fileSystem->ListFiles( saveFolder, "/" );
|
||||
const idStrList& fileList = files->GetList();
|
||||
|
||||
idLib::PrintfIf( saveGame_verbose.GetBool(), "found %d savegames\n", fileList.Num() );
|
||||
|
||||
for( int i = 0; i < fileList.Num(); i++ )
|
||||
{
|
||||
const char* directory = va( "%s/%s", saveFolder, fileList[i].c_str() );
|
||||
|
||||
if( fileSystem->IsFolder( directory, "fs_savePath" ) == FOLDER_YES )
|
||||
{
|
||||
exists = true;
|
||||
|
||||
idLib::PrintfIf( saveGame_verbose.GetBool(), "found savegame: %s\n", fileList[i].c_str() );
|
||||
|
||||
if( idStr::Icmp( fileList[i].c_str(), autosaveFolder ) == 0 )
|
||||
{
|
||||
autosaveExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileSystem->FreeFileList( files );
|
||||
}
|
||||
}
|
|
@ -1,750 +0,0 @@
|
|||
/*
|
||||
================================================================================================
|
||||
CONFIDENTIAL AND PROPRIETARY INFORMATION/NOT FOR DISCLOSURE WITHOUT WRITTEN PERMISSION
|
||||
Copyright 2010 id Software LLC, a ZeniMax Media company. All Rights Reserved.
|
||||
================================================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
|
||||
Contains the windows implementation of the network session
|
||||
|
||||
================================================================================================
|
||||
*/
|
||||
|
||||
#pragma hdrstop
|
||||
#include "precompiled.h"
|
||||
#include "../../framework/Common_local.h"
|
||||
#include "../sys_session_local.h"
|
||||
#include "../sys_stats.h"
|
||||
#include "../sys_savegame.h"
|
||||
#include "../sys_lobby_backend_direct.h"
|
||||
#include "../sys_voicechat.h"
|
||||
#include "win_achievements.h"
|
||||
#include "win_local.h"
|
||||
|
||||
/*
|
||||
========================
|
||||
Global variables
|
||||
========================
|
||||
*/
|
||||
|
||||
extern idCVar net_port;
|
||||
|
||||
class idLobbyToSessionCBLocal;
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::idSessionLocalWin
|
||||
========================
|
||||
*/
|
||||
class idSessionLocalWin : public idSessionLocal
|
||||
{
|
||||
friend class idLobbyToSessionCBLocal;
|
||||
|
||||
public:
|
||||
idSessionLocalWin();
|
||||
virtual ~idSessionLocalWin();
|
||||
|
||||
// idSessionLocal interface
|
||||
virtual void Initialize();
|
||||
virtual void Shutdown();
|
||||
|
||||
virtual void InitializeSoundRelatedSystems();
|
||||
virtual void ShutdownSoundRelatedSystems();
|
||||
|
||||
virtual void PlatformPump();
|
||||
|
||||
virtual void InviteFriends();
|
||||
virtual void InviteParty();
|
||||
virtual void ShowPartySessions();
|
||||
|
||||
virtual void ShowSystemMarketplaceUI() const;
|
||||
|
||||
virtual void ListServers( const idCallback& callback );
|
||||
virtual void CancelListServers();
|
||||
virtual int NumServers() const;
|
||||
virtual const serverInfo_t* ServerInfo( int i ) const;
|
||||
virtual void ConnectToServer( int i );
|
||||
virtual void ShowServerGamerCardUI( int i );
|
||||
|
||||
virtual void ShowLobbyUserGamerCardUI( lobbyUserID_t lobbyUserID );
|
||||
|
||||
virtual void ShowOnlineSignin() {}
|
||||
virtual void UpdateRichPresence() {}
|
||||
virtual void CheckVoicePrivileges() {}
|
||||
|
||||
virtual bool ProcessInputEvent( const sysEvent_t* ev );
|
||||
|
||||
// System UI
|
||||
virtual bool IsSystemUIShowing() const;
|
||||
virtual void SetSystemUIShowing( bool show );
|
||||
|
||||
// Invites
|
||||
virtual void HandleBootableInvite( int64 lobbyId = 0 );
|
||||
virtual void ClearBootableInvite();
|
||||
virtual void ClearPendingInvite();
|
||||
|
||||
virtual bool HasPendingBootableInvite();
|
||||
virtual void SetDiscSwapMPInvite( void* parm );
|
||||
virtual void* GetDiscSwapMPInviteParms();
|
||||
|
||||
virtual void EnumerateDownloadableContent();
|
||||
|
||||
virtual void HandleServerQueryRequest( lobbyAddress_t& remoteAddr, idBitMsg& msg, int msgType );
|
||||
virtual void HandleServerQueryAck( lobbyAddress_t& remoteAddr, idBitMsg& msg );
|
||||
|
||||
// Leaderboards
|
||||
virtual void LeaderboardUpload( lobbyUserID_t lobbyUserID, const leaderboardDefinition_t* leaderboard, const column_t* stats, const idFile_Memory* attachment = NULL );
|
||||
virtual void LeaderboardDownload( int sessionUserIndex, const leaderboardDefinition_t* leaderboard, int startingRank, int numRows, const idLeaderboardCallback& callback );
|
||||
virtual void LeaderboardDownloadAttachment( int sessionUserIndex, const leaderboardDefinition_t* leaderboard, int64 attachmentID );
|
||||
|
||||
// Scoring (currently just for TrueSkill)
|
||||
virtual void SetLobbyUserRelativeScore( lobbyUserID_t lobbyUserID, int relativeScore, int team ) {}
|
||||
|
||||
virtual void LeaderboardFlush();
|
||||
|
||||
virtual idNetSessionPort& GetPort( bool dedicated = false );
|
||||
virtual idLobbyBackend* CreateLobbyBackend( const idMatchParameters& p, float skillLevel, idLobbyBackend::lobbyBackendType_t lobbyType );
|
||||
virtual idLobbyBackend* FindLobbyBackend( const idMatchParameters& p, int numPartyUsers, float skillLevel, idLobbyBackend::lobbyBackendType_t lobbyType );
|
||||
virtual idLobbyBackend* JoinFromConnectInfo( const lobbyConnectInfo_t& connectInfo , idLobbyBackend::lobbyBackendType_t lobbyType );
|
||||
virtual void DestroyLobbyBackend( idLobbyBackend* lobbyBackend );
|
||||
virtual void PumpLobbies();
|
||||
virtual void JoinAfterSwap( void* joinID );
|
||||
|
||||
virtual bool GetLobbyAddressFromNetAddress( const netadr_t& netAddr, lobbyAddress_t& outAddr ) const;
|
||||
virtual bool GetNetAddressFromLobbyAddress( const lobbyAddress_t& lobbyAddress, netadr_t& outNetAddr ) const;
|
||||
|
||||
public:
|
||||
void Connect_f( const idCmdArgs& args );
|
||||
|
||||
private:
|
||||
void EnsurePort();
|
||||
|
||||
idLobbyBackend* CreateLobbyInternal( idLobbyBackend::lobbyBackendType_t lobbyType );
|
||||
|
||||
idArray< idLobbyBackend*, 3 > lobbyBackends;
|
||||
|
||||
idNetSessionPort port;
|
||||
bool canJoinLocalHost;
|
||||
|
||||
idLobbyToSessionCBLocal* lobbyToSessionCB;
|
||||
};
|
||||
|
||||
idSessionLocalWin sessionLocalWin;
|
||||
idSession* session = &sessionLocalWin;
|
||||
|
||||
/*
|
||||
========================
|
||||
idLobbyToSessionCBLocal
|
||||
========================
|
||||
*/
|
||||
class idLobbyToSessionCBLocal : public idLobbyToSessionCB
|
||||
{
|
||||
public:
|
||||
idLobbyToSessionCBLocal( idSessionLocalWin* sessionLocalWin_ ) : sessionLocalWin( sessionLocalWin_ ) { }
|
||||
|
||||
virtual bool CanJoinLocalHost() const
|
||||
{
|
||||
sessionLocalWin->EnsurePort();
|
||||
return sessionLocalWin->canJoinLocalHost;
|
||||
}
|
||||
virtual class idLobbyBackend* GetLobbyBackend( idLobbyBackend::lobbyBackendType_t type ) const
|
||||
{
|
||||
return sessionLocalWin->lobbyBackends[ type ];
|
||||
}
|
||||
|
||||
private:
|
||||
idSessionLocalWin* sessionLocalWin;
|
||||
};
|
||||
|
||||
idLobbyToSessionCBLocal lobbyToSessionCBLocal( &sessionLocalWin );
|
||||
idLobbyToSessionCB* lobbyToSessionCB = &lobbyToSessionCBLocal;
|
||||
|
||||
class idVoiceChatMgrWin : public idVoiceChatMgr
|
||||
{
|
||||
public:
|
||||
virtual bool GetLocalChatDataInternal( int talkerIndex, byte* data, int& dataSize )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual void SubmitIncomingChatDataInternal( int talkerIndex, const byte* data, int dataSize ) { }
|
||||
virtual bool TalkerHasData( int talkerIndex )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool RegisterTalkerInternal( int index )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual void UnregisterTalkerInternal( int index ) { }
|
||||
};
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::idSessionLocalWin
|
||||
========================
|
||||
*/
|
||||
idSessionLocalWin::idSessionLocalWin()
|
||||
{
|
||||
signInManager = new( TAG_SYSTEM ) idSignInManagerWin;
|
||||
saveGameManager = new( TAG_SAVEGAMES ) idSaveGameManager();
|
||||
voiceChat = new( TAG_SYSTEM ) idVoiceChatMgrWin();
|
||||
lobbyToSessionCB = new( TAG_SYSTEM ) idLobbyToSessionCBLocal( this );
|
||||
|
||||
canJoinLocalHost = false;
|
||||
|
||||
lobbyBackends.Zero();
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::idSessionLocalWin
|
||||
========================
|
||||
*/
|
||||
idSessionLocalWin::~idSessionLocalWin()
|
||||
{
|
||||
delete voiceChat;
|
||||
delete lobbyToSessionCB;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::Initialize
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::Initialize()
|
||||
{
|
||||
idSessionLocal::Initialize();
|
||||
|
||||
// The shipping path doesn't load title storage
|
||||
// Instead, we inject values through code which is protected through steam DRM
|
||||
titleStorageVars.Set( "MAX_PLAYERS_ALLOWED", "8" );
|
||||
titleStorageLoaded = true;
|
||||
|
||||
// First-time check for downloadable content once game is launched
|
||||
EnumerateDownloadableContent();
|
||||
|
||||
GetPartyLobby().Initialize( idLobby::TYPE_PARTY, sessionCallbacks );
|
||||
GetGameLobby().Initialize( idLobby::TYPE_GAME, sessionCallbacks );
|
||||
GetGameStateLobby().Initialize( idLobby::TYPE_GAME_STATE, sessionCallbacks );
|
||||
|
||||
achievementSystem = new( TAG_SYSTEM ) idAchievementSystemWin();
|
||||
achievementSystem->Init();
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::Shutdown
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::Shutdown()
|
||||
{
|
||||
NET_VERBOSE_PRINT( "NET: Shutdown\n" );
|
||||
idSessionLocal::Shutdown();
|
||||
|
||||
MoveToMainMenu();
|
||||
|
||||
// Wait until we fully shutdown
|
||||
while( localState != STATE_IDLE && localState != STATE_PRESS_START )
|
||||
{
|
||||
Pump();
|
||||
}
|
||||
|
||||
if( achievementSystem != NULL )
|
||||
{
|
||||
achievementSystem->Shutdown();
|
||||
delete achievementSystem;
|
||||
achievementSystem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::InitializeSoundRelatedSystems
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::InitializeSoundRelatedSystems()
|
||||
{
|
||||
if( voiceChat != NULL )
|
||||
{
|
||||
voiceChat->Init( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ShutdownSoundRelatedSystems
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::ShutdownSoundRelatedSystems()
|
||||
{
|
||||
if( voiceChat != NULL )
|
||||
{
|
||||
voiceChat->Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::PlatformPump
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::PlatformPump()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::InviteFriends
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::InviteFriends()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::InviteParty
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::InviteParty()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ShowPartySessions
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::ShowPartySessions()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ShowSystemMarketplaceUI
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::ShowSystemMarketplaceUI() const
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ListServers
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::ListServers( const idCallback& callback )
|
||||
{
|
||||
ListServersCommon();
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::CancelListServers
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::CancelListServers()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::NumServers
|
||||
========================
|
||||
*/
|
||||
int idSessionLocalWin::NumServers() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ServerInfo
|
||||
========================
|
||||
*/
|
||||
const serverInfo_t* idSessionLocalWin::ServerInfo( int i ) const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ConnectToServer
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::ConnectToServer( int i )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::Connect_f
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::Connect_f( const idCmdArgs& args )
|
||||
{
|
||||
if( args.Argc() < 2 )
|
||||
{
|
||||
idLib::Printf( "Usage: Connect to IP. Use with net_port. \n" );
|
||||
return;
|
||||
}
|
||||
|
||||
Cancel();
|
||||
|
||||
if( signInManager->GetMasterLocalUser() == NULL )
|
||||
{
|
||||
signInManager->RegisterLocalUser( 0 );
|
||||
}
|
||||
|
||||
lobbyConnectInfo_t connectInfo;
|
||||
|
||||
Sys_StringToNetAdr( args.Argv( 1 ), &connectInfo.netAddr, true );
|
||||
connectInfo.netAddr.port = net_port.GetInteger();
|
||||
|
||||
ConnectAndMoveToLobby( GetPartyLobby(), connectInfo, false );
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
void Connect_f
|
||||
========================
|
||||
*/
|
||||
CONSOLE_COMMAND( connect, "Connect to the specified IP", NULL )
|
||||
{
|
||||
sessionLocalWin.Connect_f( args );
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ShowServerGamerCardUI
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::ShowServerGamerCardUI( int i )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ShowLobbyUserGamerCardUI(
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::ShowLobbyUserGamerCardUI( lobbyUserID_t lobbyUserID )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ProcessInputEvent
|
||||
========================
|
||||
*/
|
||||
bool idSessionLocalWin::ProcessInputEvent( const sysEvent_t* ev )
|
||||
{
|
||||
if( GetSignInManager().ProcessInputEvent( ev ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::IsSystemUIShowing
|
||||
========================
|
||||
*/
|
||||
bool idSessionLocalWin::IsSystemUIShowing() const
|
||||
{
|
||||
// DG: wtf, !win32.activeApp doesn't belong here, this is totally confusing and hacky.
|
||||
// pause (when losing focus or invoking explicitly) is now handled properly by com_pause
|
||||
return isSysUIShowing;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::SetSystemUIShowing
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::SetSystemUIShowing( bool show )
|
||||
{
|
||||
isSysUIShowing = show;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::HandleServerQueryRequest
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::HandleServerQueryRequest( lobbyAddress_t& remoteAddr, idBitMsg& msg, int msgType )
|
||||
{
|
||||
NET_VERBOSE_PRINT( "HandleServerQueryRequest from %s\n", remoteAddr.ToString() );
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::HandleServerQueryAck
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::HandleServerQueryAck( lobbyAddress_t& remoteAddr, idBitMsg& msg )
|
||||
{
|
||||
NET_VERBOSE_PRINT( "HandleServerQueryAck from %s\n", remoteAddr.ToString() );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ClearBootableInvite
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::ClearBootableInvite()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::ClearPendingInvite
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::ClearPendingInvite()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::HandleBootableInvite
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::HandleBootableInvite( int64 lobbyId )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::HasPendingBootableInvite
|
||||
========================
|
||||
*/
|
||||
bool idSessionLocalWin::HasPendingBootableInvite()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocal::SetDiscSwapMPInvite
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::SetDiscSwapMPInvite( void* parm )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocal::GetDiscSwapMPInviteParms
|
||||
========================
|
||||
*/
|
||||
void* idSessionLocalWin::GetDiscSwapMPInviteParms()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::EnumerateDownloadableContent
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::EnumerateDownloadableContent()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::LeaderboardUpload
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::LeaderboardUpload( lobbyUserID_t lobbyUserID, const leaderboardDefinition_t* leaderboard, const column_t* stats, const idFile_Memory* attachment )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::LeaderboardFlush
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::LeaderboardFlush()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::LeaderboardDownload
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::LeaderboardDownload( int sessionUserIndex, const leaderboardDefinition_t* leaderboard, int startingRank, int numRows, const idLeaderboardCallback& callback )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::LeaderboardDownloadAttachment
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::LeaderboardDownloadAttachment( int sessionUserIndex, const leaderboardDefinition_t* leaderboard, int64 attachmentID )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::EnsurePort
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::EnsurePort()
|
||||
{
|
||||
// Init the port using reqular windows sockets
|
||||
if( port.IsOpen() )
|
||||
{
|
||||
return; // Already initialized
|
||||
}
|
||||
|
||||
if( port.InitPort( net_port.GetInteger(), false ) )
|
||||
{
|
||||
canJoinLocalHost = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume this is another instantiation on the same machine, and just init using any available port
|
||||
port.InitPort( PORT_ANY, false );
|
||||
canJoinLocalHost = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::GetPort
|
||||
========================
|
||||
*/
|
||||
idNetSessionPort& idSessionLocalWin::GetPort( bool dedicated )
|
||||
{
|
||||
EnsurePort();
|
||||
return port;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::CreateLobbyBackend
|
||||
========================
|
||||
*/
|
||||
idLobbyBackend* idSessionLocalWin::CreateLobbyBackend( const idMatchParameters& p, float skillLevel, idLobbyBackend::lobbyBackendType_t lobbyType )
|
||||
{
|
||||
idLobbyBackend* lobbyBackend = CreateLobbyInternal( lobbyType );
|
||||
lobbyBackend->StartHosting( p, skillLevel, lobbyType );
|
||||
return lobbyBackend;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::FindLobbyBackend
|
||||
========================
|
||||
*/
|
||||
idLobbyBackend* idSessionLocalWin::FindLobbyBackend( const idMatchParameters& p, int numPartyUsers, float skillLevel, idLobbyBackend::lobbyBackendType_t lobbyType )
|
||||
{
|
||||
idLobbyBackend* lobbyBackend = CreateLobbyInternal( lobbyType );
|
||||
lobbyBackend->StartFinding( p, numPartyUsers, skillLevel );
|
||||
return lobbyBackend;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::JoinFromConnectInfo
|
||||
========================
|
||||
*/
|
||||
idLobbyBackend* idSessionLocalWin::JoinFromConnectInfo( const lobbyConnectInfo_t& connectInfo, idLobbyBackend::lobbyBackendType_t lobbyType )
|
||||
{
|
||||
idLobbyBackend* lobbyBackend = CreateLobbyInternal( lobbyType );
|
||||
lobbyBackend->JoinFromConnectInfo( connectInfo );
|
||||
return lobbyBackend;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::DestroyLobbyBackend
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::DestroyLobbyBackend( idLobbyBackend* lobbyBackend )
|
||||
{
|
||||
assert( lobbyBackend != NULL );
|
||||
assert( lobbyBackends[lobbyBackend->GetLobbyType()] == lobbyBackend );
|
||||
|
||||
lobbyBackends[lobbyBackend->GetLobbyType()] = NULL;
|
||||
|
||||
lobbyBackend->Shutdown();
|
||||
delete lobbyBackend;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::PumpLobbies
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::PumpLobbies()
|
||||
{
|
||||
assert( lobbyBackends[idLobbyBackend::TYPE_PARTY] == NULL || lobbyBackends[idLobbyBackend::TYPE_PARTY]->GetLobbyType() == idLobbyBackend::TYPE_PARTY );
|
||||
assert( lobbyBackends[idLobbyBackend::TYPE_GAME] == NULL || lobbyBackends[idLobbyBackend::TYPE_GAME]->GetLobbyType() == idLobbyBackend::TYPE_GAME );
|
||||
assert( lobbyBackends[idLobbyBackend::TYPE_GAME_STATE] == NULL || lobbyBackends[idLobbyBackend::TYPE_GAME_STATE]->GetLobbyType() == idLobbyBackend::TYPE_GAME_STATE );
|
||||
|
||||
// Pump lobbyBackends
|
||||
for( int i = 0; i < lobbyBackends.Num(); i++ )
|
||||
{
|
||||
if( lobbyBackends[i] != NULL )
|
||||
{
|
||||
lobbyBackends[i]->Pump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::CreateLobbyInternal
|
||||
========================
|
||||
*/
|
||||
idLobbyBackend* idSessionLocalWin::CreateLobbyInternal( idLobbyBackend::lobbyBackendType_t lobbyType )
|
||||
{
|
||||
EnsurePort();
|
||||
idLobbyBackend* lobbyBackend = new( TAG_NETWORKING ) idLobbyBackendDirect();
|
||||
|
||||
lobbyBackend->SetLobbyType( lobbyType );
|
||||
|
||||
assert( lobbyBackends[lobbyType] == NULL );
|
||||
lobbyBackends[lobbyType] = lobbyBackend;
|
||||
|
||||
return lobbyBackend;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::JoinAfterSwap
|
||||
========================
|
||||
*/
|
||||
void idSessionLocalWin::JoinAfterSwap( void* joinID )
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::GetLobbyAddressFromNetAddress
|
||||
========================
|
||||
*/
|
||||
bool idSessionLocalWin::GetLobbyAddressFromNetAddress( const netadr_t& netAddr, lobbyAddress_t& outAddr ) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSessionLocalWin::GetNetAddressFromLobbyAddress
|
||||
========================
|
||||
*/
|
||||
bool idSessionLocalWin::GetNetAddressFromLobbyAddress( const lobbyAddress_t& lobbyAddress, netadr_t& outNetAddr ) const
|
||||
{
|
||||
return false;
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#pragma hdrstop
|
||||
#include "precompiled.h"
|
||||
#include "../../framework/PlayerProfile.h"
|
||||
#include "../sys_session_local.h"
|
||||
#include "win_signin.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
idCVar win_userPersistent( "win_userPersistent", "1", CVAR_BOOL, "debugging cvar for profile persistence status" );
|
||||
idCVar win_userOnline( "win_userOnline", "1", CVAR_BOOL, "debugging cvar for profile online status" );
|
||||
idCVar win_isInParty( "win_isInParty", "0", CVAR_BOOL, "debugging cvar for platform party status" );
|
||||
idCVar win_partyCount( "win_partyCount", "0", CVAR_INTEGER, "debugginc var for platform party count" );
|
||||
#endif
|
||||
|
||||
// DG: D3BFG got the username from steam, in the GPL release it just uses the hostname.
|
||||
// this adds a name to set a player name
|
||||
idCVar ui_name( "ui_name", "", CVAR_ARCHIVE, "player name - leave empty for default name (system's hostname)" );
|
||||
// DG end
|
||||
|
||||
/*
|
||||
========================
|
||||
idSignInManagerWin::Shutdown
|
||||
========================
|
||||
*/
|
||||
void idSignInManagerWin::Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSignInManagerWin::Pump
|
||||
========================
|
||||
*/
|
||||
void idSignInManagerWin::Pump()
|
||||
{
|
||||
|
||||
// If we have more users than we need, then set to the lower amount
|
||||
// (don't remove the master user though)
|
||||
if( localUsers.Num() > 1 && localUsers.Num() > maxDesiredLocalUsers )
|
||||
{
|
||||
localUsers.SetNum( maxDesiredLocalUsers );
|
||||
}
|
||||
|
||||
#ifndef ID_RETAIL
|
||||
// If we don't have enough, then make sure we do
|
||||
// NOTE - We always want at least one user on windows for now,
|
||||
// and this master user will always use controller 0
|
||||
while( localUsers.Num() < minDesiredLocalUsers )
|
||||
{
|
||||
RegisterLocalUser( localUsers.Num() );
|
||||
}
|
||||
#endif
|
||||
|
||||
// See if we need to save settings on any of the profiles
|
||||
for( int i = 0; i < localUsers.Num(); i++ )
|
||||
{
|
||||
localUsers[i].Pump();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSignInManagerWin::RemoveLocalUserByIndex
|
||||
========================
|
||||
*/
|
||||
void idSignInManagerWin::RemoveLocalUserByIndex( int index )
|
||||
{
|
||||
session->OnLocalUserSignout( &localUsers[index] );
|
||||
localUsers.RemoveIndex( index );
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSignInManagerWin::RegisterLocalUser
|
||||
========================
|
||||
*/
|
||||
void idSignInManagerWin::RegisterLocalUser( int inputDevice )
|
||||
{
|
||||
if( GetLocalUserByInputDevice( inputDevice ) != NULL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static char machineName[128];
|
||||
// DG: support for ui_name
|
||||
const char* nameSource = ui_name.GetString();
|
||||
|
||||
if( idStr::Length( nameSource ) == 0 )
|
||||
{
|
||||
DWORD len = 128;
|
||||
::GetComputerName( machineName, &len );
|
||||
nameSource = machineName;
|
||||
}
|
||||
// DG end
|
||||
|
||||
idStr name( nameSource );
|
||||
int nameLength = name.Length();
|
||||
if( idStr::IsValidUTF8( nameSource, nameLength ) )
|
||||
{
|
||||
int nameIndex = 0;
|
||||
int numChars = 0;
|
||||
name.Empty();
|
||||
while( nameIndex < nameLength && numChars++ < idLocalUserWin::MAX_GAMERTAG_CHARS )
|
||||
{
|
||||
uint32 c = idStr::UTF8Char( nameSource, nameIndex );
|
||||
name.AppendUTF8Char( c );
|
||||
}
|
||||
}
|
||||
|
||||
idLocalUserWin& localUser = *localUsers.Alloc();
|
||||
|
||||
localUser.Init( inputDevice, name.c_str(), localUsers.Num() );
|
||||
localUser.SetLocalUserHandle( GetUniqueLocalUserHandle( localUser.GetGamerTag() ) );
|
||||
|
||||
session->OnLocalUserSignin( &localUser );
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idSignInManagerWin::CreateNewUser
|
||||
========================
|
||||
*/
|
||||
bool idSignInManagerWin::CreateNewUser( winUserState_t& state )
|
||||
{
|
||||
//idScopedGlobalHeap everythingHereGoesInTheGlobalHeap; // users obviously persist across maps
|
||||
|
||||
RemoveAllLocalUsers();
|
||||
RegisterLocalUser( state.inputDevice );
|
||||
|
||||
if( localUsers.Num() > 0 )
|
||||
{
|
||||
if( !localUsers[0].VerifyUserState( state ) )
|
||||
{
|
||||
RemoveAllLocalUsers();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CONSOLE_COMMAND( testRemoveAllLocalUsers, "Forces removal of local users - mainly for PC testing", NULL )
|
||||
{
|
||||
session->GetSignInManager().RemoveAllLocalUsers();
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
#ifndef __WIN_SIGNIN_H__
|
||||
#define __WIN_SIGNIN_H__
|
||||
|
||||
#include "win_localuser.h"
|
||||
|
||||
/*
|
||||
================================================
|
||||
idSignInManagerWin
|
||||
================================================
|
||||
*/
|
||||
class idSignInManagerWin : public idSignInManagerBase
|
||||
{
|
||||
public:
|
||||
|
||||
idSignInManagerWin() : dlcVersionChecked( false ) {}
|
||||
virtual ~idSignInManagerWin() {}
|
||||
|
||||
//==========================================================================================
|
||||
// idSignInManagerBase interface
|
||||
//==========================================================================================
|
||||
virtual void Pump();
|
||||
virtual void Shutdown();
|
||||
virtual int GetNumLocalUsers() const
|
||||
{
|
||||
return localUsers.Num();
|
||||
}
|
||||
virtual idLocalUser* GetLocalUserByIndex( int index )
|
||||
{
|
||||
return &localUsers[index];
|
||||
}
|
||||
virtual const idLocalUser* GetLocalUserByIndex( int index ) const
|
||||
{
|
||||
return &localUsers[index];
|
||||
}
|
||||
virtual void RemoveLocalUserByIndex( int index );
|
||||
virtual void RegisterLocalUser( int inputDevice ); // Register a local user to the passed in controller
|
||||
|
||||
bool CreateNewUser( winUserState_t& state );
|
||||
|
||||
private:
|
||||
idStaticList< idLocalUserWin, MAX_INPUT_DEVICES > localUsers;
|
||||
bool dlcVersionChecked;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue