Erase undo stack when load a savegame

Having trouble with the game? Report issues and get help here. Read this first!

Moderator: Forum Moderators

Forum rules
Before reporting issues in this section, you must read the following topic:
Post Reply
User avatar
Toranks
Translator
Posts: 168
Joined: October 21st, 2022, 8:59 pm
Location: Sevilla
Contact:

Erase undo stack when load a savegame

Post by Toranks »

I've tried putting all sorts of actions in a preload event, but whatever I do doesn't stop loading a savegame from undoing the last move before saving the save. Even if I create a unit and generate a random number, two actions that are not supposed to be undone. The unit is created but I can undo the last movement previously saved.

Code: Select all

[event]
     name=preload
     first_time_only=no
[filter_condition]
    some conditions
[/filter_condition]
     {VARIABLE_OP disallow_undo rand(0..1)}
     {NAMED_GENERIC_UNIT 1 Peasant 1 1 dummy Dummy}
[/event]
The question is, is it technically possible to cancel/avoid undoing when loading a savegame via a preload event or similar, which allows filtering conditions?

The goal is to avoid a crash when certain events that contain [on_undo] are executed. #7253
User avatar
Pentarctagon
Project Manager
Posts: 5581
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Erase undo stack when load a savegame

Post by Pentarctagon »

Note that preload events aren't synchronized, so depending on what you use them for it can cause issues in online multiplayer games and replays.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Post Reply