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

Post Reply
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Realtime 3.1-maybe-beta (12.2 base)

Post by SciFurz »

This is a version of OpenTTD in which the game time can be slowed down to practically real time.
Unlike previous day lenght patches, this one does not stretch the day but has the core rewritten to enable it to run at any speed desired.

The main change for the original patch goal has been to switch all neccessary command functions to use the already existing command container.
Doing this basically eliminates all limits of the game, like the different amounts of roads, rail, cargo types that could be used.

Status: Alpha migration to CommandContainer done.
What remains is clean-up like removing commented-out original code, replacing the used command containers with smaller, individual structs,
and cleaning up and maybe consolidating the three core command functions. Also, network testing.

Work in progress:
Improved scheduling for vehicles: Departure and wait times can be set for vehicles to stay at stations or depots. Interval time can be set for
the complete route to automatically update departure times. Arrival times can be set but have no function right now.
Working on the display of relevant times in time table window.
Enabling larger maps: Sizes larger than 16k x 16k can be set, although there is no check on total size of XxY, so use with caution.
Creating a map in scenario editor first might be needed to begin a new game.
Loans are automatically paid off at the end of the day when the balance is more than 1000 in the plus. Will make it a optional setting later.

Side effects:
Changes made while working on the major parts: Refactoring code at various places, Added a tile cache for read-mostly tile data that had to be
calculated every time. Exchanged the CFollowTrack template for more streamlined versions for rail, road, and water to improve performance.
Splitting groups of related functions in large source files off into their own .cpp, _func.h, and _type.h files for clarity. This also exposes the
mess of included header files.
Splitting large functions into smaller ones, sometimes reducing executable size by a little.
Removed implicit order usage.
Skipped a few blitter inherited classes to improve performance for sse2 (and sse4?).
Adding category subdirectories and moving relevant source files in those to lessen the amount of files in src root.
Unlocked all industries, cargoes, and vehicles from every climate apart from Toyland ones (but including plastic).

Possible future features:
Arrival and departure board for stations and the like.
Rewriting and integrating the shunting patch. Think working cargo yards where consists are split up and re-assembled for the next part of the route.
Enable the same possibility to carry different cargos for articulated road vehicles, just like trains.
Tile locking and change status to maybe enable running the landscape part in a seperate thread, and only iterating over tiles that have actually changed.
In that train of thought I'm wondering about using a database backend like SQLite.
Migration of windowing system to wxWidgets. I like to see multiple viewports and management windows without cluttering one main window.
Also being able to switch through them like regular programs.
Gradual build of road/rail as in Simcity.
Demand based economy instead of production based. End customers place orders at producers, who place orders at suppliers, etc., and cargopackets
are created when the required supplies are delivered. Unfulfilled orders will be removed after a set time. Not transporting in time? No monies.
Limit vehicles by amount of coal mined (steam locomotives) and delivered and or amount of power stations (electric locomotives),
as well as oil and refineries (road vehicles)?
Improve YAPF to take waypoints and line ends into account for routes, so it will for instance use a siding to reverse direction into a depot.
Diagonal roads?

---

Complete src directory to replace the 12.2 src directory of the official release:
ttd-rt_src-3.1b.zip
(9.03 MiB) Downloaded 110 times
.
Linux package:
openttd-12.2-linux-generic-amd64.tar.xz
(5.47 MiB) Downloaded 83 times
.
No Windows build because it seems cross compiling no longer works.
Last edited by SciFurz on 30 Jul 2022 08:46, edited 122 times in total.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
SimYouLater
Chief Executive
Chief Executive
Posts: 675
Joined: 03 Apr 2016 20:19

Re: "Real" time patch

Post by SimYouLater »

SciFurz wrote:...
JGR wrote:...
Just getting JGR's attention. This would be nice to add to your patchpack, but no rush.
Licenses for my work...
You automatically have my permission to re-license graphics or code by me if needed for use in any project that is not GPL v2, on the condition that if you release any derivatives of my graphics they're automatically considered as ALSO GPL v2 (code may remain unreleased, but please do provide it) and carry this provision in GPL v2 uses.
Please ask someone in-the-know to be sure that the graphics are done by me. Especially TTD-Scale, long story.
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

updates

Post by SciFurz »

New versions of patched posted.

In these the station/cargo ratings should get a daily update.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1729
Joined: 30 Mar 2005 09:43

Re: "Real" time patch

Post by peter1138 »

SciFurz wrote:Currently default game time is one minute per two real seconds
That does not seem right. A game DAY is 74 game ticks, which is about 2.25 real seconds.
He's like, some kind of OpenTTD developer.
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Re: "Real" time patch

Post by SciFurz »

peter1138 wrote:
SciFurz wrote:Currently default game time is one minute per two real seconds
That does not seem right. A game DAY is 74 game ticks, which is about 2.25 real seconds.
It is default for the patch, which is 1167.567 times slower than the TTD default.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1729
Joined: 30 Mar 2005 09:43

Re: "Real" time patch

Post by peter1138 »

SciFurz wrote:
peter1138 wrote:
SciFurz wrote:Currently default game time is one minute per two real seconds
That does not seem right. A game DAY is 74 game ticks, which is about 2.25 real seconds.
It is default for the patch, which is 1167.567 times slower than the TTD default.
Ah, "currently" ... This patch seems very intrusive though. It's there a way to disable it?
He's like, some kind of OpenTTD developer.
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Re:

Post by SciFurz »

[/quote]Ah, "currently" ... This patch seems very intrusive though. It's there a way to disable it?[/quote]

Don't patch and compile it. ;-)
DAY_TICKS is a constant and there's no changing it dynamically. That's why I'm seeing if I can add a setting to modify it like tthe day length patch, only keeping the factor compatible with real time (no fractional minutes).

And obviously it's very intrusive, anything previously handled by byte size and overflowing them needs to be rewritten to the actual amount of ticks.
It's a wonder I can run the game and load and save without a crash or losing anything so far. :-p
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
JGR
Tycoon
Tycoon
Posts: 2557
Joined: 08 Aug 2005 13:46
Location: Ipswich

Re: "Real" time patch

Post by JGR »

SimYouLater wrote:
SciFurz wrote:...
JGR wrote:...
Just getting JGR's attention. This would be nice to add to your patchpack, but no rush.
I'm not sure I understand what the motivation/benefit of this is.
Changing the day length this drastically is likely to have a lot of side-effects on other parts of the game.
I'm not making any commitments about merging or not, however not being able to to turn it off would be a major blocker.
Ex TTDPatch Coder
Patch Pack, Github
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5656
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: "Real" time patch

Post by andythenorth »

SimYouLater wrote:Just getting JGR's attention. This would be nice to add to your patchpack, but no rush.
Why quote people into the thread like this? It's just rude. Stop with this crap.
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Re: "Real" time patch

Post by SciFurz »

JGR wrote:I'm not sure I understand what the motivation/benefit of this is.
It's for those that like to run the game as a model railroad and/or prefer to be able to play and ponder the next step without the stress of constantly needing to pay attention to things one after the other. It also creates more virtual space for better looking railroade stations and junctions without either side ending up touching the next town. :-)
It also makes combining road and rail transport more effective in my opinion. So far it's been a lot more fun and realistic managing a transport network.
JGR wrote:Changing the day length this drastically is likely to have a lot of side-effects on other parts of the game.
I'm not making any commitments about merging or not, however not being able to to turn it off would be a major blocker.
Actually, I was surprised at how well the game ran after the simple step of increasing day ticks, and certainly your version compared to the vanilla OpenTTD. ;-)
This patch is way too alpha to commit to a release version, for me one requirement is the option to select a speed up, and maybe even a slow down to run it at actual real time. Perhaps even a switch to freeze time and have the game looping the same day?
Anyway, the first step was to see if I could get it running with ticks as seconds, after this I can look at a good method to select a speed for those that like to blast through the game as usual.
They might miss out on taking the time to watch super long trains driving across great plains or parked in numbers on a huge industrial yard though. ;-) The shunting ability would be awesome then.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
SimYouLater
Chief Executive
Chief Executive
Posts: 675
Joined: 03 Apr 2016 20:19

Re: "Real" time patch

Post by SimYouLater »

andythenorth wrote:
SimYouLater wrote:Just getting JGR's attention. This would be nice to add to your patchpack, but no rush.
Why quote people into the thread like this? It's just rude. Stop with this crap.
You don't have to be a jerk about it. I was just trying to point JGR to it, it's entirely up to him; He said he can't decide yet whether it will be included, so I won't bother him further about this patch because that would be rude.
Licenses for my work...
You automatically have my permission to re-license graphics or code by me if needed for use in any project that is not GPL v2, on the condition that if you release any derivatives of my graphics they're automatically considered as ALSO GPL v2 (code may remain unreleased, but please do provide it) and carry this provision in GPL v2 uses.
Please ask someone in-the-know to be sure that the graphics are done by me. Especially TTD-Scale, long story.
Eddi
Tycoon
Tycoon
Posts: 8257
Joined: 17 Jan 2007 00:14

Re: "Real" time patch

Post by Eddi »

SciFurz wrote:
JGR wrote:Changing the day length this drastically is likely to have a lot of side-effects on other parts of the game.
I'm not making any commitments about merging or not, however not being able to to turn it off would be a major blocker.
Actually, I was surprised at how well the game ran after the simple step of increasing day ticks, and certainly your version compared to the vanilla OpenTTD. ;-)
several attempts at daylength patches have started with this seemingly simple change, but once you dig deeper, it usually falls apart quickly, as some code paths have not been fitted with handling lager numbers, or people having different opinions over which parts of the game should be slowed down and which parts shouldn't.
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Re: "Real" time patch

Post by SciFurz »

Eddi wrote: several attempts at daylength patches have started with this seemingly simple change, but once you dig deeper, it usually falls apart quickly, as some code paths have not been fitted with handling lager numbers, or people having different opinions over which parts of the game should be slowed down and which parts shouldn't.
I did have to increase several variables to int32 indeed. No showstopper for me and the game hasn't crashed on me yet. The only drawback is old savegames aren't compatible with the current code but that's not an issue for me either.
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 TTD patch

Post by SciFurz »

Updated the TTD patch to version 0.4.

Included the option setting day length factor under environment to slow down the game speed.
Set to 1 day ticks are 60, higher multiplies it by the factor (goes up to a maximum of 20000(!)). Set it to 1440 to get 86400 ticks in a game day.

Town cargo production is scaled with it, so no need to throw a lot of busses at passengers, instead slow down time so fewer busses can pick up all in one day.
Attachments
beta, 1981-07-08.png
(700 KiB) Not downloaded yet
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
eekee
Engineer
Engineer
Posts: 96
Joined: 23 Jun 2005 19:45
Location: quantum superposition

Re: "Real" time patch

Post by eekee »

SciFurz wrote:It's for those that like to run the game as a model railroad and/or prefer to be able to play and ponder the next step without the stress of constantly needing to pay attention to things one after the other.
This is exactly what I need! As much as I like OpenTTD, I keep thinking I really ought to replace it with another game because I keep playing too hard and getting stressed.
Extreme network builder. screenshot thread
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Re: "Real" time patch

Post by SciFurz »

eekee wrote: This is exactly what I need! As much as I like OpenTTD, I keep thinking I really ought to replace it with another game because I keep playing too hard and getting stressed.
That's why I began tinkering in the code to get the option to run the game at a scale I want to use. I don't want a train to take hours or even days to go from one end of the station to the next. :-p
Can't wait to build a complete railroad yard with long trains waiting on schedule at a decent scale to cities.. ;-)

Currently I can slow down the game at a chosen factor, but at a factor above 109 passengers keep gwtting a destination of any station at a newly built one. Working back through the code to find out where probably linkgraph jobs hit a limit.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
eekee
Engineer
Engineer
Posts: 96
Joined: 23 Jun 2005 19:45
Location: quantum superposition

Re: "Real" time patch

Post by eekee »

Um... That's normal for newly-built stations.
Extreme network builder. screenshot thread
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Re: "Real" time patch

Post by SciFurz »

eekee wrote:Um... That's normal for newly-built stations.
Not after a bus has picked up passengers and dropped them off. Then a direct link has been established and subsequent passengers from that station have a destination.
"Any station" is for discovering a station accepting that cargo type.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
User avatar
eekee
Engineer
Engineer
Posts: 96
Joined: 23 Jun 2005 19:45
Location: quantum superposition

Re: "Real" time patch

Post by eekee »

I just tested in plain 1.9.0 with two quite closely-spaced bus stops and a bus which didn't have enough capacity to pick up all the passengers on its second visit. In this case, passengers "via any station" continued to increase after the second visit.

I don't think the small bus capacity is necessary to trigger this. I think it's because Cargodist doesn't recalculate the link graph straight away. It has an option for how long to take; default 16 days. What that 16 days means with your patch, I don't know. :)
Extreme network builder. screenshot thread
User avatar
SciFurz
Traffic Manager
Traffic Manager
Posts: 154
Joined: 13 Oct 2018 16:33
Contact:

Re: "Real" time patch

Post by SciFurz »

eekee wrote:I just tested in plain 1.9.0 with two quite closely-spaced bus stops and a bus which didn't have enough capacity to pick up all the passengers on its second visit. In this case, passengers "via any station" continued to increase after the second visit.

I don't think the small bus capacity is necessary to trigger this. I think it's because Cargodist doesn't recalculate the link graph straight away. It has an option for how long to take; default 16 days. What that 16 days means with your patch, I don't know. :)
It's not the number of days for the recalculation of the link graph, or the interval. I'm currently trying to figure out why cargo only gets a destination with a day length factor of 1038 or lower (on 60 day ticks in my current modified code). It seems the calculation of links hits an unintentional timeout when there's actually more than enough time in a day. Rather a reverse problem of time. :-/
The term days for the recalculation will become irrelevant anyway since it won't be days but the time unit DAY_TICKS.
Tinkering in the code in between writing mostly naughty stuff.
See http://scifurz.wordpress.com/
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 13 guests