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

DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

MeusH wrote:Difficulity levels and patches are saved in the .cfg, you can take a look at the more disasters patch.
The difficulty has to be saved both places.

If the difficulty is not saved in the game, how does the game keep you from starting a game on easy, saving late December 2049, changing the difficulty to hard, loading the save, and ending up on the hard high-score chart?
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
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

DaleStan wrote:The difficulty has to be saved both places.
Do you know where in the code it does so? And how? :?:
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
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

I didn't know, but I do now.

After much rummaging around with grep, it's done in misc.c by function SaveLoad_OPTS(). The difficulty settings are stored in _opts.diff.
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
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

You are right Dalestan, I did not searched enough (or lost it along the way) :(

This misc.c file is quite challenging to read...
Does adding a difficulty option would mean a difference in the saved format? Could be. Don't you think?
Leading to incompatible savegames...
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 »

Small problem
misc_gui.c

Code: Select all

static const WindowDesc _cheats_desc = {
	//240, 22, 400, 160,
	240, 22, 400, 170, //XXX can anyone fix that?
	WC_CHEATS,0,
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
	_cheat_widgets,
	CheatsWndProc
};
Window is bigger, indeed, but bottom ten units are transparent\HOM[0]. Grey window background is just not drawn there..
Note, static const CheatEntry _cheats_ui[] (from misc_gui.c, too) is updated with one more entry. Any ideas about resizing windows?

Thank you in advance

[0]-Hall Of Mirrors
User avatar
LordOfThePigs
Route Supervisor
Route Supervisor
Posts: 435
Joined: 01 Jul 2004 10:28
Location: Jura/Switzerland

Post by LordOfThePigs »

You have to fiddle with the widgets, since in OTTD dialogs are transparent by default until you put some widgets on top of it (ie: there is no such thing as a grey background, just one or more window widgets that play this role). so you probably want to change this (around line 1730)

Code: Select all

{      WWT_PANEL,   RESIZE_NONE,    14,     0,   399,    14,   159, 0x0,					STR_NULL},
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   399,    14,   159, 0x0,					STR_CHEATS_TIP},
to this

Code: Select all

{      WWT_PANEL,   RESIZE_NONE,    14,     0,   399,    14,   169, 0x0,					STR_NULL},
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   399,    14,   169, 0x0,					STR_CHEATS_TIP},
Sometimes I'm told "Brilliant"...
Sometimes I'm told "Charming"...
And Often I'm told "Shut Up"!
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

belugas wrote:Does adding a difficulty option would mean a difference in the saved format?
It could, depending on where you put it. If you put it at the end, then nothing should break, AFAICT.

To actually save/load the new setting properly, it looks like you need to update the _game_opt_desc array, and, to make that work, you'll have to update the savegame version too.
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
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

The problem! In fact, it existed in previous diffs.

Code: Select all

		if (!_cheats.tunnel_obstacles.value) {
			// 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-=8) //loop throught all height levels
					for(z=128;z>0;z--) //loop throught all height levels
						if (!CheckTunnelInWay(cur_tile, z)) {//to check for tunnels
							return false; //there is a tunnel below
						}
					
				default:
					break;
			}
		}
from industry_cmd.c
Will not return false even if there is a tunnel below.
Changing

Code: Select all

if (!CheckTunnelInWay(cur_tile, z)) {//to check for tunnels
							return false; //there is a tunnel below
						}
to

Code: Select all

						return false;
will return false everytime.

The problem is that CheckTunnelInWay causes some problems and doesn't really work.
Diff against r3070 attached.
I need help!
Attachments
no_tunnels_under_mines_2005_10_21_r3070.patch
diff against r3070
(5.47 KiB) Downloaded 136 times
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

No more me multiposting. I think it is finished [sourceforge].
Features:

Cheat. If disabled:
Tunnels can't be built under shafty industries
Industries with shafts can't be built over tunnels

Diff against r3076

Request .exe? Post, and I'll attach it.
Attachments
no_tunnels_under_mines_2005_10_21_r3076.patch
Diff against r3076
(5.44 KiB) Downloaded 148 times
theleha
Engineer
Engineer
Posts: 3
Joined: 11 Jul 2007 08:00

Post by theleha »

The idea of no tunnels through underground obstacles are great.

But why are a tunnel actually stright, at the same level?
Wouldn't it be more realistic if you could make corners and hills in a tunnel, to alow for an exit at another level, go under or over another tunnel, or avoid the cubes of industry under ground.

I realize that this feature require som serious coding, but the possibilities would be realy amazing!
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Post by Bilbo »

theleha wrote:The idea of no tunnels through underground obstacles are great.

But why are a tunnel actually stright, at the same level?
Wouldn't it be more realistic if you could make corners and hills in a tunnel, to alow for an exit at another level, go under or over another tunnel, or avoid the cubes of industry under ground.

I realize that this feature require som serious coding, but the possibilities would be realy amazing!
Well, since you can't place signals in tunnels and you can't see existing tunnels (hmm .. maybe someone will make a patch to allow seeing existing tunnels?) I think such feature will not get so widespread use as you may expect :)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google [Bot] and 7 guests