Realtime 3.1-maybe-beta (12.2 base)

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
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Preview source 3.0v

Post by SciFurz »

Went to work on the roadvehicle code, trying to find my way through it all by the usual splitting of
large functions and refactoring until I found the parts where I could add timetable waiting.
The completely different way it's set up compared to the train code took more time to figure it out.

I noticed in the meantime that every time I split up a large function, the size of the executable would
decrease a little. GCC seems to be able to optimise smaller static functions better.

I also modified the generic data variables for the CommandContainer struct and begun cleaning
up the function using it. One of the effects has been to remove rail track helper functions and have building and
removing rail tracks done directly by the intended executing function.

While refactoring I tried out several more ways to format code for readability, and I think I now have a
general style to work with.
Moved roadveh* files into the vehicle subdirectory, and made a few more chages to several others, including
one that hopefully broke the circular class dependency between Vehicle and Order.
During all this it became obvious all is not well with header file inclusions. I even had to add system or
stdafx.h to files in the core directory.

Well, on to aircraft and ship refactoring. Planes keep circling the same airport now because of the changes
for road vehicles.

src directory to replace in 12.2 source code:
ttd-rt_src-3.0v.zip
(9.08 MiB) Downloaded 82 times
.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Update 3.0x

Post by SciFurz »

All vehicle types handled loading in my test game, so here's the next update (in the first post).

Now that loading and unloading is sorted out, time to kick some depot handling code and
make that work with timetabling.

Added a few category subdirectories and moved more files into those as part of the file structure reorganisation.

Edit:
Making the depot waiting work well and streamlining code there will take some time when there's three-and-a-half
places where depot code is spread.
Some of it looks like the Redundant Department for Redundancy and Repeating Senselessly has been busy.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Preview 3.0y + demo yard usage

Post by SciFurz »

Didn't change much on the functional code except made the jump to next order work again if not stopping
at a waypoint / station / depot.
Depot code is still a mess while I'm figuring out how to streamline it.

I did move more cpp code files into categorised subdirectories. Those are easier to move than the header files,
which need a change in so many different files each time. The more organised look of the source directory is worth
it though, as well as more quickly spotting the files I need.

12.2 src replacement:
ttd-rt_src-3.0y.zip
(9.03 MiB) Downloaded 88 times
.

And a screenshot of a basic railroad yard and orders for a train making use of it to demonstrate one realistic model
option of running the game at a leisurely pace.
A specific departure time can be set for the train to leave the yard (optional on an interval), but I need to fix the
timetable window after the latest changes needed to move events around again.
.
Edit
I just noticed the loading order is a full one, which of course should be a load if available one instead.
.
train_yard-02.png
train_yard-02.png (270.76 KiB) Viewed 2230 times
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Update 3.1a

Post by SciFurz »

Waiting at train depot and at road depot should work, but ships are handled in yet another obscure
and different way. It's not even close to either of the other two and will take even more time to figure out.
At this point I even have doubts about being able to unify depot code between all vehicles.
I don't even want to think of the aircraft code right now. -.-

More cpp files are moved into subdirectories again.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Sidequest done, unlocked more stuff for update 3.1b

Post by SciFurz »

Didn't yet feel like digging into the ship depot handling yesterday, but had a curiousity I wanted
look into.

Enabled all industries from every climate apart from Toyland ones, as well as the cargoes and
vehicles needed, including plastic because it fits. Fiddled a little with what's needed and
produced, and it has become more interesting now that the network has more dependencies.
Vehicles didn't seem to be defined on cargo classes, so I had to add several to the list, but now iron ore
is listed twice with coal and ore trucks. It's as if that's the only one to understands bulk cargo.

There are only extra trains and road vehicles, I haven't added extra cargo options for aircraft (yet?).
I might add a couple of cargoes later if there are some fitting ones to add more dependencies
between these original industries.

Edit: Just noticed acceptance of cargoes wasn't changed because it's not taken from the industry
specs, but instead through separate tile definitions. Yeah, definitely needs more complexity.
Edit 2: And fixed again. Changed the layout of the farms by replacing most silos and hay stack with
pig pens for the livestock farm, and replacing those with either silos or stack on the grain/maize and
wheat farms. Only the pig pens accept grain/maize on top of water for all the farm tiles.

Extra cargoes, vehicles, and farms can be planted anywhere because why not?
.
all_industries.png
all_industries.png (335.33 KiB) Viewed 2136 times
.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Winter time

Post by SciFurz »

Forgot to mention one more thing, default handling of snow line down to height 0 in sub-arctic climate.
Simply fixed up and down one level per month over the year for now, but an algorithm or simple multiplication
by a factor added to settings could be added.

A lovely winter landscape.
.
landscape-01.png
landscape-01.png (285.55 KiB) Viewed 2104 times
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Source preview

Post by SciFurz »

Spending time lately on this again, and because I'm pretty much writing the vehicle loop from scratch to add the features I want, it takes a while.
Here's the current (and messy) source as a preview.

Things I did so far:

- reorganised most files into subdirectories
- created a new vehicle handler loop (see vehicle/vehicle_loop.cpp)
- removed more intermediate classes for the animated sse2 blitter, removing the worst bottleneck in graphics
- refactored bits here and there to remove complexity and remove legacy savegame code
ttd-rt_src-3.1h.zip
(9.1 MiB) Downloaded 62 times
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
Revenge_of_KioTheDev
Engineer
Engineer
Posts: 59
Joined: 14 Jun 2022 05:54

Re: Source preview

Post by Revenge_of_KioTheDev »

SciFurz wrote: 14 Apr 2023 22:32 Spending time lately on this again, and because I'm pretty much writing the vehicle loop from scratch to add the features I want, it takes a while.
Here's the current (and messy) source as a preview.

Things I did so far:

- reorganised most files into subdirectories
- created a new vehicle handler loop (see vehicle/vehicle_loop.cpp)
- removed more intermediate classes for the animated sse2 blitter, removing the worst bottleneck in graphics
- refactored bits here and there to remove complexity and remove legacy savegame code

ttd-rt_src-3.1h.zip
will be possible to run game at 1 game month = 2 real hours with this when completed?
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 6 guests