Skip to content

Commit df50371

Browse files
committed
fix: remove loading of basic info only (#2937)
Some database tables are completely deleted to add the "new" one, which replaces the existing data with empty data. In the future I will make an improvement to remove the DELETE FROM and come back with the feature.
1 parent 72016b2 commit df50371

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

src/game/game.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ std::shared_ptr<Player> Game::getPlayerByName(const std::string &s, bool allowOf
986986
return nullptr;
987987
}
988988
std::shared_ptr<Player> tmpPlayer = std::make_shared<Player>(nullptr);
989-
if (!IOLoginData::loadPlayerByName(tmpPlayer, s, allowOffline)) {
989+
if (!IOLoginData::loadPlayerByName(tmpPlayer, s)) {
990990
if (!isNewName) {
991991
g_logger().error("Failed to load player {} from database", s);
992992
} else {
@@ -1014,7 +1014,7 @@ std::shared_ptr<Player> Game::getPlayerByGUID(const uint32_t &guid, bool allowOf
10141014
}
10151015

10161016
std::shared_ptr<Player> tmpPlayer = std::make_shared<Player>(nullptr);
1017-
if (!IOLoginData::loadPlayerById(tmpPlayer, guid, false)) {
1017+
if (!IOLoginData::loadPlayerById(tmpPlayer, guid)) {
10181018
return nullptr;
10191019
}
10201020
tmpPlayer->setOnline(false);

src/io/iologindata.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,21 @@ void IOLoginData::updateOnlineStatus(uint32_t guid, bool login) {
9292
Database::getInstance().executeQuery(query.str());
9393
}
9494

95-
// The boolean "loadBasicInfoOnly" will deactivate the loading of information that is not relevant to the preload, for example, forge, bosstiary, etc. None of this we need to access if the player is offline
96-
bool IOLoginData::loadPlayerById(std::shared_ptr<Player> player, uint32_t id, bool loadBasicInfoOnly /* = true*/) {
95+
bool IOLoginData::loadPlayerById(std::shared_ptr<Player> player, uint32_t id) {
9796
Database &db = Database::getInstance();
9897
std::ostringstream query;
9998
query << "SELECT * FROM `players` WHERE `id` = " << id;
100-
return loadPlayer(player, db.storeQuery(query.str()), loadBasicInfoOnly);
99+
return loadPlayer(player, db.storeQuery(query.str()));
101100
}
102101

103-
bool IOLoginData::loadPlayerByName(std::shared_ptr<Player> player, const std::string &name, bool loadBasicInfoOnly /* = true*/) {
102+
bool IOLoginData::loadPlayerByName(std::shared_ptr<Player> player, const std::string &name) {
104103
Database &db = Database::getInstance();
105104
std::ostringstream query;
106105
query << "SELECT * FROM `players` WHERE `name` = " << db.escapeString(name);
107-
return loadPlayer(player, db.storeQuery(query.str()), loadBasicInfoOnly);
106+
return loadPlayer(player, db.storeQuery(query.str()));
108107
}
109108

110-
bool IOLoginData::loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result, bool loadBasicInfoOnly /* = false*/) {
109+
bool IOLoginData::loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result) {
111110
if (!result || !player) {
112111
std::string nullptrType = !result ? "Result" : "Player";
113112
g_logger().warn("[{}] - {} is nullptr", __FUNCTION__, nullptrType);
@@ -117,9 +116,6 @@ bool IOLoginData::loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result
117116
try {
118117
// First
119118
IOLoginDataLoad::loadPlayerBasicInfo(player, result);
120-
if (loadBasicInfoOnly) {
121-
return true;
122-
}
123119

124120
// Blessings load
125121
IOLoginDataLoad::loadPlayerBlessings(player, result);

src/io/iologindata.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class IOLoginData {
2020
static bool gameWorldAuthentication(const std::string &accountDescriptor, const std::string &sessionOrPassword, std::string &characterName, uint32_t &accountId, bool oldProcotol, const uint32_t ip);
2121
static uint8_t getAccountType(uint32_t accountId);
2222
static void updateOnlineStatus(uint32_t guid, bool login);
23-
static bool loadPlayerById(std::shared_ptr<Player> player, uint32_t id, bool loadBasicInfoOnly = true);
24-
static bool loadPlayerByName(std::shared_ptr<Player> player, const std::string &name, bool loadBasicInfoOnly = true);
25-
static bool loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result, bool loadBasicInfoOnly = false);
23+
static bool loadPlayerById(std::shared_ptr<Player> player, uint32_t id);
24+
static bool loadPlayerByName(std::shared_ptr<Player> player, const std::string &name);
25+
static bool loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result);
2626
static bool savePlayer(std::shared_ptr<Player> player);
2727
static uint32_t getGuidByName(const std::string &name);
2828
static bool getGuidByNameEx(uint32_t &guid, bool &specialVip, std::string &name);

src/server/network/protocol/protocolgame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ void ProtocolGame::login(const std::string &name, uint32_t accountId, OperatingS
574574
return;
575575
}
576576

577-
if (!IOLoginData::loadPlayerById(player, player->getGUID(), false)) {
577+
if (!IOLoginData::loadPlayerById(player, player->getGUID())) {
578578
g_game().removePlayerUniqueLogin(player);
579579
disconnectClient("Your character could not be loaded.");
580580
g_logger().warn("Player {} could not be loaded", player->getName());

0 commit comments

Comments
 (0)