Page 3 of 5

Re: Chunnel v10 r16237

Posted: 22 May 2009 15:10
by Vitus
Here it is. Chunnel is r16237 and signals on tunnel r16305. It should work well, I hope.

It's built for win32.

Re: Chunnel v10 r16237

Posted: 22 May 2009 16:04
by Sensation Lover
thanks a lot!!! :bow: i'll tell you how it works

have a nice weekend!!!

Re: Chunnel v10 r16237

Posted: 22 May 2009 16:12
by Sensation Lover
It's not working just fine but much more!!!!!!!!! Thank you very very much! I hope this would merge to trunk soon! very good job!!!!

Re: Chunnel v10 r16237

Posted: 07 Aug 2009 09:18
by Terkhen
While checking a bug reported in TPPP I was able to make the game crash with a binary including only Chunnel v10 r16237. To recreate it, download "The Netherlands by Purno" scenario and try to build a chunnel near Amsterdam without lowering land for its exit, as seen in this screenshot:
chunnels crash.png
chunnels crash.png (70.18 KiB) Viewed 9510 times
I am attaching the crash.log file and the chunnel patch updated to r17097 (the same crash happens in this version). If required I can upload the crash.dmp file too.

Re: Chunnel v10 r16237

Posted: 07 Aug 2009 19:16
by Wasila
Are there any patches for signals on bridges/tunnels? EDIT: Just noticed it :oops:. These two patches would be a great combination for what I have planned in my game, and possibly a cheaper option. Tacking it on to my personal build might be the problem... Will the two patches work with r16816?

Which is cheaper, raising land by one level from the sea or building an undersea tunnel of the same length?

As for this, I'm sorry if this has already been asked, but how close is this to trunk? Do the devs like it?

Sorry for all my questions, and thanks! :bow:

Re: Chunnel v10 r16237

Posted: 07 Aug 2009 19:32
by Terkhen
I have updated both patches a few times: check TPPP svn revisions and grab the correct ones for the OpenTTD revision you want.

Raising land in sea is way more expensive than building a tunnel.

You can get an idea of how close to trunk inclusion is a patch reading the patch thread / flyspray task.

Re: Chunnel v10 r16237

Posted: 07 Aug 2009 19:42
by Wasila
Please note that some of these patches contain changes that alter their features to allow them to work along with other patches.
Is this true for Chunnels/Signals in tunnels and bridges?

The cost saving might mean I get my little project done more quickly, so it'll be very useful! Thanks for your help, I'll tell you how it goes once I get my separate problems with cargodist sorted.

Re: Chunnel v10 r16237

Posted: 07 Aug 2009 19:52
by Terkhen
You should ask questions related to TPPP at its own thread (answer me there about this topic). Right now there's no altered patches at TPPP and the ones which were altered where only GUI related. Anything else is not changed at all.

Re: Chunnel v10 r16237

Posted: 09 Aug 2009 23:14
by HackaLittleBit
Ok thank everybody for bug reports.

I was able to reproduce it and during this week I will have a look at it. 8)

Regards HackaLittleBit

P.S. Purno forgot to put the city Haarlem on that "Netherlands scenario". :wink:

Re: Chunnel v10 r16237

Posted: 16 Aug 2009 19:44
by HackaLittleBit
Ok bug fixed.

Added safety check for the map edges.
Did not test very much but it should work :)

See first post

P.S. Thanks Terkhen

Re: Chunnel v11 r17206

Posted: 16 Aug 2009 20:50
by Terkhen
I just tested it. The crash does not happen anymore, but the game slows down *a lot* when I try to build a chunnel in the same conditions that previously produced the crash. Is that normal?

Re: Chunnel v11 r17206

Posted: 17 Aug 2009 09:36
by HackaLittleBit
Terkhen wrote:I just tested it. The crash does not happen anymore, but the game slows down *a lot* when I try to build a chunnel in the same conditions that previously produced the crash. Is that normal?

I am at work and can´t compile here!
Code is not really optimized.
But quick look at code a little change could make a difference
Change this code into

Code: Select all

if (IsValidTile(end_tile + delta) &&
			IsTileType(end_tile + delta, MP_WATER) &&
			!IsWaterTile(start_tile - delta) &&
			end_z == 0) {
			if (GetWaterTileType(end_tile + delta) == WATER_TILE_CLEAR ||
				GetWaterTileType(end_tile + delta) == WATER_TILE_COAST) passing_water = true;
		}
this

Code: Select all

if (end_z == 0 &&
			IsValidTile(end_tile + delta) &&
			IsTileType(end_tile + delta, MP_WATER) &&
			!IsWaterTile(start_tile - delta)) {
			if (GetWaterTileType(end_tile + delta) == WATER_TILE_CLEAR ||
				GetWaterTileType(end_tile + delta) == WATER_TILE_COAST) passing_water = true;
		}
and check it out please.
If I have some time I will look if I can do some more optimalisation. :)

Re: Chunnel v11 r17206

Posted: 17 Aug 2009 09:54
by Terkhen
The problem is less intense with these changes, but it is still there. The diff is attached here. Don't worry, optimize it when you have time ;)

Re: Chunnel v11 r17206

Posted: 17 Aug 2009 10:09
by HackaLittleBit
terkhen can you have a look with this change?

Code: Select all

if (passing_water == false) {
      if (end_z == 0 &&
         IsValidTile(end_tile + delta) &&
         IsTileType(end_tile + delta, MP_WATER) &&
         !IsWaterTile(start_tile - delta)) {
         if (GetWaterTileType(end_tile + delta) == WATER_TILE_CLEAR ||
            GetWaterTileType(end_tile + delta) == WATER_TILE_COAST) passing_water = true;
      }
}
thanks :)

Re: Chunnel v11 r17206

Posted: 17 Aug 2009 10:15
by Terkhen
It keeps the same with that change.

Re: Chunnel v11 r17206

Posted: 17 Aug 2009 13:23
by Wasila
Hey hackalittlebit, I was wondering if you could shed light on the following posts:

Hey,

I added the patches 'Chunnels' and 'Signals in Bridges and Tunnels' to my running game which already had 'extra-large-maps patch' and 'cargodist'. I have been testing the new addition and have noticed something very peculiar.

Later in the game I planned on constructing a gigantic landbridge to connect two continents on the map. I did a cost estimation and I got roughly £400,000,000. I did this again after installing the new patches and this dropped to under £100,000,000. A tunnel, however, cost £600,000,000 (despite being told that underwater tunnels were cheaper than raising land).

Could someone please shed light onto this situation?
Thanks.

AND:

I recompiled (with a slightly older nightly) with just maps patch and chunnels. The landbridge costed £100,000,000 or so and the tunnel cost just under £500,000,000.

Thanks!

Re: Chunnel v11 r17206

Posted: 17 Aug 2009 13:39
by Terkhen
The cost for building tunnels don't increase lineally with distance. This means that, since tunnel cost increases faster than raising land cost (which increases lineally with distance) there's a point in which a tunnel is more expensive than raising land. The best solution for your problem will be to build smaller but still large bridges / tunnels.

Re: Chunnel v11 r17206

Posted: 17 Aug 2009 17:03
by Wasila
Hmm... I never thought of that. Thanks!

EDIT: Do you have a formula as to the cost of tunnels?

Re: Chunnel v11 r17206

Posted: 17 Aug 2009 17:16
by Terkhen
Check CmdBuildTunnel function, in tunnelbridge_cmd.cpp. I don't know if the formula is in "natural language" somewhere.

Re: Chunnel v11 r17206

Posted: 18 Aug 2009 10:21
by Wasila
So what is the starting price for one tile? From there, I take it that this:

/** Tile shift coeficient. Will decrease for very long tunnels to avoid exponential growth of price*/
int tiles_coef = 3;
/** Number of tiles from start of tunnel */
int tiles = 0;
/** Number of tiles at which the cost increase coefficient per tile is halved */
int tiles_bump = 25;
/** Tunnel under water flag */
bool passing_water = false;

is what to work things out with.