mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[6865] Improve db access in guild and arena team code.
Note: Using SetUInt32ValueInDB() is still not safe, because it's executed async. Three possible solutions: 1) remove data field 2) get rid of SetUInt32ValueInDB() calls (probably not possible) 3) make SaveValuesArrayInDB() executed directly
This commit is contained in:
parent
d0ea9cbb23
commit
1ad9adc467
4 changed files with 29 additions and 16 deletions
|
|
@ -138,19 +138,23 @@ bool ArenaTeam::AddMember(uint64 PlayerGuid)
|
|||
{
|
||||
pl->SetInArenaTeam(Id, GetSlot());
|
||||
pl->SetArenaTeamIdInvited(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Player::SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6), Id, PlayerGuid);
|
||||
}
|
||||
|
||||
// hide promote/remove buttons
|
||||
if(CaptainGuid != PlayerGuid)
|
||||
{
|
||||
if(pl)
|
||||
pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1);
|
||||
}
|
||||
else
|
||||
Player::SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1, PlayerGuid);
|
||||
{
|
||||
Tokens tokens;
|
||||
if(Player::LoadValuesArrayFromDB(tokens,PlayerGuid))
|
||||
{
|
||||
Player::SetUInt32ValueInArray(tokens,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6), Id);
|
||||
// hide promote/remove buttons
|
||||
if(CaptainGuid != PlayerGuid)
|
||||
Player::SetUInt32ValueInArray(tokens,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1);
|
||||
|
||||
Player::SaveValuesArrayInDB(tokens,PlayerGuid);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -567,8 +567,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
|
|||
{
|
||||
// remove wrong guild data
|
||||
sLog.outError("Player %s (GUID: %u) marked as member not existed guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId());
|
||||
pCurrChar->SetUInt32Value(PLAYER_GUILDID,0);
|
||||
pCurrChar->SetUInt32ValueInDB(PLAYER_GUILDID,0,pCurrChar->GetGUID());
|
||||
pCurrChar->SetInGuild(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,8 +151,13 @@ bool Guild::AddMember(uint64 plGuid, uint32 plRank)
|
|||
}
|
||||
else
|
||||
{
|
||||
Player::SetUInt32ValueInDB(PLAYER_GUILDID, Id, plGuid);
|
||||
Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, newmember.RankId, plGuid);
|
||||
Tokens tokens;
|
||||
if(Player::LoadValuesArrayFromDB(tokens,plGuid))
|
||||
{
|
||||
Player::SetUInt32ValueInArray(tokens, PLAYER_GUILDID, Id);
|
||||
Player::SetUInt32ValueInArray(tokens, PLAYER_GUILDRANK, newmember.RankId);
|
||||
Player::SaveValuesArrayInDB(tokens, plGuid);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -481,8 +486,13 @@ void Guild::DelMember(uint64 guid, bool isDisbanding)
|
|||
}
|
||||
else
|
||||
{
|
||||
Player::SetUInt32ValueInDB(PLAYER_GUILDID, 0, guid);
|
||||
Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, GR_GUILDMASTER, guid);
|
||||
Tokens tokens;
|
||||
if(Player::LoadValuesArrayFromDB(tokens,guid))
|
||||
{
|
||||
Player::SetUInt32ValueInArray(tokens, PLAYER_GUILDID, 0);
|
||||
Player::SetUInt32ValueInArray(tokens, PLAYER_GUILDRANK, GR_GUILDMASTER);
|
||||
Player::SaveValuesArrayInDB(tokens, guid);
|
||||
}
|
||||
}
|
||||
|
||||
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", GUID_LOPART(guid));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "6864"
|
||||
#define REVISION_NR "6865"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue