Core/Gossip: Gossip menu items will now have constant index, allowing to properly define scripts relying on that index when mixed with conditions. Script-created menus via ADD_GOSSIP_ITEM will still have the index generated dynamically

This commit is contained in:
Shauren
2011-05-26 23:57:17 +02:00
parent f91136b949
commit 0ad14aeafd
16 changed files with 587 additions and 653 deletions
@@ -88,7 +88,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
recv_data >> guid >> menuId >> gossipListId;
if (_player->PlayerTalkClass->GossipOptionCoded(gossipListId))
if (_player->PlayerTalkClass->IsGossipOptionCoded(gossipListId))
recv_data >> code;
Creature *unit = NULL;
@@ -128,7 +128,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
unit->LastUsedScriptID = unit->GetCreatureInfo()->ScriptID;
if (go)
go->LastUsedScriptID = go->GetGOInfo()->ScriptId;
_player->PlayerTalkClass->CloseGossip();
_player->PlayerTalkClass->SendCloseGossip();
return;
}
if (!code.empty())
@@ -136,13 +136,13 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
if (unit)
{
unit->AI()->sGossipSelectCode(_player, menuId, gossipListId, code.c_str());
if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId), code.c_str()))
if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str()))
_player->OnGossipSelect(unit, gossipListId, menuId);
}
else
{
go->AI()->GossipSelectCode(_player, menuId, gossipListId, code.c_str());
sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId), code.c_str());
sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
}
}
else
@@ -150,13 +150,13 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
if (unit)
{
unit->AI()->sGossipSelect(_player, menuId, gossipListId);
if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId)))
if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
_player->OnGossipSelect(unit, gossipListId, menuId);
}
else
{
go->AI()->GossipSelect(_player, menuId, gossipListId);
sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GossipOptionSender(gossipListId), _player->PlayerTalkClass->GossipOptionAction(gossipListId));
sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
}
}
}
@@ -497,7 +497,7 @@ void WorldSession::SendBindPoint(Creature *npc)
data << uint32(bindspell);
SendPacket(&data);
_player->PlayerTalkClass->CloseGossip();
_player->PlayerTalkClass->SendCloseGossip();
}
void WorldSession::HandleListStabledPetsOpcode(WorldPacket & recv_data)
@@ -130,7 +130,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
if (!pObject || (pObject->GetTypeId() != TYPEID_PLAYER && !pObject->hasQuest(quest)) ||
(pObject->GetTypeId() == TYPEID_PLAYER && !pObject->ToPlayer()->CanShareQuest(quest)))
{
_player->PlayerTalkClass->CloseGossip();
_player->PlayerTalkClass->SendCloseGossip();
_player->SetDivider(0);
return;
}
@@ -141,7 +141,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
// prevent cheating
if (!GetPlayer()->CanTakeQuest(qInfo, true))
{
_player->PlayerTalkClass->CloseGossip();
_player->PlayerTalkClass->SendCloseGossip();
_player->SetDivider(0);
return;
}
@@ -176,7 +176,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
pPlayer->SetDivider(_player->GetGUID());
//need confirmation that any gossip window will close
pPlayer->PlayerTalkClass->CloseGossip();
pPlayer->PlayerTalkClass->SendCloseGossip();
_player->SendQuestConfirmAccept(qInfo, pPlayer);
}
@@ -221,7 +221,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
default:
break;
}
_player->PlayerTalkClass->CloseGossip();
_player->PlayerTalkClass->SendCloseGossip();
if (qInfo->GetSrcSpell() > 0)
_player->CastSpell(_player, qInfo->GetSrcSpell(), true);
@@ -230,7 +230,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
}
}
_player->PlayerTalkClass->CloseGossip();
_player->PlayerTalkClass->SendCloseGossip();
}
void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket & recv_data)
@@ -245,7 +245,7 @@ void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket & recv_data)
Object* pObject = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT|TYPEMASK_ITEM);
if (!pObject || (!pObject->hasQuest(quest) && !pObject->hasInvolvedQuest(quest)))
{
_player->PlayerTalkClass->CloseGossip();
_player->PlayerTalkClass->SendCloseGossip();
return;
}
@@ -372,7 +372,7 @@ void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recv_data*/)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_CANCEL");
_player->PlayerTalkClass->CloseGossip();
_player->PlayerTalkClass->SendCloseGossip();
}
void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data)