Changeset - r21995:f3d5bc187e13
[Not reviewed]
master
0 3 0
frosch - 10 years ago 2015-02-14 21:55:30
frosch@openttd.org
(svn r27151) -Add: Allow changing max heightlevel in scenario editor.
3 files changed with 26 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/cheat_gui.cpp
Show inline comments
 
@@ -104,49 +104,50 @@ static int32 ClickChangeDateCheat(int32 
 
	YearMonthDay ymd;
 
	ConvertDateToYMD(_date, &ymd);
 

	
 
	p1 = Clamp(p1, MIN_YEAR, MAX_YEAR);
 
	if (p1 == _cur_year) return _cur_year;
 

	
 
	Date new_date = ConvertYMDToDate(p1, ymd.month, ymd.day);
 
	LinkGraphSchedule::Instance()->ShiftDates(new_date - _date);
 
	SetDate(new_date, _date_fract);
 
	EnginesMonthlyLoop();
 
	SetWindowDirty(WC_STATUS_BAR, 0);
 
	InvalidateWindowClassesData(WC_BUILD_STATION, 0);
 
	InvalidateWindowClassesData(WC_BUILD_OBJECT, 0);
 
	ResetSignalVariant();
 
	return _cur_year;
 
}
 

	
 
/**
 
 * Allow (or disallow) a change of the maximum allowed heightlevel.
 
 * @param p1 new value
 
 * @param p2 unused
 
 * @return New value (or unchanged old value) of the maximum
 
 *         allowed heightlevel value.
 
 */
 
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2) {
 
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
 
{
 
	p1 = Clamp(p1, MIN_MAX_HEIGHTLEVEL, MAX_MAX_HEIGHTLEVEL);
 

	
 
	/* Check if at least one mountain on the map is higher than the new value.
 
	 * If yes, disallow the change. */
 
	for (TileIndex t = 0; t < MapSize(); t++) {
 
		if ((int32)TileHeight(t) > p1) {
 
			ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
 
			/* Return old, unchanged value */
 
			return _settings_game.construction.max_heightlevel;
 
		}
 
	}
 

	
 
	/* Execute the change and reload GRF Data */
 
	_settings_game.construction.max_heightlevel = p1;
 
	ReloadNewGRFData();
 

	
 
	/* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
 
	InvalidateWindowClassesData(WC_SMALLMAP, 2);
 

	
 
	return _settings_game.construction.max_heightlevel;
 
}
 

	
 
/** Available cheats. */
 
enum CheatNumbers {
src/settings.cpp
Show inline comments
 
@@ -1256,48 +1256,69 @@ static bool CheckFreeformEdges(int32 p1)
 
			SetTileHeight(TileXY(0, i), 0);
 
			SetTileType(TileXY(0, i), MP_WATER);
 
		}
 
	}
 
	MarkWholeScreenDirty();
 
	return true;
 
}
 

	
 
/**
 
 * Changing the setting "allow multiple NewGRF sets" is not allowed
 
 * if there are vehicles.
 
 */
 
static bool ChangeDynamicEngines(int32 p1)
 
{
 
	if (_game_mode == GM_MENU) return true;
 

	
 
	if (!EngineOverrideManager::ResetToCurrentNewGRFConfig()) {
 
		ShowErrorMessage(STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES, INVALID_STRING_ID, WL_ERROR);
 
		return false;
 
	}
 

	
 
	return true;
 
}
 

	
 
static bool ChangeMaxHeightLevel(int32 p1)
 
{
 
	if (_game_mode == GM_NORMAL) return false;
 
	if (_game_mode != GM_EDITOR) return true;
 

	
 
	/* Check if at least one mountain on the map is higher than the new value.
 
	 * If yes, disallow the change. */
 
	for (TileIndex t = 0; t < MapSize(); t++) {
 
		if ((int32)TileHeight(t) > p1) {
 
			ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
 
			/* Return old, unchanged value */
 
			return false;
 
		}
 
	}
 

	
 
	/* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
 
	InvalidateWindowClassesData(WC_SMALLMAP, 2);
 

	
 
	return true;
 
}
 

	
 
static bool StationCatchmentChanged(int32 p1)
 
{
 
	Station::RecomputeIndustriesNearForAll();
 
	return true;
 
}
 

	
 

	
 
#ifdef ENABLE_NETWORK
 

	
 
static bool UpdateClientName(int32 p1)
 
{
 
	NetworkUpdateClientName();
 
	return true;
 
}
 

	
 
static bool UpdateServerPassword(int32 p1)
 
{
 
	if (strcmp(_settings_client.network.server_password, "*") == 0) {
 
		_settings_client.network.server_password[0] = '\0';
 
	}
 

	
 
	return true;
 
}
 

	
src/table/settings.ini
Show inline comments
 
@@ -7,48 +7,49 @@
 
;
 

	
 
[pre-amble]
 
/* Begin - Callback Functions for the various settings */
 
static bool v_PositionMainToolbar(int32 p1);
 
static bool v_PositionStatusbar(int32 p1);
 
static bool PopulationInLabelActive(int32 p1);
 
static bool RedrawScreen(int32 p1);
 
static bool RedrawSmallmap(int32 p1);
 
static bool StationSpreadChanged(int32 p1);
 
static bool InvalidateBuildIndustryWindow(int32 p1);
 
static bool CloseSignalGUI(int32 p1);
 
static bool InvalidateTownViewWindow(int32 p1);
 
static bool DeleteSelectStationWindow(int32 p1);
 
static bool UpdateConsists(int32 p1);
 
static bool TrainAccelerationModelChanged(int32 p1);
 
static bool RoadVehAccelerationModelChanged(int32 p1);
 
static bool TrainSlopeSteepnessChanged(int32 p1);
 
static bool RoadVehSlopeSteepnessChanged(int32 p1);
 
static bool DragSignalsDensityChanged(int32);
 
static bool TownFoundingChanged(int32 p1);
 
static bool DifficultyNoiseChange(int32 i);
 
static bool MaxNoAIsChange(int32 i);
 
static bool CheckRoadSide(int p1);
 
static bool ChangeMaxHeightLevel(int32 p1);
 
static bool CheckFreeformEdges(int32 p1);
 
static bool ChangeDynamicEngines(int32 p1);
 
static bool StationCatchmentChanged(int32 p1);
 
static bool InvalidateVehTimetableWindow(int32 p1);
 
static bool InvalidateCompanyLiveryWindow(int32 p1);
 
static bool InvalidateNewGRFChangeWindows(int32 p1);
 
static bool InvalidateIndustryViewWindow(int32 p1);
 
static bool InvalidateAISettingsWindow(int32 p1);
 
static bool RedrawTownAuthority(int32 p1);
 
static bool InvalidateCompanyInfrastructureWindow(int32 p1);
 
static bool InvalidateCompanyWindow(int32 p1);
 
static bool ZoomMinMaxChanged(int32 p1);
 

	
 
#ifdef ENABLE_NETWORK
 
static bool UpdateClientName(int32 p1);
 
static bool UpdateServerPassword(int32 p1);
 
static bool UpdateRconPassword(int32 p1);
 
static bool UpdateClientConfigValues(int32 p1);
 
#endif /* ENABLE_NETWORK */
 
/* End - Callback Functions for the various settings */
 

	
 
/* Some settings do not need to be synchronised when playing in multiplayer.
 
 * These include for example the GUI settings and will not be saved with the
 
 * savegame.
 
@@ -361,56 +362,57 @@ length   = 1
 
from     = 97
 
to       = 163
 

	
 
[SDT_OMANY]
 
base     = GameSettings
 
var      = vehicle.road_side
 
type     = SLE_UINT8
 
from     = 97
 
guiflags = SGF_MULTISTRING | SGF_NO_NETWORK
 
def      = 1
 
max      = 1
 
full     = _roadsides
 
str      = STR_CONFIG_SETTING_ROAD_SIDE
 
strhelp  = STR_CONFIG_SETTING_ROAD_SIDE_HELPTEXT
 
strval   = STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT
 
proc     = CheckRoadSide
 

	
 
; Construction
 

	
 
[SDT_VAR]
 
base     = GameSettings
 
var      = construction.max_heightlevel
 
type     = SLE_UINT8
 
from     = 194
 
guiflags = SGF_NEWGAME_ONLY | SGF_NO_NETWORK
 
guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO
 
def      = DEF_MAX_HEIGHTLEVEL
 
min      = MIN_MAX_HEIGHTLEVEL
 
max      = MAX_MAX_HEIGHTLEVEL
 
interval = 1
 
str      = STR_CONFIG_SETTING_MAX_HEIGHTLEVEL
 
strhelp  = STR_CONFIG_SETTING_MAX_HEIGHTLEVEL_HELPTEXT
 
strval   = STR_JUST_INT
 
proc     = ChangeMaxHeightLevel
 
cat      = SC_BASIC
 

	
 
[SDT_BOOL]
 
base     = GameSettings
 
var      = construction.build_on_slopes
 
guiflags = SGF_NO_NETWORK
 
def      = true
 
cat      = SC_EXPERT
 

	
 
[SDT_VAR]
 
base     = GameSettings
 
var      = construction.command_pause_level
 
type     = SLE_UINT8
 
from     = 154
 
guiflags = SGF_MULTISTRING | SGF_NO_NETWORK
 
def      = 1
 
min      = 0
 
max      = 3
 
interval = 1
 
str      = STR_CONFIG_SETTING_COMMAND_PAUSE_LEVEL
 
strhelp  = STR_CONFIG_SETTING_COMMAND_PAUSE_LEVEL_HELPTEXT
 
strval   = STR_CONFIG_SETTING_COMMAND_PAUSE_LEVEL_NO_ACTIONS
 

	
 
[SDT_VAR]
0 comments (0 inline, 0 general)