91 lines
4.8 KiB
C++
91 lines
4.8 KiB
C++
#pragma once
|
|
#include "gateway/legacy_stream.hpp"
|
|
#include <array>
|
|
#include <optional>
|
|
#include <span>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
namespace gateway::character_creation {
|
|
inline constexpr uint32_t NativeCreateOpcode=0x420070;
|
|
inline constexpr uint32_t NativeCreateResultOpcode=0x4701ac;
|
|
inline constexpr uint32_t SourceCreateOpcode=0x36;
|
|
inline constexpr uint8_t SourceCreateSuccess=46;
|
|
// Build70334 CMSG_CHAR_DELETE observed live as 0x4400CB (9-byte packed GUID,
|
|
// pipe trace run74; trinity 0x4300CB): packed ObjectGuid. Reply
|
|
// SMSG_DELETE_CHAR 0x4701AD uint32 66 in progress/67 success/68 failed.
|
|
inline constexpr uint32_t NativeDeleteOpcode=0x4400cb;
|
|
inline constexpr uint32_t NativeDeleteResultOpcode=0x4701ad;
|
|
// Tortoise 1.12 CMSG_CHAR_DELETE 0x038 uint64 guid; SMSG_CHAR_DELETE 0x03C uint8.
|
|
inline constexpr uint32_t SourceDeleteOpcode=0x38;
|
|
inline constexpr uint32_t SourceDeleteResultOpcode=0x3c;
|
|
// 56 in progress->66, 57 success->67, 58 failed/59 locked for transfer->68.
|
|
std::optional<uint32_t> translate_delete_result(uint8_t source);
|
|
inline constexpr uint32_t NativeRenameOpcode=0x4400f0;
|
|
inline constexpr uint32_t NativeRenameResultOpcode=0x47020e;
|
|
inline constexpr uint32_t SourceRenameOpcode=0x2c7;
|
|
inline constexpr uint32_t SourceRenameResultOpcode=0x2c8;
|
|
inline constexpr uint32_t CharacterFlagRename=0x4000;
|
|
bool valid_rename_name(std::span<const uint8_t> name);
|
|
LegacyPacket rename_failure(uint8_t source_code);
|
|
LegacyPacket rename_success(const Guid128& guid, const std::string& canonical_name);
|
|
struct Unsupported : Error { using Error::Error; };
|
|
struct NativeCreate {
|
|
std::string name,surname;
|
|
uint8_t race=0,cls=0,sex=0;
|
|
std::vector<std::array<uint32_t,2>> customizations;
|
|
std::optional<int32_t> template_set;
|
|
bool trial_boost=false,use_npe=false,hardcore_self_found=false;
|
|
uint8_t unknown_bits=0,padding_bits=0;
|
|
int32_t unknown_word=0,timerunning_season=0;
|
|
};
|
|
struct Conversion {
|
|
uint32_t id;uint8_t race;int8_t sex;uint8_t field,value;
|
|
uint32_t choice;uint8_t dependent,dependent_value;int32_t discriminator;
|
|
};
|
|
struct Choice { uint32_t id,option; };
|
|
struct Section {uint32_t id;uint8_t race,sex,section,variation,color;uint32_t flags;};
|
|
struct Hair {uint8_t race,sex,variation;};
|
|
struct AppearanceProfile {
|
|
std::span<const Conversion> conversions;
|
|
std::span<const Choice> choices;
|
|
std::span<const Section> sections;
|
|
std::span<const Hair> facial_hair,hair_geosets;
|
|
};
|
|
// Metadata-only Source appearance projection. This does not establish the
|
|
// native roster packet reader or that the projected appearance renders.
|
|
struct SourceAppearance { uint8_t race=0,sex=0; std::array<uint8_t,5> values{}; };
|
|
struct AppearanceProjection {
|
|
bool resolved=false;
|
|
std::vector<std::array<uint32_t,2>> choices;
|
|
std::string held_reason;
|
|
};
|
|
struct Translation {NativeCreate request;std::array<uint8_t,5> appearance;LegacyPacket packet;};
|
|
const AppearanceProfile& default_profile();
|
|
NativeCreate parse_request(uint32_t opcode,std::span<const uint8_t>);
|
|
std::array<uint8_t,5> resolve_appearance(const NativeCreate&,const AppearanceProfile& profile=default_profile());
|
|
std::vector<AppearanceProjection> project_source_appearances(std::span<const SourceAppearance>,
|
|
const AppearanceProfile& profile=default_profile());
|
|
// Presentation of an EXISTING character: its Source appearance (skin, face,
|
|
// hair style, hair colour, facial hair) as the native option/choice pairs the
|
|
// conversion relations give for those values, ordered by option. Forward
|
|
// direction only. Creation needs the unique inverse (which Source tuple did
|
|
// the player pick?); showing a character does not, and the strict projection
|
|
// above rejects every tuple of a race/sex whose facial-hair values all relate
|
|
// to one native choice (Human male, Orc, Dwarf female, ...). A Source field
|
|
// the native options cannot express contributes no pair and the client keeps
|
|
// its own default for that option. Nothing is defaulted or aliased here.
|
|
// The complete tuple must belong to the retained Source appearance domain;
|
|
// malformed/out-of-domain values never produce a partial choice list.
|
|
// Empty = invalid Source tuple, no relation, or conflicting forward choices.
|
|
// Default profile only. Strict creation/inverse APIs above are unchanged.
|
|
std::vector<std::array<uint32_t,2>> source_presentation_choices(uint8_t race,uint8_t sex,
|
|
const std::array<uint8_t,5>& values);
|
|
Translation translate_request(uint32_t opcode,std::span<const uint8_t>,
|
|
std::span<const std::array<uint8_t,2>> actual_source_pairs,const AppearanceProfile& profile=default_profile());
|
|
// A genuine success is intentionally withheld until the authenticated refreshed
|
|
// roster supplies its newly created real Player GUID. No GUID/name synthesis.
|
|
std::optional<LegacyPacket> translate_result(uint8_t genuine_source_code,std::optional<Guid128> freshly_verified_guid={});
|
|
}
|