1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-06 18:57:45 +00:00

Added a simple version check to worldServer.

This commit is contained in:
Mordred 2023-03-03 21:47:05 +01:00
parent fe471fb4f1
commit 86f0432293
3 changed files with 41 additions and 0 deletions

View file

@ -12,6 +12,7 @@ namespace Sapphire::Common::Config
{ {
std::string serverSecret; std::string serverSecret;
std::string dataPath; std::string dataPath;
std::string dataVersion;
uint16_t worldID; uint16_t worldID;
uint8_t defaultGMRank; uint8_t defaultGMRank;

View file

@ -62,6 +62,7 @@ bool ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config, const st
// params // params
config.general.dataPath = getValue< std::string >( "General", "DataPath", "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" ); config.general.dataPath = getValue< std::string >( "General", "DataPath", "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
config.general.dataVersion = getValue< std::string >( "General", "DataVersion", "2016.07.05.0000.0001" );
config.general.serverSecret = getValue< std::string >( "General", "ServerSecret", "default" ); config.general.serverSecret = getValue< std::string >( "General", "ServerSecret", "default" );
config.general.worldID = getValue< uint16_t >( "General", "WorldID", 67 ); config.general.worldID = getValue< uint16_t >( "General", "WorldID", 67 );
config.general.defaultGMRank = getValue< uint8_t >( "General", "DefaultGMRank", 255 ); config.general.defaultGMRank = getValue< uint8_t >( "General", "DefaultGMRank", 255 );

View file

@ -126,6 +126,28 @@ bool WorldServer::loadSettings( int32_t argc, char* argv[] )
return true; return true;
} }
std::string readFileToString( const std::string& filename )
{
// Open the file for reading
std::ifstream file( filename );
// Check if the file was opened successfully
if( !file )
{
throw std::runtime_error( "Failed to open file" );
}
// Read the contents of the file into a string
std::string fileContents( ( std::istreambuf_iterator< char >( file ) ),
std::istreambuf_iterator< char >() );
// Close the file
file.close();
// Return the file contents as a string
return fileContents;
}
void WorldServer::run( int32_t argc, char* argv[] ) void WorldServer::run( int32_t argc, char* argv[] )
{ {
using namespace Sapphire; using namespace Sapphire;
@ -146,6 +168,23 @@ void WorldServer::run( int32_t argc, char* argv[] )
Logger::info( "Setting up generated EXD data" ); Logger::info( "Setting up generated EXD data" );
auto pExdData = std::make_shared< Data::ExdData >(); auto pExdData = std::make_shared< Data::ExdData >();
auto dataPath = m_config.global.general.dataPath; auto dataPath = m_config.global.general.dataPath;
try
{
auto verPath = dataPath + "/../ffxivgame.ver";
auto verString = readFileToString( verPath );
if( verString != m_config.global.general.dataVersion )
{
Logger::fatal( "Sqpack version {} does not match expected version {}!", verString, m_config.global.general.dataVersion );
return;
}
}
catch ( const std::exception& e )
{
Logger::fatal( e.what() );
return;
}
if( !pExdData->init( dataPath ) ) if( !pExdData->init( dataPath ) )
{ {
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" ); Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" );