[12144] Change behaviour of text selection for gossip menus

This way the behaviour will be well defined in case multiple conditions match.
Now the text with the highest condition-id will be taken.
This commit is contained in:
Schmoozerd 2012-08-29 21:51:21 +02:00 committed by Antz
parent 796068fc13
commit d387c20dad
2 changed files with 15 additions and 14 deletions

View file

@ -13118,33 +13118,34 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* pSource)
if (!menuId) if (!menuId)
return textId; return textId;
GossipMenusMapBounds pMenuBounds = sObjectMgr.GetGossipMenusMapBounds(menuId); uint32 scriptId = 0;
uint32 lastConditionId = 0;
GossipMenusMapBounds pMenuBounds = sObjectMgr.GetGossipMenusMapBounds(menuId);
for (GossipMenusMap::const_iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr) for (GossipMenusMap::const_iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
{ {
if (itr->second.conditionId && sObjectMgr.IsPlayerMeetToNEWCondition(this, itr->second.conditionId)) // Take the text that has the highest conditionId of all fitting
// TODO: Simplify logic to (!itr->second.conditionId && !lastConditionId) || <lineBelow>)
if (itr->second.conditionId > lastConditionId && sObjectMgr.IsPlayerMeetToNEWCondition(this, itr->second.conditionId))
{ {
lastConditionId = itr->second.conditionId;
textId = itr->second.text_id; textId = itr->second.text_id;
scriptId = itr->second.script_id;
// Start related script
if (itr->second.script_id)
GetMap()->ScriptsStart(sGossipScripts, itr->second.script_id, this, pSource);
break;
} }
else if (!itr->second.conditionId) else if (!itr->second.conditionId && !lastConditionId)
{ {
if (sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_1) && sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_2)) if (sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_1) && sObjectMgr.IsPlayerMeetToCondition(this, itr->second.cond_2))
{ {
textId = itr->second.text_id; textId = itr->second.text_id;
scriptId = itr->second.script_id;
// Start related script
if (itr->second.script_id)
GetMap()->ScriptsStart(sGossipScripts, itr->second.script_id, this, pSource);
break;
} }
} }
} }
// Start related script
if (scriptId)
GetMap()->ScriptsStart(sGossipScripts, scriptId, this, pSource);
return textId; return textId;
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "12143" #define REVISION_NR "12144"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__