46 lines
2.1 KiB
C++
46 lines
2.1 KiB
C++
#pragma once
|
|
#include "gateway/character_creation.hpp"
|
|
#include <deque>
|
|
#include <set>
|
|
namespace gateway::character_creation {
|
|
class Lifecycle {
|
|
public:
|
|
enum class Phase {Idle,AwaitingSourceResult,NeedRoster,AwaitingRoster,ReplyReady,AwaitingDeleteResult,AwaitingRenameResult};
|
|
void bind_roster_context(uint32_t realm,uint32_t address,uint32_t district);
|
|
void observe_source(uint32_t opcode,std::span<const uint8_t> body);
|
|
Translation prepare_request(uint32_t opcode,std::span<const uint8_t> body,
|
|
std::span<const std::array<uint8_t,2>> pairs) const;
|
|
void request_submitted(NativeCreate request);
|
|
// Native CMSG_CHAR_DELETE -> source frame body; identity must be a current
|
|
// authenticated roster member (no unknown GUID is forwarded).
|
|
LegacyPacket prepare_delete(std::span<const uint8_t> body) const;
|
|
void delete_submitted(uint64_t counter);
|
|
LegacyPacket prepare_rename(std::span<const uint8_t> body) const;
|
|
void rename_submitted(uint64_t counter);
|
|
bool busy() const {return phase_!=Phase::Idle;}
|
|
bool need_roster_request() const {return phase_==Phase::NeedRoster;}
|
|
void roster_request_submitted();
|
|
const LegacyPacket* reply() const {return replies_.empty()?nullptr:&replies_.front();}
|
|
void reply_taken();
|
|
void enter_world();
|
|
Phase phase() const {return phase_;}
|
|
uint32_t unmatched_source_results() const {return unmatched_results_;}
|
|
private:
|
|
struct Row {uint64_t guid;std::string name;uint8_t race,cls,sex;uint32_t flags;};
|
|
Phase phase_=Phase::Idle;bool roster_seen_=false,bound_=false,in_world_=false;
|
|
uint32_t realm_=0,address_=0,district_=0,unmatched_results_=0;
|
|
uint64_t roster_generation_=0,requested_after_generation_=0;
|
|
std::vector<Row> roster_;
|
|
std::set<uint64_t> baseline_;
|
|
std::optional<NativeCreate> pending_;
|
|
uint64_t pending_delete_=0;
|
|
uint64_t pending_rename_=0;
|
|
std::string confirmed_name_;
|
|
std::deque<LegacyPacket> replies_;
|
|
void append_reply(LegacyPacket);
|
|
void reset_pending();
|
|
};
|
|
// Explicit LOCAL compatibility failure, not a fabricated source3A response.
|
|
LegacyPacket local_compatibility_rejection();
|
|
}
|