[question]Slow down years counter

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

ZerXen
Engineer
Engineer
Posts: 13
Joined: 27 May 2007 08:54

[question]Slow down years counter

Post by ZerXen »

Hi, people ..
First of all, I found about OpenTTD just recently and I just love it! You are the best!

But one thing there is I can not found on this forum { dont know what to put to search },
I would pretty much like to slow down the game date/years progress, is it possible? Only the date/years everything else like vehicles, economy, etc. not affected { some console command or line of C code to edit? }. I would like to make one year last for about an hour, or even more .... so I can start the biggest posible map and play { with default rate in OpenTTD I am in year 1990 and I only managed to interconnect with rails only half of the map! }

I would pretty much like it { not as a cheat }, but I liked the times back when one year was about 40+ minutes of real-time { original TT on my 486DX2 machine ;-) } and I could play for a more than two weeks { game-time } and have enough time to search for perfection in rail design ...

Thanks for any help

PS: putting back years manualy with that cheat menu is not what I am looking for ;-)
knedle
Traffic Manager
Traffic Manager
Posts: 158
Joined: 13 Apr 2007 17:07

Post by knedle »

It would be nice, however AFAIK it's impossible (many ppl already asked for that feature). Meantime you can try another thing (which I'm doing): Pause the game, press CTRL+ALT+C to get to that cheat menu and enable Build on Pause. Thank's to it I made a lot of progress in one year unpausing game only to let trains out of their depots and get more money to build new lines.
I know this isn't what you were looking for, however I think it's the best solution right now.
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Post by XeryusTC »

There is a patch writen by Sacro which can slow down the game but it is very outdated. It can still be found in the MiniIN.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
ZerXen
Engineer
Engineer
Posts: 13
Joined: 27 May 2007 08:54

Post by ZerXen »

Oh well, I looks like searchig the C code files is still the last option ... maybe I dig into that after semester exams. I just hope that date/year and world do not share the same timing. Bullet time would look funny :lol:

PS: stupid question, what is this "MiniIN" ? { I am total newbie here, so bear with me }
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Post by XeryusTC »

A quick search comes up with this.

And you can also look at Sacro's original patch to see which line you have to edit, I don't know where that patch is though :P.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
Tomsomethingcon
Engineer
Engineer
Posts: 123
Joined: 16 Nov 2006 16:52

Post by Tomsomethingcon »

one thing i wondered was,

with the game speed as normal, in really time, how long is a game year ?
ZerXen
Engineer
Engineer
Posts: 13
Joined: 27 May 2007 08:54

Post by ZerXen »

On my machine one year lasts about 20-25min ...
Mihr
Engineer
Engineer
Posts: 10
Joined: 23 May 2007 23:14

Post by Mihr »

In my machine a day is about 2 seconds, therefore I think that a year is about 12~15m.

I really would love a patch like this, at least for single player. If this is posted in the suggestions subforums?
ZerXen
Engineer
Engineer
Posts: 13
Joined: 27 May 2007 08:54

Post by ZerXen »

If you guys have OpenTTD dev gurus here who would like to respond to this, I would be happy ;-) . You know where to find them, not me, I would be happy to find out few weeks from now that something like this has been done, it will save the code from being tempered by me { with a possibility of failure }. I know my way in C { IT student }, but I just came to this forum so I do not want to post mainstream suggestions, mostly for I do not know comunity around OpenTTD { Maybe this was brought up in the past and was rejected and now some newbie will spam suggestion subforum with it - that newbie => me }... Currently I am just glad that I can have a good time with something surpassing my old days with TTD :D and do not have to emulate it on my precious linux with beryl box :wink:

PS: If someone here thinks it is to be posted in suggestion subforum, pls do it yourself, thx

@Mihr: I did not bothered to check times properly ;) , I just noticed that date moves WAY TOO QUICK compared to old TT and TTD in my opinion.
ZerXen
Engineer
Engineer
Posts: 13
Joined: 27 May 2007 08:54

Post by ZerXen »

As for my previous suggestion, I made it myself ... the only thing is to edit the date.c code file and do a recompile ...

So this is what I have done :
downloaded current stable version 5.1
edited date.c
on line 241 { or nearby } you will see something like this in "void IncreaseDate(void)" function

Code: Select all

/* yeah, increase day counter and call various daily loops */
_date++;
-- this increase date whenever it detects timing update { first part of function }
What I have done is really just a brute cycle waste

Code: Select all

/* yeah, increase day counter and call various daily loops */        
static int slowDown = 0;
if ( slowDown < 3 ){
      slowDown++;
      return;
}
slowDown = 0;
_date++;
This will make one day last for 3 times as usual { 8sec on my system right now, I will make it 30sec for my own reasons } if you want more, just change the value in the "if" line ...
Anyway, I am not OpenTTD dev so I can not tell if this will have any unexpected problems ... but I will post any if they occur.

-- it violates C code ISO about declaring variables inside functions but atleast it keeps it eazy for you non coders to copy paste it there

-- I am going to do some gameplay to test it ..
Mihr
Engineer
Engineer
Posts: 10
Joined: 23 May 2007 23:14

Post by Mihr »

wow :o !

Please give us some feedback about this! If there're no problems with this modification, for sure i'll use it :P
kaan
Route Supervisor
Route Supervisor
Posts: 399
Joined: 02 Apr 2007 20:13
Location: Nørup, Denmark

Post by kaan »

ZerXen wrote:As for my previous suggestion, I made it myself ... the only thing is to edit the date.c code file and do a recompile ...

So this is what I have done :
downloaded current stable version 5.1
edited date.c
on line 241 { or nearby } you will see something like this in "void IncreaseDate(void)" function

Code: Select all

/* yeah, increase day counter and call various daily loops */
_date++;
-- this increase date whenever it detects timing update { first part of function }
What I have done is really just a brute cycle waste

Code: Select all

/* yeah, increase day counter and call various daily loops */        
static int slowDown = 0;
if ( slowDown < 3 ){
      slowDown++;
      return;
}
slowDown = 0;
_date++;
This will make one day last for 3 times as usual { 8sec on my system right now, I will make it 30sec for my own reasons } if you want more, just change the value in the "if" line ...
Anyway, I am not OpenTTD dev so I can not tell if this will have any unexpected problems ... but I will post any if they occur.

-- it violates C code ISO about declaring variables inside functions but atleast it keeps it eazy for you non coders to copy paste it there

-- I am going to do some gameplay to test it ..
Does this even work?
Seems to me like the slowDown variable is just reinitialized as 0 every time you enter the scope.

Code: Select all

if (YouAreHappyAndYouKnowIt) {
    ClapYourHands();
}
ZerXen
Engineer
Engineer
Posts: 13
Joined: 27 May 2007 08:54

Post by ZerXen »

kaan wrote:
ZerXen wrote:As for my previous suggestion, I made it myself ... the only thing is to edit the date.c code file and do a recompile ...

So this is what I have done :
downloaded current stable version 5.1
edited date.c
on line 241 { or nearby } you will see something like this in "void IncreaseDate(void)" function

Code: Select all

/* yeah, increase day counter and call various daily loops */
_date++;
-- this increase date whenever it detects timing update { first part of function }
What I have done is really just a brute cycle waste

Code: Select all

/* yeah, increase day counter and call various daily loops */        
static int slowDown = 0;
if ( slowDown < 3 ){
      slowDown++;
      return;
}
slowDown = 0;
_date++;
This will make one day last for 3 times as usual { 8sec on my system right now, I will make it 30sec for my own reasons } if you want more, just change the value in the "if" line ...
Anyway, I am not OpenTTD dev so I can not tell if this will have any unexpected problems ... but I will post any if they occur.

-- it violates C code ISO about declaring variables inside functions but atleast it keeps it eazy for you non coders to copy paste it there

-- I am going to do some gameplay to test it ..
Does this even work?
Seems to me like the slowDown variable is just reinitialized as 0 every time you enter the scope.
Learn C man ;) ... "static" means single inicialization variable { sometime devs call it "sticky" variable } ... so it keeps value even out of function scope and it is not initialized again when program executes that function and hit that initialization line, so it's ignored because that variable already exist in memory.
knedle
Traffic Manager
Traffic Manager
Posts: 158
Joined: 13 Apr 2007 17:07

Post by knedle »

It has one serious bug.
It modifies time displayed in game, but does not change production rate of industries.
So if you have slowDown < 30 it will not make industries work 30 times slower, but at their normal peace, which means you will get 30 times amount of cargo displayed in industry info.
ZerXen
Engineer
Engineer
Posts: 13
Joined: 27 May 2007 08:54

Post by ZerXen »

That is not a bug ... because it was really meant that way .. I want all the economy to work unchanged { compared to game movement not date progress } .. It's really only about having the ability to play the game longer ... my intention was to stop only date dependent progress { like vehicles getting old, getting new vehicles and so on ...Just to get the feel that one decade is more than just afternoon break } and leaving everything else as it is... It could be considered a cheat .. but only in statics, about whitch I do not care ...

.. another thing is that if I would to change even factory production rates, it would result in situations that most of my trains will be waiting for cargo all the time .. and that is not what I wanted.

Plus, I don't know about what industry has displayed { no time to play - exam tomorow } but consider that trains can then do 30 times as much transport cycles in that month, so it do not affect the game mechanics. Everything has 30 times more time to do its work in realtime.
kaan
Route Supervisor
Route Supervisor
Posts: 399
Joined: 02 Apr 2007 20:13
Location: Nørup, Denmark

Post by kaan »

ZerXen wrote:
kaan wrote:
ZerXen wrote:
-- it violates C code ISO about declaring variables inside functions but atleast it keeps it eazy for you non coders to copy paste it there
Does this even work?
Seems to me like the slowDown variable is just reinitialized as 0 every time you enter the scope.
Learn C man ;) ... "static" means single inicialization variable { sometime devs call it "sticky" variable } ... so it keeps value even out of function scope and it is not initialized again when program executes that function and hit that initialization line, so it's ignored because that variable already exist in memory.
As you state yourself it violates the ISO and therefore you can't expect C++ compilers to react the same (not to mention different platforms).
It's nice that you share your code with us, but in the future you should consider doing it right and post a diff. Most people here know how to use them.

Anyway, welcome to the community. You made a nice start here i think :)

Code: Select all

if (YouAreHappyAndYouKnowIt) {
    ClapYourHands();
}
ZerXen
Engineer
Engineer
Posts: 13
Joined: 27 May 2007 08:54

Post by ZerXen »

Well, you can use variable for the whole file/module and declare it before the function, but I doub that ISO standart will have any impact on compilers as that "static" is one of key C language features and that ISO is realy just a template { one ISO is for language itself but this ISO is only on a way to write code } on how to write the code so it would be readable by fellow programers ... I can almost promise you that my code will be able to compile on any C/C++ compiler as of all C++ compilers are back compatible with C to the extend of all it's abilities including static declaration.
ZerXen
Engineer
Engineer
Posts: 13
Joined: 27 May 2007 08:54

Post by ZerXen »

I found first bug of this solution, Trains still age in normal speed { as well as their running cost } so I am in 30th march 1930 { started 1930 } and there is a train that is 1 year old ...

I will have to look on the main timing functions, not just date counter ... I just hope that basic things like movement and factory production woudn't be inseparable ...
knedle
Traffic Manager
Traffic Manager
Posts: 158
Joined: 13 Apr 2007 17:07

Post by knedle »

I found the same bug. It really looks funny. :D
Faster aging of trains looks weird, however I would leave running cost calculations without changes. It would be weird if train that made 20 or 40 trips still generated really low running costs.
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Post by Wolf01 »

knedle wrote:It has one serious bug.
It modifies time displayed in game, but does not change production rate of industries.
So if you have slowDown < 30 it will not make industries work 30 times slower, but at their normal peace, which means you will get 30 times amount of cargo displayed in industry info.
knedle wrote:I found the same bug. It really looks funny. :D
Faster aging of trains looks weird, however I would leave running cost calculations without changes. It would be weird if train that made 20 or 40 trips still generated really low running costs.
my patch did this too, but with the "daylenght affect economy" patch you was able to balanche the costs
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: Google Adsense [Bot] and 34 guests