From d387c20dadf17fe82a562410fe9d1d36f5121a80 Mon Sep 17 00:00:00 2001 From: Schmoozerd Date: Wed, 29 Aug 2012 21:51:21 +0200 Subject: [PATCH] [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. --- src/game/Player.cpp | 27 ++++++++++++++------------- src/shared/revision_nr.h | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 0eaee8cb8..b986e8deb 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -13118,33 +13118,34 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* pSource) if (!menuId) 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) { - 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) || ) + if (itr->second.conditionId > lastConditionId && sObjectMgr.IsPlayerMeetToNEWCondition(this, itr->second.conditionId)) { + lastConditionId = itr->second.conditionId; textId = itr->second.text_id; - - // Start related script - if (itr->second.script_id) - GetMap()->ScriptsStart(sGossipScripts, itr->second.script_id, this, pSource); - break; + scriptId = itr->second.script_id; } - 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)) { textId = itr->second.text_id; - - // Start related script - if (itr->second.script_id) - GetMap()->ScriptsStart(sGossipScripts, itr->second.script_id, this, pSource); - break; + scriptId = itr->second.script_id; } } } + // Start related script + if (scriptId) + GetMap()->ScriptsStart(sGossipScripts, scriptId, this, pSource); + return textId; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 50dd51d8c..f3bb58eb3 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12143" + #define REVISION_NR "12144" #endif // __REVISION_NR_H__