mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 03:32:28 -04:00
[svn] Added sanity checks in loading player cache to prevent crashing upon corrupted player data.
--HG-- branch : trunk
This commit is contained in:
@@ -185,7 +185,7 @@ void ObjectMgr::LoadPlayerInfoInCache()
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT guid, name, data, class FROM characters");
|
||||
if(!result)
|
||||
{
|
||||
sLog.outError( "ROGNAR LoadPlayerCache");
|
||||
sLog.outError( "Loading Player Cache failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,17 +203,17 @@ void ObjectMgr::LoadPlayerInfoInCache()
|
||||
|
||||
tdata.clear();
|
||||
tdata = StrSplit(fields[2].GetCppString(), " ");
|
||||
|
||||
pPPlayerInfo->unLevel = (uint32)atoi(tdata[UNIT_FIELD_LEVEL].c_str());
|
||||
pPPlayerInfo->unfield = (uint32)atoi(tdata[UNIT_FIELD_BYTES_0].c_str());
|
||||
|
||||
pPPlayerInfo->unArenaInfoId0 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (0 * 6)].c_str());
|
||||
pPPlayerInfo->unArenaInfoId1 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (1 * 6)].c_str());
|
||||
pPPlayerInfo->unArenaInfoId2 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (2 * 6)].c_str());
|
||||
pPPlayerInfo->unLevel = Player::GetUInt32ValueFromArray(tdata,UNIT_FIELD_LEVEL);
|
||||
pPPlayerInfo->unfield = Player::GetUInt32ValueFromArray(tdata,UNIT_FIELD_BYTES_0);
|
||||
|
||||
pPPlayerInfo->unArenaInfoSlot0 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5].c_str());
|
||||
pPPlayerInfo->unArenaInfoSlot1 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5].c_str());
|
||||
pPPlayerInfo->unArenaInfoSlot2 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5].c_str());
|
||||
pPPlayerInfo->unArenaInfoId0 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6);
|
||||
pPPlayerInfo->unArenaInfoId1 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6);
|
||||
pPPlayerInfo->unArenaInfoId2 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6);
|
||||
|
||||
pPPlayerInfo->unArenaInfoSlot0 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5);
|
||||
pPPlayerInfo->unArenaInfoSlot1 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5);
|
||||
pPPlayerInfo->unArenaInfoSlot2 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5);
|
||||
|
||||
pPPlayerInfo->unClass = (uint32)fields[3].GetUInt32();
|
||||
m_mPlayerInfoMap[fields[0].GetUInt32()] = pPPlayerInfo;
|
||||
|
||||
@@ -13626,11 +13626,8 @@ float Player::GetFloatValueFromArray(Tokens const& data, uint16 index)
|
||||
|
||||
uint32 Player::GetUInt32ValueFromDB(uint16 index, uint64 guid)
|
||||
{
|
||||
//rognar optimization
|
||||
//must be improved!! "if" and "switch" - it's very not aesthetically :)))
|
||||
//but we should know whith data is cached
|
||||
//PLAYER_FIELD_ARENA_TEAM_INFO* very is often using with pvp&arena patch :)
|
||||
if( index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5
|
||||
// todo: cleanup in this, move to a separate function.
|
||||
if( index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5
|
||||
|| index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5
|
||||
|| index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5
|
||||
|| index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (0 * 6)
|
||||
|
||||
Reference in New Issue
Block a user