Page 1 of 3

Sacros day length patch

Posted: 31 Jul 2005 21:20
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!

Posted: 11 Aug 2005 07:05
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.

Posted: 11 Aug 2005 08:36
by Death
I had cilcked on the "downloud" link, and Eror 404 appeared.

Posted: 15 Aug 2005 21:07
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.

Posted: 01 Sep 2005 09:58
by bobingabout
i think its back.

Posted: 05 Oct 2005 09:57
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.

Posted: 05 Oct 2005 13:11
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

Posted: 15 Oct 2005 16:03
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!

Posted: 09 Feb 2006 01:22
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.

Posted: 09 Feb 2006 09:00
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?

Posted: 09 Feb 2006 09:53
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

Posted: 09 Feb 2006 20:13
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.

Posted: 09 Feb 2006 20:16
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.

Posted: 09 Feb 2006 21:05
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 ?

Posted: 09 Feb 2006 21:11
by Sacro
I dont think thats a good way of sorting it. I can see that breaking things.

Posted: 10 Feb 2006 08:32
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.

Posted: 26 Jun 2006 18:09
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!

Posted: 30 Jun 2006 01:54
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

Posted: 30 Jun 2006 02:56
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.

Posted: 30 Jun 2006 10:44
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