329 lines
24 KiB
C++
329 lines
24 KiB
C++
#include <source_location>
|
|
#include "gateway/character_creation.hpp"
|
|
#include "fixtures/character_creation_tauren_70334.hpp"
|
|
#include <algorithm>
|
|
#include <functional>
|
|
#include <iostream>
|
|
#include <map>
|
|
#include <stdexcept>
|
|
#include <string_view>
|
|
using namespace gateway;
|
|
namespace c=gateway::character_creation;
|
|
namespace {
|
|
void require(bool value,const char* reason){if(!value)throw std::runtime_error(reason);}
|
|
void rejects(const std::function<void()>& action,std::source_location at=std::source_location::current()){try{action();}catch(const Error&){return;}throw std::runtime_error("unsupported or malformed request admitted (line "+std::to_string(at.line())+")");}
|
|
std::vector<std::array<uint32_t,2>> forward(const std::array<uint8_t,5>& appearance,uint8_t sex){
|
|
const auto& p=c::default_profile();std::map<uint32_t,uint32_t> result;
|
|
for(const auto& r:p.conversions){
|
|
if(r.race!=6||r.sex!=sex||appearance[r.field-1]!=r.value||(r.dependent&&appearance[r.dependent-1]!=r.dependent_value))continue;
|
|
auto found=std::find_if(p.choices.begin(),p.choices.end(),[&](const auto& row){return row.id==r.choice;});require(found!=p.choices.end(),"fixture choice parent");
|
|
auto old=result.find(found->option);require(old==result.end()||old->second==r.choice,"fixture forward collision");result[found->option]=r.choice;
|
|
}
|
|
std::vector<std::array<uint32_t,2>> out;for(auto [option,choice]:result)out.push_back({option,choice});return out;
|
|
}
|
|
Bytes with_choices(const Bytes& original,const std::vector<std::array<uint32_t,2>>& choices){
|
|
const auto request=c::parse_request(c::NativeCreateOpcode,original);
|
|
require(!request.template_set && request.surname.empty(),"bounded fixture header");
|
|
Bytes b(original.begin(),original.begin()+18+request.name.size());
|
|
for(unsigned i=0;i<4;++i)b[6+i]=uint8_t(choices.size()>>(8*i));
|
|
for(const auto& pair:choices){le(b,pair[0],4);le(b,pair[1],4);}return b;
|
|
}
|
|
Bytes with_surname(const Bytes& original,std::string_view surname){
|
|
const auto request=c::parse_request(c::NativeCreateOpcode,original);
|
|
require(request.surname.empty()&&surname.size()<64,"bounded surname fixture");
|
|
Bytes result=original;
|
|
uint32_t bits=(uint32_t(result[0])<<16)|(uint32_t(result[1])<<8)|result[2];
|
|
bits=(bits&~(63u<<6))|(uint32_t(surname.size())<<6);
|
|
result[0]=uint8_t(bits>>16);result[1]=uint8_t(bits>>8);result[2]=uint8_t(bits);
|
|
result.insert(result.begin()+18+request.name.size(),surname.begin(),surname.end());
|
|
return result;
|
|
}
|
|
}
|
|
int main(){try{
|
|
struct FacialCase { uint8_t race, sex, count; uint32_t option, first; };
|
|
for (const auto entry : {FacialCase{1,0,9,9494,78934}, FacialCase{2,0,11,9493,78923},
|
|
FacialCase{2,1,7,9495,78943}, FacialCase{3,1,6,9496,78950}}) {
|
|
for (uint8_t value = 0; value < entry.count; ++value) {
|
|
const std::array<uint8_t,5> appearance{0,0,0,0,value};
|
|
c::NativeCreate request;
|
|
request.race = entry.race;
|
|
request.sex = entry.sex;
|
|
request.customizations = c::source_presentation_choices(entry.race, entry.sex, appearance);
|
|
require(std::ranges::find(request.customizations, std::array<uint32_t,2>{entry.option, entry.first + value})
|
|
!= request.customizations.end(), "original facial setting selects native choice");
|
|
require(c::resolve_appearance(request) == appearance, "facial setting roundtrip");
|
|
}
|
|
}
|
|
{
|
|
struct SdCase {
|
|
uint8_t race, sex;
|
|
std::array<uint8_t,5> source;
|
|
std::vector<std::array<uint32_t,2>> choices;
|
|
};
|
|
const std::array<SdCase,4> cases{{
|
|
{9,0,{2,3,13,4,9},{{14002,100032},{9484,100017},{9483,100001},{14001,100022},{14000,100005}}},
|
|
{9,1,{2,5,16,4,4},{{9485,100033},{14003,100039},{14004,100056},{14005,100061},{14006,100066}}},
|
|
{10,0,{10,9,15,15,10},{{14007,100077},{14008,100087},{14009,100103},{14010,100119},{14011,100130}}},
|
|
{10,1,{10,9,19,15,10},{{14012,100141},{14013,100151},{14014,100171},{14015,100187},{14016,100198}}}
|
|
}};
|
|
const std::array<std::array<uint8_t,2>,2> eligible{{{9,1},{10,1}}};
|
|
auto create = [&](uint8_t race, uint8_t sex, const auto& selected) {
|
|
auto body=with_choices(unhex(std::string(CreationFixtures[0].native_hex)), selected);
|
|
body[3]=race; body[4]=1; body[5]=sex;
|
|
return c::translate_request(c::NativeCreateOpcode,body,eligible);
|
|
};
|
|
for (const auto& tc : cases) {
|
|
auto translated=create(tc.race,tc.sex,tc.choices);
|
|
require(translated.appearance==tc.source, "complete SD source appearance");
|
|
const auto begin=translated.packet.body.begin()+translated.request.name.size()+4;
|
|
require(translated.packet.opcode==c::SourceCreateOpcode &&
|
|
std::equal(tc.source.begin(),tc.source.end(),begin), "ordinary source create has exact SD values");
|
|
}
|
|
const auto input=cases[0].choices;
|
|
auto bad=input; bad.pop_back(); rejects([&]{create(9,0,bad);});
|
|
bad=input; bad[0]=bad[1]; rejects([&]{create(9,0,bad);});
|
|
bad=input; bad[0]=std::array<uint32_t,2>{104,1488}; rejects([&]{create(9,0,bad);});
|
|
bad=input; bad[0][1]=bad[1][1]; rejects([&]{create(9,0,bad);});
|
|
bad=input; bad[1][1]=1456; rejects([&]{create(9,0,bad);});
|
|
bad=input; bad[2][1]=78859; rejects([&]{create(9,0,bad);});
|
|
rejects([&]{create(9,1,input);}); rejects([&]{create(10,0,input);});
|
|
}
|
|
{
|
|
// Report fb262c (2026-11-26): Undead female features 2 and 5 are jawless on Octo (CharacterFacialHairStyles
|
|
// geosets all 0); the native jaw option 535 must get its no-jaw choice 6305 (jaw-removal geosets 2110/12198),
|
|
// not the default jawed 5337. Male 2/3/4/10/11 already map to 6304.
|
|
auto jaw=[](uint8_t sex,uint8_t facial){
|
|
for(const auto& p:c::source_presentation_choices(5,sex,std::array<uint8_t,5>{0,0,0,0,facial}))
|
|
if(p[0]==(sex?535u:534u))return p[1];
|
|
return 0u;
|
|
};
|
|
require(jaw(1,2)==6305&&jaw(1,5)==6305,"jawless Undead female features keep no jaw");
|
|
require(jaw(1,0)==5337&&jaw(1,7)==5337,"jawed Undead female features keep the jaw");
|
|
require(jaw(0,2)==6304&&jaw(0,0)==5330,"Undead male jaw mapping unchanged");
|
|
}
|
|
{
|
|
// The verified creator's Toothy click used default Eye Glow 5337 instead of 6305.
|
|
// Check the submitted choices, the legacy bytes, and the roster projection.
|
|
const std::vector<std::array<uint32_t,2>> toothy{
|
|
{63,984},{64,991},{65,1011},{66,1026},{67,1042},{535,6305},{559,6275},{568,6524}
|
|
};
|
|
const std::array<std::array<uint8_t,2>,1> undead_priest{{{5,5}}};
|
|
auto create=[&](const auto& choices){
|
|
auto body=with_choices(unhex(std::string(CreationFixtures[0].native_hex)), choices);
|
|
body[3]=5; body[4]=5; body[5]=1;
|
|
return c::translate_request(c::NativeCreateOpcode,body,undead_priest);
|
|
};
|
|
const auto made=create(toothy);
|
|
const std::array<uint8_t,5> expected{0,0,0,0,5};
|
|
const auto stored=made.packet.body.begin()+made.request.name.size()+4;
|
|
require(made.appearance==expected && std::equal(expected.begin(),expected.end(),stored),
|
|
"Toothy click preserves the five Source creation bytes");
|
|
require(c::source_presentation_choices(5,1,expected)==toothy,
|
|
"Undead female roster reproduces the creator choices");
|
|
}
|
|
{
|
|
// #122 (2026-11-26): Turtle Goblin skins are 0-2 in Octo CharSections order (GoblinMaleSkin00_100/101/102); the
|
|
// conversion only had stale values 1/4/7 (male) and 0/1 (female), so male 0/2 and female 2 (447 LOCAL characters)
|
|
// presented no skin. Male 0 -> HD 1430 (SD 100000 = _100), male 2 -> HD 1433 (SD 100001 = _102), female 2 -> HD
|
|
// 9210 (SD 100033 = _102).
|
|
auto skin=[](uint8_t sex,uint8_t v){
|
|
for(const auto& p:c::source_presentation_choices(9,sex,std::array<uint8_t,5>{v,0,0,0,0}))
|
|
if(p[0]==(sex?105u:100u))return p[1];
|
|
return 0u;
|
|
};
|
|
require(skin(0,0)==1430&&skin(0,1)==1427&&skin(0,2)==1433,"Goblin male skins 0-2 present their own HD choice");
|
|
require(skin(1,0)==1513&&skin(1,1)==1514&&skin(1,2)==9210,"Goblin female skins 0-2 present their own HD choice");
|
|
}
|
|
{
|
|
// Source flag-bit rows occupy indices after clear rows in their section group.
|
|
const std::array<std::vector<std::array<uint32_t,2>>,4> choices{{
|
|
{{58,913},{59,920},{60,940},{61,956},{62,967},{534,5330},{563,6287},{567,6527}},
|
|
{{63,984},{64,991},{65,1011},{66,1026},{67,1037},{535,5337},{559,6275},{568,6524}},
|
|
{{58,919},{59,920},{60,940},{61,956},{62,967},{534,5330},{563,6287},{567,6527}},
|
|
{{63,990},{64,991},{65,1011},{66,1026},{67,1037},{535,5337},{559,6275},{568,6524}},
|
|
}};
|
|
for(size_t i=0;i<choices.size();++i){
|
|
c::NativeCreate request;
|
|
request.race=5;request.sex=uint8_t(i%2);request.customizations=choices[i];
|
|
const std::array<uint8_t,5> expected{uint8_t(i<2?0:6),0,0,0,0};
|
|
require(c::resolve_appearance(request)==expected,"clear or flagged Source appearance roundtrip");
|
|
require(c::source_presentation_choices(5,request.sex,expected)==choices[i],"stored Undead appearance projects");
|
|
const std::array<std::array<uint8_t,2>,1> undead_priest{{{5,5}}};
|
|
auto body=with_choices(unhex(std::string(CreationFixtures[0].native_hex)),choices[i]);
|
|
body[3]=5;body[5]=request.sex;
|
|
if(i<2){
|
|
require(c::translate_request(c::NativeCreateOpcode,body,undead_priest).appearance==expected,"first Undead creator skin");
|
|
auto last=choices[i];last[0][1]+=5;
|
|
body=with_choices(body,last);
|
|
require(c::translate_request(c::NativeCreateOpcode,body,undead_priest).appearance[0]==5,"last Undead creator skin");
|
|
}else{
|
|
rejects([&]{c::translate_request(c::NativeCreateOpcode,body,undead_priest);});
|
|
}
|
|
}
|
|
{ // Live 2026-11-25: a new HD female Tauren whose skin and face choices have no single 1.12 appearance
|
|
// ("native appearance constraints conflict") gets the closest source-valid appearance instead of a refusal.
|
|
for(auto [sex,o1,c1,o2,c2]:std::vector<std::array<uint32_t,5>>{{1,74,1115,379,1135},{0,68,1066,378,1074}}){
|
|
const std::vector<std::array<uint32_t,2>> conflicting{{o1,c1},{o2,c2}};
|
|
auto tauren=with_choices(unhex(std::string(CreationFixtures[0].native_hex)),conflicting);
|
|
tauren[3]=6;tauren[5]=uint8_t(sex);
|
|
const std::array<std::array<uint8_t,2>,1> tauren_class{{{6,tauren[4]}}};
|
|
auto made=c::translate_request(c::NativeCreateOpcode,tauren,tauren_class).appearance;
|
|
require(made[0]==1 || made[1]==0,"closest Tauren appearance keeps a requested field");
|
|
if(sex==1){
|
|
require(made==std::array<uint8_t,5>{0,0,0,0,0},"sparse Tauren creator keeps its original result");
|
|
auto adjacent=with_choices(tauren,{{74,1114},{379,1135}});
|
|
rejects([&]{c::translate_request(c::NativeCreateOpcode,adjacent,tauren_class);});
|
|
const std::array<uint8_t,5> exact{1,0,0,0,0};
|
|
auto complete=with_choices(tauren,c::source_presentation_choices(6,1,exact));
|
|
require(c::translate_request(c::NativeCreateOpcode,complete,tauren_class).appearance==exact,
|
|
"fully selected Tauren appearance uses the exact skin and face");
|
|
}
|
|
c::NativeCreate existing;existing.race=6;existing.sex=uint8_t(sex);existing.customizations=conflicting;
|
|
rejects([&]{c::resolve_appearance(existing);}); // saved characters stay exact
|
|
}
|
|
}
|
|
}
|
|
{ // Owner 2026-11-29: Grimtotem paint (Tauren male skin 21, female skin 13) has glowing eyes on every face;
|
|
// every other Tauren skin, including creator skins 19/11 and shop skins 20/12, uses the plain face.
|
|
for(auto [sex,grim,faces,plain,glow]:std::vector<std::array<uint32_t,5>>{{0,21,5,1074,1079},{1,13,4,1135,1139}})
|
|
for(uint32_t skin=0;skin<=grim;++skin)for(uint32_t face=0;face<faces;++face){
|
|
const std::array<uint8_t,5> look{uint8_t(skin),uint8_t(face),0,0,0};
|
|
const uint32_t option=sex==0?378u:379u,want=(skin==grim?glow:plain)+face;
|
|
auto choices=c::source_presentation_choices(6,uint8_t(sex),look);
|
|
auto found=std::find_if(choices.begin(),choices.end(),[&](const auto& pair){return pair[0]==option;});
|
|
require(found!=choices.end() && (*found)[1]==want,"Tauren face glows only on the Grimtotem skin");
|
|
}
|
|
}
|
|
{
|
|
// Original Night Elf hair colors 8 and 9 had paired choices 79137..79140, which no client table holds:
|
|
// presenting them crashed char select (ERROR #135 "Invalid Choice ID", Noctis 2026-11-25). Every presented
|
|
// choice must be one the client knows; the held Turtle variants (79130..79166) never reach the client.
|
|
for(uint8_t sex=0;sex<2;++sex){
|
|
const uint32_t option=sex==0?43u:52u;
|
|
const uint32_t color7=sex==0?756u:865u;
|
|
for(uint8_t style=0;style<12;++style){
|
|
std::array<uint8_t,5> appearance{0,0,style,7,0};
|
|
require([&]{auto choices=c::source_presentation_choices(4,sex,appearance);
|
|
auto found=std::find_if(choices.begin(),choices.end(),[&](const auto& pair){return pair[0]==option;});
|
|
return found!=choices.end() && (*found)[1]==color7;}(),"Night Elf original seventh hair color preserved");
|
|
for(uint8_t color=8;color<10;++color){
|
|
appearance[3]=color;
|
|
for(const auto& pair:c::source_presentation_choices(4,sex,appearance))
|
|
require(pair[1]<79130u || pair[1]>79166u,"Night Elf held hair colors never present an absent client choice");
|
|
}
|
|
}
|
|
}
|
|
for(uint8_t race:{1,3,4,5,7})for(uint8_t sex=0;sex<2;++sex)for(uint8_t f=0;f<26;++f){
|
|
const std::array<uint8_t,5> appearance{0,0,f,0,f};
|
|
for(const auto& pair:c::source_presentation_choices(race,sex,appearance))
|
|
require(pair[1]<79130u || pair[1]>79166u,"held Turtle hair/facial variants never presented");
|
|
}
|
|
}
|
|
constexpr std::array<std::array<uint8_t,2>,2> pairs{{{6,1},{6,5}}};
|
|
for(const auto& fixture:CreationFixtures){
|
|
auto body=unhex(std::string(fixture.native_hex));auto out=c::translate_request(c::NativeCreateOpcode,body,pairs);
|
|
require(out.packet.opcode==0x36&&out.packet.body==unhex(std::string(fixture.source_hex)),"source request exact oracle");
|
|
require(out.request.race==6&&out.request.cls==5&&out.request.sex==fixture.sex&&out.appearance==fixture.appearance,"source identity preserved");
|
|
}
|
|
// Existing Source Goblin samples from the saved native-conversion and
|
|
// Source-domain receipts. This is an offline relationship check only.
|
|
const std::array<c::SourceAppearance,4> source_batch{{
|
|
{9,0,{1,0,0,0,0}}, {9,1,{0,0,0,0,0}},
|
|
{9,0,{3,0,0,0,0}}, {10,0,{0,0,0,0,0}} // Goblin skin 3: Octo has skins 0-2 only (#122: 0 is mapped now)
|
|
}};
|
|
const auto projected=c::project_source_appearances(source_batch);
|
|
const std::vector<std::array<uint32_t,2>> male_choices{
|
|
{100,1427},{101,1446},{102,1474},{103,1475},{104,1488},{552,5666},
|
|
{806,9071},{807,9083},{815,9153},{817,9169},{819,9179}};
|
|
const std::vector<std::array<uint32_t,2>> female_choices{
|
|
{105,1513},{106,1526},{107,1544},{108,1561},{109,1574},{553,5677},
|
|
{808,9093},{809,9104},{811,9118},{813,9144},{821,9195}};
|
|
require(projected.size()==source_batch.size()&&projected[0].resolved&&projected[1].resolved,
|
|
"saved Goblin source appearances project");
|
|
require(projected[0].choices==male_choices&&projected[1].choices==female_choices,
|
|
"saved Goblin native option/choice identities");
|
|
require(!projected[2].resolved&&projected[2].choices.empty()&&!projected[2].held_reason.empty(),
|
|
"unmapped Goblin appearance remains held");
|
|
// High Elf race10 now has 1:1 display-order rows onto Octo Source indices.
|
|
require(projected[3].resolved&&projected[3].choices.size()==5,"High Elf Source appearance projects");
|
|
auto body=unhex(std::string(CreationFixtures[0].native_hex));auto request=c::parse_request(c::NativeCreateOpcode,body);
|
|
auto control_body=with_surname(body,"Control");
|
|
require(c::parse_request(c::NativeCreateOpcode,control_body).surname=="Control","original native control surname parsed");
|
|
auto control_out=c::translate_request(c::NativeCreateOpcode,control_body,pairs);
|
|
require(control_out.request.surname.empty()&&control_out.packet.body==c::translate_request(c::NativeCreateOpcode,body,pairs).packet.body,
|
|
"exact Source UI control surname yields the single-name Classic packet");
|
|
rejects([&]{c::translate_request(c::NativeCreateOpcode,with_surname(body,"Other"),pairs);});
|
|
{
|
|
// A native-only option (no Source relation for this race/sex) is skipped;
|
|
// the Classic packet is unchanged.
|
|
auto extra=body;uint32_t count=extra[6]|extra[7]<<8|extra[8]<<16|uint32_t(extra[9])<<24;++count;
|
|
for(int i=0;i<4;++i)extra[6+i]=uint8_t(count>>(8*i));
|
|
for(uint32_t value:{0x7ffffff0u,1u})for(int i=0;i<4;++i)extra.push_back(uint8_t(value>>(8*i)));
|
|
require(c::translate_request(c::NativeCreateOpcode,extra,pairs).packet.body==c::translate_request(c::NativeCreateOpcode,body,pairs).packet.body,
|
|
"native-only customization option skipped");
|
|
}
|
|
{
|
|
// High Elf (native race10) maps 1:1 onto Octo Source indices, both sexes.
|
|
c::NativeCreate he=request;he.race=10;he.sex=0;
|
|
he.customizations={{110,1601},{111,1628},{112,1650},{113,1668},{114,1682}};
|
|
std::sort(he.customizations.begin(),he.customizations.end());
|
|
auto out=c::resolve_appearance(he);require(out[0]==2,"High Elf male skin maps to Source index");
|
|
he.customizations.push_back({571,7642});std::sort(he.customizations.begin(),he.customizations.end());
|
|
require(c::resolve_appearance(he)==out,"High Elf native-only eye colour skipped");
|
|
auto unmapped=he;for(auto& pair:unmapped.customizations)if(pair[0]==110)pair[1]=1625;rejects([&]{c::resolve_appearance(unmapped);});
|
|
}
|
|
auto warrior=body;warrior[4]=1;auto warrior_out=c::translate_request(c::NativeCreateOpcode,warrior,pairs);
|
|
require(warrior_out.appearance==CreationFixtures[0].appearance&&warrior_out.packet.body[8]==1,"class independent race appearance");
|
|
constexpr std::array<std::array<uint8_t,2>,1> no_priest{{{6,1}}};rejects([&]{c::translate_request(c::NativeCreateOpcode,body,no_priest);});
|
|
for(size_t end=0;end<body.size();++end)rejects([&]{c::parse_request(c::NativeCreateOpcode,std::span(body).first(end));});
|
|
auto changed=body;changed.push_back(0);rejects([&]{c::parse_request(c::NativeCreateOpcode,changed);});
|
|
for(uint32_t opcode:{0x430070u,0x36u,0u})rejects([&]{c::parse_request(opcode,body);});
|
|
changed=body;changed[6]=251;rejects([&]{c::parse_request(c::NativeCreateOpcode,changed);});
|
|
changed=body;changed[18]=0xff;rejects([&]{c::parse_request(c::NativeCreateOpcode,changed);});
|
|
changed=body;changed[18]=0;rejects([&]{c::parse_request(c::NativeCreateOpcode,changed);});
|
|
changed=body;changed[5]=2;rejects([&]{c::parse_request(c::NativeCreateOpcode,changed);});
|
|
changed=body;changed[6]+=1;changed.insert(changed.end(),body.begin()+24,body.begin()+32);rejects([&]{c::parse_request(c::NativeCreateOpcode,changed);});
|
|
changed=body;changed[2]|=63;require(c::parse_request(c::NativeCreateOpcode,changed).padding_bits==63,"original ResetBitPos padding semantics");
|
|
for(uint8_t flag:{0x10u,0x40u,0x80u}){changed=body;changed[1]|=flag;rejects([&]{c::translate_request(c::NativeCreateOpcode,changed,pairs);});}
|
|
auto ambiguous=request;ambiguous.customizations=forward({0,0,0,0,0},0);require(ambiguous.customizations==forward({0,0,0,0,7},0),"actual legacy0/7 collision witness");rejects([&]{c::resolve_appearance(ambiguous);});
|
|
const auto default_body=with_choices(body,ambiguous.customizations);
|
|
auto canonical=c::translate_request(c::NativeCreateOpcode,default_body,pairs);
|
|
Bytes expected;cstring(expected,"Taurea");for(auto v:{6,5,0,0,0,0,0,0,0})le(expected,v,1);le(expected,0,4);
|
|
require(canonical.appearance==std::array<uint8_t,5>{0,0,0,0,0} && canonical.packet.body==expected,"new-character canonical zero exact source request");
|
|
auto partial=ambiguous.customizations;std::erase_if(partial,[](const auto& p){return p[0]==73;});
|
|
rejects([&]{c::translate_request(c::NativeCreateOpcode,with_choices(body,partial),pairs);});
|
|
const auto& current=c::default_profile();
|
|
for(unsigned mutation=0;mutation<4;++mutation){
|
|
auto bad=current;std::vector<c::Conversion> rows(current.conversions.begin(),current.conversions.end());
|
|
std::vector<c::Choice> choices(current.choices.begin(),current.choices.end());
|
|
if(mutation==0||mutation==2){
|
|
for(const auto& r:current.conversions)if(r.race==6 && r.sex==0 &&
|
|
(mutation==0?(r.field==5&&r.value==7):(r.field==2&&r.value==0))){
|
|
auto next=r;next.id+=100000;next.value=mutation==0?8:1;rows.push_back(next);
|
|
}
|
|
}else if(mutation==1){for(auto& r:rows)if(r.race==6&&r.sex==0&&r.field==5&&r.value==7)r.value=6;
|
|
}else{
|
|
auto r=*std::find_if(rows.begin(),rows.end(),[](const auto& r){return r.race==6&&r.sex==0&&r.field==5&&r.value==7;});
|
|
r.id=999999;r.choice=999999;rows.push_back(r);choices.push_back({999999,999999});
|
|
}
|
|
bad.conversions=rows;bad.choices=choices;
|
|
rejects([&]{c::translate_request(c::NativeCreateOpcode,default_body,pairs,bad);});
|
|
}
|
|
std::vector<c::Hair> facial(current.facial_hair.begin(),current.facial_hair.end());
|
|
std::erase_if(facial,[](const auto& r){return r.race==6&&r.sex==0&&r.variation==0;});
|
|
auto seven_only=current;seven_only.facial_hair=facial;
|
|
require(c::translate_request(c::NativeCreateOpcode,default_body,pairs,seven_only).appearance[4]==7,"missing sourcezero must not receive invented default");
|
|
auto outside=request;outside.customizations=forward({24,0,0,0,1},0);rejects([&]{c::resolve_appearance(outside);});
|
|
auto missing=request;missing.customizations.clear();rejects([&]{c::resolve_appearance(missing);});
|
|
auto wrong=request;wrong.race=1;rejects([&]{c::resolve_appearance(wrong);});wrong=request;wrong.sex=1;rejects([&]{c::resolve_appearance(wrong);});
|
|
wrong=request;wrong.customizations[0][0]=999999;rejects([&]{c::resolve_appearance(wrong);});
|
|
const auto& p=c::default_profile();std::vector<c::Conversion> rows(p.conversions.begin(),p.conversions.end());rows[0].discriminator=0;
|
|
auto bad=p;bad.conversions=rows;rejects([&]{c::resolve_appearance(request,bad);});
|
|
require(!c::translate_result(46),"source success waits for actual new roster GUID");
|
|
Bytes raw;le(raw,1,8);le(raw,(uint64_t(2)<<58)|(uint64_t(70)<<42),8);Guid128 guid{};std::copy(raw.begin(),raw.end(),guid.begin());
|
|
auto success=c::translate_result(46,guid);require(success&&success->opcode==0x4701ac&&success->body==unhex("1800000001e001180108"),"native success code and packed GUID oracle");
|
|
auto failure=c::translate_result(49);require(failure&&failure->body==unhex("1b0000000000"),"genuine source name-in-use to native code27");
|
|
rejects([&]{c::translate_result(49,guid);});rejects([&]{c::translate_result(46,Guid128{});});rejects([&]{c::translate_result(255);});
|
|
std::cout<<"Character creation packet/constraint/source-domain/result contracts PASS; no live creation.\n";return 0;
|
|
}catch(const std::exception& error){std::cerr<<"Character creation contract: "<<error.what()<<'\n';return 1;}}
|