Files
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

64 lines
3.7 KiB
C++

#pragma once
#include "gateway/group.hpp"
#include "gateway/legacy_stream.hpp"
#include "gateway/world.hpp"
#include <string_view>
// Local fixture4514 only. This is genuine Source-client input, never injected
// into Forever; it does not establish a second native client/UI acceptance.
struct LocalPartyPeer {
bool ready=false,solo=false,owned_group=false,invited=false;
bool initial_solo=false; // launcher verified offline4514 has no Source group_member row
bool left=false,invite_sent=false,accept_sent=false,quitting=false;
gateway::LegacyPacket command(std::string_view command) const {
using namespace gateway;
if(command=="quit" && !quitting)return {0x4b,{}};
if(!ready || quitting)throw Error("party peer not ready");
if(command=="party-leave" && owned_group && !left)return {0x7b,{}};
if(command=="party-invite" && solo && (left || initial_solo) && !invite_sent && !invited){Bytes b;cstring(b,"Gatewaytest");return {0x6e,std::move(b)};}
if(command=="party-accept" && solo && invited && !accept_sent)return {0x72,{}};
throw Error("unqualified or repeated party peer action");
}
void sent(std::string_view command){
if(command=="quit")quitting=true;
else if(command=="party-leave"){left=true;owned_group=false;solo=false;invited=false;}
else if(command=="party-invite")invite_sent=true;
else if(command=="party-accept"){accept_sent=true;invited=false;}
}
std::string observe(const gateway::LegacyPacket& p){
using namespace gateway;
if(p.opcode==0x2e6)throw Error("unsupported integrity request");
// Native4509 can travel to this stationary peer. Do not fake transfer
// ACKs or accept an unplanned teleport into an unspecified context.
if(p.opcode==0x3e || p.opcode==0xc5)throw Error("unplanned peer teleport");
if(p.opcode==0x236){if(ready)throw Error("duplicate peer world");turtle_login_world(p.body);ready=true;return "READY 4514";}
if(p.opcode==0x7d){
auto group=turtle_group_list(p.body);
if(group.explicit_solo){solo=true;owned_group=false;return "PARTY_SOLO";}
// Source Group::Create adds/sends the founder before the invitee.
// This transient snapshot proves forming, never a usable party.
if(invite_sent && group.type==TurtleGroupType::normal &&
group.members.empty() && group.leader==4514){
solo=false;owned_group=false;initial_solo=false;
return "PARTY_FORMING leader=4514";
}
if(group.type!=TurtleGroupType::normal || group.members.size()!=1 ||
group.members[0].guid!=4509 || group.members[0].name!="Gatewaytest" ||
(group.leader!=4509 && group.leader!=4514))throw Error("unowned peer party");
solo=false;owned_group=true;invited=false;initial_solo=false;
return "PARTY_OWNED leader="+std::to_string(group.leader);
}
if(p.opcode==0x6f){
Reader r(p.body);const auto sender=r.cstring(48);r.end();
if(sender!="Gatewaytest" || !solo || invite_sent || invited || accept_sent)throw Error("unqualified peer invitation");
invited=true;return "INVITED_BY_GATEWAYTEST";
}
if(p.opcode==0x7f){
Reader r(p.body);auto op=r.le(4);const auto name=r.cstring(48);auto result=r.le(4);r.end();
if(!name.empty() && name!="Gatewaytest" && name!="Gatewayref")throw Error("foreign party result");
return "PARTY_RESULT operation="+std::to_string(op)+" result="+std::to_string(result);
}
if(p.opcode==0x4d && quitting){Reader r(p.body);r.end();return "LOGGED_OUT";}
return {};
}
};