"Real" time patch (TTD 1.9.2 + JGR 0.31.2)

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
SciFurz
Engineer
Engineer
Posts: 78
Joined: 13 Oct 2018 16:33
Contact:

working code update

Post by SciFurz » 24 Aug 2019 16:44

Updated the patch file with the current code I'm running on, the last replacement round had an unexpected efficient copy and paste process.

The major change is the (nearly) complete replacement of the Docommand variable strings (tile, p1, p2, flags, CMD_xx) to the already available CommandContainer struct, which I have expanded to include variables used in all the DoCommand functions, and increased p1 and p2 to range from p1 to p12 (the highest count of bitstuffed parameters I've seen so far at a signal function).
Only a few p1 and p2 parameters have been changed in timetable functions, the rest are still the original bitstuffed ones. I'll only modify those that I need to for the realtime implementation for now, or for the extra features I add.
Tinkering in the code in between writing mostly naughty stuff.
See https://www.patreon.com/scifurz

User avatar
SciFurz
Engineer
Engineer
Posts: 78
Joined: 13 Oct 2018 16:33
Contact:

Patch for TTD 1.9.2 uploded

Post by SciFurz » 26 Aug 2019 22:57

Uploaded the patch for the 1.9.2 branch.

Major change is I switched function calls of DoCommand so that the call with variables gets translated to the CommandContainer, and the main function is being supplied that one instead of the other way around. This way I won't have to replace all function calls in the code while still getting the benefit of dynamic way to increase parameters when they're needed. Wish I had thought of that before I replaced all calls in the JGR branch, but then I'd want to replace those anyway in the end. There's also a good chance I'll simply start with clean code again and manually modify it from the diff file like I did before to sort of clean up the cruft that has been building up.

The patch looked savegame compatible when I only patched the saveload files and the variables, but after patching the rest of the code the intro game no longer loaded. Threw in some debug lines but so far all I can see is something's not matching up during the loading of the settings chunk. I can't tell which setting triggers it until I find out where exactly the sequence of loading settings is done (doesn't seem to follow the sequence of arrays in the file) and if and where I can squeeze in a line to check per setting. Otherwise maybe I'll try splitting the whole chunk in smaller pieces to narrow the search.
Tinkering in the code in between writing mostly naughty stuff.
See https://www.patreon.com/scifurz

User avatar
SciFurz
Engineer
Engineer
Posts: 78
Joined: 13 Oct 2018 16:33
Contact:

Slowly getting there for TTD 1.9.2

Post by SciFurz » 30 Aug 2019 01:22

Figured out a way to change the command code to use the CommandContainer at its core without (relatively) major changes.
The DoCommand functions are switched around and an extra method added to run Cmd functions with either variables or the container. Existing functions wont have to be modified unless there's a need for extra variables or refactoring to make the code more readable. An example of that is in the timetable functions where 64 bit time is implemented and a few processes have been simplified for clarity (removed all bit stuffed elements).

I'm going to use the same method for the next JGR patch, which was the experimental basis for the nice method now used in the vanilla patch.

As an extra feature, enabled timetable arrival and departure times permanently. Why not display them when the order times are filled in anyway?

With this it's slowly becoming bug hunting time, especially to find out why loading settings from older games goes tits up.
Tinkering in the code in between writing mostly naughty stuff.
See https://www.patreon.com/scifurz

User avatar
SciFurz
Engineer
Engineer
Posts: 78
Joined: 13 Oct 2018 16:33
Contact:

Savegame compatible (TTD patch))

Post by SciFurz » 31 Aug 2019 13:17

I had completely overlooked version setting for the configuration file variables, that's where the loading of older game snagged.
So, the vanilla TTD patch is now savegame compatible.
Tinkering in the code in between writing mostly naughty stuff.
See https://www.patreon.com/scifurz

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Walter Novotny and 2 guests