[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:
hunuza 2008-11-30 13:15:05 +01:00
parent d0ea9cbb23
commit 1ad9adc467
4 changed files with 29 additions and 16 deletions

View file

@ -138,19 +138,23 @@ bool ArenaTeam::AddMember(uint64 PlayerGuid)
{
pl->SetInArenaTeam(Id, GetSlot());
pl->SetArenaTeamIdInvited(0);
// hide promote/remove buttons
if(CaptainGuid != PlayerGuid)
pl->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 + (GetSlot() * 6), 1);
}
else
{
Player::SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6), Id, 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);
// 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);
Player::SaveValuesArrayInDB(tokens,PlayerGuid);
}
}
return true;
}