server: 0009-setup-pairs

TICKET-258: ygol.<key>=<value> tokens after slot 11 go into the duel registry before special.lua, into the replay pairs block and to every joiner as STOC 0x43; argv sized from the token count.

Replayed from Tools/YGOLegacy/patches/0009-setup-pairs.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:57 -07:00
1 parent 00a715f181
commit 76e359f6cf
7 files changed
+94 -8

No files matched your search

+32
View File
@@ -557,5 +557,37 @@ size_t NetServer::CreateStampedPacket(unsigned char* src, int src_size, unsigned
std::memcpy(pdst, src, src_size);
return sizeof(dst_player_type) + src_size;
}
// YGOL setup pairs
std::vector<std::string> setup_pairs;
bool IsSetupPairToken(const char* token) {
return std::strncmp(token, "ygol.", 5) == 0;
}
bool AddSetupPair(const char* token) {
const auto len = std::strlen(token);
const char* eq = std::strchr(token, '=');
if(!eq || eq - token <= 5 || len > SETUP_PAIR_MAX_LEN || setup_pairs.size() >= SETUP_PAIRS_MAX)
return false;
setup_pairs.emplace_back(token, len);
return true;
}
size_t WriteSetupPairsBlock(unsigned char* dst) {
auto pdst = dst;
BufferIO::Write<uint16_t>(pdst, (uint16_t)setup_pairs.size());
for(const auto& pair : setup_pairs) {
BufferIO::Write<uint16_t>(pdst, (uint16_t)pair.size());
std::memcpy(pdst, pair.data(), pair.size());
pdst += pair.size();
}
return pdst - dst;
}
void NetServer::SendSetupPairs(DuelPlayer* dp) {
if(setup_pairs.empty())
return;
unsigned char buf[sizeof(uint16_t) + SETUP_PAIRS_BLOCK_MAX];
auto pbuf = buf;
BufferIO::Write<uint16_t>(pbuf, FEATURE_SENDER_SERVER);
const auto size = sizeof(uint16_t) + WriteSetupPairsBlock(pbuf);
SendBufferToPlayer(dp, STOC_SETUP_PAIRS, buf, size);
}
}