1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

anims:: improved rollback

This commit is contained in:
Zeno Rogue 2020-11-14 13:11:01 +01:00
parent 3082b88139
commit f35a09a885

View File

@ -1187,6 +1187,8 @@ EX void animate_rug_movement(ld t) {
); );
} }
vector<reaction_t> on_rollback;
EX void apply() { EX void apply() {
int t = ticks - lastticks; int t = ticks - lastticks;
lastticks = ticks; lastticks = ticks;
@ -1278,7 +1280,8 @@ EX void apply() {
turncount -= ticks * tidalsize / period; turncount -= ticks * tidalsize / period;
} }
if(env_volcano) { if(env_volcano) {
bak_turncount = turncount; auto bak_turncount = turncount;
on_rollback.push_back([bak_turncount] { turncount = bak_turncount; });
turncount += env_volcano * ticks * 64 / period; turncount += env_volcano * ticks * 64 / period;
for(auto& p: gmatrix) if(p.first->land == laVolcano) checkTide(p.first); for(auto& p: gmatrix) if(p.first->land == laVolcano) checkTide(p.first);
} }
@ -1318,8 +1321,9 @@ EX void apply() {
} }
EX void rollback() { EX void rollback() {
if(env_volcano) { while(!on_rollback.empty()) {
turncount = bak_turncount; on_rollback.back()();
on_rollback.pop_back();
} }
} }