Page 2 of 2

Posted: 20 Oct 2005 19:29
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?

Posted: 20 Oct 2005 19:44
by belugas
DaleStan wrote:The difficulty has to be saved both places.
Do you know where in the code it does so? And how? :?:

Posted: 20 Oct 2005 20:27
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.

Posted: 20 Oct 2005 20:54
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...

Posted: 20 Oct 2005 21:57
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

Posted: 20 Oct 2005 22:32
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},

Posted: 20 Oct 2005 23:36
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.

Posted: 21 Oct 2005 20:15
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!

Posted: 21 Oct 2005 21:44
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.

Posted: 11 Jul 2007 13:11
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!

Posted: 11 Jul 2007 13:47
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 :)