Show
Ignore:
Timestamp:
11/22/08 00:35:41 (17 years ago)
Author:
yumileroy
Message:

Delete possessed AI only on creature delete.

Original author: gvcoman
Date: 2008-11-16 14:38:02-05:00

Files:
1 modified

Legend:

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

    r263 r272  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    1919 */ 
    2020 
     
    2525#include "ProgressBar.h" 
    2626#include "MapManager.h" 
    27 #include "ObjectMgr.h" 
    2827 
    2928INSTANTIATE_SINGLETON_1(WaypointManager); 
     
    3130bool WaypointBehavior::isEmpty() 
    3231{ 
    33     if (emote || spell || model1 || model2) 
    34         return false; 
    35  
    36     for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 
    37         if(textid[i]) 
    38             return false; 
    39  
    40     return true; 
     32    return emote == 0 && spell == 0 && model1 == 0 && model2 == 0 && text[0].empty() && 
     33        text[1].empty() && text[2].empty() && text[3].empty() && text[4].empty(); 
    4134} 
    4235 
    4336WaypointBehavior::WaypointBehavior(const WaypointBehavior &b) 
    4437{ 
    45     emote = b.emote; 
    46     spell = b.spell; 
    47     model1 = b.model1; 
    48     model2 = b.model2; 
    49     for(int i=0; i < MAX_WAYPOINT_TEXT; ++i) 
    50         textid[i] = b.textid[i]; 
     38    emote = b.emote; spell = b.spell; model1 = b.model1; model2 = b.model2; 
     39    text[0] = b.text[0]; text[1] = b.text[1]; text[2] = b.text[2]; 
     40    text[3] = b.text[3]; text[4] = b.text[4]; 
    5141} 
    5242 
     
    7767    } 
    7868 
    79     result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id, point FROM creature_movement"); 
     69    result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id, point FROM creature_movement"); 
    8070    if(result) 
    8171    { 
     
    124114            be.emote            = fields[7].GetUInt32(); 
    125115            be.spell            = fields[8].GetUInt32(); 
    126  
    127             // load and store without holes in array 
    128             int j = 0; 
    129             for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) 
    130             { 
    131                 be.textid[j]        = fields[9+i].GetUInt32(); 
    132                 if(be.textid[j]) 
    133                 { 
    134                     if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID) 
    135                     { 
    136                         sLog.outErrorDb( "Table `db_script_string` not have string id  %u", be.textid[j]); 
    137                         continue; 
    138                     } 
    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 
    148                 } 
    149             } 
    150             // fill array tail 
    151             for(; j < MAX_WAYPOINT_TEXT; ++j) 
    152                 be.textid[j] = 0; 
     116            be.text[0]          = fields[9].GetCppString(); 
     117            be.text[1]          = fields[10].GetCppString(); 
     118            be.text[2]          = fields[11].GetCppString(); 
     119            be.text[3]          = fields[12].GetCppString(); 
     120            be.text[4]          = fields[13].GetCppString(); 
    153121 
    154122            // save memory by not storing empty behaviors 
     
    298266        if(!node.behavior) node.behavior = new WaypointBehavior(); 
    299267 
    300 //        if(field == "text1") node.behavior->text[0] = text ? text : ""; 
    301 //        if(field == "text2") node.behavior->text[1] = text ? text : ""; 
    302 //        if(field == "text3") node.behavior->text[2] = text ? text : ""; 
    303 //        if(field == "text4") node.behavior->text[3] = text ? text : ""; 
    304 //        if(field == "text5") node.behavior->text[4] = text ? text : ""; 
     268        if(field == "text1") node.behavior->text[0] = text ? text : ""; 
     269        if(field == "text2") node.behavior->text[1] = text ? text : ""; 
     270        if(field == "text3") node.behavior->text[2] = text ? text : ""; 
     271        if(field == "text4") node.behavior->text[3] = text ? text : ""; 
     272        if(field == "text5") node.behavior->text[4] = text ? text : ""; 
    305273        if(field == "emote") node.behavior->emote   = text ? atoi(text) : 0; 
    306274        if(field == "spell") node.behavior->spell   = text ? atoi(text) : 0;