mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[8871] Avoid use StopMoving when creature is already stopped.
Some additional code cleanup in related code.
This commit is contained in:
parent
663038c7c7
commit
10ebadcadf
5 changed files with 48 additions and 41 deletions
|
|
@ -32,23 +32,26 @@
|
||||||
#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;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
if (!pCreature->IsStopped())
|
||||||
pCreature->StopMoving();
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
// Stop the npc if moving
|
||||||
|
if (!pCreature->IsStopped())
|
||||||
pCreature->StopMoving();
|
pCreature->StopMoving();
|
||||||
|
|
||||||
if(Script->GossipHello( _player, pCreature ) )
|
if (Script->GossipHello(_player, pCreature))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pCreature->prepareGossipMenu(_player);
|
pCreature->prepareGossipMenu(_player);
|
||||||
|
|
|
||||||
|
|
@ -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__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue