1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-31 22:12:59 +00:00

nilrider:: load plans as ghosts

This commit is contained in:
Zeno Rogue
2024-08-20 11:35:31 +02:00
parent c9b1b47150
commit c4a5438f8d
3 changed files with 41 additions and 1 deletions

View File

@@ -105,4 +105,23 @@ void load() {
#endif
}
void level::load_plan_as_ghost(plan_replay& r) {
vector<timestamp> history_backup;
swap(history_backup, history);
swap(r.plan, plan);
history.clear();
history.push_back(start);
while(true) {
int s = isize(history);
if(!simulate()) break;
if(isize(history) == s) break;
}
println(hlog, "a history of length ", isize(history), " becomes a ghost");
ghosts.emplace_back();
auto& g = ghosts.back();
g.history = std::move(history);
swap(history_backup, history);
swap(r.plan, plan);
}
}