Files
ForeverCore/tests/game/ClassicBgPositionsLayout.cpp
Karrz1 ff699fb5cf Sync with WoW Forever 0.1.34: Blizzlike core
Brings forever up to date with our 0.1.34 code for the WoW Forever client 1.60.1.70862.
Blizzlike only: fixes from real game data (packet captures, live hotfixes, player caches, Wowhead and Questie data,
VMaNGOS for the vanilla world) and server fixes. No custom items or custom content; every rate and option defaults
to Blizzard's behaviour.

What is new since 2ae1313e, in short:
- Clients 70790, 70840 and 70862: message numbers, mail, guild window, charters, contact list, add-on whispers.
- Crash and exploit fixes: guild ranks, loot of emptied veins, quest lookups, taxi mask, battleground templates,
  vendor free buys, item sell price, auction house, falling out of the world, bnetserver request limit.
- Classes, talents, pets and buffs from the live game data and Blizzard's hotfixes of November.
- Quests, NPCs, spawns, trainers, loot, fishing, events, Merchant's Favor crates and writs, sealed crate turn-ins.
- Dungeon and raid scripts (Molten Core, Blackwing Lair, Zul'Gurub, Ahn'Qiraj, Shadowfang Keep, Deadmines ...).
- Pathing fixes that help pets and NPCs.
- Russian creature names, quest titles and quest texts.
- README: Blizzlike stance, branches, repack.
2026-11-09 17:27:57 +00:00

77 lines
2.7 KiB
C++

#include "tc_catch2.h"
#include "BattlegroundPackets.h"
#include "ByteBuffer.h"
#include "ObjectGuid.h"
#include "Position.h"
#include "WorldPacket.h"
// SMSG_BATTLEGROUND_PLAYER_POSITIONS (0x4D0006) as the Classic 1.60.1.70291 client reads and uses it (WowB.exe 70291).
// Reader (rva 0xA29EF0): u32 count, then per entry (stride 0x20) packed guid, u32 x, u32 y, u8 icon (+0x18), u8 slot (+0x19).
// Handler (rva 0x2B0FA10): slot 2..6 are arena team slots; for a battleground it only looks at entries whose slot byte is 1
// (PLAYER_POSITION_ARENA_SLOT_NONE), looks the guid up as a player and gives it a map icon. An entry with slot 0 (what the server sent
// before) is read correctly and then never drawn: no flag carrier on the map or minimap in a battleground.
namespace
{
using namespace WorldPackets::Battleground;
struct ReadEntry
{
ObjectGuid Guid;
float X = 0.0f, Y = 0.0f;
uint8 Icon = 0, Slot = 0;
};
std::vector<ReadEntry> ReadLikeClient(WorldPacket const& data)
{
ByteBuffer buffer(data);
uint32 count = 0;
buffer >> count;
std::vector<ReadEntry> entries;
for (uint32 i = 0; i < count; ++i)
{
ReadEntry entry;
buffer >> entry.Guid >> entry.X >> entry.Y >> entry.Icon >> entry.Slot;
entries.push_back(entry);
}
// the client's reader stops here: a byte more or less shifts every later entry and the next message
CHECK(buffer.rpos() == buffer.size());
return entries;
}
}
TEST_CASE("BG player positions are read to the last byte and a carrier has slot 1", "[ClassicBgPositions]")
{
BattlegroundPlayerPositions packet;
BattlegroundPlayerPosition alliance;
alliance.Guid = ObjectGuid::Create<HighGuid::Player>(1);
alliance.Pos = Position(920.0f, 1434.0f, 0.0f);
alliance.IconID = 2;
packet.FlagCarriers.push_back(alliance);
BattlegroundPlayerPosition horde;
horde.Guid = ObjectGuid::Create<HighGuid::Player>(70000);
horde.Pos = Position(1540.0f, 1481.0f, 0.0f);
horde.IconID = 1;
packet.FlagCarriers.push_back(horde);
std::vector<ReadEntry> const entries = ReadLikeClient(*packet.Write());
REQUIRE(entries.size() == 2);
CHECK(entries[0].Guid == alliance.Guid);
CHECK(entries[0].X == 920.0f);
CHECK(entries[0].Y == 1434.0f);
CHECK(entries[0].Icon == 2);
CHECK(entries[1].Guid == horde.Guid);
CHECK(entries[1].Icon == 1);
for (ReadEntry const& entry : entries)
CHECK(entry.Slot == 1); // the value the client's handler requires for a battleground carrier
}
TEST_CASE("An empty BG positions packet is just the count", "[ClassicBgPositions]")
{
BattlegroundPlayerPositions packet;
WorldPacket const* data = packet.Write();
CHECK(data->size() == 4);
CHECK(ReadLikeClient(*data).empty());
}