RB: refuse to replay a capture silently against the wrong board
A capture belongs to one save. Replaying one turn's commands against another turn's board is not an error the arithmetic can see -- the blocks name player ids that exist in both, so the counter is charged happily and the number is confidently wrong. The capture now records which save it was taken on and the CLI says so when they disagree, and says so too when the capture does not record it at all.
This commit is contained in:
parent
98257b9e82
commit
f438d2f9a7
1 changed files with 18 additions and 0 deletions
|
|
@ -278,6 +278,24 @@ int main(int argc, char** argv) {
|
|||
capture.blocks.size(), capture.seeds.size());
|
||||
for (const auto& kv : capture.meta)
|
||||
std::printf(" %s: %s\n", kv.first.c_str(), kv.second.c_str());
|
||||
// A CAPTURE BELONGS TO ONE SAVE. Replaying a turn's commands against a different board
|
||||
// is not an error the arithmetic can see -- the blocks name player ids that exist in
|
||||
// both, so it charges the counter happily and produces a confident wrong number. When
|
||||
// the capture records which save it was taken on, check it.
|
||||
if (const std::string* bound = capture.Meta("input")) {
|
||||
const std::string want = bound->substr(0, bound->find(' '));
|
||||
std::string have = in;
|
||||
const std::size_t slash = have.find_last_of("/\\");
|
||||
if (slash != std::string::npos) have = have.substr(slash + 1);
|
||||
if (!want.empty() && want != have)
|
||||
std::printf("turn-commands: ! this capture was taken on '%s' and is being "
|
||||
"replayed against '%s'. A capture belongs to ONE board; the counter "
|
||||
"will be charged either way and the number will be wrong.\n",
|
||||
want.c_str(), have.c_str());
|
||||
} else {
|
||||
std::printf("turn-commands: ! this capture does not record which save it was taken "
|
||||
"on, so nothing here can tell whether it belongs to this one\n");
|
||||
}
|
||||
}
|
||||
// Seeds given on the command line win over the ones in the file, and a seed for a client the
|
||||
// file does not mention is added. Nothing consumes them yet, so this is bookkeeping with a
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue