--- a/console_cmds.c Tue Apr 10 09:49:41 2007 +0000
+++ b/console_cmds.c Tue Apr 10 09:57:35 2007 +0000
@@ -1402,6 +1402,19 @@
return true;
}
+DEF_CONSOLE_CMD(ConListPatches)
+{
+ if (argc == 0) {
+ IConsoleHelp("List patch options. Usage: 'list_patches'");
+ return true;
+ }
+
+ if (argc != 1) return false;
+
+ IConsoleListPatches();
+ return true;
+}
+
DEF_CONSOLE_CMD(ConListDumpVariables)
{
const IConsoleVar *var;
@@ -1482,6 +1495,7 @@
IConsoleCmdRegister("pwd", ConPrintWorkingDirectory);
IConsoleCmdRegister("clear", ConClearBuffer);
IConsoleCmdRegister("patch", ConPatch);
+ IConsoleCmdRegister("list_patches", ConListPatches);
IConsoleAliasRegister("dir", "ls");
IConsoleAliasRegister("del", "rm %+");
--- a/rail_cmd.c Tue Apr 10 09:49:41 2007 +0000
+++ b/rail_cmd.c Tue Apr 10 09:57:35 2007 +0000
@@ -272,7 +272,7 @@
case MP_RAILWAY:
if (!CheckTrackCombination(tile, trackbit, flags) ||
- !EnsureNoVehicle(tile)) {
+ !EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
if (!IsTileOwner(tile, _current_player) ||
@@ -307,7 +307,7 @@
}
#undef M
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
@@ -384,7 +384,7 @@
if (!IsLevelCrossing(tile) ||
GetCrossingRailBits(tile) != trackbit ||
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
- !EnsureNoVehicle(tile)) {
+ !EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
@@ -399,7 +399,7 @@
if (!IsPlainRailTile(tile) ||
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
- !EnsureNoVehicle(tile)) {
+ !EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
@@ -654,7 +654,7 @@
sigvar = HASBIT(p1, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC;
pre_signal = HASBIT(p1, 3);
- if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicle(tile))
+ if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicleOnGround(tile))
return CMD_ERROR;
/* Protect against invalid signal copying */
@@ -833,7 +833,7 @@
if (!ValParamTrackOrientation(track) ||
!IsTileType(tile, MP_RAILWAY) ||
- !EnsureNoVehicle(tile) ||
+ !EnsureNoVehicleOnGround(tile) ||
!HasSignalOnTrack(tile, track)) {
return CMD_ERROR;
}
@@ -890,7 +890,7 @@
if (GetRailType(tile) == totype) return CMD_ERROR;
- if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR;
// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
@@ -993,7 +993,7 @@
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
return CMD_ERROR;
- if (!EnsureNoVehicle(tile))
+ if (!EnsureNoVehicleOnGround(tile))
return CMD_ERROR;
if (flags & DC_EXEC) {
--- a/road_cmd.c Tue Apr 10 09:49:41 2007 +0000
+++ b/road_cmd.c Tue Apr 10 09:57:35 2007 +0000
@@ -308,7 +308,7 @@
if ((existing & pieces) == pieces) {
return_cmd_error(STR_1007_ALREADY_BUILT);
}
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
break;
case ROAD_TILE_CROSSING:
@@ -352,7 +352,7 @@
default: goto do_clear;
}
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
if (flags & DC_EXEC) {
YapfNotifyTrackLayoutChange(tile, FIND_FIRST_BIT(GetTrackBits(tile)));
@@ -436,7 +436,7 @@
if (!IsLevelCrossing(tile)) return CMD_ERROR;
// not owned by me?
- if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!CheckTileOwnership(tile) || !EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
if (GetRailTypeCrossing(tile) == totype) return CMD_ERROR;
@@ -581,7 +581,7 @@
if (p1 > 3) return CMD_ERROR; // check direction
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
tileh = GetTileSlope(tile, NULL);
if (tileh != SLOPE_FLAT && (
@@ -947,7 +947,7 @@
if (t->road_build_months != 0 &&
(DistanceManhattan(t->xy, tile) < 8 || grp != 0) &&
GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) {
- if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicle(tile) && CHANCE16(1, 20)) {
+ if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && CHANCE16(1, 20)) {
StartRoadWorks(tile);
SndPlayTileFx(SND_21_JACKHAMMER, tile);
--- a/settings.c Tue Apr 10 09:49:41 2007 +0000
+++ b/settings.c Tue Apr 10 09:57:35 2007 +0000
@@ -260,7 +260,13 @@
}
} else if (group) {
// find end of keyname
- for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
+ if (*s == '\"') {
+ s++;
+ for (t = s; *t != '\0' && *t != '\"'; t++);
+ if (*t == '\"') *t = ' ';
+ } else {
+ for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
+ }
// it's an item in an existing group
item = ini_item_alloc(group, s, t-s);
@@ -348,11 +354,18 @@
assert(item->value != NULL);
if (item->comment != NULL) fputs(item->comment, f);
+ /* protect item->name with quotes if needed */
+ if (strchr(item->name, ' ') != NULL) {
+ fprintf(f, "\"%s\"", item->name);
+ } else {
+ fprintf(f, "%s", item->name);
+ }
+
/* Don't give an equal sign to list items that don't have a parameter */
if (group->type == IGT_LIST && *item->value == '\0') {
- fprintf(f, "%s\n", item->name);
+ fprintf(f, "\n");
} else {
- fprintf(f, "%s = %s\n", item->name, item->value);
+ fprintf(f, " = %s\n", item->value);
}
}
}
@@ -1800,6 +1813,26 @@
name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max);
}
+void IConsoleListPatches(void)
+{
+ const SettingDesc *sd;
+ IConsolePrintF(_icolour_warn, "All patches with their current value:");
+
+ for (sd = _patch_settings; sd->save.cmd != SL_END; sd++) {
+ char value[80];
+ const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_patches_newgame : &_patches, &sd->save);
+
+ if (sd->desc.cmd == SDT_BOOLX) {
+ snprintf(value, lengthof(value), (*(bool*)ptr == 1) ? "on" : "off");
+ } else {
+ snprintf(value, lengthof(value), "%d", (uint32)ReadValue(ptr, sd->save.conv));
+ }
+ IConsolePrintF(_icolour_def, "%s = %s", sd->desc.name, value);
+ }
+
+ IConsolePrintF(_icolour_warn, "Use 'patch' command to change a value");
+}
+
/** Save and load handler for patches/settings
* @param osd SettingDesc struct containing all information
* @param object can be either NULL in which case we load global variables or
--- a/settings.h Tue Apr 10 09:49:41 2007 +0000
+++ b/settings.h Tue Apr 10 09:57:35 2007 +0000
@@ -71,6 +71,7 @@
bool IConsoleSetPatchSetting(const char *name, int32 value);
void IConsoleGetPatchSetting(const char *name);
+void IConsoleListPatches(void);
const SettingDesc *GetPatchFromName(const char *name, uint *i);
bool SetPatchValue(uint index, const Patches *object, int32 value);
--- a/tunnelbridge_cmd.c Tue Apr 10 09:49:41 2007 +0000
+++ b/tunnelbridge_cmd.c Tue Apr 10 09:57:35 2007 +0000
@@ -675,7 +675,7 @@
endtile = GetOtherBridgeEnd(tile);
- if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(endtile)) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(endtile)) return CMD_ERROR;
direction = GetBridgeRampDirection(tile);
delta = TileOffsByDiagDir(direction);
@@ -828,8 +828,8 @@
endtile = GetOtherBridgeEnd(tile);
- if (!EnsureNoVehicle(tile) ||
- !EnsureNoVehicle(endtile) ||
+ if (!EnsureNoVehicleOnGround(tile) ||
+ !EnsureNoVehicleOnGround(endtile) ||
FindVehicleBetween(tile, endtile, GetBridgeHeightRamp(tile), false) != NULL) {
return_cmd_error(STR_8803_TRAIN_IN_THE_WAY);
}