No tunnels under mines\wells [hello sourceforge]

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

MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

No tunnels under mines\wells [hello sourceforge]

Post by MeusH »

This patch forbids building tunnel under following
industries:
coal mine, copper ore mine, iron ore mine, gold mine,
diamond mine, oil wells, plastic fountains, sugar mine, water
supply
.

If player tries to do so, error message
Can't build tunnel here...
<Industry name> in the way

will pop-up.

If you have any suggestions\found a bug please let me know. This has been submitted to the SourceForge and now it awaits for a kind dev to merge "another tunnel bug fix".
The only thing I'd change (but I don't know yet how) is the red flickering tile - it appears at the tunnel end, while it should appear at one of the industrial tiles. Anyway I don't think it is important for gameplay.
Last edited by MeusH on 19 Oct 2005 21:36, edited 2 times in total.
Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Post by Conditional Zenith »

Where's the diff?
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

Finally. I thought I would have to make it. :)

You could maybe limit the limit to the "shaft" parts of the mines (where the elevators go to the ground)...
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Conditional Zenith wrote:Where's the diff?
Peter1138 did a nice work on simplifying the code (changed if to switch, case) - link to version improved by Peter is in the comments
SirkoZ wrote:You could maybe limit the limit to the "shaft" parts of the mines (where the elevators go to the ground)...
I think we should keep it simple... I was also thinking about gold\iron ore mines should block tunnel only one height level below, but that would make game not-so-simple
User avatar
Gorre
Transport Coordinator
Transport Coordinator
Posts: 322
Joined: 03 Jan 2004 10:28
Location: Somewhere over the rainbow
Contact:

Post by Gorre »

Aaaa, MeusH, thank you! I just hope it is going to be in CVS soon.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Personally, I hope it *doesn't* appear in CVS, because that would mean that I have to figure out how to acquire the source from CVS, instead of SVN.

</smart_alek>
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
Gorre
Transport Coordinator
Transport Coordinator
Posts: 322
Joined: 03 Jan 2004 10:28
Location: Somewhere over the rainbow
Contact:

Post by Gorre »

Image
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

G0RR3 wrote:Image
Image
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
spaceman-spiff
Retired Moderator
Retired Moderator
Posts: 20634
Joined: 28 Jul 2002 07:08
Location: Belgium
Contact:

Post by spaceman-spiff »

Stick to some sort of encouraging word please
Well, back to work, lot's of it in the near future
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

I really like the idea (and the patch!) Good work!
I always found it to be unrealistic, to drill tunnels almost anywhere...

Suggestion : what about "parametrizing" the "depth" at which one can drill a tunnel?
It could be linked to a difficulty setting...
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

belugas wrote:Suggestion : what about "parametrizing" the "depth" at which one can drill a tunnel?
It could be linked to a difficulty setting...
Yes, if I go into enchancing this and keeping-not-as-simple, I'd do this.
I'd also make a cheat that allows to build such a tunnels...
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

MeusH wrote: Yes, if I go into enchancing this and keeping-not-as-simple, I'd do this.
I'd also make a cheat that allows to build such a tunnels...
Cheat is easy ! Simply remove the feature :)
But I think that cheat,as well as difficulty levels, are saved within the game.
Is there room for new stuff on it? Got to check it out!
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Industries (should) not be able to be built over a tunnel.
There is one issue I can't fix, so I'm asking for help some kind coder with spare minutes.

Everything is in bool CheckIfIndustryTilesAreFree in industry_cmd.c:

Code: Select all

// Check for industries we can't tunnel under.
			switch (type) {
				case IT_COAL_MINE:
				case IT_COPPER_MINE:
				case IT_IRON_MINE:
				case IT_GOLD_MINE:
				case IT_DIAMOND_MINE:
				case IT_OIL_WELL:
				case IT_PLASTIC_FOUNTAINS:
				case IT_SUGAR_MINE:
				case IT_WATER_SUPPLY:
					for (z=ti.z;z==0;z--) //loop throught all height levels
						if (!CheckTunnelInWay(tile, z*8)) { //check for tunnels
							break;
							return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
						}
				default:
					break;
			}
Unfortunatelly, this doesn't block industries from being placed there.
Any ideas, please?
Attachments
no_tunnels_under_mines_2005_10_18_r3059.patch
Diff against r3059
(2.14 KiB) Downloaded 262 times
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Fixed, fixed :wink:
Updated against 3065
Now industries can't be built\bought over a tunnel.
Loop is still a bit tricky, but it would be easy to fix.

Anyway, the question is about adding a cheat allowing to tunnel through shafts. This is mainly to developers, since they might i.e. not want to add next cheat...
Attachments
no_tunnels_under_mines_2005_10_19_r3065.patch
diff against 3065
(2.16 KiB) Downloaded 262 times
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Finished.
No mines\wells can be built over tunnels
Patch against r3070
Submitted to the SF
Attachments
no_tunnels_under_mines_2005_10_19_r3070.patch
(2.13 KiB) Downloaded 248 times
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

I did a search on difficulty level
I though it was saved within the game, well.. I think I was wrong.
I did found out it was saved in the config file instead...
Although I could be wrong... again... :roll:

From settings_gui.c

Code: Select all

void SetDifficultyLevel(int mode, GameOptions *gm_opt)
{
	int i;
	assert(mode <= 3);

	gm_opt->diff_level = mode;
	if (mode != 3) { // not custom
		for (i = 0; i != GAME_DIFFICULTY_NUM; i++)
			((int*)&gm_opt->diff)[i] = _default_game_diff[mode][i];
	}
}
and

Code: Select all

DoCommandP(0, -1, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
Now, following the path of CMD_CHANGE_DIFFICULTY_LEVEL, you fall into misc_cmd.c , function

Code: Select all

int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
So, I guess your patch would be complete if we can make that difficulty level thing going on... I guess! :)
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
Prof. Frink
Tycoon
Tycoon
Posts: 3849
Joined: 20 Jan 2003 14:51
Location: Broadstone, Dorset
Contact:

Post by Prof. Frink »

MeusH: Maybe you should make the 'tunnel through mineshafts' cheat part of the 'crossing tunnels' cheat.
Rename it to something like "Allow tunnels through undergound obstacles"
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

belugas wrote:I did a search on difficulty level
I though it was saved within the game, well.. I think I was wrong.
I did found out it was saved in the config file instead...
Although I could be wrong... again... :roll:

From settings_gui.c

Code: Select all

void SetDifficultyLevel(int mode, GameOptions *gm_opt)
{
	int i;
	assert(mode <= 3);

	gm_opt->diff_level = mode;
	if (mode != 3) { // not custom
		for (i = 0; i != GAME_DIFFICULTY_NUM; i++)
			((int*)&gm_opt->diff)[i] = _default_game_diff[mode][i];
	}
}
and

Code: Select all

DoCommandP(0, -1, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
Now, following the path of CMD_CHANGE_DIFFICULTY_LEVEL, you fall into misc_cmd.c , function

Code: Select all

int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
So, I guess your patch would be complete if we can make that difficulty level thing going on... I guess! :)
Is it the right thread you wanted to post? Sorry but I don't know what do you mean... You mean adding option to the difficulity settings that would allow to dig through obstacles?
Prof. Frink wrote:MeusH: Maybe you should make the 'tunnel through mineshafts' cheat part of the 'crossing tunnels' cheat.
Rename it to something like "Allow tunnels through undergound obstacles"
I'll see if it won't break the savegame and upload new version if possible. Thank you for the naming idea, too :)
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

MeusH wrote:
belugas wrote:Suggestion : what about "parametrizing" the "depth" at which one can drill a tunnel?
It could be linked to a difficulty setting...
Yes, if I go into enchancing this and keeping-not-as-simple, I'd do this.
I'd also make a cheat that allows to build such a tunnels...
belugas wrote:But I think that cheat,as well as difficulty levels, are saved within the game.
Is there room for new stuff on it? Got to check it out!
This is what I meant.
And that was the result of my search...
I guess I was looking for the wrong thing
:oops:
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Difficulity levels and patches are saved in the .cfg, you can take a look at the more disasters patch.
As for cheats, there is a table, I'll report as soon as I finalize something
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 16 guests