delete last town is just the inverse of create town

This commit is contained in:
2025-06-02 16:52:32 -05:00
parent 5452057b25
commit f4aa9780e0
6 changed files with 36 additions and 26 deletions

View File

@@ -23,13 +23,13 @@ cAction::~cAction() {}
void cAction::undo() {
UNDO_LOG("Undoing " + actname);
if(done && undo_me())
if(done && reversed ? redo_me() : undo_me())
done = false;
}
void cAction::redo() {
UNDO_LOG("Redoing " + actname);
if(!done && redo_me())
if(!done && reversed ? undo_me() : redo_me())
done = true;
}

View File

@@ -23,7 +23,9 @@ class cAction {
protected:
/// Construct a named action
/// @param name The name of the action to show in the Edit menu
cAction(std::string name) : actname(name) {}
cAction(std::string name, bool reversed = false) : actname(name), reversed(reversed) {}
/// For actions that have an inverse, this flag inverts the action implementation (i.e. create/delete)
bool reversed = true;
public:
/// Undoes this action if it has not already been undone.
/// If it has already been undone, does nothing.