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:
1 parent
00a715f181
commit
76e359f6cf
7 files changed
+94
-8
No files matched your search
@@ -144,6 +144,7 @@ int main(int argc, char* argv[]) {
|
||||
ygo::game_info.time_limit = 180;
|
||||
std::memset(ygo::pre_seed, 0, sizeof(ygo::pre_seed));
|
||||
std::memset(ygo::pre_seed_specified, 0, sizeof(ygo::pre_seed_specified));
|
||||
ygo::setup_pairs.clear(); // YGOL setup pairs
|
||||
if (argc == 2) {
|
||||
int code = atoi(argv[1]);
|
||||
ygo::mainGame = &_game;
|
||||
@@ -186,28 +187,37 @@ int main(int argc, char* argv[]) {
|
||||
ygo::game_info.draw_count = atoi(argv[10]);
|
||||
ygo::game_info.time_limit = atoi(argv[11]);
|
||||
ygo::replay_mode = atoi(argv[12]);
|
||||
for (int i = 13; (i < argc && i < (13 + MAX_MATCH_COUNT)) ; ++i)
|
||||
// YGOL setup pairs: ygol.* tokens never reach the seeds; the n-th other token is seed n, as before
|
||||
for (int i = 13, seed = 0; i < argc; ++i)
|
||||
{
|
||||
if (ygo::IsSetupPairToken(argv[i])) {
|
||||
if (!ygo::AddSetupPair(argv[i]))
|
||||
std::fprintf(stderr, "Dropped setup pair: %s\n", argv[i]);
|
||||
continue;
|
||||
}
|
||||
if (seed >= MAX_MATCH_COUNT)
|
||||
continue;
|
||||
auto ok = Base64::Decode(
|
||||
reinterpret_cast<const unsigned char*>(argv[i]),
|
||||
strlen(argv[i]),
|
||||
reinterpret_cast<unsigned char*>(ygo::pre_seed[i - 13]),
|
||||
reinterpret_cast<unsigned char*>(ygo::pre_seed[seed]),
|
||||
SEED_COUNT * sizeof(uint32_t)
|
||||
);
|
||||
if(ok) {
|
||||
// check if it isn't all zero
|
||||
bool all_zero = true;
|
||||
for (int j = 0; j < SEED_COUNT; ++j) {
|
||||
if (ygo::pre_seed[i - 13][j] != 0) {
|
||||
if (ygo::pre_seed[seed][j] != 0) {
|
||||
all_zero = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!all_zero)
|
||||
ygo::pre_seed_specified[i - 13] = 1;
|
||||
ygo::pre_seed_specified[seed] = 1;
|
||||
}
|
||||
else
|
||||
std::fprintf(stderr, "Failed to decode seed %d: %s\n", i - 13, argv[i]);
|
||||
std::fprintf(stderr, "Failed to decode seed %d: %s\n", seed, argv[i]);
|
||||
++seed;
|
||||
}
|
||||
}
|
||||
ygo::mainGame = &_game;
|
||||
|
||||
Reference in new issue
Block a user