From 8fb01069e119bc8f29fc2814ef1c93ba4c612e59 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Fri, 11 May 2018 04:16:07 +0000 Subject: [PATCH] switch to int64 for the StationId typedef, and use the StationId typedef everywhere. Note that the Archive.h in this commit really needs to use a centralized Types.h or FoundationTypes.h file, as do many others...in this case I just typedefed at the top --- .../src/shared/CentralServer.cpp | 4 +-- .../CentralServer/src/shared/CentralServer.h | 2 +- .../src/shared/ConnectionServerConnection.cpp | 4 +-- .../src/shared/ConnectionServer.cpp | 4 +-- .../src/shared/ConnectionServer.h | 2 +- .../src/shared/CharacterNameLocator.h | 3 +- .../src/shared/core/NameManager.cpp | 16 +++++------ .../serverGame/src/shared/core/NameManager.h | 10 ++++--- .../gameGameServer/CharacterNamesMessage.cpp | 2 +- .../gameGameServer/CharacterNamesMessage.h | 9 +++--- .../sharedFoundation/src/shared/StationId.h | 2 +- .../src/linux/FoundationTypesLinux.h | 7 +++-- .../src/win32/FoundationTypesWin32.h | 6 ++++ .../VChatAPI/utils2.0/utils/Base/types.h | 5 ---- .../ours/library/archive/src/shared/Archive.h | 28 ++++++++++++++++++- .../src/shared/generated/Schema_h.template | 4 +-- .../src/shared/tasks/TaskRestoreCharacter.h | 2 +- 17 files changed, 72 insertions(+), 38 deletions(-) diff --git a/engine/server/application/CentralServer/src/shared/CentralServer.cpp b/engine/server/application/CentralServer/src/shared/CentralServer.cpp index 8e39542c..2da16b79 100755 --- a/engine/server/application/CentralServer/src/shared/CentralServer.cpp +++ b/engine/server/application/CentralServer/src/shared/CentralServer.cpp @@ -1233,7 +1233,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons DEBUG_REPORT_LOG(true, ("Pending character %lu is logging in or dropping\n", m.getAccountNumber())); // Once they're logged in, Central doesn't need to know about them anymore: - removeFromAccountConnectionMap(m.getAccountNumber()); + removeSuidFromAccountConnectionMap(m.getAccountNumber()); break; } case constcrc("CharacterListMessage") : { @@ -3419,7 +3419,7 @@ void CentralServer::addToAccountConnectionMap(StationId suid, ConnectionServerCo // ---------------------------------------------------------------------- -void CentralServer::removeFromAccountConnectionMap(StationId suid) +void CentralServer::removeSuidFromAccountConnectionMap(StationId suid) { ConnectionServerSUIDMap::iterator i=m_accountConnectionMap.find(suid); if (i!=m_accountConnectionMap.end()) diff --git a/engine/server/application/CentralServer/src/shared/CentralServer.h b/engine/server/application/CentralServer/src/shared/CentralServer.h index 22e6a7de..95b6dd25 100755 --- a/engine/server/application/CentralServer/src/shared/CentralServer.h +++ b/engine/server/application/CentralServer/src/shared/CentralServer.h @@ -169,7 +169,7 @@ public: void getCharacterMatchStatistics(int & numberOfCharacterMatchRequests, int & numberOfCharacterMatchResultsPerRequest, int & timeSpentPerCharacterMatchRequestMs); - void removeFromAccountConnectionMap(StationId suid); + void removeSuidFromAccountConnectionMap(StationId suid); private: void handleRequestGameServerForLoginMessage (const RequestGameServerForLoginMessage & msg); diff --git a/engine/server/application/CentralServer/src/shared/ConnectionServerConnection.cpp b/engine/server/application/CentralServer/src/shared/ConnectionServerConnection.cpp index 196f5a18..3c6f6335 100755 --- a/engine/server/application/CentralServer/src/shared/ConnectionServerConnection.cpp +++ b/engine/server/application/CentralServer/src/shared/ConnectionServerConnection.cpp @@ -254,7 +254,7 @@ void ConnectionServerConnection::onReceive(const Archive::ByteStream & message) s_pseudoClientConnectionMap[info.getValue().first] = std::make_pair(static_cast(info.getValue().second), this); // remove corresponding "non pseudo client connection" - CentralServer::getInstance().removeFromAccountConnectionMap(static_cast(info.getValue().first)); + CentralServer::getInstance().removeSuidFromAccountConnectionMap(static_cast(info.getValue().first)); break; } case constcrc("DestroyPseudoClientConnection") : @@ -443,4 +443,4 @@ void ConnectionServerConnection::removeFromAccountConnectionMap(unsigned int sta { s_pseudoClientConnectionMap.erase(f); } -} \ No newline at end of file +} diff --git a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp index 55fb16e6..d8f3c142 100755 --- a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp +++ b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp @@ -161,7 +161,7 @@ void ConnectionServer::addGameConnection(unsigned long gameServerId, GameConnect //----------------------------------------------------------------------- bool -ConnectionServer::decryptToken(const KeyShare::Token &token, uint32 &stationUserId, bool &secure, std::string &accountName) { +ConnectionServer::decryptToken(const KeyShare::Token &token, StationId &stationUserId, bool &secure, std::string &accountName) { static ConnectionServer &cs = instance(); //Also the sizeof(int) is likewise magic from the session api @@ -179,7 +179,7 @@ ConnectionServer::decryptToken(const KeyShare::Token &token, uint32 &stationUser char *tmpBuffer = new char[MAX_ACCOUNT_NAME_LENGTH + 1]; memset(tmpBuffer, 0, MAX_ACCOUNT_NAME_LENGTH + 1); - memcpy(&stationUserId, keyBufferPointer, sizeof(uint32)); + memcpy(&stationUserId, keyBufferPointer, sizeof(StationId)); keyBufferPointer += sizeof(uint32); memcpy(&secure, keyBufferPointer, sizeof(bool)); keyBufferPointer += sizeof(bool); diff --git a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.h b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.h index 36abc449..1e337661 100755 --- a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.h +++ b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.h @@ -48,7 +48,7 @@ class ConnectionServer : public MessageDispatch::Receiver static void addNewClient(ClientConnection* cconn, const NetworkId &oid, GameConnection* gconn, const std::string &sceneName, bool sendToStarport ); static void addConnectedClient(uint32 suid, ClientConnection* conn); static void addGameConnection(unsigned long gameServerId, GameConnection* gc); - static bool decryptToken(const KeyShare::Token & token, uint32 & stationUserId, bool & secure, std::string & accountName); + static bool decryptToken(const KeyShare::Token & token, StationId & stationUserId, bool & secure, std::string & accountName); static bool decryptToken(const KeyShare::Token & token, char* sessionKey, StationId & stationId); static CentralConnection * getCentralConnection(); static void dropClient(ClientConnection * conn, const std::string &description); diff --git a/engine/server/library/serverDatabase/src/shared/CharacterNameLocator.h b/engine/server/library/serverDatabase/src/shared/CharacterNameLocator.h index 3ca8cd55..cb40bec7 100755 --- a/engine/server/library/serverDatabase/src/shared/CharacterNameLocator.h +++ b/engine/server/library/serverDatabase/src/shared/CharacterNameLocator.h @@ -14,6 +14,7 @@ #include "sharedDatabaseInterface/BindableNetworkId.h" #include "sharedDatabaseInterface/DbQuery.h" #include "serverDatabase/ObjectLocator.h" +#include "sharedFoundation/StationId.h" #include // ====================================================================== @@ -63,7 +64,7 @@ class CharacterNameLocator : public ObjectLocator private: std::vector m_characterIds; - std::vector m_stationIds; + std::vector m_stationIds; std::vector m_characterNames; std::vector m_characterFullNames; std::vector m_characterCreateTime; diff --git a/engine/server/library/serverGame/src/shared/core/NameManager.cpp b/engine/server/library/serverGame/src/shared/core/NameManager.cpp index 3724892f..f5ea7c6d 100755 --- a/engine/server/library/serverGame/src/shared/core/NameManager.cpp +++ b/engine/server/library/serverGame/src/shared/core/NameManager.cpp @@ -189,7 +189,7 @@ int NameManager::getTotalPlayerCount() const // ---------------------------------------------------------------------- -void NameManager::addPlayer(const NetworkId &id, uint32 stationId, const std::string &name, const std::string &fullName, time_t createTime, time_t lastLoginTime, bool notifyOtherServers) +void NameManager::addPlayer(const NetworkId &id, StationId stationId, const std::string &name, const std::string &fullName, time_t createTime, time_t lastLoginTime, bool notifyOtherServers) { std::string normalizedName(normalizeName(name)); @@ -221,14 +221,14 @@ void NameManager::addPlayer(const NetworkId &id, uint32 stationId, const std::st if (notifyOtherServers) { std::vector ids; - std::vector stationIds; + std::vector stationIds; std::vector characterNames; std::vector characterFullNames; std::vector characterCreateTimes; std::vector characterLastLoginTimes; ids.push_back(id); - stationIds.push_back(static_cast(stationId)); + stationIds.push_back(stationId); characterNames.push_back(normalizedName); characterFullNames.push_back(fullName); characterCreateTimes.push_back(static_cast(createTime)); @@ -247,7 +247,7 @@ void NameManager::addPlayer(const NetworkId &id, uint32 stationId, const std::st void NameManager::renamePlayer(const NetworkId &id, const Unicode::String &name, const Unicode::String &fullName) { - uint32 stationId = 0; + StationId stationId = 0; time_t createTime = 0; time_t lastLoginTime = 0; @@ -279,7 +279,7 @@ const NetworkId & NameManager::getPlayerId(const std::string &name) const // ---------------------------------------------------------------------- -uint32 NameManager::getPlayerStationId(const NetworkId &id) const +StationId NameManager::getPlayerStationId(const NetworkId &id) const { IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->find(id); if (i==m_idToCharacterDataMap->end()) @@ -464,7 +464,7 @@ void NameManager::releasePlayerName(const NetworkId &id) // ---------------------------------------------------------------------- -void NameManager::addPlayers(const std::vector &ids, const std::vector &stationIds, const std::vector &names, const std::vector &fullNames, const std::vector &createTimes, const std::vector &lastLoginTimes) +void NameManager::addPlayers(const std::vector &ids, const std::vector &stationIds, const std::vector &names, const std::vector &fullNames, const std::vector &createTimes, const std::vector &lastLoginTimes) { DEBUG_FATAL(ids.size() != stationIds.size(),("Programmer bug: Vectors ids and stationIds must be the same size.\n")); DEBUG_FATAL(ids.size() != names.size(),("Programmer bug: Vectors ids and names must be the same size.\n")); @@ -483,7 +483,7 @@ void NameManager::addPlayers(const std::vector &ids, const std::vecto void NameManager::sendAllNamesToServer (std::vector const & servers) const { std::vector ids; - std::vector stationIds; + std::vector stationIds; std::vector characterNames; std::vector characterFullNames; std::vector characterCreateTimes; @@ -492,7 +492,7 @@ void NameManager::sendAllNamesToServer (std::vector const & servers) con for (IdToCharacterDataMapType::const_iterator i=m_idToCharacterDataMap->begin(); i!=m_idToCharacterDataMap->end(); ++i) { ids.push_back(i->first); - stationIds.push_back(static_cast(i->second.stationId)); + stationIds.push_back(i->second.stationId); characterNames.push_back(i->second.characterName); characterFullNames.push_back(i->second.characterFullName); characterCreateTimes.push_back(static_cast(i->second.createTime)); diff --git a/engine/server/library/serverGame/src/shared/core/NameManager.h b/engine/server/library/serverGame/src/shared/core/NameManager.h index 6d440b16..f98940e2 100755 --- a/engine/server/library/serverGame/src/shared/core/NameManager.h +++ b/engine/server/library/serverGame/src/shared/core/NameManager.h @@ -8,6 +8,8 @@ #ifndef INCLUDED_NameManager_H #define INCLUDED_NameManager_H +#include "sharedFoundation/StationId.h" + // ====================================================================== class NameGenerator; @@ -32,13 +34,13 @@ class NameManager public: int getTotalPlayerCount () const; - void addPlayer (const NetworkId &id, uint32 stationId, const std::string &name, const std::string &fullName, time_t createTime, time_t lastLoginTime, bool notifyOtherServers); - void addPlayers (const std::vector &ids, const std::vector &stationIds, const std::vector &names, const std::vector &fullNames, const std::vector &createTimes, const std::vector &lastLoginTimes); + void addPlayer (const NetworkId &id, StationId stationId, const std::string &name, const std::string &fullName, time_t createTime, time_t lastLoginTime, bool notifyOtherServers); + void addPlayers (const std::vector &ids, const std::vector &stationIds, const std::vector &names, const std::vector &fullNames, const std::vector &createTimes, const std::vector &lastLoginTimes); void renamePlayer (const NetworkId &id, const Unicode::String &name, const Unicode::String &fullName); std::string debugGetNameList () const; bool isPlayer (NetworkId const & possiblePlayer) const; const NetworkId & getPlayerId (const std::string &name) const; - uint32 getPlayerStationId (const NetworkId &id) const; + StationId getPlayerStationId (const NetworkId &id) const; const std::string & getPlayerName (const NetworkId &id) const; const std::string & getPlayerFullName (const NetworkId &id) const; int getPlayerCreateTime (const NetworkId &id) const; @@ -78,7 +80,7 @@ class NameManager struct CharacterData { - uint32 stationId; + StationId stationId; std::string characterName; std::string characterFullName; time_t createTime; diff --git a/engine/server/library/serverNetworkMessages/src/shared/gameGameServer/CharacterNamesMessage.cpp b/engine/server/library/serverNetworkMessages/src/shared/gameGameServer/CharacterNamesMessage.cpp index 587764ac..8dcb9a94 100755 --- a/engine/server/library/serverNetworkMessages/src/shared/gameGameServer/CharacterNamesMessage.cpp +++ b/engine/server/library/serverNetworkMessages/src/shared/gameGameServer/CharacterNamesMessage.cpp @@ -10,7 +10,7 @@ // ====================================================================== -CharacterNamesMessage::CharacterNamesMessage(const std::vector &ids, const std::vector &stationIds, const std::vector &characterNames, const std::vector &characterFullNames, const std::vector &createTimes, const std::vector &loginTimes) : +CharacterNamesMessage::CharacterNamesMessage(const std::vector &ids, const std::vector &stationIds, const std::vector &characterNames, const std::vector &characterFullNames, const std::vector &createTimes, const std::vector &loginTimes) : GameNetworkMessage("CharacterNamesMessage"), m_ids(), m_stationIds(), diff --git a/engine/server/library/serverNetworkMessages/src/shared/gameGameServer/CharacterNamesMessage.h b/engine/server/library/serverNetworkMessages/src/shared/gameGameServer/CharacterNamesMessage.h index a693698b..047b32d0 100755 --- a/engine/server/library/serverNetworkMessages/src/shared/gameGameServer/CharacterNamesMessage.h +++ b/engine/server/library/serverNetworkMessages/src/shared/gameGameServer/CharacterNamesMessage.h @@ -8,6 +8,7 @@ #ifndef INCLUDED_CharacterNamesMessage_H #define INCLUDED_CharacterNamesMessage_H +#include "sharedFoundation/StationId.h" #include "sharedNetworkMessages/GameNetworkMessage.h" // ====================================================================== @@ -21,12 +22,12 @@ class CharacterNamesMessage : public GameNetworkMessage { public: - CharacterNamesMessage(const std::vector &ids, const std::vector &stationIds, const std::vector &characterNames, const std::vector &characterFullNames, const std::vector &createTimes, const std::vector &loginTimes); + CharacterNamesMessage(const std::vector &ids, const std::vector &stationIds, const std::vector &characterNames, const std::vector &characterFullNames, const std::vector &createTimes, const std::vector &loginTimes); CharacterNamesMessage(Archive::ReadIterator & source); ~CharacterNamesMessage(); const std::vector &getIds() const; - const std::vector &getStationIds() const; + const std::vector &getStationIds() const; const std::vector &getNames() const; const std::vector &getFullNames() const; const std::vector &getCreateTimes() const; @@ -34,7 +35,7 @@ class CharacterNamesMessage : public GameNetworkMessage private: Archive::AutoArray m_ids; - Archive::AutoArray m_stationIds; + Archive::AutoArray m_stationIds; Archive::AutoArray m_names; Archive::AutoArray m_fullNames; Archive::AutoArray m_createTimes; @@ -57,7 +58,7 @@ inline const std::vector & CharacterNamesMessage::getIds() const // ---------------------------------------------------------------------- -inline const std::vector & CharacterNamesMessage::getStationIds() const +inline const std::vector & CharacterNamesMessage::getStationIds() const { return m_stationIds.get(); } diff --git a/engine/shared/library/sharedFoundation/src/shared/StationId.h b/engine/shared/library/sharedFoundation/src/shared/StationId.h index a0d7872c..8633f774 100755 --- a/engine/shared/library/sharedFoundation/src/shared/StationId.h +++ b/engine/shared/library/sharedFoundation/src/shared/StationId.h @@ -10,7 +10,7 @@ // ====================================================================== -typedef uint32 StationId; +typedef int64 StationId; // ====================================================================== diff --git a/engine/shared/library/sharedFoundationTypes/src/linux/FoundationTypesLinux.h b/engine/shared/library/sharedFoundationTypes/src/linux/FoundationTypesLinux.h index 386c4ffb..8d7e87b2 100755 --- a/engine/shared/library/sharedFoundationTypes/src/linux/FoundationTypesLinux.h +++ b/engine/shared/library/sharedFoundationTypes/src/linux/FoundationTypesLinux.h @@ -10,6 +10,8 @@ #define PLATFORM_LINUX #include +#include + // ====================================================================== // basic types that we assume to be around @@ -20,11 +22,12 @@ typedef unsigned long uint32; typedef signed char int8; typedef signed short int16; typedef signed long int32; -typedef signed long long int int64; -typedef unsigned long long int uint64; typedef float real; typedef FILE* FILE_HANDLE; +typedef int64_t int64; +typedef u_int64_t uint64; + #endif diff --git a/engine/shared/library/sharedFoundationTypes/src/win32/FoundationTypesWin32.h b/engine/shared/library/sharedFoundationTypes/src/win32/FoundationTypesWin32.h index 622039d8..64864f82 100755 --- a/engine/shared/library/sharedFoundationTypes/src/win32/FoundationTypesWin32.h +++ b/engine/shared/library/sharedFoundationTypes/src/win32/FoundationTypesWin32.h @@ -7,6 +7,8 @@ // // ====================================================================== +#include + #ifndef INCLUDED_FoundationTypesWin32_H #define INCLUDED_FoundationTypesWin32_H @@ -28,6 +30,10 @@ typedef signed long int32; typedef signed __int64 int64; typedef int FILE_HANDLE; +typedef int64_t int64; +typedef u_int64_t uint64; + + // ====================================================================== #endif diff --git a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/types.h b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/types.h index ba396c51..2ebb44de 100755 --- a/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/types.h +++ b/external/3rd/library/soePlatform/VChatAPI/utils2.0/utils/Base/types.h @@ -49,11 +49,6 @@ namespace soe typedef u_int32_t uint32; typedef int64_t int64; typedef u_int64_t uint64; -//! the previous seem erroneous -// typedef signed int int32; -// typedef unsigned int uint32; -// typedef signed long long int64; -// typedef unsigned long long uint64; #endif } diff --git a/external/ours/library/archive/src/shared/Archive.h b/external/ours/library/archive/src/shared/Archive.h index 2921d66f..20a2ce2e 100755 --- a/external/ours/library/archive/src/shared/Archive.h +++ b/external/ours/library/archive/src/shared/Archive.h @@ -9,12 +9,28 @@ #include #include +// TODO: this is retarded, we have like 30-50 places where we define types... +// we must do something abou tthis +#include +typedef int64_t int64; +typedef u_int64_t uint64; +typedef int64 StationId; + //--------------------------------------------------------------------- namespace Archive { //--------------------------------------------------------------------- - + +inline void get(ByteStream::ReadIterator & source, uint64 & target) +{ + source.get(&target, 8); +} + +inline void get(ByteStream::ReadIterator & source, int64 & target) +{ + source.get(&target, 8); +} inline void get(ReadIterator & source, double & target) { @@ -215,6 +231,16 @@ template inline void get(ReadIterator & source, A * target, int leng //--------------------------------------------------------------------- +inline void put(ByteStream & target, const uint64 & source) +{ + target.put(&source, 8); +} + +inline void put(ByteStream & target, const int64 & source) +{ + target.put(&source, 8); +} + inline void put(ByteStream & target, const double & source) { target.put(&source, 8); 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 7297cfd7..1bd7c287 100644 --- a/game/server/application/SwgDatabaseServer/src/shared/generated/Schema_h.template +++ b/game/server/application/SwgDatabaseServer/src/shared/generated/Schema_h.template @@ -23,7 +23,7 @@ struct PlayerObjectRow : public DB::Row enum {QUEST_DATA_SIZE=4000}; DB::BindableNetworkId object_id; - DB::BindableLong station_id; + DB::BindableInt64 station_id; DB::BindableNetworkId house_id; DB::BindableLong account_num_lots; DB::BindableBool account_is_outcast; @@ -80,7 +80,7 @@ struct PlayerObjectRow : public DB::Row struct PlayerObjectBufferRow : public DB::Row { DB::BindableNetworkId object_id; - DB::BindableLong station_id; + DB::BindableInt64 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 2e043f3d..f48e415a 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::BindableLong account; + DB::BindableInt64 account; DB::BindableLong template_id; private: