make cosmetic advance_time() mismatches warnings unless --strict
This commit is contained in:
@@ -1648,8 +1648,10 @@ void advance_time(bool did_something, bool need_redraw, bool need_reprint) {
|
||||
std::ostringstream sstr;
|
||||
sstr << std::boolalpha;
|
||||
bool wrong_args = false;
|
||||
bool divergent = false;
|
||||
if(did_something != str_to_bool(info["did_something"])){
|
||||
wrong_args = true;
|
||||
divergent = true;
|
||||
sstr << "did_something: expected " << !did_something << ", was " << did_something << ". ";
|
||||
}
|
||||
if(need_redraw != str_to_bool(info["need_redraw"])){
|
||||
@@ -1662,10 +1664,29 @@ void advance_time(bool did_something, bool need_redraw, bool need_reprint) {
|
||||
}
|
||||
sstr << "After " << _last_action_type;
|
||||
if(wrong_args){
|
||||
throw std::string { "Replay system internal error! advance_time() was called with the wrong args. " } + sstr.str();
|
||||
if(divergent){
|
||||
throw replay_error + "advance_time() was called with the wrong args, diverging behavior. " + sstr.str();
|
||||
}
|
||||
else{
|
||||
std::string message = "advance_time() was called with the wrong args, changing behavior cosmetically. " + sstr.str();
|
||||
if(replay_strict){
|
||||
throw replay_error + message;
|
||||
}else{
|
||||
std::cout << replay_warning << message << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
throw std::string { "Replay system internal error! advance_time() was called following an action which does not advance time: " } + last_action_type;
|
||||
if(did_something){
|
||||
throw replay_error + "advance_time() was called with divergent side effects following an action which does not advance time: " + last_action_type;
|
||||
}else{
|
||||
std::string message = "advance_time() was called with cosmetic side effects following an action which does not advance time: " + last_action_type;
|
||||
if(replay_strict){
|
||||
throw replay_error + message;
|
||||
}else{
|
||||
std::cout << replay_warning << message << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -236,6 +236,7 @@ static void init_ui() {
|
||||
|
||||
extern bool record_verbose;
|
||||
extern bool replay_verbose;
|
||||
extern bool replay_strict;
|
||||
|
||||
static void process_args(int argc, char* argv[]) {
|
||||
preprocess_args(argc, argv);
|
||||
@@ -248,6 +249,7 @@ static void process_args(int argc, char* argv[]) {
|
||||
cli |= clara::Opt(record_unique)["--unique"]("When recording, automatically insert a timestamp into the filename to guarantee uniqueness.");
|
||||
cli |= clara::Opt(record_verbose)["--verbose"]("Record extra information for internal testing of the replay system.");
|
||||
cli |= clara::Opt(replay, "replay-file")["--replay"]("Replays a previously-recorded session from the specified XML file.");
|
||||
cli |= clara::Opt(replay_strict)["--strict"]("Enforces strictly identical replay behavior, even where this is only cosmetic");
|
||||
cli |= clara::Opt(replay_speed, "fps")["--replay-speed"]("Specifies how quickly actions are processed while replaying");
|
||||
cli |= clara::Arg(saved_game, "save-file")("Launch and load a saved game file.");
|
||||
bool show_help = false;
|
||||
@@ -617,6 +619,7 @@ static void replay_next_action() {
|
||||
}else if(t == "cancel_item_target"){
|
||||
cancel_item_target(did_something, need_redraw, need_reprint);
|
||||
}else if(t == "advance_time"){
|
||||
// This is bad regardless of strictness, because visual changes may have occurred which won't get redrawn/reprinted
|
||||
throw std::string { "Replay system internal error! advance_time() was supposed to be called by the last action, but wasn't: " } + _last_action_type;
|
||||
}else{
|
||||
std::ostringstream sstr;
|
||||
|
Reference in New Issue
Block a user