Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,17 @@ namespace{
// A stream of frames into a ScreenEventLog, and its describe() text.
struct ScreenEventLogCase{
struct Frame{
int ms;
int ms = 0;
std::vector<ScreenEvent> events;
};
struct Input{
size_t capacity;
size_t capacity = 0;
std::vector<Frame> frames;
};
struct Expectation{
// describe() of the log, times from the first frame.
std::string text;
size_t dropped;
size_t dropped = 0;
};

std::string name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,32 @@ void check_in_story_order(

namespace{

// Which row sequence the reload check applies to.
enum class RunKind{
DEVELOPER,
USER,
};

// Text naming `run` in a reload error.
std::string_view run_suffix(RunKind run){
switch (run){
case RunKind::DEVELOPER:
return "";
case RunKind::USER:
return " in a user's run";
}
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Unknown story run kind.");
}

// Throws ParseException naming `source` unless `previous` ends on the
// game's autosave in `rows`; `run` says in whose run ("" or " in a
// user's run").
// game's autosave in `rows`, for `run`.
void check_reload_after(
std::optional<std::string_view> previous, const StoryRows& rows, std::string_view run, std::string_view source
std::optional<std::string_view> previous, const StoryRows& rows, RunKind run, std::string_view source
){
if (!previous || !rows.autosaves.contains(*previous)){
throw ParseException(std::format(
"{}: reload_when_chained after a checkpoint that does not end on the game's autosave{}: the reload would load an older save",
source, run
source, run_suffix(run)
));
}
}
Expand All @@ -87,9 +103,9 @@ void add_story_row(
if (start == RowSave::WITHOUT_SAVE){
throw ParseException(std::format("{}: reload_when_chained on a checkpoint with no save to reload", source));
}
check_reload_after(previous.in_dev_run, rows, "", source);
check_reload_after(previous.in_dev_run, rows, RunKind::DEVELOPER, source);
if (!execution.dev_only && previous.in_user_run != previous.in_dev_run){
check_reload_after(previous.in_user_run, rows, " in a user's run", source);
check_reload_after(previous.in_user_run, rows, RunKind::USER, source);
}
rows.reload_when_chained.emplace(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ const LoadCase LOAD_CASES[] = {
.input = {.builtin = {{"test-01.00.plan", file_text("01.00", R"({"save": "menu"})")}, ROW_1}},
.expectation = {.error = "test-01.01.plan: reload_when_chained after a checkpoint that does not end on the game's autosave"},
},
{
.name = "a dev-only reload after a dev-only autosave row, the user's row before it not autosaving, loads",
.input = {.builtin = {
{"test-01.00.plan", file_text("01.00", R"({"save": "menu"})")},
{"test-01.005.plan", file_text("01.005", R"({"dev_only": true, "save": "autosave"})")},
{"test-01.01.plan", file_text("01.01", R"({"dev_only": true, "reload_when_chained": true})")},
}},
.expectation = {.summary = "rows 01.00 01.005 01.01 | titles Row Row Row | autosave 01.005 | chained 01.01 | always | dev_only 01.005 01.01 | dev "},
},
{
.name = "reload_when_chained after a dev-only autosave row, the user's row before it not autosaving, fails",
.input = {.builtin = {
Expand Down
Loading
Loading