Skip to content

Commit d0fd988

Browse files
0bluratkosrb
andauthored
Packet parsing in IO thread (#3303)
Co-authored-by: ratkosrb <ratkomladic2@abv.bg>
1 parent cef24fc commit d0fd988

20 files changed

Lines changed: 700 additions & 707 deletions

src/game/Anticheat/MovementAnticheat/MovementAnticheat.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ uint32 MovementAnticheat::ComputeCheatAction(std::stringstream& reason)
211211
uint32 action = CHEAT_ACTION_NONE;
212212

213213
auto AddPenaltyForCheat = [&action, &reason, this](bool total, CheatType cheatType, eConfigBoolValues enabledConfig, eConfigUInt32Values thresholdConfig, eConfigUInt32Values penaltyConfig)
214-
{
214+
{
215215
if (sWorld.getConfig(enabledConfig))
216216
{
217217
ASSERT(cheatType < CHEATS_COUNT);
@@ -610,7 +610,7 @@ uint32 MovementAnticheat::HandlePositionTests(Player* pPlayer, MovementInfo& mov
610610
(sWorld.getConfig(CONFIG_BOOL_AC_MOVEMENT_PLAYERS_ONLY) && (m_session->GetSecurity() != SEC_PLAYER)) ||
611611
!pPlayer->movespline->Finalized())
612612
return 0;
613-
613+
614614
if (pPlayer != me)
615615
InitNewPlayer(pPlayer);
616616

@@ -682,7 +682,7 @@ uint32 MovementAnticheat::HandlePositionTests(Player* pPlayer, MovementInfo& mov
682682
cheatFlags |= flags;
683683
}
684684

685-
if (IsFallEndOpcode(opcode) ||
685+
if (IsFallEndOpcode(opcode) ||
686686
movementInfo.HasMovementFlag(MOVEFLAG_ROOT))
687687
m_knockBack = false;
688688

@@ -697,8 +697,8 @@ uint32 MovementAnticheat::HandlePositionTests(Player* pPlayer, MovementInfo& mov
697697
{
698698
me->m_movementInfo.moveFlags = movementInfo.moveFlags;
699699
me->m_movementInfo.CorrectData();
700-
}
701-
700+
}
701+
702702
if (HAS_CHEAT(CHEAT_TYPE_OVERSPEED_JUMP) &&
703703
sWorld.getConfig(CONFIG_BOOL_AC_MOVEMENT_CHEAT_OVERSPEED_JUMP_REJECT))
704704
{
@@ -733,7 +733,7 @@ uint32 MovementAnticheat::HandleFlagTests(Player* pPlayer, MovementInfo& movemen
733733
if (!sWorld.getConfig(CONFIG_BOOL_AC_MOVEMENT_ENABLED) ||
734734
(sWorld.getConfig(CONFIG_BOOL_AC_MOVEMENT_PLAYERS_ONLY) && (m_session->GetSecurity() != SEC_PLAYER)))
735735
return 0;
736-
736+
737737
if (me != pPlayer)
738738
InitNewPlayer(pPlayer);
739739

@@ -941,7 +941,7 @@ bool MovementAnticheat::CheckFallReset(MovementInfo const& movementInfo) const
941941
if (!GetLastMovementInfo().HasMovementFlag(MOVEFLAG_JUMPING | MOVEFLAG_FALLINGFAR))
942942
return true;
943943
}
944-
944+
945945
return movementInfo.fallTime != 0 || movementInfo.jump.zspeed != 0.0f;
946946
}
947947

@@ -997,7 +997,7 @@ bool MovementAnticheat::CheckMoveStart(MovementInfo const& movementInfo, uint16
997997
!GetLastMovementInfo().HasMovementFlag(MOVEFLAG_FORWARD))
998998
return true;
999999
}
1000-
1000+
10011001
if (opcode == MSG_MOVE_START_BACKWARD)
10021002
{
10031003
if (!movementInfo.HasMovementFlag(MOVEFLAG_BACKWARD))
@@ -1065,7 +1065,7 @@ bool MovementAnticheat::CheckMoveStart(MovementInfo const& movementInfo, uint16
10651065
}
10661066
else
10671067
{
1068-
1068+
10691069
if (movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING) &&
10701070
!GetLastMovementInfo().HasMovementFlag(MOVEFLAG_SWIMMING) &&
10711071
!me->HasCheatOption(PLAYER_CHEAT_FLY))
@@ -1260,7 +1260,7 @@ uint32 MovementAnticheat::CheckSpeedHack(MovementInfo const& movementInfo, uint1
12601260
(opcode == CMSG_MOVE_SPLINE_DONE) ||
12611261
IsInKnockBack() ||
12621262
!GetLastMovementInfo().ctime ||
1263-
me->IsTaxiFlying() ||
1263+
me->IsTaxiFlying() ||
12641264
me->IsBeingTeleported())
12651265
return 0;
12661266

@@ -1477,7 +1477,7 @@ void MovementAnticheat::CheckBotting(uint16 opcode, MovementInfo const& movement
14771477
// we store turns count here
14781478
m_cheatOccuranceTotal[CHEAT_TYPE_BOTTING]++;
14791479
}
1480-
1480+
14811481
m_movementPacketsCount++;
14821482
}
14831483

@@ -1500,7 +1500,7 @@ bool MovementAnticheat::CheckTeleport(MovementInfo const& movementInfo) const
15001500
float const distance2d = movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT) ?
15011501
GetDistance2D(GetLastMovementInfo().t_pos, movementInfo.t_pos) :
15021502
GetDistance2D(GetLastMovementInfo().pos, movementInfo.pos);
1503-
1503+
15041504
if (distance2d > 1.0f)
15051505
return true;
15061506

@@ -1512,7 +1512,7 @@ bool MovementAnticheat::CheckTeleport(MovementInfo const& movementInfo) const
15121512
float const distanceZ = movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT) ?
15131513
std::abs(GetLastMovementInfo().t_pos.z - movementInfo.t_pos.z) :
15141514
std::abs(GetLastMovementInfo().pos.z - movementInfo.pos.z);
1515-
1515+
15161516
if (distanceZ > 2.0f)
15171517
return true;
15181518
}

src/game/Anticheat/MovementAnticheat/MovementAnticheat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class MovementAnticheat
145145
uint32 m_movementPacketsCount = 0;
146146
TurnType m_turnType = TURN_NONE;
147147

148-
// Wallclimb limits - initialized from vmangos.conf
148+
// Wallclimb limits - initialized from vmangos.conf
149149
static float m_wallSlope;
150150
static float m_wallSlopeHigh;
151151

src/game/PlayerBots/BattleBotAI.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ float BattleBotAI::GetMaxAggroDistanceForMap() const
233233
BattleGround* bg = me->GetBattleGround();
234234
if (!bg || bg->GetTypeID() != BATTLEGROUND_AV)
235235
return 50.0f;
236-
236+
237237
return 30.0f;
238238
}
239239

@@ -488,7 +488,7 @@ void BattleBotAI::OnPacketReceived(WorldPacket const* packet)
488488
#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4
489489
*data << uint32(me->GetMapId());
490490
#endif
491-
me->GetSession()->QueuePacket(std::move(data));
491+
me->GetSession()->QueueBinaryPacket(std::move(data));
492492
}
493493
}
494494
return;
@@ -534,7 +534,7 @@ void BattleBotAI::UpdateWaypointMovement()
534534
return;
535535

536536
if (StartNewPathToObjective())
537-
return;
537+
return;
538538

539539
if (StartNewPathFromBeginning())
540540
return;
@@ -772,7 +772,7 @@ void BattleBotAI::UpdateAI(uint32 const diff)
772772
}
773773
}
774774
}
775-
775+
776776
if (me->IsDead())
777777
{
778778
if (!m_wasDead)
@@ -781,7 +781,7 @@ void BattleBotAI::UpdateAI(uint32 const diff)
781781
OnJustDied();
782782
return;
783783
}
784-
784+
785785
if (me->InBattleGround())
786786
{
787787
if (me->GetDeathState() == CORPSE)
@@ -799,7 +799,7 @@ void BattleBotAI::UpdateAI(uint32 const diff)
799799
//me->SendCreateUpdateToPlayer(pLeader);
800800
}
801801
}
802-
802+
803803
return;
804804
}
805805
else
@@ -841,7 +841,7 @@ void BattleBotAI::UpdateAI(uint32 const diff)
841841
me->ClearTarget();
842842

843843
Unit* pVictim = me->GetVictim();
844-
844+
845845
// Prevent battelbot from chasing target entered stealth mode
846846
if (pVictim && !pVictim->IsVisibleForOrDetect(me, me, false))
847847
{
@@ -913,7 +913,7 @@ void BattleBotAI::UpdateAI(uint32 const diff)
913913

914914
if (UseMount())
915915
return;
916-
916+
917917
UpdateWaypointMovement();
918918
}
919919
return;
@@ -926,7 +926,7 @@ void BattleBotAI::UpdateAI(uint32 const diff)
926926
return;
927927
}
928928

929-
if (!pVictim || !IsValidHostileTarget(pVictim) ||
929+
if (!pVictim || !IsValidHostileTarget(pVictim) ||
930930
!pVictim->IsWithinDist(me, VISIBILITY_DISTANCE_SMALL))
931931
{
932932
if (Unit* pNewVictim = SelectAttackTarget(pVictim))
@@ -1302,7 +1302,7 @@ void BattleBotAI::UpdateOutOfCombatAI_Paladin()
13021302
m_isBuffing = true;
13031303
return;
13041304
}
1305-
}
1305+
}
13061306
}
13071307
}
13081308

@@ -1336,7 +1336,7 @@ void BattleBotAI::UpdateInCombatAI_Paladin()
13361336
{
13371337
me->CastSpell(me, m_spells.paladin.pSeal, false);
13381338
}
1339-
1339+
13401340
if (Unit* pVictim = me->GetVictim())
13411341
{
13421342
if (hasSeal && m_spells.paladin.pJudgement &&
@@ -1553,7 +1553,7 @@ void BattleBotAI::UpdateInCombatAI_Shaman()
15531553
if (DoCastSpell(pVictim, m_spells.shaman.pFlameShock) == SPELL_CAST_OK)
15541554
return;
15551555
}
1556-
1556+
15571557
if (m_spells.shaman.pLightningBolt &&
15581558
!me->CanReachWithMeleeAutoAttack(pVictim) &&
15591559
CanTryToCastSpell(pVictim, m_spells.shaman.pLightningBolt))
@@ -1923,7 +1923,7 @@ void BattleBotAI::UpdateInCombatAI_Mage()
19231923
{
19241924
if (DoCastSpell(me, m_spells.mage.pPresenceOfMind) == SPELL_CAST_OK)
19251925
return;
1926-
}
1926+
}
19271927

19281928
if (m_spells.mage.pScorch &&
19291929
(pVictim->GetHealthPercent() < 20.0f) &&
@@ -3166,7 +3166,7 @@ void BattleBotAI::UpdateInCombatAI_Druid()
31663166
me->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
31673167
me->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);
31683168
}
3169-
3169+
31703170
if (Unit* pVictim = me->GetVictim())
31713171
{
31723172
ShapeshiftForm const form = me->GetShapeshiftForm();
@@ -3270,7 +3270,7 @@ void BattleBotAI::UpdateInCombatAI_Druid()
32703270
if (DoCastSpell(pVictim, m_spells.druid.pClaw) == SPELL_CAST_OK)
32713271
return;
32723272
}
3273-
3273+
32743274
break;
32753275
}
32763276
case FORM_BEAR:

src/game/PlayerBots/CombatBotBaseAI.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,7 +3312,7 @@ void CombatBotBaseAI::OnPacketReceived(WorldPacket const* packet)
33123312
return;
33133313

33143314
std::unique_ptr<WorldPacket> data = std::make_unique<WorldPacket>(MSG_MOVE_WORLDPORT_ACK);
3315-
me->GetSession()->QueuePacket(std::move(data));
3315+
me->GetSession()->QueueBinaryPacket(std::move(data));
33163316
break;
33173317
}
33183318
case MSG_MOVE_TELEPORT_ACK:
@@ -3326,7 +3326,7 @@ void CombatBotBaseAI::OnPacketReceived(WorldPacket const* packet)
33263326
*data << me->GetLastCounterForMovementChangeType(TELEPORT);
33273327
#endif
33283328
*data << uint32(time(nullptr));
3329-
me->GetSession()->QueuePacket(std::move(data));
3329+
me->GetSession()->QueueBinaryPacket(std::move(data));
33303330
break;
33313331
}
33323332
case SMSG_LOGIN_SETTIMESPEED:
@@ -3346,13 +3346,13 @@ void CombatBotBaseAI::OnPacketReceived(WorldPacket const* packet)
33463346
if (status == TRADE_STATUS_BEGIN_TRADE)
33473347
{
33483348
std::unique_ptr<WorldPacket> data = std::make_unique<WorldPacket>(CMSG_BEGIN_TRADE);
3349-
me->GetSession()->QueuePacket(std::move(data));
3349+
me->GetSession()->QueueBinaryPacket(std::move(data));
33503350
}
33513351
else if (status == TRADE_STATUS_TRADE_ACCEPT)
33523352
{
33533353
std::unique_ptr<WorldPacket> data = std::make_unique<WorldPacket>(CMSG_ACCEPT_TRADE);
33543354
*data << uint32(1);
3355-
me->GetSession()->QueuePacket(std::move(data));
3355+
me->GetSession()->QueueBinaryPacket(std::move(data));
33563356
}
33573357
else if (status == TRADE_STATUS_TRADE_COMPLETE)
33583358
{
@@ -3369,7 +3369,7 @@ void CombatBotBaseAI::OnPacketReceived(WorldPacket const* packet)
33693369
std::unique_ptr<WorldPacket> data = std::make_unique<WorldPacket>(CMSG_RESURRECT_RESPONSE);
33703370
*data << me->GetResurrector();
33713371
*data << uint8(1);
3372-
me->GetSession()->QueuePacket(std::move(data));
3372+
me->GetSession()->QueueBinaryPacket(std::move(data));
33733373
break;
33743374
}
33753375
case SMSG_BATTLEFIELD_STATUS:
@@ -3404,7 +3404,7 @@ void CombatBotBaseAI::OnPacketReceived(WorldPacket const* packet)
34043404
*data << uint64(guid);
34053405
*data << uint32(slot);
34063406
*data << uint8(0); // pass
3407-
me->GetSession()->QueuePacket(std::move(data));
3407+
me->GetSession()->QueueBinaryPacket(std::move(data));
34083408
return;
34093409
}
34103410
}

src/game/PlayerBots/PartyBotAI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ void PartyBotAI::OnPacketReceived(WorldPacket const* packet)
563563
{
564564
std::unique_ptr<WorldPacket> data = std::make_unique<WorldPacket>(CMSG_DUEL_ACCEPTED, 8);
565565
*data << me->GetObjectGuid();
566-
me->GetSession()->QueuePacket(std::move(data));
566+
me->GetSession()->QueueBinaryPacket(std::move(data));
567567
return;
568568
}
569569
}

0 commit comments

Comments
 (0)