Skip to content

Commit

Permalink
keep cam pos after undo
Browse files Browse the repository at this point in the history
  • Loading branch information
griffi-gh committed Oct 15, 2024
1 parent c138b18 commit 9a79d05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/src/gundo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ void undo_stack::checkpoint(const char *reason) {
);
}

const char* undo_stack::restore() {
const char* undo_stack::restore(bool keep_cam_pos /* = true */) {
float cx, cy, cz;
if (keep_cam_pos) {
cx = G->cam->_position.x;
cy = G->cam->_position.y;
cz = G->cam->_position.z;
}

if (this->items.size() == 0) {
tms_fatalf("undo_load: no items to load");
}
Expand All @@ -68,5 +75,9 @@ const char* undo_stack::restore() {
tms_infof("Restored level from undo stack");

free(item.data);

if (keep_cam_pos) {
G->cam->set_position(cx, cy, cz);
}
return item.reason;
}
2 changes: 1 addition & 1 deletion src/src/gundo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct undo_stack {
// Returns the reason for the last checkpoint
//
// Avoid using this function directly, use P.add_action(ACTION_UNDO_RESTORE, 0) instead
const char* restore();
const char* restore(bool keep_cam_pos = true);
};

extern struct undo_stack undo;
Expand Down

0 comments on commit 9a79d05

Please sign in to comment.