Skip to content

Commit 00875fe

Browse files
committed
Core/Misc: Reduce code differences between branches
1 parent 7782a17 commit 00875fe

File tree

9 files changed

+62
-55
lines changed

9 files changed

+62
-55
lines changed

src/server/game/Entities/Player/Player.cpp

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16674,14 +16674,17 @@ void Player::SendQuestReward(Quest const* quest, uint32 XP) const
1667416674
{
1667516675
uint32 questId = quest->GetQuestId();
1667616676
sGameEventMgr->HandleQuestComplete(questId);
16677-
WorldPacket data(SMSG_QUESTGIVER_QUEST_COMPLETE, (4+4+4+4+4));
16678-
data << uint32(questId);
16677+
16678+
uint32 xp;
1667916679

1668016680
if (!IsMaxLevel())
16681-
data << uint32(XP);
16681+
xp = XP;
1668216682
else
16683-
data << uint32(0);
16683+
xp = 0;
1668416684

16685+
WorldPacket data(SMSG_QUESTGIVER_QUEST_COMPLETE, (4+4+4+4+4));
16686+
data << uint32(questId);
16687+
data << uint32(xp);
1668516688
data << uint32(quest->GetRewOrReqMoney(this));
1668616689
data << uint32(10 * quest->CalculateHonorGain(GetQuestLevel(quest)));
1668716690
data << uint32(quest->GetBonusTalents()); // bonus talents
@@ -20365,7 +20368,7 @@ void Player::SendResetInstanceFailed(uint32 reason, uint32 MapId) const
2036520368
// 1: There are players offline in your party.
2036620369
// 2>: There are players in your party attempting to zone into an instance.
2036720370
*/
20368-
WorldPacket data(SMSG_INSTANCE_RESET_FAILED, 4);
20371+
WorldPacket data(SMSG_INSTANCE_RESET_FAILED, 8);
2036920372
data << uint32(reason);
2037020373
data << uint32(MapId);
2037120374
SendDirectMessage(&data);
@@ -26215,6 +26218,26 @@ PetStable& Player::GetOrInitPetStable()
2621526218
return *m_petStable;
2621626219
}
2621726220

26221+
void Player::SendItemRefundResult(Item* item, ItemExtendedCostEntry const* iece, uint8 error) const
26222+
{
26223+
WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4 + 4 + 4 + 4 + 4 * 4 + 4 * 4);
26224+
data << uint64(item->GetGUID()); // item guid
26225+
data << uint32(error); // 0, or error code
26226+
if (!error)
26227+
{
26228+
data << uint32(item->GetPaidMoney()); // money cost
26229+
data << uint32(iece->HonorPoints); // honor point cost
26230+
data << uint32(iece->ArenaPoints); // arena point cost
26231+
for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data
26232+
{
26233+
data << uint32(iece->ItemID[i]);
26234+
data << uint32(iece->ItemCount[i]);
26235+
}
26236+
}
26237+
26238+
SendDirectMessage(&data);
26239+
}
26240+
2621826241
void Player::RefundItem(Item* item)
2621926242
{
2622026243
if (!item->IsRefundable())
@@ -26226,10 +26249,7 @@ void Player::RefundItem(Item* item)
2622626249
if (item->IsRefundExpired()) // item refund has expired
2622726250
{
2622826251
item->SetNotRefundable(this);
26229-
WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8+4);
26230-
data << uint64(item->GetGUID()); // Guid
26231-
data << uint32(10); // Error!
26232-
SendDirectMessage(&data);
26252+
SendItemRefundResult(item, nullptr, 10);
2623326253
return;
2623426254
}
2623526255

@@ -26267,25 +26287,11 @@ void Player::RefundItem(Item* item)
2626726287

2626826288
if (store_error)
2626926289
{
26270-
WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8+4);
26271-
data << uint64(item->GetGUID()); // Guid
26272-
data << uint32(10); // Error!
26273-
SendDirectMessage(&data);
26290+
SendItemRefundResult(item, iece, 10);
2627426291
return;
2627526292
}
2627626293

26277-
WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8+4+4+4+4+4*4+4*4);
26278-
data << uint64(item->GetGUID()); // item guid
26279-
data << uint32(0); // 0, or error code
26280-
data << uint32(item->GetPaidMoney()); // money cost
26281-
data << uint32(iece->HonorPoints); // honor point cost
26282-
data << uint32(iece->ArenaPoints); // arena point cost
26283-
for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data
26284-
{
26285-
data << uint32(iece->ItemID[i]);
26286-
data << uint32(iece->ItemCount[i]);
26287-
}
26288-
SendDirectMessage(&data);
26294+
SendItemRefundResult(item, iece, 0);
2628926295

2629026296
uint32 moneyRefund = item->GetPaidMoney(); // item-> will be invalidated in DestroyItem
2629126297

src/server/game/Entities/Player/Player.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct CharTitlesEntry;
4444
struct ChatChannelsEntry;
4545
struct CreatureTemplate;
4646
struct FactionEntry;
47+
struct ItemExtendedCostEntry;
4748
struct ItemSetEffect;
4849
struct ItemTemplate;
4950
struct Loot;
@@ -2496,6 +2497,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
24962497
GuidSet m_refundableItems;
24972498
void SendRefundInfo(Item* item);
24982499
void RefundItem(Item* item);
2500+
void SendItemRefundResult(Item* item, ItemExtendedCostEntry const* iece, uint8 error) const;
24992501

25002502
// know currencies are not removed at any point (0 displayed)
25012503
void AddKnownCurrency(uint32 itemId);

src/server/game/Entities/Unit/Unit.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11100,8 +11100,9 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
1110011100
// only if not player and not controlled by player pet. And not at BG
1110111101
if ((durabilityLoss && !player && !victim->ToPlayer()->InBattleground()) || (player && sWorld->getBoolConfig(CONFIG_DURABILITY_LOSS_IN_PVP)))
1110211102
{
11103-
TC_LOG_DEBUG("entities.unit", "We are dead, losing {} percent durability", sWorld->getRate(RATE_DURABILITY_LOSS_ON_DEATH));
11104-
plrVictim->DurabilityLossAll(sWorld->getRate(RATE_DURABILITY_LOSS_ON_DEATH), false);
11103+
double baseLoss = sWorld->getRate(RATE_DURABILITY_LOSS_ON_DEATH);
11104+
TC_LOG_DEBUG("entities.unit", "We are dead, losing {} percent durability", baseLoss);
11105+
plrVictim->DurabilityLossAll(baseLoss, false);
1110511106
// durability lost message
1110611107
plrVictim->SendDurabilityLoss();
1110711108
}
@@ -12210,6 +12211,17 @@ void Unit::UpdateObjectVisibility(bool forced)
1221012211
}
1221112212
}
1221212213

12214+
void Unit::SendMoveKnockBack(Player* player, float speedXY, float speedZ, float vcos, float vsin)
12215+
{
12216+
WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8 + 4 + 4 + 4 + 4 + 4));
12217+
data << GetPackGUID();
12218+
data << uint32(0); // counter
12219+
data << TaggedPosition<Position::XY>(vcos, vsin);
12220+
data << float(speedXY); // Horizontal speed
12221+
data << float(speedZ); // Z Movement speed (vertical)
12222+
player->SendDirectMessage(&data);
12223+
}
12224+
1221312225
void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
1221412226
{
1221512227
if (IsMovedByServer())
@@ -12220,15 +12232,7 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
1222012232
{
1222112233
float vcos, vsin;
1222212234
GetSinCos(x, y, vsin, vcos);
12223-
12224-
WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8 + 4 + 4 + 4 + 4 + 4));
12225-
data << GetPackGUID();
12226-
data << uint32(0); // counter
12227-
data << TaggedPosition<Position::XY>(vcos, vsin);
12228-
data << float(speedXY); // Horizontal speed
12229-
data << float(-speedZ); // Z Movement speed (vertical)
12230-
12231-
GetGameClientMovingMe()->SendDirectMessage(&data);
12235+
SendMoveKnockBack(GetGameClientMovingMe()->GetBasePlayer(), speedXY, -speedZ, vcos, vsin);
1223212236

1223312237
if (HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || HasAuraType(SPELL_AURA_FLY))
1223412238
SetCanFly(true, true);
@@ -12474,15 +12478,7 @@ void Unit::JumpTo(float speedXY, float speedZ, bool forward, Optional<Position>
1247412478
{
1247512479
float vcos = std::cos(angle+GetOrientation());
1247612480
float vsin = std::sin(angle+GetOrientation());
12477-
12478-
WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8+4+4+4+4+4));
12479-
data << GetPackGUID();
12480-
data << uint32(0); // Sequence
12481-
data << TaggedPosition<Position::XY>(vcos, vsin);
12482-
data << float(speedXY); // Horizontal speed
12483-
data << float(-speedZ); // Z Movement speed (vertical)
12484-
12485-
ToPlayer()->SendDirectMessage(&data);
12481+
SendMoveKnockBack(ToPlayer(), speedXY, -speedZ, vcos, vsin);
1248612482
}
1248712483
}
1248812484

src/server/game/Entities/Unit/Unit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,7 @@ class TC_GAME_API Unit : public WorldObject
12041204
void UpdateOrientation(float orientation);
12051205
void UpdateHeight(float newZ);
12061206

1207+
void SendMoveKnockBack(Player* player, float speedXY, float speedZ, float vcos, float vsin);
12071208
void KnockbackFrom(float x, float y, float speedXY, float speedZ);
12081209
void JumpTo(float speedXY, float speedZ, bool forward = true, Optional<Position> dest = {});
12091210
void JumpTo(WorldObject* obj, float speedZ, bool withOrientation = false);

src/server/game/Handlers/ArenaTeamHandler.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket& recvData)
403403

404404
void WorldSession::SendArenaTeamCommandResult(uint32 teamAction, const std::string& team, const std::string& player, uint32 errorId)
405405
{
406-
WorldPacket data(SMSG_ARENA_TEAM_COMMAND_RESULT, 4+team.length()+1+player.length()+1+4);
406+
WorldPacket data(SMSG_ARENA_TEAM_COMMAND_RESULT, 4 + team.length() + 1 + player.length() + 1 + 4);
407407
data << uint32(teamAction);
408408
data << team;
409409
data << player;
@@ -413,10 +413,10 @@ void WorldSession::SendArenaTeamCommandResult(uint32 teamAction, const std::stri
413413

414414
void WorldSession::SendNotInArenaTeamPacket(uint8 type)
415415
{
416-
WorldPacket data(SMSG_ARENA_ERROR, 4+1); // 886 - You are not in a %uv%u arena team
417-
uint32 unk = 0;
418-
data << uint32(unk); // unk(0)
419-
if (!unk)
416+
WorldPacket data(SMSG_ARENA_ERROR, 4+1);
417+
uint32 error = 0;
418+
data << uint32(error); // 0 = ERR_ARENA_NO_TEAM_II, 1 = ERR_ARENA_EXPIRED_CAIS, 2 = ERR_LFG_CANT_USE_BATTLEGROUND
419+
if (!error)
420420
data << uint8(type); // team type (2=2v2, 3=3v3, 5=5v5), can be used for custom types...
421421
SendPacket(&data);
422422
}

src/server/game/Handlers/CharacterHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ void WorldSession::HandleAlterAppearance(WorldPacket& recvData)
13051305

13061306
// 0 - ok
13071307
// 1, 3 - not enough money
1308-
// 2 - you have to seat on barber chair
1308+
// 2 - you have to sit on barber chair
13091309
if (!_player->HasEnoughMoney(cost))
13101310
{
13111311
SendBarberShopResult(BARBER_SHOP_RESULT_NO_MONEY);

src/server/game/Handlers/GroupHandler.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,17 +525,15 @@ void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recvData)
525525
if (!group)
526526
return;
527527

528-
uint8 x;
528+
uint8 x;
529529
recvData >> x;
530530

531531
/** error handling **/
532532
/********************/
533533

534534
// everything's fine, do it
535535
if (x == 0xFF) // target icon request
536-
{
537536
group->SendTargetIconList(this);
538-
}
539537
else // target icon update
540538
{
541539
if (group->isRaidGroup() && !group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))

src/server/game/Movement/Spline/MoveSplineInit.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ namespace Movement
266266
args.path[1] = transform(dest);
267267
}
268268

269+
void MoveSplineInit::SetFall()
270+
{
271+
args.flags.EnableFalling();
272+
}
273+
269274
Vector3 TransportPathTransform::operator()(Vector3 input)
270275
{
271276
if (_transformForTransport)

src/server/game/Movement/Spline/MoveSplineInit.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ namespace Movement
151151
inline void MoveSplineInit::SetWalk(bool enable) { args.walk = enable; }
152152
inline void MoveSplineInit::SetSmooth() { args.flags.EnableCatmullRom(); }
153153
inline void MoveSplineInit::SetCyclic() { args.flags.cyclic = true; }
154-
inline void MoveSplineInit::SetFall() { args.flags.EnableFalling(); }
155154
inline void MoveSplineInit::SetVelocity(float vel) { args.velocity = vel; args.HasVelocity = true; }
156155
inline void MoveSplineInit::SetBackward() { args.flags.backward = true; }
157156
inline void MoveSplineInit::SetTransportEnter() { args.flags.EnableTransportEnter(); }

0 commit comments

Comments
 (0)