diff options
author | jackpoz <giacomopoz@gmail.com> | 2015-06-13 12:27:19 +0200 |
---|---|---|
committer | DDuarte <dnpd.dd@gmail.com> | 2015-07-03 01:05:22 +0100 |
commit | 0b745370dc8629be7f64c941f8e6bd65b172a77d (patch) | |
tree | 933e84a0dc3dcd850bf61fbd7fbace1ef0359a2b /src/server/game/Texts/CreatureTextMgr.cpp | |
parent | f803178819ac1633709ee3a7fe1f296e5832536e (diff) |
Core/Texts: Fix race conditions in CreatureTextMgr repeat group
Fix race conditions in CreatureTextMgr repeat group happening with MapThreads > 1 reported by helgrind by moving Creature-GUID-base data from CreatureTextMgr to Creature.
Issues added in bbf86641a1c35fcc66de30d7a79175c31effde88
(cherry picked from commit d123c811623fcedcf125f56101b6aea773f460e0)
Conflicts:
src/server/game/Texts/CreatureTextMgr.cpp
Diffstat (limited to 'src/server/game/Texts/CreatureTextMgr.cpp')
-rw-r--r-- | src/server/game/Texts/CreatureTextMgr.cpp | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 4d61e2ec5d2..9967f9f299b 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -81,7 +81,7 @@ void CreatureTextMgr::LoadCreatureTexts() uint32 oldMSTime = getMSTime(); mTextMap.clear(); // for reload case - mTextRepeatMap.clear(); //reset all currently used temp texts + //all currently used temp texts are NOT reset PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_TEXT); PreparedQueryResult result = WorldDatabase.Query(stmt); @@ -228,13 +228,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject if (tempGroup.empty()) { - CreatureTextRepeatMap::iterator mapItr = mTextRepeatMap.find(source->GetGUID()); - if (mapItr != mTextRepeatMap.end()) - { - CreatureTextRepeatGroup::iterator groupItr = mapItr->second.find(textGroup); - groupItr->second.clear(); - } - + source->ClearTextRepeatGroup(textGroup); tempGroup = textGroupContainer; } @@ -428,26 +422,14 @@ void CreatureTextMgr::SetRepeatId(Creature* source, uint8 textGroup, uint8 id) if (!source) return; - CreatureTextRepeatIds& repeats = mTextRepeatMap[source->GetGUID()][textGroup]; - if (std::find(repeats.begin(), repeats.end(), id) == repeats.end()) - repeats.push_back(id); - else - TC_LOG_ERROR("sql.sql", "CreatureTextMgr: TextGroup %u for Creature (%s) %s, id %u already added", uint32(textGroup), source->GetName().c_str(), source->GetGUID().ToString().c_str(), uint32(id)); + source->SetTextRepeatId(textGroup, id); } CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 textGroup) const { ASSERT(source);//should never happen - CreatureTextRepeatIds ids; - CreatureTextRepeatMap::const_iterator mapItr = mTextRepeatMap.find(source->GetGUID()); - if (mapItr != mTextRepeatMap.end()) - { - CreatureTextRepeatGroup::const_iterator groupItr = (*mapItr).second.find(textGroup); - if (groupItr != mapItr->second.end()) - ids = groupItr->second; - } - return ids; + return source->GetTextRepeatGroup(textGroup); } bool CreatureTextMgr::TextExist(uint32 sourceEntry, uint8 textGroup) const |