mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-29 16:11:48 -06:00
Compare commits
4 Commits
auth-packe
...
feat-conve
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8d6b1e101 | ||
|
|
951a6710d8 | ||
|
|
922a9ef5ea | ||
|
|
68f2e2dee2 |
@@ -7,6 +7,7 @@ FetchContent_Declare(
|
||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG release-1.12.1
|
||||
GIT_PROGRESS TRUE
|
||||
GIT_SHALLOW 1
|
||||
)
|
||||
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
//Auth includes:
|
||||
#include "AuthPackets.h"
|
||||
#include "CommonPackets.h"
|
||||
#include "ServiceType.h"
|
||||
#include "MessageType/Server.h"
|
||||
#include "MessageType/Auth.h"
|
||||
@@ -165,12 +164,17 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
void HandlePacket(Packet* packet) {
|
||||
CINSTREAM;
|
||||
LUBitStream luBitStream;
|
||||
if (!luBitStream.ReadHeader(inStream) && luBitStream.rakNetID != ID_USER_PACKET_ENUM) return;
|
||||
else if (luBitStream.serviceType == ServiceType::COMMON) {
|
||||
CommonPackets::Handle(inStream, packet->systemAddress);
|
||||
} else if (luBitStream.serviceType == ServiceType::AUTH) {
|
||||
AuthPackets::Handle(inStream, packet->systemAddress);
|
||||
if (packet->length < 4) return;
|
||||
|
||||
if (packet->data[0] == ID_USER_PACKET_ENUM) {
|
||||
if (static_cast<ServiceType>(packet->data[1]) == ServiceType::COMMON) {
|
||||
if (static_cast<MessageType::Server>(packet->data[3]) == MessageType::Server::VERSION_CONFIRM) {
|
||||
AuthPackets::HandleHandshake(Game::server, packet);
|
||||
}
|
||||
} else if (static_cast<ServiceType>(packet->data[1]) == ServiceType::AUTH) {
|
||||
if (static_cast<MessageType::Auth>(packet->data[3]) == MessageType::Auth::LOGIN_REQUEST) {
|
||||
AuthPackets::HandleLoginRequest(Game::server, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ void ChatIgnoreList::GetIgnoreList(Packet* packet) {
|
||||
if (!receiver.ignoredPlayers.empty()) {
|
||||
LOG_DEBUG("Player %llu already has an ignore list, but is requesting it again.", playerId);
|
||||
} else {
|
||||
auto ignoreList = Database::Get()->GetIgnoreList(static_cast<uint32_t>(playerId));
|
||||
auto ignoreList = Database::Get()->GetIgnoreList(playerId);
|
||||
if (ignoreList.empty()) {
|
||||
LOG_DEBUG("Player %llu has no ignores", playerId);
|
||||
return;
|
||||
@@ -43,7 +43,6 @@ void ChatIgnoreList::GetIgnoreList(Packet* packet) {
|
||||
for (auto& ignoredPlayer : ignoreList) {
|
||||
receiver.ignoredPlayers.emplace_back(ignoredPlayer.name, ignoredPlayer.id);
|
||||
GeneralUtils::SetBit(receiver.ignoredPlayers.back().playerId, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(receiver.ignoredPlayers.back().playerId, eObjectBits::PERSISTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +113,8 @@ void ChatIgnoreList::AddIgnore(Packet* packet) {
|
||||
}
|
||||
|
||||
if (ignoredPlayerId != LWOOBJID_EMPTY) {
|
||||
Database::Get()->AddIgnore(static_cast<uint32_t>(playerId), static_cast<uint32_t>(ignoredPlayerId));
|
||||
Database::Get()->AddIgnore(playerId, ignoredPlayerId);
|
||||
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(ignoredPlayerId, eObjectBits::PERSISTENT);
|
||||
|
||||
receiver.ignoredPlayers.emplace_back(toIgnoreStr, ignoredPlayerId);
|
||||
LOG_DEBUG("Player %llu is ignoring %s", playerId, toIgnoreStr.c_str());
|
||||
@@ -157,7 +155,7 @@ void ChatIgnoreList::RemoveIgnore(Packet* packet) {
|
||||
return;
|
||||
}
|
||||
|
||||
Database::Get()->RemoveIgnore(static_cast<uint32_t>(playerId), static_cast<uint32_t>(toRemove->playerId));
|
||||
Database::Get()->RemoveIgnore(playerId, toRemove->playerId);
|
||||
receiver.ignoredPlayers.erase(toRemove, receiver.ignoredPlayers.end());
|
||||
|
||||
CBITSTREAM;
|
||||
|
||||
@@ -35,7 +35,6 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
|
||||
FriendData fd;
|
||||
fd.isFTP = false; // not a thing in DLU
|
||||
fd.friendID = friendData.friendID;
|
||||
GeneralUtils::SetBit(fd.friendID, eObjectBits::PERSISTENT);
|
||||
GeneralUtils::SetBit(fd.friendID, eObjectBits::CHARACTER);
|
||||
|
||||
fd.isBestFriend = friendData.isBestFriend; //0 = friends, 1 = left_requested, 2 = right_requested, 3 = both_accepted - are now bffs
|
||||
@@ -161,9 +160,7 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
|
||||
|
||||
// Set the bits
|
||||
GeneralUtils::SetBit(queryPlayerID, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(queryPlayerID, eObjectBits::PERSISTENT);
|
||||
GeneralUtils::SetBit(queryFriendID, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(queryFriendID, eObjectBits::PERSISTENT);
|
||||
|
||||
// Since this player can either be the friend of someone else or be friends with someone else
|
||||
// their column in the database determines what bit gets set. When the value hits 3, they
|
||||
@@ -318,7 +315,6 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) {
|
||||
}
|
||||
|
||||
// Convert friendID to LWOOBJID
|
||||
GeneralUtils::SetBit(friendID, eObjectBits::PERSISTENT);
|
||||
GeneralUtils::SetBit(friendID, eObjectBits::CHARACTER);
|
||||
|
||||
Database::Get()->RemoveFriend(playerID, friendID);
|
||||
|
||||
@@ -55,6 +55,7 @@ elseif (WIN32)
|
||||
URL https://github.com/madler/zlib/archive/refs/tags/v1.2.11.zip
|
||||
URL_HASH MD5=9d6a627693163bbbf3f26403a3a0b0b1
|
||||
GIT_PROGRESS TRUE
|
||||
GIT_SHALLOW 1
|
||||
)
|
||||
|
||||
# Disable warning about no project version.
|
||||
|
||||
24
dCommon/dEnums/eLoginResponse.h
Normal file
24
dCommon/dEnums/eLoginResponse.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef __ELOGINRESPONSE__H__
|
||||
#define __ELOGINRESPONSE__H__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
enum class eLoginResponse : uint8_t {
|
||||
GENERAL_FAILED = 0,
|
||||
SUCCESS,
|
||||
BANNED,
|
||||
// Unused 3
|
||||
// Unused 4
|
||||
PERMISSIONS_NOT_HIGH_ENOUGH = 5,
|
||||
INVALID_USER,
|
||||
ACCOUNT_LOCKED,
|
||||
WRONG_PASS,
|
||||
ACCOUNT_ACTIVATION_PENDING,
|
||||
ACCOUNT_DISABLED,
|
||||
GAME_TIME_EXPIRED,
|
||||
FREE_TRIAL_ENDED,
|
||||
PLAY_SCHEDULE_TIME_UP,
|
||||
ACCOUNT_NOT_ACTIVATED
|
||||
};
|
||||
|
||||
#endif //!__ELOGINRESPONSE__H__
|
||||
24
dCommon/dEnums/eServerDisconnectIdentifiers.h
Normal file
24
dCommon/dEnums/eServerDisconnectIdentifiers.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef __ESERVERDISCONNECTIDENTIFIERS__H__
|
||||
#define __ESERVERDISCONNECTIDENTIFIERS__H__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
enum class eServerDisconnectIdentifiers : uint32_t {
|
||||
UNKNOWN_SERVER_ERROR = 0,
|
||||
WRONG_GAME_VERSION,
|
||||
WRONG_SERVER_VERSION,
|
||||
CONNECTION_ON_INVALID_PORT,
|
||||
DUPLICATE_LOGIN,
|
||||
SERVER_SHUTDOWN,
|
||||
SERVER_MAP_LOAD_FAILURE,
|
||||
INVALID_SESSION_KEY,
|
||||
ACCOUNT_NOT_IN_PENDING_LIST,
|
||||
CHARACTER_NOT_FOUND,
|
||||
CHARACTER_CORRUPTED,
|
||||
KICK,
|
||||
SAVE_FAILURE,
|
||||
FREE_TRIAL_EXPIRED,
|
||||
PLAY_SCHEDULE_TIME_DONE
|
||||
};
|
||||
|
||||
#endif //!__ESERVERDISCONNECTIDENTIFIERS__H__
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
virtual void Commit() = 0;
|
||||
virtual bool GetAutoCommit() = 0;
|
||||
virtual void SetAutoCommit(bool value) = 0;
|
||||
virtual void DeleteCharacter(const uint32_t characterId) = 0;
|
||||
virtual void DeleteCharacter(const LWOOBJID characterId) = 0;
|
||||
};
|
||||
|
||||
#endif //!__GAMEDATABASE__H__
|
||||
|
||||
@@ -14,7 +14,7 @@ enum class eActivityType : uint32_t {
|
||||
class IActivityLog {
|
||||
public:
|
||||
// Update the activity log for the given account.
|
||||
virtual void UpdateActivityLog(const uint32_t characterId, const eActivityType activityType, const LWOMAPID mapId) = 0;
|
||||
virtual void UpdateActivityLog(const LWOOBJID characterId, const eActivityType activityType, const LWOMAPID mapId) = 0;
|
||||
};
|
||||
|
||||
#endif //!__IACTIVITYLOG__H__
|
||||
|
||||
@@ -9,7 +9,7 @@ class IBehaviors {
|
||||
public:
|
||||
struct Info {
|
||||
LWOOBJID behaviorId{};
|
||||
uint32_t characterId{};
|
||||
LWOOBJID characterId{};
|
||||
std::string behaviorInfo;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
std::string clientVersion;
|
||||
std::string otherPlayer;
|
||||
std::string selection;
|
||||
uint32_t characterId{};
|
||||
LWOOBJID characterId{};
|
||||
};
|
||||
|
||||
// Add a new bug report to the database.
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
struct Info {
|
||||
std::string name;
|
||||
std::string pendingName;
|
||||
uint32_t id{};
|
||||
LWOOBJID id{};
|
||||
uint32_t accountId{};
|
||||
bool needsRename{};
|
||||
LWOCLONEID cloneId{};
|
||||
@@ -25,25 +25,25 @@ public:
|
||||
virtual std::vector<std::string> GetApprovedCharacterNames() = 0;
|
||||
|
||||
// Get the character info for the given character id.
|
||||
virtual std::optional<ICharInfo::Info> GetCharacterInfo(const uint32_t charId) = 0;
|
||||
virtual std::optional<ICharInfo::Info> GetCharacterInfo(const LWOOBJID charId) = 0;
|
||||
|
||||
// Get the character info for the given character name.
|
||||
virtual std::optional<ICharInfo::Info> GetCharacterInfo(const std::string_view name) = 0;
|
||||
|
||||
// Get the character ids for the given account.
|
||||
virtual std::vector<uint32_t> GetAccountCharacterIds(const uint32_t accountId) = 0;
|
||||
virtual std::vector<LWOOBJID> GetAccountCharacterIds(const LWOOBJID accountId) = 0;
|
||||
|
||||
// Insert a new character into the database.
|
||||
virtual void InsertNewCharacter(const ICharInfo::Info info) = 0;
|
||||
|
||||
// Set the name of the given character.
|
||||
virtual void SetCharacterName(const uint32_t characterId, const std::string_view name) = 0;
|
||||
virtual void SetCharacterName(const LWOOBJID characterId, const std::string_view name) = 0;
|
||||
|
||||
// Set the pending name of the given character.
|
||||
virtual void SetPendingCharacterName(const uint32_t characterId, const std::string_view name) = 0;
|
||||
virtual void SetPendingCharacterName(const LWOOBJID characterId, const std::string_view name) = 0;
|
||||
|
||||
// Updates the given character ids last login to be right now.
|
||||
virtual void UpdateLastLoggedInCharacter(const uint32_t characterId) = 0;
|
||||
virtual void UpdateLastLoggedInCharacter(const LWOOBJID characterId) = 0;
|
||||
|
||||
virtual bool IsNameInUse(const std::string_view name) = 0;
|
||||
};
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
class ICharXml {
|
||||
public:
|
||||
// Get the character xml for the given character id.
|
||||
virtual std::string GetCharacterXml(const uint32_t charId) = 0;
|
||||
virtual std::string GetCharacterXml(const LWOOBJID charId) = 0;
|
||||
|
||||
// Update the character xml for the given character id.
|
||||
virtual void UpdateCharacterXml(const uint32_t charId, const std::string_view lxfml) = 0;
|
||||
virtual void UpdateCharacterXml(const LWOOBJID charId, const std::string_view lxfml) = 0;
|
||||
|
||||
// Insert the character xml for the given character id.
|
||||
virtual void InsertCharacterXml(const uint32_t characterId, const std::string_view lxfml) = 0;
|
||||
virtual void InsertCharacterXml(const LWOOBJID characterId, const std::string_view lxfml) = 0;
|
||||
};
|
||||
|
||||
#endif //!__ICHARXML__H__
|
||||
|
||||
@@ -8,7 +8,7 @@ class ICommandLog {
|
||||
public:
|
||||
|
||||
// Insert a new slash command log entry.
|
||||
virtual void InsertSlashCommandUsage(const uint32_t characterId, const std::string_view command) = 0;
|
||||
virtual void InsertSlashCommandUsage(const LWOOBJID characterId, const std::string_view command) = 0;
|
||||
};
|
||||
|
||||
#endif //!__ICOMMANDLOG__H__
|
||||
|
||||
@@ -8,25 +8,25 @@
|
||||
class IFriends {
|
||||
public:
|
||||
struct BestFriendStatus {
|
||||
uint32_t playerCharacterId{};
|
||||
uint32_t friendCharacterId{};
|
||||
LWOOBJID playerCharacterId{};
|
||||
LWOOBJID friendCharacterId{};
|
||||
uint32_t bestFriendStatus{};
|
||||
};
|
||||
|
||||
// Get the friends list for the given character id.
|
||||
virtual std::vector<FriendData> GetFriendsList(const uint32_t charId) = 0;
|
||||
virtual std::vector<FriendData> GetFriendsList(const LWOOBJID charId) = 0;
|
||||
|
||||
// Get the best friend status for the given player and friend character ids.
|
||||
virtual std::optional<IFriends::BestFriendStatus> GetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId) = 0;
|
||||
virtual std::optional<IFriends::BestFriendStatus> GetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) = 0;
|
||||
|
||||
// Set the best friend status for the given player and friend character ids.
|
||||
virtual void SetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId, const uint32_t bestFriendStatus) = 0;
|
||||
virtual void SetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId, const uint32_t bestFriendStatus) = 0;
|
||||
|
||||
// Add a friend to the given character id.
|
||||
virtual void AddFriend(const uint32_t playerCharacterId, const uint32_t friendCharacterId) = 0;
|
||||
virtual void AddFriend(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) = 0;
|
||||
|
||||
// Remove a friend from the given character id.
|
||||
virtual void RemoveFriend(const uint32_t playerCharacterId, const uint32_t friendCharacterId) = 0;
|
||||
virtual void RemoveFriend(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) = 0;
|
||||
};
|
||||
|
||||
#endif //!__IFRIENDS__H__
|
||||
|
||||
@@ -9,12 +9,12 @@ class IIgnoreList {
|
||||
public:
|
||||
struct Info {
|
||||
std::string name;
|
||||
uint32_t id;
|
||||
LWOOBJID id;
|
||||
};
|
||||
|
||||
virtual std::vector<Info> GetIgnoreList(const uint32_t playerId) = 0;
|
||||
virtual void AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) = 0;
|
||||
virtual void RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) = 0;
|
||||
virtual std::vector<Info> GetIgnoreList(const LWOOBJID playerId) = 0;
|
||||
virtual void AddIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) = 0;
|
||||
virtual void RemoveIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) = 0;
|
||||
};
|
||||
|
||||
#endif //!__IIGNORELIST__H__
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "dCommonVars.h"
|
||||
|
||||
class ILeaderboard {
|
||||
public:
|
||||
|
||||
struct Entry {
|
||||
uint32_t charId{};
|
||||
LWOOBJID charId{};
|
||||
uint32_t lastPlayedTimestamp{};
|
||||
float primaryScore{};
|
||||
float secondaryScore{};
|
||||
@@ -36,12 +37,12 @@ public:
|
||||
virtual std::vector<ILeaderboard::Entry> GetAscendingLeaderboard(const uint32_t activityId) = 0;
|
||||
virtual std::vector<ILeaderboard::Entry> GetNsLeaderboard(const uint32_t activityId) = 0;
|
||||
virtual std::vector<ILeaderboard::Entry> GetAgsLeaderboard(const uint32_t activityId) = 0;
|
||||
virtual std::optional<Score> GetPlayerScore(const uint32_t playerId, const uint32_t gameId) = 0;
|
||||
virtual std::optional<Score> GetPlayerScore(const LWOOBJID playerId, const uint32_t gameId) = 0;
|
||||
|
||||
virtual void SaveScore(const uint32_t playerId, const uint32_t gameId, const Score& score) = 0;
|
||||
virtual void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) = 0;
|
||||
virtual void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) = 0;
|
||||
virtual void IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) = 0;
|
||||
virtual void SaveScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) = 0;
|
||||
virtual void UpdateScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) = 0;
|
||||
virtual void IncrementNumWins(const LWOOBJID playerId, const uint32_t gameId) = 0;
|
||||
virtual void IncrementTimesPlayed(const LWOOBJID playerId, const uint32_t gameId) = 0;
|
||||
};
|
||||
|
||||
#endif //!__ILEADERBOARD__H__
|
||||
|
||||
@@ -16,13 +16,13 @@ public:
|
||||
virtual void InsertNewMail(const MailInfo& mail) = 0;
|
||||
|
||||
// Get the mail for the given character id.
|
||||
virtual std::vector<MailInfo> GetMailForPlayer(const uint32_t characterId, const uint32_t numberOfMail) = 0;
|
||||
virtual std::vector<MailInfo> GetMailForPlayer(const LWOOBJID characterId, const uint32_t numberOfMail) = 0;
|
||||
|
||||
// Get the mail for the given mail id.
|
||||
virtual std::optional<MailInfo> GetMail(const uint64_t mailId) = 0;
|
||||
|
||||
// Get the number of unread mail for the given character id.
|
||||
virtual uint32_t GetUnreadMailCount(const uint32_t characterId) = 0;
|
||||
virtual uint32_t GetUnreadMailCount(const LWOOBJID characterId) = 0;
|
||||
|
||||
// Mark the given mail as read.
|
||||
virtual void MarkMailRead(const uint64_t mailId) = 0;
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
std::string description;
|
||||
std::string rejectionReason;
|
||||
LWOOBJID id{};
|
||||
uint32_t ownerId{};
|
||||
LWOOBJID ownerId{};
|
||||
LWOCLONEID cloneId{};
|
||||
int32_t privacyOption{};
|
||||
uint32_t modApproved{};
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
uint32_t mapId{};
|
||||
std::string searchString;
|
||||
ePropertySortType sortChoice{};
|
||||
uint32_t playerId{};
|
||||
LWOOBJID playerId{};
|
||||
uint32_t numResults{};
|
||||
uint32_t startIndex{};
|
||||
uint32_t playerSort{};
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
std::stringstream& sd0Data,
|
||||
const uint32_t blueprintId,
|
||||
const uint32_t accountId,
|
||||
const uint32_t characterId) = 0;
|
||||
const LWOOBJID characterId) = 0;
|
||||
|
||||
// Get the property models for the given property id.
|
||||
virtual std::vector<IPropertyContents::Model> GetPropertyModels(const LWOOBJID& propertyId) = 0;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
class IUgcModularBuild {
|
||||
public:
|
||||
virtual void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) = 0;
|
||||
virtual void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<LWOOBJID> characterId) = 0;
|
||||
virtual void DeleteUgcBuild(const LWOOBJID bigId) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ void MySQLDatabase::SetAutoCommit(bool value) {
|
||||
con->setAutoCommit(value);
|
||||
}
|
||||
|
||||
void MySQLDatabase::DeleteCharacter(const uint32_t characterId) {
|
||||
void MySQLDatabase::DeleteCharacter(const LWOOBJID characterId) {
|
||||
ExecuteDelete("DELETE FROM charxml WHERE id=? LIMIT 1;", characterId);
|
||||
ExecuteDelete("DELETE FROM command_log WHERE character_id=?;", characterId);
|
||||
ExecuteDelete("DELETE FROM friends WHERE player_id=? OR friend_id=?;", characterId, characterId);
|
||||
|
||||
@@ -40,31 +40,31 @@ public:
|
||||
|
||||
std::vector<std::string> GetApprovedCharacterNames() override;
|
||||
|
||||
std::vector<FriendData> GetFriendsList(uint32_t charID) override;
|
||||
std::vector<FriendData> GetFriendsList(LWOOBJID charID) override;
|
||||
|
||||
std::optional<IFriends::BestFriendStatus> GetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId) override;
|
||||
void SetBestFriendStatus(const uint32_t playerAccountId, const uint32_t friendAccountId, const uint32_t bestFriendStatus) override;
|
||||
void AddFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) override;
|
||||
void RemoveFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) override;
|
||||
void UpdateActivityLog(const uint32_t characterId, const eActivityType activityType, const LWOMAPID mapId) override;
|
||||
std::optional<IFriends::BestFriendStatus> GetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) override;
|
||||
void SetBestFriendStatus(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId, const uint32_t bestFriendStatus) override;
|
||||
void AddFriend(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId) override;
|
||||
void RemoveFriend(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId) override;
|
||||
void UpdateActivityLog(const LWOOBJID characterId, const eActivityType activityType, const LWOMAPID mapId) override;
|
||||
void DeleteUgcModelData(const LWOOBJID& modelId) override;
|
||||
void UpdateUgcModelData(const LWOOBJID& modelId, std::stringstream& lxfml) override;
|
||||
std::vector<IUgc::Model> GetAllUgcModels() override;
|
||||
void CreateMigrationHistoryTable() override;
|
||||
bool IsMigrationRun(const std::string_view str) override;
|
||||
void InsertMigration(const std::string_view str) override;
|
||||
std::optional<ICharInfo::Info> GetCharacterInfo(const uint32_t charId) override;
|
||||
std::optional<ICharInfo::Info> GetCharacterInfo(const LWOOBJID charId) override;
|
||||
std::optional<ICharInfo::Info> GetCharacterInfo(const std::string_view charId) override;
|
||||
std::string GetCharacterXml(const uint32_t accountId) override;
|
||||
void UpdateCharacterXml(const uint32_t characterId, const std::string_view lxfml) override;
|
||||
std::string GetCharacterXml(const LWOOBJID accountId) override;
|
||||
void UpdateCharacterXml(const LWOOBJID characterId, const std::string_view lxfml) override;
|
||||
std::optional<IAccounts::Info> GetAccountInfo(const std::string_view username) override;
|
||||
void InsertNewCharacter(const ICharInfo::Info info) override;
|
||||
void InsertCharacterXml(const uint32_t accountId, const std::string_view lxfml) override;
|
||||
std::vector<uint32_t> GetAccountCharacterIds(uint32_t accountId) override;
|
||||
void DeleteCharacter(const uint32_t characterId) override;
|
||||
void SetCharacterName(const uint32_t characterId, const std::string_view name) override;
|
||||
void SetPendingCharacterName(const uint32_t characterId, const std::string_view name) override;
|
||||
void UpdateLastLoggedInCharacter(const uint32_t characterId) override;
|
||||
void InsertCharacterXml(const LWOOBJID accountId, const std::string_view lxfml) override;
|
||||
std::vector<LWOOBJID> GetAccountCharacterIds(LWOOBJID accountId) override;
|
||||
void DeleteCharacter(const LWOOBJID characterId) override;
|
||||
void SetCharacterName(const LWOOBJID characterId, const std::string_view name) override;
|
||||
void SetPendingCharacterName(const LWOOBJID characterId, const std::string_view name) override;
|
||||
void UpdateLastLoggedInCharacter(const LWOOBJID characterId) override;
|
||||
void SetPetNameModerationStatus(const LWOOBJID& petId, const IPetNames::Info& info) override;
|
||||
std::optional<IPetNames::Info> GetPetNameInfo(const LWOOBJID& petId) override;
|
||||
std::optional<IProperty::Info> GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) override;
|
||||
@@ -85,14 +85,14 @@ public:
|
||||
std::stringstream& sd0Data,
|
||||
const uint32_t blueprintId,
|
||||
const uint32_t accountId,
|
||||
const uint32_t characterId) override;
|
||||
std::vector<MailInfo> GetMailForPlayer(const uint32_t characterId, const uint32_t numberOfMail) override;
|
||||
const LWOOBJID characterId) override;
|
||||
std::vector<MailInfo> GetMailForPlayer(const LWOOBJID characterId, const uint32_t numberOfMail) override;
|
||||
std::optional<MailInfo> GetMail(const uint64_t mailId) override;
|
||||
uint32_t GetUnreadMailCount(const uint32_t characterId) override;
|
||||
uint32_t GetUnreadMailCount(const LWOOBJID characterId) override;
|
||||
void MarkMailRead(const uint64_t mailId) override;
|
||||
void DeleteMail(const uint64_t mailId) override;
|
||||
void ClaimMailItem(const uint64_t mailId) override;
|
||||
void InsertSlashCommandUsage(const uint32_t characterId, const std::string_view command) override;
|
||||
void InsertSlashCommandUsage(const LWOOBJID characterId, const std::string_view command) override;
|
||||
void UpdateAccountUnmuteTime(const uint32_t accountId, const uint64_t timeToUnmute) override;
|
||||
void UpdateAccountBan(const uint32_t accountId, const bool banned) override;
|
||||
void UpdateAccountPassword(const uint32_t accountId, const std::string_view bcryptpassword) override;
|
||||
@@ -104,9 +104,9 @@ public:
|
||||
std::optional<uint32_t> GetDonationTotal(const uint32_t activityId) override;
|
||||
std::optional<bool> IsPlaykeyActive(const int32_t playkeyId) override;
|
||||
std::vector<IUgc::Model> GetUgcModels(const LWOOBJID& propertyId) override;
|
||||
void AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) override;
|
||||
void RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) override;
|
||||
std::vector<IIgnoreList::Info> GetIgnoreList(const uint32_t playerId) override;
|
||||
void AddIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) override;
|
||||
void RemoveIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) override;
|
||||
std::vector<IIgnoreList::Info> GetIgnoreList(const LWOOBJID playerId) override;
|
||||
void InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) override;
|
||||
std::vector<uint32_t> GetRewardCodesByAccountID(const uint32_t account_id) override;
|
||||
void AddBehavior(const IBehaviors::Info& info) override;
|
||||
@@ -118,12 +118,12 @@ public:
|
||||
std::vector<ILeaderboard::Entry> GetAscendingLeaderboard(const uint32_t activityId) override;
|
||||
std::vector<ILeaderboard::Entry> GetNsLeaderboard(const uint32_t activityId) override;
|
||||
std::vector<ILeaderboard::Entry> GetAgsLeaderboard(const uint32_t activityId) override;
|
||||
void SaveScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override;
|
||||
void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override;
|
||||
std::optional<ILeaderboard::Score> GetPlayerScore(const uint32_t playerId, const uint32_t gameId) override;
|
||||
void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) override;
|
||||
void IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) override;
|
||||
void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) override;
|
||||
void SaveScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) override;
|
||||
void UpdateScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) override;
|
||||
std::optional<ILeaderboard::Score> GetPlayerScore(const LWOOBJID playerId, const uint32_t gameId) override;
|
||||
void IncrementNumWins(const LWOOBJID playerId, const uint32_t gameId) override;
|
||||
void IncrementTimesPlayed(const LWOOBJID playerId, const uint32_t gameId) override;
|
||||
void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<LWOOBJID> characterId) override;
|
||||
void DeleteUgcBuild(const LWOOBJID bigId) override;
|
||||
uint32_t GetAccountCount() override;
|
||||
bool IsNameInUse(const std::string_view name) override;
|
||||
@@ -268,4 +268,15 @@ inline void SetParam(UniquePreppedStmtRef stmt, const int index, const std::opti
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(UniquePreppedStmtRef stmt, const int index, const std::optional<LWOOBJID> param) {
|
||||
if (param) {
|
||||
// LOG("%d", param.value());
|
||||
stmt->setInt64(index, param.value());
|
||||
} else {
|
||||
// LOG("Null");
|
||||
stmt->setNull(index, sql::DataType::SQLNULL);
|
||||
}
|
||||
}
|
||||
|
||||
#endif //!__MYSQLDATABASE__H__
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "MySQLDatabase.h"
|
||||
|
||||
void MySQLDatabase::UpdateActivityLog(const uint32_t characterId, const eActivityType activityType, const LWOMAPID mapId) {
|
||||
void MySQLDatabase::UpdateActivityLog(const LWOOBJID characterId, const eActivityType activityType, const LWOMAPID mapId) {
|
||||
ExecuteInsert("INSERT INTO activity_log (character_id, activity, time, map_id) VALUES (?, ?, ?, ?);",
|
||||
characterId, static_cast<uint32_t>(activityType), static_cast<uint32_t>(time(NULL)), mapId);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ std::optional<ICharInfo::Info> CharInfoFromQueryResult(std::unique_ptr<sql::Resu
|
||||
|
||||
ICharInfo::Info toReturn;
|
||||
|
||||
toReturn.id = stmt->getUInt("id");
|
||||
toReturn.id = stmt->getInt64("id");
|
||||
toReturn.name = stmt->getString("name").c_str();
|
||||
toReturn.pendingName = stmt->getString("pending_name").c_str();
|
||||
toReturn.needsRename = stmt->getBoolean("needs_rename");
|
||||
@@ -30,7 +30,7 @@ std::optional<ICharInfo::Info> CharInfoFromQueryResult(std::unique_ptr<sql::Resu
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
std::optional<ICharInfo::Info> MySQLDatabase::GetCharacterInfo(const uint32_t charId) {
|
||||
std::optional<ICharInfo::Info> MySQLDatabase::GetCharacterInfo(const LWOOBJID charId) {
|
||||
return CharInfoFromQueryResult(
|
||||
ExecuteSelect("SELECT name, pending_name, needs_rename, prop_clone_id, permission_map, id, account_id FROM charinfo WHERE id = ? LIMIT 1;", charId)
|
||||
);
|
||||
@@ -42,13 +42,13 @@ std::optional<ICharInfo::Info> MySQLDatabase::GetCharacterInfo(const std::string
|
||||
);
|
||||
}
|
||||
|
||||
std::vector<uint32_t> MySQLDatabase::GetAccountCharacterIds(const uint32_t accountId) {
|
||||
std::vector<LWOOBJID> MySQLDatabase::GetAccountCharacterIds(const LWOOBJID accountId) {
|
||||
auto result = ExecuteSelect("SELECT id FROM charinfo WHERE account_id = ? ORDER BY last_login DESC LIMIT 4;", accountId);
|
||||
|
||||
std::vector<uint32_t> toReturn;
|
||||
std::vector<LWOOBJID> toReturn;
|
||||
toReturn.reserve(result->rowsCount());
|
||||
while (result->next()) {
|
||||
toReturn.push_back(result->getUInt("id"));
|
||||
toReturn.push_back(result->getInt64("id"));
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
@@ -65,15 +65,15 @@ void MySQLDatabase::InsertNewCharacter(const ICharInfo::Info info) {
|
||||
static_cast<uint32_t>(time(NULL)));
|
||||
}
|
||||
|
||||
void MySQLDatabase::SetCharacterName(const uint32_t characterId, const std::string_view name) {
|
||||
void MySQLDatabase::SetCharacterName(const LWOOBJID characterId, const std::string_view name) {
|
||||
ExecuteUpdate("UPDATE charinfo SET name = ?, pending_name = '', needs_rename = 0, last_login = ? WHERE id = ? LIMIT 1;", name, static_cast<uint32_t>(time(NULL)), characterId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::SetPendingCharacterName(const uint32_t characterId, const std::string_view name) {
|
||||
void MySQLDatabase::SetPendingCharacterName(const LWOOBJID characterId, const std::string_view name) {
|
||||
ExecuteUpdate("UPDATE charinfo SET pending_name = ?, needs_rename = 0, last_login = ? WHERE id = ? LIMIT 1", name, static_cast<uint32_t>(time(NULL)), characterId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::UpdateLastLoggedInCharacter(const uint32_t characterId) {
|
||||
void MySQLDatabase::UpdateLastLoggedInCharacter(const LWOOBJID characterId) {
|
||||
ExecuteUpdate("UPDATE charinfo SET last_login = ? WHERE id = ? LIMIT 1", static_cast<uint32_t>(time(NULL)), characterId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "MySQLDatabase.h"
|
||||
|
||||
std::string MySQLDatabase::GetCharacterXml(const uint32_t charId) {
|
||||
std::string MySQLDatabase::GetCharacterXml(const LWOOBJID charId) {
|
||||
auto result = ExecuteSelect("SELECT xml_data FROM charxml WHERE id = ? LIMIT 1;", charId);
|
||||
|
||||
if (!result->next()) {
|
||||
@@ -10,10 +10,10 @@ std::string MySQLDatabase::GetCharacterXml(const uint32_t charId) {
|
||||
return result->getString("xml_data").c_str();
|
||||
}
|
||||
|
||||
void MySQLDatabase::UpdateCharacterXml(const uint32_t charId, const std::string_view lxfml) {
|
||||
void MySQLDatabase::UpdateCharacterXml(const LWOOBJID charId, const std::string_view lxfml) {
|
||||
ExecuteUpdate("UPDATE charxml SET xml_data = ? WHERE id = ?;", lxfml, charId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::InsertCharacterXml(const uint32_t characterId, const std::string_view lxfml) {
|
||||
void MySQLDatabase::InsertCharacterXml(const LWOOBJID characterId, const std::string_view lxfml) {
|
||||
ExecuteInsert("INSERT INTO `charxml` (`id`, `xml_data`) VALUES (?,?)", characterId, lxfml);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "MySQLDatabase.h"
|
||||
|
||||
void MySQLDatabase::InsertSlashCommandUsage(const uint32_t characterId, const std::string_view command) {
|
||||
void MySQLDatabase::InsertSlashCommandUsage(const LWOOBJID characterId, const std::string_view command) {
|
||||
ExecuteInsert("INSERT INTO command_log (character_id, command) VALUES (?, ?);", characterId, command);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "MySQLDatabase.h"
|
||||
|
||||
std::vector<FriendData> MySQLDatabase::GetFriendsList(const uint32_t charId) {
|
||||
std::vector<FriendData> MySQLDatabase::GetFriendsList(const LWOOBJID charId) {
|
||||
auto friendsList = ExecuteSelect(
|
||||
R"QUERY(
|
||||
SELECT fr.requested_player AS player, best_friend AS bff, ci.name AS name FROM
|
||||
@@ -19,7 +19,7 @@ std::vector<FriendData> MySQLDatabase::GetFriendsList(const uint32_t charId) {
|
||||
|
||||
while (friendsList->next()) {
|
||||
FriendData fd;
|
||||
fd.friendID = friendsList->getUInt("player");
|
||||
fd.friendID = friendsList->getUInt64("player");
|
||||
fd.isBestFriend = friendsList->getInt("bff") == 3; // 0 = friends, 1 = left_requested, 2 = right_requested, 3 = both_accepted - are now bffs
|
||||
fd.friendName = friendsList->getString("name").c_str();
|
||||
|
||||
@@ -29,7 +29,7 @@ std::vector<FriendData> MySQLDatabase::GetFriendsList(const uint32_t charId) {
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
std::optional<IFriends::BestFriendStatus> MySQLDatabase::GetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId) {
|
||||
std::optional<IFriends::BestFriendStatus> MySQLDatabase::GetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) {
|
||||
auto result = ExecuteSelect("SELECT * FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?) LIMIT 1;",
|
||||
playerCharacterId,
|
||||
friendCharacterId,
|
||||
@@ -42,14 +42,14 @@ std::optional<IFriends::BestFriendStatus> MySQLDatabase::GetBestFriendStatus(con
|
||||
}
|
||||
|
||||
IFriends::BestFriendStatus toReturn;
|
||||
toReturn.playerCharacterId = result->getUInt("player_id");
|
||||
toReturn.friendCharacterId = result->getUInt("friend_id");
|
||||
toReturn.playerCharacterId = result->getUInt64("player_id");
|
||||
toReturn.friendCharacterId = result->getUInt64("friend_id");
|
||||
toReturn.bestFriendStatus = result->getUInt("best_friend");
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
void MySQLDatabase::SetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId, const uint32_t bestFriendStatus) {
|
||||
void MySQLDatabase::SetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId, const uint32_t bestFriendStatus) {
|
||||
ExecuteUpdate("UPDATE friends SET best_friend = ? WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?) LIMIT 1;",
|
||||
bestFriendStatus,
|
||||
playerCharacterId,
|
||||
@@ -59,11 +59,11 @@ void MySQLDatabase::SetBestFriendStatus(const uint32_t playerCharacterId, const
|
||||
);
|
||||
}
|
||||
|
||||
void MySQLDatabase::AddFriend(const uint32_t playerCharacterId, const uint32_t friendCharacterId) {
|
||||
void MySQLDatabase::AddFriend(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) {
|
||||
ExecuteInsert("INSERT IGNORE INTO friends (player_id, friend_id, best_friend) VALUES (?, ?, 0);", playerCharacterId, friendCharacterId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::RemoveFriend(const uint32_t playerCharacterId, const uint32_t friendCharacterId) {
|
||||
void MySQLDatabase::RemoveFriend(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) {
|
||||
ExecuteDelete("DELETE FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?) LIMIT 1;",
|
||||
playerCharacterId,
|
||||
friendCharacterId,
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#include "MySQLDatabase.h"
|
||||
|
||||
std::vector<IIgnoreList::Info> MySQLDatabase::GetIgnoreList(const uint32_t playerId) {
|
||||
std::vector<IIgnoreList::Info> MySQLDatabase::GetIgnoreList(const LWOOBJID playerId) {
|
||||
auto result = ExecuteSelect("SELECT ci.name AS name, il.ignored_player_id AS ignore_id FROM ignore_list AS il JOIN charinfo AS ci ON il.ignored_player_id = ci.id WHERE il.player_id = ?", playerId);
|
||||
|
||||
std::vector<IIgnoreList::Info> ignoreList;
|
||||
|
||||
ignoreList.reserve(result->rowsCount());
|
||||
while (result->next()) {
|
||||
ignoreList.push_back(IIgnoreList::Info{ result->getString("name").c_str(), result->getUInt("ignore_id") });
|
||||
ignoreList.push_back(IIgnoreList::Info{ result->getString("name").c_str(), result->getInt64("ignore_id") });
|
||||
}
|
||||
|
||||
return ignoreList;
|
||||
}
|
||||
|
||||
void MySQLDatabase::AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||
void MySQLDatabase::AddIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) {
|
||||
ExecuteInsert("INSERT IGNORE INTO ignore_list (player_id, ignored_player_id) VALUES (?, ?)", playerId, ignoredPlayerId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||
void MySQLDatabase::RemoveIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) {
|
||||
ExecuteDelete("DELETE FROM ignore_list WHERE player_id = ? AND ignored_player_id = ?", playerId, ignoredPlayerId);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ std::vector<ILeaderboard::Entry> ProcessQuery(UniqueResultSet& rows) {
|
||||
while (rows->next()) {
|
||||
auto& entry = entries.emplace_back();
|
||||
|
||||
entry.charId = rows->getUInt("character_id");
|
||||
entry.charId = rows->getUInt64("character_id");
|
||||
entry.lastPlayedTimestamp = rows->getUInt("lp_unix");
|
||||
entry.primaryScore = rows->getFloat("primaryScore");
|
||||
entry.secondaryScore = rows->getFloat("secondaryScore");
|
||||
@@ -58,21 +58,21 @@ std::vector<ILeaderboard::Entry> MySQLDatabase::GetNsLeaderboard(const uint32_t
|
||||
return ProcessQuery(leaderboard);
|
||||
}
|
||||
|
||||
void MySQLDatabase::SaveScore(const uint32_t playerId, const uint32_t gameId, const Score& score) {
|
||||
void MySQLDatabase::SaveScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) {
|
||||
ExecuteInsert("INSERT leaderboard SET primaryScore = ?, secondaryScore = ?, tertiaryScore = ?, character_id = ?, game_id = ?;",
|
||||
score.primaryScore, score.secondaryScore, score.tertiaryScore, playerId, gameId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) {
|
||||
void MySQLDatabase::UpdateScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) {
|
||||
ExecuteInsert("UPDATE leaderboard SET primaryScore = ?, secondaryScore = ?, tertiaryScore = ?, timesPlayed = timesPlayed + 1 WHERE character_id = ? AND game_id = ?;",
|
||||
score.primaryScore, score.secondaryScore, score.tertiaryScore, playerId, gameId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) {
|
||||
void MySQLDatabase::IncrementTimesPlayed(const LWOOBJID playerId, const uint32_t gameId) {
|
||||
ExecuteUpdate("UPDATE leaderboard SET timesPlayed = timesPlayed + 1 WHERE character_id = ? AND game_id = ?;", playerId, gameId);
|
||||
}
|
||||
|
||||
std::optional<ILeaderboard::Score> MySQLDatabase::GetPlayerScore(const uint32_t playerId, const uint32_t gameId) {
|
||||
std::optional<ILeaderboard::Score> MySQLDatabase::GetPlayerScore(const LWOOBJID playerId, const uint32_t gameId) {
|
||||
std::optional<ILeaderboard::Score> toReturn = std::nullopt;
|
||||
auto res = ExecuteSelect("SELECT * FROM leaderboard WHERE character_id = ? AND game_id = ?;", playerId, gameId);
|
||||
if (res->next()) {
|
||||
@@ -86,6 +86,6 @@ std::optional<ILeaderboard::Score> MySQLDatabase::GetPlayerScore(const uint32_t
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
void MySQLDatabase::IncrementNumWins(const uint32_t playerId, const uint32_t gameId) {
|
||||
void MySQLDatabase::IncrementNumWins(const LWOOBJID playerId, const uint32_t gameId) {
|
||||
ExecuteUpdate("UPDATE leaderboard SET numWins = numWins + 1 WHERE character_id = ? AND game_id = ?;", playerId, gameId);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ void MySQLDatabase::InsertNewMail(const MailInfo& mail) {
|
||||
mail.itemCount);
|
||||
}
|
||||
|
||||
std::vector<MailInfo> MySQLDatabase::GetMailForPlayer(const uint32_t characterId, const uint32_t numberOfMail) {
|
||||
std::vector<MailInfo> MySQLDatabase::GetMailForPlayer(const LWOOBJID characterId, const uint32_t numberOfMail) {
|
||||
auto res = ExecuteSelect(
|
||||
"SELECT id, subject, body, sender_name, attachment_id, attachment_lot, attachment_subkey, attachment_count, was_read, time_sent"
|
||||
" FROM mail WHERE receiver_id=? limit ?;",
|
||||
@@ -61,7 +61,7 @@ std::optional<MailInfo> MySQLDatabase::GetMail(const uint64_t mailId) {
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
uint32_t MySQLDatabase::GetUnreadMailCount(const uint32_t characterId) {
|
||||
uint32_t MySQLDatabase::GetUnreadMailCount(const LWOOBJID characterId) {
|
||||
auto res = ExecuteSelect("SELECT COUNT(*) AS number_unread FROM mail WHERE receiver_id=? AND was_read=0;", characterId);
|
||||
|
||||
if (!res->next()) {
|
||||
|
||||
@@ -119,7 +119,7 @@ std::optional<IProperty::PropertyEntranceResult> MySQLDatabase::GetProperties(co
|
||||
if (!result) result = IProperty::PropertyEntranceResult();
|
||||
auto& entry = result->entries.emplace_back();
|
||||
entry.id = properties->getUInt64("id");
|
||||
entry.ownerId = properties->getUInt64("owner_id");
|
||||
entry.ownerId = properties->getInt64("owner_id");
|
||||
entry.cloneId = properties->getUInt64("clone_id");
|
||||
entry.name = properties->getString("name").c_str();
|
||||
entry.description = properties->getString("description").c_str();
|
||||
@@ -146,7 +146,7 @@ std::optional<IProperty::Info> MySQLDatabase::GetPropertyInfo(const LWOMAPID map
|
||||
|
||||
IProperty::Info toReturn;
|
||||
toReturn.id = propertyEntry->getUInt64("id");
|
||||
toReturn.ownerId = propertyEntry->getUInt64("owner_id");
|
||||
toReturn.ownerId = propertyEntry->getInt64("owner_id");
|
||||
toReturn.cloneId = propertyEntry->getUInt64("clone_id");
|
||||
toReturn.name = propertyEntry->getString("name").c_str();
|
||||
toReturn.description = propertyEntry->getString("description").c_str();
|
||||
|
||||
@@ -48,7 +48,7 @@ void MySQLDatabase::InsertNewUgcModel(
|
||||
std:: stringstream& sd0Data, // cant be const sad
|
||||
const uint32_t blueprintId,
|
||||
const uint32_t accountId,
|
||||
const uint32_t characterId) {
|
||||
const LWOOBJID characterId) {
|
||||
const std::istream stream(sd0Data.rdbuf());
|
||||
ExecuteInsert(
|
||||
"INSERT INTO `ugc`(`id`, `account_id`, `character_id`, `is_optimized`, `lxfml`, `bake_ao`, `filename`) VALUES (?,?,?,?,?,?,?)",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "MySQLDatabase.h"
|
||||
|
||||
void MySQLDatabase::InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) {
|
||||
void MySQLDatabase::InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<LWOOBJID> characterId) {
|
||||
ExecuteInsert("INSERT INTO ugc_modular_build (ugc_id, ldf_config, character_id) VALUES (?,?,?)", bigId, modules, characterId);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ void SQLiteDatabase::SetAutoCommit(bool value) {
|
||||
}
|
||||
}
|
||||
|
||||
void SQLiteDatabase::DeleteCharacter(const uint32_t characterId) {
|
||||
void SQLiteDatabase::DeleteCharacter(const LWOOBJID characterId) {
|
||||
ExecuteDelete("DELETE FROM charxml WHERE id=?;", characterId);
|
||||
ExecuteDelete("DELETE FROM command_log WHERE character_id=?;", characterId);
|
||||
ExecuteDelete("DELETE FROM friends WHERE player_id=? OR friend_id=?;", characterId, characterId);
|
||||
|
||||
@@ -38,31 +38,31 @@ public:
|
||||
|
||||
std::vector<std::string> GetApprovedCharacterNames() override;
|
||||
|
||||
std::vector<FriendData> GetFriendsList(uint32_t charID) override;
|
||||
std::vector<FriendData> GetFriendsList(LWOOBJID charID) override;
|
||||
|
||||
std::optional<IFriends::BestFriendStatus> GetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId) override;
|
||||
void SetBestFriendStatus(const uint32_t playerAccountId, const uint32_t friendAccountId, const uint32_t bestFriendStatus) override;
|
||||
void AddFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) override;
|
||||
void RemoveFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) override;
|
||||
void UpdateActivityLog(const uint32_t characterId, const eActivityType activityType, const LWOMAPID mapId) override;
|
||||
std::optional<IFriends::BestFriendStatus> GetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) override;
|
||||
void SetBestFriendStatus(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId, const uint32_t bestFriendStatus) override;
|
||||
void AddFriend(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId) override;
|
||||
void RemoveFriend(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId) override;
|
||||
void UpdateActivityLog(const LWOOBJID characterId, const eActivityType activityType, const LWOMAPID mapId) override;
|
||||
void DeleteUgcModelData(const LWOOBJID& modelId) override;
|
||||
void UpdateUgcModelData(const LWOOBJID& modelId, std::stringstream& lxfml) override;
|
||||
std::vector<IUgc::Model> GetAllUgcModels() override;
|
||||
void CreateMigrationHistoryTable() override;
|
||||
bool IsMigrationRun(const std::string_view str) override;
|
||||
void InsertMigration(const std::string_view str) override;
|
||||
std::optional<ICharInfo::Info> GetCharacterInfo(const uint32_t charId) override;
|
||||
std::optional<ICharInfo::Info> GetCharacterInfo(const LWOOBJID charId) override;
|
||||
std::optional<ICharInfo::Info> GetCharacterInfo(const std::string_view charId) override;
|
||||
std::string GetCharacterXml(const uint32_t accountId) override;
|
||||
void UpdateCharacterXml(const uint32_t characterId, const std::string_view lxfml) override;
|
||||
std::string GetCharacterXml(const LWOOBJID accountId) override;
|
||||
void UpdateCharacterXml(const LWOOBJID characterId, const std::string_view lxfml) override;
|
||||
std::optional<IAccounts::Info> GetAccountInfo(const std::string_view username) override;
|
||||
void InsertNewCharacter(const ICharInfo::Info info) override;
|
||||
void InsertCharacterXml(const uint32_t accountId, const std::string_view lxfml) override;
|
||||
std::vector<uint32_t> GetAccountCharacterIds(uint32_t accountId) override;
|
||||
void DeleteCharacter(const uint32_t characterId) override;
|
||||
void SetCharacterName(const uint32_t characterId, const std::string_view name) override;
|
||||
void SetPendingCharacterName(const uint32_t characterId, const std::string_view name) override;
|
||||
void UpdateLastLoggedInCharacter(const uint32_t characterId) override;
|
||||
void InsertCharacterXml(const LWOOBJID accountId, const std::string_view lxfml) override;
|
||||
std::vector<LWOOBJID> GetAccountCharacterIds(LWOOBJID accountId) override;
|
||||
void DeleteCharacter(const LWOOBJID characterId) override;
|
||||
void SetCharacterName(const LWOOBJID characterId, const std::string_view name) override;
|
||||
void SetPendingCharacterName(const LWOOBJID characterId, const std::string_view name) override;
|
||||
void UpdateLastLoggedInCharacter(const LWOOBJID characterId) override;
|
||||
void SetPetNameModerationStatus(const LWOOBJID& petId, const IPetNames::Info& info) override;
|
||||
std::optional<IPetNames::Info> GetPetNameInfo(const LWOOBJID& petId) override;
|
||||
std::optional<IProperty::Info> GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) override;
|
||||
@@ -83,14 +83,14 @@ public:
|
||||
std::stringstream& sd0Data,
|
||||
const uint32_t blueprintId,
|
||||
const uint32_t accountId,
|
||||
const uint32_t characterId) override;
|
||||
std::vector<MailInfo> GetMailForPlayer(const uint32_t characterId, const uint32_t numberOfMail) override;
|
||||
const LWOOBJID characterId) override;
|
||||
std::vector<MailInfo> GetMailForPlayer(const LWOOBJID characterId, const uint32_t numberOfMail) override;
|
||||
std::optional<MailInfo> GetMail(const uint64_t mailId) override;
|
||||
uint32_t GetUnreadMailCount(const uint32_t characterId) override;
|
||||
uint32_t GetUnreadMailCount(const LWOOBJID characterId) override;
|
||||
void MarkMailRead(const uint64_t mailId) override;
|
||||
void DeleteMail(const uint64_t mailId) override;
|
||||
void ClaimMailItem(const uint64_t mailId) override;
|
||||
void InsertSlashCommandUsage(const uint32_t characterId, const std::string_view command) override;
|
||||
void InsertSlashCommandUsage(const LWOOBJID characterId, const std::string_view command) override;
|
||||
void UpdateAccountUnmuteTime(const uint32_t accountId, const uint64_t timeToUnmute) override;
|
||||
void UpdateAccountBan(const uint32_t accountId, const bool banned) override;
|
||||
void UpdateAccountPassword(const uint32_t accountId, const std::string_view bcryptpassword) override;
|
||||
@@ -102,9 +102,9 @@ public:
|
||||
std::optional<uint32_t> GetDonationTotal(const uint32_t activityId) override;
|
||||
std::optional<bool> IsPlaykeyActive(const int32_t playkeyId) override;
|
||||
std::vector<IUgc::Model> GetUgcModels(const LWOOBJID& propertyId) override;
|
||||
void AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) override;
|
||||
void RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) override;
|
||||
std::vector<IIgnoreList::Info> GetIgnoreList(const uint32_t playerId) override;
|
||||
void AddIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) override;
|
||||
void RemoveIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) override;
|
||||
std::vector<IIgnoreList::Info> GetIgnoreList(const LWOOBJID playerId) override;
|
||||
void InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) override;
|
||||
std::vector<uint32_t> GetRewardCodesByAccountID(const uint32_t account_id) override;
|
||||
void AddBehavior(const IBehaviors::Info& info) override;
|
||||
@@ -116,12 +116,12 @@ public:
|
||||
std::vector<ILeaderboard::Entry> GetAscendingLeaderboard(const uint32_t activityId) override;
|
||||
std::vector<ILeaderboard::Entry> GetNsLeaderboard(const uint32_t activityId) override;
|
||||
std::vector<ILeaderboard::Entry> GetAgsLeaderboard(const uint32_t activityId) override;
|
||||
void SaveScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override;
|
||||
void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override;
|
||||
std::optional<ILeaderboard::Score> GetPlayerScore(const uint32_t playerId, const uint32_t gameId) override;
|
||||
void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) override;
|
||||
void IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) override;
|
||||
void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) override;
|
||||
void SaveScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) override;
|
||||
void UpdateScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) override;
|
||||
std::optional<ILeaderboard::Score> GetPlayerScore(const LWOOBJID playerId, const uint32_t gameId) override;
|
||||
void IncrementNumWins(const LWOOBJID playerId, const uint32_t gameId) override;
|
||||
void IncrementTimesPlayed(const LWOOBJID playerId, const uint32_t gameId) override;
|
||||
void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<LWOOBJID> characterId) override;
|
||||
void DeleteUgcBuild(const LWOOBJID bigId) override;
|
||||
uint32_t GetAccountCount() override;
|
||||
bool IsNameInUse(const std::string_view name) override;
|
||||
@@ -270,4 +270,15 @@ inline void SetParam(PreppedStmtRef stmt, const int index, const std::optional<u
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SetParam(PreppedStmtRef stmt, const int index, const std::optional<LWOOBJID> param) {
|
||||
if (param) {
|
||||
LOG("%d", param.value());
|
||||
stmt.bind(index, static_cast<sqlite_int64>(param.value()));
|
||||
} else {
|
||||
LOG("Null");
|
||||
stmt.bindNull(index);
|
||||
}
|
||||
}
|
||||
|
||||
#endif //!SQLITEDATABASE_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "SQLiteDatabase.h"
|
||||
|
||||
void SQLiteDatabase::UpdateActivityLog(const uint32_t characterId, const eActivityType activityType, const LWOMAPID mapId) {
|
||||
void SQLiteDatabase::UpdateActivityLog(const LWOOBJID characterId, const eActivityType activityType, const LWOMAPID mapId) {
|
||||
ExecuteInsert("INSERT INTO activity_log (character_id, activity, time, map_id) VALUES (?, ?, ?, ?);",
|
||||
characterId, static_cast<uint32_t>(activityType), static_cast<uint32_t>(time(NULL)), mapId);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ std::optional<ICharInfo::Info> CharInfoFromQueryResult(CppSQLite3Query stmt) {
|
||||
|
||||
ICharInfo::Info toReturn;
|
||||
|
||||
toReturn.id = stmt.getIntField("id");
|
||||
toReturn.id = stmt.getInt64Field("id");
|
||||
toReturn.name = stmt.getStringField("name");
|
||||
toReturn.pendingName = stmt.getStringField("pending_name");
|
||||
toReturn.needsRename = stmt.getIntField("needs_rename");
|
||||
@@ -31,7 +31,7 @@ std::optional<ICharInfo::Info> CharInfoFromQueryResult(CppSQLite3Query stmt) {
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
std::optional<ICharInfo::Info> SQLiteDatabase::GetCharacterInfo(const uint32_t charId) {
|
||||
std::optional<ICharInfo::Info> SQLiteDatabase::GetCharacterInfo(const LWOOBJID charId) {
|
||||
return CharInfoFromQueryResult(
|
||||
ExecuteSelect("SELECT name, pending_name, needs_rename, prop_clone_id, permission_map, id, account_id FROM charinfo WHERE id = ? LIMIT 1;", charId).second
|
||||
);
|
||||
@@ -43,12 +43,12 @@ std::optional<ICharInfo::Info> SQLiteDatabase::GetCharacterInfo(const std::strin
|
||||
);
|
||||
}
|
||||
|
||||
std::vector<uint32_t> SQLiteDatabase::GetAccountCharacterIds(const uint32_t accountId) {
|
||||
std::vector<LWOOBJID> SQLiteDatabase::GetAccountCharacterIds(const LWOOBJID accountId) {
|
||||
auto [_, result] = ExecuteSelect("SELECT id FROM charinfo WHERE account_id = ? ORDER BY last_login DESC LIMIT 4;", accountId);
|
||||
|
||||
std::vector<uint32_t> toReturn;
|
||||
std::vector<LWOOBJID> toReturn;
|
||||
while (!result.eof()) {
|
||||
toReturn.push_back(result.getIntField("id"));
|
||||
toReturn.push_back(result.getInt64Field("id"));
|
||||
result.nextRow();
|
||||
}
|
||||
|
||||
@@ -66,15 +66,15 @@ void SQLiteDatabase::InsertNewCharacter(const ICharInfo::Info info) {
|
||||
static_cast<uint32_t>(time(NULL)));
|
||||
}
|
||||
|
||||
void SQLiteDatabase::SetCharacterName(const uint32_t characterId, const std::string_view name) {
|
||||
void SQLiteDatabase::SetCharacterName(const LWOOBJID characterId, const std::string_view name) {
|
||||
ExecuteUpdate("UPDATE charinfo SET name = ?, pending_name = '', needs_rename = 0, last_login = ? WHERE id = ?;", name, static_cast<uint32_t>(time(NULL)), characterId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::SetPendingCharacterName(const uint32_t characterId, const std::string_view name) {
|
||||
void SQLiteDatabase::SetPendingCharacterName(const LWOOBJID characterId, const std::string_view name) {
|
||||
ExecuteUpdate("UPDATE charinfo SET pending_name = ?, needs_rename = 0, last_login = ? WHERE id = ?;", name, static_cast<uint32_t>(time(NULL)), characterId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::UpdateLastLoggedInCharacter(const uint32_t characterId) {
|
||||
void SQLiteDatabase::UpdateLastLoggedInCharacter(const LWOOBJID characterId) {
|
||||
ExecuteUpdate("UPDATE charinfo SET last_login = ? WHERE id = ?;", static_cast<uint32_t>(time(NULL)), characterId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "SQLiteDatabase.h"
|
||||
|
||||
std::string SQLiteDatabase::GetCharacterXml(const uint32_t charId) {
|
||||
std::string SQLiteDatabase::GetCharacterXml(const LWOOBJID charId) {
|
||||
auto [_, result] = ExecuteSelect("SELECT xml_data FROM charxml WHERE id = ? LIMIT 1;", charId);
|
||||
|
||||
if (result.eof()) {
|
||||
@@ -10,10 +10,10 @@ std::string SQLiteDatabase::GetCharacterXml(const uint32_t charId) {
|
||||
return result.getStringField("xml_data");
|
||||
}
|
||||
|
||||
void SQLiteDatabase::UpdateCharacterXml(const uint32_t charId, const std::string_view lxfml) {
|
||||
void SQLiteDatabase::UpdateCharacterXml(const LWOOBJID charId, const std::string_view lxfml) {
|
||||
ExecuteUpdate("UPDATE charxml SET xml_data = ? WHERE id = ?;", lxfml, charId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::InsertCharacterXml(const uint32_t characterId, const std::string_view lxfml) {
|
||||
void SQLiteDatabase::InsertCharacterXml(const LWOOBJID characterId, const std::string_view lxfml) {
|
||||
ExecuteInsert("INSERT INTO `charxml` (`id`, `xml_data`) VALUES (?,?)", characterId, lxfml);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "SQLiteDatabase.h"
|
||||
|
||||
void SQLiteDatabase::InsertSlashCommandUsage(const uint32_t characterId, const std::string_view command) {
|
||||
void SQLiteDatabase::InsertSlashCommandUsage(const LWOOBJID characterId, const std::string_view command) {
|
||||
ExecuteInsert("INSERT INTO command_log (character_id, command) VALUES (?, ?);", characterId, command);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "SQLiteDatabase.h"
|
||||
|
||||
std::vector<FriendData> SQLiteDatabase::GetFriendsList(const uint32_t charId) {
|
||||
std::vector<FriendData> SQLiteDatabase::GetFriendsList(const LWOOBJID charId) {
|
||||
auto [_, friendsList] = ExecuteSelect(
|
||||
R"QUERY(
|
||||
SELECT fr.requested_player AS player, best_friend AS bff, ci.name AS name FROM
|
||||
@@ -18,7 +18,7 @@ std::vector<FriendData> SQLiteDatabase::GetFriendsList(const uint32_t charId) {
|
||||
|
||||
while (!friendsList.eof()) {
|
||||
FriendData fd;
|
||||
fd.friendID = friendsList.getIntField("player");
|
||||
fd.friendID = friendsList.getInt64Field("player");
|
||||
fd.isBestFriend = friendsList.getIntField("bff") == 3; // 0 = friends, 1 = left_requested, 2 = right_requested, 3 = both_accepted - are now bffs
|
||||
fd.friendName = friendsList.getStringField("name");
|
||||
|
||||
@@ -29,7 +29,7 @@ std::vector<FriendData> SQLiteDatabase::GetFriendsList(const uint32_t charId) {
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
std::optional<IFriends::BestFriendStatus> SQLiteDatabase::GetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId) {
|
||||
std::optional<IFriends::BestFriendStatus> SQLiteDatabase::GetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) {
|
||||
auto [_, result] = ExecuteSelect("SELECT * FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?) LIMIT 1;",
|
||||
playerCharacterId,
|
||||
friendCharacterId,
|
||||
@@ -42,14 +42,14 @@ std::optional<IFriends::BestFriendStatus> SQLiteDatabase::GetBestFriendStatus(co
|
||||
}
|
||||
|
||||
IFriends::BestFriendStatus toReturn;
|
||||
toReturn.playerCharacterId = result.getIntField("player_id");
|
||||
toReturn.friendCharacterId = result.getIntField("friend_id");
|
||||
toReturn.playerCharacterId = result.getInt64Field("player_id");
|
||||
toReturn.friendCharacterId = result.getInt64Field("friend_id");
|
||||
toReturn.bestFriendStatus = result.getIntField("best_friend");
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
void SQLiteDatabase::SetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId, const uint32_t bestFriendStatus) {
|
||||
void SQLiteDatabase::SetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId, const uint32_t bestFriendStatus) {
|
||||
ExecuteUpdate("UPDATE friends SET best_friend = ? WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?);",
|
||||
bestFriendStatus,
|
||||
playerCharacterId,
|
||||
@@ -59,11 +59,11 @@ void SQLiteDatabase::SetBestFriendStatus(const uint32_t playerCharacterId, const
|
||||
);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::AddFriend(const uint32_t playerCharacterId, const uint32_t friendCharacterId) {
|
||||
void SQLiteDatabase::AddFriend(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) {
|
||||
ExecuteInsert("INSERT OR IGNORE INTO friends (player_id, friend_id, best_friend) VALUES (?, ?, 0);", playerCharacterId, friendCharacterId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::RemoveFriend(const uint32_t playerCharacterId, const uint32_t friendCharacterId) {
|
||||
void SQLiteDatabase::RemoveFriend(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) {
|
||||
ExecuteDelete("DELETE FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?);",
|
||||
playerCharacterId,
|
||||
friendCharacterId,
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#include "SQLiteDatabase.h"
|
||||
|
||||
std::vector<IIgnoreList::Info> SQLiteDatabase::GetIgnoreList(const uint32_t playerId) {
|
||||
std::vector<IIgnoreList::Info> SQLiteDatabase::GetIgnoreList(const LWOOBJID playerId) {
|
||||
auto [_, result] = ExecuteSelect("SELECT ci.name AS name, il.ignored_player_id AS ignore_id FROM ignore_list AS il JOIN charinfo AS ci ON il.ignored_player_id = ci.id WHERE il.player_id = ?", playerId);
|
||||
|
||||
std::vector<IIgnoreList::Info> ignoreList;
|
||||
|
||||
while (!result.eof()) {
|
||||
ignoreList.push_back(IIgnoreList::Info{ result.getStringField("name"), static_cast<uint32_t>(result.getIntField("ignore_id")) });
|
||||
ignoreList.push_back(IIgnoreList::Info{ result.getStringField("name"), result.getInt64Field("ignore_id") });
|
||||
result.nextRow();
|
||||
}
|
||||
|
||||
return ignoreList;
|
||||
}
|
||||
|
||||
void SQLiteDatabase::AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||
void SQLiteDatabase::AddIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) {
|
||||
ExecuteInsert("INSERT OR IGNORE INTO ignore_list (player_id, ignored_player_id) VALUES (?, ?)", playerId, ignoredPlayerId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||
void SQLiteDatabase::RemoveIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) {
|
||||
ExecuteDelete("DELETE FROM ignore_list WHERE player_id = ? AND ignored_player_id = ?", playerId, ignoredPlayerId);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ std::vector<ILeaderboard::Entry> ProcessQuery(CppSQLite3Query& rows) {
|
||||
while (!rows.eof()) {
|
||||
auto& entry = entries.emplace_back();
|
||||
|
||||
entry.charId = rows.getIntField("character_id");
|
||||
entry.charId = rows.getInt64Field("character_id");
|
||||
entry.lastPlayedTimestamp = rows.getIntField("lp_unix");
|
||||
entry.primaryScore = rows.getFloatField("primaryScore");
|
||||
entry.secondaryScore = rows.getFloatField("secondaryScore");
|
||||
@@ -58,17 +58,17 @@ std::vector<ILeaderboard::Entry> SQLiteDatabase::GetNsLeaderboard(const uint32_t
|
||||
return ProcessQuery(result);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::SaveScore(const uint32_t playerId, const uint32_t gameId, const Score& score) {
|
||||
void SQLiteDatabase::SaveScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) {
|
||||
ExecuteInsert("INSERT INTO leaderboard (primaryScore, secondaryScore, tertiaryScore, character_id, game_id, last_played) VALUES (?,?,?,?,?,CURRENT_TIMESTAMP) ;",
|
||||
score.primaryScore, score.secondaryScore, score.tertiaryScore, playerId, gameId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) {
|
||||
void SQLiteDatabase::UpdateScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) {
|
||||
ExecuteInsert("UPDATE leaderboard SET primaryScore = ?, secondaryScore = ?, tertiaryScore = ?, timesPlayed = timesPlayed + 1, last_played = CURRENT_TIMESTAMP WHERE character_id = ? AND game_id = ?;",
|
||||
score.primaryScore, score.secondaryScore, score.tertiaryScore, playerId, gameId);
|
||||
}
|
||||
|
||||
std::optional<ILeaderboard::Score> SQLiteDatabase::GetPlayerScore(const uint32_t playerId, const uint32_t gameId) {
|
||||
std::optional<ILeaderboard::Score> SQLiteDatabase::GetPlayerScore(const LWOOBJID playerId, const uint32_t gameId) {
|
||||
std::optional<ILeaderboard::Score> toReturn = std::nullopt;
|
||||
auto [_, res] = ExecuteSelect("SELECT * FROM leaderboard WHERE character_id = ? AND game_id = ?;", playerId, gameId);
|
||||
if (!res.eof()) {
|
||||
@@ -82,10 +82,10 @@ std::optional<ILeaderboard::Score> SQLiteDatabase::GetPlayerScore(const uint32_t
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
void SQLiteDatabase::IncrementNumWins(const uint32_t playerId, const uint32_t gameId) {
|
||||
void SQLiteDatabase::IncrementNumWins(const LWOOBJID playerId, const uint32_t gameId) {
|
||||
ExecuteUpdate("UPDATE leaderboard SET numWins = numWins + 1, last_played = CURRENT_TIMESTAMP WHERE character_id = ? AND game_id = ?;", playerId, gameId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) {
|
||||
void SQLiteDatabase::IncrementTimesPlayed(const LWOOBJID playerId, const uint32_t gameId) {
|
||||
ExecuteUpdate("UPDATE leaderboard SET timesPlayed = timesPlayed + 1, last_played = CURRENT_TIMESTAMP WHERE character_id = ? AND game_id = ?;", playerId, gameId);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ void SQLiteDatabase::InsertNewMail(const MailInfo& mail) {
|
||||
mail.itemCount);
|
||||
}
|
||||
|
||||
std::vector<MailInfo> SQLiteDatabase::GetMailForPlayer(const uint32_t characterId, const uint32_t numberOfMail) {
|
||||
std::vector<MailInfo> SQLiteDatabase::GetMailForPlayer(const LWOOBJID characterId, const uint32_t numberOfMail) {
|
||||
auto [_, res] = ExecuteSelect(
|
||||
"SELECT id, subject, body, sender_name, attachment_id, attachment_lot, attachment_subkey, attachment_count, was_read, time_sent"
|
||||
" FROM mail WHERE receiver_id=? limit ?;",
|
||||
@@ -60,7 +60,7 @@ std::optional<MailInfo> SQLiteDatabase::GetMail(const uint64_t mailId) {
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
uint32_t SQLiteDatabase::GetUnreadMailCount(const uint32_t characterId) {
|
||||
uint32_t SQLiteDatabase::GetUnreadMailCount(const LWOOBJID characterId) {
|
||||
auto [_, res] = ExecuteSelect("SELECT COUNT(*) AS number_unread FROM mail WHERE receiver_id=? AND was_read=0;", characterId);
|
||||
|
||||
if (res.eof()) {
|
||||
|
||||
@@ -49,7 +49,7 @@ void SQLiteDatabase::InsertNewUgcModel(
|
||||
std::stringstream& sd0Data, // cant be const sad
|
||||
const uint32_t blueprintId,
|
||||
const uint32_t accountId,
|
||||
const uint32_t characterId) {
|
||||
const LWOOBJID characterId) {
|
||||
const std::istream stream(sd0Data.rdbuf());
|
||||
ExecuteInsert(
|
||||
"INSERT INTO `ugc`(`id`, `account_id`, `character_id`, `is_optimized`, `lxfml`, `bake_ao`, `filename`) VALUES (?,?,?,?,?,?,?)",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "SQLiteDatabase.h"
|
||||
|
||||
void SQLiteDatabase::InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) {
|
||||
void SQLiteDatabase::InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<LWOOBJID> characterId) {
|
||||
ExecuteInsert("INSERT INTO ugc_modular_build (ugc_id, ldf_config, character_id) VALUES (?,?,?)", bigId, modules, characterId);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,27 +32,27 @@ std::vector<std::string> TestSQLDatabase::GetApprovedCharacterNames() {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<FriendData> TestSQLDatabase::GetFriendsList(uint32_t charID) {
|
||||
std::vector<FriendData> TestSQLDatabase::GetFriendsList(LWOOBJID charID) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<IFriends::BestFriendStatus> TestSQLDatabase::GetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId) {
|
||||
std::optional<IFriends::BestFriendStatus> TestSQLDatabase::GetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) {
|
||||
return {};
|
||||
}
|
||||
|
||||
void TestSQLDatabase::SetBestFriendStatus(const uint32_t playerAccountId, const uint32_t friendAccountId, const uint32_t bestFriendStatus) {
|
||||
void TestSQLDatabase::SetBestFriendStatus(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId, const uint32_t bestFriendStatus) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::AddFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) {
|
||||
void TestSQLDatabase::AddFriend(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::RemoveFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) {
|
||||
void TestSQLDatabase::RemoveFriend(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::UpdateActivityLog(const uint32_t characterId, const eActivityType activityType, const LWOMAPID mapId) {
|
||||
void TestSQLDatabase::UpdateActivityLog(const LWOOBJID characterId, const eActivityType activityType, const LWOMAPID mapId) {
|
||||
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ void TestSQLDatabase::InsertMigration(const std::string_view str) {
|
||||
|
||||
}
|
||||
|
||||
std::optional<ICharInfo::Info> TestSQLDatabase::GetCharacterInfo(const uint32_t charId) {
|
||||
std::optional<ICharInfo::Info> TestSQLDatabase::GetCharacterInfo(const LWOOBJID charId) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -88,11 +88,11 @@ std::optional<ICharInfo::Info> TestSQLDatabase::GetCharacterInfo(const std::stri
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string TestSQLDatabase::GetCharacterXml(const uint32_t accountId) {
|
||||
std::string TestSQLDatabase::GetCharacterXml(const LWOOBJID accountId) {
|
||||
return {};
|
||||
}
|
||||
|
||||
void TestSQLDatabase::UpdateCharacterXml(const uint32_t characterId, const std::string_view lxfml) {
|
||||
void TestSQLDatabase::UpdateCharacterXml(const LWOOBJID characterId, const std::string_view lxfml) {
|
||||
|
||||
}
|
||||
|
||||
@@ -104,27 +104,27 @@ void TestSQLDatabase::InsertNewCharacter(const ICharInfo::Info info) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::InsertCharacterXml(const uint32_t accountId, const std::string_view lxfml) {
|
||||
void TestSQLDatabase::InsertCharacterXml(const LWOOBJID accountId, const std::string_view lxfml) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<uint32_t> TestSQLDatabase::GetAccountCharacterIds(uint32_t accountId) {
|
||||
std::vector<LWOOBJID> TestSQLDatabase::GetAccountCharacterIds(LWOOBJID accountId) {
|
||||
return {};
|
||||
}
|
||||
|
||||
void TestSQLDatabase::DeleteCharacter(const uint32_t characterId) {
|
||||
void TestSQLDatabase::DeleteCharacter(const LWOOBJID characterId) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::SetCharacterName(const uint32_t characterId, const std::string_view name) {
|
||||
void TestSQLDatabase::SetCharacterName(const LWOOBJID characterId, const std::string_view name) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::SetPendingCharacterName(const uint32_t characterId, const std::string_view name) {
|
||||
void TestSQLDatabase::SetPendingCharacterName(const LWOOBJID characterId, const std::string_view name) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::UpdateLastLoggedInCharacter(const uint32_t characterId) {
|
||||
void TestSQLDatabase::UpdateLastLoggedInCharacter(const LWOOBJID characterId) {
|
||||
|
||||
}
|
||||
|
||||
@@ -192,11 +192,11 @@ void TestSQLDatabase::InsertNewMail(const MailInfo& mail) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::InsertNewUgcModel(std::stringstream& sd0Data, const uint32_t blueprintId, const uint32_t accountId, const uint32_t characterId) {
|
||||
void TestSQLDatabase::InsertNewUgcModel(std::stringstream& sd0Data, const uint32_t blueprintId, const uint32_t accountId, const LWOOBJID characterId) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<MailInfo> TestSQLDatabase::GetMailForPlayer(const uint32_t characterId, const uint32_t numberOfMail) {
|
||||
std::vector<MailInfo> TestSQLDatabase::GetMailForPlayer(const LWOOBJID characterId, const uint32_t numberOfMail) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ std::optional<MailInfo> TestSQLDatabase::GetMail(const uint64_t mailId) {
|
||||
return {};
|
||||
}
|
||||
|
||||
uint32_t TestSQLDatabase::GetUnreadMailCount(const uint32_t characterId) {
|
||||
uint32_t TestSQLDatabase::GetUnreadMailCount(const LWOOBJID characterId) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ void TestSQLDatabase::ClaimMailItem(const uint64_t mailId) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::InsertSlashCommandUsage(const uint32_t characterId, const std::string_view command) {
|
||||
void TestSQLDatabase::InsertSlashCommandUsage(const LWOOBJID characterId, const std::string_view command) {
|
||||
|
||||
}
|
||||
|
||||
@@ -268,15 +268,15 @@ std::vector<IUgc::Model> TestSQLDatabase::GetUgcModels(const LWOOBJID& propertyI
|
||||
return {};
|
||||
}
|
||||
|
||||
void TestSQLDatabase::AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||
void TestSQLDatabase::AddIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) {
|
||||
|
||||
}
|
||||
|
||||
void TestSQLDatabase::RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) {
|
||||
void TestSQLDatabase::RemoveIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) {
|
||||
|
||||
}
|
||||
|
||||
std::vector<IIgnoreList::Info> TestSQLDatabase::GetIgnoreList(const uint32_t playerId) {
|
||||
std::vector<IIgnoreList::Info> TestSQLDatabase::GetIgnoreList(const LWOOBJID playerId) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -17,31 +17,31 @@ class TestSQLDatabase : public GameDatabase {
|
||||
|
||||
std::vector<std::string> GetApprovedCharacterNames() override;
|
||||
|
||||
std::vector<FriendData> GetFriendsList(uint32_t charID) override;
|
||||
std::vector<FriendData> GetFriendsList(LWOOBJID charID) override;
|
||||
|
||||
std::optional<IFriends::BestFriendStatus> GetBestFriendStatus(const uint32_t playerCharacterId, const uint32_t friendCharacterId) override;
|
||||
void SetBestFriendStatus(const uint32_t playerAccountId, const uint32_t friendAccountId, const uint32_t bestFriendStatus) override;
|
||||
void AddFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) override;
|
||||
void RemoveFriend(const uint32_t playerAccountId, const uint32_t friendAccountId) override;
|
||||
void UpdateActivityLog(const uint32_t characterId, const eActivityType activityType, const LWOMAPID mapId) override;
|
||||
std::optional<IFriends::BestFriendStatus> GetBestFriendStatus(const LWOOBJID playerCharacterId, const LWOOBJID friendCharacterId) override;
|
||||
void SetBestFriendStatus(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId, const uint32_t bestFriendStatus) override;
|
||||
void AddFriend(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId) override;
|
||||
void RemoveFriend(const LWOOBJID playerAccountId, const LWOOBJID friendAccountId) override;
|
||||
void UpdateActivityLog(const LWOOBJID characterId, const eActivityType activityType, const LWOMAPID mapId) override;
|
||||
void DeleteUgcModelData(const LWOOBJID& modelId) override;
|
||||
void UpdateUgcModelData(const LWOOBJID& modelId, std::stringstream& lxfml) override;
|
||||
std::vector<IUgc::Model> GetAllUgcModels() override;
|
||||
void CreateMigrationHistoryTable() override;
|
||||
bool IsMigrationRun(const std::string_view str) override;
|
||||
void InsertMigration(const std::string_view str) override;
|
||||
std::optional<ICharInfo::Info> GetCharacterInfo(const uint32_t charId) override;
|
||||
std::optional<ICharInfo::Info> GetCharacterInfo(const LWOOBJID charId) override;
|
||||
std::optional<ICharInfo::Info> GetCharacterInfo(const std::string_view charId) override;
|
||||
std::string GetCharacterXml(const uint32_t accountId) override;
|
||||
void UpdateCharacterXml(const uint32_t characterId, const std::string_view lxfml) override;
|
||||
std::string GetCharacterXml(const LWOOBJID accountId) override;
|
||||
void UpdateCharacterXml(const LWOOBJID characterId, const std::string_view lxfml) override;
|
||||
std::optional<IAccounts::Info> GetAccountInfo(const std::string_view username) override;
|
||||
void InsertNewCharacter(const ICharInfo::Info info) override;
|
||||
void InsertCharacterXml(const uint32_t accountId, const std::string_view lxfml) override;
|
||||
std::vector<uint32_t> GetAccountCharacterIds(uint32_t accountId) override;
|
||||
void DeleteCharacter(const uint32_t characterId) override;
|
||||
void SetCharacterName(const uint32_t characterId, const std::string_view name) override;
|
||||
void SetPendingCharacterName(const uint32_t characterId, const std::string_view name) override;
|
||||
void UpdateLastLoggedInCharacter(const uint32_t characterId) override;
|
||||
void InsertCharacterXml(const LWOOBJID accountId, const std::string_view lxfml) override;
|
||||
std::vector<LWOOBJID> GetAccountCharacterIds(LWOOBJID accountId) override;
|
||||
void DeleteCharacter(const LWOOBJID characterId) override;
|
||||
void SetCharacterName(const LWOOBJID characterId, const std::string_view name) override;
|
||||
void SetPendingCharacterName(const LWOOBJID characterId, const std::string_view name) override;
|
||||
void UpdateLastLoggedInCharacter(const LWOOBJID characterId) override;
|
||||
void SetPetNameModerationStatus(const LWOOBJID& petId, const IPetNames::Info& info) override;
|
||||
std::optional<IPetNames::Info> GetPetNameInfo(const LWOOBJID& petId) override;
|
||||
std::optional<IProperty::Info> GetPropertyInfo(const LWOMAPID mapId, const LWOCLONEID cloneId) override;
|
||||
@@ -62,14 +62,14 @@ class TestSQLDatabase : public GameDatabase {
|
||||
std::stringstream& sd0Data,
|
||||
const uint32_t blueprintId,
|
||||
const uint32_t accountId,
|
||||
const uint32_t characterId) override;
|
||||
std::vector<MailInfo> GetMailForPlayer(const uint32_t characterId, const uint32_t numberOfMail) override;
|
||||
const LWOOBJID characterId) override;
|
||||
std::vector<MailInfo> GetMailForPlayer(const LWOOBJID characterId, const uint32_t numberOfMail) override;
|
||||
std::optional<MailInfo> GetMail(const uint64_t mailId) override;
|
||||
uint32_t GetUnreadMailCount(const uint32_t characterId) override;
|
||||
uint32_t GetUnreadMailCount(const LWOOBJID characterId) override;
|
||||
void MarkMailRead(const uint64_t mailId) override;
|
||||
void DeleteMail(const uint64_t mailId) override;
|
||||
void ClaimMailItem(const uint64_t mailId) override;
|
||||
void InsertSlashCommandUsage(const uint32_t characterId, const std::string_view command) override;
|
||||
void InsertSlashCommandUsage(const LWOOBJID characterId, const std::string_view command) override;
|
||||
void UpdateAccountUnmuteTime(const uint32_t accountId, const uint64_t timeToUnmute) override;
|
||||
void UpdateAccountBan(const uint32_t accountId, const bool banned) override;
|
||||
void UpdateAccountPassword(const uint32_t accountId, const std::string_view bcryptpassword) override;
|
||||
@@ -81,9 +81,9 @@ class TestSQLDatabase : public GameDatabase {
|
||||
std::optional<uint32_t> GetDonationTotal(const uint32_t activityId) override;
|
||||
std::optional<bool> IsPlaykeyActive(const int32_t playkeyId) override;
|
||||
std::vector<IUgc::Model> GetUgcModels(const LWOOBJID& propertyId) override;
|
||||
void AddIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) override;
|
||||
void RemoveIgnore(const uint32_t playerId, const uint32_t ignoredPlayerId) override;
|
||||
std::vector<IIgnoreList::Info> GetIgnoreList(const uint32_t playerId) override;
|
||||
void AddIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) override;
|
||||
void RemoveIgnore(const LWOOBJID playerId, const LWOOBJID ignoredPlayerId) override;
|
||||
std::vector<IIgnoreList::Info> GetIgnoreList(const LWOOBJID playerId) override;
|
||||
void InsertRewardCode(const uint32_t account_id, const uint32_t reward_code) override;
|
||||
std::vector<uint32_t> GetRewardCodesByAccountID(const uint32_t account_id) override;
|
||||
void AddBehavior(const IBehaviors::Info& info) override;
|
||||
@@ -95,12 +95,12 @@ class TestSQLDatabase : public GameDatabase {
|
||||
std::vector<ILeaderboard::Entry> GetAscendingLeaderboard(const uint32_t activityId) override { return {}; };
|
||||
std::vector<ILeaderboard::Entry> GetNsLeaderboard(const uint32_t activityId) override { return {}; };
|
||||
std::vector<ILeaderboard::Entry> GetAgsLeaderboard(const uint32_t activityId) override { return {}; };
|
||||
void SaveScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override {};
|
||||
void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override {};
|
||||
std::optional<ILeaderboard::Score> GetPlayerScore(const uint32_t playerId, const uint32_t gameId) override { return {}; };
|
||||
void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) override {};
|
||||
void IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) override {};
|
||||
void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) override {};
|
||||
void SaveScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) override {};
|
||||
void UpdateScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) override {};
|
||||
std::optional<ILeaderboard::Score> GetPlayerScore(const LWOOBJID playerId, const uint32_t gameId) override { return {}; };
|
||||
void IncrementNumWins(const LWOOBJID playerId, const uint32_t gameId) override {};
|
||||
void IncrementTimesPlayed(const LWOOBJID playerId, const uint32_t gameId) override {};
|
||||
void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<LWOOBJID> characterId) override {};
|
||||
void DeleteUgcBuild(const LWOOBJID bigId) override {};
|
||||
uint32_t GetAccountCount() override { return 0; };
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "ePlayerFlag.h"
|
||||
#include "CDPlayerFlagsTable.h"
|
||||
|
||||
Character::Character(uint32_t id, User* parentUser) {
|
||||
Character::Character(LWOOBJID id, User* parentUser) {
|
||||
//First load the name, etc:
|
||||
m_ID = id;
|
||||
m_ParentUser = parentUser;
|
||||
@@ -50,6 +50,10 @@ void Character::UpdateInfoFromDatabase() {
|
||||
|
||||
//Load the xmlData now:
|
||||
m_XMLData = Database::Get()->GetCharacterXml(m_ID);
|
||||
if (m_XMLData.empty()) {
|
||||
LOG("Character %s (%llu) has no xml data!", m_Name.c_str(), m_ID);
|
||||
return;
|
||||
}
|
||||
|
||||
m_ZoneID = 0; //TEMP! Set back to 0 when done. This is so we can see loading screen progress for testing.
|
||||
m_ZoneInstanceID = 0; //These values don't really matter, these are only used on the char select screen and seem unused.
|
||||
@@ -61,7 +65,6 @@ void Character::UpdateInfoFromDatabase() {
|
||||
//Set our objectID:
|
||||
m_ObjectID = m_ID;
|
||||
GeneralUtils::SetBit(m_ObjectID, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(m_ObjectID, eObjectBits::PERSISTENT);
|
||||
|
||||
m_OurEntity = nullptr;
|
||||
m_BuildMode = false;
|
||||
@@ -75,7 +78,7 @@ void Character::DoQuickXMLDataParse() {
|
||||
if (m_XMLData.size() == 0) return;
|
||||
|
||||
if (m_Doc.Parse(m_XMLData.c_str(), m_XMLData.size()) == 0) {
|
||||
LOG("Loaded xmlData for character %s (%i)!", m_Name.c_str(), m_ID);
|
||||
LOG("Loaded xmlData for character %s (%llu)!", m_Name.c_str(), m_ID);
|
||||
} else {
|
||||
LOG("Failed to load xmlData (%i) (%s) (%s)!", m_Doc.ErrorID(), m_Doc.ErrorIDToName(m_Doc.ErrorID()), m_Doc.ErrorStr());
|
||||
//Server::rakServer->CloseConnection(m_ParentUser->GetSystemAddress(), true);
|
||||
@@ -238,7 +241,7 @@ void Character::SetBuildMode(bool buildMode) {
|
||||
void Character::SaveXMLToDatabase() {
|
||||
// Check that we can actually _save_ before saving
|
||||
if (!m_OurEntity) {
|
||||
LOG("%i:%s didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!", this->GetID(), this->GetName().c_str());
|
||||
LOG("%llu:%s didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!", this->GetID(), this->GetName().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -308,7 +311,7 @@ void Character::SaveXMLToDatabase() {
|
||||
//For metrics, log the time it took to save:
|
||||
auto end = std::chrono::system_clock::now();
|
||||
std::chrono::duration<double> elapsed = end - start;
|
||||
LOG("%i:%s Saved character to Database in: %fs", this->GetID(), this->GetName().c_str(), elapsed.count());
|
||||
LOG("%llu:%s Saved character to Database in: %fs", this->GetID(), this->GetName().c_str(), elapsed.count());
|
||||
}
|
||||
|
||||
void Character::SetIsNewLogin() {
|
||||
@@ -320,7 +323,7 @@ void Character::SetIsNewLogin() {
|
||||
while (currentChild) {
|
||||
auto* nextChild = currentChild->NextSiblingElement();
|
||||
if (currentChild->Attribute("si")) {
|
||||
LOG("Removed session flag (%s) from character %i:%s, saving character to database", currentChild->Attribute("si"), GetID(), GetName().c_str());
|
||||
LOG("Removed session flag (%s) from character %llu:%s, saving character to database", currentChild->Attribute("si"), GetID(), GetName().c_str());
|
||||
flags->DeleteChild(currentChild);
|
||||
WriteToDatabase();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ enum class eLootSourceType : uint32_t;
|
||||
*/
|
||||
class Character {
|
||||
public:
|
||||
Character(uint32_t id, User* parentUser);
|
||||
Character(LWOOBJID id, User* parentUser);
|
||||
~Character();
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
* Gets the database ID of the character
|
||||
* @return the database ID of the character
|
||||
*/
|
||||
uint32_t GetID() const { return m_ID; }
|
||||
LWOOBJID GetID() const { return m_ID; }
|
||||
|
||||
/**
|
||||
* Gets the (custom) name of the character
|
||||
@@ -467,9 +467,9 @@ public:
|
||||
private:
|
||||
void UpdateInfoFromDatabase();
|
||||
/**
|
||||
* The ID of this character. First 32 bits of the ObjectID.
|
||||
* The ID of this character.
|
||||
*/
|
||||
uint32_t m_ID{};
|
||||
LWOOBJID m_ID{};
|
||||
|
||||
/**
|
||||
* The 64-bit unique ID used in the game.
|
||||
|
||||
@@ -145,7 +145,7 @@ void QueryToLdf(Leaderboard& leaderboard, const std::vector<ILeaderboard::Entry>
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ILeaderboard::Entry> FilterToNumResults(const std::vector<ILeaderboard::Entry>& leaderboard, const uint32_t relatedPlayer, const Leaderboard::InfoType infoType, const uint32_t numResults) {
|
||||
std::vector<ILeaderboard::Entry> FilterToNumResults(const std::vector<ILeaderboard::Entry>& leaderboard, const LWOOBJID relatedPlayer, const Leaderboard::InfoType infoType, const uint32_t numResults) {
|
||||
std::vector<ILeaderboard::Entry> toReturn;
|
||||
|
||||
int32_t index = 0;
|
||||
@@ -197,7 +197,7 @@ std::vector<ILeaderboard::Entry> FilterWeeklies(const std::vector<ILeaderboard::
|
||||
return weeklyLeaderboard;
|
||||
}
|
||||
|
||||
std::vector<ILeaderboard::Entry> FilterFriends(const std::vector<ILeaderboard::Entry>& leaderboard, const uint32_t relatedPlayer) {
|
||||
std::vector<ILeaderboard::Entry> FilterFriends(const std::vector<ILeaderboard::Entry>& leaderboard, const LWOOBJID relatedPlayer) {
|
||||
// Filter the leaderboard to only include friends of the player
|
||||
auto friendOfPlayer = Database::Get()->GetFriendsList(relatedPlayer);
|
||||
std::vector<ILeaderboard::Entry> friendsLeaderboard;
|
||||
@@ -217,7 +217,7 @@ std::vector<ILeaderboard::Entry> ProcessLeaderboard(
|
||||
const std::vector<ILeaderboard::Entry>& leaderboard,
|
||||
const bool weekly,
|
||||
const Leaderboard::InfoType infoType,
|
||||
const uint32_t relatedPlayer,
|
||||
const LWOOBJID relatedPlayer,
|
||||
const uint32_t numResults) {
|
||||
std::vector<ILeaderboard::Entry> toReturn;
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
#include "Logger.h"
|
||||
#include "Game.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "eServerDisconnectIdentifiers.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "MessageType/Chat.h"
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include "CommonPackets.h"
|
||||
|
||||
User::User(const SystemAddress& sysAddr, const std::string& username, const std::string& sessionKey) {
|
||||
m_AccountID = 0;
|
||||
@@ -39,11 +39,11 @@ User::User(const SystemAddress& sysAddr, const std::string& username, const std:
|
||||
if (Game::server->GetZoneID() != 0) {
|
||||
auto characterList = Database::Get()->GetAccountCharacterIds(m_AccountID);
|
||||
if (!characterList.empty()) {
|
||||
const uint32_t lastUsedCharacterId = characterList.front();
|
||||
const auto lastUsedCharacterId = characterList.front();
|
||||
Character* character = new Character(lastUsedCharacterId, this);
|
||||
character->UpdateFromDatabase();
|
||||
m_Characters.push_back(character);
|
||||
LOG("Loaded %i as it is the last used char", lastUsedCharacterId);
|
||||
LOG("Loaded %llu as it is the last used char", lastUsedCharacterId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,10 +132,7 @@ void User::UserOutOfSync() {
|
||||
if (m_AmountOfTimesOutOfSync > m_MaxDesyncAllowed) {
|
||||
//YEET
|
||||
LOG("User %s was out of sync %i times out of %i, disconnecting for suspected speedhacking.", m_Username.c_str(), m_AmountOfTimesOutOfSync, m_MaxDesyncAllowed);
|
||||
CommonPackets::DisconnectNotify notification;
|
||||
notification.disconnectID = eServerDisconnectIdentifiers::PLAY_SCHEDULE_TIME_DONE;
|
||||
notification.Send(this->m_SystemAddress);
|
||||
Game::server->Disconnect(this->m_SystemAddress);
|
||||
Game::server->Disconnect(this->m_SystemAddress, eServerDisconnectIdentifiers::PLAY_SCHEDULE_TIME_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -325,7 +325,9 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
}
|
||||
|
||||
//Now that the name is ok, we can get an objectID from Master:
|
||||
ObjectIDManager::RequestPersistentID([=, this](uint32_t objectID) {
|
||||
ObjectIDManager::RequestPersistentID([=, this](uint32_t persistentID) {
|
||||
LWOOBJID objectID = persistentID;
|
||||
GeneralUtils::SetBit(objectID, eObjectBits::CHARACTER);
|
||||
if (Database::Get()->GetCharacterInfo(objectID)) {
|
||||
LOG("Character object id unavailable, check object_id_tracker!");
|
||||
WorldPackets::SendCharacterCreationResponse(sysAddr, eCharacterCreationResponse::OBJECT_ID_UNAVAILABLE);
|
||||
@@ -409,9 +411,8 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID objectID;
|
||||
inStream.Read(objectID);
|
||||
uint32_t charID = static_cast<uint32_t>(objectID);
|
||||
|
||||
LOG("Received char delete req for ID: %llu (%u)", objectID, charID);
|
||||
LOG("Received char delete req for ID: %llu", objectID);
|
||||
|
||||
bool hasCharacter = CheatDetection::VerifyLwoobjidIsSender(
|
||||
objectID,
|
||||
@@ -423,8 +424,8 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
if (!hasCharacter) {
|
||||
WorldPackets::SendCharacterDeleteResponse(sysAddr, false);
|
||||
} else {
|
||||
LOG("Deleting character %i", charID);
|
||||
Database::Get()->DeleteCharacter(charID);
|
||||
LOG("Deleting character %llu", objectID);
|
||||
Database::Get()->DeleteCharacter(objectID);
|
||||
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::CHAT, MessageType::Chat::UNEXPECTED_DISCONNECT);
|
||||
@@ -445,11 +446,8 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID objectID;
|
||||
inStream.Read(objectID);
|
||||
GeneralUtils::ClearBit(objectID, eObjectBits::CHARACTER);
|
||||
GeneralUtils::ClearBit(objectID, eObjectBits::PERSISTENT);
|
||||
|
||||
uint32_t charID = static_cast<uint32_t>(objectID);
|
||||
LOG("Received char rename request for ID: %llu (%u)", objectID, charID);
|
||||
LOG("Received char rename request for ID: %llu", objectID);
|
||||
|
||||
LUWString LUWStringName;
|
||||
inStream.Read(LUWStringName);
|
||||
@@ -466,7 +464,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
u->GetAccountID());
|
||||
|
||||
auto unusedItr = std::find_if(u->GetCharacters().begin(), u->GetCharacters().end(), [&](Character* c) {
|
||||
if (c->GetID() == charID) {
|
||||
if (c->GetID() == objectID) {
|
||||
character = c;
|
||||
return true;
|
||||
}
|
||||
@@ -483,12 +481,12 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
|
||||
if (!Database::Get()->GetCharacterInfo(newName)) {
|
||||
if (IsNamePreapproved(newName)) {
|
||||
Database::Get()->SetCharacterName(charID, newName);
|
||||
Database::Get()->SetCharacterName(objectID, newName);
|
||||
LOG("Character %s now known as %s", character->GetName().c_str(), newName.c_str());
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::SUCCESS);
|
||||
UserManager::RequestCharacterList(sysAddr);
|
||||
} else {
|
||||
Database::Get()->SetPendingCharacterName(charID, newName);
|
||||
Database::Get()->SetPendingCharacterName(objectID, newName);
|
||||
LOG("Character %s has been renamed to %s and is pending approval by a moderator.", character->GetName().c_str(), newName.c_str());
|
||||
WorldPackets::SendCharacterRenameResponse(sysAddr, eRenameResponse::SUCCESS);
|
||||
UserManager::RequestCharacterList(sysAddr);
|
||||
@@ -502,7 +500,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
}
|
||||
}
|
||||
|
||||
void UserManager::LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID) {
|
||||
void UserManager::LoginCharacter(const SystemAddress& sysAddr, LWOOBJID playerID) {
|
||||
User* u = GetUser(sysAddr);
|
||||
if (!u) {
|
||||
LOG("Couldn't get user to log in character");
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
void CreateCharacter(const SystemAddress& sysAddr, Packet* packet);
|
||||
void DeleteCharacter(const SystemAddress& sysAddr, Packet* packet);
|
||||
void RenameCharacter(const SystemAddress& sysAddr, Packet* packet);
|
||||
void LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID);
|
||||
void LoginCharacter(const SystemAddress& sysAddr, LWOOBJID playerID);
|
||||
|
||||
void SaveAllActiveCharacters();
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
|
||||
this->propertyId = propertyInfo->id;
|
||||
this->owner = propertyInfo->ownerId;
|
||||
GeneralUtils::SetBit(this->owner, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(this->owner, eObjectBits::PERSISTENT);
|
||||
this->clone_Id = propertyInfo->cloneId;
|
||||
this->propertyName = propertyInfo->name;
|
||||
this->propertyDescription = propertyInfo->description;
|
||||
|
||||
@@ -76,8 +76,8 @@ void LogAndSaveFailedAntiCheatCheck(const LWOOBJID& id, const SystemAddress& sys
|
||||
auto* user = UserManager::Instance()->GetUser(sysAddr);
|
||||
|
||||
if (user) {
|
||||
LOG("User at system address (%s) (%s) (%llu) sent a packet as (%i) which is not an id they own.",
|
||||
sysAddr.ToString(), user->GetLastUsedChar()->GetName().c_str(), user->GetLastUsedChar()->GetObjectID(), static_cast<int32_t>(id));
|
||||
LOG("User at system address (%s) (%s) (%llu) sent a packet as (%llu) which is not an id they own.",
|
||||
sysAddr.ToString(), user->GetLastUsedChar()->GetName().c_str(), user->GetLastUsedChar()->GetObjectID(), id);
|
||||
// Can't know sending player. Just log system address for IP banning.
|
||||
} else {
|
||||
LOG("No user found for system address (%s).", sysAddr.ToString());
|
||||
@@ -117,7 +117,7 @@ bool CheatDetection::VerifyLwoobjidIsSender(const LWOOBJID& id, const SystemAddr
|
||||
return false;
|
||||
}
|
||||
invalidPacket = true;
|
||||
const uint32_t characterId = static_cast<uint32_t>(id);
|
||||
const auto characterId = id;
|
||||
// Check to make sure the ID provided is one of the user's characters.
|
||||
for (const auto& character : sendingUser->GetCharacters()) {
|
||||
if (character && character->GetID() == characterId) {
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace {
|
||||
}
|
||||
|
||||
namespace Mail {
|
||||
std::map<eMessageID, std::function<std::unique_ptr<MailClientLUBitStream>()>> g_Handlers = {
|
||||
std::map<eMessageID, std::function<std::unique_ptr<MailLUBitStream>()>> g_Handlers = {
|
||||
{eMessageID::SendRequest, []() {
|
||||
return std::make_unique<SendRequest>();
|
||||
}},
|
||||
@@ -55,11 +55,11 @@ namespace Mail {
|
||||
}},
|
||||
};
|
||||
|
||||
void MailClientLUBitStream::Serialize(RakNet::BitStream& bitStream) const {
|
||||
void MailLUBitStream::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(messageID);
|
||||
}
|
||||
|
||||
bool MailClientLUBitStream::Deserialize(RakNet::BitStream& bitstream) {
|
||||
bool MailLUBitStream::Deserialize(RakNet::BitStream& bitstream) {
|
||||
VALIDATE_READ(bitstream.Read(messageID));
|
||||
return true;
|
||||
}
|
||||
@@ -133,16 +133,16 @@ namespace Mail {
|
||||
response.status = eSendResponse::SenderAccountIsMuted;
|
||||
}
|
||||
LOG("Finished send with status %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send();
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
void SendResponse::Serialize(RakNet::BitStream& bitStream) const {
|
||||
MailClientLUBitStream::Serialize(bitStream);
|
||||
MailLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write(status);
|
||||
}
|
||||
|
||||
void NotificationResponse::Serialize(RakNet::BitStream& bitStream) const {
|
||||
MailClientLUBitStream::Serialize(bitStream);
|
||||
MailLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write(status);
|
||||
bitStream.Write<uint64_t>(0); // unused
|
||||
bitStream.Write<uint64_t>(0); // unused
|
||||
@@ -158,12 +158,12 @@ namespace Mail {
|
||||
auto playerMail = Database::Get()->GetMailForPlayer(character->GetID(), 20);
|
||||
DataResponse response;
|
||||
response.playerMail = playerMail;
|
||||
response.Send();
|
||||
response.Send(sysAddr);
|
||||
LOG("DataRequest");
|
||||
}
|
||||
|
||||
void DataResponse::Serialize(RakNet::BitStream& bitStream) const {
|
||||
MailClientLUBitStream::Serialize(bitStream);
|
||||
MailLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write(this->throttled);
|
||||
|
||||
bitStream.Write<uint16_t>(this->playerMail.size());
|
||||
@@ -199,11 +199,11 @@ namespace Mail {
|
||||
}
|
||||
}
|
||||
LOG("AttachmentCollectResponse %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send();
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
void AttachmentCollectResponse::Serialize(RakNet::BitStream& bitStream) const {
|
||||
MailClientLUBitStream::Serialize(bitStream);
|
||||
MailLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write(status);
|
||||
bitStream.Write(mailID);
|
||||
}
|
||||
@@ -230,11 +230,11 @@ namespace Mail {
|
||||
response.status = eDeleteResponse::NotFound;
|
||||
}
|
||||
LOG("DeleteRequest status %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send();
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
void DeleteResponse::Serialize(RakNet::BitStream& bitStream) const {
|
||||
MailClientLUBitStream::Serialize(bitStream);
|
||||
MailLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write(status);
|
||||
bitStream.Write(mailID);
|
||||
}
|
||||
@@ -256,11 +256,11 @@ namespace Mail {
|
||||
}
|
||||
|
||||
LOG("ReadRequest %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send();
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
void ReadResponse::Serialize(RakNet::BitStream& bitStream) const {
|
||||
MailClientLUBitStream::Serialize(bitStream);
|
||||
MailLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write(status);
|
||||
bitStream.Write(mailID);
|
||||
}
|
||||
@@ -275,13 +275,13 @@ namespace Mail {
|
||||
}
|
||||
|
||||
LOG("NotificationRequest %s", StringifiedEnum::ToString(response.status).data());
|
||||
response.Send();
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
}
|
||||
|
||||
// Non Stuct Functions
|
||||
void Mail::Handle(RakNet::BitStream& inStream, const SystemAddress& sysAddr, Entity* player) {
|
||||
MailClientLUBitStream data;
|
||||
void Mail::HandleMail(RakNet::BitStream& inStream, const SystemAddress& sysAddr, Entity* player) {
|
||||
MailLUBitStream data;
|
||||
if (!data.Deserialize(inStream)) {
|
||||
LOG_DEBUG("Error Reading Mail header");
|
||||
return;
|
||||
@@ -368,5 +368,5 @@ void Mail::SendMail(const LWOOBJID sender, const std::string& senderName, LWOOBJ
|
||||
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) return; // TODO: Echo to chat server
|
||||
NotificationResponse response;
|
||||
response.status = eNotificationResponse::NewMail;
|
||||
response.Send();
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include "dCommonVars.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "MailInfo.h"
|
||||
#include "MessageType/Client.h"
|
||||
#include "ClientPackets.h"
|
||||
|
||||
class Entity;
|
||||
|
||||
@@ -105,111 +103,112 @@ namespace Mail {
|
||||
UnknownError
|
||||
};
|
||||
|
||||
struct MailClientLUBitStream : public ClientPackets::ClientLUBitStream {
|
||||
struct MailLUBitStream : public LUBitStream {
|
||||
eMessageID messageID = eMessageID::UnknownError;
|
||||
SystemAddress sysAddr = UNASSIGNED_SYSTEM_ADDRESS;
|
||||
Entity* player = nullptr;
|
||||
|
||||
MailClientLUBitStream() = default;
|
||||
MailClientLUBitStream(eMessageID _messageID) : ClientPackets::ClientLUBitStream(MessageType::Client::MAIL), messageID{_messageID} {};
|
||||
MailLUBitStream() = default;
|
||||
MailLUBitStream(eMessageID _messageID) : LUBitStream(ServiceType::CLIENT, MessageType::Client::MAIL), messageID{_messageID} {};
|
||||
|
||||
virtual void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
virtual bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
virtual void Handle() override {};
|
||||
};
|
||||
|
||||
struct SendRequest : public MailClientLUBitStream {
|
||||
struct SendRequest : public MailLUBitStream {
|
||||
MailInfo mailInfo;
|
||||
|
||||
SendRequest() : MailClientLUBitStream(eMessageID::SendRequest) {}
|
||||
SendRequest() : MailLUBitStream(eMessageID::SendRequest) {}
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
struct SendResponse :public MailClientLUBitStream {
|
||||
struct SendResponse :public MailLUBitStream {
|
||||
eSendResponse status = eSendResponse::UnknownError;
|
||||
|
||||
SendResponse() : MailClientLUBitStream(eMessageID::SendResponse) {}
|
||||
SendResponse() : MailLUBitStream(eMessageID::SendResponse) {}
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct NotificationResponse : public MailClientLUBitStream {
|
||||
struct NotificationResponse : public MailLUBitStream {
|
||||
eNotificationResponse status = eNotificationResponse::UnknownError;
|
||||
LWOOBJID auctionID = LWOOBJID_EMPTY;
|
||||
uint32_t mailCount = 1;
|
||||
NotificationResponse() : MailClientLUBitStream(eMessageID::NotificationResponse) {};
|
||||
NotificationResponse() : MailLUBitStream(eMessageID::NotificationResponse) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct DataRequest : public MailClientLUBitStream {
|
||||
DataRequest() : MailClientLUBitStream(eMessageID::DataRequest) {}
|
||||
struct DataRequest : public MailLUBitStream {
|
||||
DataRequest() : MailLUBitStream(eMessageID::DataRequest) {}
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override { return true; };
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
struct DataResponse : public MailClientLUBitStream {
|
||||
struct DataResponse : public MailLUBitStream {
|
||||
uint32_t throttled = 0;
|
||||
std::vector<MailInfo> playerMail;
|
||||
|
||||
DataResponse() : MailClientLUBitStream(eMessageID::DataResponse) {};
|
||||
DataResponse() : MailLUBitStream(eMessageID::DataResponse) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
|
||||
};
|
||||
|
||||
struct AttachmentCollectRequest : public MailClientLUBitStream {
|
||||
struct AttachmentCollectRequest : public MailLUBitStream {
|
||||
uint64_t mailID = 0;
|
||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||
|
||||
AttachmentCollectRequest() : MailClientLUBitStream(eMessageID::AttachmentCollectRequest) {};
|
||||
AttachmentCollectRequest() : MailLUBitStream(eMessageID::AttachmentCollectRequest) {};
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
struct AttachmentCollectResponse : public MailClientLUBitStream {
|
||||
struct AttachmentCollectResponse : public MailLUBitStream {
|
||||
eAttachmentCollectResponse status = eAttachmentCollectResponse::UnknownError;
|
||||
uint64_t mailID = 0;
|
||||
AttachmentCollectResponse() : MailClientLUBitStream(eMessageID::AttachmentCollectResponse) {};
|
||||
AttachmentCollectResponse() : MailLUBitStream(eMessageID::AttachmentCollectResponse) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct DeleteRequest : public MailClientLUBitStream {
|
||||
struct DeleteRequest : public MailLUBitStream {
|
||||
uint64_t mailID = 0;
|
||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||
|
||||
DeleteRequest() : MailClientLUBitStream(eMessageID::DeleteRequest) {};
|
||||
DeleteRequest() : MailLUBitStream(eMessageID::DeleteRequest) {};
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
struct DeleteResponse : public MailClientLUBitStream {
|
||||
struct DeleteResponse : public MailLUBitStream {
|
||||
eDeleteResponse status = eDeleteResponse::UnknownError;
|
||||
uint64_t mailID = 0;
|
||||
DeleteResponse() : MailClientLUBitStream(eMessageID::DeleteResponse) {};
|
||||
DeleteResponse() : MailLUBitStream(eMessageID::DeleteResponse) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct ReadRequest : public MailClientLUBitStream {
|
||||
struct ReadRequest : public MailLUBitStream {
|
||||
uint64_t mailID = 0;
|
||||
|
||||
ReadRequest() : MailClientLUBitStream(eMessageID::ReadRequest) {};
|
||||
ReadRequest() : MailLUBitStream(eMessageID::ReadRequest) {};
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
struct ReadResponse : public MailClientLUBitStream {
|
||||
struct ReadResponse : public MailLUBitStream {
|
||||
uint64_t mailID = 0;
|
||||
eReadResponse status = eReadResponse::UnknownError;
|
||||
|
||||
ReadResponse() : MailClientLUBitStream(eMessageID::ReadResponse) {};
|
||||
ReadResponse() : MailLUBitStream(eMessageID::ReadResponse) {};
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct NotificationRequest : public MailClientLUBitStream {
|
||||
NotificationRequest() : MailClientLUBitStream(eMessageID::NotificationRequest) {};
|
||||
struct NotificationRequest : public MailLUBitStream {
|
||||
NotificationRequest() : MailLUBitStream(eMessageID::NotificationRequest) {};
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override { return true; };
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
void Handle(RakNet::BitStream& inStream, const SystemAddress& sysAddr, Entity* player);
|
||||
void HandleMail(RakNet::BitStream& inStream, const SystemAddress& sysAddr, Entity* player);
|
||||
|
||||
void SendMail(
|
||||
const Entity* recipient,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// Classes
|
||||
#include "Character.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "CommonPackets.h"
|
||||
#include "dServer.h"
|
||||
#include "PlayerManager.h"
|
||||
#include "User.h"
|
||||
@@ -17,6 +16,7 @@
|
||||
|
||||
// Enums
|
||||
#include "MessageType/Chat.h"
|
||||
#include "eServerDisconnectIdentifiers.h"
|
||||
#include "eObjectBits.h"
|
||||
|
||||
namespace GMGreaterThanZeroCommands {
|
||||
@@ -31,10 +31,8 @@ namespace GMGreaterThanZeroCommands {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Count not find player of name: " + username);
|
||||
return;
|
||||
}
|
||||
CommonPackets::DisconnectNotify notification;
|
||||
notification.disconnectID = eServerDisconnectIdentifiers::KICK;
|
||||
notification.Send(player->GetSystemAddress());
|
||||
Game::server->Disconnect(player->GetSystemAddress());
|
||||
|
||||
Game::server->Disconnect(player->GetSystemAddress(), eServerDisconnectIdentifiers::KICK);
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Kicked: " + username);
|
||||
} else {
|
||||
@@ -71,10 +69,7 @@ namespace GMGreaterThanZeroCommands {
|
||||
if (accountId != 0) Database::Get()->UpdateAccountBan(accountId, true);
|
||||
|
||||
if (player != nullptr) {
|
||||
CommonPackets::DisconnectNotify notification;
|
||||
notification.disconnectID = eServerDisconnectIdentifiers::FREE_TRIAL_EXPIRED;
|
||||
notification.Send(player->GetSystemAddress());
|
||||
Game::server->Disconnect(player->GetSystemAddress());
|
||||
Game::server->Disconnect(player->GetSystemAddress(), eServerDisconnectIdentifiers::FREE_TRIAL_EXPIRED);
|
||||
}
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Banned: " + GeneralUtils::ASCIIToUTF16(splitArgs[0]));
|
||||
@@ -146,7 +141,6 @@ namespace GMGreaterThanZeroCommands {
|
||||
characterId = characterInfo->id;
|
||||
|
||||
GeneralUtils::SetBit(characterId, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(characterId, eObjectBits::PERSISTENT);
|
||||
}
|
||||
|
||||
if (accountId == 0) {
|
||||
|
||||
@@ -17,244 +17,296 @@
|
||||
|
||||
#include "Game.h"
|
||||
#include "dConfig.h"
|
||||
#include "eServerDisconnectIdentifiers.h"
|
||||
#include "eLoginResponse.h"
|
||||
#include "ServiceType.h"
|
||||
#include "MessageType/Server.h"
|
||||
#include "MessageType/Master.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "StringifiedEnum.h"
|
||||
#include "CommonPackets.h"
|
||||
#include "ClientPackets.h"
|
||||
|
||||
namespace {
|
||||
std::vector<uint32_t> claimCodes;
|
||||
}
|
||||
|
||||
namespace AuthPackets {
|
||||
std::map<MessageType::Auth, std::function<std::unique_ptr<LUBitStream>()>> g_Handlers = {
|
||||
{MessageType::Auth::LOGIN_REQUEST, []() {
|
||||
return std::make_unique<LoginRequest>();
|
||||
}}
|
||||
};
|
||||
void Stamp::Serialize(RakNet::BitStream& outBitStream){
|
||||
outBitStream.Write(type);
|
||||
outBitStream.Write(value);
|
||||
outBitStream.Write(timestamp);
|
||||
};
|
||||
|
||||
// Struct Functions
|
||||
void AuthLUBitStream::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(this->messageType);
|
||||
bitStream.Write<uint8_t>(0); // padding
|
||||
}
|
||||
bool AuthLUBitStream::Deserialize(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(this->messageType));
|
||||
uint8_t padding = 0;
|
||||
VALIDATE_READ(bitStream.Read(padding));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoginRequest::Deserialize(RakNet::BitStream& bitStream) {
|
||||
LUWString usernameLUString;
|
||||
VALIDATE_READ(bitStream.Read(usernameLUString));
|
||||
username = usernameLUString.GetAsString();
|
||||
|
||||
LUWString passwordLUString(41);
|
||||
VALIDATE_READ(bitStream.Read(passwordLUString));
|
||||
password = passwordLUString.GetAsString();
|
||||
VALIDATE_READ(bitStream.Read(locale_id));
|
||||
VALIDATE_READ(bitStream.Read(clientOS));
|
||||
|
||||
LUWString memoryStatsLU(256);
|
||||
VALIDATE_READ(bitStream.Read(memoryStatsLU));
|
||||
computerInfo.memoryStats = memoryStatsLU.GetAsString();
|
||||
|
||||
LUWString videoCardLU(128);
|
||||
VALIDATE_READ(bitStream.Read(videoCardLU));
|
||||
computerInfo.videoCard = videoCardLU.GetAsString();
|
||||
|
||||
// Processor/CPU info
|
||||
VALIDATE_READ(bitStream.Read(computerInfo.processorInfo.count));
|
||||
VALIDATE_READ(bitStream.Read(computerInfo.processorInfo.type));
|
||||
VALIDATE_READ(bitStream.Read(computerInfo.processorInfo.level));
|
||||
VALIDATE_READ(bitStream.Read(computerInfo.processorInfo.revision));
|
||||
|
||||
// OS Info
|
||||
VALIDATE_READ(bitStream.Read(computerInfo.osVersionInfo.infoSize));
|
||||
VALIDATE_READ(bitStream.Read(computerInfo.osVersionInfo.majorVersion));
|
||||
VALIDATE_READ(bitStream.Read(computerInfo.osVersionInfo.minorVersion));
|
||||
VALIDATE_READ(bitStream.Read(computerInfo.osVersionInfo.buildNumber));
|
||||
VALIDATE_READ(bitStream.Read(computerInfo.osVersionInfo.platformID));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoginRequest::Handle() {
|
||||
LOG_DEBUG("Login Request from %s", username.c_str());
|
||||
LOG_DEBUG("Password: %s", password.c_str());
|
||||
|
||||
LOG_DEBUG("Locale ID: %s", StringifiedEnum::ToString(locale_id).data());
|
||||
|
||||
LOG_DEBUG("Operating System: %s", StringifiedEnum::ToString(clientOS).data());
|
||||
|
||||
LOG_DEBUG("Memory Stats [%s]", computerInfo.memoryStats.c_str());
|
||||
|
||||
LOG_DEBUG("VideoCard Info: [%s]", computerInfo.videoCard.c_str());
|
||||
|
||||
LOG_DEBUG("CPU Info: [#Processors: %i, Processor Type: %i, Processor Level: %i, Processor Revision: %i]",
|
||||
computerInfo.processorInfo.count,
|
||||
computerInfo.processorInfo.type,
|
||||
computerInfo.processorInfo.level,
|
||||
computerInfo.processorInfo.revision
|
||||
);
|
||||
|
||||
LOG_DEBUG("OS Info: [Size: %i, Version: %i.%i, Buid#: %i, platformID: %i]",
|
||||
computerInfo.osVersionInfo.infoSize,
|
||||
computerInfo.osVersionInfo.majorVersion,
|
||||
computerInfo.osVersionInfo.minorVersion,
|
||||
computerInfo.osVersionInfo.buildNumber,
|
||||
computerInfo.osVersionInfo.platformID
|
||||
);
|
||||
|
||||
ClientPackets::LoginResponse response;
|
||||
response.sysAddr = this->sysAddr;
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_START, 0);
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_CLIENT_OS, 0);
|
||||
response.events.push_back(LUString(Game::config->GetValue("event_1")));
|
||||
response.events.push_back(LUString(Game::config->GetValue("event_2")));
|
||||
response.events.push_back(LUString(Game::config->GetValue("event_3")));
|
||||
response.events.push_back(LUString(Game::config->GetValue("event_4")));
|
||||
response.events.push_back(LUString(Game::config->GetValue("event_5")));
|
||||
response.events.push_back(LUString(Game::config->GetValue("event_6")));
|
||||
response.events.push_back(LUString(Game::config->GetValue("event_7")));
|
||||
response.events.push_back(LUString(Game::config->GetValue("event_8")));
|
||||
response.version_major = GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_major")).value_or(ClientVersion::major);
|
||||
response.version_current = GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_current")).value_or(ClientVersion::current);
|
||||
response.version_minor = GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor")).value_or(ClientVersion::minor);
|
||||
|
||||
uint32_t sessionKey = GeneralUtils::GenerateRandomNumber<uint32_t>();
|
||||
std::string userHash = std::to_string(sessionKey);
|
||||
response.userKey = md5(userHash);
|
||||
|
||||
// Fetch account details
|
||||
auto accountInfo = Database::Get()->GetAccountInfo(username);
|
||||
|
||||
if (!accountInfo) {
|
||||
LOG("No user by name %s found!", username.c_str());
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
response.Send(sysAddr);
|
||||
return;
|
||||
}
|
||||
|
||||
//If we aren't running in live mode, then only GMs are allowed to enter:
|
||||
const auto& closedToNonDevs = Game::config->GetValue("closed_to_non_devs");
|
||||
if (closedToNonDevs.size() > 0 && bool(std::stoi(closedToNonDevs)) && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) {
|
||||
response.stamps.emplace_back(eStamps::GM_REQUIRED, 1);
|
||||
response.Send(sysAddr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Game::config->GetValue("dont_use_keys") != "1" && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) {
|
||||
//Check to see if we have a play key:
|
||||
if (accountInfo->playKeyId == 0) {
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
response.responseCode = eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH;
|
||||
response.errorMessage = "Your account doesn't have a play key associated with it!";
|
||||
response.Send(sysAddr);
|
||||
LOG("User %s tried to log in, but they don't have a play key.", username.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if the play key is _valid_:
|
||||
auto playKeyStatus = Database::Get()->IsPlaykeyActive(accountInfo->playKeyId);
|
||||
|
||||
if (!playKeyStatus) {
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
response.responseCode = eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH;
|
||||
response.errorMessage = "Your account doesn't have a valid play key associated with it!";
|
||||
response.Send(sysAddr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playKeyStatus.value()) {
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
response.responseCode = eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH;
|
||||
response.errorMessage = "Your play key has been disabled.";
|
||||
response.Send(sysAddr);
|
||||
LOG("User %s tried to log in, but their play key was disabled", username.c_str());
|
||||
return;
|
||||
}
|
||||
} else if (Game::config->GetValue("dont_use_keys") == "1" || accountInfo->maxGmLevel > eGameMasterLevel::CIVILIAN) {
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_BYPASS, 1);
|
||||
}
|
||||
|
||||
if (accountInfo->banned) {
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
response.responseCode = eLoginResponse::BANNED;
|
||||
response.errorMessage = "Your account has been banned.";
|
||||
response.Send(sysAddr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (accountInfo->locked) {
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
response.responseCode = eLoginResponse::ACCOUNT_LOCKED;
|
||||
response.errorMessage = "Your account is locked.";
|
||||
response.Send(sysAddr);
|
||||
return;
|
||||
}
|
||||
|
||||
bool loginSuccess = ::bcrypt_checkpw(password.c_str(), accountInfo->bcryptPassword.c_str()) == 0;
|
||||
|
||||
if (!loginSuccess) {
|
||||
response.stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
response.responseCode = eLoginResponse::WRONG_PASS;
|
||||
response.Send(sysAddr);
|
||||
} else {
|
||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, 0, 0, false, [this, response, sessionKey](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) mutable {
|
||||
response.responseCode = eLoginResponse::SUCCESS;
|
||||
response.worldServerIP = LUString(zoneIP);
|
||||
response.worldServerPort = zonePort;
|
||||
response.Send();
|
||||
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::MASTER, MessageType::Master::SET_SESSION_KEY);
|
||||
bitStream.Write(sessionKey);
|
||||
LOG_DEBUG("Sending session key for %s to master server", this->username.c_str());
|
||||
bitStream.Write(LUString(this->username));
|
||||
Game::server->SendToMaster(bitStream);
|
||||
});
|
||||
|
||||
for (auto const code : claimCodes) {
|
||||
Database::Get()->InsertRewardCode(accountInfo->id, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Non Stuct Functions
|
||||
void AuthPackets::LoadClaimCodes() {
|
||||
if (!claimCodes.empty()) return;
|
||||
if(!claimCodes.empty()) return;
|
||||
auto rcstring = Game::config->GetValue("rewardcodes");
|
||||
auto codestrings = GeneralUtils::SplitString(rcstring, ',');
|
||||
for (auto const& codestring : codestrings) {
|
||||
for(auto const &codestring: codestrings){
|
||||
const auto code = GeneralUtils::TryParse<uint32_t>(codestring);
|
||||
|
||||
if (code && code.value() != -1) claimCodes.push_back(code.value());
|
||||
}
|
||||
}
|
||||
|
||||
// Non Stuct Functions
|
||||
void AuthPackets::Handle(RakNet::BitStream& inStream, const SystemAddress& sysAddr) {
|
||||
AuthLUBitStream authLUBitStream;
|
||||
if (!authLUBitStream.Deserialize(inStream)) return;
|
||||
void AuthPackets::HandleHandshake(dServer* server, Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER
|
||||
uint32_t clientVersion = 0;
|
||||
inStream.Read(clientVersion);
|
||||
inStream.IgnoreBytes(4);
|
||||
|
||||
auto it = g_Handlers.find(authLUBitStream.messageType);
|
||||
if (it != g_Handlers.end()) {
|
||||
auto request = it->second();
|
||||
request->sysAddr = sysAddr;
|
||||
if (!request->Deserialize(inStream)) {
|
||||
LOG_DEBUG("Error Reading Auth Packet: %s", StringifiedEnum::ToString(authLUBitStream.messageType).data());
|
||||
ServiceType serviceType;
|
||||
inStream.Read(serviceType);
|
||||
if (serviceType != ServiceType::CLIENT) LOG("WARNING: Service is not a Client!");
|
||||
inStream.IgnoreBytes(2);
|
||||
|
||||
uint32_t processID;
|
||||
inStream.Read(processID);
|
||||
|
||||
uint16_t port;
|
||||
inStream.Read(port);
|
||||
if (port != packet->systemAddress.port) LOG("WARNING: Port written in packet does not match the port the client is connecting over!");
|
||||
|
||||
inStream.IgnoreBytes(33);
|
||||
|
||||
LOG_DEBUG("Client Data [Version: %i, Service: %s, Process: %u, Port: %u, Sysaddr Port: %u]", clientVersion, StringifiedEnum::ToString(serviceType).data(), processID, port, packet->systemAddress.port);
|
||||
|
||||
SendHandshake(server, packet->systemAddress, server->GetIP(), server->GetPort(), server->GetServerType());
|
||||
}
|
||||
|
||||
void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, const std::string& nextServerIP, uint16_t nextServerPort, const ServiceType serverType) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::COMMON, MessageType::Server::VERSION_CONFIRM);
|
||||
|
||||
const auto& clientNetVersionString = Game::config->GetValue("client_net_version");
|
||||
const uint32_t clientNetVersion = GeneralUtils::TryParse<uint32_t>(clientNetVersionString).value_or(171022);
|
||||
|
||||
bitStream.Write<uint32_t>(clientNetVersion);
|
||||
bitStream.Write<uint32_t>(861228100);
|
||||
bitStream.Write(static_cast<uint32_t>(serverType));
|
||||
bitStream.Write<uint64_t>(219818307120);
|
||||
|
||||
server->Send(bitStream, sysAddr, false);
|
||||
}
|
||||
|
||||
std::string CleanReceivedString(const std::string& str) {
|
||||
std::string toReturn = str;
|
||||
const auto removed = std::ranges::find_if(toReturn, [](unsigned char c) { return isprint(c) == 0 && isblank(c) == 0; });
|
||||
toReturn.erase(removed, toReturn.end());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
|
||||
std::vector<Stamp> stamps;
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_START, 0);
|
||||
|
||||
LUWString usernameLUString;
|
||||
inStream.Read(usernameLUString);
|
||||
const auto username = usernameLUString.GetAsString();
|
||||
|
||||
LUWString password(41);
|
||||
inStream.Read(password);
|
||||
|
||||
LanguageCodeID locale_id;
|
||||
inStream.Read(locale_id);
|
||||
LOG_DEBUG("Locale ID: %s", StringifiedEnum::ToString(locale_id).data());
|
||||
|
||||
ClientOS clientOS;
|
||||
inStream.Read(clientOS);
|
||||
LOG_DEBUG("Operating System: %s", StringifiedEnum::ToString(clientOS).data());
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_CLIENT_OS, 0);
|
||||
|
||||
LUWString memoryStats(256);
|
||||
inStream.Read(memoryStats);
|
||||
LOG_DEBUG("Memory Stats [%s]", CleanReceivedString(memoryStats.GetAsString()).c_str());
|
||||
|
||||
LUWString videoCard(128);
|
||||
inStream.Read(videoCard);
|
||||
LOG_DEBUG("VideoCard Info: [%s]", CleanReceivedString(videoCard.GetAsString()).c_str());
|
||||
|
||||
// Processor/CPU info
|
||||
uint32_t numOfProcessors;
|
||||
inStream.Read(numOfProcessors);
|
||||
uint32_t processorType;
|
||||
inStream.Read(processorType);
|
||||
uint16_t processorLevel;
|
||||
inStream.Read(processorLevel);
|
||||
uint16_t processorRevision;
|
||||
inStream.Read(processorRevision);
|
||||
LOG_DEBUG("CPU Info: [#Processors: %i, Processor Type: %i, Processor Level: %i, Processor Revision: %i]", numOfProcessors, processorType, processorLevel, processorRevision);
|
||||
|
||||
// OS Info
|
||||
uint32_t osVersionInfoSize;
|
||||
inStream.Read(osVersionInfoSize);
|
||||
uint32_t majorVersion;
|
||||
inStream.Read(majorVersion);
|
||||
uint32_t minorVersion;
|
||||
inStream.Read(minorVersion);
|
||||
uint32_t buildNumber;
|
||||
inStream.Read(buildNumber);
|
||||
uint32_t platformID;
|
||||
inStream.Read(platformID);
|
||||
LOG_DEBUG("OS Info: [Size: %i, Major: %i, Minor %i, Buid#: %i, platformID: %i]", osVersionInfoSize, majorVersion, minorVersion, buildNumber, platformID);
|
||||
|
||||
// Fetch account details
|
||||
auto accountInfo = Database::Get()->GetAccountInfo(username);
|
||||
|
||||
if (!accountInfo) {
|
||||
LOG("No user by name %s found!", username.c_str());
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::INVALID_USER, "", "", 2001, username, stamps);
|
||||
return;
|
||||
}
|
||||
|
||||
//If we aren't running in live mode, then only GMs are allowed to enter:
|
||||
const auto& closedToNonDevs = Game::config->GetValue("closed_to_non_devs");
|
||||
if (closedToNonDevs.size() > 0 && bool(std::stoi(closedToNonDevs)) && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) {
|
||||
stamps.emplace_back(eStamps::GM_REQUIRED, 1);
|
||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "The server is currently only open to developers.", "", 2001, username, stamps);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Game::config->GetValue("dont_use_keys") != "1" && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) {
|
||||
//Check to see if we have a play key:
|
||||
if (accountInfo->playKeyId == 0) {
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username, stamps);
|
||||
LOG("User %s tried to log in, but they don't have a play key.", username.c_str());
|
||||
return;
|
||||
}
|
||||
LOG_DEBUG("Received Auth Packet: %s", StringifiedEnum::ToString(authLUBitStream.messageType).data());
|
||||
request->Handle();
|
||||
|
||||
//Check if the play key is _valid_:
|
||||
auto playKeyStatus = Database::Get()->IsPlaykeyActive(accountInfo->playKeyId);
|
||||
|
||||
if (!playKeyStatus) {
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a valid play key associated with it!", "", 2001, username, stamps);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playKeyStatus.value()) {
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username, stamps);
|
||||
LOG("User %s tried to log in, but their play key was disabled", username.c_str());
|
||||
return;
|
||||
}
|
||||
} else if (Game::config->GetValue("dont_use_keys") == "1" || accountInfo->maxGmLevel > eGameMasterLevel::CIVILIAN){
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_BYPASS, 1);
|
||||
}
|
||||
|
||||
if (accountInfo->banned) {
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::BANNED, "", "", 2001, username, stamps);
|
||||
return;
|
||||
}
|
||||
|
||||
if (accountInfo->locked) {
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::ACCOUNT_LOCKED, "", "", 2001, username, stamps);
|
||||
return;
|
||||
}
|
||||
|
||||
bool loginSuccess = ::bcrypt_checkpw(password.GetAsString().c_str(), accountInfo->bcryptPassword.c_str()) == 0;
|
||||
|
||||
if (!loginSuccess) {
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_ERROR, 1);
|
||||
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::WRONG_PASS, "", "", 2001, username, stamps);
|
||||
LOG("Wrong password used");
|
||||
} else {
|
||||
LOG_DEBUG("Unhandled Auth Packet with ID: %i", authLUBitStream.messageType);
|
||||
SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main
|
||||
|
||||
if (!server->GetIsConnectedToMaster()) {
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_WORLD_DISCONNECT, 1);
|
||||
AuthPackets::SendLoginResponse(server, system, eLoginResponse::GENERAL_FAILED, "", "", 0, username, stamps);
|
||||
return;
|
||||
}
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH, 1);
|
||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, [system, server, username, stamps](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) mutable {
|
||||
AuthPackets::SendLoginResponse(server, system, eLoginResponse::SUCCESS, "", zoneIP, zonePort, username, stamps);
|
||||
});
|
||||
}
|
||||
|
||||
for(auto const code: claimCodes){
|
||||
Database::Get()->InsertRewardCode(accountInfo->id, code);
|
||||
}
|
||||
}
|
||||
|
||||
void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username, std::vector<Stamp>& stamps) {
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_IM_LOGIN_START, 1);
|
||||
RakNet::BitStream loginResponse;
|
||||
BitStreamUtils::WriteHeader(loginResponse, ServiceType::CLIENT, MessageType::Client::LOGIN_RESPONSE);
|
||||
|
||||
loginResponse.Write(responseCode);
|
||||
|
||||
// Event Gating
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_1")));
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_2")));
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_3")));
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_4")));
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_5")));
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_6")));
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_7")));
|
||||
loginResponse.Write(LUString(Game::config->GetValue("event_8")));
|
||||
|
||||
const uint16_t version_major =
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_major")).value_or(ClientVersion::major);
|
||||
const uint16_t version_current =
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_current")).value_or(ClientVersion::current);
|
||||
const uint16_t version_minor =
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor")).value_or(ClientVersion::minor);
|
||||
|
||||
loginResponse.Write(version_major);
|
||||
loginResponse.Write(version_current);
|
||||
loginResponse.Write(version_minor);
|
||||
|
||||
// Writes the user key
|
||||
uint32_t sessionKey = GeneralUtils::GenerateRandomNumber<uint32_t>();
|
||||
std::string userHash = std::to_string(sessionKey);
|
||||
userHash = md5(userHash);
|
||||
loginResponse.Write(LUWString(userHash));
|
||||
|
||||
// World Server IP
|
||||
loginResponse.Write(LUString(wServerIP));
|
||||
// Chat Server IP (unused)
|
||||
loginResponse.Write(LUString(""));
|
||||
|
||||
// World Server Redirect port
|
||||
loginResponse.Write(wServerPort);
|
||||
// Char Server Redirect port (unused)
|
||||
loginResponse.Write(static_cast<uint16_t>(0));
|
||||
|
||||
// CDN Key
|
||||
loginResponse.Write(LUString(""));
|
||||
|
||||
// CDN Ticket
|
||||
loginResponse.Write(LUString("00000000-0000-0000-0000-000000000000", 37));
|
||||
|
||||
// Language
|
||||
loginResponse.Write(Language::en_US);
|
||||
|
||||
// Write the localization
|
||||
loginResponse.Write(LUString("US", 3));
|
||||
|
||||
loginResponse.Write<uint8_t>(false); // Just upgraded from F2P
|
||||
loginResponse.Write<uint8_t>(false); // User is F2P
|
||||
loginResponse.Write<uint64_t>(0); // Time Remaining in F2P
|
||||
|
||||
// Write custom error message
|
||||
loginResponse.Write<uint16_t>(errorMsg.length());
|
||||
loginResponse.Write(LUWString(errorMsg, static_cast<uint32_t>(errorMsg.length())));
|
||||
|
||||
stamps.emplace_back(eStamps::PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH, 1);
|
||||
|
||||
loginResponse.Write<uint32_t>((sizeof(Stamp) * stamps.size()) + sizeof(uint32_t));
|
||||
for (auto& stamp : stamps) stamp.Serialize(loginResponse);
|
||||
|
||||
server->Send(loginResponse, sysAddr, false);
|
||||
//Inform the master server that we've created a session for this user:
|
||||
if (responseCode == eLoginResponse::SUCCESS) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::MASTER, MessageType::Master::SET_SESSION_KEY);
|
||||
bitStream.Write(sessionKey);
|
||||
bitStream.Write(LUString(username));
|
||||
server->SendToMaster(bitStream);
|
||||
|
||||
LOG("Set sessionKey: %i for user %s", sessionKey, username.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,67 @@
|
||||
#include "dCommonVars.h"
|
||||
#include "dNetCommon.h"
|
||||
#include "magic_enum.hpp"
|
||||
#include "BitStream.h"
|
||||
#include "RakNetTypes.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "MessageType/Auth.h"
|
||||
|
||||
enum class eLoginResponse : uint8_t;
|
||||
enum class ServiceType : uint16_t;
|
||||
class dServer;
|
||||
|
||||
enum class eStamps : uint32_t {
|
||||
PASSPORT_AUTH_START,
|
||||
PASSPORT_AUTH_BYPASS,
|
||||
PASSPORT_AUTH_ERROR,
|
||||
PASSPORT_AUTH_DB_SELECT_START,
|
||||
PASSPORT_AUTH_DB_SELECT_FINISH,
|
||||
PASSPORT_AUTH_DB_INSERT_START,
|
||||
PASSPORT_AUTH_DB_INSERT_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_COMMUNICATION_START,
|
||||
PASSPORT_AUTH_LEGOINT_RECEIVED,
|
||||
PASSPORT_AUTH_LEGOINT_THREAD_SPAWN,
|
||||
PASSPORT_AUTH_LEGOINT_WEBSERVICE_START,
|
||||
PASSPORT_AUTH_LEGOINT_WEBSERVICE_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_LEGOCLUB_START,
|
||||
PASSPORT_AUTH_LEGOINT_LEGOCLUB_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_THREAD_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_REPLY,
|
||||
PASSPORT_AUTH_LEGOINT_ERROR,
|
||||
PASSPORT_AUTH_LEGOINT_COMMUNICATION_END,
|
||||
PASSPORT_AUTH_LEGOINT_DISCONNECT,
|
||||
PASSPORT_AUTH_WORLD_COMMUNICATION_START,
|
||||
PASSPORT_AUTH_CLIENT_OS,
|
||||
PASSPORT_AUTH_WORLD_PACKET_RECEIVED,
|
||||
PASSPORT_AUTH_IM_COMMUNICATION_START,
|
||||
PASSPORT_AUTH_IM_LOGIN_START,
|
||||
PASSPORT_AUTH_IM_LOGIN_ALREADY_LOGGED_IN,
|
||||
PASSPORT_AUTH_IM_OTHER_LOGIN_REMOVED,
|
||||
PASSPORT_AUTH_IM_LOGIN_QUEUED,
|
||||
PASSPORT_AUTH_IM_LOGIN_RESPONSE,
|
||||
PASSPORT_AUTH_IM_COMMUNICATION_END,
|
||||
PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH,
|
||||
PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH,
|
||||
PASSPORT_AUTH_WORLD_DISCONNECT,
|
||||
NO_LEGO_INTERFACE,
|
||||
DB_ERROR,
|
||||
GM_REQUIRED,
|
||||
NO_LEGO_WEBSERVICE_XML,
|
||||
LEGO_WEBSERVICE_TIMEOUT,
|
||||
LEGO_WEBSERVICE_ERROR,
|
||||
NO_WORLD_SERVER
|
||||
};
|
||||
|
||||
struct Stamp {
|
||||
eStamps type;
|
||||
uint32_t value;
|
||||
uint64_t timestamp;
|
||||
|
||||
Stamp(eStamps type, uint32_t value, uint64_t timestamp = time(nullptr)){
|
||||
this->type = type;
|
||||
this->value = value;
|
||||
this->timestamp = timestamp;
|
||||
}
|
||||
|
||||
void Serialize(RakNet::BitStream& outBitStream);
|
||||
};
|
||||
|
||||
enum class ClientOS : uint8_t {
|
||||
UNKNOWN,
|
||||
WINDOWS,
|
||||
@@ -32,50 +84,20 @@ struct magic_enum::customize::enum_range<LanguageCodeID> {
|
||||
static constexpr int max = 2057;
|
||||
};
|
||||
|
||||
enum class Language : uint32_t {
|
||||
en_US,
|
||||
pl_US,
|
||||
de_DE,
|
||||
en_GB,
|
||||
};
|
||||
|
||||
namespace AuthPackets {
|
||||
void HandleHandshake(dServer* server, Packet* packet);
|
||||
void SendHandshake(dServer* server, const SystemAddress& sysAddr, const std::string& nextServerIP, uint16_t nextServerPort, const ServiceType serverType);
|
||||
|
||||
struct AuthLUBitStream : public LUBitStream {
|
||||
MessageType::Auth messageType = MessageType::Auth::LOGIN_REQUEST;
|
||||
|
||||
AuthLUBitStream() : LUBitStream(ServiceType::AUTH) {};
|
||||
AuthLUBitStream(MessageType::Auth _messageType) : LUBitStream(ServiceType::AUTH), messageType{_messageType} {};
|
||||
|
||||
virtual void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
virtual bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
virtual void Handle() override {};
|
||||
};
|
||||
|
||||
struct LoginRequest : public AuthLUBitStream {
|
||||
std::string username;
|
||||
std::string password;
|
||||
LanguageCodeID locale_id;
|
||||
ClientOS clientOS;
|
||||
struct ComputerInfo {
|
||||
std::string memoryStats;
|
||||
std::string videoCard;
|
||||
struct ProcessorInfo {
|
||||
uint32_t count = 0;
|
||||
uint32_t type = 0;
|
||||
uint16_t level = 0;
|
||||
uint16_t revision = 0;
|
||||
} processorInfo;
|
||||
struct OSVersionInfo {
|
||||
uint32_t infoSize = 0;
|
||||
uint32_t majorVersion = 0;
|
||||
uint32_t minorVersion = 0;
|
||||
uint32_t buildNumber = 0;
|
||||
uint32_t platformID = 0;
|
||||
} osVersionInfo;
|
||||
} computerInfo;
|
||||
|
||||
LoginRequest() : AuthLUBitStream(MessageType::Auth::LOGIN_REQUEST) {}
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
// Non struct functions
|
||||
void HandleLoginRequest(dServer* server, Packet* packet);
|
||||
void SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username, std::vector<Stamp>& stamps);
|
||||
void LoadClaimCodes();
|
||||
void Handle(RakNet::BitStream& inStream, const SystemAddress& sysAddr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,18 @@
|
||||
|
||||
void LUBitStream::WriteHeader(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write<MessageID>(ID_USER_PACKET_ENUM);
|
||||
bitStream.Write(this->serviceType);
|
||||
bitStream.Write(this->connectionType);
|
||||
bitStream.Write(this->internalPacketID);
|
||||
bitStream.Write<uint8_t>(0); // padding
|
||||
}
|
||||
|
||||
bool LUBitStream::ReadHeader(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(this->rakNetID));
|
||||
VALIDATE_READ(bitStream.Read(this->serviceType));
|
||||
MessageID messageID;
|
||||
bitStream.Read(messageID);
|
||||
if (messageID != ID_USER_PACKET_ENUM) return false;
|
||||
VALIDATE_READ(bitStream.Read(this->connectionType));
|
||||
VALIDATE_READ(bitStream.Read(this->internalPacketID));
|
||||
bitStream.IgnoreBytes(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,22 +47,20 @@ struct LUWString {
|
||||
};
|
||||
|
||||
struct LUBitStream {
|
||||
// Common header data that is serialized
|
||||
MessageID rakNetID = ID_USER_PACKET_ENUM;
|
||||
ServiceType serviceType = ServiceType::UNKNOWN;
|
||||
|
||||
SystemAddress sysAddr = UNASSIGNED_SYSTEM_ADDRESS;
|
||||
ServiceType connectionType = ServiceType::UNKNOWN;
|
||||
uint32_t internalPacketID = 0xFFFFFFFF;
|
||||
|
||||
LUBitStream() = default;
|
||||
|
||||
LUBitStream(ServiceType serviceType) {
|
||||
this->serviceType = serviceType;
|
||||
template <typename T>
|
||||
LUBitStream(ServiceType connectionType, T internalPacketID) {
|
||||
this->connectionType = connectionType;
|
||||
this->internalPacketID = static_cast<uint32_t>(internalPacketID);
|
||||
}
|
||||
|
||||
void WriteHeader(RakNet::BitStream& bitStream) const;
|
||||
bool ReadHeader(RakNet::BitStream& bitStream);
|
||||
void Send(const SystemAddress& sysAddr) const;
|
||||
void Send() const { Send(this->sysAddr); };
|
||||
void Broadcast() const { Send(UNASSIGNED_SYSTEM_ADDRESS); };
|
||||
|
||||
virtual void Serialize(RakNet::BitStream& bitStream) const {}
|
||||
|
||||
@@ -2,14 +2,12 @@ set(DNET_SOURCES "AuthPackets.cpp"
|
||||
"BitStreamUtils.cpp"
|
||||
"ChatPackets.cpp"
|
||||
"ClientPackets.cpp"
|
||||
"CommonPackets.cpp"
|
||||
"dServer.cpp"
|
||||
"MailInfo.cpp"
|
||||
"MasterPackets.cpp"
|
||||
"PacketUtils.cpp"
|
||||
"WorldPackets.cpp"
|
||||
"ZoneInstanceManager.cpp"
|
||||
)
|
||||
"ZoneInstanceManager.cpp")
|
||||
|
||||
add_library(dNet STATIC ${DNET_SOURCES})
|
||||
target_link_libraries(dNet PRIVATE bcrypt MD5 glm::glm)
|
||||
|
||||
@@ -12,20 +12,6 @@
|
||||
#include "ServiceType.h"
|
||||
#include "MessageType/Chat.h"
|
||||
|
||||
namespace ChatPackets {
|
||||
// Struct Functions
|
||||
void ChatLUBitStream::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(this->messageType);
|
||||
bitStream.Write<uint8_t>(0); // padding
|
||||
}
|
||||
bool ChatLUBitStream::Deserialize(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(this->messageType));
|
||||
uint8_t padding = 0;
|
||||
VALIDATE_READ(bitStream.Read(padding));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void ShowAllRequest::Serialize(RakNet::BitStream& bitStream) {
|
||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::CHAT, MessageType::Chat::SHOW_ALL);
|
||||
bitStream.Write(this->requestor);
|
||||
@@ -114,7 +100,6 @@ void ChatPackets::SendMessageFail(const SystemAddress& sysAddr) {
|
||||
|
||||
namespace ChatPackets {
|
||||
void Announcement::Serialize(RakNet::BitStream& bitStream) const {
|
||||
ChatLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write<uint32_t>(title.size());
|
||||
bitStream.Write(title);
|
||||
bitStream.Write<uint32_t>(message.size());
|
||||
@@ -123,7 +108,6 @@ namespace ChatPackets {
|
||||
}
|
||||
|
||||
void ChatPackets::AchievementNotify::Serialize(RakNet::BitStream& bitstream) const {
|
||||
ChatLUBitStream::Serialize(bitstream);
|
||||
bitstream.Write<uint64_t>(0); // Packing
|
||||
bitstream.Write<uint32_t>(0); // Packing
|
||||
bitstream.Write<uint8_t>(0); // Packing
|
||||
@@ -149,7 +133,6 @@ bool ChatPackets::AchievementNotify::Deserialize(RakNet::BitStream& bitstream) {
|
||||
}
|
||||
|
||||
void ChatPackets::TeamInviteInitialResponse::Serialize(RakNet::BitStream& bitstream) const {
|
||||
ClientLUBitStream::Serialize(bitstream);
|
||||
bitstream.Write<uint8_t>(inviteFailedToSend);
|
||||
bitstream.Write(playerName);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ struct SystemAddress;
|
||||
#include "dCommonVars.h"
|
||||
#include "MessageType/Chat.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "ClientPackets.h"
|
||||
|
||||
struct ShowAllRequest{
|
||||
LWOOBJID requestor = LWOOBJID_EMPTY;
|
||||
@@ -31,39 +30,28 @@ struct FindPlayerRequest{
|
||||
|
||||
namespace ChatPackets {
|
||||
|
||||
struct ChatLUBitStream : public LUBitStream {
|
||||
MessageType::Chat messageType = MessageType::Chat::GENERAL_CHAT_MESSAGE;
|
||||
|
||||
ChatLUBitStream() : LUBitStream(ServiceType::CHAT) {};
|
||||
ChatLUBitStream(MessageType::Chat _messageType) : LUBitStream(ServiceType::CHAT), messageType{_messageType} {};
|
||||
|
||||
virtual void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
virtual bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
virtual void Handle() override {};
|
||||
};
|
||||
|
||||
struct Announcement : public ChatLUBitStream {
|
||||
struct Announcement : public LUBitStream {
|
||||
std::string title;
|
||||
std::string message;
|
||||
|
||||
Announcement() : ChatLUBitStream(MessageType::Chat::GM_ANNOUNCE) {};
|
||||
Announcement() : LUBitStream(ServiceType::CHAT, MessageType::Chat::GM_ANNOUNCE) {};
|
||||
virtual void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct AchievementNotify : public ChatLUBitStream {
|
||||
struct AchievementNotify : public LUBitStream {
|
||||
LUWString targetPlayerName{};
|
||||
uint32_t missionEmailID{};
|
||||
LWOOBJID earningPlayerID{};
|
||||
LUWString earnerName{};
|
||||
AchievementNotify() : ChatLUBitStream(MessageType::Chat::ACHIEVEMENT_NOTIFY) {}
|
||||
AchievementNotify() : LUBitStream(ServiceType::CHAT, MessageType::Chat::ACHIEVEMENT_NOTIFY) {}
|
||||
void Serialize(RakNet::BitStream& bitstream) const override;
|
||||
bool Deserialize(RakNet::BitStream& bitstream) override;
|
||||
};
|
||||
|
||||
struct TeamInviteInitialResponse : public ClientPackets::ClientLUBitStream {
|
||||
struct TeamInviteInitialResponse : public LUBitStream {
|
||||
bool inviteFailedToSend{};
|
||||
LUWString playerName{};
|
||||
TeamInviteInitialResponse() : ClientPackets::ClientLUBitStream(MessageType::Client::TEAM_INVITE_INITIAL_RESPONSE) {}
|
||||
TeamInviteInitialResponse() : LUBitStream(ServiceType::CLIENT, MessageType::Client::TEAM_INVITE_INITIAL_RESPONSE) {}
|
||||
|
||||
void Serialize(RakNet::BitStream& bitstream) const override;
|
||||
// No Deserialize needed on our end
|
||||
|
||||
@@ -6,58 +6,6 @@
|
||||
#include "ClientPackets.h"
|
||||
#include "dCommonVars.h"
|
||||
#include "PositionUpdate.h"
|
||||
#include "StringifiedEnum.h"
|
||||
|
||||
|
||||
namespace ClientPackets {
|
||||
void Stamp::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(type);
|
||||
bitStream.Write(value);
|
||||
bitStream.Write(timestamp);
|
||||
};
|
||||
|
||||
void ClientLUBitStream::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(this->messageType);
|
||||
bitStream.Write<uint8_t>(0); // padding
|
||||
}
|
||||
bool ClientLUBitStream::Deserialize(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(this->messageType));
|
||||
uint8_t padding = 0;
|
||||
VALIDATE_READ(bitStream.Read(padding)); return true;
|
||||
}
|
||||
|
||||
void LoginResponse::Serialize(RakNet::BitStream& bitStream) const {
|
||||
ClientLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write(responseCode);
|
||||
bitStream.Write(events[0]);
|
||||
bitStream.Write(events[1]);
|
||||
bitStream.Write(events[2]);
|
||||
bitStream.Write(events[3]);
|
||||
bitStream.Write(events[4]);
|
||||
bitStream.Write(events[5]);
|
||||
bitStream.Write(events[6]);
|
||||
bitStream.Write(events[7]);
|
||||
bitStream.Write(version_major);
|
||||
bitStream.Write(version_current);
|
||||
bitStream.Write(version_minor);
|
||||
bitStream.Write(userKey);
|
||||
bitStream.Write(worldServerIP);
|
||||
bitStream.Write(chatServerIP);
|
||||
bitStream.Write(worldServerPort);
|
||||
bitStream.Write(chatServerPort);
|
||||
bitStream.Write(cdnKey);
|
||||
bitStream.Write(cdnTicket);
|
||||
bitStream.Write(language);
|
||||
bitStream.Write(localization);
|
||||
bitStream.Write(static_cast<uint8_t>(justUpgradedFromF2P));
|
||||
bitStream.Write(static_cast<uint8_t>(isF2P));
|
||||
bitStream.Write(membershipTimeLeft);
|
||||
bitStream.Write<uint16_t>(errorMessage.length());
|
||||
bitStream.Write(LUWString(errorMessage, static_cast<uint32_t>(errorMessage.length())));
|
||||
bitStream.Write<uint32_t>((sizeof(Stamp) * stamps.size()) + sizeof(uint32_t));
|
||||
for (const auto& stampData : stamps) stampData.Serialize(bitStream);
|
||||
};
|
||||
}
|
||||
|
||||
ChatMessage ClientPackets::HandleChatMessage(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "BitStreamUtils.h"
|
||||
#include "MessageType/Client.h"
|
||||
|
||||
class PositionUpdate;
|
||||
|
||||
@@ -28,132 +26,11 @@ struct ChatModerationRequest {
|
||||
std::string message;
|
||||
};
|
||||
|
||||
|
||||
enum class eLoginResponse : uint8_t {
|
||||
GENERAL_FAILED = 0,
|
||||
SUCCESS,
|
||||
BANNED,
|
||||
// Unused 3
|
||||
// Unused 4
|
||||
PERMISSIONS_NOT_HIGH_ENOUGH = 5,
|
||||
INVALID_USER,
|
||||
ACCOUNT_LOCKED,
|
||||
WRONG_PASS,
|
||||
ACCOUNT_ACTIVATION_PENDING,
|
||||
ACCOUNT_DISABLED,
|
||||
GAME_TIME_EXPIRED,
|
||||
FREE_TRIAL_ENDED,
|
||||
PLAY_SCHEDULE_TIME_UP,
|
||||
ACCOUNT_NOT_ACTIVATED
|
||||
};
|
||||
|
||||
enum class eStamps : uint32_t {
|
||||
PASSPORT_AUTH_START,
|
||||
PASSPORT_AUTH_BYPASS,
|
||||
PASSPORT_AUTH_ERROR,
|
||||
PASSPORT_AUTH_DB_SELECT_START,
|
||||
PASSPORT_AUTH_DB_SELECT_FINISH,
|
||||
PASSPORT_AUTH_DB_INSERT_START,
|
||||
PASSPORT_AUTH_DB_INSERT_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_COMMUNICATION_START,
|
||||
PASSPORT_AUTH_LEGOINT_RECEIVED,
|
||||
PASSPORT_AUTH_LEGOINT_THREAD_SPAWN,
|
||||
PASSPORT_AUTH_LEGOINT_WEBSERVICE_START,
|
||||
PASSPORT_AUTH_LEGOINT_WEBSERVICE_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_LEGOCLUB_START,
|
||||
PASSPORT_AUTH_LEGOINT_LEGOCLUB_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_THREAD_FINISH,
|
||||
PASSPORT_AUTH_LEGOINT_REPLY,
|
||||
PASSPORT_AUTH_LEGOINT_ERROR,
|
||||
PASSPORT_AUTH_LEGOINT_COMMUNICATION_END,
|
||||
PASSPORT_AUTH_LEGOINT_DISCONNECT,
|
||||
PASSPORT_AUTH_WORLD_COMMUNICATION_START,
|
||||
PASSPORT_AUTH_CLIENT_OS,
|
||||
PASSPORT_AUTH_WORLD_PACKET_RECEIVED,
|
||||
PASSPORT_AUTH_IM_COMMUNICATION_START,
|
||||
PASSPORT_AUTH_IM_LOGIN_START,
|
||||
PASSPORT_AUTH_IM_LOGIN_ALREADY_LOGGED_IN,
|
||||
PASSPORT_AUTH_IM_OTHER_LOGIN_REMOVED,
|
||||
PASSPORT_AUTH_IM_LOGIN_QUEUED,
|
||||
PASSPORT_AUTH_IM_LOGIN_RESPONSE,
|
||||
PASSPORT_AUTH_IM_COMMUNICATION_END,
|
||||
PASSPORT_AUTH_WORLD_SESSION_CONFIRM_TO_AUTH,
|
||||
PASSPORT_AUTH_WORLD_COMMUNICATION_FINISH,
|
||||
PASSPORT_AUTH_WORLD_DISCONNECT,
|
||||
NO_LEGO_INTERFACE,
|
||||
DB_ERROR,
|
||||
GM_REQUIRED,
|
||||
NO_LEGO_WEBSERVICE_XML,
|
||||
LEGO_WEBSERVICE_TIMEOUT,
|
||||
LEGO_WEBSERVICE_ERROR,
|
||||
NO_WORLD_SERVER
|
||||
};
|
||||
|
||||
enum class Language : uint32_t {
|
||||
en_US,
|
||||
pl_US,
|
||||
de_DE,
|
||||
en_GB,
|
||||
};
|
||||
|
||||
namespace ClientPackets {
|
||||
|
||||
// Structs
|
||||
struct ClientLUBitStream : public LUBitStream {
|
||||
MessageType::Client messageType = MessageType::Client::LOGIN_RESPONSE;
|
||||
|
||||
ClientLUBitStream() : LUBitStream(ServiceType::CLIENT) {};
|
||||
ClientLUBitStream(MessageType::Client _messageType) : LUBitStream(ServiceType::CLIENT), messageType{_messageType} {};
|
||||
virtual void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
virtual bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
virtual void Handle() override {};
|
||||
};
|
||||
|
||||
struct Stamp {
|
||||
eStamps type;
|
||||
uint32_t value;
|
||||
uint64_t timestamp;
|
||||
|
||||
Stamp(eStamps type, uint32_t value, uint64_t timestamp = time(nullptr)) {
|
||||
this->type = type;
|
||||
this->value = value;
|
||||
this->timestamp = timestamp;
|
||||
}
|
||||
|
||||
void Serialize(RakNet::BitStream& bitStream) const;
|
||||
};
|
||||
|
||||
struct LoginResponse : public ClientLUBitStream {
|
||||
eLoginResponse responseCode = eLoginResponse::GENERAL_FAILED;
|
||||
std::vector<LUString> events;
|
||||
uint16_t version_major = 0;
|
||||
uint16_t version_current = 0;
|
||||
uint16_t version_minor = 0;
|
||||
LUWString userKey;
|
||||
LUString worldServerIP;
|
||||
LUString chatServerIP = LUString(""); // unused
|
||||
uint16_t worldServerPort = 0;
|
||||
uint16_t chatServerPort = 0; // unused
|
||||
LUString cdnKey = LUString("");
|
||||
LUString cdnTicket = LUString("00000000-0000-0000-0000-000000000000", 37);
|
||||
Language language = Language::en_US;
|
||||
LUString localization = LUString("US", 3);
|
||||
bool justUpgradedFromF2P = false; // written as uint8_t
|
||||
bool isF2P = false; // written as uint8_t
|
||||
uint64_t membershipTimeLeft = 0;
|
||||
std::string errorMessage;
|
||||
std::vector<Stamp> stamps;
|
||||
|
||||
LoginResponse() : ClientLUBitStream(MessageType::Client::LOGIN_RESPONSE) {}
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
|
||||
ChatMessage HandleChatMessage(Packet* packet);
|
||||
PositionUpdate HandleClientPositionUpdate(Packet* packet);
|
||||
ChatModerationRequest HandleChatModerationRequest(Packet* packet);
|
||||
int32_t SendTop5HelpIssues(Packet* packet);
|
||||
};
|
||||
|
||||
|
||||
#endif // CLIENTPACKETS_H
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
|
||||
#include "CommonPackets.h"
|
||||
#include "dServer.h"
|
||||
#include "Logger.h"
|
||||
#include "Game.h"
|
||||
#include "dServer.h"
|
||||
#include "dConfig.h"
|
||||
#include "StringifiedEnum.h"
|
||||
#include "GeneralUtils.h"
|
||||
|
||||
|
||||
namespace CommonPackets {
|
||||
std::map<MessageType::Server, std::function<std::unique_ptr<LUBitStream>()>> g_Handlers = {
|
||||
{MessageType::Server::VERSION_CONFIRM, []() {
|
||||
return std::make_unique<VersionConfirm>();
|
||||
}},
|
||||
{MessageType::Server::DISCONNECT_NOTIFY, []() {
|
||||
return std::make_unique<DisconnectNotify>();
|
||||
}},
|
||||
{MessageType::Server::GENERAL_NOTIFY, []() {
|
||||
return std::make_unique<GeneralNotify>();
|
||||
}}
|
||||
};
|
||||
|
||||
// Struct Functions
|
||||
void CommonLUBitStream::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(this->messageType);
|
||||
bitStream.Write<uint8_t>(0); // padding
|
||||
}
|
||||
bool CommonLUBitStream::Deserialize(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(this->messageType));
|
||||
uint8_t padding = 0;
|
||||
VALIDATE_READ(bitStream.Read(padding));
|
||||
return true;
|
||||
}
|
||||
|
||||
void VersionConfirm::Serialize(RakNet::BitStream& bitStream) const {
|
||||
CommonLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write<uint32_t>(netVersion);
|
||||
bitStream.Write<uint32_t>(861228100);
|
||||
bitStream.Write(static_cast<uint32_t>(serviceType));
|
||||
bitStream.Write<uint64_t>(219818307120);
|
||||
}
|
||||
|
||||
bool VersionConfirm::Deserialize(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(netVersion));
|
||||
uint32_t unknown = 0;
|
||||
VALIDATE_READ(bitStream.Read(unknown));
|
||||
VALIDATE_READ(bitStream.Read(serviceType));
|
||||
uint16_t unknown2 = 0;
|
||||
VALIDATE_READ(bitStream.Read(unknown2));
|
||||
VALIDATE_READ(bitStream.Read(processID));
|
||||
VALIDATE_READ(bitStream.Read(port));
|
||||
LUString unknownString;
|
||||
VALIDATE_READ(bitStream.Read(unknownString));
|
||||
return true;
|
||||
}
|
||||
|
||||
void VersionConfirm::Handle() {
|
||||
LOG_DEBUG("Client Data [Version: %i, Service: %s, Process: %u, Port: %u, Sysaddr Port: %u]", netVersion, StringifiedEnum::ToString(serviceType).data(), processID, port, sysAddr.port);
|
||||
|
||||
VersionConfirm response;
|
||||
auto& serverNetVersionString = Game::config->GetValue("client_net_version");
|
||||
const uint32_t serverNetVersion = GeneralUtils::TryParse<uint32_t>(serverNetVersionString).value_or(171022);
|
||||
response.netVersion = serverNetVersion;
|
||||
response.serviceType = Game::server->GetServerType();
|
||||
response.Send(sysAddr);
|
||||
}
|
||||
|
||||
void DisconnectNotify::Serialize(RakNet::BitStream& bitStream) const {
|
||||
CommonLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write(disconnectID);
|
||||
}
|
||||
|
||||
void GeneralNotify::Serialize(RakNet::BitStream& bitStream) const {
|
||||
CommonLUBitStream::Serialize(bitStream);
|
||||
bitStream.Write(notifyID);
|
||||
bitStream.Write(notifyUser);
|
||||
}
|
||||
}
|
||||
|
||||
void CommonPackets::Handle(RakNet::BitStream& inStream, const SystemAddress& sysAddr) {
|
||||
CommonLUBitStream lubitstream;
|
||||
if (!lubitstream.Deserialize(inStream)) return;
|
||||
|
||||
auto it = g_Handlers.find(lubitstream.messageType);
|
||||
if (it != g_Handlers.end()) {
|
||||
auto request = it->second();
|
||||
request->sysAddr = sysAddr;
|
||||
if (!request->Deserialize(inStream)) {
|
||||
LOG_DEBUG("Error Reading Common Packet: %s", StringifiedEnum::ToString(lubitstream.messageType).data());
|
||||
return;
|
||||
}
|
||||
LOG_DEBUG("Received Common Packet: %s", StringifiedEnum::ToString(lubitstream.messageType).data());
|
||||
request->Handle();
|
||||
} else {
|
||||
LOG_DEBUG("Unhandled Common Packet with ID: %i", lubitstream.messageType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
#include "dCommonVars.h"
|
||||
#include "dNetCommon.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "MessageType/Server.h"
|
||||
|
||||
enum class eServerDisconnectIdentifiers : uint32_t {
|
||||
UNKNOWN_SERVER_ERROR = 0,
|
||||
WRONG_GAME_VERSION,
|
||||
WRONG_SERVER_VERSION,
|
||||
CONNECTION_ON_INVALID_PORT,
|
||||
DUPLICATE_LOGIN,
|
||||
SERVER_SHUTDOWN,
|
||||
SERVER_MAP_LOAD_FAILURE,
|
||||
INVALID_SESSION_KEY,
|
||||
ACCOUNT_NOT_IN_PENDING_LIST,
|
||||
CHARACTER_NOT_FOUND,
|
||||
CHARACTER_CORRUPTED,
|
||||
KICK,
|
||||
SAVE_FAILURE,
|
||||
FREE_TRIAL_EXPIRED,
|
||||
PLAY_SCHEDULE_TIME_DONE
|
||||
};
|
||||
|
||||
// Packet Struct Functions
|
||||
namespace CommonPackets {
|
||||
// Structs
|
||||
struct CommonLUBitStream : public LUBitStream {
|
||||
MessageType::Server messageType = MessageType::Server::VERSION_CONFIRM;
|
||||
|
||||
CommonLUBitStream() : LUBitStream(ServiceType::COMMON) {};
|
||||
CommonLUBitStream(MessageType::Server _messageType) : LUBitStream(ServiceType::COMMON), messageType{_messageType} {};
|
||||
|
||||
virtual void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
virtual bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
virtual void Handle() override {};
|
||||
};
|
||||
|
||||
struct VersionConfirm : public CommonLUBitStream {
|
||||
uint32_t netVersion = 0;
|
||||
ServiceType serviceType;
|
||||
uint32_t processID = 0;
|
||||
uint16_t port = 0;
|
||||
|
||||
VersionConfirm() : CommonLUBitStream(MessageType::Server::VERSION_CONFIRM) {}
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
void Handle() override;
|
||||
};
|
||||
|
||||
struct DisconnectNotify : public CommonLUBitStream {
|
||||
eServerDisconnectIdentifiers disconnectID = eServerDisconnectIdentifiers::UNKNOWN_SERVER_ERROR;
|
||||
|
||||
DisconnectNotify() : CommonLUBitStream(MessageType::Server::DISCONNECT_NOTIFY) {}
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
struct GeneralNotify : public CommonLUBitStream {
|
||||
uint32_t notifyID = 0; // only one known value: 0, which is Duplicate account login
|
||||
bool notifyUser = true;
|
||||
|
||||
GeneralNotify() : CommonLUBitStream(MessageType::Server::GENERAL_NOTIFY) {}
|
||||
void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
};
|
||||
|
||||
// Non Struct functions
|
||||
void Handle(RakNet::BitStream& inStream, const SystemAddress& sysAddr);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ struct MailInfo {
|
||||
std::string subject;
|
||||
std::string body;
|
||||
uint64_t id{};
|
||||
uint32_t senderId{};
|
||||
uint32_t receiverId{};
|
||||
LWOOBJID senderId{};
|
||||
LWOOBJID receiverId{};
|
||||
uint64_t timeSent{};
|
||||
bool wasRead{};
|
||||
uint16_t languageCode{};
|
||||
|
||||
@@ -12,20 +12,6 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace WorldPackets {
|
||||
// Struct Functions
|
||||
void WorldLUBitStream::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(this->messageType);
|
||||
bitStream.Write<uint8_t>(0); // padding
|
||||
}
|
||||
bool WorldLUBitStream::Deserialize(RakNet::BitStream& bitStream) {
|
||||
VALIDATE_READ(bitStream.Read(this->messageType));
|
||||
uint8_t padding = 0;
|
||||
VALIDATE_READ(bitStream.Read(padding));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void HTTPMonitorInfo::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(port);
|
||||
bitStream.Write<uint8_t>(openWeb);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "dCommonVars.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "MessageType/World.h"
|
||||
|
||||
class User;
|
||||
struct SystemAddress;
|
||||
@@ -26,16 +25,6 @@ struct HTTPMonitorInfo {
|
||||
};
|
||||
|
||||
namespace WorldPackets {
|
||||
struct WorldLUBitStream : public LUBitStream {
|
||||
MessageType::World messageType = MessageType::World::VALIDATION;
|
||||
|
||||
WorldLUBitStream() : LUBitStream(ServiceType::WORLD) {};
|
||||
WorldLUBitStream(MessageType::World messageType) : LUBitStream(ServiceType::WORLD), messageType{messageType} {};
|
||||
|
||||
virtual void Serialize(RakNet::BitStream& bitStream) const override;
|
||||
virtual bool Deserialize(RakNet::BitStream& bitStream) override;
|
||||
virtual void Handle() override {};
|
||||
};
|
||||
void SendLoadStaticZone(const SystemAddress& sysAddr, float x, float y, float z, uint32_t checksum, LWOZONEID zone);
|
||||
void SendCharacterCreationResponse(const SystemAddress& sysAddr, eCharacterCreationResponse response);
|
||||
void SendCharacterRenameResponse(const SystemAddress& sysAddr, eRenameResponse response);
|
||||
|
||||
@@ -197,7 +197,12 @@ void dServer::SendToMaster(RakNet::BitStream& bitStream) {
|
||||
mMasterPeer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE_ORDERED, 0, mMasterSystemAddress, false);
|
||||
}
|
||||
|
||||
void dServer::Disconnect(const SystemAddress& sysAddr) {
|
||||
void dServer::Disconnect(const SystemAddress& sysAddr, eServerDisconnectIdentifiers disconNotifyID) {
|
||||
RakNet::BitStream bitStream;
|
||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::COMMON, MessageType::Server::DISCONNECT_NOTIFY);
|
||||
bitStream.Write(disconNotifyID);
|
||||
mPeer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE_ORDERED, 0, sysAddr, false);
|
||||
|
||||
mPeer->CloseConnection(sysAddr, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
virtual void Send(RakNet::BitStream& bitStream, const SystemAddress& sysAddr, bool broadcast);
|
||||
void SendToMaster(RakNet::BitStream& bitStream);
|
||||
|
||||
void Disconnect(const SystemAddress& sysAddr);
|
||||
void Disconnect(const SystemAddress& sysAddr, eServerDisconnectIdentifiers disconNotifyID);
|
||||
|
||||
bool IsConnected(const SystemAddress& sysAddr);
|
||||
const std::string& GetIP() const { return mIP; }
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "dChatFilter.h"
|
||||
#include "ClientPackets.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "CommonPackets.h"
|
||||
|
||||
#include "EntityManager.h"
|
||||
#include "EntityInfo.h"
|
||||
@@ -63,6 +62,7 @@
|
||||
#include "eBlueprintSaveResponseType.h"
|
||||
#include "Amf3.h"
|
||||
#include "NiPoint3.h"
|
||||
#include "eServerDisconnectIdentifiers.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "ServiceType.h"
|
||||
#include "MessageType/Server.h"
|
||||
@@ -78,6 +78,7 @@
|
||||
#include "Server.h"
|
||||
#include "PositionUpdate.h"
|
||||
#include "PlayerManager.h"
|
||||
#include "eLoginResponse.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "SlashCommandHandler.h"
|
||||
#include "InventoryComponent.h"
|
||||
@@ -702,10 +703,7 @@ void HandleMasterPacket(Packet* packet) {
|
||||
//Verify it:
|
||||
if (userHash != it->second.hash) {
|
||||
LOG("SOMEONE IS TRYING TO HACK? SESSION KEY MISMATCH: ours: %s != master: %s", userHash.c_str(), it->second.hash.c_str());
|
||||
CommonPackets::DisconnectNotify notification;
|
||||
notification.disconnectID = eServerDisconnectIdentifiers::INVALID_SESSION_KEY;
|
||||
notification.Send(it->second.sysAddr);
|
||||
Game::server->Disconnect(it->second.sysAddr);
|
||||
Game::server->Disconnect(it->second.sysAddr, eServerDisconnectIdentifiers::INVALID_SESSION_KEY);
|
||||
return;
|
||||
} else {
|
||||
LOG("User %s authenticated with correct key.", username.GetAsString().c_str());
|
||||
@@ -788,10 +786,7 @@ void HandleMasterPacket(Packet* packet) {
|
||||
//Check the key:
|
||||
if (sessionKey != std::atoi(user->GetSessionKey().c_str())) {
|
||||
LOG("But the session key is invalid!", username.string.c_str());
|
||||
CommonPackets::DisconnectNotify notification;
|
||||
notification.disconnectID = eServerDisconnectIdentifiers::INVALID_SESSION_KEY;
|
||||
notification.Send(user->GetSystemAddress());
|
||||
Game::server->Disconnect(user->GetSystemAddress());
|
||||
Game::server->Disconnect(user->GetSystemAddress(), eServerDisconnectIdentifiers::INVALID_SESSION_KEY);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -859,15 +854,15 @@ void HandlePacket(Packet* packet) {
|
||||
LUBitStream luBitStream;
|
||||
luBitStream.ReadHeader(inStream);
|
||||
|
||||
if (luBitStream.serviceType == ServiceType::COMMON) {
|
||||
CommonPackets::Handle(inStream, packet->systemAddress);
|
||||
if (luBitStream.connectionType == ServiceType::COMMON) {
|
||||
if (static_cast<MessageType::Server>(luBitStream.internalPacketID) == MessageType::Server::VERSION_CONFIRM) {
|
||||
AuthPackets::HandleHandshake(Game::server, packet);
|
||||
}
|
||||
}
|
||||
|
||||
if (luBitStream.serviceType != ServiceType::WORLD) return;
|
||||
WorldPackets::WorldLUBitStream worldLUBitStream;
|
||||
worldLUBitStream.Deserialize(inStream);
|
||||
|
||||
switch (static_cast<MessageType::World>(worldLUBitStream.messageType)) {
|
||||
if (luBitStream.connectionType != ServiceType::WORLD) return;
|
||||
LOG_DEBUG("Got world packet %s", StringifiedEnum::ToString(static_cast<MessageType::World>(luBitStream.internalPacketID)).data());
|
||||
switch (static_cast<MessageType::World>(luBitStream.internalPacketID)) {
|
||||
case MessageType::World::VALIDATION: {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LUWString username;
|
||||
@@ -884,10 +879,7 @@ void HandlePacket(Packet* packet) {
|
||||
auto accountInfo = Database::Get()->GetAccountInfo(username.GetAsString());
|
||||
if (!accountInfo) {
|
||||
LOG("Client's account does not exist in the database, aborting connection.");
|
||||
CommonPackets::DisconnectNotify notification;
|
||||
notification.disconnectID = eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND;
|
||||
notification.Send(packet->systemAddress);
|
||||
Game::server->Disconnect(packet->systemAddress);
|
||||
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -896,13 +888,13 @@ void HandlePacket(Packet* packet) {
|
||||
|
||||
if (accountInfo->maxGmLevel < eGameMasterLevel::DEVELOPER) {
|
||||
LOG("Client's database checksum does not match the server's, aborting connection.");
|
||||
std::vector<Stamp> stamps;
|
||||
|
||||
// Using the LoginResponse here since the UI is still in the login screen state
|
||||
// and we have a way to send a message about the client mismatch.
|
||||
ClientPackets::LoginResponse response;
|
||||
response.sysAddr = packet->systemAddress;
|
||||
response.responseCode = eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH;
|
||||
response.errorMessage= Game::config->GetValue("cdclient_mismatch_message");
|
||||
response.Send(packet->systemAddress);
|
||||
AuthPackets::SendLoginResponse(
|
||||
Game::server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH,
|
||||
Game::config->GetValue("cdclient_mismatch_message"), "", 0, "", stamps);
|
||||
return;
|
||||
} else {
|
||||
AMFArrayValue args;
|
||||
@@ -991,7 +983,7 @@ void HandlePacket(Packet* packet) {
|
||||
|
||||
LWOOBJID playerID = 0;
|
||||
inStream.Read(playerID);
|
||||
|
||||
LOG("User is requesting to login with character %llu", playerID);
|
||||
bool valid = CheatDetection::VerifyLwoobjidIsSender(
|
||||
playerID,
|
||||
packet->systemAddress,
|
||||
@@ -999,18 +991,15 @@ void HandlePacket(Packet* packet) {
|
||||
"Sending login request with a sending player that does not match their own. Player ID: %llu",
|
||||
playerID
|
||||
);
|
||||
|
||||
LOG("Login request for player %llu is %s", playerID, valid ? "valid" : "invalid");
|
||||
if (!valid) return;
|
||||
|
||||
GeneralUtils::ClearBit(playerID, eObjectBits::CHARACTER);
|
||||
GeneralUtils::ClearBit(playerID, eObjectBits::PERSISTENT);
|
||||
|
||||
auto user = UserManager::Instance()->GetUser(packet->systemAddress);
|
||||
|
||||
if (user) {
|
||||
auto lastCharacter = user->GetLoggedInChar();
|
||||
// This means we swapped characters and we need to remove the previous player from the container.
|
||||
if (static_cast<uint32_t>(lastCharacter) != playerID) {
|
||||
if (lastCharacter != playerID) {
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, ServiceType::CHAT, MessageType::Chat::UNEXPECTED_DISCONNECT);
|
||||
bitStream.Write(lastCharacter);
|
||||
@@ -1018,7 +1007,7 @@ void HandlePacket(Packet* packet) {
|
||||
}
|
||||
}
|
||||
|
||||
UserManager::Instance()->LoginCharacter(packet->systemAddress, static_cast<uint32_t>(playerID));
|
||||
UserManager::Instance()->LoginCharacter(packet->systemAddress, playerID);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1215,10 +1204,7 @@ void HandlePacket(Packet* packet) {
|
||||
}
|
||||
} else {
|
||||
LOG("Couldn't find character to log in with for user %s (%i)!", user->GetUsername().c_str(), user->GetAccountID());
|
||||
CommonPackets::DisconnectNotify notification;
|
||||
notification.disconnectID = eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND;
|
||||
notification.Send(packet->systemAddress);
|
||||
Game::server->Disconnect(packet->systemAddress);
|
||||
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::CHARACTER_NOT_FOUND);
|
||||
}
|
||||
} else {
|
||||
LOG("Couldn't get user for level load complete!");
|
||||
@@ -1241,7 +1227,7 @@ void HandlePacket(Packet* packet) {
|
||||
}
|
||||
|
||||
case MessageType::World::MAIL: {
|
||||
Mail::Handle(inStream, packet->systemAddress, UserManager::Instance()->GetUser(packet->systemAddress)->GetLastUsedChar()->GetEntity());
|
||||
Mail::HandleMail(inStream, packet->systemAddress, UserManager::Instance()->GetUser(packet->systemAddress)->GetLastUsedChar()->GetEntity());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1397,11 +1383,7 @@ void HandlePacket(Packet* packet) {
|
||||
if (user) {
|
||||
user->UserOutOfSync();
|
||||
} else {
|
||||
CommonPackets::DisconnectNotify notification;
|
||||
notification.disconnectID = eServerDisconnectIdentifiers::KICK;
|
||||
notification.Send(packet->systemAddress);
|
||||
Game::server->Disconnect(packet->systemAddress);
|
||||
|
||||
Game::server->Disconnect(packet->systemAddress, eServerDisconnectIdentifiers::KICK);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1478,10 +1460,8 @@ void WorldShutdownProcess(uint32_t zoneId) {
|
||||
|
||||
while (Game::server->GetReplicaManager()->GetParticipantCount() > 0) {
|
||||
const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(0);
|
||||
CommonPackets::DisconnectNotify notification;
|
||||
notification.disconnectID = eServerDisconnectIdentifiers::SERVER_SHUTDOWN;
|
||||
notification.Send(player);
|
||||
Game::server->Disconnect(player);
|
||||
|
||||
Game::server->Disconnect(player, eServerDisconnectIdentifiers::SERVER_SHUTDOWN);
|
||||
}
|
||||
SendShutdownMessageToMaster();
|
||||
}
|
||||
|
||||
22
migrations/dlu/mysql/23_store_character_id_as_objectid.sql
Normal file
22
migrations/dlu/mysql/23_store_character_id_as_objectid.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
START TRANSACTION;
|
||||
ALTER TABLE mail MODIFY COLUMN sender_id BIGINT NOT NULL;
|
||||
ALTER TABLE bug_reports MODIFY COLUMN reporter_id BIGINT;
|
||||
/* This is done to prevent all entries on the leaderboard from updating */
|
||||
ALTER TABLE leaderboard CHANGE last_played last_played TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP();
|
||||
SET foreign_key_checks = 0;
|
||||
UPDATE activity_log SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE behaviors SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE bug_reports SET reporter_id = reporter_id | 0x1000000000000000;
|
||||
UPDATE charinfo SET id = id | 0x1000000000000000;
|
||||
UPDATE charxml SET id = id | 0x1000000000000000;
|
||||
UPDATE command_log SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE friends SET player_id = player_id | 0x1000000000000000, friend_id = friend_id | 0x1000000000000000;
|
||||
UPDATE ignore_list SET player_id = player_id | 0x1000000000000000, ignored_player_id = ignored_player_id | 0x1000000000000000;
|
||||
UPDATE leaderboard SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE mail SET sender_id = sender_id | 0x1000000000000000, receiver_id = receiver_id | 0x1000000000000000;
|
||||
UPDATE properties SET owner_id = owner_id | 0x1000000000000000;
|
||||
UPDATE ugc SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE ugc_modular_build SET character_id = character_id | 0x1000000000000000;
|
||||
SET foreign_key_checks = 1;
|
||||
ALTER TABLE leaderboard CHANGE last_played last_played TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP();
|
||||
COMMIT;
|
||||
22
migrations/dlu/sqlite/6_store_character_id_as_objectid.sql
Normal file
22
migrations/dlu/sqlite/6_store_character_id_as_objectid.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
ALTER TABLE mail ADD COLUMN sender_id_1 BIGINT DEFAULT 0;
|
||||
ALTER TABLE bug_reports ADD COLUMN reporter_id_1 BIGINT DEFAULT 0;
|
||||
/* The leaderboard last_played change is not needed here since sqlite does not have ON UPDATE */
|
||||
UPDATE activity_log SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE behaviors SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE bug_reports SET reporter_id_1 = reporter_id | 0x1000000000000000;
|
||||
UPDATE charinfo SET id = id | 0x1000000000000000;
|
||||
UPDATE charxml SET id = id | 0x1000000000000000;
|
||||
UPDATE command_log SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE friends SET player_id = player_id | 0x1000000000000000, friend_id = friend_id | 0x1000000000000000;
|
||||
UPDATE ignore_list SET player_id = player_id | 0x1000000000000000, ignored_player_id = ignored_player_id | 0x1000000000000000;
|
||||
UPDATE leaderboard SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE mail SET sender_id_1 = sender_id | 0x1000000000000000, receiver_id = receiver_id | 0x1000000000000000;
|
||||
UPDATE properties SET owner_id = owner_id | 0x1000000000000000;
|
||||
UPDATE ugc SET character_id = character_id | 0x1000000000000000;
|
||||
UPDATE ugc_modular_build SET character_id = character_id | 0x1000000000000000;
|
||||
|
||||
ALTER TABLE mail DROP COLUMN sender_id;
|
||||
ALTER TABLE mail RENAME COLUMN sender_id_1 TO sender_id;
|
||||
|
||||
ALTER TABLE bug_reports DROP COLUMN reporter_id;
|
||||
ALTER TABLE bug_reports RENAME COLUMN reporter_id_1 TO reporter_id;
|
||||
2
thirdparty/CMakeLists.txt
vendored
2
thirdparty/CMakeLists.txt
vendored
@@ -49,6 +49,7 @@ if(UNIX AND NOT APPLE)
|
||||
backtrace
|
||||
GIT_REPOSITORY https://github.com/ianlancetaylor/libbacktrace.git
|
||||
GIT_PROGRESS TRUE
|
||||
GIT_SHALLOW 1
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(backtrace)
|
||||
@@ -71,6 +72,7 @@ FetchContent_Declare(
|
||||
GIT_REPOSITORY https://github.com/g-truc/glm.git
|
||||
GIT_TAG bf71a834948186f4097caa076cd2663c69a10e1e #refs/tags/1.0.1
|
||||
GIT_PROGRESS TRUE
|
||||
GIT_SHALLOW 1
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(glm)
|
||||
|
||||
Reference in New Issue
Block a user