diff --git a/engine/server/application/LoginServer/src/CMakeLists.txt b/engine/server/application/LoginServer/src/CMakeLists.txt index 991b0a11..6a1c07e1 100644 --- a/engine/server/application/LoginServer/src/CMakeLists.txt +++ b/engine/server/application/LoginServer/src/CMakeLists.txt @@ -50,6 +50,8 @@ set(SHARED_SOURCES shared/TaskGetClusterList.h shared/TaskGetValidationData.cpp shared/TaskGetValidationData.h + shared/TaskMapAccount.h + shared/TaskMapAccount.cpp shared/TaskRegisterNewCluster.cpp shared/TaskRegisterNewCluster.h shared/TaskRenameCharacter.cpp @@ -76,7 +78,7 @@ if(WIN32) else() set(PLATFORM_SOURCES linux/main.cpp - ) + shared/TaskMapAccount.h shared/TaskMapAccount.cpp) endif() include_directories( diff --git a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp index 0cb75726..f76d0d2a 100755 --- a/engine/server/application/LoginServer/src/shared/ClientConnection.cpp +++ b/engine/server/application/LoginServer/src/shared/ClientConnection.cpp @@ -11,8 +11,8 @@ #include "Archive/ByteStream.h" #include "ConfigLoginServer.h" #include "DatabaseConnection.h" -#include "LoginServer.h" #include "SessionApiClient.h" +#include "TaskMapAccount.h" #include "serverKeyShare/KeyShare.h" #include "sharedFoundation/ApplicationVersion.h" #include "sharedLog/Log.h" @@ -25,7 +25,7 @@ #include "sharedFoundation/CrcConstexpr.hpp" -#include +//#include #include "webAPI.h" @@ -244,10 +244,12 @@ void ClientConnection::validateClient(const std::string & id, const std::string uname.resize(MAX_ACCOUNT_NAME_LENGTH); } - std::hash h; - suid = h(uname.c_str()); + suid = std::hash(uname.c_str()); } + // insert all related accounts, if not already there, into the db + //taskmapaccount + LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), id (%s)", m_stationId, getRemoteAddress().c_str(), uname.c_str())); LoginServer::getInstance().onValidateClient(suid, uname, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF); diff --git a/engine/server/application/LoginServer/src/shared/TaskMapAccount.cpp b/engine/server/application/LoginServer/src/shared/TaskMapAccount.cpp new file mode 100644 index 00000000..ba95989a --- /dev/null +++ b/engine/server/application/LoginServer/src/shared/TaskMapAccount.cpp @@ -0,0 +1,83 @@ +// ====================================================================== +// +// TaskMapAccount.cpp +// copyright (c) 2001 Sony Online Entertainment +// +// ====================================================================== + +#include "FirstLoginServer.h" +#include "TaskMapAccount.h" + +#include "ClientConnection.h" +#include "DatabaseConnection.h" +#include "sharedDatabaseInterface/DbSession.h" + +// ====================================================================== + +TaskMapAccount::TaskMapAccount(StationId parentID, StationId childID) : + TaskRequest(), + m_parentID(parentID), + m_childID(childID) +{ +} + +// ---------------------------------------------------------------------- + +bool TaskMapAccount::process(DB::Session *session) +{ + MapAccountQuery qry; + qry.parentID=m_parentId; + qry.childID=m_childId; + + bool rval = session->exec(&qry); + + qry.done(); + return rval; +} + +// ---------------------------------------------------------------------- + +void TaskMapAccount::onComplete() +{ +} + +// ====================================================================== + +TaskMapAccount::MapAccountQuery::MapAccountQuery() : + Query(), + parentID(), + childID() +{ +} + +// ---------------------------------------------------------------------- + +void TaskMapAccount::MapAccountQuery::getSQL(std::string &sql) +{ + sql = std::string("begin ")+DatabaseConnection::getInstance().getSchemaQualifier()+"login.upsert_account_map(:parentID, :childID); end;"; +} + +// ---------------------------------------------------------------------- + +bool TaskMapAccount::MapAccountQuery::bindParameters() +{ + if (!bindParameter(parentID)) return false; + if (!bindParameter(childID)) return false; + return true; +} + +// ---------------------------------------------------------------------- + +bool TaskMapAccount::MapAccountQuery::bindColumns() +{ + return true; +} + +// ---------------------------------------------------------------------- + +DB::Query::QueryMode TaskMapAccount::MapAccountQuery::getExecutionMode() const +{ + return MODE_PROCEXEC; +} + +// ====================================================================== diff --git a/engine/server/application/LoginServer/src/shared/TaskMapAccount.h b/engine/server/application/LoginServer/src/shared/TaskMapAccount.h new file mode 100644 index 00000000..73e7227b --- /dev/null +++ b/engine/server/application/LoginServer/src/shared/TaskMapAccount.h @@ -0,0 +1,57 @@ +// ====================================================================== +// +// TaskMapAccount.h +// copyright (c) 2016 StellaBellum +// +// ====================================================================== + +#ifndef INCLUDED_TaskMapAccount_H +#define INCLUDED_TaskMapAccount_H + +// ====================================================================== + +#include "sharedDatabaseInterface/Bindable.h" +#include "sharedDatabaseInterface/BindableNetworkId.h" +#include "sharedDatabaseInterface/DbQuery.h" +#include "sharedDatabaseInterface/DbTaskRequest.h" + +// ====================================================================== + +class TaskMapAccount : public DB::TaskRequest +{ + public: + TaskMapAccount(StationId parentID, StationId childID); + + public: + virtual bool process (DB::Session *session); + virtual void onComplete (); + + private: + TaskMapAccount(); // disabled default constructor + + class MapAccountQuery : public DB::Query + { + public: + MapAccountQuery(); + + DB::BindableNetworkId parentID; //lint !e1925 // public data member + DB::BindableLong childID; //lint !e1925 // public data member + + virtual void getSQL(std::string &sql); + virtual bool bindParameters(); + virtual bool bindColumns(); + virtual QueryMode getExecutionMode() const; + + private: //disable + MapAccountQuery(const MapAccountQuery&); + MapAccountQuery &operator=(const MapAccountQuery&); + }; + + private: + StationId m_parentID; + StationId m_childID; +}; + +// ====================================================================== + +#endif