Files
ForeverCore/tests/headless/HeadlessClient.h
T
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

101 lines
3.6 KiB
C++

#ifndef TRINITYCORE_TESTS_HEADLESS_CLIENT_H
#define TRINITYCORE_TESTS_HEADLESS_CLIENT_H
#include "AES.h"
#include "ByteBuffer.h"
#include "Define.h"
#include <array>
#include <chrono>
#include <memory>
#include <optional>
#include <string>
#include <vector>
// A packet-level WoW Classic 1.60.1.70291 client for tests: no game client, no graphics. It speaks the world socket protocol of
// WorldSocket.cpp (hello strings, framed packets, AES-GCM after SMSG_ENTER_ENCRYPTED_MODE, zlib compressed packets) and numbers its
// opcodes like the 70291 client (ClassicOpcodes). Blocking, single threaded: every call has a timeout and throws on a protocol error.
namespace Headless
{
using Milliseconds = std::chrono::milliseconds;
struct Credentials
{
std::string GameAccount; // account.username of the seeded game account ("<bnet id>#<index>")
std::vector<uint8> KeyData; // account.session_key_bnet of that account (what the Battle.net login stores)
uint32 RealmId = 1;
uint32 RegionId = 1;
uint32 BattlegroupId = 1;
uint32 Platform = 0; // ClientBuild platform / arch / type ids of the ticket
uint32 Arch = 0;
uint32 Type = 0;
};
struct ReceivedPacket
{
uint32 Wire = 0; // the number on the wire
uint32 Core = 0; // the core OpcodeServer it maps to (0 if unknown)
std::vector<uint8> Data; // payload without the opcode
std::chrono::steady_clock::time_point At;
};
/// What the reader specs of the real client say about one received packet.
struct SpecIssue
{
std::string Name;
uint32 Wire = 0;
std::string Problem;
};
struct SpecCoverage
{
uint32 Checked = 0; // packets whose reader spec is resolved
uint32 Unresolved = 0; // spec has a field the analysis could not resolve ("?")
uint32 Undecrypted = 0; // reader page not in the dump ("!")
uint32 NoSpec = 0; // not in the main group, or unknown wire number
std::vector<SpecIssue> Issues;
};
std::string OpcodeName(uint32 coreOpcode);
class Client
{
public:
Client(std::string host, uint16 port);
~Client();
Client(Client const&) = delete;
Client& operator=(Client const&) = delete;
/// TCP connect, hello strings, SMSG_AUTH_CHALLENGE, CMSG_AUTH_SESSION, SMSG_ENTER_ENCRYPTED_MODE + ack, SMSG_AUTH_RESPONSE.
/// Returns the result code of SMSG_AUTH_RESPONSE (0 = ok); throws on a protocol error or timeout.
uint32 Authenticate(Credentials const& credentials, Milliseconds timeout = Milliseconds(15000));
/// Sends a client packet by its core OpcodeClient value; the payload is written in the layout the server reads.
void Send(uint32 coreOpcode, ByteBuffer const& payload = ByteBuffer());
/// The next packet from the server (any), or nothing after the timeout.
std::optional<ReceivedPacket> Next(Milliseconds timeout);
/// Receives until the given core opcode arrives (everything else is kept in Log()); nothing after the timeout.
std::optional<ReceivedPacket> WaitFor(uint32 coreOpcode, Milliseconds timeout);
/// Receives for the given time, collecting into Log().
void Pump(Milliseconds duration);
std::vector<ReceivedPacket> const& Log() const { return _log; }
void ClearLog() { _log.clear(); }
/// Every packet in Log() against the reader specs of the real client.
SpecCoverage CheckLog() const;
bool IsEncrypted() const { return _encrypted; }
private:
struct Impl;
std::unique_ptr<Impl> _impl;
std::vector<ReceivedPacket> _log;
bool _encrypted = false;
};
}
#endif