"Real" time patch (TTD 1.9.3 + 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: 87
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: 87
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: 87
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: 87
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

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

Vanilla patch update for 1.9.3

Post by SciFurz » 25 Nov 2019 20:09

Updated the last code changes to version 1.9.3 when I got back to working on it.

The patch seems savegame compatible now and fully functional, apart from one bug.
Using ctrl to link stations crashes the game because the struct with the data is lost at the OnClick function call. I haven't found the cause yet and a test change in calling the station function prevented placing road stations all together. Other stations can still be placed so I think I'll begin with unifying station placement code as much as possible to find out where the differences lie.
Workaround is to temporarily place rail station tiles to where the linked station is to be placed, then removing them again.

Haven't found other bugs during my latest test game, so it seems the whole code conversion to CommandContainers is a success. Increasing the number of any objects or flags should be easy now.
Tinkering in the code in between writing mostly naughty stuff.
See https://www.patreon.com/scifurz

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

Intermezzo: Dutch trainset wagons modification

Post by SciFurz » 06 Dec 2019 06:50

Tinkered with the Dutch trainset grf as a little distraction on the side, getting to know a bit more about NML/NFO, and added a new stake wagon because the others are too toy-like for a serious cargo train.
The prototype; 4 axle, 50 t load, maximum speed 120km/h, based of off the 35t stake wagon.
50t_stakewagon-01.jpg
50t_stakewagon-01.jpg (83.38 KiB) Viewed 210 times
The wood train suddenly looks so much better (no, no idea why this image isn't set inline).
50t_stakewagon-02.jpg
(170.2 KiB) Not downloaded yet
Made the graphics fit with direction, matched wheel style with the locomotives. The empty version is complete but I still have to draw the diagonal sprites with cargo.
I might modify the other stake wagons when I'm done with this one since the cargo label for metal needs correction anyway. Adding other cargo sprites like crates is an option.

edit:
Couldn't refrain from trying a few more things and ended up adding two more colour variations to the coil wagon, a crate variation of the large stake wagon, and tweaked the wheels on the Eass and tankers wagons. Also activated the brown version to the random livery of the Eass.

Looking at the last screenshot, I realised a lot more tweaking is needed to fit the wagons correctly to the locomotives. Buffers don't match, length is incorrect, and I wonder if the wagons can be changed without things getting real ugly.

edit 2:
Modified wagon length properties (causing a possible crash warning in OpenTTD but no problems so far), and redid the sideviews while keeping to the original design as much as possible.
modified_wagons_dutch_trainset-old-new.jpg
modified_wagons_dutch_trainset-old-new.jpg (99.19 KiB) Viewed 146 times
Tinkering in the code in between writing mostly naughty stuff.
See https://www.patreon.com/scifurz

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

More bling intermezzo

Post by SciFurz » 08 Dec 2019 16:45

Had a few more ideas last night, and went creative for a while again today.
Made a tiny multi-purpose locomotive which can refit to any cargo, including passengers. It'll come in handy when I'm experimenting. Named it Mier (Ant) because it can do anything, and a network with lots of these crawling around will look like an ant hill.
Tweaked more wagons, added an extra large livestock wagon for 50 cattle, and replaced the second green livery of the Takkis compost wagon with the orangy VAM potgrond livery. There's also a green striped one which I might add later.
Added food and non-food tanker copies of the existing ones, which will prevent refitting between chemical cargo and food cargo, and doubled capacity of the largest one to 50000 liters. Have some ideas for liveries for these, which will likely take some effort to draw.
modified_wagons_dutch_trainset-e.jpg
modified_wagons_dutch_trainset-e.jpg (22.94 KiB) Viewed 103 times
Tinkering in the code in between writing mostly naughty stuff.
See https://www.patreon.com/scifurz

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

Modded trainset grf

Post by SciFurz » 09 Dec 2019 08:09

Made the basic changes that I had in mind for the wagons with the last split of the Takkls VAM wagons between farm supplies and recyclables. While searching for photos of the wagons, I found a few more liveries that fit well into their own cargo category, thus the split. Two of the liveries I added, and even the striped one, which didn't turn out as horrible as I expected.
Made one new livery for a new tanker, which should be obvious as to what cargo it carries.

A preview:
modified_wagons_dutch_trainset-f1.jpg
modified_wagons_dutch_trainset-f1.jpg (210.71 KiB) Viewed 45 times
For the curious, here's the grf;
dutchtrains-2.1.0-mod.tar
(2.99 MiB) Downloaded 6 times
Remember, not all tilesets are completely done, but it should give an idea of what I have in mind. When loading a game that already has the Dutch trainset in use, the warnings can be resolved by replacing the coil, VAM, and Eass wagons, but I noticed sometimes a wagon isn't available in my test game. A new game will show all as it's supposed to.

Unless I see other interesting wagons or need a different version of an existing one, I'll only be finishing the rest of the images later, maybe adding one or two liveries to wagons that have only one to make a long train look more interesting.

Now how come images here are sometimes inline, and sometimes only available as download?
Attachments
modified_wagons_dutch_trainset-f.jpg
(238.37 KiB) Not downloaded yet
Last edited by SciFurz on 09 Dec 2019 08:47, edited 1 time in total.
Tinkering in the code in between writing mostly naughty stuff.
See https://www.patreon.com/scifurz

User avatar
kamnet
Moderator
Moderator
Posts: 6892
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: Modded trainset grf

Post by kamnet » 09 Dec 2019 08:25

SciFurz wrote:
09 Dec 2019 08:09
Now how come images here are sometimes inline, and sometimes only available as download?
Inline images have a maximum with of 800 pixels and a maximum height of 600 pixels. If it is larger than that in either direction then it's not available inline.

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

Re: Modded trainset grf

Post by SciFurz » 09 Dec 2019 08:41

kamnet wrote:
09 Dec 2019 08:25
SciFurz wrote:
09 Dec 2019 08:09
Now how come images here are sometimes inline, and sometimes only available as download?
Inline images have a maximum with of 800 pixels and a maximum height of 600 pixels. If it is larger than that in either direction then it's not available inline.
Ahh, indeed, two were larger. Thanks!
Maybe it was in the previous version, but I thought I had uploaded a larger one before which showed up fine. I'll have to scale as well next time then.
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: No registered users and 6 guests