Changeset 95 for trunk

Show
Ignore:
Timestamp:
11/19/08 13:35:02 (17 years ago)
Author:
yumileroy
Message:

[svn] Added sanity checks in loading player cache to prevent crashing upon corrupted player data.

Original author: w12x
Date: 2008-10-22 04:05:15-05:00

Location:
trunk/src/game
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/ObjectMgr.cpp

    r94 r95  
    186186    if(!result) 
    187187    { 
    188         sLog.outError( "ROGNAR LoadPlayerCache"); 
     188        sLog.outError( "Loading Player Cache failed."); 
    189189        return; 
    190190    } 
     
    204204        tdata.clear(); 
    205205        tdata = StrSplit(fields[2].GetCppString(), " "); 
    206          
    207         pPPlayerInfo->unLevel = (uint32)atoi(tdata[UNIT_FIELD_LEVEL].c_str()); 
    208         pPPlayerInfo->unfield = (uint32)atoi(tdata[UNIT_FIELD_BYTES_0].c_str()); 
    209  
    210         pPPlayerInfo->unArenaInfoId0 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (0 * 6)].c_str()); 
    211         pPPlayerInfo->unArenaInfoId1 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (1 * 6)].c_str()); 
    212         pPPlayerInfo->unArenaInfoId2 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (2 * 6)].c_str()); 
    213  
    214         pPPlayerInfo->unArenaInfoSlot0 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5].c_str()); 
    215         pPPlayerInfo->unArenaInfoSlot1 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5].c_str()); 
    216         pPPlayerInfo->unArenaInfoSlot2 = (uint32)atoi(tdata[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5].c_str()); 
     206 
     207        pPPlayerInfo->unLevel = Player::GetUInt32ValueFromArray(tdata,UNIT_FIELD_LEVEL); 
     208        pPPlayerInfo->unfield = Player::GetUInt32ValueFromArray(tdata,UNIT_FIELD_BYTES_0); 
     209 
     210        pPPlayerInfo->unArenaInfoId0 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6); 
     211        pPPlayerInfo->unArenaInfoId1 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6); 
     212        pPPlayerInfo->unArenaInfoId2 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6); 
     213 
     214        pPPlayerInfo->unArenaInfoSlot0 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5); 
     215        pPPlayerInfo->unArenaInfoSlot1 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5); 
     216        pPPlayerInfo->unArenaInfoSlot2 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5); 
    217217     
    218218        pPPlayerInfo->unClass = (uint32)fields[3].GetUInt32(); 
  • trunk/src/game/Player.cpp

    r88 r95  
    1362713627uint32 Player::GetUInt32ValueFromDB(uint16 index, uint64 guid) 
    1362813628{ 
    13629     //rognar optimization 
    13630     //must be improved!! "if" and "switch" - it's very not aesthetically :))) 
    13631     //but we should know whith data is cached 
    13632     //PLAYER_FIELD_ARENA_TEAM_INFO* very is often using with pvp&arena patch :) 
    13633     if(       index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5 
     13629    // todo: cleanup in this, move to a separate function. 
     13630    if(    index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5 
    1363413631        || index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5 
    1363513632        || index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5