OpenTTD

Tasklist

FS#3602 - Industry tiles - extended prop 12 with special flag INDTILE_SPECIAL_DONT_BUILD

Attached to Project: OpenTTD
Opened by andythenorth (andythenorth) - Sunday, 07 February 2010, 18:36 GMT
Last edited by Remko Bijker (Rubidium) - Monday, 13 December 2010, 18:39 GMT
Type Patch
Category NewGRF → NewIndustries
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

This extends industry tile prop 12, and the tile building routine. If prop 12 bit 1 is set, the tile won't be built, but will be available for use in layout checks etc.

This task depends upon

Closed by  Remko Bijker (Rubidium)
Monday, 13 December 2010, 18:39 GMT
Reason for closing:  Won't implement
Additional comments about closing:  Not needed; can be done using other callback/variable.
Comment by frosch (frosch) - Sunday, 07 February 2010, 18:49 GMT
The hardest part is missing :(
The location in the industry layout should be signed just as for type 0xFF.

Edit:
Also "/* it->gfx is stored in the map. But the translated ID cur_gfx is the interesting one */" might need some care.
Comment by andythenorth (andythenorth) - Sunday, 07 February 2010, 21:39 GMT
I modified newgrf.cpp to allow signed offsets. Currently all tiles can be built with signed offset, which will cause problems. I need to prevent a tile with signed offset from being constructed, I haven't figured that out yet.
There was also some exciting irc debate about the format of itt[k].ti.x = (int8)GB(itt[k].ti.x, 0, 8);
Comment by andythenorth (andythenorth) - Sunday, 07 February 2010, 22:25 GMT
I've modified industry_cmd.cpp further to prevent tiles with signed offsets being built.
I also moved a couple of lines as suggested by frosch in resp. of /* it->gfx is stored in the map. But the translated ID cur_gfx is the interesting one */

Not building is handled silently - no errors are reported.
IMO the newgrf author has done something stupid if they use negative offsets without prop 12 bit 1 set (i.e. don't build this tile).

EDIT: I wonder if CheckIfIndustryTilesAreFree needs to exclude tiles with negative offsets unless prop 12 bit 1 is set for tile?
Comment by andythenorth (andythenorth) - Monday, 08 February 2010, 21:38 GMT
Update - CheckIfIndustryTilesAreFree now returns false if offsets are < 0 and tile prop 12 bit 1 is not set. (This is now checked in two places which seems redundant)
Comment by andythenorth (andythenorth) - Monday, 08 February 2010, 23:30 GMT
frosch was pretty adamant that negative offsets need checking in a better way with AfterLoadGRFs

This is my attempt to do that. It doesn't quite work, and I'm not sure why. It's not reading the special flag for tile prop 12 bit 1 correctly. I think I'm probably checking the wrong tile?
Comment by Thijs Marinussen (Yexo) - Monday, 08 February 2010, 23:44 GMT
The latest change in src/industry_cmd.cpp is wrong. GetIndustryTileSpec(GFX_WATERTILE_SPECIALCHECK) is not valid, it's never done in trunk because the check for GFX_WATERTILE_SPECIALCHECK is first, but you move those calls around so GetIndustryTileSpec is called for that id.
Comment by andythenorth (andythenorth) - Tuesday, 09 February 2010, 07:44 GMT
Yexo - I've added some conditional code to check tile id before calling GetIndustryTileSpec. Also seemed easiest to set a little flag to control wherever the tile is built or not.
Comment by andythenorth (andythenorth) - Tuesday, 09 February 2010, 10:05 GMT
For some reason I had ruled out using industry tile cb 2F and industry tile var 60 to solve this. That was a mistake.

Using cb 2F and var 60, I can simply check the contents of a tile's 8 neighbours. If they contain another industry (or other unremovable object), then I can prevent the industry from being built.

This should render my patch attempts for this redundant.

Loading...