[Patch] Daylength, Cargodist with sprinkles

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

Eddi
Tycoon
Tycoon
Posts: 7414
Joined: 17 Jan 2007 00:14

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Eddi » 21 May 2011 12:30

i took the liberty to update the town cargo patch to trunk and yacd
Attachments
town-cargo-factor-02-noslv-trunk.patch
(5.58 KiB) Downloaded 133 times
town-cargo-factor-02-noslv-yacd.patch
(5.76 KiB) Downloaded 111 times
daily-autosave-01-trunk.patch
(3.9 KiB) Downloaded 106 times
Last edited by Eddi on 21 May 2011 15:34, edited 2 times in total.
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2656
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [Patch] Daylength, Cargodist with sprinkles

Post by ChillCore » 21 May 2011 14:33

Nice Eddi, with the CargoD*st patches (maybe YACD too) that patch is very usefull.

Unfortunately I have a bit to much on my plate already to update it myself at the moment but if someone is looking to update the daylength part of the sprinkles ... I have adjusted a few more places in my patchpack that needed tweaking also, I'd be happy to point them out.

IIRC the changes are:
- hs->minimum life (town_cmd.cpp) multiplied by daylength factor because town growth and shrinkage is unbalanced.
- t->time_untill_rebuild (town.h) multiplied by daylength factor for the same reason as above.
- t->exlusive_counter (town_cmd.cpp) multiplied by daylength factor because a year is a year.
- Vehicle profit (economy.cpp) devided by daylength factor prevents skyrocketing of income with higher daylength factors. (still needs some adjustments -> fractional income for profits below 1)

Some of these values need also their defenition changed to prevent overflowing. (eg. byte minimum_life -> uint16 minimum_life in house.h)
Others require additional changes in the savegamecode. (eg. the exclusive_counter)

I will post more details and check if I forgot to mention something if someone shows interest in continuing to develop this version of the daylength patch. ;)


Edit:
Almost forgot ...
- In CargoDist I adjusted the linkgraph recalculation to use the ORIG_DAY_TICKS. (ignoring the daylength factor.)
- I do not see or understand why the daylength factor needs to be saved globally, most likely I will change the savegamecode to SDT_VAR instead of using SDTG_VAR and disable changing it in network games ... (not yet done as I think it will break the savegamecompatibiliyty I have been keeping for a while.)
Last edited by ChillCore on 21 May 2011 15:40, edited 1 time in total.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

Eddi
Tycoon
Tycoon
Posts: 7414
Joined: 17 Jan 2007 00:14

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Eddi » 21 May 2011 15:32

thanks for these hints, i'll take a look at them. in the mean time, my attempt at updating the daylength patch (without those changes mentioned above) (note that they don't apply cleanly to yacd, because it has not been updated to trunk yet, and last trunk revision (r22482) is relevant to this patch)

autosave patch also updated, and attached in my previous post above
Attachments
variable-daylength-01-noslv-trunk.patch
(3.38 KiB) Downloaded 228 times
variable-daylength-02-towngrowthfreq-trunk.patch
(783 Bytes) Downloaded 161 times
variable-daylength-03-autofill-roundoff-trunk.patch
(632 Bytes) Downloaded 148 times
You might not exactly be interested in Ferion, but if you are, have fun :)

Eddi
Tycoon
Tycoon
Posts: 7414
Joined: 17 Jan 2007 00:14

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Eddi » 21 May 2011 15:43

ChillCore wrote:- I do not see or understand why the daylength factor needs to be saved globally, most likely I will change the savegamecode to SDT_VAR instead of using SDTG_VAR and disable changing it in network games ... (not yet done as I think it will break the savegamecompatibiliyty I have been keeping for a while.)
don't know either, i am just updating as closely to the original as possible at this point. might be because the settings struct is not necessarily available everywhere where DAY_TICKS is used. savegame compatibility should not be affected as long as the same position in the savegame structure is kept.
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2656
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [Patch] Daylength, Cargodist with sprinkles

Post by ChillCore » 21 May 2011 15:53

Hehe, edited my post without noticing you posted ...

If you need help finding things, just give me a yell, I'd be happy to help. ;)

Edit:
Eddi wrote:
ChillCore wrote: - I do not see or understand why the daylength factor needs to be saved globally, most likely I will change the savegamecode to SDT_VAR instead of using SDTG_VAR and disable changing it in network games ... (not yet done as I think it will break the savegamecompatibiliyty I have been keeping for a while.)
don't know either, i am just updating as closely to the original as possible at this point. might be because the settings struct is not necessarily available everywhere where DAY_TICKS is used. savegame compatibility should not be affected as long as the same position in the savegame structure is kept.
I know there sometimes is a problem in my patchpack when changing the daylength factor ingame, saving with the modified value, and loading the game again ...
It could be because of me making a mistake while trying to maintain backwards compatibilty ... ¿or because of the value being saved globally in the savegame.? (-> needs testing after I changed it.)

I tried changing it before and the code complained because of not finding "daylength_factor", IIRC, it has been a while ...
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

Eddi
Tycoon
Tycoon
Posts: 7414
Joined: 17 Jan 2007 00:14

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Eddi » 21 May 2011 16:04

ChillCore wrote:I know there sometimes is a problem in my patchpack when changing the daylength factor ingame, saving with the modified value, and loading the game again ...
it is very unlikely that this is due to the saveload code from the daylength patch itself. it might be because some counters somewhere else get out of range. but using SDT_VAR or SDTG_VAR doesn't change the savegame structure at all, only the way the code handles the data. this change wouldn't even need a savegame bump.
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2656
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [Patch] Daylength, Cargodist with sprinkles

Post by ChillCore » 22 May 2011 01:19

Eddi wrote:
ChillCore wrote: I know there sometimes is a problem in my patchpack when changing the daylength factor ingame, saving with the modified value, and loading the game again ...
it is very unlikely that this is due to the saveload code from the daylength patch itself. it might be because some counters somewhere else get out of range. but using SDT_VAR or SDTG_VAR doesn't change the savegame structure at all, only the way the code handles the data. this change wouldn't even need a savegame bump.
Yeah, it is more likely that date_fract (asserts points at this when trying to load) is not correct (or overflown) after changing the daylength factor and saving during the same day.
That is why I think changing it ingame should be disabled ...

Do you happen to know if globally saved values can be changed by clients in multiplayer games? When changing to SDT_VAR it would best be disabled for network games, I think.
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

Eddi
Tycoon
Tycoon
Posts: 7414
Joined: 17 Jan 2007 00:14

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Eddi » 22 May 2011 01:22

i have not looked into it, but i guess that is either one of the "flags" or one of the "guiflags". there should be plenty of examples, and it should also not depend on SDTG_VAR or SDT_VAR
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
ChillCore
Tycoon
Tycoon
Posts: 2656
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: [Patch] Daylength, Cargodist with sprinkles

Post by ChillCore » 22 May 2011 01:37

In current trunk.
flags = SLF_NO_NETWORK_SYNC
or
guiflags = SGF_NO_NETWORK (I think this is the one ...)

If globally saved or not does not make a difference then it was/is not disabled. ;)
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.

dasy2k1
Transport Coordinator
Transport Coordinator
Posts: 334
Joined: 20 Sep 2006 23:43
Location: UK
Contact:

Re: [Patch] Daylength, Cargodist with sprinkles

Post by dasy2k1 » 23 May 2011 23:01

Do you reckon you can fork the cargodist git repo with this?
would make life easier for all if we could just pull cargodisst-daylength from git

Dr. B. Ching
Engineer
Engineer
Posts: 97
Joined: 14 May 2011 10:58
Location: Sausagewood

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Dr. B. Ching » 24 May 2011 09:50

Hello Eddi,

although I've settled on another patch now, the update will be helpful for other players. Thanks for your work!

Kind Regards,
The Axe

User avatar
KeithM
Engineer
Engineer
Posts: 5
Joined: 12 Nov 2009 15:50

Re: [Patch] Daylength, Cargodist with sprinkles

Post by KeithM » 03 Jul 2011 15:06

Excuse me if this issue has already been discussed, but I cannot find it anywhere on these boards or on the web.

I am running the cargodist + sprinkles build (r19964M) with a daylength factor of 16 so time passes by nice and slowly. But it seems this is messing up cargodist. Whenever my train loads a bunch of passengers from station A to C, but the train passes a station B en-route, it will just unload everything at station B. I am not using non-stop orders by the way, is that of any relevance?

Please let me know if this is a known problem and how to fix is, and once more my apologies if I should have been able to find this myself.
Something witty.

Eddi
Tycoon
Tycoon
Posts: 7414
Joined: 17 Jan 2007 00:14

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Eddi » 03 Jul 2011 17:39

yes. that very likely is the cause. newer cargodist versions should have that fixed, but r19964 is very old.
You might not exactly be interested in Ferion, but if you are, have fun :)

Ferrarius
Engineer
Engineer
Posts: 37
Joined: 03 May 2011 11:52

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Ferrarius » 11 Jul 2013 12:18

I have updated the towncargo patch against trunk: 25581. I have not extensively tested this
Attachments
towncargo-25581.diff
25581
(5.88 KiB) Downloaded 172 times

User avatar
kyosuke1989
Transport Coordinator
Transport Coordinator
Posts: 269
Joined: 24 Mar 2008 13:04
Location: Finland

Re: [Patch] Daylength, Cargodist with sprinkles

Post by kyosuke1989 » 10 Sep 2013 12:40

Now that Cargodist is in trunk, could someone update those three daylength patches up to current trunk?

Swoop
Engineer
Engineer
Posts: 23
Joined: 01 Mar 2013 18:47

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Swoop » 03 Apr 2015 03:19

<PUNT> Yes, can we get these in the trunk please?
Image

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

Re: [Patch] Daylength, Cargodist with sprinkles

Post by kamnet » 03 Apr 2015 03:50

HAAH! How funny, I just pulled up this topic to ask the same. Anybody? :D

Swoop
Engineer
Engineer
Posts: 23
Joined: 01 Mar 2013 18:47

Re: [Patch] Daylength, Cargodist with sprinkles

Post by Swoop » 04 Apr 2015 18:39

It's the passenger traffic reduction that's the biggest thing......now we've got Cargodist in the trunk.......it's fantastic but I just can't keep up with the traffic unless it's 2020 and I've got a dozen super fast electric trains per route.
Image

lostwizard
Engineer
Engineer
Posts: 4
Joined: 06 Apr 2012 03:07

Re: [Patch] Daylength, Cargodist with sprinkles

Post by lostwizard » 12 Oct 2015 18:38

Swoop wrote:It's the passenger traffic reduction that's the biggest thing......now we've got Cargodist in the trunk.......it's fantastic but I just can't keep up with the traffic unless it's 2020 and I've got a dozen super fast electric trains per route.
Indeed. It turns out that the cargo factor one is fairly small.

I've attached my attempt at forward porting it to trunk revision 27400. I make no representation that it operates correctly or that it won't eat your games, explode your computer, or torture small kittens. I have tested it briefly on a saved game with a crazy high number of passengers at dozens of stations. Adjusting the factor did reduce the congestion after some time passed. I don't take any credit for the actual code. I only modified it to build with the trunk.
Attachments
town-cargo-factor-lw01-r27400.patch
Town cargo factor patch updated for r27400
(6.8 KiB) Downloaded 82 times

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 2 guests