Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close #2501

Closed
wants to merge 24 commits into from
Closed

close #2501

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5158,6 +5158,7 @@ void Player::addUnjustifiedDead(std::shared_ptr<Player> attacked) {
sendTextMessage(MESSAGE_EVENT_ADVANCE, "Warning! The murder of " + attacked->getName() + " was not justified.");

unjustifiedKills.emplace_back(attacked->getGUID(), time(nullptr), true);
setSaveUnjustifiedKills(true);

uint8_t dayKills = 0;
uint8_t weekKills = 0;
Expand Down Expand Up @@ -5248,11 +5249,13 @@ double Player::getLostPercent() const {
void Player::learnInstantSpell(const std::string &spellName) {
if (!hasLearnedInstantSpell(spellName)) {
learnedInstantSpellList.push_front(spellName);
setSaveSpells(true);
}
}

void Player::forgetInstantSpell(const std::string &spellName) {
learnedInstantSpellList.remove(spellName);
setSaveSpells(true);
}

bool Player::hasLearnedInstantSpell(const std::string &spellName) const {
Expand Down
28 changes: 28 additions & 0 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ class Player final : public Creature, public Cylinder, public Bankable {
auto it = stashItems.find(itemId);
if (it != stashItems.end()) {
stashItems[itemId] += amount;
setSaveStash(true);
return;
}

Expand All @@ -711,6 +712,7 @@ class Player final : public Creature, public Cylinder, public Bankable {
} else {
return false;
}
setSaveStash(true);
return true;
}
return false;
Expand Down Expand Up @@ -2597,6 +2599,25 @@ class Player final : public Creature, public Cylinder, public Bankable {

bool canSpeakWithHireling(uint8_t speechbubble);

bool hasSaveStash() {
return saveStash;
}
void setSaveStash(bool onOff) {
saveStash = onOff;
}
bool hasSaveUnjustifiedKills() {
return saveUnjustifiedKills;
}
void setSaveUnjustifiedKills(bool onOff) {
saveUnjustifiedKills = onOff;
}
bool hasSaveSpells() {
return saveSpells;
}
void setSaveSpells(bool onOff) {
saveSpells = onOff;
}

private:
friend class PlayerLock;
std::mutex mutex;
Expand Down Expand Up @@ -2819,6 +2840,8 @@ class Player final : public Creature, public Cylinder, public Bankable {
uint16_t storeXpBoost = 0;
uint16_t staminaXpBoost = 100;
int16_t lastDepotId = -1;

// Stash
StashItemList stashItems; // [ItemID] = amount
uint32_t movedItems = 0;

Expand Down Expand Up @@ -2889,6 +2912,11 @@ class Player final : public Creature, public Cylinder, public Bankable {
bool dead = false;
bool imbuementTrackerWindowOpen = false;

// Otimize Save Players
bool saveStash = false;
bool saveUnjustifiedKills = false;
bool saveSpells = false;

// Hazard system
int64_t lastHazardSystemCriticalHit = 0;
bool reloadHazardSystemPointsCounter = true;
Expand Down
5 changes: 5 additions & 0 deletions src/game/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,11 @@ class Game {
std::string generateHighscoreQueryForOurRank(const std::string &categoryName, uint8_t entriesPerPage, uint32_t playerGUID, uint32_t vocation);
std::string generateHighscoreOrGetCachedQueryForEntries(const std::string &categoryName, uint32_t page, uint8_t entriesPerPage, uint32_t vocation);
std::string generateHighscoreOrGetCachedQueryForOurRank(const std::string &categoryName, uint8_t entriesPerPage, uint32_t playerGUID, uint32_t vocation);

uint32_t totalImproveSave = 0;
uint32_t totalImproveSaveStash = 0;
uint32_t totalImproveSaveSpells = 0;
uint32_t totalImproveSaveKills = 0;
};

constexpr auto g_game = Game::getInstance;
3 changes: 3 additions & 0 deletions src/io/functions/iologindata_load_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ void IOLoginDataLoad::loadPlayerKills(std::shared_ptr<Player> player, DBResult_p
time_t killTime = result->getNumber<time_t>("time");
if ((time(nullptr) - killTime) <= g_configManager().getNumber(FRAG_TIME, __FUNCTION__)) {
player->unjustifiedKills.emplace_back(result->getNumber<uint32_t>("target"), killTime, result->getNumber<bool>("unavenged"));
} else {
player->setSaveUnjustifiedKills(true);
}
} while (result->next());
}
Expand Down Expand Up @@ -399,6 +401,7 @@ void IOLoginDataLoad::loadPlayerStashItems(std::shared_ptr<Player> player, DBRes
player->addItemOnStash(result->getNumber<uint16_t>("item_id"), result->getNumber<uint32_t>("item_count"));
} while (result->next());
}
player->setSaveStash(false);
}

void IOLoginDataLoad::loadPlayerBestiaryCharms(std::shared_ptr<Player> player, DBResult_ptr result) {
Expand Down
6 changes: 6 additions & 0 deletions src/io/functions/iologindata_save_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ bool IOLoginDataSave::savePlayerStash(std::shared_ptr<Player> player) {
if (!stashQuery.execute()) {
return false;
}

player->setSaveStash(false);
return true;
}

Expand Down Expand Up @@ -369,6 +371,8 @@ bool IOLoginDataSave::savePlayerSpells(std::shared_ptr<Player> player) {
if (!spellsQuery.execute()) {
return false;
}

player->setSaveSpells(false);
return true;
}

Expand Down Expand Up @@ -398,6 +402,8 @@ bool IOLoginDataSave::savePlayerKills(std::shared_ptr<Player> player) {
if (!killsQuery.execute()) {
return false;
}

player->setSaveUnjustifiedKills(false);
return true;
}

Expand Down
25 changes: 18 additions & 7 deletions src/io/iologindata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,32 @@
throw DatabaseException("Player nullptr in function: " + std::string(__FUNCTION__));
}

if (!IOLoginDataSave::savePlayerFirst(player)) {
g_game().addImproveSave(1)

Check failure on line 218 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-release

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 218 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-release

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 218 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / windows-2022-windows-release

'addImproveSave': is not a member of 'Game'

Check failure on line 218 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-debug

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 218 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

if (!IOLoginDataSave::savePlayerFirst(player)) {

Check failure on line 220 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / windows-2022-windows-release

syntax error: missing ';' before 'if'
throw DatabaseException("[" + std::string(__FUNCTION__) + "] - Failed to save player first: " + player->getName());
}

if (!IOLoginDataSave::savePlayerStash(player)) {
throw DatabaseException("[IOLoginDataSave::savePlayerFirst] - Failed to save player stash: " + player->getName());
if (player->hasSaveStash()) {
if (!IOLoginDataSave::savePlayerStash(player)) {
throw DatabaseException("[IOLoginDataSave::savePlayerFirst] - Failed to save player stash: " + player->getName());
}
g_game().addImproveSave(2)

Check failure on line 228 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-release

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 228 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-release

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 228 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / windows-2022-windows-release

'addImproveSave': is not a member of 'Game'

Check failure on line 228 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-debug

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 228 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)
}

Check failure on line 229 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / windows-2022-windows-release

syntax error: missing ';' before '}'

if (!IOLoginDataSave::savePlayerSpells(player)) {
throw DatabaseException("[IOLoginDataSave::savePlayerSpells] - Failed to save player spells: " + player->getName());
if (player->hasSaveSpells()) {
if (!IOLoginDataSave::savePlayerSpells(player)) {
throw DatabaseException("[IOLoginDataSave::savePlayerSpells] - Failed to save player spells: " + player->getName());
}
g_game().addImproveSave(3)

Check failure on line 235 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-release

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 235 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-release

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 235 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / windows-2022-windows-release

'addImproveSave': is not a member of 'Game'

Check failure on line 235 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-debug

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 235 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)
}

Check failure on line 236 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / windows-2022-windows-release

syntax error: missing ';' before '}'

if (!IOLoginDataSave::savePlayerKills(player)) {
throw DatabaseException("IOLoginDataSave::savePlayerKills] - Failed to save player kills: " + player->getName());
if (player->hasSaveUnjustifiedKills()) {
if (!IOLoginDataSave::savePlayerKills(player)) {
throw DatabaseException("IOLoginDataSave::savePlayerKills] - Failed to save player kills: " + player->getName());
}
g_game().addImproveSave(4)

Check failure on line 242 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-release

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 242 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-release

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 242 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / windows-2022-windows-release

'addImproveSave': is not a member of 'Game'

Check failure on line 242 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-20.04-linux-debug

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)

Check failure on line 242 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-22.04-linux-debug

‘class Game’ has no member named ‘addImproveSave’; did you mean ‘uint32_t Game::totalImproveSave’? (not accessible from this context)
}

Check failure on line 243 in src/io/iologindata.cpp

View workflow job for this annotation

GitHub Actions / windows-2022-windows-release

syntax error: missing ';' before '}'

if (!IOLoginDataSave::savePlayerBestiarySystem(player)) {
throw DatabaseException("[IOLoginDataSave::savePlayerBestiarySystem] - Failed to save player bestiary system: " + player->getName());
Expand Down
Loading