server: 0020-profile

TICKET-360: profile. CTOS/STOC 0x5D (98 bytes): a seated human's avatar id and frame id, stored per seat, in the join snapshot, swapped with the seat. Capability bit 0x200, protocol 7.

Replayed from Tools/YGOLegacy/patches/0020-profile.patch in the Unity repo.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
donnyandClaude Fable 5.1 committed 2026-10-14 20:58:59 -07:00
1 parent 980228945e
commit 27c35b81bd
6 files changed
+91 -4

No files matched your search

+25 -1
View File
@@ -77,10 +77,22 @@ void SingleDuel::SeatState(DuelPlayer* dp, unsigned char* pdata, int len) {
seat_state[dp->type] = state;
BroadcastFeature(STOC_SEAT_STATE, pdata, len, dp->type);
}
// YGOL profile: a seated human says which avatar and frame it shows; kept per seat, cleared with the seat, kept across matches
void SingleDuel::Profile(DuelPlayer* dp, unsigned char* pdata, int len) {
if(dp->type > 1 || dp->ygol_cpu)
return;
CTOS_Profile sent;
std::memcpy(&sent, pdata, sizeof sent);
if(sent.version != PROFILE_VERSION)
return;
profile[dp->type] = sent;
has_profile[dp->type] = true;
BroadcastFeature(STOC_PROFILE, pdata, len, dp->type);
}
void SingleDuel::SendServerCapability(DuelPlayer* dp) {
CTOS_Capability cap;
cap.protocol = FEATURE_PROTOCOL;
cap.flags = FEATURE_APPEARANCE | FEATURE_DIALOGUE | FEATURE_SETUP_PAIRS | FEATURE_SEAT_PLAN | FEATURE_RULES_RESTART | FEATURE_SEAT_STATE | FEATURE_LOBBY_AFTER_MATCH | FEATURE_COIN_TOSS | FEATURE_DECK_LIST; // YGOL setup pairs + host seats + rules restart + seat state + lobby after match + coin toss + deck lists
cap.flags = FEATURE_APPEARANCE | FEATURE_DIALOGUE | FEATURE_SETUP_PAIRS | FEATURE_SEAT_PLAN | FEATURE_RULES_RESTART | FEATURE_SEAT_STATE | FEATURE_LOBBY_AFTER_MATCH | FEATURE_COIN_TOSS | FEATURE_DECK_LIST | FEATURE_PROFILE; // YGOL setup pairs + host seats + rules restart + seat state + lobby after match + coin toss + deck lists + profile
unsigned char buf[SIZE_STOC_FEATURE];
const auto size = NetServer::CreateStampedPacket((unsigned char*)&cap, sizeof cap, buf, FEATURE_SENDER_SERVER);
NetServer::SendBufferToPlayer(dp, STOC_CAPABILITY, buf, size);
@@ -99,6 +111,10 @@ void SingleDuel::SendSeatFeatures(DuelPlayer* dp, int seat) {
const auto size = NetServer::CreateStampedPacket((unsigned char*)&seat_state[seat], sizeof seat_state[seat], buf, (uint16_t)seat);
NetServer::SendBufferToPlayer(dp, STOC_SEAT_STATE, buf, size);
}
if(has_profile[seat]) { // YGOL profile
const auto size = NetServer::CreateStampedPacket((unsigned char*)&profile[seat], sizeof profile[seat], buf, (uint16_t)seat);
NetServer::SendBufferToPlayer(dp, STOC_PROFILE, buf, size);
}
}
// YGOL host seats
void SingleDuel::SendToLobby(unsigned char proto, void* buffer, size_t len) {
@@ -141,6 +157,10 @@ void SingleDuel::BroadcastSeatFeatures(int seat) {
const auto size = NetServer::CreateStampedPacket((unsigned char*)&seat_state[seat], sizeof seat_state[seat], buf, (uint16_t)seat);
SendToLobby(STOC_SEAT_STATE, buf, size);
}
if(has_profile[seat]) { // YGOL profile
const auto size = NetServer::CreateStampedPacket((unsigned char*)&profile[seat], sizeof profile[seat], buf, (uint16_t)seat);
SendToLobby(STOC_PROFILE, buf, size);
}
}
int SingleDuel::FreeOpenSeat() {
for(int i = 0; i < 2; ++i)
@@ -272,6 +292,8 @@ void SingleDuel::SwapSeats(int first, int second) {
std::swap(appearance[first], appearance[second]);
std::swap(has_appearance[first], has_appearance[second]);
std::swap(seat_state[first], seat_state[second]); // YGOL seat state
std::swap(profile[first], profile[second]); // YGOL profile
std::swap(has_profile[first], has_profile[second]);
std::swap(seat_kind[first], seat_kind[second]);
uint8_t token[SEAT_TOKEN_LEN];
std::memcpy(token, seat_token[first], SEAT_TOKEN_LEN);
@@ -894,6 +916,7 @@ void SingleDuel::SeatLeft(DuelPlayer* dp) {
ready[dp->type] = false;
has_appearance[dp->type] = false; // YGOL feature messages
seat_state[dp->type] = CTOS_SeatState{}; // YGOL seat state
has_profile[dp->type] = false; // YGOL profile
scpc.status = (dp->type << 4) | PLAYERCHANGE_LEAVE;
if(players[0] && dp->type != 0)
NetServer::SendPacketToPlayer(players[0], STOC_HS_PLAYER_CHANGE, scpc);
@@ -972,6 +995,7 @@ void SingleDuel::ToObserver(DuelPlayer* dp) {
ready[dp->type] = false;
has_appearance[dp->type] = false; // YGOL feature messages
seat_state[dp->type] = CTOS_SeatState{}; // YGOL seat state
has_profile[dp->type] = false; // YGOL profile
dp->type = NETPLAYER_TYPE_OBSERVER;
observers.insert(dp);
STOC_TypeChange sctc;