From 75fab887e177fcee9077d5911da5f335266ca7e9 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Wed, 6 Sep 2023 09:46:28 -0700 Subject: [PATCH] make tournament state parsing more robust --- src/Episode3/Tournament.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Episode3/Tournament.cc b/src/Episode3/Tournament.cc index 5abb991f..6e428aa0 100644 --- a/src/Episode3/Tournament.cc +++ b/src/Episode3/Tournament.cc @@ -661,10 +661,10 @@ TournamentIndex::TournamentIndex( } auto json = JSON::parse(load_file(this->state_filename)); - if (json.size() != 0x20) { + if (json.size() > 0x20) { throw runtime_error("tournament JSON list length is incorrect"); } - for (size_t z = 0; z < 0x20; z++) { + for (size_t z = 0; z < min(json.size(), 0x20); z++) { if (!json.at(z).is_null()) { this->tournaments[z].reset(new Tournament(this->map_index, this->com_deck_index, z, json.at(z))); this->tournaments[z]->init();