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

[svn] * Added some player info cache to the core. Thanx to Rognar for patch, visaglis for testing and bugging me to add it.

Original author: KingPin?
Date: 2008-10-21 12:43:24-05:00

Files:
1 modified

Legend:

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

    r78 r88  
    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 
     13634        || index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5 
     13635        || index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5 
     13636        || index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (0 * 6) 
     13637        || index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (1 * 6) 
     13638        || index == PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (2 * 6) 
     13639        || index == UNIT_FIELD_LEVEL) 
     13640    { 
     13641        CachePlayerInfoMap::iterator _iter = objmgr.m_mPlayerInfoMap.find(GUID_LOPART(guid)); 
     13642        if(_iter != objmgr.m_mPlayerInfoMap.end()) 
     13643        { 
     13644            switch(index) 
     13645            { 
     13646            case (PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5): 
     13647                return _iter->second->unArenaInfoSlot0; 
     13648            case (PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5): 
     13649                return _iter->second->unArenaInfoSlot1; 
     13650            case (PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5): 
     13651                return _iter->second->unArenaInfoSlot2; 
     13652            case (PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (0 * 6)): 
     13653                return _iter->second->unArenaInfoId0; 
     13654            case (PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (1 * 6)): 
     13655                return _iter->second->unArenaInfoId1; 
     13656            case (PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (2 * 6)): 
     13657                return _iter->second->unArenaInfoId2; 
     13658            case (UNIT_FIELD_LEVEL): 
     13659                return _iter->second->unLevel; 
     13660            } 
     13661        } 
     13662    } 
    1362913663    Tokens data; 
    1363013664    if(!LoadValuesArrayFromDB(data,guid)) 
     
    1522015254    if(Pet* pet = GetPet()) 
    1522115255        pet->SavePetToDB(PET_SAVE_AS_CURRENT); 
     15256         
     15257    //to prevent access to DB we should cache some data, which is used very often 
     15258    CachePlayerInfoMap::iterator _iter = objmgr.m_mPlayerInfoMap.find(GetGUIDLow()); 
     15259    if(_iter != objmgr.m_mPlayerInfoMap.end())//skip new players 
     15260    { 
     15261        _iter->second->unLevel = getLevel(); 
     15262 
     15263        _iter->second->unArenaInfoSlot0 = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5); 
     15264        _iter->second->unArenaInfoSlot1 = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5); 
     15265        _iter->second->unArenaInfoSlot2 = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5); 
     15266 
     15267        _iter->second->unfield = GetUInt32Value(UNIT_FIELD_BYTES_0); 
     15268 
     15269        _iter->second->unArenaInfoId0 = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (0 * 6)); 
     15270        _iter->second->unArenaInfoId1 = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (1 * 6)); 
     15271        _iter->second->unArenaInfoId2 = GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (2 * 6)); 
     15272    } 
    1522215273} 
    1522315274