mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 16:14:58 +01:00
fix: a test run neither reads nor saves the player's odometer store
the autotests (--test, Global.test.enabled) run the vehicles of the player's game: their odometers count from the legacy or made up states in a store of their own, and nothing is written to eu07_odometers.txt
This commit is contained in:
@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "vehicle/odometer.h"
|
||||
|
||||
#include "utilities/Globals.h"
|
||||
#include "utilities/Logs.h"
|
||||
#include "utilities/utilities.h"
|
||||
|
||||
@@ -227,7 +228,17 @@ std::filesystem::path file() {
|
||||
return path.empty() ? std::filesystem::path{"eu07_odometers.txt"} : path;
|
||||
}
|
||||
|
||||
bool persistent() {
|
||||
return false == Global.test.enabled;
|
||||
}
|
||||
|
||||
store &states() {
|
||||
if (false == persistent()) {
|
||||
// the vehicles of a test run count their odometers as usual, from the guessed or legacy states, with nothing
|
||||
// read from or saved to the player's file
|
||||
static store scratch;
|
||||
return scratch;
|
||||
}
|
||||
static store odometers = [] {
|
||||
store result;
|
||||
std::ifstream input{file(), std::ios::binary};
|
||||
@@ -292,6 +303,8 @@ bool save(store &States, std::filesystem::path const &File) {
|
||||
}
|
||||
|
||||
bool save() {
|
||||
if (false == persistent())
|
||||
return true;
|
||||
return save(states(), file());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user