diff --git a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp index f76d0d2a..20f358cf 100755 --- a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp +++ b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp @@ -8,13 +8,8 @@ #include "FirstLoginServer.h" #include "ClientConnection.h" -#include "Archive/ByteStream.h" #include "ConfigLoginServer.h" -#include "DatabaseConnection.h" #include "SessionApiClient.h" -#include "TaskMapAccount.h" -#include "serverKeyShare/KeyShare.h" -#include "sharedFoundation/ApplicationVersion.h" #include "sharedLog/Log.h" #include "sharedNetworkMessages/ClientLoginMessages.h" #include "sharedNetworkMessages/DeleteCharacterMessage.h" @@ -25,8 +20,6 @@ #include "sharedFoundation/CrcConstexpr.hpp" -//#include - #include "webAPI.h" using namespace StellaBellum; @@ -244,11 +237,27 @@ void ClientConnection::validateClient(const std::string & id, const std::string uname.resize(MAX_ACCOUNT_NAME_LENGTH); } - suid = std::hash(uname.c_str()); + std::hash h; + suid = h(uname.c_str()); } - // insert all related accounts, if not already there, into the db - //taskmapaccount + std::string parentAccount = api.getString("mainAccount"); + vector childAccounts = api.getVector("subAccounts"); + + if (childAccounts.size() == 0) { + for (auto i = childAccounts.begin(); i != childAccounts.end(); ++i) { + if (!i.empty()) { + std::hash tmphash; + + if (i.length() > MAX_ACCOUNT_NAME_LENGTH) { + i.resize(MAX_ACCOUNT_NAME_LENGTH); + } + + // insert all related accounts, if not already there, into the db + DatabaseConnection::getInstance().upsertAccountRelationship(suid, tmphash(i)); + } + } + } LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), id (%s)", m_stationId, getRemoteAddress().c_str(), uname.c_str())); diff --git a/engine/server/application/LoginServer/src/shared/DatabaseConnection.cpp b/engine/server/application/LoginServer/src/shared/DatabaseConnection.cpp index e5b1e584..f86cba4f 100755 --- a/engine/server/application/LoginServer/src/shared/DatabaseConnection.cpp +++ b/engine/server/application/LoginServer/src/shared/DatabaseConnection.cpp @@ -20,6 +20,7 @@ #include "TaskGetCharactersForDelete.h" #include "TaskGetClusterList.h" #include "TaskGetValidationData.h" +#include "TaskMapAccount.h" #include "TaskRegisterNewCluster.h" #include "TaskRenameCharacter.h" #include "TaskRestoreCharacter.h" @@ -163,6 +164,12 @@ void DatabaseConnection::getAccountValidationData(const TransferRequestMoveValid // ---------------------------------------------------------------------- +void DatabaseConnection::upsertAccountRelationship(StationId parentID, StationId childID) { + m_taskQueue->asyncRequest(new TaskMapAccount(parentID, childID)); +} + +// ---------------------------------------------------------------------- + void DatabaseConnection::deleteCharacter(uint32 clusterId, const NetworkId &characterId, StationId stationId) { NOT_NULL(m_taskQueue); diff --git a/engine/server/application/LoginServer/src/shared/DatabaseConnection.h b/engine/server/application/LoginServer/src/shared/DatabaseConnection.h index e2ad211e..4e848a20 100755 --- a/engine/server/application/LoginServer/src/shared/DatabaseConnection.h +++ b/engine/server/application/LoginServer/src/shared/DatabaseConnection.h @@ -47,6 +47,7 @@ class DatabaseConnection : public Singleton void update (); void getAccountValidationData (StationId stationId, uint32 clusterId, unsigned int track, uint32 subscriptionBits); void getAccountValidationData (const TransferRequestMoveValidation & request, uint32 clusterId); + void upsertAccountRelationship (StationId parentID, StationId childID); void deleteCharacter (uint32 clusterId, const NetworkId &characterId, StationId stationId); void deleteAllCharacters (StationId stationId); void renameCharacter (uint32 clusterId, const NetworkId &characterId, const Unicode::String &newName, const TransferCharacterData * requestData); diff --git a/engine/server/application/LoginServer/src/shared/TaskMapAccount.cpp b/engine/server/application/LoginServer/src/shared/TaskMapAccount.cpp index ba95989a..1a8b9705 100644 --- a/engine/server/application/LoginServer/src/shared/TaskMapAccount.cpp +++ b/engine/server/application/LoginServer/src/shared/TaskMapAccount.cpp @@ -1,7 +1,7 @@ // ====================================================================== // // TaskMapAccount.cpp -// copyright (c) 2001 Sony Online Entertainment +// copyright (c) 2016 StellaBellum // // ====================================================================== diff --git a/external/3rd/library/webAPI/webAPI.cpp b/external/3rd/library/webAPI/webAPI.cpp index 57741ff8..cd99d9b3 100644 --- a/external/3rd/library/webAPI/webAPI.cpp +++ b/external/3rd/library/webAPI/webAPI.cpp @@ -55,6 +55,14 @@ std::string webAPI::getString(const std::string &slot) { return std::string(""); } +std::vector getStringVector(const std::string &slot) { + if (!this->responseData.empty() && !slot.empty() && responseData.count(slot) && !this->responseData[slot].is_null()) { + return this->responseData[slot].get>(); + } + + return std::vector(); +} + bool webAPI::submit(const int &reqType, const int &getPost, const int &respType) { if (reqType == DTYPE::JSON) // json request { diff --git a/external/3rd/library/webAPI/webAPI.h b/external/3rd/library/webAPI/webAPI.h index 8a4cb708..9ca0c20e 100644 --- a/external/3rd/library/webAPI/webAPI.h +++ b/external/3rd/library/webAPI/webAPI.h @@ -59,6 +59,9 @@ namespace StellaBellum { // get a string from a given slot std::string getString(const std::string &slot); + // get a vector of strings from a given slot + std::vector getStringVector(const std::string &slot); + // set json key and value for request template bool addJsonData(const std::string &key, const T &value) { if (!key.empty() &&