Show
Ignore:
Timestamp:
09/20/09 20:13:24 (3 years ago)
Author:
valroft
Message:

- Reduced the memory overhead of achievements significantly.
- Changed the number of possibly criteria per achievement to be completely dependent on how many there actually are.
- To save memory, achievement counters will not be loaded for achievements that are already completed. This affects nothing in-game.
- Run the SQL update 2009_09_20_achievements.sql, or large achievements will not save!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/hearthstone-world/ObjectMgr.cpp

    r19 r20  
    189189                delete (itr->second); 
    190190 
    191         Log.Notice("ObjectMgr", "Deleting Achievement Quest Map..."); 
    192         for(map<uint32,set<Quest*>*>::iterator qitr = ZoneToQuestMap.begin(); qitr != ZoneToQuestMap.end(); ++qitr) 
    193                 delete qitr->second; 
     191        AchievementEntry* ae; 
     192        for(uint32 i = 0; i < dbcAchivementCriteria.GetNumRows(); ++i) 
     193        { 
     194                ae = dbcAchievement.LookupRow(i); 
     195                if( ae ) 
     196                { 
     197                        delete ae->AssociatedCriteria; 
     198                } 
     199        } 
    194200} 
    195201void ObjectMgr::LoadAchievements() 
     
    200206                if(ae) 
    201207                { 
     208                        ae->AssociatedCriteria = new vector<uint32>; 
    202209                        ae->AssociatedCriteriaCount = 0; 
    203210                } 
     
    227234                        if( ae ) 
    228235                        { 
    229                                 if(ae->AssociatedCriteriaCount >= 32) continue; 
    230                                 ae->AssociatedCriteria[ ae->AssociatedCriteriaCount ] = ace->ID; 
     236                                //if(ae->AssociatedCriteriaCount >= 32) continue; 
     237                                ae->AssociatedCriteria->push_back( ace->ID ); 
     238                                //ae->AssociatedCriteria[ ae->AssociatedCriteriaCount ] = ace->ID; 
    231239                                ae->AssociatedCriteriaCount++; 
    232240                        } 
    233                 } 
    234         } 
    235  
    236         // For Achievements: Complete Quest by Zone Id 
    237         StorageContainerIterator<Quest> * itr = QuestStorage.MakeIterator(); 
    238         for(; !itr->AtEnd(); itr->Inc() ) 
    239         { 
    240                 Quest * pQuest = itr->Get(); 
    241                 if(!pQuest) continue; 
    242  
    243                 uint32 QuestZone = pQuest->zone_id; 
    244                 map<uint32,set<Quest*>*>::iterator qitr = ZoneToQuestMap.find( QuestZone ); 
    245                 if( qitr == ZoneToQuestMap.end() ) 
    246                 { 
    247                         // We don't have any entries for this zone yet. 
    248                         set<Quest*>* mySet = new set<Quest*>; 
    249                         mySet->insert( pQuest ); 
    250                         ZoneToQuestMap.insert( make_pair( QuestZone, mySet ) ); 
    251                 } 
    252                 else 
    253                 { 
    254                         set<Quest*>* thisSet = qitr->second; 
    255                         thisSet->insert( pQuest ); 
    256241                } 
    257242        }