fix undo/redo edit town text and outdoor text

This commit is contained in:
2025-06-21 12:29:39 -05:00
parent 66d6e197b9
commit b2c69554f3
2 changed files with 10 additions and 1 deletions

View File

@@ -1081,12 +1081,16 @@ bool aClearLocString::redo_me() {
}
bool aEditClearString::undo_me() {
if(str_mode == STRS_TOWN) set_current_town(which_town);
else if(str_mode == STRS_OUT) set_current_out(which_out);
fetch_str(str_mode, which) = old_value;
start_string_editing(str_mode);
return true;
}
bool aEditClearString::redo_me() {
if(str_mode == STRS_TOWN) set_current_town(which_town);
else if(str_mode == STRS_OUT) set_current_out(which_out);
fetch_str(str_mode, which) = new_value;
start_string_editing(str_mode);
return true;

View File

@@ -18,6 +18,8 @@
extern cScenario scenario;
extern cTown* town;
extern bool editing_town;
extern short cur_town;
extern location cur_out;
struct area_ref_t {
bool is_town;
@@ -747,9 +749,12 @@ class aEditClearString : public cAction {
std::string new_value;
bool undo_me() override;
bool redo_me() override;
// undo/redo for town text and outdoor text depends on global state of which town/outdoor section are active
size_t which_town;
location which_out;
public:
aEditClearString(std::string name, eStrMode str_mode, size_t which, std::string old_value, std::string new_value) :
cAction(name), str_mode(str_mode), which(which), old_value(old_value), new_value(new_value) {}
cAction(name), str_mode(str_mode), which(which), old_value(old_value), new_value(new_value), which_town(cur_town), which_out(cur_out) {}
};
#endif