Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

demario
Posts: 37
Joined: July 3rd, 2019, 1:05 pm

Re: Questions about replays, random seed, recruit and unit checksum

Post by demario »

Additional support for loading 1.10 replays in BFW1.14 is implemented in the diff file in attachment.
With this modification, you can load the some replays from ladder from the past 9 years (starting around Feb 2012 by my count). :whistle:

As the differences are growing, the changes to apply to the code are deeper and dirtier. I will give up the idea to explain how it is done. Just to mention that in some circumstances, there is no way to generate the right random numbers and the RNG1.10 is updated to load the content of the [replay] from the savegame and to bypass number generation and simulate the legacy behavior by returning numbers from the replay. This is ugly but it does the trick.

Most of the known replay breaking OOS are fixed, the OOS from the recruit checksum got disabled from WML (by removing the [checkup]). So you don't have to apply a second diff to disable the checksum check in the code for either 1.12 or 1.10.

You better apply the changes in diff files from inside wesnoth directory using "patch -p2 ..." from an original BFW1.14 code (you need to revert previous 1.12 support as it is included here too and would conflict). I got them compiled with cmake only. Let me know if it works for you. Together with the list of issues for different versions of replay that have been fixed already (or not).

[update May 26th] New diff file ; updated status. [/update]

This version supports you to:
- load replays from different versions in sequence
- observe and play on MP server from a newly started wesnoth
This version does not support you to:
- observe or play on MP server right after you loaded replays from a different version (you will get MP OOS)


So while you may have only one version of BFW1.14, it should be restarted between backward replay mode and play/obs on MP server.
Last edited by demario on May 26th, 2021, 9:00 am, edited 1 time in total.
"simply put, it's an old game"T — Cackfiend
demario
Posts: 37
Joined: July 3rd, 2019, 1:05 pm

Re: Questions about replays, random seed, recruit and unit checksum

Post by demario »

Here is an assessment of the ability to backward support old replays in BFW1.14 at this time.

First it should be clear that the backward support is done by cascading changes in the static data from the savegame.
A 1.14 saves are loaded as is, and 1.12 saves are converted to 1.14 format by moving around pieces of savegame's WML to match the 1.14 syntax. The matching from the conversion is not perfect (less than 100% compatible). Actually different 1.14 saves are sometimes having different formats too.

This is a cascading process as 1.10 saves are converted to 1.12 format first and the resulting format is then going through the same conversion as original 1.12 saves to 1.14 format.
So a problem to replay 1.10 save in BFW1.14 can have two origins:
  • the 1.10 save is not meeting the expected format for 1.10-1.12 conversion
  • the 1.12 format resulting from the first conversion is not meeting the expected format for 1.12-1.14 conversion
So it is easy to understand that the oldest the save is, the more conversion steps are needed and the more likely to fail part of the conversion and not being eligible for replay. Or put in another way, if 90% of 1.10-1.12 conversion output is matching 1.12 format and 90% of 1.12-1.14 conversion output is matching 1.14 format then a 1.10 save has roughly 81% "chance" of being replayed OK in BFW1.14 (down from 90% "chance" for 1.12 save).

This is the concern at this time: how is the rate dropping at each step of the cascading conversion process. I got the following numbers:

1.14 saves:
I will assume all 1.14 saves can be replayed in BFW1.14. This is probably not true as some saves may be corrupted. But if such a problem happens, this is a bug in BFW1.14 save/replay that is better reported to the development team.

1.12 saves:
I have downloaded 302 saves from ladder records from 2015/04/12 to 2017/06/28.
Some 283 of these saves could be replayed in BFW1.14 (93.7%)
There are 9 saves that report OOS (3%). Some of them come from corrupted saves due to disconnect/reload.
There are 6 saves that report WML problem (2%). For example, the leader doesn't show or the recruit list is inconsistent.
There are 3 saves that crash BFW1.14 (1%).

1.10 saves:
I have downloaded 249 saves from ladder records from 2012/01/30 to 2013/04/30.
There are 142 saves that replay OK (57%).
There are 82 saves that report OOS (33%).
There are 13 saves that report WML problem (5%).
There are 12 saves that crash BFW1.14 (5%).

The cascading effect is clear, and the drop in numbers of save that can be replayed is steep (nearly one third, from 93% to 57%). If I extrapolate the drop down to 1.4 saves, there would be only 12% of 1.4 saves that could be replayed.
Lastly, the games that are more likely to be replayed are the shortest ones which are also the least interesting ones (bad matchup, bad strategy, bad RNG, losing player is tired...). That is the point where I started questioning the whole point of the endeavor.
[To be continued]

Over there, the last version of the changes to apply on BFW1.14 with 'patch -p2' to get the version of the code used for these statistics. Previously listed limitations still apply to this version.
Last edited by demario on June 2nd, 2021, 11:28 am, edited 2 times in total.
"simply put, it's an old game"T — Cackfiend
demario
Posts: 37
Joined: July 3rd, 2019, 1:05 pm

Re: Questions about replays, random seed, recruit and unit checksum

Post by demario »

[Part two]
What is keeping me going is one good news: as I was sitting on a half finished 1.8 support, the first stats were very encouraging: from the 168 saves from ladder records, there were 121 saves that replay OK (72%) in that first version.
So it appear that many issues about 1.10 saves do not apply to 1.8 saves. Or put it like this: 1.8 saves converted to 1.10 are better than original 1.10 saves.
As an example, BFW1.10 expects the position of leader to be passed in all recruit commands (which was implemented in 1.8 conversion) but 1.10 sometimes fills this position with position (-999,-999), which is not accepted by later versions.
[The End]

After some more work on both 1.8 and 1.10 support, here is the first version that implements support for loading 1.8-1.12 replays in BFW1.14 is implemented in the diff file in attachment. You can apply it to a clean BFW1.14 (I use 1.14.14, build with cmake) using 'patch -p2'.

The most common OOS that is not fatal is something like 'Our next unit id is [X] but the original next unit id was [Y]'.
If it happens in turn 1, it will probably be sorted out at turn 2, so you just need to skip it at most twice.
If it happens after turn 2, it will happen at every side turn, so it is quite annoying. If you really want to keep going, pressing <ESC> on the dialog is like pressing the 'no' button. I advise not enabling "skip all" as other OOS (more likely to be fatal) may be hidden.

The stats that are achieved now:
[1.14 and 1.12] Probably unchanged

[1.10]
I have downloaded 249 saves from ladder records from 2012/01/30 to 2013/04/30.
Files that replay OK: 216/249 (86%) :) including "Our next unit id" OOS that can be skipped
Files that crash BFW1.14: 13/249 (5%)
Files with WML errors: 12/249 (5%)
Files with other OOS: 7/249 (3%)

[1.8]
I have downloaded 168 saves from ladder records from 2011/02/22 to 2012/01/21.
Files that replay OK: 140/169 (83%) 8) including "Our next unit id" OOS that can be skipped
Files with other OOS: 14/168 (8%)
Files with WML errors: 11/168 (7%)
Files that crash BFW1.14: 8/168 (5%)

Remember that you have to close BFW between switching from replay old replays and playing/replaying 1.14 games (or you will get OOS)
All Hornshark Islands replays fail (WML error), all 1.8 Aethermath saves fail too.
Let me know how it works for you.
Last edited by demario on July 5th, 2021, 9:17 am, edited 1 time in total.
"simply put, it's an old game"T — Cackfiend
demario
Posts: 37
Joined: July 3rd, 2019, 1:05 pm

Re: Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Post by demario »

demario wrote: January 8th, 2021, 2:34 am At version BFW1.14, wesnoth doesn't offer any support for loading old saves to replay.
If you are interested in replaying old saves, additional support must be added to BFW1.14 code.
After 6 months from the opening post, it is time for me to take on long break on this.

A finai version of the changes to apply on BFW1.14 to be able to replay saves from 1.4 to 1.12 is available.

You will find the instructions and the current statistics in the opening post.

Direct download of latest patch.

In attachment, a file by file status for each tested saves broken down based on the version number.
I believe that some of the problems could still be fixed but it will have to wait for another time.

It would be cool if someone was trying to compile it on windows and possibly sharing the executable for everyone to enjoy those good old replays from years ago.
Attachments
saves-1.12.file_list.txt
file by file status for 1.12 saves
(24.61 KiB) Downloaded 33 times
saves-1.10.file_list.txt
file by file status for 1.10 saves
(55.88 KiB) Downloaded 33 times
saves-1.8.file_list.txt
file by file status for 1.8 saves
(42.62 KiB) Downloaded 35 times
saves-1.6.file_list.txt
file by file status for 1.6 saves
(14.04 KiB) Downloaded 35 times
saves-1.4.file_list.txt
file by file status for 1.4 saves
(13.94 KiB) Downloaded 33 times
"simply put, it's an old game"T — Cackfiend
User avatar
egallager
Posts: 165
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Post by egallager »

Could you (or someone else, possibly even a smarter future version of myself) submit this as a pull request to mainline? I think this would be a useful feature to have; it'd help ease some qualms players might have about updating their versions of BfW...
Wesnoth-related GitHub repos:
General mods collection, SotBEEE, AToTBWaTD, The Earth's Gut, A Little Adventure, FtF
Social media: Twitter: @cooljeanius, Steam: egallager
User avatar
Celtic_Minstrel
Developer
Posts: 1817
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Post by Celtic_Minstrel »

I think the patch in its current state is unsuitable for merging to 1.16 or even to master. In particular, I'm not fond of having duplicate versions of every unit ever. The C++ side of the patch could perhaps be somewhat cleaned up for inclusion though, and perhaps a way could be devised to allow WML side of things to be distributed as an add-on.

A patch specifically to allow 1.14 replays (but not older ones) to be loaded in 1.16 would be more likely to be accepted than this all-purpose patch extending back to the beginning of time.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
User avatar
egallager
Posts: 165
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Post by egallager »

I tried applying the patch to master, but it creates a rather large rejects file that I'm not sure how to wiggle back into the source file: https://github.com/cooljeanius/wesnoth/ ... me.cpp.rej
Wesnoth-related GitHub repos:
General mods collection, SotBEEE, AToTBWaTD, The Earth's Gut, A Little Adventure, FtF
Social media: Twitter: @cooljeanius, Steam: egallager
User avatar
octalot
Developer
Posts: 580
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Post by octalot »

egallager wrote: July 26th, 2021, 5:32 am I tried applying the patch to master, but it creates a rather large rejects file that I'm not sure how to wiggle back into the source file: https://github.com/cooljeanius/wesnoth/ ... me.cpp.rej
I echo Soliton's and CelticMinstrel's concerns, and add to them a question "how much do all those extra units slow down the game's startup and cache-creation sequences?". I think this shouldn't be merged to the mainline 1.16 branch.

For trying to apply the patch, note that savegame.cpp was reformatted in 2a827fbefbcc9168285c810a440443420dbb951d. I'd start by applying the patch to 1.14, and then applying the same reformatting to the 1.14 branch.
User avatar
egallager
Posts: 165
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Post by egallager »

octalot wrote: July 26th, 2021, 8:03 am
egallager wrote: July 26th, 2021, 5:32 am I tried applying the patch to master, but it creates a rather large rejects file that I'm not sure how to wiggle back into the source file: https://github.com/cooljeanius/wesnoth/ ... me.cpp.rej
I echo Soliton's and CelticMinstrel's concerns, and add to them a question "how much do all those extra units slow down the game's startup and cache-creation sequences?". I think this shouldn't be merged to the mainline 1.16 branch.

For trying to apply the patch, note that savegame.cpp was reformatted in 2a827fbefbcc9168285c810a440443420dbb951d. I'd start by applying the patch to 1.14, and then applying the same reformatting to the 1.14 branch.
OK, I tried doing it that way around, but unfortunately I still wound up with a rather large rejects file from applying the patch from 2a827fb; this time it's here: https://github.com/wesnoth/wesnoth/blob ... me.cpp.rej
Wesnoth-related GitHub repos:
General mods collection, SotBEEE, AToTBWaTD, The Earth's Gut, A Little Adventure, FtF
Social media: Twitter: @cooljeanius, Steam: egallager
User avatar
Celtic_Minstrel
Developer
Posts: 1817
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Post by Celtic_Minstrel »

octalot wrote: July 26th, 2021, 8:03 am I echo Soliton's and CelticMinstrel's concerns, and add to them a question "how much do all those extra units slow down the game's startup and cache-creation sequences?". I think this shouldn't be merged to the mainline 1.16 branch.
It might be acceptable if the old unit definitions are loaded only on-demand, though I'm still not a fan of having them sitting around in the data folder, but I guess I could live with it.

I've mentioned a number of concerns on the pull request, #5990. In particular, I think it should make use of loaded-on-demand WML files for most of the actual update logic.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
demario
Posts: 37
Joined: July 3rd, 2019, 1:05 pm

Re: Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Post by demario »

Here is a new packaging of the code to support replaying old saves.
Nothing much changed in the code, so all the status, troubles and statistics should be the same. If not, that's a new bug.

This is an alternative package and it should be applied on a clean BFW1.14 (without other patch from this thread). This package doesn't contain any unit definition and after applying the patch and compilation, you have to head to the add-on server to download the "Support Past Default Eras" MP era to get the unit definitions. As units, factions and eras are installed, beside replay, you can also play new games with old default eras (and people are able to join if they have SPDE installed). The RNG used in new games will be the latest one.

For those trying to understand the conversion process, let me break it down into 3 types of changes:
  • changes in WML syntax, moving WML blocks around, renaming WML attributes (from colour to color, ...).
    This is the typical conversion that was already present in old convert functions. This is only WML block manipulation and with these changes only, we can support back to BFW1.10. It also involves some changes in random numbers stored in the saves.
  • adding new events to cover for changes in C++ engine changes (healthy, feral, ...).
    This is done by adding the events defined in the era into the scenario (replay_start). As the eras are in an add-on, it requires to apply the changes after the user-made eras are loaded (they are not loaded yet when convert_old_saves() is called). It is done by changes in loadgame::load_game() logic. Without these changes, there is no way to support 1.8 saves
  • adding missing leaders or accessing unit types to apply WML changes (based on traits, race, ...).
    The user-made unit definitions is not loaded when calling convert_old_saves(). The code in loadgame::load_game() must be changed further to load unit definitions before the conversion is done. Without these changes, there is no way to support 1.6 saves and earlier.
So the earlier you want to expand, the more complex the code.
egallager wrote: July 26th, 2021, 5:32 am I tried applying the patch to master, but it creates a rather large rejects file that I'm not sure how to wiggle back into the source file: https://github.com/cooljeanius/wesnoth/ ... me.cpp.rej
I highlighted several times that this patch is to be applied on BFW1.14 code (not master/BFW1.16). Applying it to BFW1.15 and beyond requires further changes. It is up to you to decide to make these changes, but I think you better think about your use-case. Any scenario with complex WML/lua (what MP 1v1 is not) will be quite hard to support. This patch is only about replay, not loading so it is unlikely to help the transition to a new version for people engaged in long campaigns. Incidentally I see no rush to assess the future of this patch in mainline, I would have just expected it to mature a bit and get some feedback.
Remember: it is crashing wesnoth sometimes :mrgreen:
Attachments
BFW1.14.load_1.4_replay_backward_support(with SPDE).diff.gz
Apply over clean BFW1.14 for 1.12-1.4 replays, patch -p2, build with cmake, download SPDE add-on
(17.61 KiB) Downloaded 6 times
"simply put, it's an old game"T — Cackfiend
User avatar
egallager
Posts: 165
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: Adding support to replay old saves (1.4-1.12 1v1) in BFW1.14

Post by egallager »

demario wrote: July 28th, 2021, 12:53 am
egallager wrote: July 26th, 2021, 5:32 am I tried applying the patch to master, but it creates a rather large rejects file that I'm not sure how to wiggle back into the source file: https://github.com/cooljeanius/wesnoth/ ... me.cpp.rej
I highlighted several times that this patch is to be applied on BFW1.14 code (not master/BFW1.16).
I mean, yes, I realized that, but I still wanted to see if I could get it to work anyways. And I did also try applying it against 1.14, too, in a separate branch, but the 1.14 branch isn't receiving any further major feature updates, so new pull requests opened against it won't be accepted, nor is the one I opened meant to be.
Wesnoth-related GitHub repos:
General mods collection, SotBEEE, AToTBWaTD, The Earth's Gut, A Little Adventure, FtF
Social media: Twitter: @cooljeanius, Steam: egallager
Post Reply