Skip to content

Commit f558246

Browse files
fix: Serene and Harmony when closing game client (#532)
* fix: Serene and Harmony when closing game client This PR fixes the Serene and Harmony issues that occur when a player closes the game client using the 'X' button. * Code format - (Clang-format) * fix: sync spells utamo tio with !fps command --------- Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
1 parent a4c6f69 commit f558246

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

src/creatures/players/player.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12210,6 +12210,26 @@ void Player::setSereneCooldown(const uint64_t addTime) {
1221012210
m_serene_cooldown = timenow + addTime;
1221112211
}
1221212212

12213+
void Player::resyncSpellCooldowns() const {
12214+
if (!client) {
12215+
return;
12216+
}
12217+
12218+
// Resync individual spell cooldowns
12219+
for (const auto &condition : getConditionsByType(CONDITION_SPELLCOOLDOWN)) {
12220+
uint16_t spellId = condition->getSubId();
12221+
uint32_t ticks = condition->getTicks();
12222+
sendSpellCooldown(spellId, ticks);
12223+
}
12224+
12225+
// Resync group spell cooldowns
12226+
for (const auto &condition : getConditionsByType(CONDITION_SPELLGROUPCOOLDOWN)) {
12227+
SpellGroup_t groupId = static_cast<SpellGroup_t>(condition->getSubId());
12228+
uint32_t ticks = condition->getTicks();
12229+
client->sendSpellGroupCooldown(groupId, ticks);
12230+
}
12231+
}
12232+
1221312233
void Player::sendVirtueProtocol() const {
1221412234
if (client && m_virtue != VIRTUE_NONE) {
1221512235
client->sendVirtueProtocol(static_cast<uint8_t>(m_virtue));

src/creatures/players/player.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,7 @@ class Player final : public Creature, public Cylinder, public Bankable {
15281528
void setSerene(const bool isSerene);
15291529
uint64_t getSereneCooldown();
15301530
void setSereneCooldown(const uint64_t addTime);
1531+
void resyncSpellCooldowns() const;
15311532
void sendVirtueProtocol() const;
15321533
void setVirtue(const VirtueMonk_t virtue);
15331534
VirtueMonk_t getVirtue() const;

src/server/network/protocol/protocolgame.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,11 @@ void ProtocolGame::connect(const std::string &playerName, OperatingSystem_t oper
776776

777777
player->client = getThis();
778778
player->openPlayerContainers();
779+
780+
player->sendHarmonyProtocol();
781+
player->sendSereneProtocol();
782+
player->resyncSpellCooldowns();
783+
779784
sendAddCreature(player, player->getPosition(), 0, true);
780785
player->lastIP = player->getIP();
781786
player->lastLoad = OTSYS_TIME();

src/server/network/protocol/protocolgame.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ class ProtocolGame final : public Protocol {
541541
void parseWheelGemAction(NetworkMessage &msg);
542542

543543
void sendHarmonyProtocol(const uint8_t harmonyValue);
544-
void sendSereneProtocol(const bool isSerene);
544+
void sendSereneProtocol(const bool isSerene = true);
545545
void sendVirtueProtocol(const uint8_t virtueValue);
546546
void parseSelectSpellAimProtocol(NetworkMessage &msg);
547547

0 commit comments

Comments
 (0)