[8871] Avoid use StopMoving when creature is already stopped.

Some additional code cleanup in related code.
This commit is contained in:
NoFantasy 2009-11-25 12:14:59 +01:00
parent 663038c7c7
commit 10ebadcadf
5 changed files with 48 additions and 41 deletions

View file

@ -32,30 +32,33 @@
#include "Language.h" #include "Language.h"
#include "ScriptCalls.h" #include "ScriptCalls.h"
void WorldSession::HandleBattlemasterHelloOpcode( WorldPacket & recv_data ) void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket & recv_data)
{ {
uint64 guid; uint64 guid;
recv_data >> guid; recv_data >> guid;
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)));
Creature *unit = GetPlayer()->GetMap()->GetCreature(guid); sLog.outDebug("WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)));
if (!unit)
Creature *pCreature = GetPlayer()->GetMap()->GetCreature(guid);
if (!pCreature)
return; return;
if(!unit->isBattleMaster()) // it's not battlemaster if (!pCreature->isBattleMaster()) // it's not battlemaster
return; return;
// Stop the npc if moving // Stop the npc if moving
unit->StopMoving(); if (!pCreature->IsStopped())
pCreature->StopMoving();
BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(unit->GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(pCreature->GetEntry());
if (bgTypeId == BATTLEGROUND_TYPE_NONE) if (bgTypeId == BATTLEGROUND_TYPE_NONE)
return; return;
if (!_player->GetBGAccessByLevel(bgTypeId)) if (!_player->GetBGAccessByLevel(bgTypeId))
{ {
// temp, must be gossip message... // temp, must be gossip message...
SendNotification(LANG_YOUR_BG_LEVEL_REQ_ERROR); SendNotification(LANG_YOUR_BG_LEVEL_REQ_ERROR);
return; return;
} }

View file

@ -700,29 +700,32 @@ void WorldSession::HandleListInventoryOpcode( WorldPacket & recv_data )
SendListInventory( guid ); SendListInventory( guid );
} }
void WorldSession::SendListInventory( uint64 vendorguid ) void WorldSession::SendListInventory(uint64 vendorguid)
{ {
sLog.outDebug( "WORLD: Sent SMSG_LIST_INVENTORY" ); sLog.outDebug("WORLD: Sent SMSG_LIST_INVENTORY");
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR); Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
if (!pCreature) if (!pCreature)
{ {
sLog.outDebug( "WORLD: SendListInventory - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid)) ); sLog.outDebug("WORLD: SendListInventory - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid)));
_player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0); _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0);
return; return;
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
// Stop the npc if moving // Stop the npc if moving
pCreature->StopMoving(); if (!pCreature->IsStopped())
pCreature->StopMoving();
VendorItemData const* vItems = pCreature->GetVendorItems(); VendorItemData const* vItems = pCreature->GetVendorItems();
if(!vItems)
if (!vItems)
{ {
_player->SendSellError( SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0); _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0);
return; return;
} }

View file

@ -249,37 +249,36 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleGossipHelloOpcode( WorldPacket & recv_data ) void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data)
{ {
sLog.outDebug( "WORLD: Received CMSG_GOSSIP_HELLO" ); sLog.outDebug("WORLD: Received CMSG_GOSSIP_HELLO");
uint64 guid; uint64 guid;
recv_data >> guid; recv_data >> guid;
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
if (!unit)
if (!pCreature)
{ {
sLog.outDebug( "WORLD: HandleGossipHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) ); sLog.outDebug("WORLD: HandleGossipHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)));
return; return;
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if( unit->isArmorer() || unit->isCivilian() || unit->isQuestGiver() || unit->isServiceProvider()) if (!pCreature->IsStopped())
{ pCreature->StopMoving();
unit->StopMoving();
}
if (unit->isSpiritGuide()) if (pCreature->isSpiritGuide())
unit->SendAreaSpiritHealerQueryOpcode(_player); pCreature->SendAreaSpiritHealerQueryOpcode(_player);
if(!Script->GossipHello( _player, unit )) if (!Script->GossipHello(_player, pCreature))
{ {
_player->TalkedToCreature(unit->GetEntry(),unit->GetGUID()); _player->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
unit->prepareGossipMenu(_player); pCreature->prepareGossipMenu(_player);
unit->sendPreparedGossip(_player); pCreature->sendPreparedGossip(_player);
} }
} }

View file

@ -76,28 +76,30 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode( WorldPacket & recv_data )
_player->PlayerTalkClass->SendQuestGiverStatus(questStatus, guid); _player->PlayerTalkClass->SendQuestGiverStatus(questStatus, guid);
} }
void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data ) void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket & recv_data)
{ {
uint64 guid; uint64 guid;
recv_data >> guid; recv_data >> guid;
sLog.outDebug ("WORLD: Received CMSG_QUESTGIVER_HELLO npc = %u", GUID_LOPART(guid)); sLog.outDebug ("WORLD: Received CMSG_QUESTGIVER_HELLO npc = %u", GUID_LOPART(guid));
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_NONE); Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
if (!pCreature) if (!pCreature)
{ {
sLog.outDebug ("WORLD: HandleQuestgiverHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", sLog.outDebug ("WORLD: HandleQuestgiverHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", GUID_LOPART(guid));
GUID_LOPART(guid));
return; return;
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
// Stop the npc if moving
pCreature->StopMoving();
if(Script->GossipHello( _player, pCreature ) ) // Stop the npc if moving
if (!pCreature->IsStopped())
pCreature->StopMoving();
if (Script->GossipHello(_player, pCreature))
return; return;
pCreature->prepareGossipMenu(_player); pCreature->prepareGossipMenu(_player);

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 "8870" #define REVISION_NR "8871"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__