Show
Ignore:
Timestamp:
11/22/08 16:14:42 (17 years ago)
Author:
yumileroy
Message:

*Update to Mangos 6842. Source: Mangos.

Original author: megamage
Date: 2008-11-22 09:51:35-06:00

Files:
1 modified

Legend:

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

    r279 r290  
    125125            be.spell            = fields[8].GetUInt32(); 
    126126 
    127             // load and store without holes in array 
    128             int j = 0; 
    129127            for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 
    130128            { 
    131                 be.textid[j]        = fields[9+i].GetUInt32(); 
    132                 if(be.textid[j]) 
     129                be.textid[i]        = fields[9+i].GetUInt32(); 
     130                if(be.textid[i]) 
    133131                { 
    134                     if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID) 
     132                    if (be.textid[i] < MIN_DB_SCRIPT_STRING_ID || be.textid[i] >= MAX_DB_SCRIPT_STRING_ID) 
    135133                    { 
    136                         sLog.outErrorDb( "Table `db_script_string` not have string id  %u", be.textid[j]); 
     134                        sLog.outErrorDb( "Table `db_script_string` not have string id  %u", be.textid[i]); 
    137135                        continue; 
    138136                    } 
    139  
    140                     if (!objmgr.GetTrinityStringLocale (be.textid[j])) 
    141                     { 
    142                         sLog.outErrorDb("ERROR: Waypoint path %d (point %d), have invalid text id (%i) in `textid%d, ignored.", 
    143                             id, point, be.textid[j], i+1); 
    144                         continue; 
    145                     } 
    146  
    147                     ++j;                                    // to next internal field 
    148137                } 
    149138            } 
    150             // fill array tail 
    151             for(; j < MAX_WAYPOINT_TEXT; ++j) 
    152                 be.textid[j] = 0; 
    153139 
    154140            // save memory by not storing empty behaviors 
     
    309295    } 
    310296} 
     297 
     298void WaypointManager::CheckTextsExistance(std::set<int32>& ids) 
     299{ 
     300    WaypointPathMap::iterator pmItr = m_pathMap.begin(); 
     301    for ( ; pmItr != m_pathMap.end(); ++pmItr) 
     302    { 
     303        for (int i = 0; i < pmItr->second.size(); ++i) 
     304        { 
     305            if (!pmItr->second[i].behavior) 
     306                continue; 
     307 
     308            // Now we check text existence and put all zero texts ids to the end of array 
     309 
     310            // Counting leading zeros for futher textid shift 
     311            int zeroCount = 0; 
     312            for (int j = 0; j < MAX_WAYPOINT_TEXT; ++j) 
     313            { 
     314                if (!pmItr->second[i].behavior->textid[j]) 
     315                { 
     316                    ++zeroCount; 
     317                    continue; 
     318                } 
     319                else 
     320                { 
     321                    if (!objmgr.GetMangosStringLocale(pmItr->second[i].behavior->textid[j])) 
     322                    { 
     323                        sLog.outErrorDb("ERROR: Some waypoint has textid%u with not existing %u text.", j, pmItr->second[i].behavior->textid[j]); 
     324                        pmItr->second[i].behavior->textid[j] = 0; 
     325                        ++zeroCount; 
     326                        continue; 
     327                    } 
     328                    else 
     329                        ids.erase(pmItr->second[i].behavior->textid[j]); 
     330 
     331                    // Shifting check 
     332                    if (zeroCount) 
     333                    { 
     334                        // Correct textid but some zeros leading, so move it forward. 
     335                        pmItr->second[i].behavior->textid[j-zeroCount] = pmItr->second[i].behavior->textid[j]; 
     336                        pmItr->second[i].behavior->textid[j] = 0; 
     337                    } 
     338                } 
     339            } 
     340        } 
     341    } 
     342}