From 1b49c7e742a43ef2cc2cd43a331a8d1cb8f549be Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 16 May 2018 05:37:43 +0000 Subject: [PATCH] revert to using 32 bit ints for station id's because...it breaks legacy ones if we don't --- .../src/shared/ClientConnection.cpp | 2 +- .../src/shared/CharacterNameLocator.h | 2 +- .../sharedFoundation/src/shared/StationId.h | 2 +- external/3rd/library/webAPI/webAPI.cpp | 18 ++++++++++++++++++ external/3rd/library/webAPI/webAPI.h | 3 +++ .../ours/library/archive/src/shared/Archive.h | 3 ++- .../src/shared/generated/Schema_h.template | 5 +++-- .../src/shared/tasks/TaskRestoreCharacter.h | 2 +- 8 files changed, 30 insertions(+), 7 deletions(-) diff --git a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp index dc5bd08f..8e3aec10 100755 --- a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp +++ b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp @@ -181,7 +181,7 @@ void ClientConnection::validateClient(const std::string &id, const std::string & authOK = true; parentAccount = api.getString("mainAccount"); - childAccounts = api.getStringMap64("subAccounts"); + childAccounts = api.getStringMapU32("subAccounts"); if (!ConfigLoginServer::getUseOldSuidGenerator()) { user_id = static_cast(api.getNullableValue("user_id")); diff --git a/engine/server/library/serverDatabase/src/shared/CharacterNameLocator.h b/engine/server/library/serverDatabase/src/shared/CharacterNameLocator.h index 6227b30e..8cb9e864 100755 --- a/engine/server/library/serverDatabase/src/shared/CharacterNameLocator.h +++ b/engine/server/library/serverDatabase/src/shared/CharacterNameLocator.h @@ -33,7 +33,7 @@ class CharacterNameLocator : public ObjectLocator struct CharacterNameRow { DB::BindableNetworkId character_id; - DB::BindableInt64 character_station_id; + DB::BindableLong character_station_id; DB::BindableString<127> character_name; DB::BindableString<127> character_full_name; DB::BindableInt64 character_create_time; diff --git a/engine/shared/library/sharedFoundation/src/shared/StationId.h b/engine/shared/library/sharedFoundation/src/shared/StationId.h index 8633f774..48bdbf39 100755 --- a/engine/shared/library/sharedFoundation/src/shared/StationId.h +++ b/engine/shared/library/sharedFoundation/src/shared/StationId.h @@ -10,7 +10,7 @@ // ====================================================================== -typedef int64 StationId; +typedef uint32_t StationId; // ====================================================================== diff --git a/external/3rd/library/webAPI/webAPI.cpp b/external/3rd/library/webAPI/webAPI.cpp index faf7d11b..4fd4c533 100644 --- a/external/3rd/library/webAPI/webAPI.cpp +++ b/external/3rd/library/webAPI/webAPI.cpp @@ -72,6 +72,24 @@ std::unordered_map webAPI::getStringMap(const std::string &slo return ret; } +std::unordered_map webAPI::getStringMapU32(const std::string &slot) { + std::unordered_map ret = std::unordered_map(); + + if (!responseData.empty() && !slot.empty() && responseData.count(slot) && !responseData[slot].is_null()) { + + nlohmann::json j = responseData[slot]; + + for (nlohmann::json::iterator it = j.begin(); it != j.end(); ++it) { + uint32_t k = std::stoi(it.key()); + std::string val = it.value(); + + ret.insert({k, val}); + } + } + + return ret; +} + std::unordered_map webAPI::getStringMap64(const std::string &slot) { std::unordered_map ret = std::unordered_map(); diff --git a/external/3rd/library/webAPI/webAPI.h b/external/3rd/library/webAPI/webAPI.h index 2209b8f5..080dd0d2 100644 --- a/external/3rd/library/webAPI/webAPI.h +++ b/external/3rd/library/webAPI/webAPI.h @@ -66,6 +66,9 @@ namespace StellaBellum { // get a vector of strings from a given slot std::unordered_map getStringMap(const std::string &slot); + // return the above as unsigned to make various things happy + std::unordered_map getStringMapU32(const std::string &slot); + // get a 64 bit keyed vector of strings from a given slot std::unordered_map getStringMap64(const std::string &slot); diff --git a/external/ours/library/archive/src/shared/Archive.h b/external/ours/library/archive/src/shared/Archive.h index 20a2ce2e..21870ec7 100755 --- a/external/ours/library/archive/src/shared/Archive.h +++ b/external/ours/library/archive/src/shared/Archive.h @@ -14,7 +14,8 @@ #include typedef int64_t int64; typedef u_int64_t uint64; -typedef int64 StationId; + +#include "../../../../../../engine/shared/library/sharedFoundation/src/shared/StationId.h" //--------------------------------------------------------------------- diff --git a/game/server/application/SwgDatabaseServer/src/shared/generated/Schema_h.template b/game/server/application/SwgDatabaseServer/src/shared/generated/Schema_h.template index 1bd7c287..97c0dbe7 100644 --- a/game/server/application/SwgDatabaseServer/src/shared/generated/Schema_h.template +++ b/game/server/application/SwgDatabaseServer/src/shared/generated/Schema_h.template @@ -14,6 +14,7 @@ #include "sharedDatabaseInterface/BindableNetworkId.h" #include "sharedDatabaseInterface/BufferString.h" #include "sharedDatabaseInterface/DbRow.h" +#include "sharedFoundation/StationId.h" namespace DBSchema { @@ -23,7 +24,7 @@ struct PlayerObjectRow : public DB::Row enum {QUEST_DATA_SIZE=4000}; DB::BindableNetworkId object_id; - DB::BindableInt64 station_id; + DB::BindableLong station_id; DB::BindableNetworkId house_id; DB::BindableLong account_num_lots; DB::BindableBool account_is_outcast; @@ -80,7 +81,7 @@ struct PlayerObjectRow : public DB::Row struct PlayerObjectBufferRow : public DB::Row { DB::BindableNetworkId object_id; - DB::BindableInt64 station_id; + DB::BindableLong station_id; DB::BindableNetworkId house_id; DB::BindableLong account_num_lots; DB::BindableBool account_is_outcast; diff --git a/game/server/application/SwgDatabaseServer/src/shared/tasks/TaskRestoreCharacter.h b/game/server/application/SwgDatabaseServer/src/shared/tasks/TaskRestoreCharacter.h index f48e415a..2e043f3d 100755 --- a/game/server/application/SwgDatabaseServer/src/shared/tasks/TaskRestoreCharacter.h +++ b/game/server/application/SwgDatabaseServer/src/shared/tasks/TaskRestoreCharacter.h @@ -45,7 +45,7 @@ class TaskRestoreCharacter:public DB::TaskRequest //output: DB::BindableLong result; DB::BindableString<127> character_name; - DB::BindableInt64 account; + DB::BindableLong account; DB::BindableLong template_id; private: