Another Daylength patch

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
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Another Daylength patch

Post by planetmaker »

Can we please avoid double and tripple posts? You can edit your posts after creation. And when replying your can quote several postings easily by pressing 'quote' in the appropriate posts (by scrolling down further the list of postings of the thread when making your reply).
gabrielbyrnei
Engineer
Engineer
Posts: 17
Joined: 11 Oct 2013 23:20

Re: Another Daylength patch

Post by gabrielbyrnei »

planetmaker wrote:Can we please avoid double and tripple posts? You can edit your posts after creation. And when replying your can quote several postings easily by pressing 'quote' in the appropriate posts (by scrolling down further the list of postings of the thread when making your reply).
Sorry, got used to another forum where you had a very limited time to edit your posts.

:)


I dont know if this is the right place, but has anyone achieved patching the source with the automated timetables and this daylength patch? Those are the two things im really wishing i had before i start a new map :)

http://www.tt-forums.net/viewtopic.php?t=46391 (automated timetable)

Thanks!
User avatar
Pyoro
Tycoon
Tycoon
Posts: 2558
Joined: 17 Oct 2008 12:17
Location: Virgo Supercluster

Re: Another Daylength patch

Post by Pyoro »

I've ran into a bit of trouble getting the patch to work with current trunk:

Code: Select all

static const SaveLoadGlobVarList _date_desc[] = {
	  SLEG_CONDVAR(_date,                   SLE_FILE_U16 | SLE_VAR_I32,  0,  30),
	  SLEG_CONDVAR(_date,                   SLE_INT32,                  31, SL_MAX_VERSION),
	      SLEG_VAR(_date_fract,             SLE_UINT16),
	      SLEG_VAR(_tick_counter,           SLE_UINT16),
	  SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day
now is

Code: Select all

static const SaveLoad _date_desc[] = {
	SLEG_VAR(_date,                   SLE_FILE_U16 | SLE_VAR_I32,  , ,   0,  30),
	SLEG_VAR(_date,                   SLE_INT32,                  0, ,  31,    ),
	SLEG_VAR(_date_fract,             SLE_UINT16),
	SLEG_VAR(_tick_counter,           SLE_UINT16),
	SLE_NULL(2, , , 0, 156), // _vehicle_id_ctr_day
which conflicts with the patch adding this line:

Code: Select all

SLEG_CONDVAR(_date,                   SLE_INT32,                  31, SL_MAX_VERSION),
 	    SLEG_VAR(_date_fract,             SLE_UINT16),
 	    SLEG_VAR(_tick_counter,           SLE_UINT16),
+       SLEG_CONDVAR(_tick_skip_counter,      SLE_UINT8,                 200, SL_MAX_VERSION),
 	SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day
 	SLEG_CONDVAR(_age_cargo_skip_counter, SLE_UINT8,                   0, 161),
 	SLE_CONDNULL(1, 0, 45),
Apparently CONDVARS aren't wanted anymore ...

Unfortunately I have absolute zero programming knowledge. Changing condvar to var compiles the game and it actually seems to be running fine, but, surprise surprise, newly made saves are corrupted/can't be loaded. Anything I can do about that? ^^;

€: to be more precise it crashes for saves with daylength set to not 1, at date.cpp "assert(fract < DAY_TICKS);".
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Another Daylength patch

Post by Eddi »

you probably need to replace the DAY_TICKS in this assert, to consider the daylength of the new savegame. and this is probably unrelated to the above conflict.


the difference between "VAR" and "CONDVAR" was that "CONDVAR" had a from-to range for the valid savegame versions. this difference was not very useful since all new things need CONDVAR anyway, so the two things were combined. so all "VAR" now have this range, with missing values filled with default. (0 and max)
User avatar
Pyoro
Tycoon
Tycoon
Posts: 2558
Joined: 17 Oct 2008 12:17
Location: Virgo Supercluster

Re: Another Daylength patch

Post by Pyoro »

Mh. I thought about that, but none of the patch revs ever do anything in date.cpp, and also neither spring patch pack nor hard patch pack (always a good place to check for updated patches but currently both are too old ^^;). I tried changing it to DAY_TICKS_DAY_LENGTH (which the patch uses at some other point) but that makes it crash right at the start ;) It's also I think a file virtually unchanged since quitealotofrevs.

That's basically why my mental connection went "game runs fine, but loading saves doesn't work" -> probably something to do with misc_sl, which is the only saveload thing that's changed. But I guess with your explanation that seems unlikely as well. Hm.

Oh well. There's only so far you can get with a bit of trial & error ^^; Thanks for trying to help though :)
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Another Daylength patch

Post by Eddi »

the startup crash may be because order of setting initalization has changed, so at certain points there may be places where daylength has a value of 0. might need to guard against that.

since it's an assert, you can also just leave it out. it has no effect on how the program works, it's just a reminder to developers about preconditions this part of the code assumes
User avatar
Pyoro
Tycoon
Tycoon
Posts: 2558
Joined: 17 Oct 2008 12:17
Location: Virgo Supercluster

Re: Another Daylength patch

Post by Pyoro »

That indeed did the trick. Thanks again, seems to work fine now :)
gabrielbyrnei
Engineer
Engineer
Posts: 17
Joined: 11 Oct 2013 23:20

Re: Another Daylength patch

Post by gabrielbyrnei »

Im sorry, but what did you do to fix the savegame crashes? Im having the same issue, and total noob!

Thanks
User avatar
Pyoro
Tycoon
Tycoon
Posts: 2558
Joined: 17 Oct 2008 12:17
Location: Virgo Supercluster

Re: Another Daylength patch

Post by Pyoro »

In date.cpp line 38 I commented out the assertion:
// assert(fract < DAY_TICKS);
...might as well just delete that line.
gabrielbyrnei
Engineer
Engineer
Posts: 17
Joined: 11 Oct 2013 23:20

Re: Another Daylength patch

Post by gabrielbyrnei »

Ok, deleted the line but still the issue.

I started a new test game, saved using 8 daylength, closed openttd, launched again, loaded and crash :(

Code: Select all

Error: Assertion failed at line 38 of /home/gabriel/openttd/src/date.cpp: fract < DAY_TICKS
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Another Daylength patch

Post by Alberth »

Deleting a line in the source code doesn't change the binary program, you'll have to compile the source code again.

Edit: Anyway, "assert" usually means that the condition should always hold, or something very bad will happen.
Deleting the assert line will of course remove the check and the crash, but one should normally also make sure that nothing bad will happen when you run into the territory of values where the check would have failed.
(in other words, you remove an assert only after verifying that doing so will not cause any problem)
gabrielbyrnei
Engineer
Engineer
Posts: 17
Joined: 11 Oct 2013 23:20

Re: Another Daylength patch

Post by gabrielbyrnei »

Oh, little mistake by me then hehe.

So ill now remove the line before compiling. Will also do my best on checking if it causes problems.

Thanks for helping a new guy !


Edit: Worked like a charm now!
Transnova
Engineer
Engineer
Posts: 1
Joined: 03 May 2014 05:59

Re: Another Daylength patch

Post by Transnova »

Uggggh. This is so Confusing.

I just want to play with slower days.

I only play with the FIRS Industry Set and the FISH Ship set.

I downloaded the executable from page 14 on this thread.

Opened it up and downloaded FIRS and the FISH set and the OpenSFX and OpenMSX from the available online content.

Now how do I choose the daylength?

*edit*

Eureka I found it.

Now for my next question.

Instead of using that e xecutable. Is there a simple guide on how to get the current official Version to use this "True" Daylength Patch? It's impossible trying to sift through all the info on the threads, takes far too much time. I'm sure theres like 10 steps to getting the patch to work with the current build.... Just need the steps and I can do it.... Please :D
User avatar
kamnet
Moderator
Moderator
Posts: 8548
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: Another Daylength patch

Post by kamnet »

No, there's no simple steps to applying a patch to a current version of OpenTTD. You will need some familiarity with programming and modifying source files. If you're lucky you may be able to just apply the patch without having to make modifications, but considering that OpenTTD is a constantly-changing project, it is likely going to be trial-and-error. Apply the patch, compile, wait for it to fail, take a note of the errors and fix them. With any luck you'll finally end up with a patch that is updated and works. Feel free to share the source code of the patch here, and if you need help with specific issues feel free to ask.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Another Daylength patch

Post by Eddi »

well, there are 3 "simple" steps.
  1. Install a compiling environment for your operating system as per http://wiki.openttd.org/Compiling and compile the unmodified version
  2. Compile a modified version of the revision the patch was originally written for
  3. update the patch in slower or faster steps.
User avatar
pavel1269
Route Supervisor
Route Supervisor
Posts: 473
Joined: 03 Dec 2006 13:22
Location: Czech Republic
Contact:

Re: Another Daylength patch

Post by pavel1269 »

Updated to current trunk. Problem only in save game version and game loop changed a bit.

edit: I noticed, that with this day length, I break the timetables. Updated patch included.
Attachments
true_day_length_r26686.patch
(8.01 KiB) Downloaded 531 times
Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 260
Joined: 09 Apr 2014 11:10

Re: Another Daylength patch

Post by Eddy Arfik »

Thankyou for this patch, it has made the game playable again, I had sometimes over 100 trucks for each factory and 12 track wide train lines in places, and it still was not enough to move everything, on a large map with 3 players the lag soon causes desyncs. Now I can move everything with a good number of vehicles and realistic layout because they can make more trips per month.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Another Daylength patch

Post by Eddi »

lag never ever causes desync.
Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 260
Joined: 09 Apr 2014 11:10

Re: Another Daylength patch

Post by Eddy Arfik »

server lags, stops sending data to clients, client connection times out, I don't know what else to call that other than desync, but that's besides the point. All I was trying to say was using this patch allows me to move the same amount of cargo with less vehicles, increasing my enjoyment of the game.
Eddi
Tycoon
Tycoon
Posts: 8258
Joined: 17 Jan 2007 00:14

Re: Another Daylength patch

Post by Eddi »

... calling a timeout a desync is like calling a derailment a plane crash....
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 13 guests