[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

@ -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));