Page 1 of 2

Increase or remove oil refinary limit over 48 tiles

Posted: 09 Mar 2010 22:51
by NekoMaster
OpenTTD Is almost a Full v1.0.0 and yet there still the annoying limit of 48 tiles away from the map edges for oil refineries.
IRL As far as I know, oil refineries are usually near a large source of water (usually oceans or seas)

Anyways, could someone tell me how I would remove that limit (like which file in the source code has the limit) or could someone make a simple patch to fix this

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 09 Mar 2010 22:57
by petert
This line of code looks like it deals with the limit and returning errors:
http://hg.openttd.org/openttd/trunk.hg/ ... .cpp#l1169

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 02:54
by NekoMaster
Ok, im having A LOT of trouble with this since I know nothing about C\C+

What do I need to change to remove the limit or make it higher?

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 03:06
by petert
NekoMaster wrote:What do I need to change to remove the limit or make it higher?
From what my limited knowledge of coding can determine:

Code: Select all

if // if xx is true
(DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) // The distrance from the edge (TILE_ADD X+Y)
< _settings_game.game_creation.oil_refinery_limit) // is less that that defined in  _settings_game.game_creation....
return CommandCost() // Return the Command Cost

return_cmd_error(STR_ERROR_CAN_ONLY_BE_POSITIONED); // Other wise, find and return STR_ERROR_CAN_ONLY_BE_POSITIONED
}
You could probably get around this by changing return_cmd_error(STR) to return CommandCost(), so that although it failed, it will still successfully complete the command.

You'd have to do this many times, as the oil refinery code isn't all in one place: http://hg.openttd.org/openttd/trunk.hg/ ... .cpp#l1183

On another note, you sound like you want someone to just do it for you, without actually trying to understand the code. The developers have lives, they just do this in their free time. Perhaps you should try to invest some of yours to figure it out.

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 03:36
by NekoMaster
Ok I got it, I also removed the limitations of some other industries that should be able to build anywhere, like the forest in subarctic and and the water supply in subtropic

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 03:56
by petert
NekoMaster wrote:Ok I got it, I also removed the limitations of some other industries that should be able to build anywhere, like the forest in subarctic and and the water supply in subtropic
Could you provide a patch, if at all possible?
With TortoiseSVN: Right Click -> TortoiseSVN -> Create Patch
Command-line: svn diff > patchfile.diff

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 05:11
by NekoMaster
petert wrote:
NekoMaster wrote:Ok I got it, I also removed the limitations of some other industries that should be able to build anywhere, like the forest in subarctic and and the water supply in subtropic
Could you provide a patch, if at all possible?
With TortoiseSVN: Right Click -> TortoiseSVN -> Create Patch
Command-line: svn diff > patchfile.diff
currently when I try to make a patch it wont compile when I patch openttd with it, but when I edit industry_cmd.cpp by hand it works :\

could I just post the modified industry_cmd.cpp?

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 11:23
by Roujin
NekoMaster wrote:Ok I got it, I also removed the limitations of some other industries that should be able to build anywhere, like the forest in subarctic and and the water supply in subtropic
Who says where they should be? There are gameplay reasons for these limitations. [I'm not one of them but] quite some people like these restrictions in arctic and tropic. It's arguable though that the oil refinery limitation got broken by large maps anyway.

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 12:41
by NekoMaster
Roujin wrote:
NekoMaster wrote:Ok I got it, I also removed the limitations of some other industries that should be able to build anywhere, like the forest in subarctic and and the water supply in subtropic
Who says where they should be? There are gameplay reasons for these limitations. [I'm not one of them but] quite some people like these restrictions in arctic and tropic. It's arguable though that the oil refinery limitation got broken by large maps anyway.
The problem with having forests only above the snow line is stupid, IRL not all forest's in that climate will grow above the Snow line, after all the Sub-Arctic Climate is suppose to mimic North America, where you can find forests far below the snow line in many places.

As for the water supply, ground water can happen anywhere, it doesn't have to be just under desert's.

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 12:42
by Kogut
It is even less probably to find water on desert.

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 13:04
by NekoMaster
Kogut wrote:It is even less probably to find water on desert.
True, now with the patch I made water supplies can be built on tropical grass.

One thing I found is that Oil Refinaries wont spawn on map generation beyond 48 tiles, so you have to build them your self if you need a oil refinary beyond the 48 tile limit

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 18:43
by ColdIce
Here is the patch for refinery. I followed petert instructions. If you have problem with the patch, I think i can`t help you very much. I don`t know anything about c++.

patch revision 19378

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 21:37
by NekoMaster
Heres my patch, Less Restrictive Industries (Removes placement limits\restrictions for refinaries, forests and water supplies)

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 22:21
by ChillCore

Code: Select all

...
+	if (_settings_game.game_creation.landscape == LT_ARCTIC) {}
...
+	if (GetTropicZone(tile) != TROPICZONE_DESERT) {}

May I ask why you bother keeping the if statements if you are not doing anything after checking for the condition.
The only thing the above code does for the moment is stressing the processor needlessly.

Anyway I think you will have a hard time convincing the devs to include this into trunk.(I wouldn't.)
Maybe the oil refinery limit but not in this form.
If you could make it a configurable setting in advanced setting ...
You should go look here "_settings_game.game_creation.oil_refinery_limit" and change oil_refinery_limit where it is declared if you want to change the max distance from the edge.

Changing the forest and the water supply placement will break something, if not in the code it will remove the reason they have been coded this way, different gameplay strategy for different climates.

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 22:36
by Yexo
Even then it wouldn't be included in trunk. If you want to disable the limits create a simple newgrf that doesn't have those limits. I think that as soon as your newgrf overrides an industry some of the limits are already gone and you have to implement them again in the newgrf if you want them.

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 23:43
by Zephyris
Given large map sizes it would make a nice feature to allow oil rigs to be built far from the map edge, but have a requirement to be at least a certain distance away from land...

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 10 Mar 2010 23:56
by NekoMaster
Zephyris wrote:Given large map sizes it would make a nice feature to allow oil rigs to be built far from the map edge, but have a requirement to be at least a certain distance away from land...
What are you talking about, Im tlaking about removing the oil refinery limits

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 11 Mar 2010 01:07
by petert
NekoMaster wrote:What are you talking about, Im tlaking about removing the oil refinery limits
And he was merely suggesting something that has to do with your topic, without opening a new one.

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 11 Mar 2010 03:44
by NekoMaster
petert wrote:
NekoMaster wrote:What are you talking about, Im tlaking about removing the oil refinery limits
And he was merely suggesting something that has to do with your topic, without opening a new one.
What, is there a limit for Oil Rig's too like the limit for Oil Refineries?

Re: Increase or remove oil refinary limit over 48 tiles

Posted: 11 Mar 2010 07:56
by jonty-comp
Kogut wrote:It is even less probably to find water on desert.
I think it's more the point that they only need the water in the desert parts, in general tropical rainforest has quite a lot of water anyway. :o