diff options
author | megamage <none@none> | 2009-03-31 14:17:57 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-31 14:17:57 -0600 |
commit | 4afd030b48c428af9775340cac9574118cee78d2 (patch) | |
tree | 004dc51c069367f180d478798e265f246be9d106 /src/game/MiscHandler.cpp | |
parent | b51cea6ce48295c3ebea9b2340d76a4ab147a6e5 (diff) | |
parent | e097f358a198b086d2960f774ac1da148b8b3c54 (diff) |
*Merge.
--HG--
branch : trunk
Diffstat (limited to 'src/game/MiscHandler.cpp')
-rw-r--r-- | src/game/MiscHandler.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 7b1a3731d16..35842906e49 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -26,6 +26,7 @@ #include "Opcodes.h" #include "Log.h" #include "Player.h" +#include "GossipDef.h" #include "World.h" #include "ObjectMgr.h" #include "WorldSession.h" @@ -68,6 +69,79 @@ void WorldSession::HandleRepopRequestOpcode( WorldPacket & /*recv_data*/ ) GetPlayer()->RepopAtGraveyard(); } +void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) +{ + CHECK_PACKET_SIZE(recv_data,8+4+4); + + sLog.outDebug("WORLD: CMSG_GOSSIP_SELECT_OPTION"); + + uint32 option; + uint32 unk; + uint64 guid; + std::string code = ""; + + recv_data >> guid >> unk >> option; + + if(_player->PlayerTalkClass->GossipOptionCoded( option )) + { + // recheck + CHECK_PACKET_SIZE(recv_data,8+4+1); + sLog.outBasic("reading string"); + recv_data >> code; + sLog.outBasic("string read: %s", code.c_str()); + } + + Creature *unit = NULL; + GameObject *go = NULL; + if(IS_CREATURE_GUID(guid)) + { + unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_NONE); + if (!unit) + { + sLog.outDebug( "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); + return; + } + } + else if(IS_GAMEOBJECT_GUID(guid)) + { + go = ObjectAccessor::GetGameObject(*_player, guid); + if (!go) + { + sLog.outDebug( "WORLD: HandleGossipSelectOptionOpcode - GameObject (GUID: %u) not found.", uint32(GUID_LOPART(guid)) ); + return; + } + } + else + { + sLog.outDebug( "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u.", uint32(GUID_HIPART(guid)), uint32(GUID_LOPART(guid)) ); + } + + // remove fake death + if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); + + if(!code.empty()) + { + if(unit) + { + if(!Script->GossipSelectWithCode( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str()) ) + unit->OnGossipSelect( _player, option ); + } + else + Script->GOSelectWithCode( _player, go, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str()); + } + else + { + if(unit) + { + if(!Script->GossipSelect( _player, unit, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option )) ) + unit->OnGossipSelect( _player, option ); + } + else + Script->GOSelect( _player, go, _player->PlayerTalkClass->GossipOptionSender( option ), _player->PlayerTalkClass->GossipOptionAction( option )); + } +} + void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) { CHECK_PACKET_SIZE(recv_data,4+4+1+1+4+4+4+4); |