diff options
Diffstat (limited to 'src/game/WaypointManager.cpp')
-rw-r--r-- | src/game/WaypointManager.cpp | 68 |
1 files changed, 50 insertions, 18 deletions
diff --git a/src/game/WaypointManager.cpp b/src/game/WaypointManager.cpp index d72ac1e266e..a6dda2477ff 100644 --- a/src/game/WaypointManager.cpp +++ b/src/game/WaypointManager.cpp @@ -10,12 +10,12 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Database/DatabaseEnv.h" @@ -24,20 +24,30 @@ #include "WaypointManager.h" #include "ProgressBar.h" #include "MapManager.h" +#include "ObjectMgr.h" INSTANTIATE_SINGLETON_1(WaypointManager); bool WaypointBehavior::isEmpty() { - return emote == 0 && spell == 0 && model1 == 0 && model2 == 0 && text[0].empty() && - text[1].empty() && text[2].empty() && text[3].empty() && text[4].empty(); + if (emote || spell || model1 || model2) + return false; + + for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + if(textid[i]) + return false; + + return true; } WaypointBehavior::WaypointBehavior(const WaypointBehavior &b) { - emote = b.emote; spell = b.spell; model1 = b.model1; model2 = b.model2; - text[0] = b.text[0]; text[1] = b.text[1]; text[2] = b.text[2]; - text[3] = b.text[3]; text[4] = b.text[4]; + emote = b.emote; + spell = b.spell; + model1 = b.model1; + model2 = b.model2; + for(int i=0; i < MAX_WAYPOINT_TEXT; ++i) + textid[i] = b.textid[i]; } void WaypointManager::Load() @@ -66,7 +76,7 @@ void WaypointManager::Load() delete result; } - 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"); + 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"); if(result) { barGoLink bar( result->GetRowCount() ); @@ -113,11 +123,33 @@ void WaypointManager::Load() be.model2 = fields[5].GetUInt32(); be.emote = fields[7].GetUInt32(); be.spell = fields[8].GetUInt32(); - be.text[0] = fields[9].GetCppString(); - be.text[1] = fields[10].GetCppString(); - be.text[2] = fields[11].GetCppString(); - be.text[3] = fields[12].GetCppString(); - be.text[4] = fields[13].GetCppString(); + + // load and store without holes in array + int j = 0; + for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i) + { + be.textid[j] = fields[9+i].GetUInt32(); + if(be.textid[j]) + { + if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID) + { + sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[j]); + continue; + } + + if (!objmgr.GetTrinityStringLocale (be.textid[j])) + { + sLog.outErrorDb("ERROR: Waypoint path %d (point %d), have invalid text id (%i) in `textid%d, ignored.", + id, point, be.textid[j], i+1); + continue; + } + + ++j; // to next internal field + } + } + // fill array tail + for(; j < MAX_WAYPOINT_TEXT; ++j) + be.textid[j] = 0; // save memory by not storing empty behaviors if(!be.isEmpty()) @@ -265,11 +297,11 @@ void WaypointManager::SetNodeText(uint32 id, uint32 point, const char *text_fiel WaypointNode &node = itr->second[point-1]; if(!node.behavior) node.behavior = new WaypointBehavior(); - if(field == "text1") node.behavior->text[0] = text ? text : ""; - if(field == "text2") node.behavior->text[1] = text ? text : ""; - if(field == "text3") node.behavior->text[2] = text ? text : ""; - if(field == "text4") node.behavior->text[3] = text ? text : ""; - if(field == "text5") node.behavior->text[4] = text ? text : ""; +// if(field == "text1") node.behavior->text[0] = text ? text : ""; +// if(field == "text2") node.behavior->text[1] = text ? text : ""; +// if(field == "text3") node.behavior->text[2] = text ? text : ""; +// if(field == "text4") node.behavior->text[3] = text ? text : ""; +// if(field == "text5") node.behavior->text[4] = text ? text : ""; if(field == "emote") node.behavior->emote = text ? atoi(text) : 0; if(field == "spell") node.behavior->spell = text ? atoi(text) : 0; if(field == "model1") node.behavior->model1 = text ? atoi(text) : 0; |