Skip to content

Commit

Permalink
fix(Core/World): edge case when last Char on realm was deleted (#20864)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tralenor authored Jan 9, 2025
1 parent 6b22c7b commit 70c34bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/server/game/World/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2884,27 +2884,27 @@ void World::UpdateRealmCharCount(uint32 accountId)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_COUNT);
stmt->SetData(0, accountId);
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&World::_UpdateRealmCharCount, this, std::placeholders::_1)));
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&World::_UpdateRealmCharCount, this, std::placeholders::_1,accountId)));
}

void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount)
void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount,uint32 accountId)
{
uint8 charCount{0};
if (resultCharCount)
{
Field* fields = resultCharCount->Fetch();
uint32 accountId = fields[0].Get<uint32>();
uint8 charCount = uint8(fields[1].Get<uint64>());
charCount = uint8(fields[1].Get<uint64>());
}

LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();

LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_REALM_CHARACTERS);
stmt->SetData(0, charCount);
stmt->SetData(1, accountId);
stmt->SetData(2, realm.Id.Realm);
trans->Append(stmt);
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_REP_REALM_CHARACTERS);
stmt->SetData(0, charCount);
stmt->SetData(1, accountId);
stmt->SetData(2, realm.Id.Realm);
trans->Append(stmt);

LoginDatabase.CommitTransaction(trans);
}
LoginDatabase.CommitTransaction(trans);
}

void World::InitWeeklyQuestResetTime()
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/World/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class World: public IWorld
protected:
void _UpdateGameTime();
// callback for UpdateRealmCharacters
void _UpdateRealmCharCount(PreparedQueryResult resultCharCount);
void _UpdateRealmCharCount(PreparedQueryResult resultCharCount,uint32 accountId);

void InitDailyQuestResetTime();
void InitWeeklyQuestResetTime();
Expand Down

0 comments on commit 70c34bd

Please sign in to comment.