From 23e2bb4b7bd609057bf0a5d598d33c08117c14f8 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Wed, 9 Aug 2017 23:49:00 +0100 Subject: [PATCH 01/11] fix 64bit build --- .travis.yml | 4 +--- src/libraries | 2 +- src/servers/Server_Common/CMakeLists.txt | 2 +- src/servers/Server_Lobby/blowfish.cpp | 3 ++- src/servers/Server_REST/CMakeLists.txt | 2 +- src/servers/Server_Zone/Zone.cpp | 6 +++--- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7849b63..54be0136 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,7 @@ before_install: - sudo apt-get install -y software-properties-common - sudo apt-get update - sudo apt-get install gcc-4.9 g++-4.9 gcc-4.9-multilib g++-4.9-multilib - - sudo apt-get remove 'libboost.*' - - sudo apt-get remove 'libmysqlclient.*' - - sudo apt-get install libboost-dev:i386 libboost-all-dev:i386 libmysqlclient-dev:i386 + - sudo apt-get install libboost-dev libboost-all-dev libmysqlclient-dev:i386 compiler: - gcc diff --git a/src/libraries b/src/libraries index 278556fc..0f6ea9dd 160000 --- a/src/libraries +++ b/src/libraries @@ -1 +1 @@ -Subproject commit 278556fc80472b87810348bfc2b988ae10a997c1 +Subproject commit 0f6ea9ddd28f3defc69bb92413442c71db48e8b4 diff --git a/src/servers/Server_Common/CMakeLists.txt b/src/servers/Server_Common/CMakeLists.txt index 04e0ea48..1661ac65 100644 --- a/src/servers/Server_Common/CMakeLists.txt +++ b/src/servers/Server_Common/CMakeLists.txt @@ -7,7 +7,7 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../../libraries/external/ChaiSc if(UNIX) include_directories("/usr/include/mysql/") message(STATUS "Setting GCC flags") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") find_package(Boost ${SAPPHIRE_BOOST_VER} COMPONENTS log log_setup thread date_time filesystem system) if(Boost_FOUND) diff --git a/src/servers/Server_Lobby/blowfish.cpp b/src/servers/Server_Lobby/blowfish.cpp index ab15ecad..1c23e2b2 100644 --- a/src/servers/Server_Lobby/blowfish.cpp +++ b/src/servers/Server_Lobby/blowfish.cpp @@ -4,6 +4,7 @@ // Revised code--3/20/94 // Converted to C++ class 5/96, Jim Conger +#include #include "blowfish.h" #include "blowfish.h2" // holds the random digit tables @@ -103,7 +104,7 @@ void BlowFish::initialize (BYTE key[], int keybytes) int v10 = keybytes; - int v9 = (int)key; + int v9 = (uintptr_t)key; int v8 = 0; int v11 = 0; do { diff --git a/src/servers/Server_REST/CMakeLists.txt b/src/servers/Server_REST/CMakeLists.txt index 80e8d840..80252299 100644 --- a/src/servers/Server_REST/CMakeLists.txt +++ b/src/servers/Server_REST/CMakeLists.txt @@ -15,7 +15,7 @@ set(Boost_USE_STATIC_LIBS ON) if(UNIX) include_directories("/usr/include/mysql/") message(STATUS "Setting GCC flags") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") find_package(Boost ${SAPPHIRE_BOOST_VER} COMPONENTS log log_setup thread date_time filesystem system) if(Boost_FOUND) diff --git a/src/servers/Server_Zone/Zone.cpp b/src/servers/Server_Zone/Zone.cpp index 0b670779..7070252a 100644 --- a/src/servers/Server_Zone/Zone.cpp +++ b/src/servers/Server_Zone/Zone.cpp @@ -226,14 +226,14 @@ uint8_t Zone::getNextWeather() { auto zoneInfo = g_exdData.m_zoneInfoMap[ getLayoutId() ]; - uint32_t unix = static_cast< uint32_t >( time( nullptr ) ); + uint32_t unixTime = static_cast< uint32_t >( time( nullptr ) ); // Get Eorzea hour for weather start - uint32_t bell = unix / 175; + uint32_t bell = unixTime / 175; // Do the magic 'cause for calculations 16:00 is 0, 00:00 is 8 and 08:00 is 16 int32_t increment = ( ( bell + 8 - ( bell % 8 ) ) ) % 24; // Take Eorzea days since unix epoch - uint32_t totalDays = ( unix / 4200 ); + uint32_t totalDays = ( unixTime / 4200 ); uint32_t calcBase = ( totalDays * 0x64 ) + increment; From 04105eaad4e47149df7555d6e265a31813b04ef1 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Thu, 10 Aug 2017 18:07:35 +0100 Subject: [PATCH 02/11] apparently i didnt commit this --- .travis.yml | 2 +- src/servers/Server_Lobby/CMakeLists.txt | 2 +- src/servers/Server_Zone/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 54be0136..fc646c25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_install: - sudo apt-get install -y software-properties-common - sudo apt-get update - sudo apt-get install gcc-4.9 g++-4.9 gcc-4.9-multilib g++-4.9-multilib - - sudo apt-get install libboost-dev libboost-all-dev libmysqlclient-dev:i386 + - sudo apt-get install libboost-dev libboost-all-dev libmysqlclient-dev compiler: - gcc diff --git a/src/servers/Server_Lobby/CMakeLists.txt b/src/servers/Server_Lobby/CMakeLists.txt index 57cdcd6b..53b2d556 100644 --- a/src/servers/Server_Lobby/CMakeLists.txt +++ b/src/servers/Server_Lobby/CMakeLists.txt @@ -15,7 +15,7 @@ set(Boost_USE_STATIC_LIBS ON) if(UNIX) include_directories("/usr/include/mysql/") message(STATUS "Setting GCC flags") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") find_package(Boost ${SAPPHIRE_BOOST_VER} COMPONENTS log log_setup thread date_time filesystem system) if(Boost_FOUND) diff --git a/src/servers/Server_Zone/CMakeLists.txt b/src/servers/Server_Zone/CMakeLists.txt index 7d4afbce..ebc36ef3 100644 --- a/src/servers/Server_Zone/CMakeLists.txt +++ b/src/servers/Server_Zone/CMakeLists.txt @@ -15,7 +15,7 @@ set(Boost_USE_STATIC_LIBS ON) if(UNIX) include_directories("/usr/include/mysql/") message(STATUS "Setting GCC flags") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") find_package(Boost ${SAPPHIRE_BOOST_VER} COMPONENTS log log_setup thread date_time filesystem system) if(Boost_FOUND) From 93763c500516713280d09222fc437d8e71e1b031 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Thu, 10 Aug 2017 22:13:00 +0100 Subject: [PATCH 03/11] added launch args to server_rest (needs testing) --- src/servers/Server_REST/main.cpp | 254 +++++++++++++++++-------------- 1 file changed, 140 insertions(+), 114 deletions(-) diff --git a/src/servers/Server_REST/main.cpp b/src/servers/Server_REST/main.cpp index a1279231..ff7382c7 100644 --- a/src/servers/Server_REST/main.cpp +++ b/src/servers/Server_REST/main.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -43,35 +44,100 @@ typedef SimpleWeb::Client HttpClient; void default_resource_send( const HttpServer &server, const shared_ptr &response, const shared_ptr &ifs ); + +auto m_pConfig = boost::make_shared(); +HttpServer server; +std::string configPath("config/settings_rest.xml"); + +void reloadConfig() +{ + m_pConfig = boost::make_shared(); + + if (!m_pConfig->loadConfig(configPath)) + throw std::exception( std::string("Error loading config " + configPath).c_str() ); +} + void print_request_info( shared_ptr request ) { g_log.info( "Request from " + request->remote_endpoint_address + " (" + request->path + ")" ); } - -int main() +bool loadSettings( int argc, char* argv[] ) { - g_log.setLogPath( "log\\SapphireAPI" ); - g_log.init(); + g_log.info( "Loading config " + configPath ); - g_log.info( "===========================================================" ); - g_log.info( "Sapphire API Server " ); - g_log.info( "Version: 0.0.1" ); - g_log.info( "Compiled: " __DATE__ " " __TIME__ ); - g_log.info( "===========================================================" ); - - auto m_pConfig = new Core::XMLConfig(); - - g_log.info( "Loading config settings_rest.xml" ); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) + if( !m_pConfig->loadConfig( configPath ) ) { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; + g_log.fatal( "Error loading config " + configPath ); + return false; } - if( !g_exdData.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath" ) ) ) + std::vector args( argv + 1, argv + argc ); + for( auto i = 0; i + 1 < args.size(); i += 2 ) + { + std::string arg( "" ); + std::string val( "" ); + + try + { + arg = boost::to_lower_copy( std::string( args[i] ) ); + val = std::string( args[i + 1] ); + + // trim '-' from start of arg + arg = arg.erase( 0, arg.find_first_not_of( '-' ) ); + + if( arg == "ip" ) + { + // todo: ip addr in config + m_pConfig->setValue< std::string >( "Settings.General.ListenIP", val ); + } + else if( arg == "p" || arg == "port" ) + { + m_pConfig->setValue< std::string >( "Settings.General.ListenPort", val ); + } + else if( arg == "exdpath" || arg == "datapath" ) + { + m_pConfig->setValue< std::string >( "Settings.General.DataPath", val ); + } + else if( arg == "h" || arg == "dbhost" ) + { + m_pConfig->setValue< std::string >( "Settings.General.Mysql.Host", val ); + } + else if( arg == "dbport" ) + { + m_pConfig->setValue< std::string >( "Settings.General.Mysql.Port", val ); + } + else if( arg == "u" || arg == "user" || arg == "dbuser" ) + { + m_pConfig->setValue< std::string >( "Settings.General.Mysql.Username", val ); + } + else if( arg == "pass" || arg == "dbpass" ) + { + m_pConfig->setValue< std::string >( "Settings.General.Mysql.Pass", val ); + } + else if( arg == "d" || arg == "db" || arg == "database" ) + { + m_pConfig->setValue< std::string >( "Settings.General.Mysql.Database", val ); + } + else if ( arg == "lobbyip" || arg == "lobbyhost" ) + { + m_pConfig->setValue< std::string >( "Settings.General.LobbyHost", val ); + } + else if ( arg == "lobbyport" ) + { + m_pConfig->setValue< std::string >( "Settings.General.LobbyPort", val ); + } + } + catch( ... ) + { + g_log.error( "Error parsing argument: " + arg + " " + "value: " + val + "\n" ); + g_log.error( "Usage: \n" ); + } + } + + g_log.info( "Setting up EXD data" ); + if( !g_exdData.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) ) { g_log.fatal( "Error setting up EXD data " ); - return 1; + return false; } Core::Db::DatabaseParams params; @@ -83,21 +149,42 @@ int main() params.port = m_pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 ); params.username = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" ); + server.config.port = std::stoul( m_pConfig->getValue( "Settings.General.HttpPort", "80" ) ); + if( !g_database.initialize( params ) ) { std::this_thread::sleep_for( std::chrono::milliseconds( 5000 ) ); - return -1; + return false; + } + + g_log.info("Database: Connected to " + params.hostname + ":" + std::to_string(params.port)); + + return true; +} + +int main(int argc, char* argv[]) +{ + g_log.setLogPath( "log\\SapphireAPI" ); + g_log.init(); + + g_log.info( "===========================================================" ); + g_log.info( "Sapphire API Server " ); + g_log.info( "Version: 0.0.1" ); + g_log.info( "Compiled: " __DATE__ " " __TIME__ ); + g_log.info( "===========================================================" ); + + if (!loadSettings(argc, argv)) + { + throw std::exception(); } - g_log.info( "Database: Connected to " + params.hostname + ":" + std::to_string( params.port ) ); g_exdData.loadZoneInfo(); g_exdData.loadClassJobInfo(); - HttpServer server; server.config.port = stoi( m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) ); g_log.info( "Starting REST server at port " + m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) + "..." ); - server.resource["^/ZoneName/([0-9]+)$"]["GET"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/ZoneName/([0-9]+)$"]["GET"] = [&]( shared_ptr response, shared_ptr request ) { string number = request->path_match[1]; auto it = g_exdData.m_zoneInfoMap.find( atoi( number.c_str() ) ); std::string responseStr = "Not found!"; @@ -110,7 +197,7 @@ int main() /* Create account */ - server.resource["^/sapphire-api/lobby/createAccount"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/createAccount"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); std::string responseStr = "HTTP/1.1 400\r\n\r\n"; @@ -124,19 +211,11 @@ int main() std::string pass = pt.get( "pass" ); std::string user = pt.get( "username" ); + // reloadConfig(); + std::string sId; if( g_sapphireAPI.createAccount( user, pass, sId ) ) { - auto m_pConfig = new Core::XMLConfig(); - - g_log.info( "Loading config settings_rest.xml" ); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } - std::string json_string = "{\"sId\":\"" + sId + "\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.LobbyHost" ) + "\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.FrontierHost" ) + "\"}"; *response << "HTTP/1.1 200 OK\r\n " << "Content-Type: application/json\r\n" @@ -155,7 +234,7 @@ int main() }; - server.resource["^/sapphire-api/lobby/login"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/login"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -169,16 +248,10 @@ int main() std::string sId; + // reloadConfig(); + if( g_sapphireAPI.login( user, pass, sId ) ) { - auto m_pConfig = new Core::XMLConfig(); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } - std::string json_string = "{\"sId\":\"" + sId + "\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >("Settings.General.LobbyHost") + "\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.FrontierHost" ) + "\"}"; *response << "HTTP/1.1 200\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string; } @@ -194,7 +267,7 @@ int main() }; - server.resource["^/sapphire-api/lobby/deleteCharacter"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/deleteCharacter"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -206,16 +279,10 @@ int main() std::string sId = pt.get( "sId" ); std::string secret = pt.get( "secret" ); std::string name = pt.get( "name" ); + + // reloadConfig(); int accountId = g_sapphireAPI.checkSession( sId ); - - auto m_pConfig = new Core::XMLConfig(); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; @@ -236,7 +303,7 @@ int main() }; - server.resource["^/sapphire-api/lobby/createCharacter"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/createCharacter"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -252,18 +319,12 @@ int main() std::string finalJson = Core::Util::base64_decode( infoJson ); + // reloadConfig(); + int result = g_sapphireAPI.checkSession( sId ); if( result != -1 ) { - auto m_pConfig = new Core::XMLConfig(); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } - if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << "HTTP/1.1 403\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string; @@ -290,7 +351,7 @@ int main() }; - server.resource["^/sapphire-api/lobby/insertSession"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/insertSession"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -303,13 +364,7 @@ int main() uint32_t accountId = pt.get( "accountId" ); std::string secret = pt.get( "secret" ); - auto m_pConfig = new Core::XMLConfig(); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } + // reloadConfig(); if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; @@ -330,7 +385,7 @@ int main() }; - server.resource["^/sapphire-api/lobby/checkNameTaken"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/checkNameTaken"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -342,13 +397,7 @@ int main() std::string name = pt.get( "name" ); std::string secret = pt.get( "secret" ); - auto m_pConfig = new Core::XMLConfig(); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } + // reloadConfig(); if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; @@ -373,7 +422,7 @@ int main() }; - server.resource["^/sapphire-api/lobby/checkSession"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/checkSession"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -387,16 +436,10 @@ int main() int result = g_sapphireAPI.checkSession( sId ); + // reloadConfig(); + if( result != -1 ) { - auto m_pConfig = new Core::XMLConfig(); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } - if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << "HTTP/1.1 403\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string; @@ -421,7 +464,7 @@ int main() }; - server.resource["^/sapphire-api/lobby/getNextCharId"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/getNextCharId"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -432,13 +475,7 @@ int main() std::string secret = pt.get( "secret" ); - auto m_pConfig = new Core::XMLConfig(); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } + // reloadConfig(); if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; @@ -458,7 +495,7 @@ int main() }; - server.resource["^/sapphire-api/lobby/getNextContentId"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/getNextContentId"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -469,13 +506,7 @@ int main() std::string secret = pt.get( "secret" ); - auto m_pConfig = new Core::XMLConfig(); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } + // reloadConfig(); if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; @@ -495,7 +526,7 @@ int main() }; - server.resource["^/sapphire-api/lobby/getCharacterList"]["POST"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^/sapphire-api/lobby/getCharacterList"]["POST"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -507,17 +538,12 @@ int main() std::string sId = pt.get( "sId" ); std::string secret = pt.get( "secret" ); + // reloadConfig(); + int result = g_sapphireAPI.checkSession( sId ); if( result != -1 ) { - auto m_pConfig = new Core::XMLConfig(); - - if( !m_pConfig->loadConfig( "config/settings_rest.xml" ) ) - { - g_log.fatal( "Error loading config settings_rest.xml" ); - return 1; - } if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; @@ -562,7 +588,7 @@ int main() }; - server.resource["^(/frontier-api/ffxivsupport/view/get_init)(.*)"]["GET"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^(/frontier-api/ffxivsupport/view/get_init)(.*)"]["GET"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -603,7 +629,7 @@ int main() }; - server.resource["^(/frontier-api/ffxivsupport/information/get_headline_all)(.*)"]["GET"] = [&server]( shared_ptr response, shared_ptr request ) { + server.resource["^(/frontier-api/ffxivsupport/information/get_headline_all)(.*)"]["GET"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -648,7 +674,7 @@ int main() //Will respond with content in the web/-directory, and its subdirectories. //Default file: index.html //Can for instance be used to retrieve an HTML 5 client that uses REST-resources on this server - server.default_resource["GET"] = [&server]( shared_ptr response, shared_ptr request ) { + server.default_resource["GET"] = [&]( shared_ptr response, shared_ptr request ) { print_request_info( request ); try @@ -690,7 +716,7 @@ int main() } }; - thread server_thread( [&server]() { + thread server_thread( [&]() { //Start server server.start(); } ); From 85292ad0510c58ccdd018729c664337ecda7c650 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Thu, 10 Aug 2017 23:33:46 +0100 Subject: [PATCH 04/11] fix exception crap from previous commit --- src/servers/Server_REST/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/Server_REST/main.cpp b/src/servers/Server_REST/main.cpp index ff7382c7..72e59ca4 100644 --- a/src/servers/Server_REST/main.cpp +++ b/src/servers/Server_REST/main.cpp @@ -54,7 +54,7 @@ void reloadConfig() m_pConfig = boost::make_shared(); if (!m_pConfig->loadConfig(configPath)) - throw std::exception( std::string("Error loading config " + configPath).c_str() ); + throw "Error loading config "; } void print_request_info( shared_ptr request ) { From d4cb82d82beea1492215027c2b73be49c7d5b935 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Fri, 11 Aug 2017 02:48:56 +0100 Subject: [PATCH 05/11] added sql import script --- .travis.yml | 3 ++- sql_import.sh | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 sql_import.sh diff --git a/.travis.yml b/.travis.yml index fc646c25..b9d6974f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,4 +30,5 @@ install: script: - mkdir build - cd build - - ${DEPS_DIR}/cmake/bin/cmake .. -DSAPPHIRE_BOOST_VER="1.54.0" -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_C_COMPILER=gcc-4.9 && make \ No newline at end of file + - ${DEPS_DIR}/cmake/bin/cmake .. -DSAPPHIRE_BOOST_VER="1.54.0" -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_C_COMPILER=gcc-4.9 && make + - sh ./sql_import.sh diff --git a/sql_import.sh b/sql_import.sh new file mode 100644 index 00000000..59785957 --- /dev/null +++ b/sql_import.sh @@ -0,0 +1,15 @@ +#!/bin/bash +cd sql +mysql -u root -e 'drop database sapphire;' +mysql -u root -e 'create database sapphire;' +for f in *.sql + do + [ "$f" = "update.sql" ] && continue; + echo -n "importing $f into the database..." + mysql sapphire -u root < $f && echo "Success" + CODE=$? + if [ $CODE -ne 0 ]; then exit $CODE; fi +done +mysql sapphire -u root < update.sql -f +echo 'todo: test update sql' +cd .. From ba5a385d2919f5b1a1c327ec3589ab7f044d858f Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Fri, 11 Aug 2017 03:46:41 +0100 Subject: [PATCH 06/11] lets see if it imports this time.. --- .travis.yml | 24 ++++++------------------ sql_import.sh | 3 +-- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index b9d6974f..484be1ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,29 +6,17 @@ before_install: - sudo apt-get update - sudo apt-get install -y software-properties-common - sudo apt-get update - - sudo apt-get install gcc-4.9 g++-4.9 gcc-4.9-multilib g++-4.9-multilib - - sudo apt-get install libboost-dev libboost-all-dev libmysqlclient-dev + - sudo apt-get install gcc-4.9 g++-4.9 gcc-4.9-multilib g++-4.9-multilib cmake3 -y + - sudo apt-get install libboost-dev libboost-all-dev libmysqlclient-dev -y compiler: - gcc -install: - - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - - mkdir ${DEPS_DIR} && cd ${DEPS_DIR} - - - | - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then - CMAKE_URL="http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz" - mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake - export PATH=${DEPS_DIR}/cmake/bin:${PATH} - fi - - # Go to the Root directory - - cd .. - + # Build steps script: - mkdir build - cd build - - ${DEPS_DIR}/cmake/bin/cmake .. -DSAPPHIRE_BOOST_VER="1.54.0" -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_C_COMPILER=gcc-4.9 && make - - sh ./sql_import.sh + - cmake .. -DSAPPHIRE_BOOST_VER="1.54.0" -DCMAKE_CXX_COMPILER=g++-4.9 -DCMAKE_C_COMPILER=gcc-4.9 && make -j 3 + - cd .. + - bash sql_import.sh \ No newline at end of file diff --git a/sql_import.sh b/sql_import.sh index 59785957..a49e7f12 100644 --- a/sql_import.sh +++ b/sql_import.sh @@ -1,6 +1,5 @@ #!/bin/bash cd sql -mysql -u root -e 'drop database sapphire;' mysql -u root -e 'create database sapphire;' for f in *.sql do @@ -10,6 +9,6 @@ for f in *.sql CODE=$? if [ $CODE -ne 0 ]; then exit $CODE; fi done -mysql sapphire -u root < update.sql -f +#mysql sapphire -u root < update.sql -f echo 'todo: test update sql' cd .. From c06874e4b4f8de81440cb64a55beecc17f9b03c3 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Fri, 11 Aug 2017 15:18:40 +0100 Subject: [PATCH 07/11] add travis badge to readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8ff2cc7..4fa10544 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Sapphire - FINAL FANTASY XIV Server Emulator [![Discord Server](https://img.shields.io/badge/discord-Sapphire-7289DA.svg)](https://discord.gg/KfrZCkx) - +[![Build Status](https://travis-ci.org/SapphireMordred/Sapphire.svg?branch=master)](https://travis-ci.org/SapphireMordred/Sapphire) ![FFXIV Sapphire](http://i.imgur.com/I4bj1tR.png) Sapphire is a FINAL FANTASY XIV 4.0+ Server Emulator currently in development. From 82af45e5619c8b24ff77e6ae5fa72e897032d38a Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Fri, 11 Aug 2017 22:56:30 +0100 Subject: [PATCH 08/11] mass replace data types to fixed width ones --- src/libraries | 2 +- src/servers/Server_Common/Database.cpp | 8 ++--- src/servers/Server_Common/GamePacket.cpp | 4 +-- src/servers/Server_Common/GamePacket.h | 12 ++++---- src/servers/Server_Common/PacketContainer.cpp | 4 +-- src/servers/Server_Common/Util.cpp | 4 +-- src/servers/Server_Common/base64.cpp | 22 +++++++------- src/servers/Server_Common/base64.h | 2 +- src/servers/Server_Common/md5.cpp | 2 +- src/servers/Server_Common/md5.h | 2 +- src/servers/Server_Lobby/GameConnection.cpp | 4 +-- src/servers/Server_Lobby/RestConnector.cpp | 2 +- src/servers/Server_Lobby/RestConnector.h | 2 +- src/servers/Server_Lobby/ServerLobby.cpp | 4 +-- src/servers/Server_Lobby/ServerLobby.h | 4 +-- src/servers/Server_Lobby/blowfish.cpp | 30 +++++++++---------- src/servers/Server_Lobby/blowfish.h | 30 +++++++++---------- src/servers/Server_Lobby/mainLobbyServer.cpp | 2 +- src/servers/Server_REST/PlayerMinimal.cpp | 6 ++-- src/servers/Server_REST/SapphireAPI.cpp | 16 +++++----- src/servers/Server_REST/SapphireAPI.h | 4 +-- src/servers/Server_REST/main.cpp | 12 ++++---- src/servers/Server_REST/server_http.hpp | 2 +- src/servers/Server_Zone/Actor.cpp | 2 +- src/servers/Server_Zone/GameConnection.cpp | 2 +- src/servers/Server_Zone/Inventory.cpp | 18 +++++------ src/servers/Server_Zone/ItemContainer.cpp | 2 +- src/servers/Server_Zone/PacketHandlers.cpp | 6 ++-- src/servers/Server_Zone/Player.cpp | 12 ++++---- src/servers/Server_Zone/PlayerQuest.cpp | 10 +++---- src/servers/Server_Zone/PlayerSql.cpp | 2 +- .../Server_Zone/PlayerStateFlagsPacket.h | 2 +- src/servers/Server_Zone/ScriptManager.h | 2 +- src/servers/Server_Zone/ServerZone.cpp | 4 +-- src/servers/Server_Zone/ServerZone.h | 4 +-- src/servers/Server_Zone/Zone.cpp | 8 ++--- src/servers/Server_Zone/Zone.h | 2 +- src/servers/Server_Zone/mainGameServer.cpp | 2 +- 38 files changed, 129 insertions(+), 129 deletions(-) diff --git a/src/libraries b/src/libraries index 0f6ea9dd..23b9c0a1 160000 --- a/src/libraries +++ b/src/libraries @@ -1 +1 @@ -Subproject commit 0f6ea9ddd28f3defc69bb92413442c71db48e8b4 +Subproject commit 23b9c0a154a327b25d700cd6857a4e53bed2e8a1 diff --git a/src/servers/Server_Common/Database.cpp b/src/servers/Server_Common/Database.cpp index af9ba2ab..f43789bd 100644 --- a/src/servers/Server_Common/Database.cpp +++ b/src/servers/Server_Common/Database.cpp @@ -255,7 +255,7 @@ std::string Database::escapeString( std::string Escape ) DatabaseConnection * con = getFreeConnection(); const char * ret; - if( mysql_real_escape_string( con->conn, a2, Escape.c_str(), ( unsigned long ) Escape.length() ) == 0 ) + if( mysql_real_escape_string( con->conn, a2, Escape.c_str(), ( uint32_t ) Escape.length() ) == 0 ) { ret = Escape.c_str(); } @@ -272,7 +272,7 @@ void Database::escapeLongString( const char * str, uint32_t len, std::stringstre char a2[65536 * 3] = { 0 }; DatabaseConnection * con = getFreeConnection(); - mysql_real_escape_string( con->conn, a2, str, ( unsigned long ) len ); + mysql_real_escape_string( con->conn, a2, str, ( uint32_t ) len ); out.write( a2, ( std::streamsize )strlen( a2 ) ); con->lock.unlock(); @@ -282,7 +282,7 @@ std::string Database::escapeString( const char * esc, DatabaseConnection * con ) { char a2[16384] = { 0 }; const char * ret; - if( mysql_real_escape_string( con->conn, a2, ( char* ) esc, ( unsigned long ) strlen( esc ) ) == 0 ) + if( mysql_real_escape_string( con->conn, a2, ( char* ) esc, ( uint32_t ) strlen( esc ) ) == 0 ) { ret = esc; } @@ -297,7 +297,7 @@ std::string Database::escapeString( const char * esc, DatabaseConnection * con ) bool Database::_SendQuery( DatabaseConnection *con, const char* Sql, bool Self ) { //dunno what it does ...leaving untouched - int result = mysql_query( con->conn, Sql ); + int32_t result = mysql_query( con->conn, Sql ); if( result > 0 ) { if( Self == false && _HandleError( con, mysql_errno( con->conn ) ) ) diff --git a/src/servers/Server_Common/GamePacket.cpp b/src/servers/Server_Common/GamePacket.cpp index a7084c72..180ccfec 100644 --- a/src/servers/Server_Common/GamePacket.cpp +++ b/src/servers/Server_Common/GamePacket.cpp @@ -98,9 +98,9 @@ std::string Core::Network::Packets::GamePacket::toString() { std::string str = "\n"; - for( unsigned int i = 0; i < getSize(); i++ ) + for( uint32_t i = 0; i < getSize(); i++ ) { - str += boost::str( boost::format( "%|02X|" ) % ( int ) ( m_dataBuf[i] & 0xFF ) ) + " "; + str += boost::str( boost::format( "%|02X|" ) % ( int32_t ) ( m_dataBuf[i] & 0xFF ) ) + " "; if( ( i + 1 ) % 16 == 0 ) str += "\n"; diff --git a/src/servers/Server_Common/GamePacket.h b/src/servers/Server_Common/GamePacket.h index bee8675a..d4bf27c3 100644 --- a/src/servers/Server_Common/GamePacket.h +++ b/src/servers/Server_Common/GamePacket.h @@ -38,7 +38,7 @@ public: template void setValAt( uint16_t pos, T value ) { - memcpy( reinterpret_cast< unsigned char* >( &m_dataBuf[0] + pos ), &value, sizeof( T ) ); + memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), &value, sizeof( T ) ); } template @@ -47,9 +47,9 @@ public: return *reinterpret_cast< T* >( &m_dataBuf[0] + pos ); } - void setBytesAt( uint16_t offset, unsigned char * bytes, uint16_t length ) + void setBytesAt( uint16_t offset, uint8_t * bytes, uint16_t length ) { - memcpy( reinterpret_cast< unsigned char* >( &m_dataBuf[0] + offset ), bytes, length ); + memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + offset ), bytes, length ); } char * getStringAt( uint16_t pos ) @@ -59,12 +59,12 @@ public: void setStringAt( uint16_t pos, const std::string& str ) { - memcpy( reinterpret_cast< unsigned char* >( &m_dataBuf[0] + pos ), str.c_str(), str.length() ); + memcpy( reinterpret_cast< uint8_t* >( &m_dataBuf[0] + pos ), str.c_str(), str.length() ); } - unsigned char * getData() + uint8_t * getData() { - return reinterpret_cast< unsigned char* >( &m_dataBuf[0] ); + return reinterpret_cast< uint8_t* >( &m_dataBuf[0] ); } void setHeader( uint16_t size, uint16_t type, uint32_t id1, uint32_t id2, uint16_t subType, uint32_t unknown = 0xFED2E000 ); diff --git a/src/servers/Server_Common/PacketContainer.cpp b/src/servers/Server_Common/PacketContainer.cpp index 956f548d..9c192eae 100644 --- a/src/servers/Server_Common/PacketContainer.cpp +++ b/src/servers/Server_Common/PacketContainer.cpp @@ -65,9 +65,9 @@ std::string Core::Network::Packets::PacketContainer::toString() fillSendBuffer( tmpBuffer ); std::string str = "\n"; - for( unsigned int i = 0; i < m_ipcHdr.size; i++ ) + for( uint32_t i = 0; i < m_ipcHdr.size; i++ ) { - str += boost::str( boost::format( "%|02X|" ) % static_cast< int >( tmpBuffer[i] & 0xFF ) ) + " "; + str += boost::str( boost::format( "%|02X|" ) % static_cast< int32_t >( tmpBuffer[i] & 0xFF ) ) + " "; if( ( i + 1 ) % 16 == 0 ) str += "\n"; diff --git a/src/servers/Server_Common/Util.cpp b/src/servers/Server_Common/Util.cpp index 2d09f7cc..f46c68cc 100644 --- a/src/servers/Server_Common/Util.cpp +++ b/src/servers/Server_Common/Util.cpp @@ -6,9 +6,9 @@ std::string Core::Util::binaryToHexString( uint8_t* pBinData, uint16_t size ) std::string outStr; - for( unsigned int i = 0; i < size; i++ ) + for( uint32_t i = 0; i < size; i++ ) { - outStr += boost::str( boost::format( "%|02X|" ) % ( int ) ( pBinData[i] & 0xFF ) ); + outStr += boost::str( boost::format( "%|02X|" ) % ( int32_t ) ( pBinData[i] & 0xFF ) ); } return outStr; diff --git a/src/servers/Server_Common/base64.cpp b/src/servers/Server_Common/base64.cpp index 16e77159..3ad4db0d 100644 --- a/src/servers/Server_Common/base64.cpp +++ b/src/servers/Server_Common/base64.cpp @@ -34,16 +34,16 @@ static const std::string base64_chars = "0123456789+/"; -static inline bool is_base64( unsigned char c ) { +static inline bool is_base64( uint8_t c ) { return ( isalnum( c ) || ( c == '+' ) || ( c == '/' ) ); } -std::string Core::Util::base64_encode( unsigned char const* bytes_to_encode, unsigned int in_len ) { +std::string Core::Util::base64_encode( uint8_t const* bytes_to_encode, uint32_t in_len ) { std::string ret; - int i = 0; - int j = 0; - unsigned char char_array_3[3]; - unsigned char char_array_4[4]; + int32_t i = 0; + int32_t j = 0; + uint8_t char_array_3[3]; + uint8_t char_array_4[4]; while( in_len-- ) { char_array_3[i++] = *( bytes_to_encode++ ); @@ -82,11 +82,11 @@ std::string Core::Util::base64_encode( unsigned char const* bytes_to_encode, uns } std::string Core::Util::base64_decode( std::string const& encoded_string ) { - int in_len = encoded_string.size(); - int i = 0; - int j = 0; - int in_ = 0; - unsigned char char_array_4[4], char_array_3[3]; + int32_t in_len = encoded_string.size(); + int32_t i = 0; + int32_t j = 0; + int32_t in_ = 0; + uint8_t char_array_4[4], char_array_3[3]; std::string ret; while( in_len-- && ( encoded_string[in_] != '=' ) && is_base64( encoded_string[in_] ) ) { diff --git a/src/servers/Server_Common/base64.h b/src/servers/Server_Common/base64.h index 01b53c55..3840b8af 100644 --- a/src/servers/Server_Common/base64.h +++ b/src/servers/Server_Common/base64.h @@ -4,7 +4,7 @@ namespace Core { namespace Util { - std::string base64_encode( unsigned char const*, unsigned int len ); + std::string base64_encode( uint8_t const*, uint32_t len ); std::string base64_decode( std::string const& s ); } } diff --git a/src/servers/Server_Common/md5.cpp b/src/servers/Server_Common/md5.cpp index 1c1eaf6b..6f9a4152 100644 --- a/src/servers/Server_Common/md5.cpp +++ b/src/servers/Server_Common/md5.cpp @@ -247,7 +247,7 @@ void Core::Util::md5_finish( md5_context *ctx, uint8_t digest[16] ) * those are the standard RFC 1321 test vectors */ -void Core::Util::md5( unsigned char *text, unsigned char *hash, int size ) +void Core::Util::md5( uint8_t *text, uint8_t *hash, int32_t size ) { md5_context ctx; md5_starts( &ctx ); diff --git a/src/servers/Server_Common/md5.h b/src/servers/Server_Common/md5.h index 87bf4d7f..d4162221 100644 --- a/src/servers/Server_Common/md5.h +++ b/src/servers/Server_Common/md5.h @@ -16,7 +16,7 @@ namespace Core md5_context; - void md5( unsigned char *text, unsigned char *hash, int size ); + void md5( uint8_t *text, uint8_t *hash, int32_t size ); void md5_starts( md5_context *ctx ); void md5_update( md5_context *ctx, uint8_t *input, uint32_t length ); void md5_finish( md5_context *ctx, uint8_t digest[16] ); diff --git a/src/servers/Server_Lobby/GameConnection.cpp b/src/servers/Server_Lobby/GameConnection.cpp index 5f40d522..498f8f0b 100644 --- a/src/servers/Server_Lobby/GameConnection.cpp +++ b/src/servers/Server_Lobby/GameConnection.cpp @@ -120,7 +120,7 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui auto charList = g_restConnector.getCharList( ( char * )m_pSession->getSessionId() ); - int charIndex = 0; + int32_t charIndex = 0; for( uint8_t i = 0; i < 4; i++ ) { @@ -455,7 +455,7 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets: { BlowFish blowfish; blowfish.initialize( m_encKey, 0x10 ); - blowfish.Decode( ( unsigned char* )( &inPacket.data[0] ), ( unsigned char* )( &inPacket.data[0] ), + blowfish.Decode( ( uint8_t* )( &inPacket.data[0] ), ( uint8_t* )( &inPacket.data[0] ), ( inPacket.data.size() ) - 0x10 ); } diff --git a/src/servers/Server_Lobby/RestConnector.cpp b/src/servers/Server_Lobby/RestConnector.cpp index 997739e0..8e233f7f 100644 --- a/src/servers/Server_Lobby/RestConnector.cpp +++ b/src/servers/Server_Lobby/RestConnector.cpp @@ -306,7 +306,7 @@ bool Core::Network::RestConnector::deleteCharacter( char* sId, std::string name int Core::Network::RestConnector::createCharacter( char * sId, std::string name, std::string infoJson ) { - std::string json_string = "{\"sId\": \"" + std::string( sId, 56 ) + "\",\"secret\": \"" + serverSecret + "\",\"name\": \"" + name + "\",\"infoJson\": \"" + Core::Util::base64_encode( (unsigned char *)infoJson.c_str(), infoJson.length() ) + "\"}"; + std::string json_string = "{\"sId\": \"" + std::string( sId, 56 ) + "\",\"secret\": \"" + serverSecret + "\",\"name\": \"" + name + "\",\"infoJson\": \"" + Core::Util::base64_encode( (uint8_t *)infoJson.c_str(), infoJson.length() ) + "\"}"; HttpResponse r = requestApi( "createCharacter", json_string ); diff --git a/src/servers/Server_Lobby/RestConnector.h b/src/servers/Server_Lobby/RestConnector.h index c31c2a6e..e76da1ab 100644 --- a/src/servers/Server_Lobby/RestConnector.h +++ b/src/servers/Server_Lobby/RestConnector.h @@ -27,7 +27,7 @@ namespace Core HttpResponse requestApi( std::string endpoint, std::string data ); LobbySessionPtr getSession( char* sId ); - int createCharacter( char * sId, std::string name, std::string infoJson ); + int32_t createCharacter( char * sId, std::string name, std::string infoJson ); std::vector> getCharList( char * sId ); bool deleteCharacter( char* sId, std::string name ); bool checkNameTaken( std::string name ); diff --git a/src/servers/Server_Lobby/ServerLobby.cpp b/src/servers/Server_Lobby/ServerLobby.cpp index c8724111..4d239ac8 100644 --- a/src/servers/Server_Lobby/ServerLobby.cpp +++ b/src/servers/Server_Lobby/ServerLobby.cpp @@ -46,7 +46,7 @@ namespace Core { return g_restConnector.getSession( sessionId ); } - void ServerLobby::run( int argc, char* argv[] ) + void ServerLobby::run( int32_t argc, char* argv[] ) { g_log.setLogPath( "log\\SapphireLobby" ); g_log.init(); @@ -74,7 +74,7 @@ namespace Core { } - bool ServerLobby::loadSettings( int argc, char* argv[] ) + bool ServerLobby::loadSettings( int32_t argc, char* argv[] ) { g_log.info( "Loading config " + m_configPath ); diff --git a/src/servers/Server_Lobby/ServerLobby.h b/src/servers/Server_Lobby/ServerLobby.h index 6bc07868..29031ac4 100644 --- a/src/servers/Server_Lobby/ServerLobby.h +++ b/src/servers/Server_Lobby/ServerLobby.h @@ -34,9 +34,9 @@ namespace Core ServerLobby( const std::string& configPath ); ~ServerLobby( void ); - void run( int argc, char* argv[] ); + void run( int32_t argc, char* argv[] ); - bool loadSettings( int argc, char* argv[] ); + bool loadSettings( int32_t argc, char* argv[] ); void addSession( char* sessionId, LobbySessionPtr pSession ) { diff --git a/src/servers/Server_Lobby/blowfish.cpp b/src/servers/Server_Lobby/blowfish.cpp index 1c23e2b2..96d3badc 100644 --- a/src/servers/Server_Lobby/blowfish.cpp +++ b/src/servers/Server_Lobby/blowfish.cpp @@ -74,7 +74,7 @@ void BlowFish::Blowfish_decipher (DWORD *xl, DWORD *xr) // constructs the enctryption sieve -void BlowFish::initialize (BYTE key[], int keybytes) +void BlowFish::initialize (BYTE key[], int32_t keybytes) { int i, j ; DWORD datal, datar ; @@ -90,23 +90,23 @@ void BlowFish::initialize (BYTE key[], int keybytes) SBoxes [i][j] = bf_S [i][j] ; } - int v12; // eax@6 - int v13; // ecx@6 - int v14; // eax@8 - int v15; // edx@8 - int v16; // edx@8 - int v17; // eax@10 - int v18; // ecx@10 - int v19; // ecx@10 - int v20; // edx@12 - int v21; // edx@12 + int32_t v12; // eax@6 + int32_t v13; // ecx@6 + int32_t v14; // eax@8 + int32_t v15; // edx@8 + int32_t v16; // edx@8 + int32_t v17; // eax@10 + int32_t v18; // ecx@10 + int32_t v19; // ecx@10 + int32_t v20; // edx@12 + int32_t v21; // edx@12 - int v10 = keybytes; - int v9 = (uintptr_t)key; - int v8 = 0; - int v11 = 0; + int32_t v10 = keybytes; + int32_t v9 = (int32_t)key; + int32_t v8 = 0; + int32_t v11 = 0; do { v13 = (char)(*(BYTE *)(v8 + v9)); v12 = v8 + 1; diff --git a/src/servers/Server_Lobby/blowfish.h b/src/servers/Server_Lobby/blowfish.h index e05b422b..8c13144a 100644 --- a/src/servers/Server_Lobby/blowfish.h +++ b/src/servers/Server_Lobby/blowfish.h @@ -7,9 +7,9 @@ #define MAXKEYBYTES 56 // 448 bits max #define NPASS 16 // SBox passes -#define DWORD unsigned long +#define DWORD uint32_t #define WORD unsigned short -#define BYTE unsigned char +#define BYTE uint8_t class BlowFish { @@ -22,7 +22,7 @@ private: public: BlowFish () ; ~BlowFish () ; - void initialize (BYTE key[], int keybytes) ; + void initialize (BYTE key[], int32_t keybytes) ; DWORD GetOutputLength (DWORD lInputLong) ; DWORD Encode (BYTE * pInput, BYTE * pOutput, DWORD lSize) ; void Decode (BYTE * pInput, BYTE * pOutput, DWORD lSize) ; @@ -37,10 +37,10 @@ public: DWORD dword; BYTE byte [4]; struct { - unsigned int byte3:8; - unsigned int byte2:8; - unsigned int byte1:8; - unsigned int byte0:8; + uint32_t byte3:8; + uint32_t byte2:8; + uint32_t byte1:8; + uint32_t byte0:8; } w; }; #endif @@ -50,10 +50,10 @@ public: DWORD dword; BYTE byte [4]; struct { - unsigned int byte0:8; - unsigned int byte1:8; - unsigned int byte2:8; - unsigned int byte3:8; + uint32_t byte0:8; + uint32_t byte1:8; + uint32_t byte2:8; + uint32_t byte3:8; } w; }; #endif @@ -63,10 +63,10 @@ public: DWORD dword; BYTE byte [4]; struct { - unsigned int byte1:8; - unsigned int byte0:8; - unsigned int byte3:8; - unsigned int byte2:8; + uint32_t byte1:8; + uint32_t byte0:8; + uint32_t byte3:8; + uint32_t byte2:8; } w; }; #endif diff --git a/src/servers/Server_Lobby/mainLobbyServer.cpp b/src/servers/Server_Lobby/mainLobbyServer.cpp index 5627449d..e247f3b5 100644 --- a/src/servers/Server_Lobby/mainLobbyServer.cpp +++ b/src/servers/Server_Lobby/mainLobbyServer.cpp @@ -2,7 +2,7 @@ Core::ServerLobby g_serverLobby( "config/settings_lobby.xml" ); -int main( int argc, char* argv[] ) +int main( int32_t argc, char* argv[] ) { g_serverLobby.run( argc, argv ); diff --git a/src/servers/Server_REST/PlayerMinimal.cpp b/src/servers/Server_REST/PlayerMinimal.cpp index 356057a4..5f57fe05 100644 --- a/src/servers/Server_REST/PlayerMinimal.cpp +++ b/src/servers/Server_REST/PlayerMinimal.cpp @@ -62,7 +62,7 @@ namespace Core { field[6].getBinary( (char*)m_modelEquip, 40 ); - for( int i = 0; i < 26; i++ ) + for( int32_t i = 0; i < 26; i++ ) { m_lookMap[i] = m_look[i]; } @@ -179,7 +179,7 @@ namespace Core { uint16_t size = static_cast< uint16_t >( m_lookMap.size() ); - for( int i = 0; i < m_lookMap.size(); i++ ) + for( int32_t i = 0; i < m_lookMap.size(); i++ ) { customize[i] = m_lookMap[i]; } @@ -189,7 +189,7 @@ namespace Core { uint32_t startZone; float x, y, z, o; - int startTown = 0; + int32_t startTown = 0; switch( m_class ) { diff --git a/src/servers/Server_REST/SapphireAPI.cpp b/src/servers/Server_REST/SapphireAPI.cpp index b1bc0e7f..3ea460d0 100644 --- a/src/servers/Server_REST/SapphireAPI.cpp +++ b/src/servers/Server_REST/SapphireAPI.cpp @@ -36,13 +36,13 @@ bool Core::Network::SapphireAPI::login( const std::string& username, const std:: return false; // user found, proceed - int accountId = pQR->fetch()[0].getUInt32(); + int32_t accountId = pQR->fetch()[0].getUInt32(); // session id string generation - srand( ( unsigned int )time( NULL ) + 42 ); + srand( ( uint32_t )time( NULL ) + 42 ); uint8_t sid[58]; - for( int i = 0; i < 56; i += 4 ) + for( int32_t i = 0; i < 56; i += 4 ) { short number = 0x1111 + rand() % 0xFFFF; sprintf( ( char* )sid + i, "%04hx", number ); @@ -96,7 +96,7 @@ bool Core::Network::SapphireAPI::createAccount( const std::string& username, con // we are clear and can create a new account // get the next free account id pQR = g_database.query( "SELECT MAX(account_id) FROM accounts;" ); - int accountId = pQR->fetch()[0].getUInt32() + 1; + int32_t accountId = pQR->fetch()[0].getUInt32() + 1; // store the account to the db g_database.execute( "INSERT INTO accounts (account_Id, account_name, account_pass, account_created) VALUE(%i, '%s', '%s', %i);", @@ -132,7 +132,7 @@ int Core::Network::SapphireAPI::createCharacter( const int& accountId, const std const char *ptr = infoJson.c_str() + 50; std::string lookPart( ptr ); - int pos = lookPart.find_first_of( "]" ); + int32_t pos = lookPart.find_first_of( "]" ); if( pos != std::string::npos ) { lookPart = lookPart.substr( 0, pos + 1 ); @@ -154,7 +154,7 @@ int Core::Network::SapphireAPI::createCharacter( const int& accountId, const std tmpVector2.push_back( std::stoi( v.second.data() ) ); } std::vector::iterator it = tmpVector.begin(); - for( int i = 0; it != tmpVector.end(); ++it, i++ ) + for( int32_t i = 0; it != tmpVector.end(); ++it, i++ ) { newPlayer.setLook( i, *it ); } @@ -187,7 +187,7 @@ void Core::Network::SapphireAPI::deleteCharacter( std::string name, uint32_t acc } } - int id = deletePlayer.getId(); + int32_t id = deletePlayer.getId(); g_database.execute( "DELETE FROM charabase WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); g_database.execute( "DELETE FROM characlass WHERE CharacterId LIKE '" + std::to_string( id ) + "';" ); @@ -247,7 +247,7 @@ bool Core::Network::SapphireAPI::checkNameTaken( std::string name ) uint32_t Core::Network::SapphireAPI::getNextCharId() { - int charId = 0; + int32_t charId = 0; boost::shared_ptr pQR = g_database.query( "SELECT MAX(CharacterId) FROM charabase" ); diff --git a/src/servers/Server_REST/SapphireAPI.h b/src/servers/Server_REST/SapphireAPI.h index 1a79f2a0..09b86729 100644 --- a/src/servers/Server_REST/SapphireAPI.h +++ b/src/servers/Server_REST/SapphireAPI.h @@ -27,7 +27,7 @@ namespace Core bool createAccount( const std::string& username, const std::string& pass, std::string& sId ); - int createCharacter( const int& accountId, const std::string& name, const std::string& infoJson ); + int32_t createCharacter( const int& accountId, const std::string& name, const std::string& infoJson ); void deleteCharacter( std::string name, uint32_t accountId ); @@ -41,7 +41,7 @@ namespace Core uint64_t getNextContentId(); - int checkSession( const std::string& sId ); + int32_t checkSession( const std::string& sId ); bool removeSession( const std::string& sId ); diff --git a/src/servers/Server_REST/main.cpp b/src/servers/Server_REST/main.cpp index 72e59ca4..fffe5e96 100644 --- a/src/servers/Server_REST/main.cpp +++ b/src/servers/Server_REST/main.cpp @@ -60,7 +60,7 @@ void reloadConfig() void print_request_info( shared_ptr request ) { g_log.info( "Request from " + request->remote_endpoint_address + " (" + request->path + ")" ); } -bool loadSettings( int argc, char* argv[] ) +bool loadSettings( int32_t argc, char* argv[] ) { g_log.info( "Loading config " + configPath ); @@ -282,7 +282,7 @@ int main(int argc, char* argv[]) // reloadConfig(); - int accountId = g_sapphireAPI.checkSession( sId ); + int32_t accountId = g_sapphireAPI.checkSession( sId ); if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; @@ -321,7 +321,7 @@ int main(int argc, char* argv[]) // reloadConfig(); - int result = g_sapphireAPI.checkSession( sId ); + int32_t result = g_sapphireAPI.checkSession( sId ); if( result != -1 ) { @@ -331,7 +331,7 @@ int main(int argc, char* argv[]) } else { - int charId = g_sapphireAPI.createCharacter( result, name, finalJson ); + int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson ); std::string json_string = "{\"result\":\"" + std::to_string( charId ) + "\"}"; *response << "HTTP/1.1 200\r\nContent-Length: " << json_string.length() << "\r\n\r\n" << json_string; @@ -434,7 +434,7 @@ int main(int argc, char* argv[]) std::string sId = pt.get( "sId" ); std::string secret = pt.get( "secret" ); - int result = g_sapphireAPI.checkSession( sId ); + int32_t result = g_sapphireAPI.checkSession( sId ); // reloadConfig(); @@ -540,7 +540,7 @@ int main(int argc, char* argv[]) // reloadConfig(); - int result = g_sapphireAPI.checkSession( sId ); + int32_t result = g_sapphireAPI.checkSession( sId ); if( result != -1 ) { diff --git a/src/servers/Server_REST/server_http.hpp b/src/servers/Server_REST/server_http.hpp index 2651eaba..82ee541a 100644 --- a/src/servers/Server_REST/server_http.hpp +++ b/src/servers/Server_REST/server_http.hpp @@ -269,7 +269,7 @@ namespace SimpleWeb { //If content, read that as well auto it=request->header.find("Content-Length"); if(it!=request->header.end()) { - unsigned long long content_length; + uint64_t content_length; try { content_length=stoull(it->second); } diff --git a/src/servers/Server_Zone/Actor.cpp b/src/servers/Server_Zone/Actor.cpp index 1512e22f..bd1670a2 100644 --- a/src/servers/Server_Zone/Actor.cpp +++ b/src/servers/Server_Zone/Actor.cpp @@ -109,7 +109,7 @@ Core::Common::ClassJob Core::Entity::Actor::getClass() const return m_class; } -/*! \return current class or job as int ( this feels pointless ) */ +/*! \return current class or job as int32_t ( this feels pointless ) */ uint8_t Core::Entity::Actor::getClassAsInt() const { return static_cast< uint8_t >( m_class ); diff --git a/src/servers/Server_Zone/GameConnection.cpp b/src/servers/Server_Zone/GameConnection.cpp index cca0745a..53b2d2e8 100644 --- a/src/servers/Server_Zone/GameConnection.cpp +++ b/src/servers/Server_Zone/GameConnection.cpp @@ -238,7 +238,7 @@ void Core::Network::GameConnection::injectPacket( const std::string& packetpath, fclose( fp ); // cycle through the packet entries and queue each one - for( int k = 0x18; k < size;) + for( int32_t k = 0x18; k < size;) { uint32_t tmpId = pPlayer->getId(); // replace ids in the entryheader if needed diff --git a/src/servers/Server_Zone/Inventory.cpp b/src/servers/Server_Zone/Inventory.cpp index e6c6e47a..1da5df7a 100644 --- a/src/servers/Server_Zone/Inventory.cpp +++ b/src/servers/Server_Zone/Inventory.cpp @@ -242,7 +242,7 @@ void Core::Inventory::updateCurrencyDb() int32_t firstItemPos = -1; std::string query = "UPDATE charaitemcurrency SET "; - for( int i = 0; i <= 11; i++ ) + for( int32_t i = 0; i <= 11; i++ ) { auto currItem = m_inventoryMap[Currency]->getItem( i ); @@ -269,7 +269,7 @@ void Core::Inventory::updateCrystalDb() int32_t firstItemPos = -1; std::string query = "UPDATE charaitemcrystal SET "; - for( int i = 0; i <= 11; i++ ) + for( int32_t i = 0; i <= 11; i++ ) { auto currItem = m_inventoryMap[Crystal]->getItem( i ); @@ -294,7 +294,7 @@ void Core::Inventory::updateBagDb( InventoryType type ) { std::string query = "UPDATE charaiteminventory SET "; - for( int i = 0; i <= 34; i++ ) + for( int32_t i = 0; i <= 34; i++ ) { auto currItem = m_inventoryMap[type]->getItem( i ); @@ -377,7 +377,7 @@ void Core::Inventory::updateMannequinDb( InventoryType type ) { std::string query = "UPDATE charaitemgearset SET "; - for( int i = 0; i <= 13; i++ ) + for( int32_t i = 0; i <= 13; i++ ) { auto currItem = m_inventoryMap[type]->getItem( i ); @@ -671,7 +671,7 @@ bool Core::Inventory::load() { uint16_t storageId = field[0].getUInt16(); - for( int i = 1; i <= 14; i++ ) + for( int32_t i = 1; i <= 14; i++ ) { uint64_t uItemId = field[i].getUInt64(); if( uItemId == 0 ) @@ -708,7 +708,7 @@ bool Core::Inventory::load() do { uint16_t storageId = bagField[0].getUInt16(); - for( int i = 1; i <= 25; i++ ) + for( int32_t i = 1; i <= 25; i++ ) { uint64_t uItemId = bagField[i].getUInt64(); if( uItemId == 0 ) @@ -741,7 +741,7 @@ bool Core::Inventory::load() do { uint16_t storageId = curField[0].getUInt16(); - for( int i = 1; i <= 12; i++ ) + for( int32_t i = 1; i <= 12; i++ ) { uint64_t uItemId = curField[i].getUInt64(); if( uItemId == 0 ) @@ -775,7 +775,7 @@ bool Core::Inventory::load() do { uint16_t storageId = crystalField[0].getUInt16(); - for( int i = 1; i <= 17; i++ ) + for( int32_t i = 1; i <= 17; i++ ) { uint64_t uItemId = crystalField[i].getUInt64(); if( uItemId == 0 ) @@ -798,7 +798,7 @@ void Core::Inventory::send() { InventoryMap::iterator it; - int count = 0; + int32_t count = 0; for( it = m_inventoryMap.begin(); it != m_inventoryMap.end(); ++it, count++ ) { diff --git a/src/servers/Server_Zone/ItemContainer.cpp b/src/servers/Server_Zone/ItemContainer.cpp index 76d97eb9..0685c0bd 100644 --- a/src/servers/Server_Zone/ItemContainer.cpp +++ b/src/servers/Server_Zone/ItemContainer.cpp @@ -68,7 +68,7 @@ const Core::ItemMap & Core::ItemContainer::getItemMap() const int16_t Core::ItemContainer::getFreeSlot() { - for( unsigned char slotId = 0; slotId < m_size; slotId++ ) + for( uint8_t slotId = 0; slotId < m_size; slotId++ ) { ItemMap::iterator it = m_itemMap.find( slotId ); if( it == m_itemMap.end() || diff --git a/src/servers/Server_Zone/PacketHandlers.cpp b/src/servers/Server_Zone/PacketHandlers.cpp index 95d23962..bba999e2 100644 --- a/src/servers/Server_Zone/PacketHandlers.cpp +++ b/src/servers/Server_Zone/PacketHandlers.cpp @@ -614,7 +614,7 @@ void Core::Network::GameConnection::updatePositionHandler( Core::Network::Packet // } default: { - if( static_cast< int >( IPC_OP_019A.moveBackward ) ) + if( static_cast< int32_t >( IPC_OP_019A.moveBackward ) ) { unk1 = 0xFF; unk2 = 0x06; @@ -999,7 +999,7 @@ void Core::Network::GameConnection::socialListHandler( Core::Network::Packets::G listPacket.data().type = 2; listPacket.data().sequence = count; - int entrysizes = sizeof( listPacket.data().entries ); + int32_t entrysizes = sizeof( listPacket.data().entries ); memset( listPacket.data().entries, 0, sizeof( listPacket.data().entries ) ); listPacket.data().entries[0].bytes[2] = pPlayer->getCurrentZone()->getId(); @@ -1046,7 +1046,7 @@ void Core::Network::GameConnection::socialListHandler( Core::Network::Packets::G std::set::iterator it; - int i = 0x30; + int32_t i = 0x30; for(it = tmpSet.begin(); it != tmpSet.end(); it++) { if((*it)->getId() == pPlayer->getId()) diff --git a/src/servers/Server_Zone/Player.cpp b/src/servers/Server_Zone/Player.cpp index 6a45489d..8703e12b 100644 --- a/src/servers/Server_Zone/Player.cpp +++ b/src/servers/Server_Zone/Player.cpp @@ -462,7 +462,7 @@ void Core::Entity::Player::initSpawnIdQueue() m_freeSpawnIdQueue.pop(); } - for( int i = 1; i < MAX_DISPLAYED_ACTORS; i++ ) + for( int32_t i = 1; i < MAX_DISPLAYED_ACTORS; i++ ) { m_freeSpawnIdQueue.push( i ); } @@ -974,7 +974,7 @@ const uint8_t * Core::Entity::Player::getStateFlags() const bool Core::Entity::Player::hasStateFlag( Core::Common::PlayerStateFlag flag ) const { - int iFlag = static_cast< uint32_t >( flag ); + int32_t iFlag = static_cast< uint32_t >( flag ); uint16_t index; uint8_t value; @@ -985,7 +985,7 @@ bool Core::Entity::Player::hasStateFlag( Core::Common::PlayerStateFlag flag ) co void Core::Entity::Player::setStateFlag( Core::Common::PlayerStateFlag flag ) { - int iFlag = static_cast< uint32_t >( flag ); + int32_t iFlag = static_cast< uint32_t >( flag ); uint16_t index; uint8_t value; @@ -1005,7 +1005,7 @@ void Core::Entity::Player::unsetStateFlag( Core::Common::PlayerStateFlag flag ) if( !hasStateFlag( flag ) ) return; - int iFlag = static_cast< uint32_t >( flag ); + int32_t iFlag = static_cast< uint32_t >( flag ); uint16_t index; uint8_t value; @@ -1381,7 +1381,7 @@ bool Core::Entity::Player::hateListHasMob( Core::Entity::BattleNpcPtr pBNpc ) void Core::Entity::Player::initHateSlotQueue() { m_freeHateSlotQueue = std::queue< uint8_t >(); - for( int i = 1; i < 26; i++ ) + for( int32_t i = 1; i < 26; i++ ) m_freeHateSlotQueue.push( i ); } @@ -1390,7 +1390,7 @@ void Core::Entity::Player::sendHateList() GamePacketNew< FFXIVIpcHateList > hateListPacket( getId() ); hateListPacket.data().numEntries = m_actorIdTohateSlotMap.size(); auto it = m_actorIdTohateSlotMap.begin(); - for( int i = 0; it != m_actorIdTohateSlotMap.end(); ++it, i++ ) + for( int32_t i = 0; it != m_actorIdTohateSlotMap.end(); ++it, i++ ) { hateListPacket.data().entry[i].actorId = it->first; hateListPacket.data().entry[i].hatePercent = 100; diff --git a/src/servers/Server_Zone/PlayerQuest.cpp b/src/servers/Server_Zone/PlayerQuest.cpp index 89e1959d..fd73091d 100644 --- a/src/servers/Server_Zone/PlayerQuest.cpp +++ b/src/servers/Server_Zone/PlayerQuest.cpp @@ -94,7 +94,7 @@ void Core::Entity::Player::finishQuest( uint16_t questId ) setSyncFlag( PlayerSyncFlags::Quests ); setSyncFlag( PlayerSyncFlags::QuestTracker ); - for( int ii = 0; ii < 5; ii++ ) + for( int32_t ii = 0; ii < 5; ii++ ) { if( m_questTracking[ii] == idx ) m_questTracking[ii] = -1; @@ -143,7 +143,7 @@ void Core::Entity::Player::removeQuest( uint16_t questId ) setSyncFlag( PlayerSyncFlags::Quests ); setSyncFlag( PlayerSyncFlags::QuestTracker ); - for( int ii = 0; ii < 5; ii++ ) + for( int32_t ii = 0; ii < 5; ii++ ) { if( m_questTracking[ii] == idx ) m_questTracking[ii] = -1; @@ -1015,7 +1015,7 @@ void Core::Entity::Player::updateQuest( uint16_t questId, uint16_t sequence ) setSyncFlag( PlayerSyncFlags::Quests ); setSyncFlag( PlayerSyncFlags::QuestTracker ); - for( int ii = 0; ii < 5; ii++ ) + for( int32_t ii = 0; ii < 5; ii++ ) { if( m_questTracking[ii] == -1 ) { @@ -1033,7 +1033,7 @@ void Core::Entity::Player::sendQuestTracker() { GamePacketNew< FFXIVIpcQuestTracker > trackerPacket( getId() ); - for( int ii = 0; ii < 5; ii++ ) + for( int32_t ii = 0; ii < 5; ii++ ) { if( m_questTracking[ii] >= 0 ) { @@ -1080,7 +1080,7 @@ void Core::Entity::Player::sendQuestInfo() { GamePacketNew< FFXIVIpcQuestActiveList > pe_qa( getId() ); - for( int i = 0; i < 30; i++ ) + for( int32_t i = 0; i < 30; i++ ) { uint8_t offset = i * 12; if( m_activeQuests[i] != nullptr ) diff --git a/src/servers/Server_Zone/PlayerSql.cpp b/src/servers/Server_Zone/PlayerSql.cpp index 4090ae40..bbd7b1ac 100644 --- a/src/servers/Server_Zone/PlayerSql.cpp +++ b/src/servers/Server_Zone/PlayerSql.cpp @@ -350,7 +350,7 @@ void Core::Entity::Player::createUpdateSql() { charaDetailSet.insert( " QuestCompleteFlags = UNHEX('" + std::string( Util::binaryToHexString( static_cast< uint8_t* >( m_questCompleteFlags ), 200 ) ) + "')" ); - for( int i = 0; i < 30; i++ ) + for( int32_t i = 0; i < 30; i++ ) { if( m_activeQuests[i] != nullptr ) { diff --git a/src/servers/Server_Zone/PlayerStateFlagsPacket.h b/src/servers/Server_Zone/PlayerStateFlagsPacket.h index 7b7f801d..ae0f81b9 100644 --- a/src/servers/Server_Zone/PlayerStateFlagsPacket.h +++ b/src/servers/Server_Zone/PlayerStateFlagsPacket.h @@ -31,7 +31,7 @@ public: for( auto& flag : flags ) { - int iFlag = static_cast< uint32_t >( flag ); + int32_t iFlag = static_cast< uint32_t >( flag ); uint8_t index = iFlag / 8; uint8_t bitIndex = iFlag % 8; diff --git a/src/servers/Server_Zone/ScriptManager.h b/src/servers/Server_Zone/ScriptManager.h index b398d4a4..e4c322de 100644 --- a/src/servers/Server_Zone/ScriptManager.h +++ b/src/servers/Server_Zone/ScriptManager.h @@ -32,7 +32,7 @@ namespace Core ScriptManager(); ~ScriptManager(); - int init(); + int32_t init(); void reload(); const boost::shared_ptr< chaiscript::ChaiScript >& getHandler() const; diff --git a/src/servers/Server_Zone/ServerZone.cpp b/src/servers/Server_Zone/ServerZone.cpp index 6c65dbd8..8b7d331a 100644 --- a/src/servers/Server_Zone/ServerZone.cpp +++ b/src/servers/Server_Zone/ServerZone.cpp @@ -87,7 +87,7 @@ void Core::ServerZone::setServerId( uint16_t serverId ) m_serverId = serverId; } -bool Core::ServerZone::loadSettings( int argc, char* argv[] ) +bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] ) { g_log.info( "Loading config " + m_configPath ); @@ -183,7 +183,7 @@ bool Core::ServerZone::loadSettings( int argc, char* argv[] ) return true; } -void Core::ServerZone::run( int argc, char* argv[] ) +void Core::ServerZone::run( int32_t argc, char* argv[] ) { // TODO: add more error checks for the entire initialisation g_log.setLogPath( "log\\SapphireZone_" + std::to_string( m_serverId ) + "_" ); diff --git a/src/servers/Server_Zone/ServerZone.h b/src/servers/Server_Zone/ServerZone.h index 6b615838..1c95e350 100644 --- a/src/servers/Server_Zone/ServerZone.h +++ b/src/servers/Server_Zone/ServerZone.h @@ -18,7 +18,7 @@ namespace Core { ServerZone( const std::string& configPath, uint16_t serverId = 0 ); ~ServerZone(); - void run( int argc, char* argv[] ); + void run( int32_t argc, char* argv[] ); void setServerId( uint16_t serverId ); uint16_t getServerId() const; @@ -27,7 +27,7 @@ namespace Core { void removeSession( uint32_t sessionId ); void removeSession( std::string playerName ); - bool loadSettings( int argc, char* argv[] ); + bool loadSettings( int32_t argc, char* argv[] ); SessionPtr getSession( uint32_t id ); SessionPtr getSession( std::string playerName ); diff --git a/src/servers/Server_Zone/Zone.cpp b/src/servers/Server_Zone/Zone.cpp index 7070252a..209bae83 100644 --- a/src/servers/Server_Zone/Zone.cpp +++ b/src/servers/Server_Zone/Zone.cpp @@ -564,7 +564,7 @@ bool Zone::isCellActive( uint32_t x, uint32_t y ) return false; } -void Zone::updateCellActivity( uint32_t x, uint32_t y, int radius ) +void Zone::updateCellActivity( uint32_t x, uint32_t y, int32_t radius ) { uint32_t endX = ( x + radius ) <= _sizeX ? x + radius : ( _sizeX - 1 ); @@ -692,8 +692,8 @@ void Zone::changeActorPosition( Entity::ActorPtr pActor ) if( pOldCell != nullptr ) { // only do the second check if theres -/+ 2 difference - if( abs( ( int ) cellX - ( int ) pOldCell->m_posX ) > 2 || - abs( ( int ) cellY - ( int ) pOldCell->m_posY ) > 2 ) + if( abs( ( int32_t ) cellX - ( int32_t ) pOldCell->m_posX ) > 2 || + abs( ( int32_t ) cellY - ( int32_t ) pOldCell->m_posY ) > 2 ) updateCellActivity( pOldCell->m_posX, pOldCell->m_posY, 2 ); } } @@ -728,7 +728,7 @@ void Zone::updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ) auto iter = pCell->m_actors.begin(); float fRange = 70.0f; - int count = 0; + int32_t count = 0; while( iter != pCell->m_actors.end() ) { pCurAct = *iter; diff --git a/src/servers/Server_Zone/Zone.h b/src/servers/Server_Zone/Zone.h index a1f6a599..162a8a32 100644 --- a/src/servers/Server_Zone/Zone.h +++ b/src/servers/Server_Zone/Zone.h @@ -86,7 +86,7 @@ public: bool isCellActive( uint32_t x, uint32_t y ); - void updateCellActivity( uint32_t x, uint32_t y, int radius ); + void updateCellActivity( uint32_t x, uint32_t y, int32_t radius ); void updateInRangeSet( Entity::ActorPtr pActor, Cell* pCell ); diff --git a/src/servers/Server_Zone/mainGameServer.cpp b/src/servers/Server_Zone/mainGameServer.cpp index 6a9bcdfc..0706dc08 100644 --- a/src/servers/Server_Zone/mainGameServer.cpp +++ b/src/servers/Server_Zone/mainGameServer.cpp @@ -4,7 +4,7 @@ Core::ServerZone g_serverZone( "config/settings_zone.xml" ); -int main( int argc, char* argv[] ) +int main( int32_t argc, char* argv[] ) { // i hate to do this, but we need to set this first... for(auto i = 1; i < argc; ++i ) From 9d87f23caf5ea256d11260c52fe7fb082f2bb1e9 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Fri, 11 Aug 2017 23:13:00 +0100 Subject: [PATCH 09/11] fix lobby config, add default values for ip/port, change blowfish back to uintptr_t --- src/servers/Server_Lobby/ServerLobby.cpp | 14 +++++++------- src/servers/Server_Lobby/blowfish.cpp | 2 +- src/servers/Server_Zone/ServerZone.cpp | 7 ++++--- src/servers/Server_Zone/mainGameServer.cpp | 3 ++- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/servers/Server_Lobby/ServerLobby.cpp b/src/servers/Server_Lobby/ServerLobby.cpp index 4d239ac8..1adbe99a 100644 --- a/src/servers/Server_Lobby/ServerLobby.cpp +++ b/src/servers/Server_Lobby/ServerLobby.cpp @@ -21,7 +21,7 @@ #include #include - +#include #include Core::Logger g_log; @@ -91,7 +91,7 @@ namespace Core { try { - arg = std::string( args[i] ); + arg = boost::to_lower_copy( std::string( args[i] ) ); val = std::string( args[i + 1] ); // trim '-' from start of arg @@ -100,7 +100,7 @@ namespace Core { if( arg == "ip" ) { // todo: ip addr in config - m_pConfig->setValue< std::string >( "Settings.General.ListenIP", val ); + m_pConfig->setValue< std::string >( "Settings.General.ListenIp", val ); } else if( arg == "p" || arg == "port" ) { @@ -110,11 +110,11 @@ namespace Core { { m_pConfig->setValue< std::string>( "Settings.General.AuthPort", val ); } - else if( arg == "worldIP" || arg == "worldIp" ) + else if( arg == "worldip" || arg == "worldip" ) { m_pConfig->setValue < std::string >( "Settings.General.WorldIp", val ); } - else if( arg == "worldPort" ) + else if( arg == "worldport" ) { m_pConfig->setValue< std::string >( "Settings.General.WorldPort", val ); } @@ -126,8 +126,8 @@ namespace Core { } } - m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort" ); - m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp" ); + m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort", 54994 ); + m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp", "0.0.0.0" ); g_restConnector.restHost = m_pConfig->getValue< std::string >( "Settings.General.RestHost" ); g_restConnector.serverSecret = m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ); diff --git a/src/servers/Server_Lobby/blowfish.cpp b/src/servers/Server_Lobby/blowfish.cpp index 96d3badc..236be5d9 100644 --- a/src/servers/Server_Lobby/blowfish.cpp +++ b/src/servers/Server_Lobby/blowfish.cpp @@ -104,7 +104,7 @@ void BlowFish::initialize (BYTE key[], int32_t keybytes) int32_t v10 = keybytes; - int32_t v9 = (int32_t)key; + int32_t v9 = (uintptr_t)key; int32_t v8 = 0; int32_t v11 = 0; do { diff --git a/src/servers/Server_Zone/ServerZone.cpp b/src/servers/Server_Zone/ServerZone.cpp index 8b7d331a..2582a9c1 100644 --- a/src/servers/Server_Zone/ServerZone.cpp +++ b/src/servers/Server_Zone/ServerZone.cpp @@ -27,6 +27,7 @@ #include "Forwards.h" #include #include +#include Core::Logger g_log; @@ -120,7 +121,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] ) { m_pConfig->setValue< std::string >( "Settings.General.ListenPort", val ); } - else if( arg == "exdPath" || arg == "dataPath" ) + else if( arg == "exdpath" || arg == "datapath" ) { m_pConfig->setValue< std::string >( "Settings.General.DataPath", val ); } @@ -175,8 +176,8 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] ) } m_serverId = m_serverId ? m_serverId : m_pConfig->getValue< uint16_t >( "Settings.General.ServerId" ); - m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort" ); - m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp" );; + m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort", 54992 ); + m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp", "0.0.0.0" );; g_log.info( "Server ID: " + std::to_string( m_serverId ) ); diff --git a/src/servers/Server_Zone/mainGameServer.cpp b/src/servers/Server_Zone/mainGameServer.cpp index 0706dc08..c6d6a6f4 100644 --- a/src/servers/Server_Zone/mainGameServer.cpp +++ b/src/servers/Server_Zone/mainGameServer.cpp @@ -1,6 +1,7 @@ #include #include "ServerZone.h" +#include Core::ServerZone g_serverZone( "config/settings_zone.xml" ); @@ -9,7 +10,7 @@ int main( int32_t argc, char* argv[] ) // i hate to do this, but we need to set this first... for(auto i = 1; i < argc; ++i ) { - std::string arg( argv[i] ); + auto arg = boost::to_lower_copy( std::string( argv[i] ) ); // trim '-' from start of arg arg = arg.erase( 0, arg.find_first_not_of( '-' ) ); From 8488e7679fe90ea29d1f7b41d988b84ebb65c46c Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Fri, 11 Aug 2017 23:15:55 +0100 Subject: [PATCH 10/11] missed a crap from previous commit --- src/servers/Server_Zone/ServerZone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/servers/Server_Zone/ServerZone.cpp b/src/servers/Server_Zone/ServerZone.cpp index 2582a9c1..d670047a 100644 --- a/src/servers/Server_Zone/ServerZone.cpp +++ b/src/servers/Server_Zone/ServerZone.cpp @@ -106,7 +106,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] ) try { - arg = std::string( args[i] ); + arg = boost::to_lower_copy( std::string( args[i] ) ); val = std::string( args[i + 1] ); // trim '-' from start of arg From c8096d4ed014e97c35094bcb1437a5aadac50cde Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Sat, 12 Aug 2017 01:59:41 +0100 Subject: [PATCH 11/11] add appveyor test --- .appveyor.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..85bb8d25 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,30 @@ +os: + - Visual Studio 2015 + +configuration: + - Debug + +platform: + - Win32 + +environment: + MSVC_DEFAULT_OPTIONS: ON + BOOST_ROOT_DIR: "C:\\Libraries\\boost_1_60_0" + BOOST_LIB_DIR: "C:\\Libraries\\boost_1_60_0\\lib32-msvc-14.0" + MYSQL_PWD: "Password12!" + +services: + - mysql + +before_build: + - set PATH="C:\\Program Files\\MySQL\\MySQL Server 5.7\\bin";%PATH% + - cd c:\projects\sapphire + - git submodule update --init + - mkdir build + - cd build + - cmake .. -G "Visual Studio 14 2015" + - cmake --build . --target ALL_BUILD --config Debug + +build_script: + - cd .. + - sh sql_import.sh \ No newline at end of file