diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/ObjectMgr.cpp | 3 | ||||
| -rw-r--r-- | src/game/Player.cpp | 15 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 3 | ||||
| -rw-r--r-- | src/game/WaypointManager.cpp | 68 | ||||
| -rw-r--r-- | src/game/WaypointManager.h | 1 |
5 files changed, 68 insertions, 22 deletions
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 751a3ca4fbc..e6fc35b21a4 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -44,6 +44,7 @@ #include "InstanceSaveMgr.h" #include "SpellAuras.h" #include "Util.h" +#include "WaypointManager.h" INSTANTIATE_SINGLETON_1(ObjectMgr); @@ -7471,6 +7472,8 @@ void ObjectMgr::LoadDbScriptStrings() CheckScripts(sGameObjectScripts,ids); CheckScripts(sEventScripts,ids); + WaypointMgr.CheckTextsExistance(ids); + for(std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr) sLog.outErrorDb( "Table `db_script_string` has unused string id %u", *itr); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 8fe5baed6f4..2736534ba07 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1016,6 +1016,13 @@ void Player::Update( uint32 p_time ) CheckExploreSystem(); + /*if(isCharmed()) + { + if(Unit *charmer = GetCharmer()) + if(charmer->GetTypeId() == TYPEID_UNIT && ((Creature*)charmer)->AI()) + ((Creature*)charmer)->AI()->UpdateCharmedAI(this, p_time); + }*/ + // Update items that have just a limited lifetime if (now>m_Last_tick) UpdateItemDuration(uint32(now- m_Last_tick)); @@ -5266,6 +5273,10 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele x = GetPositionX(); y = GetPositionY(); z = GetPositionZ(); + + // group update + if(GetGroup() && (old_x != x || old_y != y)) + SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); } // code block for underwater state update @@ -5273,10 +5284,6 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele CheckExploreSystem(); - // group update - if(GetGroup()) - SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); - return true; } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index e4a83c88093..0498c8d3711 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9622,6 +9622,9 @@ void Unit::SetMaxHealth(uint32 val) void Unit::SetPower(Powers power, uint32 val) { + if(GetPower(power) == val) + return; + uint32 maxPower = GetMaxPower(power); if(maxPower < val) val = maxPower; diff --git a/src/game/WaypointManager.cpp b/src/game/WaypointManager.cpp index a6dda2477ff..bd0d0635de4 100644 --- a/src/game/WaypointManager.cpp +++ b/src/game/WaypointManager.cpp @@ -124,32 +124,18 @@ void WaypointManager::Load() be.emote = fields[7].GetUInt32(); be.spell = fields[8].GetUInt32(); - // 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]) + be.textid[i] = fields[9+i].GetUInt32(); + if(be.textid[i]) { - if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID) + if (be.textid[i] < MIN_DB_SCRIPT_STRING_ID || be.textid[i] >= MAX_DB_SCRIPT_STRING_ID) { - sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[j]); + sLog.outErrorDb( "Table `db_script_string` not have string id %u", be.textid[i]); 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()) @@ -308,3 +294,49 @@ void WaypointManager::SetNodeText(uint32 id, uint32 point, const char *text_fiel if(field == "model2") node.behavior->model2 = text ? atoi(text) : 0; } } + +void WaypointManager::CheckTextsExistance(std::set<int32>& ids) +{ + WaypointPathMap::iterator pmItr = m_pathMap.begin(); + for ( ; pmItr != m_pathMap.end(); ++pmItr) + { + for (int i = 0; i < pmItr->second.size(); ++i) + { + if (!pmItr->second[i].behavior) + continue; + + // Now we check text existence and put all zero texts ids to the end of array + + // Counting leading zeros for futher textid shift + int zeroCount = 0; + for (int j = 0; j < MAX_WAYPOINT_TEXT; ++j) + { + if (!pmItr->second[i].behavior->textid[j]) + { + ++zeroCount; + continue; + } + else + { + if (!objmgr.GetMangosStringLocale(pmItr->second[i].behavior->textid[j])) + { + sLog.outErrorDb("ERROR: Some waypoint has textid%u with not existing %u text.", j, pmItr->second[i].behavior->textid[j]); + pmItr->second[i].behavior->textid[j] = 0; + ++zeroCount; + continue; + } + else + ids.erase(pmItr->second[i].behavior->textid[j]); + + // Shifting check + if (zeroCount) + { + // Correct textid but some zeros leading, so move it forward. + pmItr->second[i].behavior->textid[j-zeroCount] = pmItr->second[i].behavior->textid[j]; + pmItr->second[i].behavior->textid[j] = 0; + } + } + } + } + } +} diff --git a/src/game/WaypointManager.h b/src/game/WaypointManager.h index 75f01cc82f3..38cf5551d64 100644 --- a/src/game/WaypointManager.h +++ b/src/game/WaypointManager.h @@ -78,6 +78,7 @@ class WaypointManager void DeletePath(uint32 id); void SetNodePosition(uint32 id, uint32 point, float x, float y, float z); void SetNodeText(uint32 id, uint32 point, const char *text_field, const char *text); + void CheckTextsExistance(std::set<int32>& ids); private: void _addNode(uint32 id, uint32 point, float x, float y, float z, float o, uint32 delay, uint32 wpGuid); |
