Sacros day length 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

Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Sacros day length patch

Post by Sacro »

Here is the first release of my day length patch, currently its just a multiplyer for the date incrementer, and i still need to sort out the impacts made on the economy. Any problems or ideas, send us a message!
Attachments
daylength-5370.diff
(12.81 KiB) Downloaded 809 times
daylength-5370MiniIN.diff
MiniIN patch
(13.38 KiB) Downloaded 623 times
Last edited by Sacro on 26 Jun 2006 19:54, edited 4 times in total.
We Am De Best

Host of ThroughTheTube site
ElectricA4
Engineer
Engineer
Posts: 72
Joined: 29 Sep 2004 15:30

Post by ElectricA4 »

I used the windows compilation that used to be here. I thought the patch worked well and I had no problems with it.
User avatar
Death
Tycoon
Tycoon
Posts: 992
Joined: 02 Aug 2005 13:00
Location: Jerusalem, Israel

Post by Death »

I had cilcked on the "downloud" link, and Eror 404 appeared.
Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Post by Sacro »

Sorry people, I don't have the internet at home, and as such it can take me a while so update the files, I will upload them asap, the .diff file is on the sf tracker though, and a windows binary will be up soon.
We Am De Best

Host of ThroughTheTube site
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

i think its back.
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
Nappe1
Traffic Manager
Traffic Manager
Posts: 175
Joined: 19 Jan 2004 17:25
Location: kotka or Savitaipale, Finland
Contact:

Post by Nappe1 »

we have been testing this patch in our private dedicated server with latest subsidiaries version. It's excelent patch and gives quite lot to the game, but there's few bugs we have come across:
- The time miltiplier isn't set up correctly to clients when they connect. (friend of mine did a small fix for this but I don't have a source nor diff for it.) and wrong time multiplier causes out of sync (naturally).
- all trains, trucks, airplanes, busses and ships are having their age in old time. (so with multiplier 3, busses gets old in 4 years. :D )
- if city has even one station, it grows on full rate all the time. (not a bug exactly, if you like metropolies...)

As a note, it's actually much easier make money in slowed time game than in regular one, because vechile moving speeds nor cargo payment rates aren't affected.

Still, this patch is definetely worth of developing, so keep up the good work.
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

the money issues are 1 of the things we were considering changing. its something we arn't sure about, because half of the point is to make the game last longer, so we were thnking of making it an option you can turn on and off, and if its on, it simply devides some money transactions by the daylenth multiplier, such as running costs and cargo payments. building costs shouldn't be effected.

city growth also seems like it should be changed too.

thanks for reporting these "test" results

however, i've been trying to contact sacro, and he seems to have vanished...

i'm guessing that the daylenth isn't passed to the clients for the same reason the game doesn't save the daylenth... sacro hasn't programmed that part yet.

I'm sure he'd apreciate the help of whoever it was who patched his patch to transmit it :P
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Post by Sacro »

Right, im having a few problems in life at the moment, its a long story, but I should be back home and developing this patch soon!

I will take a look at getting the server to send the day length to the clients on connection, I'm sure I can remember how to do that one, as for the aging and city sizes, im sure I can have a look at sorting those out too, also there was mention of income and production being multiplied too, do these also want sorting?

Thanks for testing it for me too! Feels nice to know people are actually using it!
We Am De Best

Host of ThroughTheTube site
Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Post by Sacro »

Just thought that i'd see how many people are after this patch having a few updates, and if they could suggest what kind of things could be implemented. At the moment all it does is increase the number of ticks before a new day is started, however the economy and income are still at the original rate.

Any feedback would be much appreciated.
We Am De Best

Host of ThroughTheTube site
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

wasn't the first things you were suposed to be doing making it save the state of this flag when you saved the game, and transmitting it to other players in multiplayer?
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
User avatar
sidew
Engineer
Engineer
Posts: 115
Joined: 31 Aug 2005 06:46
Location: Milan, Italy
Contact:

Post by sidew »

I 've played often with last IN with your patch. I never cared about economics but on custom 1024x1024 maps it is a MUST.

My standard setting is around game day at 20 real time sec. (10x)

I hope that you update your patch for the 0.4.5
Sidewinder

Italian Town names patch for OTTD (R5266) now in trunk since 0.4.8
For typo, errors or bug on OTTD italian translation, please PM me.
unofficial italian TTD/OpenTTD forum: http://wolf01.game-host.org/forum/index.php
User avatar
Gedemon
Traffic Manager
Traffic Manager
Posts: 150
Joined: 29 Apr 2004 21:53

Post by Gedemon »

Sacro wrote:Just thought that i'd see how many people are after this patch having a few updates, and if they could suggest what kind of things could be implemented. At the moment all it does is increase the number of ticks before a new day is started, however the economy and income are still at the original rate.

Any feedback would be much appreciated.
nice patch for "semi-persistent" server :D

I'll be pleased to have bobingabout idea integrated ("devides *or multiply* some money transactions by the daylenth multiplier, such as running costs and cargo payments")

maybe vehicule age and reliability decay should be locked at too.
Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Post by Sacro »

Well i was planning on looking into that, however im not sure how many variables will need to be altered, also the way i see it the game could end up 32x longer to actually do anything (due to income being 32x slower) rather than 32x longer.
We Am De Best

Host of ThroughTheTube site
User avatar
Gedemon
Traffic Manager
Traffic Manager
Posts: 150
Joined: 29 Apr 2004 21:53

Post by Gedemon »

Sacro wrote:Well i was planning on looking into that, however im not sure how many variables will need to be altered, also the way i see it the game could end up 32x longer to actually do anything (due to income being 32x slower) rather than 32x longer.
maybe max loan 32x higher ?
Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Post by Sacro »

I dont think thats a good way of sorting it. I can see that breaking things.
We Am De Best

Host of ThroughTheTube site
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

thats why i sugested the option of making everything 32x lower. if it takes 32x the length of time to make any money at all, that might get boring fast, so, a small config option to devide by "1", "DAY_LENGTH/2", "DAY_LENGTH", you can name the settings later. so, thats keeping it as it is, deviding by 16, and deviding by 32. assuming DAY_LENGTH is 32. some things such as vehicle age should always relly on DAY_LENGTH.

also, erm, if production of some things gets too large (like 65000 grain a month, more worries are with the oil, when set with a high daylength) it might be a good idea to display grain per day, rather than per month. also, when editing the values, the display needs updating, because although it says 2048 oer month when you set it, it jumps to like 65000 soon after, so the number in that setting wants multiplying by daylength.
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Post by Sacro »

Right, well thanks to Wolf01, we have a shiny new daylength patch, not only is updated to the latest revisions, its MiniIN compatible, and should work for network games too.

Also he's adjusted the timings for network messages and other such things, so they stay for so many ticks, rather than so many days.

I will post the updated patch in the top post, merges with "-p 0" for trunk and "-p 0 -F 100" against MiniIN, and hopefully if my cross-compiler is working, then a windows binary.

Any suggestions, problems, questions etc, let me know!
We Am De Best

Host of ThroughTheTube site
Hazelrah
Traffic Manager
Traffic Manager
Posts: 196
Joined: 13 Apr 2005 05:41

Post by Hazelrah »

Wolf01 From MiniIN Thread wrote:i found a biiiiig bug on the daylength patch, and i'm looking for somebody which can help me and sacro to fix it

the bug description is this: if you stretch the day length by increasing the multiplier you can earn more money than the default day length, this because all the running costs, maintenance and interests are based on the year, instead industry production is based on (old) day length, so if before stretching the days a train can do a travel in i say 15 days, now a train can do the same travel in 2 or less days (also 2 travels a day) and for each travel it earn the same profit!!!
Moving this discussion back to the thread it belongs in. ;)


[Start Edit] Opps, spoke too soon :oops:. Well, I'll leave my idea here just in case it can help you out in the future. Actually I found a different function that maybe more appropriate.

Code: Select all

File: economy.c

int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type)
Maybe what you can do is change 'transit_days' to 'transit_ticks' instead, or something simmilar to that. How many ticks per day in a normal game?

[End Edit]



[Start Old idea]
Ok, I did a quick runthrough of the money code. I've got an idea of where to look.

Code: Select all

File: players.c

static void SubtractMoneyFromAnyPlayer(Player *p, int32 cost)
{
	p->money64 -= cost;
	UpdatePlayerMoney32(p);

	p->yearly_expenses[0][_yearly_expenses_type] += cost;

	if (HASBIT(1<<7|1<<8|1<<9|1<<10, _yearly_expenses_type)) {
		p->cur_economy.income -= cost;
	} else if (HASBIT(1<<2|1<<3|1<<4|1<<5|1<<6|1<<11, _yearly_expenses_type)) {
		p->cur_economy.expenses -= cost;
	}

	InvalidatePlayerWindows(p);
}
This code might be efficient (not sure about that) but it's hell on the eyes!

Those bit shifts all refer to a yearly expense, which is defined as follows:

Code: Select all

File: openttd.h

enum {
	EXPENSES_CONSTRUCTION = 0,
	EXPENSES_NEW_VEHICLES = 1,
	EXPENSES_TRAIN_RUN = 2,
	EXPENSES_ROADVEH_RUN = 3,
	EXPENSES_AIRCRAFT_RUN = 4,
	EXPENSES_SHIP_RUN = 5,
	EXPENSES_PROPERTY = 6,
	EXPENSES_TRAIN_INC = 7,
	EXPENSES_ROADVEH_INC = 8,
	EXPENSES_AIRCRAFT_INC = 9,
	EXPENSES_SHIP_INC = 10,
	EXPENSES_LOAN_INT = 11,
	EXPENSES_OTHER = 12,
};
This was just a quick look through the code, so your still going to need to do the math. Basically, check to see if it is of type 7, 8, 9, or 10, (possibly OTHER, but I haven't looked at what goes in there yet). Then work out some magical formula that divides the money by the same factor that you slow days with.

Code: Select all

File: players.c

static void SubtractMoneyFromAnyPlayer(Player *p, int32 cost)
{
	/* Daylength Adjustment code start here */
	if (HASBIT(1<<7|1<<8|1<<9|1<<10, _yearly_expenses_type)) {
		cost = /* Magical Daylength formula */;
	}
	/* Daylength Adjustment code end here */

	p->money64 -= cost;
	UpdatePlayerMoney32(p);

	p->yearly_expenses[0][_yearly_expenses_type] += cost;

	if (HASBIT(1<<7|1<<8|1<<9|1<<10, _yearly_expenses_type)) {
		p->cur_economy.income -= cost;
	} else if (HASBIT(1<<2|1<<3|1<<4|1<<5|1<<6|1<<11, _yearly_expenses_type)) {
		p->cur_economy.expenses -= cost;
	}

	InvalidatePlayerWindows(p);
}

I'm not exaclty sure when it prints the money on the main screen, so that might need some special attention. Give it a try!

-Hazelrah
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Hazelrah wrote:Maybe what you can do is change 'transit_days' to 'transit_ticks' instead, or something simmilar to that. How many ticks per day in a normal game?
0x10000/0x375 ≈ 74 ticks/day.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Post by Wolf01 »

DaleStan wrote:
Hazelrah wrote:Maybe what you can do is change 'transit_days' to 'transit_ticks' instead, or something simmilar to that. How many ticks per day in a normal game?
0x10000/0x375 ≈ 74 ticks/day.
but this patch multiplies it from 1 to 32 so we have 2 possibilities:
1) multiply the day ticks first and divide it where it has to be the old behavior (as now)
2) multiply the day ticks only where we need (but is a pain with the day calculation)

however thanks for the info Hazelrah :D
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google [Bot] and 44 guests