aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorVincent-Michael <Vincent_Michael@gmx.de>2013-09-01 23:48:40 +0200
committerVincent-Michael <Vincent_Michael@gmx.de>2013-09-01 23:48:40 +0200
commit97fc632b9d32727480d42e7c056dff72ead8fb4e (patch)
tree0898abdb12107ced7fcb53febb4556d8e465b3aa /src/server/game
parentd6fdd05493aaa8600b07eb17dfee222a8379b033 (diff)
parent37bdc7a62b5d719f9c78d8db99837c769ce900e0 (diff)
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Conflicts: src/server/game/Entities/Object/Object.cpp src/server/game/Entities/Object/Object.h src/server/game/Server/WorldSession.cpp
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp68
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp17
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h13
-rw-r--r--src/server/game/Entities/Object/Object.h2
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp10
-rw-r--r--src/server/game/Server/WorldSession.cpp173
-rw-r--r--src/server/game/World/World.cpp2
-rw-r--r--src/server/game/World/World.h2
8 files changed, 170 insertions, 117 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 2d6046cbddf..f94a3e79066 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -731,7 +731,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
me->AI()->EnterEvadeMode();
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_EVADE: Creature %u EnterEvadeMode", me->GetGUIDLow());
- return;
+ break;
}
case SMART_ACTION_FLEE_FOR_ASSIST:
{
@@ -854,7 +854,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_CALL_KILLEDMONSTER:
{
- if (e.target.type == SMART_TARGET_NONE) // Loot recipient and his group members
+ if (e.target.type == SMART_TARGET_NONE || e.target.type == SMART_TARGET_SELF) // Loot recipient and his group members
{
if (!me)
break;
@@ -1340,15 +1340,18 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!me)
break;
- ObjectList* targets = GetTargets(e, unit);
if (e.GetTargetType() == SMART_TARGET_SELF)
me->SetFacingTo(me->GetHomePosition().GetOrientation());
else if (e.GetTargetType() == SMART_TARGET_POSITION)
me->SetFacingTo(e.target.o);
- else if (targets && !targets->empty())
- me->SetFacingToObject(*targets->begin());
+ else if (ObjectList* targets = GetTargets(e, unit))
+ {
+ if (!targets->empty())
+ me->SetFacingToObject(*targets->begin());
+
+ delete targets;
+ }
- delete targets;
break;
}
case SMART_ACTION_PLAYMOVIE:
@@ -1445,7 +1448,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id %u for creature %u", equipId, npc->GetEntry());
delete targets;
- return;
+ break;
}
npc->SetCurrentEquipmentId(equipId);
@@ -1879,11 +1882,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
+ {
if (Creature* creature = (*itr)->ToCreature())
{
creature->GetMotionMaster()->Clear();
creature->GetMotionMaster()->MoveJump(e.target.x, e.target.y, e.target.z, (float)e.action.jump.speedxy, (float)e.action.jump.speedz);
}
+ }
/// @todo Resume path when reached jump location
delete targets;
@@ -1913,7 +1918,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!storedTargets)
{
delete targets;
- return;
+ break;
}
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
@@ -1950,6 +1955,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
+ {
if (Player* player = (*itr)->ToPlayer())
{
if (e.action.sendGossipMenu.gossipMenuId)
@@ -1959,6 +1965,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
player->SEND_GOSSIP_MENU(e.action.sendGossipMenu.gossipNpcTextId, GetBaseObject()->GetGUID());
}
+ }
delete targets;
break;
@@ -1970,15 +1977,32 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
+ {
if (IsCreature(*itr))
{
if (e.GetTargetType() == SMART_TARGET_SELF)
(*itr)->ToCreature()->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
else if (e.GetTargetType() == SMART_TARGET_POSITION)
(*itr)->ToCreature()->SetHomePosition(e.target.x, e.target.y, e.target.z, e.target.o);
+ else if (e.GetTargetType() == SMART_TARGET_CREATURE_RANGE || e.GetTargetType() == SMART_TARGET_CREATURE_GUID ||
+ e.GetTargetType() == SMART_TARGET_CREATURE_DISTANCE || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_RANGE ||
+ e.GetTargetType() == SMART_TARGET_GAMEOBJECT_GUID || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_DISTANCE ||
+ e.GetTargetType() == SMART_TARGET_CLOSEST_CREATURE || e.GetTargetType() == SMART_TARGET_CLOSEST_GAMEOBJECT ||
+ e.GetTargetType() == SMART_TARGET_OWNER_OR_SUMMONER || e.GetTargetType() == SMART_TARGET_ACTION_INVOKER ||
+ e.GetTargetType() == SMART_TARGET_CLOSEST_ENEMY || e.GetTargetType() == SMART_TARGET_CLOSEST_FRIENDLY)
+ {
+ if (ObjectList* targets = GetTargets(e, unit))
+ {
+ if (WorldObject* target = targets->front())
+ (*itr)->ToCreature()->SetHomePosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation());
+
+ delete targets;
+ }
+ }
else
- TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target for SMART_ACTION_SET_HOME_POS is not using SMART_TARGET_SELF or SMART_TARGET_POSITION, skipping");
+ TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript: Action target for SMART_ACTION_SET_HOME_POS is invalid, skipping");
}
+ }
delete targets;
break;
@@ -2101,7 +2125,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!sGameEventMgr->IsActiveEvent(eventId))
{
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_STOP, inactive event (id: %u)", eventId);
- return;
+ break;
}
sGameEventMgr->StopEvent(eventId, true);
break;
@@ -2112,7 +2136,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (sGameEventMgr->IsActiveEvent(eventId))
{
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartScript::ProcessAction: At case SMART_ACTION_GAME_EVENT_START, already activated event (id: %u)", eventId);
- return;
+ break;
}
sGameEventMgr->StartEvent(eventId, true);
break;
@@ -2621,10 +2645,20 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
}
case SMART_EVENT_TARGET_CASTING:
{
- if (!me || !me->IsInCombat() || !me->GetVictim() || !me->GetVictim()->IsNonMeleeSpellCasted(false, false, true))
+ if (!me || !me->IsInCombat())
return;
- ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax, me->GetVictim());
+ Unit* victim = me->GetVictim();
+
+ if (!victim || !victim->IsNonMeleeSpellCasted(false, false, true))
+ return;
+
+ if (e.event.targetCasting.spellId > 0)
+ if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
+ if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
+ return;
+
+ ProcessTimedAction(e, e.event.targetCasting.repeatMin, e.event.targetCasting.repeatMax, me->GetVictim());
break;
}
case SMART_EVENT_FRIENDLY_HEALTH:
@@ -2632,10 +2666,10 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!me || !me->IsInCombat())
return;
- Unit* target = DoSelectLowestHpFriendly((float)e.event.friendlyHealt.radius, e.event.friendlyHealt.hpDeficit);
+ Unit* target = DoSelectLowestHpFriendly((float)e.event.friendlyHealth.radius, e.event.friendlyHealth.hpDeficit);
if (!target || !target->IsInCombat())
return;
- ProcessTimedAction(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax, target);
+ ProcessTimedAction(e, e.event.friendlyHealth.repeatMin, e.event.friendlyHealth.repeatMax, target);
break;
}
case SMART_EVENT_FRIENDLY_IS_CC:
@@ -2983,7 +3017,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
{
uint32 healthPct = uint32((*itr)->ToUnit()->GetHealthPct());
- if (healthPct > e.event.friendlyHealtPct.maxHpPct || healthPct < e.event.friendlyHealtPct.minHpPct)
+ if (healthPct > e.event.friendlyHealthPct.maxHpPct || healthPct < e.event.friendlyHealthPct.minHpPct)
continue;
target = (*itr)->ToUnit();
@@ -2996,7 +3030,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!target)
return;
- ProcessTimedAction(e, e.event.friendlyHealtPct.repeatMin, e.event.friendlyHealtPct.repeatMax, target);
+ ProcessTimedAction(e, e.event.friendlyHealthPct.repeatMin, e.event.friendlyHealthPct.repeatMax, target);
break;
}
default:
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index 081599c322e..ae87d7122d4 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -407,10 +407,10 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
}
break;
case SMART_EVENT_FRIENDLY_HEALTH:
- if (!NotNULL(e, e.event.friendlyHealt.radius))
+ if (!NotNULL(e, e.event.friendlyHealth.radius))
return false;
- if (!IsMinMaxValid(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax))
+ if (!IsMinMaxValid(e, e.event.friendlyHealth.repeatMin, e.event.friendlyHealth.repeatMax))
return false;
break;
case SMART_EVENT_FRIENDLY_IS_CC:
@@ -437,6 +437,15 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
return false;
break;
case SMART_EVENT_TARGET_CASTING:
+ if (e.event.targetCasting.spellId > 0 && !sSpellMgr->GetSpellInfo(e.event.targetCasting.spellId))
+ {
+ sLog->outError(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Spell entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.spellHit.spell);
+ return false;
+ }
+
+ if (!IsMinMaxValid(e, e.event.targetCasting.repeatMin, e.event.targetCasting.repeatMax))
+ return false;
+ break;
case SMART_EVENT_PASSENGER_BOARDED:
case SMART_EVENT_PASSENGER_REMOVED:
if (!IsMinMaxValid(e, e.event.minMax.repeatMin, e.event.minMax.repeatMax))
@@ -546,10 +555,10 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
break;
}
case SMART_EVENT_FRIENDLY_HEALTH_PCT:
- if (!IsMinMaxValid(e, e.event.friendlyHealtPct.repeatMin, e.event.friendlyHealtPct.repeatMax))
+ if (!IsMinMaxValid(e, e.event.friendlyHealthPct.repeatMin, e.event.friendlyHealthPct.repeatMax))
return false;
- if (e.event.friendlyHealtPct.maxHpPct > 100 || e.event.friendlyHealtPct.minHpPct > 100)
+ if (e.event.friendlyHealthPct.maxHpPct > 100 || e.event.friendlyHealthPct.minHpPct > 100)
{
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u has pct value above 100, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
return false;
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 0138d2b07a3..6f0dd31e11f 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -95,7 +95,7 @@ enum SMART_EVENT
SMART_EVENT_OOC_LOS = 10, // NoHostile, MaxRnage, CooldownMin, CooldownMax
SMART_EVENT_RESPAWN = 11, // type, MapId, ZoneId
SMART_EVENT_TARGET_HEALTH_PCT = 12, // HPMin%, HPMax%, RepeatMin, RepeatMax
- SMART_EVENT_TARGET_CASTING = 13, // RepeatMin, RepeatMax
+ SMART_EVENT_TARGET_CASTING = 13, // RepeatMin, RepeatMax, spellid
SMART_EVENT_FRIENDLY_HEALTH = 14, // HPDeficit, Radius, RepeatMin, RepeatMax
SMART_EVENT_FRIENDLY_IS_CC = 15, // Radius, RepeatMin, RepeatMax
SMART_EVENT_FRIENDLY_MISSING_BUFF = 16, // SpellId, Radius, RepeatMin, RepeatMax
@@ -216,11 +216,18 @@ struct SmartEvent
struct
{
+ uint32 repeatMin;
+ uint32 repeatMax;
+ uint32 spellId;
+ } targetCasting;
+
+ struct
+ {
uint32 hpDeficit;
uint32 radius;
uint32 repeatMin;
uint32 repeatMax;
- } friendlyHealt;
+ } friendlyHealth;
struct
{
@@ -369,7 +376,7 @@ struct SmartEvent
uint32 maxHpPct;
uint32 repeatMin;
uint32 repeatMax;
- } friendlyHealtPct;
+ } friendlyHealthPct;
struct
{
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 27ca1d7df89..e7f7be356a6 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -55,7 +55,7 @@ enum TypeMask
TYPEMASK_DYNAMICOBJECT = 0x0040,
TYPEMASK_CORPSE = 0x0080,
TYPEMASK_AREATRIGGER = 0x0100,
- TYPEMASK_SEER = TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
+ TYPEMASK_SEER = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
};
enum TypeID
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 81a07e2620d..b7321b7c51d 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -586,6 +586,10 @@ void ObjectMgr::LoadCreatureTemplateAddons()
TC_LOG_ERROR(LOG_FILTER_SQL, "Creature (Entry: %u) has wrong spell %u defined in `auras` field in `creature_template_addon`.", entry, uint32(atol(*itr)));
continue;
}
+
+ if (AdditionalSpellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
+ TC_LOG_ERROR(LOG_FILTER_SQL, "Creature (Entry: %u) has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_template_addon`.", entry, uint32(atol(*itr)));
+
creatureAddon.auras[i++] = uint32(atol(*itr));
}
@@ -600,7 +604,7 @@ void ObjectMgr::LoadCreatureTemplateAddons()
if (!sEmotesStore.LookupEntry(creatureAddon.emote))
{
- TC_LOG_ERROR(LOG_FILTER_SQL, "Creature (Entry: %u) has invalid emote (%u) defined in `creature_addon`.", entry, creatureAddon.emote);
+ TC_LOG_ERROR(LOG_FILTER_SQL, "Creature (Entry: %u) has invalid emote (%u) defined in `creature_template_addon`.", entry, creatureAddon.emote);
creatureAddon.emote = 0;
}
@@ -959,6 +963,10 @@ void ObjectMgr::LoadCreatureAddons()
TC_LOG_ERROR(LOG_FILTER_SQL, "Creature (GUID: %u) has wrong spell %u defined in `auras` field in `creature_addon`.", guid, uint32(atol(*itr)));
continue;
}
+
+ if (AdditionalSpellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
+ TC_LOG_ERROR(LOG_FILTER_SQL, "Creature (GUID: %u) has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_addon`.", guid, uint32(atol(*itr)));
+
creatureAddon.auras[i++] = uint32(atol(*itr));
}
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index 2fe882d0c8a..275349c83cb 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -317,107 +317,102 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
_recvQueue.next(packet, updater))
{
if (!AntiDOS.EvaluateOpcode(*packet))
- {
- delete packet;
- packet = NULL;
KickPlayer();
- }
- if (packet)
+ OpcodeHandler const* opHandle = opcodeTable[packet->GetOpcode()];
+ try
{
- OpcodeHandler const* opHandle = opcodeTable[packet->GetOpcode()];
- try
+ switch (opHandle->Status)
{
- switch (opHandle->Status)
- {
- case STATUS_LOGGEDIN:
- if (!_player)
- {
- // skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
- //! If player didn't log out a while ago, it means packets are being sent while the server does not recognize
- //! the client to be in world yet. We will re-add the packets to the bottom of the queue and process them later.
- if (!m_playerRecentlyLogout)
- {
- //! Prevent infinite loop
- if (!firstDelayedPacket)
- firstDelayedPacket = packet;
- //! Because checking a bool is faster than reallocating memory
- deletePacket = false;
- QueuePacket(packet);
- //! Log
- TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "Re-enqueueing packet with opcode %s with with status STATUS_LOGGEDIN. "
- "Player is currently not in world yet.", GetOpcodeNameForLogging(packet->GetOpcode()).c_str());
- }
- }
- else if (_player->IsInWorld())
- {
- sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
- (this->*opHandle->Handler)(*packet);
- LogUnprocessedTail(packet);
- }
- // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
- break;
- case STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT:
- if (!_player && !m_playerRecentlyLogout && !m_playerLogout) // There's a short delay between _player = null and m_playerRecentlyLogout = true during logout
- LogUnexpectedOpcode(packet, "STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT",
- "the player has not logged in yet and not recently logout");
- else
+ case STATUS_LOGGEDIN:
+ if (!_player)
+ {
+ // skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
+ //! If player didn't log out a while ago, it means packets are being sent while the server does not recognize
+ //! the client to be in world yet. We will re-add the packets to the bottom of the queue and process them later.
+ if (!m_playerRecentlyLogout)
{
- // not expected _player or must checked in packet hanlder
- sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
- (this->*opHandle->Handler)(*packet);
- LogUnprocessedTail(packet);
+ //! Prevent infinite loop
+ if (!firstDelayedPacket)
+ firstDelayedPacket = packet;
+ //! Because checking a bool is faster than reallocating memory
+ deletePacket = false;
+ QueuePacket(packet);
+ //! Log
+ TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "Re-enqueueing packet with opcode %s with with status STATUS_LOGGEDIN. "
+ "Player is currently not in world yet.", GetOpcodeNameForLogging(packet->GetOpcode()).c_str());
}
- break;
- case STATUS_TRANSFER:
- if (!_player)
- LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player has not logged in yet");
- else if (_player->IsInWorld())
- LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world");
- else
- {
- sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
- (this->*opHandle->Handler)(*packet);
- LogUnprocessedTail(packet);
- }
- break;
- case STATUS_AUTHED:
- // prevent cheating with skip queue wait
- if (m_inQueue)
- {
- LogUnexpectedOpcode(packet, "STATUS_AUTHED", "the player not pass queue yet");
- break;
- }
-
- // some auth opcodes can be recieved before STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes
- // however when we recieve CMSG_CHAR_ENUM we are surely no longer during the logout process.
- if (packet->GetOpcode() == CMSG_CHAR_ENUM)
- m_playerRecentlyLogout = false;
-
+ }
+ else if (_player->IsInWorld())
+ {
sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
(this->*opHandle->Handler)(*packet);
LogUnprocessedTail(packet);
+ }
+ // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
+ break;
+ case STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT:
+ if (!_player && !m_playerRecentlyLogout && !m_playerLogout) // There's a short delay between _player = null and m_playerRecentlyLogout = true during logout
+ LogUnexpectedOpcode(packet, "STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT",
+ "the player has not logged in yet and not recently logout");
+ else
+ {
+ // not expected _player or must checked in packet hanlder
+ sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
+ (this->*opHandle->Handler)(*packet);
+ LogUnprocessedTail(packet);
+ }
+ break;
+ case STATUS_TRANSFER:
+ if (!_player)
+ LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player has not logged in yet");
+ else if (_player->IsInWorld())
+ LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world");
+ else
+ {
+ sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
+ (this->*opHandle->Handler)(*packet);
+ LogUnprocessedTail(packet);
+ }
+ break;
+ case STATUS_AUTHED:
+ // prevent cheating with skip queue wait
+ if (m_inQueue)
+ {
+ LogUnexpectedOpcode(packet, "STATUS_AUTHED", "the player not pass queue yet");
break;
- case STATUS_NEVER:
- TC_LOG_ERROR(LOG_FILTER_OPCODES, "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str()
- , GetPlayerInfo().c_str());
- break;
- case STATUS_UNHANDLED:
- TC_LOG_ERROR(LOG_FILTER_OPCODES, "Received not handled opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str()
- , GetPlayerInfo().c_str());
- break;
- }
+ }
+
+ // some auth opcodes can be recieved before STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes
+ // however when we recieve CMSG_CHAR_ENUM we are surely no longer during the logout process.
+ if (packet->GetOpcode() == CMSG_CHAR_ENUM)
+ m_playerRecentlyLogout = false;
+
+ sScriptMgr->OnPacketReceive(m_Socket, WorldPacket(*packet));
+ (this->*opHandle->Handler)(*packet);
+ LogUnprocessedTail(packet);
+ break;
+ case STATUS_NEVER:
+ TC_LOG_ERROR(LOG_FILTER_OPCODES, "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str()
+ , GetPlayerInfo().c_str());
+ break;
+ case STATUS_UNHANDLED:
+ TC_LOG_ERROR(LOG_FILTER_OPCODES, "Received not handled opcode %s from %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str()
+ , GetPlayerInfo().c_str());
+ break;
}
- catch(ByteBufferException &)
- {
- TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
- packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
- packet->hexlike();
- }
-
- if (deletePacket)
- delete packet;
}
+ catch (ByteBufferException const&)
+ {
+ TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
+ packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
+ packet->hexlike();
+ }
+
+ if (deletePacket)
+ delete packet;
+
+ deletePacket = true;
}
if (m_Socket && !m_Socket->IsClosed() && _warden)
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 5fdc499403a..7ec30c49d3c 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -84,7 +84,7 @@
ACE_Atomic_Op<ACE_Thread_Mutex, bool> World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
-volatile uint32 World::m_worldLoopCounter = 0;
+ACE_Atomic_Op<ACE_Thread_Mutex, uint32> World::m_worldLoopCounter = 0;
float World::m_MaxVisibleDistanceOnContinents = DEFAULT_VISIBILITY_DISTANCE;
float World::m_MaxVisibleDistanceInInstances = DEFAULT_VISIBILITY_INSTANCE;
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index 0ba76ff3ce2..8de393ee54b 100644
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -534,7 +534,7 @@ struct CharacterNameData
class World
{
public:
- static volatile uint32 m_worldLoopCounter;
+ static ACE_Atomic_Op<ACE_Thread_Mutex, uint32> m_worldLoopCounter;
World();
~World();