(svn r13265) [NoAI] -Sync with trunk r13185:13264.
--- a/projects/openttd_vs80.vcproj Mon May 26 11:36:42 2008 +0000
+++ b/projects/openttd_vs80.vcproj Mon May 26 13:52:59 2008 +0000
@@ -508,6 +508,10 @@
>
</File>
<File
+ RelativePath=".\..\src\console_gui.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\currency.cpp"
>
</File>
@@ -880,7 +884,19 @@
>
</File>
<File
- RelativePath=".\..\src\console.h"
+ RelativePath=".\..\src\console_func.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\console_gui.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\console_internal.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\console_type.h"
>
</File>
<File
@@ -2104,6 +2120,34 @@
>
</File>
<File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdblob.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdio.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdstring.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdsystem.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqfuncproto.h"
>
</File>
@@ -2976,10 +3020,6 @@
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_settings.h"
- >
- </File>
- <File
RelativePath=".\..\src\yapf\yapf_ship.cpp"
>
</File>
--- a/projects/openttd_vs90.vcproj Mon May 26 11:36:42 2008 +0000
+++ b/projects/openttd_vs90.vcproj Mon May 26 13:52:59 2008 +0000
@@ -505,6 +505,10 @@
>
</File>
<File
+ RelativePath=".\..\src\console_gui.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\currency.cpp"
>
</File>
@@ -877,7 +881,19 @@
>
</File>
<File
- RelativePath=".\..\src\console.h"
+ RelativePath=".\..\src\console_func.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\console_gui.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\console_internal.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\console_type.h"
>
</File>
<File
@@ -2101,6 +2117,34 @@
>
</File>
<File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdblob.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdblobimpl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdio.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdmath.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\sqstdlib\sqstdstream.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdstring.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\3rdparty\squirrel\include\sqstdsystem.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\3rdparty\squirrel\squirrel\sqfuncproto.h"
>
</File>
@@ -2973,10 +3017,6 @@
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_settings.h"
- >
- </File>
- <File
RelativePath=".\..\src\yapf\yapf_ship.cpp"
>
</File>
--- a/source.list Mon May 26 11:36:42 2008 +0000
+++ b/source.list Mon May 26 13:52:59 2008 +0000
@@ -13,6 +13,7 @@
command.cpp
console.cpp
console_cmds.cpp
+console_gui.cpp
currency.cpp
date.cpp
debug.cpp
@@ -145,7 +146,10 @@
cmd_helper.h
command_func.h
command_type.h
-console.h
+console_func.h
+console_gui.h
+console_internal.h
+console_type.h
cheat_func.h
cheat_type.h
currency.h
@@ -470,6 +474,13 @@
3rdparty/squirrel/squirrel/sqclosure.h
3rdparty/squirrel/squirrel/sqcompiler.h
3rdparty/squirrel/include/sqstdaux.h
+3rdparty/squirrel/include/sqstdblob.h
+3rdparty/squirrel/sqstdlib/sqstdblobimpl.h
+3rdparty/squirrel/include/sqstdio.h
+3rdparty/squirrel/include/sqstdmath.h
+3rdparty/squirrel/sqstdlib/sqstdstream.h
+3rdparty/squirrel/include/sqstdstring.h
+3rdparty/squirrel/include/sqstdsystem.h
3rdparty/squirrel/squirrel/sqfuncproto.h
3rdparty/squirrel/squirrel/sqfuncstate.h
3rdparty/squirrel/squirrel/sqlexer.h
@@ -703,7 +714,6 @@
yapf/yapf_node_road.hpp
yapf/yapf_rail.cpp
yapf/yapf_road.cpp
-yapf/yapf_settings.h
yapf/yapf_ship.cpp
# Video
--- a/src/ai/ai.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/ai/ai.cpp Mon May 26 13:52:59 2008 +0000
@@ -44,14 +44,14 @@
if (!_ai_enabled) return;
/* Don't do anything if we are a network-client, or the AI has been disabled */
- if (_networking && (!_network_server || !_patches.ai_in_multiplayer)) return;
+ if (_networking && (!_network_server || !_settings.ai.ai_in_multiplayer)) return;
/* New tick */
_ai_frame_counter++;
/* Make sure the AI follows the difficulty rule.. */
- assert(_opt.diff.competitor_speed <= 4);
- if ((_ai_frame_counter & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0) return;
+ assert(_settings.difficulty.competitor_speed <= 4);
+ if ((_ai_frame_counter & ((1 << (4 - _settings.difficulty.competitor_speed)) - 1)) != 0) return;
/* Check for AI-client (so joining a network with an AI) */
if (!_networking || _network_server) {
@@ -199,7 +199,7 @@
/* If in network, and server, possible AI */
if (_networking && _network_server) {
/* Do we want AIs in multiplayer? */
- if (!_patches.ai_in_multiplayer) return false;
+ if (!_settings.ai.ai_in_multiplayer) return false;
}
return true;
--- a/src/ai/api/ai_airport.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/ai/api/ai_airport.cpp Mon May 26 13:52:59 2008 +0000
@@ -46,7 +46,7 @@
/* static */ int32 AIAirport::GetAirportCoverageRadius(AirportType type)
{
if (type > AT_HELISTATION) return -1;
- return _patches.modified_catchment ? ::GetAirport(type)->catchment : (uint)CA_UNMODIFIED;
+ return _settings.station.modified_catchment ? ::GetAirport(type)->catchment : (uint)CA_UNMODIFIED;
}
/* static */ bool AIAirport::BuildAirport(TileIndex tile, AirportType type)
--- a/src/ai/api/ai_bridge.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/ai/api/ai_bridge.cpp Mon May 26 13:52:59 2008 +0000
@@ -77,7 +77,7 @@
if (!IsValidBridge(bridge_id)) return -1;
uint max = ::GetBridgeSpec(bridge_id)->max_length;
- if (max >= 16 && _patches.longbridges) max = 100;
+ if (max >= 16 && _settings.construction.longbridges) max = 100;
return max + 2;
}
--- a/src/ai/api/ai_engine.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/ai/api/ai_engine.cpp Mon May 26 13:52:59 2008 +0000
@@ -134,7 +134,7 @@
case VEH_AIRCRAFT: {
const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id);
- return vi->max_speed / _patches.plane_speed;
+ return vi->max_speed / _settings.vehicle.plane_speed;
} break;
default: NOT_REACHED();
--- a/src/ai/api/ai_event_types.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/ai/api/ai_event_types.cpp Mon May 26 13:52:59 2008 +0000
@@ -104,7 +104,7 @@
case VEH_AIRCRAFT: {
const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine);
- return vi->max_speed / _patches.plane_speed;
+ return vi->max_speed / _settings.vehicle.plane_speed;
} break;
default: NOT_REACHED();
--- a/src/ai/api/ai_station.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/ai/api/ai_station.cpp Mon May 26 13:52:59 2008 +0000
@@ -79,7 +79,7 @@
DEBUG(ai, 0, "GetCoverageRadius(): coverage radius of airports needs to be requested via AIAirport::GetAirportCoverageRadius(), as it requires AirportType");
return -1;
}
- if (!_patches.modified_catchment) return CA_UNMODIFIED;
+ if (!_settings.station.modified_catchment) return CA_UNMODIFIED;
switch (type) {
case STATION_TRAIN: return CA_TRAIN;
--- a/src/ai/api/ai_tile.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/ai/api/ai_tile.cpp Mon May 26 13:52:59 2008 +0000
@@ -107,7 +107,7 @@
if (!::IsValidTile(tile)) return false;
AcceptedCargo accepts;
- ::GetAcceptanceAroundTiles(accepts, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED);
+ ::GetAcceptanceAroundTiles(accepts, tile, width, height, _settings.station.modified_catchment ? radius : (uint)CA_UNMODIFIED);
return accepts[cargo_type];
}
@@ -116,7 +116,7 @@
if (!::IsValidTile(tile)) return false;
AcceptedCargo produced;
- ::GetProductionAroundTiles(produced, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED);
+ ::GetProductionAroundTiles(produced, tile, width, height, _settings.station.modified_catchment ? radius : (uint)CA_UNMODIFIED);
return produced[cargo_type];
}
--- a/src/ai/api/ai_tilelist.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/ai/api/ai_tilelist.cpp Mon May 26 13:52:59 2008 +0000
@@ -87,7 +87,7 @@
if (!cargo_accepts) return;
}
- if (!_patches.modified_catchment) radius = CA_UNMODIFIED;
+ if (!_settings.station.modified_catchment) radius = CA_UNMODIFIED;
BEGIN_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
if (!::IsValidTile(cur_tile)) continue;
@@ -126,7 +126,7 @@
if (!cargo_produces) return;
}
- if (!_patches.modified_catchment) radius = CA_UNMODIFIED;
+ if (!_settings.station.modified_catchment) radius = CA_UNMODIFIED;
BEGIN_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
if (!::IsValidTile(cur_tile)) continue;
--- a/src/aircraft_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/aircraft_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -288,7 +288,7 @@
}
UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT);
- if (unit_num > _patches.max_aircraft)
+ if (unit_num > _settings.vehicle.max_aircraft)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) {
@@ -405,7 +405,7 @@
v->u.air.targetairport = GetStationIndex(tile);
v->SetNext(u);
- v->service_interval = _patches.servint_aircraft;
+ v->service_interval = _settings.vehicle.servint_aircraft;
v->date_of_last_service = _date;
v->build_year = u->build_year = _cur_year;
@@ -665,7 +665,7 @@
static void CheckIfAircraftNeedsService(Vehicle *v)
{
- if (_patches.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
+ if (_settings.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
if (v->IsInDepot()) {
VehicleServiceInDepot(v);
return;
@@ -888,7 +888,7 @@
/* Adjust speed limits by plane speed factor to prevent taxiing
* and take-off speeds being too low. */
- speed_limit *= _patches.plane_speed;
+ speed_limit *= _settings.vehicle.plane_speed;
if (v->u.air.cached_max_speed < speed_limit) {
if (v->cur_speed < speed_limit) hard_limit = false;
@@ -906,7 +906,7 @@
* speeds to that aircraft do not get to taxi speed straight after
* touchdown. */
if (!hard_limit && v->cur_speed > speed_limit) {
- speed_limit = v->cur_speed - max(1, ((v->cur_speed * v->cur_speed) / 16384) / _patches.plane_speed);
+ speed_limit = v->cur_speed - max(1, ((v->cur_speed * v->cur_speed) / 16384) / _settings.vehicle.plane_speed);
}
spd = min(v->cur_speed + (spd >> 8) + (v->subspeed < t), speed_limit);
@@ -917,12 +917,12 @@
/* updates statusbar only if speed have changed to save CPU time */
if (spd != v->cur_speed) {
v->cur_speed = spd;
- if (_patches.vehicle_speed)
+ if (_settings.gui.vehicle_speed)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
}
/* Adjust distance moved by plane speed setting */
- if (_patches.plane_speed > 1) spd /= _patches.plane_speed;
+ if (_settings.vehicle.plane_speed > 1) spd /= _settings.vehicle.plane_speed;
if (!(v->direction & 1)) spd = spd * 3 / 4;
@@ -1605,7 +1605,7 @@
AircraftEventHandler_EnterTerminal(v, apc);
/* on an airport with helipads, a helicopter will always land there
* and get serviced at the same time - patch setting */
- if (_patches.serviceathelipad) {
+ if (_settings.order.serviceathelipad) {
if (v->subtype == AIR_HELICOPTER && apc->helipads != NULL) {
/* an exerpt of ServiceAircraft, without the invisibility stuff */
v->date_of_last_service = _date;
--- a/src/airport.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/airport.cpp Mon May 26 13:52:59 2008 +0000
@@ -43,7 +43,7 @@
_airport_fta_dummy,
NULL,
0,
- 0, 0,
+ 0, 0, 0,
0,
0
);
@@ -57,7 +57,7 @@
_airport_fta_country,
_airport_depots_country,
lengthof(_airport_depots_country),
- 4, 3,
+ 4, 3, 3,
0,
4
);
@@ -71,7 +71,7 @@
_airport_fta_city,
_airport_depots_city,
lengthof(_airport_depots_city),
- 6, 6,
+ 6, 6, 5,
0,
5
);
@@ -85,7 +85,7 @@
_airport_fta_metropolitan,
_airport_depots_metropolitan,
lengthof(_airport_depots_metropolitan),
- 6, 6,
+ 6, 6, 8,
0,
6
);
@@ -99,7 +99,7 @@
_airport_fta_international,
_airport_depots_international,
lengthof(_airport_depots_international),
- 7, 7,
+ 7, 7, 17,
0,
8
);
@@ -113,7 +113,7 @@
_airport_fta_intercontinental,
_airport_depots_intercontinental,
lengthof(_airport_depots_intercontinental),
- 9, 11,
+ 9, 11, 25,
0,
10
);
@@ -127,7 +127,7 @@
_airport_fta_heliport_oilrig,
NULL,
0,
- 1, 1,
+ 1, 1, 1,
60,
4
);
@@ -141,7 +141,7 @@
_airport_fta_heliport_oilrig,
NULL,
0,
- 1, 1,
+ 1, 1, 0,
54,
3
);
@@ -155,7 +155,7 @@
_airport_fta_commuter,
_airport_depots_commuter,
lengthof(_airport_depots_commuter),
- 5, 4,
+ 5, 4, 4,
0,
4
);
@@ -169,7 +169,7 @@
_airport_fta_helidepot,
_airport_depots_helidepot,
lengthof(_airport_depots_helidepot),
- 2, 2,
+ 2, 2, 2,
0,
4
);
@@ -183,7 +183,7 @@
_airport_fta_helistation,
_airport_depots_helistation,
lengthof(_airport_depots_helistation),
- 4, 2,
+ 4, 2, 3,
0,
4
);
@@ -225,6 +225,7 @@
const byte nof_depots_,
uint size_x_,
uint size_y_,
+ byte noise_level_,
byte delta_z_,
byte catchment_
) :
@@ -238,6 +239,7 @@
entry_points(entry_points_),
size_x(size_x_),
size_y(size_y_),
+ noise_level(noise_level_),
delta_z(delta_z_),
catchment(catchment_)
{
@@ -475,7 +477,7 @@
{
uint32 mask = 0;
- if (_cur_year < 1960 || _patches.always_small_airport) SetBit(mask, 0); // small airport
+ if (_cur_year < 1960 || _settings.station.always_small_airport) SetBit(mask, 0); // small airport
if (_cur_year >= 1955) SetBit(mask, 1); // city airport
if (_cur_year >= 1963) SetBit(mask, 2); // heliport
if (_cur_year >= 1980) SetBit(mask, 3); // metropolitan airport
--- a/src/airport.h Mon May 26 11:36:42 2008 +0000
+++ b/src/airport.h Mon May 26 13:52:59 2008 +0000
@@ -7,6 +7,7 @@
#include "direction_type.h"
#include "map_type.h"
+#include "tile_type.h"
enum {MAX_TERMINALS = 10};
enum {MAX_HELIPADS = 4};
@@ -144,6 +145,7 @@
byte nof_depots,
uint size_x,
uint size_y,
+ uint8 noise_level,
byte delta_z,
byte catchment
);
@@ -167,6 +169,7 @@
const byte *entry_points; ///< when an airplane arrives at this airport, enter it at position entry_point, index depends on direction
byte size_x;
byte size_y;
+ uint8 noise_level; ///< noise that this airport generates
byte delta_z; ///< Z adjustment for helicopter pads
byte catchment;
};
@@ -194,4 +197,8 @@
*/
uint32 GetValidAirports();
+
+/* Calculate the noise this type airport will generate */
+uint8 GetAirportNoiseLevelForTown(const AirportFTAClass *afc, TileIndex town_tile, TileIndex tile);
+
#endif /* AIRPORT_H */
--- a/src/airport_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/airport_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -12,6 +12,7 @@
#include "airport.h"
#include "sound_func.h"
#include "window_func.h"
+#include "strings_func.h"
#include "settings_type.h"
#include "viewport_func.h"
#include "gfx_func.h"
@@ -25,7 +26,7 @@
static byte _selected_airport_type;
-static void ShowBuildAirportPicker();
+static void ShowBuildAirportPicker(Window *parent);
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
@@ -50,7 +51,7 @@
static void BuildAirClick_Airport(Window *w)
{
- if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, VHM_RECT, PlaceAirport)) ShowBuildAirportPicker();
+ if (HandlePlacePushButton(w, ATW_AIRPORT, SPR_CURSOR_AIRPORT, VHM_RECT, PlaceAirport)) ShowBuildAirportPicker(w);
}
static void BuildAirClick_Demolish(Window *w)
@@ -69,12 +70,12 @@
BuildAirToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
this->FindWindowPlacementAndResize(desc);
- if (_patches.link_terraform_toolbar) ShowTerraformToolbar(this);
+ if (_settings.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}
~BuildAirToolbarWindow()
{
- if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
+ if (_settings.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
}
virtual void OnPaint()
@@ -171,18 +172,23 @@
public:
- AirportPickerWindow(const WindowDesc *desc) : PickerWindowBase(desc)
+ AirportPickerWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_station_show_coverage);
this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _station_show_coverage);
this->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
+ if (_settings.economy.station_noise_level) {
+ ResizeWindowForWidget(this, BAW_BOTTOMPANEL, 0, 10);
+ }
+
this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
{
int i; // airport enabling loop
+ uint16 y_noise_offset = 0;
uint32 avail_airports;
const AirportFTAClass *airport;
@@ -205,13 +211,22 @@
airport = GetAirport(_selected_airport_type);
SetTileSelectSize(airport->size_x, airport->size_y);
- int rad = _patches.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
+ int rad = _settings.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
this->DrawWidgets();
+
+ /* only show the station (airport) noise, if the noise option is activated */
+ if (_settings.economy.station_noise_level) {
+ /* show the noise of the selected airport */
+ SetDParam(0, airport->noise_level);
+ DrawString(2, 206, STR_STATION_NOISE, 0);
+ y_noise_offset = 10;
+ }
+
/* strings such as 'Size' and 'Coverage Area' */
- int text_end = DrawStationCoverageAreaText(2, 206, SCT_ALL, rad, false);
+ int text_end = DrawStationCoverageAreaText(2, this->widget[BAW_BTN_DOHILIGHT].bottom + 4 + y_noise_offset, SCT_ALL, rad, false);
text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4;
if (text_end != this->widget[BAW_BOTTOMPANEL].bottom) {
this->SetDirty();
@@ -283,9 +298,9 @@
_build_airport_picker_widgets,
};
-static void ShowBuildAirportPicker()
+static void ShowBuildAirportPicker(Window *parent)
{
- new AirportPickerWindow(&_build_airport_desc);
+ new AirportPickerWindow(&_build_airport_desc, parent);
}
void InitializeAirportGui()
--- a/src/autoslope.h Mon May 26 11:36:42 2008 +0000
+++ b/src/autoslope.h Mon May 26 13:52:59 2008 +0000
@@ -38,7 +38,7 @@
*/
static inline bool AutoslopeEnabled()
{
- return (_patches.autoslope &&
+ return (_settings.construction.autoslope &&
(IsValidPlayer(_current_player) ||
(_current_player == OWNER_NONE && _game_mode == GM_EDITOR)));
}
--- a/src/bridge_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/bridge_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -183,7 +183,7 @@
uint y = this->widget[BBSW_BRIDGE_LIST].top + 2;
- for (uint i = this->vscroll.pos; (i < (this->vscroll.cap + this->vscroll.pos)) && (i < this->bridges->list_length); i++) {
+ for (int i = this->vscroll.pos; (i < (this->vscroll.cap + this->vscroll.pos)) && (i < this->bridges->list_length); i++) {
const BridgeSpec *b = this->bridges->sort_list[i].spec;
SetDParam(2, this->bridges->sort_list[i].cost);
--- a/src/build_vehicle_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/build_vehicle_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -506,7 +506,7 @@
y += 10;
/* Wagon speed limit, displayed if above zero */
- if (_patches.wagon_speed_limits) {
+ if (_settings.vehicle.wagon_speed_limits) {
uint max_speed = GetEngineProperty(engine_number, 0x09, rvi->max_speed);
if (max_speed > 0) {
SetDParam(0, max_speed * 10 / 16);
@@ -544,7 +544,7 @@
y += 10;
/* Max tractive effort - not applicable if old acceleration or maglev */
- if (_patches.realistic_acceleration && rvi->railtype != RAILTYPE_MAGLEV) {
+ if (_settings.vehicle.realistic_acceleration && rvi->railtype != RAILTYPE_MAGLEV) {
SetDParam(0, ((weight << multihead) * 10 * GetEngineProperty(engine_number, 0x1F, rvi->tractive_effort)) / 256);
DrawString(x, y, STR_PURCHASE_INFO_MAX_TE, TC_FROMSTRING);
y += 10;
@@ -800,7 +800,6 @@
AirportFTAClass::Flags flags;
RoadTypes roadtypes;
} filter;
- byte sel_index; ///< deprecated value, used for 'unified' ship and road
bool descending_sort_order;
byte sort_criteria;
bool regenerate_list;
--- a/src/cheat_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/cheat_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -64,9 +64,9 @@
{
if (p1 == -1) p1 = 3;
if (p1 == 4) p1 = 0;
- _opt.landscape = p1;
+ _settings.game_creation.landscape = p1;
ReloadNewGRFData();
- return _opt.landscape;
+ return _settings.game_creation.landscape;
}
extern void EnginesMonthlyLoop();
@@ -100,15 +100,15 @@
};
static const CheatEntry _cheats_ui[] = {
- {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
- {SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat },
- {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL },
- {SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat},
- {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
+ {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
+ {SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat },
+ {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL },
+ {SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_settings.game_creation.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat},
+ {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
};
@@ -125,6 +125,7 @@
CheatWindow(const WindowDesc *desc) : Window(desc)
{
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
--- a/src/clear_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/clear_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -218,7 +218,7 @@
{
TileLoopClearHelper(tile);
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_TROPIC: TileLoopClearDesert(tile); break;
case LT_ARCTIC: TileLoopClearAlps(tile); break;
}
@@ -336,7 +336,7 @@
} else {
td->str = _clear_land_str[GetClearGround(tile)];
}
- td->owner = GetTileOwner(tile);
+ td->owner[0] = GetTileOwner(tile);
}
static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID new_player)
@@ -346,7 +346,7 @@
void InitializeClearLand()
{
- _opt.snow_line = _patches.snow_line_height * TILE_HEIGHT;
+ _settings.game_creation.snow_line = _settings.game_creation.snow_line_height * TILE_HEIGHT;
}
static CommandCost TerraformTile_Clear(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
--- a/src/command.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/command.cpp Mon May 26 13:52:59 2008 +0000
@@ -152,7 +152,6 @@
DEF_COMMAND(CmdSetRoadDriveSide);
-DEF_COMMAND(CmdChangeDifficultyLevel);
DEF_COMMAND(CmdChangePatchSetting);
DEF_COMMAND(CmdStartStopShip);
@@ -304,7 +303,6 @@
{CmdDoTownAction, 0}, /* CMD_DO_TOWN_ACTION */
{CmdSetRoadDriveSide, CMD_SERVER}, /* CMD_SET_ROAD_DRIVE_SIDE */
- {CmdChangeDifficultyLevel, CMD_SERVER}, /* CMD_CHANGE_DIFFICULTY_LEVEL */
{CmdStartStopShip, 0}, /* CMD_START_STOP_SHIP */
{CmdSellShip, 0}, /* CMD_SELL_SHIP */
--- a/src/command_type.h Mon May 26 11:36:42 2008 +0000
+++ b/src/command_type.h Mon May 26 13:52:59 2008 +0000
@@ -233,8 +233,6 @@
CMD_SET_ROAD_DRIVE_SIDE, ///< set the side where the road vehicles drive
- CMD_CHANGE_DIFFICULTY_LEVEL, ///< change the difficult of a game (each setting for it own)
-
CMD_START_STOP_SHIP, ///< start/stop a ship
CMD_SELL_SHIP, ///< sell a ship
CMD_BUILD_SHIP, ///< build a new ship
--- a/src/console.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/console.cpp Mon May 26 13:52:59 2008 +0000
@@ -3,23 +3,15 @@
/** @file console.cpp Handling of the in-game console. */
#include "stdafx.h"
-#include "openttd.h"
-#include "gui.h"
-#include "textbuf_gui.h"
-#include "window_gui.h"
-#include "variables.h"
-#include <stdarg.h>
-#include <string.h>
-#include "console.h"
-#include "network/network.h"
+#include "console_internal.h"
#include "network/network_data.h"
#include "network/network_server.h"
#include "core/alloc_func.hpp"
-#include "window_func.h"
#include "string_func.h"
-#include "gfx_func.h"
#include "rev.h"
+#include <stdarg.h>
+
#include "table/strings.h"
#define ICON_BUFFER 79
@@ -35,264 +27,21 @@
IConsoleVar *_iconsole_vars; ///< list of registred vars
IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
-/* console colors/modes */
-byte _icolour_def;
-byte _icolour_err;
-byte _icolour_warn;
-byte _icolour_dbg;
-byte _icolour_cmd;
-IConsoleModes _iconsole_mode;
-
-/* ** main console ** */
-static char *_iconsole_buffer[ICON_BUFFER + 1];
-static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
-static Textbuf _iconsole_cmdline;
-
/* ** stdlib ** */
byte _stdlib_developer = 1;
bool _stdlib_con_developer = false;
FILE *_iconsole_output_file;
-/* ** main console cmd buffer ** */
-static char *_iconsole_history[ICON_HISTORY_SIZE];
-static byte _iconsole_historypos;
-
-/* *************** *
- * end of header *
- * *************** */
-
-static void IConsoleClearCommand()
-{
- memset(_iconsole_cmdline.buf, 0, ICON_CMDLN_SIZE);
- _iconsole_cmdline.length = 0;
- _iconsole_cmdline.width = 0;
- _iconsole_cmdline.caretpos = 0;
- _iconsole_cmdline.caretxoffs = 0;
- SetWindowDirty(FindWindowById(WC_CONSOLE, 0));
-}
-
-static inline void IConsoleResetHistoryPos() {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
-
-
-static void IConsoleHistoryAdd(const char *cmd);
-static void IConsoleHistoryNavigate(int direction);
-
-struct IConsoleWindow : Window
-{
- static byte scroll;
-
- IConsoleWindow(const WindowDesc *desc) : Window(desc)
- {
- _iconsole_mode = ICONSOLE_OPENED;
- SetBit(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
-
- this->height = _screen.height / 3;
- this->width = _screen.width;
- }
-
- ~IConsoleWindow()
- {
- _iconsole_mode = ICONSOLE_CLOSED;
- ClrBit(_no_scroll, SCROLL_CON);
- }
-
- virtual void OnPaint()
- {
- int i = IConsoleWindow::scroll;
- int max = (this->height / ICON_LINE_HEIGHT) - 1;
- int delta = 0;
- GfxFillRect(this->left, this->top, this->width, this->height - 1, 0);
- while ((i > 0) && (i > IConsoleWindow::scroll - max) && (_iconsole_buffer[i] != NULL)) {
- DoDrawString(_iconsole_buffer[i], 5,
- this->height - (IConsoleWindow::scroll + 2 - i) * ICON_LINE_HEIGHT, _iconsole_cbuffer[i]);
- i--;
- }
- /* If the text is longer than the window, don't show the starting ']' */
- delta = this->width - 10 - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH;
- if (delta > 0) {
- DoDrawString("]", 5, this->height - ICON_LINE_HEIGHT, _icolour_cmd);
- delta = 0;
- }
-
- DoDrawString(_iconsole_cmdline.buf, 10 + delta, this->height - ICON_LINE_HEIGHT, _icolour_cmd);
-
- if (_iconsole_cmdline.caret) {
- DoDrawString("_", 10 + delta + _iconsole_cmdline.caretxoffs, this->height - ICON_LINE_HEIGHT, TC_WHITE);
- }
- }
-
- virtual void OnMouseLoop()
- {
- if (HandleCaret(&_iconsole_cmdline)) this->SetDirty();
- }
-
- virtual EventState OnKeyPress(uint16 key, uint16 keycode)
- {
- switch (keycode) {
- case WKC_UP:
- IConsoleHistoryNavigate(+1);
- this->SetDirty();
- break;
-
- case WKC_DOWN:
- IConsoleHistoryNavigate(-1);
- this->SetDirty();
- break;
-
- case WKC_SHIFT | WKC_PAGEUP:
- if (IConsoleWindow::scroll - (this->height / ICON_LINE_HEIGHT) - 1 < 0) {
- IConsoleWindow::scroll = 0;
- } else {
- IConsoleWindow::scroll -= (this->height / ICON_LINE_HEIGHT) - 1;
- }
- this->SetDirty();
- break;
-
- case WKC_SHIFT | WKC_PAGEDOWN:
- if (IConsoleWindow::scroll + (this->height / ICON_LINE_HEIGHT) - 1 > ICON_BUFFER) {
- IConsoleWindow::scroll = ICON_BUFFER;
- } else {
- IConsoleWindow::scroll += (this->height / ICON_LINE_HEIGHT) - 1;
- }
- this->SetDirty();
- break;
-
- case WKC_SHIFT | WKC_UP:
- if (IConsoleWindow::scroll <= 0) {
- IConsoleWindow::scroll = 0;
- } else {
- --IConsoleWindow::scroll;
- }
- this->SetDirty();
- break;
-
- case WKC_SHIFT | WKC_DOWN:
- if (IConsoleWindow::scroll >= ICON_BUFFER) {
- IConsoleWindow::scroll = ICON_BUFFER;
- } else {
- ++IConsoleWindow::scroll;
- }
- this->SetDirty();
- break;
-
- case WKC_BACKQUOTE:
- IConsoleSwitch();
- break;
-
- case WKC_RETURN: case WKC_NUM_ENTER:
- IConsolePrintF(_icolour_cmd, "] %s", _iconsole_cmdline.buf);
- IConsoleHistoryAdd(_iconsole_cmdline.buf);
-
- IConsoleCmdExec(_iconsole_cmdline.buf);
- IConsoleClearCommand();
- break;
-
- case WKC_CTRL | WKC_RETURN:
- _iconsole_mode = (_iconsole_mode == ICONSOLE_FULL) ? ICONSOLE_OPENED : ICONSOLE_FULL;
- IConsoleResize(this);
- MarkWholeScreenDirty();
- break;
-
- case (WKC_CTRL | 'V'):
- if (InsertTextBufferClipboard(&_iconsole_cmdline)) {
- IConsoleResetHistoryPos();
- this->SetDirty();
- }
- break;
-
- case (WKC_CTRL | 'L'):
- IConsoleCmdExec("clear");
- break;
-
- case (WKC_CTRL | 'U'):
- DeleteTextBufferAll(&_iconsole_cmdline);
- this->SetDirty();
- break;
-
- case WKC_BACKSPACE: case WKC_DELETE:
- if (DeleteTextBufferChar(&_iconsole_cmdline, keycode)) {
- IConsoleResetHistoryPos();
- this->SetDirty();
- }
- break;
-
- case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
- if (MoveTextBufferPos(&_iconsole_cmdline, keycode)) {
- IConsoleResetHistoryPos();
- this->SetDirty();
- }
- break;
-
- default:
- if (IsValidChar(key, CS_ALPHANUMERAL)) {
- IConsoleWindow::scroll = ICON_BUFFER;
- InsertTextBufferChar(&_iconsole_cmdline, key);
- IConsoleResetHistoryPos();
- this->SetDirty();
- } else {
- return ES_NOT_HANDLED;
- }
- }
- return ES_HANDLED;
- }
-};
-
-byte IConsoleWindow::scroll = ICON_BUFFER;
-
-static const Widget _iconsole_window_widgets[] = {
- {WIDGETS_END}
-};
-
-static const WindowDesc _iconsole_window_desc = {
- 0, 0, 2, 2, 2, 2,
- WC_CONSOLE, WC_NONE,
- WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
- _iconsole_window_widgets,
-};
-
void IConsoleInit()
{
_iconsole_output_file = NULL;
- _icolour_def = 1;
- _icolour_err = 3;
- _icolour_warn = 13;
- _icolour_dbg = 5;
- _icolour_cmd = TC_GOLD;
- _iconsole_historypos = ICON_HISTORY_SIZE - 1;
- _iconsole_mode = ICONSOLE_CLOSED;
-
#ifdef ENABLE_NETWORK /* Initialize network only variables */
_redirect_console_to_client = 0;
#endif
- memset(_iconsole_history, 0, sizeof(_iconsole_history));
- memset(_iconsole_buffer, 0, sizeof(_iconsole_buffer));
- memset(_iconsole_cbuffer, 0, sizeof(_iconsole_cbuffer));
- _iconsole_cmdline.buf = CallocT<char>(ICON_CMDLN_SIZE); // create buffer and zero it
- _iconsole_cmdline.maxlength = ICON_CMDLN_SIZE;
+ IConsoleGUIInit();
- IConsolePrintF(13, "OpenTTD Game Console Revision 7 - %s", _openttd_revision);
- IConsolePrint(12, "------------------------------------");
- IConsolePrint(12, "use \"help\" for more information");
- IConsolePrint(12, "");
IConsoleStdLibRegister();
- IConsoleClearCommand();
- IConsoleHistoryAdd("");
-}
-
-void IConsoleClearBuffer()
-{
- uint i;
- for (i = 0; i <= ICON_BUFFER; i++) {
- free(_iconsole_buffer[i]);
- _iconsole_buffer[i] = NULL;
- }
-}
-
-static void IConsoleClear()
-{
- free(_iconsole_cmdline.buf);
- IConsoleClearBuffer();
}
static void IConsoleWriteToLogFile(const char *string)
@@ -303,7 +52,7 @@
fwrite("\n", 1, 1, _iconsole_output_file) != 1) {
fclose(_iconsole_output_file);
_iconsole_output_file = NULL;
- IConsolePrintF(_icolour_def, "cannot write to log file");
+ IConsolePrintF(CC_DEFAULT, "cannot write to log file");
}
}
}
@@ -311,7 +60,7 @@
bool CloseConsoleLogIfActive()
{
if (_iconsole_output_file != NULL) {
- IConsolePrintF(_icolour_def, "file output complete");
+ IConsolePrintF(CC_DEFAULT, "file output complete");
fclose(_iconsole_output_file);
_iconsole_output_file = NULL;
return true;
@@ -322,86 +71,10 @@
void IConsoleFree()
{
- IConsoleClear();
+ IConsoleGUIFree();
CloseConsoleLogIfActive();
}
-void IConsoleResize(Window *w)
-{
- switch (_iconsole_mode) {
- case ICONSOLE_OPENED:
- w->height = _screen.height / 3;
- w->width = _screen.width;
- break;
- case ICONSOLE_FULL:
- w->height = _screen.height - ICON_BOTTOM_BORDERWIDTH;
- w->width = _screen.width;
- break;
- default: return;
- }
-
- MarkWholeScreenDirty();
-}
-
-void IConsoleSwitch()
-{
- switch (_iconsole_mode) {
- case ICONSOLE_CLOSED:
- new IConsoleWindow(&_iconsole_window_desc);
- break;
-
- case ICONSOLE_OPENED: case ICONSOLE_FULL:
- DeleteWindowById(WC_CONSOLE, 0);
- break;
- }
-
- MarkWholeScreenDirty();
-}
-
-void IConsoleClose() {if (_iconsole_mode == ICONSOLE_OPENED) IConsoleSwitch();}
-void IConsoleOpen() {if (_iconsole_mode == ICONSOLE_CLOSED) IConsoleSwitch();}
-
-/**
- * Add the entered line into the history so you can look it back
- * scroll, etc. Put it to the beginning as it is the latest text
- * @param cmd Text to be entered into the 'history'
- */
-static void IConsoleHistoryAdd(const char *cmd)
-{
- free(_iconsole_history[ICON_HISTORY_SIZE - 1]);
-
- memmove(&_iconsole_history[1], &_iconsole_history[0], sizeof(_iconsole_history[0]) * (ICON_HISTORY_SIZE - 1));
- _iconsole_history[0] = strdup(cmd);
- IConsoleResetHistoryPos();
-}
-
-/**
- * Navigate Up/Down in the history of typed commands
- * @param direction Go further back in history (+1), go to recently typed commands (-1)
- */
-static void IConsoleHistoryNavigate(int direction)
-{
- int i = _iconsole_historypos + direction;
-
- /* watch out for overflows, just wrap around */
- if (i < 0) i = ICON_HISTORY_SIZE - 1;
- if (i >= ICON_HISTORY_SIZE) i = 0;
-
- if (direction > 0)
- if (_iconsole_history[i] == NULL) i = 0;
-
- if (direction < 0) {
- while (i > 0 && _iconsole_history[i] == NULL) i--;
- }
-
- _iconsole_historypos = i;
- IConsoleClearCommand();
- /* copy history to 'command prompt / bash' */
- assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE));
- ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxlength);
- UpdateTextBufferSize(&_iconsole_cmdline);
-}
-
/**
* Handle the printing of text entered into the console or redirected there
* by any other means. Text can be redirected to other players in a network game
@@ -411,7 +84,7 @@
* @param color_code the colour of the command. Red in case of errors, etc.
* @param string the message entered or output on the console (notice, error, etc.)
*/
-void IConsolePrint(uint16 color_code, const char *string)
+void IConsolePrint(ConsoleColour color_code, const char *string)
{
char *str;
#ifdef ENABLE_NETWORK
@@ -436,18 +109,8 @@
return;
}
- /* move up all the strings in the buffer one place and do the same for colour
- * to accomodate for the new command/message */
- free(_iconsole_buffer[0]);
- memmove(&_iconsole_buffer[0], &_iconsole_buffer[1], sizeof(_iconsole_buffer[0]) * ICON_BUFFER);
- _iconsole_buffer[ICON_BUFFER] = str;
-
- memmove(&_iconsole_cbuffer[0], &_iconsole_cbuffer[1], sizeof(_iconsole_cbuffer[0]) * ICON_BUFFER);
- _iconsole_cbuffer[ICON_BUFFER] = color_code;
-
- IConsoleWriteToLogFile(_iconsole_buffer[ICON_BUFFER]);
-
- SetWindowDirty(FindWindowById(WC_CONSOLE, 0));
+ IConsoleWriteToLogFile(str);
+ IConsoleGUIPrint(color_code, str);
}
/**
@@ -455,7 +118,7 @@
* by any other means. Uses printf() style format, for more information look
* at IConsolePrint()
*/
-void CDECL IConsolePrintF(uint16 color_code, const char *s, ...)
+void CDECL IConsolePrintF(ConsoleColour color_code, const char *s, ...)
{
va_list va;
char buf[ICON_MAX_STREAMSIZE];
@@ -478,7 +141,7 @@
void IConsoleDebug(const char *dbg, const char *string)
{
if (_stdlib_developer > 1)
- IConsolePrintF(_icolour_dbg, "dbg: [%s] %s", dbg, string);
+ IConsolePrintF(CC_DEBUG, "dbg: [%s] %s", dbg, string);
}
/**
@@ -489,7 +152,7 @@
void IConsoleWarning(const char *string)
{
if (_stdlib_developer > 0)
- IConsolePrintF(_icolour_warn, "WARNING: %s", string);
+ IConsolePrintF(CC_WARNING, "WARNING: %s", string);
}
/**
@@ -498,7 +161,7 @@
*/
void IConsoleError(const char *string)
{
- IConsolePrintF(_icolour_err, "ERROR: %s", string);
+ IConsolePrintF(CC_ERROR, "ERROR: %s", string);
}
/**
@@ -747,7 +410,7 @@
memset(&aliasstream, 0, sizeof(aliasstream));
if (_stdlib_con_developer)
- IConsolePrintF(_icolour_dbg, "condbg: requested command is an alias; parsing...");
+ IConsolePrintF(CC_DEBUG, "condbg: requested command is an alias; parsing...");
aliases[0] = aliasstream;
for (cmdptr = alias->cmdline, a_index = 0, astream_i = 0; *cmdptr != '\0'; cmdptr++) {
@@ -787,7 +450,7 @@
if (param < 0 || param >= tokencount) {
IConsoleError("too many or wrong amount of parameters passed to alias, aborting");
- IConsolePrintF(_icolour_warn, "Usage of alias '%s': %s", alias->name, alias->cmdline);
+ IConsolePrintF(CC_WARNING, "Usage of alias '%s': %s", alias->name, alias->cmdline);
return;
}
@@ -1000,7 +663,7 @@
}
value = IConsoleVarGetStringValue(var);
- IConsolePrintF(_icolour_warn, "Current value for '%s' is: %s", var->name, value);
+ IConsolePrintF(CC_WARNING, "Current value for '%s' is: %s", var->name, value);
}
/**
@@ -1010,7 +673,7 @@
void IConsoleVarPrintSetValue(const IConsoleVar *var)
{
char *value = IConsoleVarGetStringValue(var);
- IConsolePrintF(_icolour_warn, "'%s' changed to: %s", var->name, value);
+ IConsolePrintF(CC_WARNING, "'%s' changed to: %s", var->name, value);
}
/**
@@ -1027,7 +690,7 @@
uint32 value;
if (_stdlib_con_developer)
- IConsolePrintF(_icolour_dbg, "condbg: requested command is a variable");
+ IConsolePrintF(CC_DEBUG, "condbg: requested command is a variable");
if (tokencount == 0) { /* Just print out value */
IConsoleVarPrintGetValue(var);
@@ -1104,13 +767,13 @@
for (cmdptr = cmdstr; *cmdptr != '\0'; cmdptr++) {
if (!IsValidChar(*cmdptr, CS_ALPHANUMERAL)) {
IConsoleError("command contains malformed characters, aborting");
- IConsolePrintF(_icolour_err, "ERROR: command was: '%s'", cmdstr);
+ IConsolePrintF(CC_ERROR, "ERROR: command was: '%s'", cmdstr);
return;
}
}
if (_stdlib_con_developer)
- IConsolePrintF(_icolour_dbg, "condbg: executing cmdline: '%s'", cmdstr);
+ IConsolePrintF(CC_DEBUG, "condbg: executing cmdline: '%s'", cmdstr);
memset(&tokens, 0, sizeof(tokens));
memset(&tokenstream, 0, sizeof(tokenstream));
@@ -1158,7 +821,7 @@
uint i;
for (i = 0; tokens[i] != NULL; i++) {
- IConsolePrintF(_icolour_dbg, "condbg: token %d is: '%s'", i, tokens[i]);
+ IConsolePrintF(CC_DEBUG, "condbg: token %d is: '%s'", i, tokens[i]);
}
}
--- a/src/console.h Mon May 26 11:36:42 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-/* $Id$ */
-
-/** @file console.h In-game console. */
-
-#ifndef CONSOLE_H
-#define CONSOLE_H
-
-#include "window_type.h"
-
-/* maximum length of a typed in command */
-#define ICON_CMDLN_SIZE 255
-/* maximum length of a totally expanded command */
-#define ICON_MAX_STREAMSIZE 1024
-
-enum IConsoleVarTypes {
- ICONSOLE_VAR_BOOLEAN,
- ICONSOLE_VAR_BYTE,
- ICONSOLE_VAR_UINT16,
- ICONSOLE_VAR_UINT32,
- ICONSOLE_VAR_INT16,
- ICONSOLE_VAR_INT32,
- ICONSOLE_VAR_STRING
-};
-
-enum IConsoleModes {
- ICONSOLE_FULL,
- ICONSOLE_OPENED,
- ICONSOLE_CLOSED
-};
-
-enum IConsoleHookTypes {
- ICONSOLE_HOOK_ACCESS,
- ICONSOLE_HOOK_PRE_ACTION,
- ICONSOLE_HOOK_POST_ACTION
-};
-
-/** --Hooks--
- * Hooks are certain triggers get get accessed/executed on either
- * access, before execution/change or after execution/change. This allows
- * for general flow of permissions or special action needed in some cases
- */
-typedef bool IConsoleHook();
-struct IConsoleHooks{
- IConsoleHook *access; ///< trigger when accessing the variable/command
- IConsoleHook *pre; ///< trigger before the variable/command is changed/executed
- IConsoleHook *post; ///< trigger after the variable/command is changed/executed
-};
-
-/** --Commands--
- * Commands are commands, or functions. They get executed once and any
- * effect they produce are carried out. The arguments to the commands
- * are given to them, each input word seperated by a double-quote (") is an argument
- * If you want to handle multiple words as one, enclose them in double-quotes
- * eg. 'say "hello sexy boy"'
- */
-typedef bool (IConsoleCmdProc)(byte argc, char *argv[]);
-
-struct IConsoleCmd {
- char *name; ///< name of command
- IConsoleCmd *next; ///< next command in list
-
- IConsoleCmdProc *proc; ///< process executed when command is typed
- IConsoleHooks hook; ///< any special trigger action that needs executing
-};
-
-/** --Variables--
- * Variables are pointers to real ingame variables which allow for
- * changing while ingame. After changing they keep their new value
- * and can be used for debugging, gameplay, etc. It accepts:
- * - no arguments; just print out current value
- * - '= <new value>' to assign a new value to the variable
- * - '++' to increase value by one
- * - '--' to decrease value by one
- */
-struct IConsoleVar {
- char *name; ///< name of the variable
- IConsoleVar *next; ///< next variable in list
-
- void *addr; ///< the address where the variable is pointing at
- uint32 size; ///< size of the variable, used for strings
- char *help; ///< the optional help string shown when requesting information
- IConsoleVarTypes type; ///< type of variable (for correct assignment/output)
- IConsoleCmdProc *proc; ///< some variables need really special handling, use a callback function for that
- IConsoleHooks hook; ///< any special trigger action that needs executing
-};
-
-/** --Aliases--
- * Aliases are like shortcuts for complex functions, variable assignments,
- * etc. You can use a simple alias to rename a longer command (eg 'lv' for
- * 'list_vars' for example), or concatenate more commands into one
- * (eg. 'ng' for 'load %A; unpause; debug_level 5'). Aliases can parse the arguments
- * given to them in the command line.
- * - "%A - %Z" substitute arguments 1 t/m 26
- * - "%+" lists all parameters keeping them seperated
- * - "%!" also lists all parameters but presenting them to the aliased command as one argument
- * - ";" allows for combining commands (see example 'ng')
- */
-struct IConsoleAlias {
- char *name; ///< name of the alias
- IConsoleAlias *next; ///< next alias in list
-
- char *cmdline; ///< command(s) that is/are being aliased
-};
-
-/* console parser */
-extern IConsoleCmd *_iconsole_cmds; ///< list of registred commands
-extern IConsoleVar *_iconsole_vars; ///< list of registred vars
-extern IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
-
-/* console colors/modes */
-extern byte _icolour_def;
-extern byte _icolour_err;
-extern byte _icolour_warn;
-extern byte _icolour_dbg;
-extern byte _icolour_cmd;
-extern IConsoleModes _iconsole_mode;
-
-/* console functions */
-void IConsoleInit();
-void IConsoleFree();
-void IConsoleClearBuffer();
-void IConsoleResize(Window *w);
-void IConsoleSwitch();
-void IConsoleClose();
-void IConsoleOpen();
-
-/* console output */
-void IConsolePrint(uint16 color_code, const char *string);
-void CDECL IConsolePrintF(uint16 color_code, const char *s, ...);
-void IConsoleDebug(const char *dbg, const char *string);
-void IConsoleWarning(const char *string);
-void IConsoleError(const char *string);
-
-/* Commands */
-void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc);
-void IConsoleAliasRegister(const char *name, const char *cmd);
-IConsoleCmd *IConsoleCmdGet(const char *name);
-IConsoleAlias *IConsoleAliasGet(const char *name);
-
-/* Variables */
-void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help);
-void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const char *help);
-IConsoleVar* IConsoleVarGet(const char *name);
-void IConsoleVarPrintGetValue(const IConsoleVar *var);
-void IConsoleVarPrintSetValue(const IConsoleVar *var);
-
-/* Parser */
-void IConsoleCmdExec(const char *cmdstr);
-void IConsoleVarExec(const IConsoleVar *var, byte tokencount, char *token[]);
-
-/* console std lib (register ingame commands/aliases/variables) */
-void IConsoleStdLibRegister();
-
-/* Hooking code */
-void IConsoleCmdHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
-void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
-void IConsoleVarProcAdd(const char *name, IConsoleCmdProc *proc);
-
-/* Supporting functions */
-bool GetArgumentInteger(uint32 *value, const char *arg);
-#endif /* CONSOLE_H */
--- a/src/console_cmds.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/console_cmds.cpp Mon May 26 13:52:59 2008 +0000
@@ -4,7 +4,7 @@
#include "stdafx.h"
#include "openttd.h"
-#include "console.h"
+#include "console_internal.h"
#include "debug.h"
#include "engine_func.h"
#include "landscape.h"
@@ -108,7 +108,7 @@
static void IConsoleHelp(const char *str)
{
- IConsolePrintF(_icolour_warn, "- %s", str);
+ IConsolePrintF(CC_WARNING, "- %s", str);
}
DEF_CONSOLE_CMD(ConResetEngines)
@@ -166,7 +166,7 @@
uint32 result;
if (GetArgumentInteger(&result, argv[1])) {
if (result >= MapSize()) {
- IConsolePrint(_icolour_err, "Tile does not exist");
+ IConsolePrint(CC_ERROR, "Tile does not exist");
return true;
}
ScrollMainWindowToTile((TileIndex)result);
@@ -190,12 +190,12 @@
if (argc == 2) {
char *filename = str_fmt("%s.sav", argv[1]);
- IConsolePrint(_icolour_def, "Saving map...");
+ IConsolePrint(CC_DEFAULT, "Saving map...");
if (SaveOrLoad(filename, SL_SAVE, SAVE_DIR) != SL_OK) {
- IConsolePrint(_icolour_err, "Saving map failed");
+ IConsolePrint(CC_ERROR, "Saving map failed");
} else {
- IConsolePrintF(_icolour_def, "Map sucessfully saved to %s", filename);
+ IConsolePrintF(CC_DEFAULT, "Map sucessfully saved to %s", filename);
}
free(filename);
return true;
@@ -213,7 +213,7 @@
}
SaveToConfig();
- IConsolePrint(_icolour_def, "Saved config.");
+ IConsolePrint(CC_DEFAULT, "Saved config.");
return true;
}
@@ -263,10 +263,10 @@
ttd_strlcpy(_file_to_saveload.name, FiosBrowseTo(item), sizeof(_file_to_saveload.name));
ttd_strlcpy(_file_to_saveload.title, item->title, sizeof(_file_to_saveload.title));
} break;
- default: IConsolePrintF(_icolour_err, "%s: Not a savegame.", file);
+ default: IConsolePrintF(CC_ERROR, "%s: Not a savegame.", file);
}
} else {
- IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
+ IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file);
}
FiosFreeSavegameList();
@@ -290,9 +290,9 @@
item = GetFiosItem(file);
if (item != NULL) {
if (!FiosDelete(item->name))
- IConsolePrintF(_icolour_err, "%s: Failed to delete file", file);
+ IConsolePrintF(CC_ERROR, "%s: Failed to delete file", file);
} else {
- IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
+ IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file);
}
FiosFreeSavegameList();
@@ -314,7 +314,7 @@
for (i = 0; i < _fios_num; i++) {
const FiosItem *item = &_fios_list[i];
- IConsolePrintF(_icolour_def, "%d) %s", i, item->title);
+ IConsolePrintF(CC_DEFAULT, "%d) %s", i, item->title);
}
FiosFreeSavegameList();
@@ -341,10 +341,10 @@
case FIOS_TYPE_DIR: case FIOS_TYPE_DRIVE: case FIOS_TYPE_PARENT:
FiosBrowseTo(item);
break;
- default: IConsolePrintF(_icolour_err, "%s: Not a directory.", file);
+ default: IConsolePrintF(CC_ERROR, "%s: Not a directory.", file);
}
} else {
- IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
+ IConsolePrintF(CC_ERROR, "%s: No such file or directory.", file);
}
FiosFreeSavegameList();
@@ -365,7 +365,7 @@
FiosFreeSavegameList();
FiosGetDescText(&path, NULL);
- IConsolePrint(_icolour_def, path);
+ IConsolePrint(CC_DEFAULT, path);
return true;
}
@@ -428,9 +428,9 @@
if (ci != NULL) {
banip = inet_ntoa(*(struct in_addr *)&ci->client_ip);
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
- IConsolePrint(_icolour_def, "Client banned");
+ IConsolePrint(CC_DEFAULT, "Client banned");
} else {
- IConsolePrint(_icolour_def, "Client not online, banned IP");
+ IConsolePrint(CC_DEFAULT, "Client not online, banned IP");
}
/* Add user to ban-list */
@@ -465,12 +465,12 @@
if (strcmp(_network_ban_list[i], argv[1]) == 0 || index == i) {
free(_network_ban_list[i]);
_network_ban_list[i] = NULL;
- IConsolePrint(_icolour_def, "IP unbanned.");
+ IConsolePrint(CC_DEFAULT, "IP unbanned.");
return true;
}
}
- IConsolePrint(_icolour_def, "IP not in ban-list.");
+ IConsolePrint(CC_DEFAULT, "IP not in ban-list.");
return true;
}
@@ -483,11 +483,11 @@
return true;
}
- IConsolePrint(_icolour_def, "Banlist: ");
+ IConsolePrint(CC_DEFAULT, "Banlist: ");
for (i = 0; i < lengthof(_network_ban_list); i++) {
if (_network_ban_list[i] != NULL)
- IConsolePrintF(_icolour_def, " %d) %s", i + 1, _network_ban_list[i]);
+ IConsolePrintF(CC_DEFAULT, " %d) %s", i + 1, _network_ban_list[i]);
}
return true;
@@ -502,9 +502,9 @@
if (_pause_game == 0) {
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
- IConsolePrint(_icolour_def, "Game paused.");
+ IConsolePrint(CC_DEFAULT, "Game paused.");
} else {
- IConsolePrint(_icolour_def, "Game is already paused.");
+ IConsolePrint(CC_DEFAULT, "Game is already paused.");
}
return true;
@@ -519,9 +519,9 @@
if (_pause_game != 0) {
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
- IConsolePrint(_icolour_def, "Game unpaused.");
+ IConsolePrint(CC_DEFAULT, "Game unpaused.");
} else {
- IConsolePrint(_icolour_def, "Game is already unpaused.");
+ IConsolePrint(CC_DEFAULT, "Game is already unpaused.");
}
return true;
@@ -571,7 +571,7 @@
const char* status;
status = (cs->status < (ptrdiff_t)lengthof(stat_str) ? stat_str[cs->status] : "unknown");
- IConsolePrintF(8, "Client #%1d name: '%s' status: '%s' frame-lag: %3d company: %1d IP: %s unique-id: '%s'",
+ IConsolePrintF(CC_INFO, "Client #%1d name: '%s' status: '%s' frame-lag: %3d company: %1d IP: %s unique-id: '%s'",
cs->index, ci->client_name, status, lag,
ci->client_playas + (IsValidPlayer(ci->client_playas) ? 1 : 0),
GetPlayerIP(ci), ci->unique_id);
@@ -591,9 +591,9 @@
}
gi = &_network_game_info;
- IConsolePrintF(_icolour_def, "Current/maximum clients: %2d/%2d", gi->clients_on, gi->clients_max);
- IConsolePrintF(_icolour_def, "Current/maximum companies: %2d/%2d", ActivePlayerCount(), gi->companies_max);
- IConsolePrintF(_icolour_def, "Current/maximum spectators: %2d/%2d", NetworkSpectatorCount(), gi->spectators_max);
+ IConsolePrintF(CC_DEFAULT, "Current/maximum clients: %2d/%2d", gi->clients_on, gi->clients_max);
+ IConsolePrintF(CC_DEFAULT, "Current/maximum companies: %2d/%2d", ActivePlayerCount(), gi->companies_max);
+ IConsolePrintF(CC_DEFAULT, "Current/maximum spectators: %2d/%2d", NetworkSpectatorCount(), gi->spectators_max);
return true;
}
@@ -694,7 +694,7 @@
/* Check valid range */
if (!IsValidPlayer(index)) {
- IConsolePrintF(_icolour_err, "Company does not exist. Company-id must be between 1 and %d.", MAX_PLAYERS);
+ IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_PLAYERS);
return true;
}
@@ -726,7 +726,7 @@
/* It is safe to remove this company */
DoCommandP(0, 2, index, NULL, CMD_PLAYER_CTRL);
- IConsolePrint(_icolour_def, "Company deleted.");
+ IConsolePrint(CC_DEFAULT, "Company deleted.");
return true;
}
@@ -741,7 +741,7 @@
}
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
- IConsolePrintF(8, "Client #%1d name: '%s' company: %1d IP: %s",
+ IConsolePrintF(CC_INFO, "Client #%1d name: '%s' company: %1d IP: %s",
ci->client_index, ci->client_name,
ci->client_playas + (IsValidPlayer(ci->client_playas) ? 1 : 0),
GetPlayerIP(ci));
@@ -774,10 +774,10 @@
ParseConnectionString(&player, &port, ip);
- IConsolePrintF(_icolour_def, "Connecting to %s...", ip);
+ IConsolePrintF(CC_DEFAULT, "Connecting to %s...", ip);
if (player != NULL) {
_network_playas = (PlayerID)atoi(player);
- IConsolePrintF(_icolour_def, " player-no: %d", _network_playas);
+ IConsolePrintF(CC_DEFAULT, " player-no: %d", _network_playas);
/* From a user pov 0 is a new player, internally it's different and all
* players are offset by one to ease up on users (eg players 1-8 not 0-7) */
@@ -788,7 +788,7 @@
}
if (port != NULL) {
rport = atoi(port);
- IConsolePrintF(_icolour_def, " port: %s", port);
+ IConsolePrintF(CC_DEFAULT, " port: %s", port);
}
NetworkClientConnectGame(ip, rport);
@@ -871,7 +871,7 @@
if (!CloseConsoleLogIfActive()) {
if (argc < 2) return false;
- IConsolePrintF(_icolour_def, "file output started to: %s", argv[1]);
+ IConsolePrintF(CC_DEFAULT, "file output started to: %s", argv[1]);
_iconsole_output_file = fopen(argv[1], "ab");
if (_iconsole_output_file == NULL) IConsoleError("could not open file");
}
@@ -888,7 +888,7 @@
}
if (argc < 2) return false;
- IConsolePrint(_icolour_def, argv[1]);
+ IConsolePrint(CC_DEFAULT, argv[1]);
return true;
}
@@ -900,7 +900,7 @@
}
if (argc < 3) return false;
- IConsolePrint(atoi(argv[1]), argv[2]);
+ IConsolePrint((ConsoleColour)atoi(argv[1]), argv[2]);
return true;
}
@@ -927,8 +927,8 @@
}
/* Don't copy the _newgame pointers to the real pointers, so call SwitchMode directly */
- _patches.map_x = MapLogX();
- _patches.map_y = FindFirstBit(MapSizeY());
+ _settings.game_creation.map_x = MapLogX();
+ _settings.game_creation.map_y = FindFirstBit(MapSizeY());
SwitchMode(SM_NEWGAME);
return true;
}
@@ -944,7 +944,7 @@
for (char *p2 = &buf[0]; *p2 != '\0'; p2++) {
if (*p2 == '\n') {
*p2 = '\0';
- IConsolePrintF(_icolour_def, "%s", p);
+ IConsolePrintF(CC_DEFAULT, "%s", p);
p = p2 + 1;
}
}
@@ -990,7 +990,7 @@
return true;
}
- IConsolePrintF(_icolour_def, "Generation Seed: %u", _patches.generation_seed);
+ IConsolePrintF(CC_DEFAULT, "Generation Seed: %u", _settings.game_creation.generation_seed);
return true;
}
@@ -1003,7 +1003,7 @@
YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd);
- IConsolePrintF(_icolour_def, "Date: %d-%d-%d", ymd.day, ymd.month + 1, ymd.year);
+ IConsolePrintF(CC_DEFAULT, "Date: %d-%d-%d", ymd.day, ymd.month + 1, ymd.year);
return true;
}
@@ -1069,9 +1069,9 @@
return true;
}
- IConsolePrintF(_icolour_def, "variable name: %s", var->name);
- IConsolePrintF(_icolour_def, "variable type: %s", _icon_vartypes[var->type]);
- IConsolePrintF(_icolour_def, "variable addr: 0x%X", var->addr);
+ IConsolePrintF(CC_DEFAULT, "variable name: %s", var->name);
+ IConsolePrintF(CC_DEFAULT, "variable type: %s", _icon_vartypes[var->type]);
+ IConsolePrintF(CC_DEFAULT, "variable addr: 0x%X", var->addr);
if (var->hook.access) IConsoleWarning("variable is access hooked");
if (var->hook.pre) IConsoleWarning("variable is pre hooked");
@@ -1097,8 +1097,8 @@
return true;
}
- IConsolePrintF(_icolour_def, "command name: %s", cmd->name);
- IConsolePrintF(_icolour_def, "command proc: 0x%X", cmd->proc);
+ IConsolePrintF(CC_DEFAULT, "command name: %s", cmd->name);
+ IConsolePrintF(CC_DEFAULT, "command proc: 0x%X", cmd->proc);
if (cmd->hook.access) IConsoleWarning("command is access hooked");
if (cmd->hook.pre) IConsoleWarning("command is pre hooked");
@@ -1118,7 +1118,7 @@
if (argc > 2) return false;
if (argc == 1) {
- IConsolePrintF(_icolour_def, "Current debug-level: '%s'", GetDebugString());
+ IConsolePrintF(CC_DEFAULT, "Current debug-level: '%s'", GetDebugString());
} else {
SetDebugString(argv[1]);
}
@@ -1133,7 +1133,7 @@
return true;
}
- if (_game_mode == GM_NORMAL && _patches.autosave_on_exit) DoExitSave();
+ if (_game_mode == GM_NORMAL && _settings.gui.autosave_on_exit) DoExitSave();
_exit_game = true;
return true;
@@ -1172,7 +1172,7 @@
cmd->proc(0, NULL);
return true;
}
- IConsolePrintF(_icolour_err, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline);
+ IConsolePrintF(CC_ERROR, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline);
return true;
}
@@ -1186,18 +1186,18 @@
return true;
}
- IConsolePrint(13, " ---- OpenTTD Console Help ---- ");
- IConsolePrint( 1, " - variables: [command to list all variables: list_vars]");
- IConsolePrint( 1, " set value with '<var> = <value>', use '++/--' to in-or decrement");
- IConsolePrint( 1, " or omit '=' and just '<var> <value>'. get value with typing '<var>'");
- IConsolePrint( 1, " - commands: [command to list all commands: list_cmds]");
- IConsolePrint( 1, " call commands with '<command> <arg2> <arg3>...'");
- IConsolePrint( 1, " - to assign strings, or use them as arguments, enclose it within quotes");
- IConsolePrint( 1, " like this: '<command> \"string argument with spaces\"'");
- IConsolePrint( 1, " - use 'help <command> | <variable>' to get specific information");
- IConsolePrint( 1, " - scroll console output with shift + (up | down) | (pageup | pagedown))");
- IConsolePrint( 1, " - scroll console input history with the up | down arrows");
- IConsolePrint( 1, "");
+ IConsolePrint(CC_WARNING, " ---- OpenTTD Console Help ---- ");
+ IConsolePrint(CC_DEFAULT, " - variables: [command to list all variables: list_vars]");
+ IConsolePrint(CC_DEFAULT, " set value with '<var> = <value>', use '++/--' to in-or decrement");
+ IConsolePrint(CC_DEFAULT, " or omit '=' and just '<var> <value>'. get value with typing '<var>'");
+ IConsolePrint(CC_DEFAULT, " - commands: [command to list all commands: list_cmds]");
+ IConsolePrint(CC_DEFAULT, " call commands with '<command> <arg2> <arg3>...'");
+ IConsolePrint(CC_DEFAULT, " - to assign strings, or use them as arguments, enclose it within quotes");
+ IConsolePrint(CC_DEFAULT, " like this: '<command> \"string argument with spaces\"'");
+ IConsolePrint(CC_DEFAULT, " - use 'help <command> | <variable>' to get specific information");
+ IConsolePrint(CC_DEFAULT, " - scroll console output with shift + (up | down) | (pageup | pagedown))");
+ IConsolePrint(CC_DEFAULT, " - scroll console input history with the up | down arrows");
+ IConsolePrint(CC_DEFAULT, "");
return true;
}
@@ -1215,7 +1215,7 @@
for (cmd = _iconsole_cmds; cmd != NULL; cmd = cmd->next) {
if (argv[1] == NULL || strncmp(cmd->name, argv[1], l) == 0) {
- IConsolePrintF(_icolour_def, "%s", cmd->name);
+ IConsolePrintF(CC_DEFAULT, "%s", cmd->name);
}
}
@@ -1236,7 +1236,7 @@
for (var = _iconsole_vars; var != NULL; var = var->next) {
if (argv[1] == NULL || strncmp(var->name, argv[1], l) == 0)
- IConsolePrintF(_icolour_def, "%s", var->name);
+ IConsolePrintF(CC_DEFAULT, "%s", var->name);
}
return true;
@@ -1256,7 +1256,7 @@
for (alias = _iconsole_aliases; alias != NULL; alias = alias->next) {
if (argv[1] == NULL || strncmp(alias->name, argv[1], l) == 0)
- IConsolePrintF(_icolour_def, "%s => %s", alias->name, alias->cmdline);
+ IConsolePrintF(CC_DEFAULT, "%s => %s", alias->name, alias->cmdline);
}
return true;
@@ -1300,7 +1300,7 @@
const NetworkPlayerInfo *npi = &_network_player_info[p->index];
GetString(buffer, STR_00D1_DARK_BLUE + _player_colors[p->index], lastof(buffer));
- IConsolePrintF(8, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: %" OTTD_PRINTF64 "d Loan: %" OTTD_PRINTF64 "d Value: %" OTTD_PRINTF64 "d (T:%d, R:%d, P:%d, S:%d) %sprotected",
+ IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: %" OTTD_PRINTF64 "d Loan: %" OTTD_PRINTF64 "d Value: %" OTTD_PRINTF64 "d (T:%d, R:%d, P:%d, S:%d) %sprotected",
p->index + 1, buffer, npi->company_name, p->inaugurated_year, (int64)p->player_money, (int64)p->current_loan, (int64)CalculateCompanyValue(p),
/* trains */ npi->num_vehicle[0],
/* lorry + bus */ npi->num_vehicle[1] + npi->num_vehicle[2],
@@ -1323,7 +1323,7 @@
if (argc != 3) return false;
if (atoi(argv[1]) < 1 || atoi(argv[1]) > MAX_PLAYERS) {
- IConsolePrintF(_icolour_def, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS);
+ IConsolePrintF(CC_DEFAULT, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS);
return true;
}
@@ -1385,7 +1385,7 @@
{
if (argc == 0) {
if (!IsValidPlayer(_local_player)) return true; // dedicated server
- IConsolePrintF(_icolour_warn, "Current value for 'company_pw': %s", _network_player_info[_local_player].password);
+ IConsolePrintF(CC_WARNING, "Current value for 'company_pw': %s", _network_player_info[_local_player].password);
return true;
}
@@ -1406,7 +1406,7 @@
HashCurrentCompanyPassword();
}
- IConsolePrintF(_icolour_warn, "'company_pw' changed to: %s", _network_player_info[_local_player].password);
+ IConsolePrintF(CC_WARNING, "'company_pw' changed to: %s", _network_player_info[_local_player].password);
return true;
}
@@ -1423,7 +1423,7 @@
SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_network_player_name);
} else {
if (NetworkFindName(_network_player_name)) {
- NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, false, ci->client_name, "%s", _network_player_name);
+ NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", _network_player_name);
ttd_strlcpy(ci->client_name, _network_player_name, sizeof(ci->client_name));
NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
}
@@ -1450,7 +1450,7 @@
DEF_CONSOLE_CMD(ConProcServerIP)
{
if (argc == 0) {
- IConsolePrintF(_icolour_warn, "Current value for 'server_ip': %s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip));
+ IConsolePrintF(CC_WARNING, "Current value for 'server_ip': %s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip));
return true;
}
@@ -1458,7 +1458,7 @@
_network_server_bind_ip = (strcmp(argv[0], "all") == 0) ? inet_addr("0.0.0.0") : inet_addr(argv[0]);
snprintf(_network_server_bind_ip_host, sizeof(_network_server_bind_ip_host), "%s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip));
- IConsolePrintF(_icolour_warn, "'server_ip' changed to: %s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip));
+ IConsolePrintF(CC_WARNING, "'server_ip' changed to: %s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip));
return true;
}
#endif /* ENABLE_NETWORK */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/console_func.h Mon May 26 13:52:59 2008 +0000
@@ -0,0 +1,26 @@
+/* $Id$ */
+
+/** @file console_func.h Console functions used outside of the console code. */
+
+#ifndef CONSOLE_FUNC_H
+#define CONSOLE_FUNC_H
+
+#include "console_type.h"
+
+/* console modes */
+extern IConsoleModes _iconsole_mode;
+
+/* console functions */
+void IConsoleInit();
+void IConsoleFree();
+void IConsoleClose();
+
+/* console output */
+void IConsolePrint(ConsoleColour color_code, const char *string);
+void CDECL IConsolePrintF(ConsoleColour color_code, const char *s, ...);
+void IConsoleDebug(const char *dbg, const char *string);
+
+/* Parser */
+void IConsoleCmdExec(const char *cmdstr);
+
+#endif /* CONSOLE_FUNC_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/console_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -0,0 +1,366 @@
+/* $Id$ */
+
+/** @file console.cpp Handling of the in-game console. */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "textbuf_gui.h"
+#include "window_gui.h"
+#include "console_gui.h"
+#include <stdarg.h>
+#include <string.h>
+#include "console_internal.h"
+#include "window_func.h"
+#include "string_func.h"
+#include "gfx_func.h"
+#include "core/math_func.hpp"
+#include "rev.h"
+
+#include "table/strings.h"
+
+#define ICON_BUFFER 79
+#define ICON_HISTORY_SIZE 20
+#define ICON_LINE_HEIGHT 12
+#define ICON_RIGHT_BORDERWIDTH 10
+#define ICON_BOTTOM_BORDERWIDTH 12
+#define ICON_MAX_ALIAS_LINES 40
+#define ICON_TOKEN_COUNT 20
+
+/* console modes */
+IConsoleModes _iconsole_mode;
+
+/* ** main console ** */
+static char *_iconsole_buffer[ICON_BUFFER + 1];
+static uint16 _iconsole_cbuffer[ICON_BUFFER + 1];
+static Textbuf _iconsole_cmdline;
+
+/* ** main console cmd buffer ** */
+static char *_iconsole_history[ICON_HISTORY_SIZE];
+static byte _iconsole_historypos;
+
+/* *************** *
+ * end of header *
+ * *************** */
+
+static void IConsoleClearCommand()
+{
+ memset(_iconsole_cmdline.buf, 0, ICON_CMDLN_SIZE);
+ _iconsole_cmdline.length = 0;
+ _iconsole_cmdline.width = 0;
+ _iconsole_cmdline.caretpos = 0;
+ _iconsole_cmdline.caretxoffs = 0;
+ SetWindowDirty(FindWindowById(WC_CONSOLE, 0));
+}
+
+static inline void IConsoleResetHistoryPos() {_iconsole_historypos = ICON_HISTORY_SIZE - 1;}
+
+
+static void IConsoleHistoryAdd(const char *cmd);
+static void IConsoleHistoryNavigate(int direction);
+
+struct IConsoleWindow : Window
+{
+ static byte scroll;
+
+ IConsoleWindow(const WindowDesc *desc) : Window(desc)
+ {
+ _iconsole_mode = ICONSOLE_OPENED;
+ SetBit(_no_scroll, SCROLL_CON); // override cursor arrows; the gamefield will not scroll
+
+ this->height = _screen.height / 3;
+ this->width = _screen.width;
+ }
+
+ ~IConsoleWindow()
+ {
+ _iconsole_mode = ICONSOLE_CLOSED;
+ ClrBit(_no_scroll, SCROLL_CON);
+ }
+
+ virtual void OnPaint()
+ {
+ int i = IConsoleWindow::scroll;
+ int max = (this->height / ICON_LINE_HEIGHT) - 1;
+ int delta = 0;
+ GfxFillRect(this->left, this->top, this->width, this->height - 1, 0);
+ while ((i > 0) && (i > IConsoleWindow::scroll - max) && (_iconsole_buffer[i] != NULL)) {
+ DoDrawString(_iconsole_buffer[i], 5,
+ this->height - (IConsoleWindow::scroll + 2 - i) * ICON_LINE_HEIGHT, _iconsole_cbuffer[i]);
+ i--;
+ }
+ /* If the text is longer than the window, don't show the starting ']' */
+ delta = this->width - 10 - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH;
+ if (delta > 0) {
+ DoDrawString("]", 5, this->height - ICON_LINE_HEIGHT, CC_COMMAND);
+ delta = 0;
+ }
+
+ DoDrawString(_iconsole_cmdline.buf, 10 + delta, this->height - ICON_LINE_HEIGHT, CC_COMMAND);
+
+ if (_iconsole_cmdline.caret) {
+ DoDrawString("_", 10 + delta + _iconsole_cmdline.caretxoffs, this->height - ICON_LINE_HEIGHT, TC_WHITE);
+ }
+ }
+
+ virtual void OnMouseLoop()
+ {
+ if (HandleCaret(&_iconsole_cmdline)) this->SetDirty();
+ }
+
+ virtual EventState OnKeyPress(uint16 key, uint16 keycode)
+ {
+ switch (keycode) {
+ case WKC_UP:
+ IConsoleHistoryNavigate(+1);
+ this->SetDirty();
+ break;
+
+ case WKC_DOWN:
+ IConsoleHistoryNavigate(-1);
+ this->SetDirty();
+ break;
+
+ case WKC_SHIFT | WKC_PAGEUP:
+ if (IConsoleWindow::scroll - (this->height / ICON_LINE_HEIGHT) - 1 < 0) {
+ IConsoleWindow::scroll = 0;
+ } else {
+ IConsoleWindow::scroll -= (this->height / ICON_LINE_HEIGHT) - 1;
+ }
+ this->SetDirty();
+ break;
+
+ case WKC_SHIFT | WKC_PAGEDOWN:
+ if (IConsoleWindow::scroll + (this->height / ICON_LINE_HEIGHT) - 1 > ICON_BUFFER) {
+ IConsoleWindow::scroll = ICON_BUFFER;
+ } else {
+ IConsoleWindow::scroll += (this->height / ICON_LINE_HEIGHT) - 1;
+ }
+ this->SetDirty();
+ break;
+
+ case WKC_SHIFT | WKC_UP:
+ if (IConsoleWindow::scroll <= 0) {
+ IConsoleWindow::scroll = 0;
+ } else {
+ --IConsoleWindow::scroll;
+ }
+ this->SetDirty();
+ break;
+
+ case WKC_SHIFT | WKC_DOWN:
+ if (IConsoleWindow::scroll >= ICON_BUFFER) {
+ IConsoleWindow::scroll = ICON_BUFFER;
+ } else {
+ ++IConsoleWindow::scroll;
+ }
+ this->SetDirty();
+ break;
+
+ case WKC_BACKQUOTE:
+ IConsoleSwitch();
+ break;
+
+ case WKC_RETURN: case WKC_NUM_ENTER:
+ IConsolePrintF(CC_COMMAND, "] %s", _iconsole_cmdline.buf);
+ IConsoleHistoryAdd(_iconsole_cmdline.buf);
+
+ IConsoleCmdExec(_iconsole_cmdline.buf);
+ IConsoleClearCommand();
+ break;
+
+ case WKC_CTRL | WKC_RETURN:
+ _iconsole_mode = (_iconsole_mode == ICONSOLE_FULL) ? ICONSOLE_OPENED : ICONSOLE_FULL;
+ IConsoleResize(this);
+ MarkWholeScreenDirty();
+ break;
+
+ case (WKC_CTRL | 'V'):
+ if (InsertTextBufferClipboard(&_iconsole_cmdline)) {
+ IConsoleResetHistoryPos();
+ this->SetDirty();
+ }
+ break;
+
+ case (WKC_CTRL | 'L'):
+ IConsoleCmdExec("clear");
+ break;
+
+ case (WKC_CTRL | 'U'):
+ DeleteTextBufferAll(&_iconsole_cmdline);
+ this->SetDirty();
+ break;
+
+ case WKC_BACKSPACE: case WKC_DELETE:
+ if (DeleteTextBufferChar(&_iconsole_cmdline, keycode)) {
+ IConsoleResetHistoryPos();
+ this->SetDirty();
+ }
+ break;
+
+ case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
+ if (MoveTextBufferPos(&_iconsole_cmdline, keycode)) {
+ IConsoleResetHistoryPos();
+ this->SetDirty();
+ }
+ break;
+
+ default:
+ if (IsValidChar(key, CS_ALPHANUMERAL)) {
+ IConsoleWindow::scroll = ICON_BUFFER;
+ InsertTextBufferChar(&_iconsole_cmdline, key);
+ IConsoleResetHistoryPos();
+ this->SetDirty();
+ } else {
+ return ES_NOT_HANDLED;
+ }
+ }
+ return ES_HANDLED;
+ }
+};
+
+byte IConsoleWindow::scroll = ICON_BUFFER;
+
+static const Widget _iconsole_window_widgets[] = {
+ {WIDGETS_END}
+};
+
+static const WindowDesc _iconsole_window_desc = {
+ 0, 0, 2, 2, 2, 2,
+ WC_CONSOLE, WC_NONE,
+ WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
+ _iconsole_window_widgets,
+};
+
+void IConsoleGUIInit()
+{
+ _iconsole_historypos = ICON_HISTORY_SIZE - 1;
+ _iconsole_mode = ICONSOLE_CLOSED;
+
+ memset(_iconsole_history, 0, sizeof(_iconsole_history));
+ memset(_iconsole_buffer, 0, sizeof(_iconsole_buffer));
+ memset(_iconsole_cbuffer, 0, sizeof(_iconsole_cbuffer));
+ _iconsole_cmdline.buf = CallocT<char>(ICON_CMDLN_SIZE); // create buffer and zero it
+ _iconsole_cmdline.maxlength = ICON_CMDLN_SIZE;
+
+ IConsolePrintF(CC_WARNING, "OpenTTD Game Console Revision 7 - %s", _openttd_revision);
+ IConsolePrint(CC_WHITE, "------------------------------------");
+ IConsolePrint(CC_WHITE, "use \"help\" for more information");
+ IConsolePrint(CC_WHITE, "");
+ IConsoleClearCommand();
+ IConsoleHistoryAdd("");
+}
+
+void IConsoleClearBuffer()
+{
+ uint i;
+ for (i = 0; i <= ICON_BUFFER; i++) {
+ free(_iconsole_buffer[i]);
+ _iconsole_buffer[i] = NULL;
+ }
+}
+
+void IConsoleGUIFree()
+{
+ free(_iconsole_cmdline.buf);
+ IConsoleClearBuffer();
+}
+
+void IConsoleResize(Window *w)
+{
+ switch (_iconsole_mode) {
+ case ICONSOLE_OPENED:
+ w->height = _screen.height / 3;
+ w->width = _screen.width;
+ break;
+ case ICONSOLE_FULL:
+ w->height = _screen.height - ICON_BOTTOM_BORDERWIDTH;
+ w->width = _screen.width;
+ break;
+ default: return;
+ }
+
+ MarkWholeScreenDirty();
+}
+
+void IConsoleSwitch()
+{
+ switch (_iconsole_mode) {
+ case ICONSOLE_CLOSED:
+ new IConsoleWindow(&_iconsole_window_desc);
+ break;
+
+ case ICONSOLE_OPENED: case ICONSOLE_FULL:
+ DeleteWindowById(WC_CONSOLE, 0);
+ break;
+ }
+
+ MarkWholeScreenDirty();
+}
+
+void IConsoleClose() {if (_iconsole_mode == ICONSOLE_OPENED) IConsoleSwitch();}
+void IConsoleOpen() {if (_iconsole_mode == ICONSOLE_CLOSED) IConsoleSwitch();}
+
+/**
+ * Add the entered line into the history so you can look it back
+ * scroll, etc. Put it to the beginning as it is the latest text
+ * @param cmd Text to be entered into the 'history'
+ */
+static void IConsoleHistoryAdd(const char *cmd)
+{
+ free(_iconsole_history[ICON_HISTORY_SIZE - 1]);
+
+ memmove(&_iconsole_history[1], &_iconsole_history[0], sizeof(_iconsole_history[0]) * (ICON_HISTORY_SIZE - 1));
+ _iconsole_history[0] = strdup(cmd);
+ IConsoleResetHistoryPos();
+}
+
+/**
+ * Navigate Up/Down in the history of typed commands
+ * @param direction Go further back in history (+1), go to recently typed commands (-1)
+ */
+static void IConsoleHistoryNavigate(int direction)
+{
+ int i = _iconsole_historypos + direction;
+
+ /* watch out for overflows, just wrap around */
+ if (i < 0) i = ICON_HISTORY_SIZE - 1;
+ if (i >= ICON_HISTORY_SIZE) i = 0;
+
+ if (direction > 0) {
+ if (_iconsole_history[i] == NULL) i = 0;
+ }
+
+ if (direction < 0) {
+ while (i > 0 && _iconsole_history[i] == NULL) i--;
+ }
+
+ _iconsole_historypos = i;
+ IConsoleClearCommand();
+ /* copy history to 'command prompt / bash' */
+ assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE));
+ ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxlength);
+ UpdateTextBufferSize(&_iconsole_cmdline);
+}
+
+/**
+ * Handle the printing of text entered into the console or redirected there
+ * by any other means. Text can be redirected to other players in a network game
+ * as well as to a logfile. If the network server is a dedicated server, all activities
+ * are also logged. All lines to print are added to a temporary buffer which can be
+ * used as a history to print them onscreen
+ * @param color_code the colour of the command. Red in case of errors, etc.
+ * @param string the message entered or output on the console (notice, error, etc.)
+ */
+void IConsoleGUIPrint(ConsoleColour color_code, char *str)
+{
+ /* move up all the strings in the buffer one place and do the same for colour
+ * to accomodate for the new command/message */
+ free(_iconsole_buffer[0]);
+ memmove(&_iconsole_buffer[0], &_iconsole_buffer[1], sizeof(_iconsole_buffer[0]) * ICON_BUFFER);
+ _iconsole_buffer[ICON_BUFFER] = str;
+
+ memmove(&_iconsole_cbuffer[0], &_iconsole_cbuffer[1], sizeof(_iconsole_cbuffer[0]) * ICON_BUFFER);
+ _iconsole_cbuffer[ICON_BUFFER] = color_code;
+
+ SetWindowDirty(FindWindowById(WC_CONSOLE, 0));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/console_gui.h Mon May 26 13:52:59 2008 +0000
@@ -0,0 +1,13 @@
+/* $Id$ */
+
+/** @file console_gui.h GUI related functions in the console. */
+
+#ifndef CONSOLE_GUI_H
+#define CONSOLE_GUI_H
+
+#include "window_type.h"
+
+void IConsoleResize(Window *w);
+void IConsoleSwitch();
+
+#endif /* CONSOLE_GUI_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/console_internal.h Mon May 26 13:52:59 2008 +0000
@@ -0,0 +1,143 @@
+/* $Id$ */
+
+/** @file console_internal.h Internally used functions for the console. */
+
+#ifndef CONSOLE_INTERNAL_H
+#define CONSOLE_INTERNAL_H
+
+#include "console_func.h"
+
+/* maximum length of a typed in command */
+#define ICON_CMDLN_SIZE 255
+/* maximum length of a totally expanded command */
+#define ICON_MAX_STREAMSIZE 1024
+
+enum IConsoleVarTypes {
+ ICONSOLE_VAR_BOOLEAN,
+ ICONSOLE_VAR_BYTE,
+ ICONSOLE_VAR_UINT16,
+ ICONSOLE_VAR_UINT32,
+ ICONSOLE_VAR_INT16,
+ ICONSOLE_VAR_INT32,
+ ICONSOLE_VAR_STRING
+};
+
+enum IConsoleHookTypes {
+ ICONSOLE_HOOK_ACCESS,
+ ICONSOLE_HOOK_PRE_ACTION,
+ ICONSOLE_HOOK_POST_ACTION
+};
+
+/** --Hooks--
+ * Hooks are certain triggers get get accessed/executed on either
+ * access, before execution/change or after execution/change. This allows
+ * for general flow of permissions or special action needed in some cases
+ */
+typedef bool IConsoleHook();
+struct IConsoleHooks{
+ IConsoleHook *access; ///< trigger when accessing the variable/command
+ IConsoleHook *pre; ///< trigger before the variable/command is changed/executed
+ IConsoleHook *post; ///< trigger after the variable/command is changed/executed
+};
+
+/** --Commands--
+ * Commands are commands, or functions. They get executed once and any
+ * effect they produce are carried out. The arguments to the commands
+ * are given to them, each input word seperated by a double-quote (") is an argument
+ * If you want to handle multiple words as one, enclose them in double-quotes
+ * eg. 'say "hello sexy boy"'
+ */
+typedef bool (IConsoleCmdProc)(byte argc, char *argv[]);
+
+struct IConsoleCmd {
+ char *name; ///< name of command
+ IConsoleCmd *next; ///< next command in list
+
+ IConsoleCmdProc *proc; ///< process executed when command is typed
+ IConsoleHooks hook; ///< any special trigger action that needs executing
+};
+
+/** --Variables--
+ * Variables are pointers to real ingame variables which allow for
+ * changing while ingame. After changing they keep their new value
+ * and can be used for debugging, gameplay, etc. It accepts:
+ * - no arguments; just print out current value
+ * - '= <new value>' to assign a new value to the variable
+ * - '++' to increase value by one
+ * - '--' to decrease value by one
+ */
+struct IConsoleVar {
+ char *name; ///< name of the variable
+ IConsoleVar *next; ///< next variable in list
+
+ void *addr; ///< the address where the variable is pointing at
+ uint32 size; ///< size of the variable, used for strings
+ char *help; ///< the optional help string shown when requesting information
+ IConsoleVarTypes type; ///< type of variable (for correct assignment/output)
+ IConsoleCmdProc *proc; ///< some variables need really special handling, use a callback function for that
+ IConsoleHooks hook; ///< any special trigger action that needs executing
+};
+
+/** --Aliases--
+ * Aliases are like shortcuts for complex functions, variable assignments,
+ * etc. You can use a simple alias to rename a longer command (eg 'lv' for
+ * 'list_vars' for example), or concatenate more commands into one
+ * (eg. 'ng' for 'load %A; unpause; debug_level 5'). Aliases can parse the arguments
+ * given to them in the command line.
+ * - "%A - %Z" substitute arguments 1 t/m 26
+ * - "%+" lists all parameters keeping them seperated
+ * - "%!" also lists all parameters but presenting them to the aliased command as one argument
+ * - ";" allows for combining commands (see example 'ng')
+ */
+struct IConsoleAlias {
+ char *name; ///< name of the alias
+ IConsoleAlias *next; ///< next alias in list
+
+ char *cmdline; ///< command(s) that is/are being aliased
+};
+
+/* console parser */
+extern IConsoleCmd *_iconsole_cmds; ///< list of registred commands
+extern IConsoleVar *_iconsole_vars; ///< list of registred vars
+extern IConsoleAlias *_iconsole_aliases; ///< list of registred aliases
+
+/* console functions */
+void IConsoleClearBuffer();
+void IConsoleOpen();
+
+/* console output */
+void IConsoleWarning(const char *string);
+void IConsoleError(const char *string);
+
+/* Commands */
+void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc);
+void IConsoleAliasRegister(const char *name, const char *cmd);
+IConsoleCmd *IConsoleCmdGet(const char *name);
+IConsoleAlias *IConsoleAliasGet(const char *name);
+
+/* Variables */
+void IConsoleVarRegister(const char *name, void *addr, IConsoleVarTypes type, const char *help);
+void IConsoleVarStringRegister(const char *name, void *addr, uint32 size, const char *help);
+IConsoleVar* IConsoleVarGet(const char *name);
+void IConsoleVarPrintGetValue(const IConsoleVar *var);
+void IConsoleVarPrintSetValue(const IConsoleVar *var);
+
+/* Parser */
+void IConsoleVarExec(const IConsoleVar *var, byte tokencount, char *token[]);
+
+/* console std lib (register ingame commands/aliases/variables) */
+void IConsoleStdLibRegister();
+
+/* Hooking code */
+void IConsoleCmdHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
+void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *proc);
+void IConsoleVarProcAdd(const char *name, IConsoleCmdProc *proc);
+
+/* Supporting functions */
+bool GetArgumentInteger(uint32 *value, const char *arg);
+
+void IConsoleGUIInit();
+void IConsoleGUIFree();
+void IConsoleGUIPrint(ConsoleColour color_code, char *string);
+
+#endif /* CONSOLE_INTERNAL_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/console_type.h Mon May 26 13:52:59 2008 +0000
@@ -0,0 +1,24 @@
+/* $Id$ */
+
+/** @file console_type.h Globally used console related types. */
+
+#ifndef CONSOLE_TYPE_H
+#define CONSOLE_TYPE_H
+
+enum IConsoleModes {
+ ICONSOLE_FULL,
+ ICONSOLE_OPENED,
+ ICONSOLE_CLOSED
+};
+
+enum ConsoleColour {
+ CC_DEFAULT = 1,
+ CC_ERROR = 3,
+ CC_WARNING = 13,
+ CC_INFO = 8,
+ CC_DEBUG = 5,
+ CC_COMMAND = 2,
+ CC_WHITE = 12,
+};
+
+#endif /* CONSOLE_TYPE_H */
--- a/src/currency.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/currency.cpp Mon May 26 13:52:59 2008 +0000
@@ -150,10 +150,10 @@
**/
void CheckSwitchToEuro()
{
- if (_currency_specs[_opt.currency].to_euro != CF_NOEURO &&
- _currency_specs[_opt.currency].to_euro != CF_ISEURO &&
- _cur_year >= _currency_specs[_opt.currency].to_euro) {
- _opt.currency = 2; // this is the index of euro above.
+ if (_currency_specs[_settings.gui.currency].to_euro != CF_NOEURO &&
+ _currency_specs[_settings.gui.currency].to_euro != CF_ISEURO &&
+ _cur_year >= _currency_specs[_settings.gui.currency].to_euro) {
+ _settings.gui.currency = 2; // this is the index of euro above.
AddNewsItem(STR_EURO_INTRODUCE, NS_ECONOMY, 0, 0);
}
}
--- a/src/currency.h Mon May 26 11:36:42 2008 +0000
+++ b/src/currency.h Mon May 26 13:52:59 2008 +0000
@@ -39,7 +39,7 @@
// XXX small hack, but makes the rest of the code a bit nicer to read
#define _custom_currency (_currency_specs[CUSTOM_CURRENCY_ID])
-#define _currency ((const CurrencySpec*)&_currency_specs[_opt_ptr->currency])
+#define _currency ((const CurrencySpec*)&_currency_specs[(_game_mode == GM_MENU) ? _settings_newgame.gui.currency : _settings.gui.currency])
uint GetMaskOfAllowedCurrencies();
void CheckSwitchToEuro();
--- a/src/date.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/date.cpp Mon May 26 13:52:59 2008 +0000
@@ -257,7 +257,7 @@
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
DebugDumpCommands("ddc:save:%s\n", name);
#endif /* DUMP_COMMANDS */
- if (_opt.autosave != 0 && (_cur_month % _autosave_months[_opt.autosave]) == 0) {
+ if (_settings.gui.autosave != 0 && (_cur_month % _autosave_months[_settings.gui.autosave]) == 0) {
_do_autosave = true;
RedrawAutosave();
}
@@ -283,10 +283,10 @@
ShipsYearlyLoop();
if (_network_server) NetworkServerYearlyLoop();
- if (_cur_year == _patches.semaphore_build_before) ResetSignalVariant();
+ if (_cur_year == _settings.gui.semaphore_build_before) ResetSignalVariant();
/* check if we reached end of the game */
- if (_cur_year == _patches.ending_year) {
+ if (_cur_year == _settings.gui.ending_year) {
ShowEndGameChart();
/* check if we reached the maximum year, decrement dates by a year */
} else if (_cur_year == MAX_YEAR + 1) {
@@ -303,5 +303,5 @@
InitChatMessage();
}
- if (_patches.auto_euro) CheckSwitchToEuro();
+ if (_settings.gui.auto_euro) CheckSwitchToEuro();
}
--- a/src/debug.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/debug.cpp Mon May 26 13:52:59 2008 +0000
@@ -6,7 +6,7 @@
#include <stdio.h>
#include <stdarg.h>
#include "openttd.h"
-#include "console.h"
+#include "console_func.h"
#include "debug.h"
#include "string_func.h"
#include "network/core/core.h"
--- a/src/depot_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/depot_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -131,7 +131,7 @@
};
extern int WagonLengthToPixels(int len);
-extern void DepotSortList(Vehicle **v, uint16 length);
+extern void DepotSortList(VehicleList *list);
/**
* This is the Callback method after the cloning attempt of a vehicle
@@ -144,16 +144,14 @@
{
if (!success) return;
- Vehicle *v = GetVehicle(_new_vehicle_id);
+ const Vehicle *v = GetVehicle(_new_vehicle_id);
ShowVehicleViewWindow(v);
}
-static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head)
+static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Vehicle *head)
{
- Vehicle *v;
-
- v = GetVehicle(sel);
+ const Vehicle *v = GetVehicle(sel);
if (v == wagon) return;
@@ -242,20 +240,12 @@
VehicleID sel;
VehicleType type;
bool generate_list;
- uint16 engine_list_length;
- uint16 wagon_list_length;
- uint16 engine_count;
- uint16 wagon_count;
- Vehicle **vehicle_list;
- Vehicle **wagon_list;
+ VehicleList vehicle_list;
+ VehicleList wagon_list;
DepotWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
this->sel = INVALID_VEHICLE;
- this->vehicle_list = NULL;
- this->wagon_list = NULL;
- this->engine_count = 0;
- this->wagon_count = 0;
this->generate_list = true;
this->FindWindowPlacementAndResize(desc);
@@ -264,8 +254,6 @@
~DepotWindow()
{
DeleteWindowById(WC_BUILD_VEHICLE, this->window_number);
- free((void*)this->vehicle_list);
- free((void*)this->wagon_list);
}
/** Draw a vehicle in the depot window in the box with the top left corner at x,y
@@ -316,11 +304,9 @@
void DrawDepotWindow(Window *w)
{
- Vehicle **vl = this->vehicle_list;
TileIndex tile = this->window_number;
int x, y, i, maxval;
uint16 hnum;
- uint16 num = this->engine_count;
/* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
uint16 rows_in_display = this->widget[DEPOT_WIDGET_MATRIX].data >> 8;
@@ -341,15 +327,15 @@
/* determine amount of items for scroller */
if (this->type == VEH_TRAIN) {
hnum = 8;
- for (num = 0; num < this->engine_count; num++) {
- const Vehicle *v = vl[num];
+ for (uint num = 0; num < this->vehicle_list.Length(); num++) {
+ const Vehicle *v = this->vehicle_list[num];
hnum = max(hnum, v->u.rail.cached_total_length);
}
/* Always have 1 empty row, so people can change the setting of the train */
- SetVScrollCount(w, this->engine_count + this->wagon_count + 1);
+ SetVScrollCount(w, this->vehicle_list.Length() + this->wagon_list.Length() + 1);
SetHScrollCount(w, WagonLengthToPixels(hnum));
} else {
- SetVScrollCount(w, (num + this->hscroll.cap - 1) / this->hscroll.cap);
+ SetVScrollCount(w, (this->vehicle_list.Length() + this->hscroll.cap - 1) / this->hscroll.cap);
}
/* locate the depot struct */
@@ -364,24 +350,24 @@
w->DrawWidgets();
- num = this->vscroll.pos * boxes_in_each_row;
- maxval = min(this->engine_count, num + (rows_in_display * boxes_in_each_row));
+ uint16 num = this->vscroll.pos * boxes_in_each_row;
+ maxval = min(this->vehicle_list.Length(), num + (rows_in_display * boxes_in_each_row));
for (x = 2, y = 15; num < maxval; y += this->resize.step_height, x = 2) { // Draw the rows
byte i;
for (i = 0; i < boxes_in_each_row && num < maxval; i++, num++, x += this->resize.step_width) {
/* Draw all vehicles in the current row */
- const Vehicle *v = vl[num];
+ const Vehicle *v = this->vehicle_list[num];
DrawVehicleInDepot(w, v, x, y);
}
}
- maxval = min(this->engine_count + this->wagon_count, (this->vscroll.pos * boxes_in_each_row) + (rows_in_display * boxes_in_each_row));
+ maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll.pos * boxes_in_each_row) + (rows_in_display * boxes_in_each_row));
/* draw the train wagons, that do not have an engine in front */
for (; num < maxval; num++, y += 14) {
- const Vehicle *v = this->wagon_list[num - this->engine_count];
+ const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()];
const Vehicle *u;
DrawTrainImage(v, x + 50, y, this->sel, this->hscroll.cap - 29, 0);
@@ -397,8 +383,8 @@
}
struct GetDepotVehiclePtData {
- Vehicle *head;
- Vehicle *wagon;
+ const Vehicle *head;
+ const Vehicle *wagon;
};
enum DepotGUIAction {
@@ -408,9 +394,8 @@
MODE_START_STOP,
};
- DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, Vehicle **veh, GetDepotVehiclePtData *d) const
+ DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, const Vehicle **veh, GetDepotVehiclePtData *d) const
{
- Vehicle **vl = this->vehicle_list;
uint xt, row, xm = 0, ym = 0;
int pos, skip = 0;
uint16 boxes_in_each_row = this->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
@@ -431,7 +416,7 @@
pos = ((row + this->vscroll.pos) * boxes_in_each_row) + xt;
- if (this->engine_count + this->wagon_count <= pos) {
+ if ((int)(this->vehicle_list.Length() + this->wagon_list.Length()) <= pos) {
if (this->type == VEH_TRAIN) {
d->head = NULL;
d->wagon = NULL;
@@ -441,20 +426,19 @@
}
}
- if (this->engine_count > pos) {
- *veh = vl[pos];
+ if ((int)this->vehicle_list.Length() > pos) {
+ *veh = this->vehicle_list[pos];
skip = this->hscroll.pos;
} else {
- vl = this->wagon_list;
- pos -= this->engine_count;
- *veh = vl[pos];
+ pos -= this->vehicle_list.Length();
+ *veh = this->wagon_list[pos];
/* free wagons don't have an initial loco. */
x -= _traininfo_vehicle_width;
}
switch (this->type) {
case VEH_TRAIN: {
- Vehicle *v = *veh;
+ const Vehicle *v = *veh;
d->head = d->wagon = v;
/* either pressed the flag or the number, but only when it's a loco */
@@ -501,7 +485,7 @@
void DepotClick(int x, int y)
{
GetDepotVehiclePtData gdvp = { NULL, NULL };
- Vehicle *v = NULL;
+ const Vehicle *v = NULL;
DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
/* share / copy orders */
@@ -761,11 +745,9 @@
if (this->generate_list) {
/* Generate the vehicle list
* It's ok to use the wagon pointers for non-trains as they will be ignored */
- BuildDepotVehicleList(this->type, this->window_number,
- &this->vehicle_list, &this->engine_list_length, &this->engine_count,
- &this->wagon_list, &this->wagon_list_length, &this->wagon_count);
+ BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list);
this->generate_list = false;
- DepotSortList(this->vehicle_list, this->engine_count);
+ DepotSortList(&this->vehicle_list);
}
DrawDepotWindow(this);
}
@@ -814,7 +796,7 @@
case DEPOT_WIDGET_SELL_ALL:
/* Only open the confimation window if there are anything to sell */
- if (this->engine_count != 0 || this->wagon_count != 0) {
+ if (this->vehicle_list.Length() != 0 || this->wagon_list.Length() != 0) {
static const StringID confirm_captions[] = {
STR_8800_TRAIN_DEPOT,
STR_9003_ROAD_VEHICLE_DEPOT,
@@ -879,7 +861,7 @@
{
switch (widget) {
case DEPOT_WIDGET_MATRIX: {
- Vehicle *v;
+ const Vehicle *v = NULL;
VehicleID sel = this->sel;
this->sel = INVALID_VEHICLE;
@@ -908,23 +890,20 @@
case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
this->sel != INVALID_VEHICLE) {
- Vehicle *v;
uint command;
- int sell_cmd;
- bool is_engine;
if (this->IsWidgetDisabled(widget)) return;
if (this->sel == INVALID_VEHICLE) return;
this->HandleButtonClick(widget);
- v = GetVehicle(this->sel);
+ const Vehicle *v = GetVehicle(this->sel);
this->sel = INVALID_VEHICLE;
this->SetDirty();
- sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
+ int sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
- is_engine = (!(v->type == VEH_TRAIN && !IsFrontEngine(v)));
+ bool is_engine = (!(v->type == VEH_TRAIN && !IsFrontEngine(v)));
if (is_engine) {
_backup_orders_tile = v->tile;
--- a/src/disaster_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/disaster_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -1050,7 +1050,7 @@
ResetDisasterDelay();
- if (_opt.diff.disasters != 0) DoDisaster();
+ if (_settings.difficulty.disasters != 0) DoDisaster();
}
void StartupDisasters()
--- a/src/dock_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/dock_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -25,8 +25,8 @@
#include "table/sprites.h"
#include "table/strings.h"
-static void ShowBuildDockStationPicker();
-static void ShowBuildDocksDepotPicker();
+static void ShowBuildDockStationPicker(Window *parent);
+static void ShowBuildDocksDepotPicker(Window *parent);
static Axis _ship_depot_direction;
@@ -69,14 +69,21 @@
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_MSG(STR_CANT_BUILD_LOCKS));
}
-
-enum {
- DTW_CANAL = 3,
- DTW_LOCK = 4,
- DTW_DEMOLISH = 6,
- DTW_DEPOT = 7,
- DTW_STATION = 8,
- DTW_BUOY = 9
+/** Enum referring to the widgets of the build dock toolbar */
+enum DockToolbarWidgets {
+ DTW_BEGIN = 0, ///< Start of toolbar widgets
+ DTW_CLOSEBOX = DTW_BEGIN, ///< Close window button
+ DTW_CAPTION, ///< Window caption
+ DTW_STICKY, ///< Sticky window button
+ DTW_BUTTONS_BEGIN, ///< Begin of clickable buttons (except seperating panel)
+ DTW_CANAL = DTW_BUTTONS_BEGIN, ///< Build canal button
+ DTW_LOCK, ///< Build lock button
+ DTW_SEPERATOR, ///< Seperating panel between lock and demolish
+ DTW_DEMOLISH, ///< Demolish aka dynamite button
+ DTW_DEPOT, ///< Build depot button
+ DTW_STATION, ///< Build station button
+ DTW_BUOY, ///< Build buoy button
+ DTW_END, ///< End of toolbar widgets
};
@@ -98,13 +105,13 @@
static void BuildDocksClick_Depot(Window *w)
{
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
- if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker();
+ if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, VHM_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(w);
}
static void BuildDocksClick_Dock(Window *w)
{
if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return;
- if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker();
+ if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, VHM_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(w);
}
static void BuildDocksClick_Buoy(Window *w)
@@ -129,23 +136,23 @@
BuildDocksToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
this->FindWindowPlacementAndResize(desc);
- if (_patches.link_terraform_toolbar) ShowTerraformToolbar(this);
+ if (_settings.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}
~BuildDocksToolbarWindow()
{
- if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
+ if (_settings.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
}
virtual void OnPaint()
{
- this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), 7, 8, 9, WIDGET_LIST_END);
+ this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), DTW_DEPOT, DTW_STATION, DTW_BUOY, WIDGET_LIST_END);
this->DrawWidgets();
}
virtual void OnClick(Point pt, int widget)
{
- if (widget - 3 >= 0 && widget != 5) _build_docks_button_proc[widget - 3](this);
+ if (widget >= DTW_BUTTONS_BEGIN && widget != DTW_SEPERATOR) _build_docks_button_proc[widget - DTW_BUTTONS_BEGIN](this);
}
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
@@ -206,18 +213,18 @@
};
static const Widget _build_docks_toolb_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 7, 11, 123, 0, 13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_STICKYBOX, RESIZE_NONE, 7, 124, 135, 0, 13, 0x0, STR_STICKY_BUTTON},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_BUILD_CANALS_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP},
+{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DTW_CLOSEBOX
+{ WWT_CAPTION, RESIZE_NONE, 7, 11, 123, 0, 13, STR_9801_DOCK_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DTW_CAPTION
+{ WWT_STICKYBOX, RESIZE_NONE, 7, 124, 135, 0, 13, 0x0, STR_STICKY_BUTTON}, // DTW_STICKY
+{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_BUILD_CANAL, STR_BUILD_CANALS_TIP}, // DTW_CANAL
+{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_BUILD_LOCK, STR_BUILD_LOCKS_TIP}, // DTW_LOCK
-{ WWT_PANEL, RESIZE_NONE, 7, 44, 47, 14, 35, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 7, 44, 47, 14, 35, 0x0, STR_NULL}, // DTW_SEPERATOR
-{ WWT_IMGBTN, RESIZE_NONE, 7, 48, 69, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 70, 91, 14, 35, SPR_IMG_SHIP_DEPOT, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 92, 113, 14, 35, SPR_IMG_SHIP_DOCK, STR_981D_BUILD_SHIP_DOCK},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_BOUY, STR_9834_POSITION_BUOY_WHICH_CAN},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 48, 69, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // DTW_DEMOLISH
+{ WWT_IMGBTN, RESIZE_NONE, 7, 70, 91, 14, 35, SPR_IMG_SHIP_DEPOT, STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING}, // DTW_DEPOT
+{ WWT_IMGBTN, RESIZE_NONE, 7, 92, 113, 14, 35, SPR_IMG_SHIP_DOCK, STR_981D_BUILD_SHIP_DOCK}, // DTW_STATION
+{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_BOUY, STR_9834_POSITION_BUOY_WHICH_CAN}, // DTW_BUOY
{ WIDGETS_END},
};
@@ -248,7 +255,7 @@
};
public:
- BuildDocksStationWindow(const WindowDesc *desc) : PickerWindowBase(desc)
+ BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF);
this->FindWindowPlacementAndResize(desc);
@@ -256,7 +263,7 @@
virtual void OnPaint()
{
- int rad = (_patches.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
+ int rad = (_settings.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED;
this->DrawWidgets();
@@ -312,9 +319,9 @@
_build_dock_station_widgets,
};
-static void ShowBuildDockStationPicker()
+static void ShowBuildDockStationPicker(Window *parent)
{
- new BuildDocksStationWindow(&_build_dock_station_desc);
+ new BuildDocksStationWindow(&_build_dock_station_desc, parent);
}
struct BuildDocksDepotWindow : public PickerWindowBase {
@@ -337,7 +344,7 @@
}
public:
- BuildDocksDepotWindow(const WindowDesc *desc) : PickerWindowBase(desc)
+ BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->LowerWidget(_ship_depot_direction + BDDW_X);
UpdateDocksDirection();
@@ -387,9 +394,9 @@
};
-static void ShowBuildDocksDepotPicker()
+static void ShowBuildDocksDepotPicker(Window *parent)
{
- new BuildDocksDepotWindow(&_build_docks_depot_desc);
+ new BuildDocksDepotWindow(&_build_docks_depot_desc, parent);
}
--- a/src/dummy_land.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/dummy_land.cpp Mon May 26 13:52:59 2008 +0000
@@ -41,7 +41,7 @@
static void GetTileDesc_Dummy(TileIndex tile, TileDesc *td)
{
td->str = STR_EMPTY;
- td->owner = OWNER_NONE;
+ td->owner[0] = OWNER_NONE;
}
static void AnimateTile_Dummy(TileIndex tile)
--- a/src/economy.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/economy.cpp Mon May 26 13:52:59 2008 +0000
@@ -663,7 +663,7 @@
* inflation doesn't add anything after that either; it even makes playing
* it impossible due to the diverging cost and income rates.
*/
- if ((_cur_year - _patches.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return;
+ if ((_cur_year - _settings.game_creation.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return;
/* Approximation for (100 + infl_amount)% ** (1 / 12) - 100%
* scaled by 65536
@@ -713,7 +713,7 @@
static void HandleEconomyFluctuations()
{
- if (_opt.diff.economy == 0) return;
+ if (_settings.difficulty.economy == 0) return;
if (--_economy.fluct == 0) {
_economy.fluct = -(int)GB(Random(), 0, 2);
@@ -822,7 +822,7 @@
for (i = 0; i != NUM_PRICES; i++) {
Money price = _price_base[i];
if (_price_category[i] != 0) {
- uint mod = _price_category[i] == 1 ? _opt.diff.vehicle_costs : _opt.diff.construction_cost;
+ uint mod = _price_category[i] == 1 ? _settings.difficulty.vehicle_costs : _settings.difficulty.construction_cost;
if (mod < 1) {
price = price * 3 >> 2;
} else if (mod > 1) {
@@ -838,10 +838,10 @@
_price_frac[i] = 0;
}
- _economy.interest_rate = _opt.diff.initial_interest;
- _economy.infl_amount = _opt.diff.initial_interest;
- _economy.infl_amount_pr = max(0, _opt.diff.initial_interest - 1);
- _economy.max_loan_unround = _economy.max_loan = _opt.diff.max_loan * 1000;
+ _economy.interest_rate = _settings.difficulty.initial_interest;
+ _economy.infl_amount = _settings.difficulty.initial_interest;
+ _economy.infl_amount_pr = max(0, _settings.difficulty.initial_interest - 1);
+ _economy.max_loan_unround = _economy.max_loan = _settings.difficulty.max_loan;
_economy.fluct = GB(Random(), 0, 8) + 168;
}
@@ -1180,7 +1180,7 @@
}
/* zero the distance (thus income) if it's the bank and very short transport. */
- if (_opt.landscape == LT_TEMPERATE && cs->label == 'VALU' && dist < 10) return 0;
+ if (_settings.game_creation.landscape == LT_TEMPERATE && cs->label == 'VALU' && dist < 10) return 0;
static const int MIN_TIME_FACTOR = 31;
@@ -1226,7 +1226,7 @@
* XXX - Think of something better to
* 1) Only deliver to industries which are withing the catchment radius
* 2) Distribute between industries if more then one is present */
- best_dist = (_patches.station_spread + 8) * 2;
+ best_dist = (_settings.station.station_spread + 8) * 2;
FOR_ALL_INDUSTRIES(ind) {
indspec = GetIndustrySpec(ind->type);
uint i;
@@ -1331,7 +1331,7 @@
SetDParam(0, _current_player);
AddNewsItem(
- STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier,
+ STR_2031_SERVICE_SUBSIDY_AWARDED + _settings.difficulty.subsidy_multiplier,
NS_SUBSIDIES,
pair.a, pair.b
);
@@ -1381,7 +1381,7 @@
/* Modify profit if a subsidy is in effect */
if (subsidised) {
- switch (_opt.diff.subsidy_multiplier) {
+ switch (_settings.difficulty.subsidy_multiplier) {
case 0: profit += profit >> 1; break;
case 1: profit *= 2; break;
case 2: profit *= 3; break;
@@ -1502,7 +1502,7 @@
/* We have not waited enough time till the next round of loading/unloading */
if (--v->load_unload_time_rem != 0) {
- if (_patches.improved_load && (v->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
+ if (_settings.order.improved_load && (v->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
/* 'Reserve' this cargo for this vehicle, because we were first. */
for (; v != NULL; v = v->Next()) {
if (v->cargo_cap != 0) cargo_left[v->cargo_type] -= v->cargo_cap - v->cargo.Count();
@@ -1538,7 +1538,7 @@
if (v->cargo_cap == 0) continue;
byte load_amount = EngInfo(v->engine_type)->load_amount;
- if (_patches.gradual_loading && HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_LOAD_AMOUNT)) {
+ if (_settings.order.gradual_loading && HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_LOAD_AMOUNT)) {
uint16 cb_load_amount = GetVehicleCallback(CBID_VEHICLE_LOAD_AMOUNT, 0, 0, v->engine_type, v);
if (cb_load_amount != CALLBACK_FAILED && GB(cb_load_amount, 0, 8) != 0) load_amount = GB(cb_load_amount, 0, 8);
}
@@ -1547,7 +1547,7 @@
if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (u->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
uint cargo_count = v->cargo.Count();
- uint amount_unloaded = _patches.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
+ uint amount_unloaded = _settings.order.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
bool remaining; // Are there cargo entities in this vehicle that can still be unloaded here?
if (HasBit(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) && !(u->current_order.GetUnloadType() & OUFB_TRANSFER)) {
@@ -1573,7 +1573,7 @@
unloading_time += amount_unloaded;
anything_unloaded = true;
- if (_patches.gradual_loading && remaining) {
+ if (_settings.order.gradual_loading && remaining) {
completely_emptied = false;
} else {
/* We have finished unloading (cargo count == 0) */
@@ -1607,14 +1607,14 @@
/* Skip loading this vehicle if another train/vehicle is already handling
* the same cargo type at this station */
- if (_patches.improved_load && cargo_left[v->cargo_type] <= 0) {
+ if (_settings.order.improved_load && cargo_left[v->cargo_type] <= 0) {
SetBit(cargo_not_full, v->cargo_type);
continue;
}
if (cap > count) cap = count;
- if (_patches.gradual_loading) cap = min(cap, load_amount);
- if (_patches.improved_load) {
+ if (_settings.order.gradual_loading) cap = min(cap, load_amount);
+ if (_settings.order.improved_load) {
/* Don't load stuff that is already 'reserved' for other vehicles */
cap = min((uint)cargo_left[v->cargo_type], cap);
cargo_left[v->cargo_type] -= cap;
@@ -1658,7 +1658,7 @@
* all wagons at the same time instead of using the same 'improved'
* loading algorithm for the wagons (only fill wagon when there is
* enough to fill the previous wagons) */
- if (_patches.improved_load && (u->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
+ if (_settings.order.improved_load && (u->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
/* Update left cargo */
for (v = u; v != NULL; v = v->Next()) {
if (v->cargo_cap != 0) cargo_left[v->cargo_type] -= v->cargo_cap - v->cargo.Count();
@@ -1668,7 +1668,7 @@
v = u;
if (anything_loaded || anything_unloaded) {
- if (_patches.gradual_loading) {
+ if (_settings.order.gradual_loading) {
/* The time it takes to load one 'slice' of cargo or passengers depends
* on the vehicle type - the values here are those found in TTDPatch */
const uint gradual_loading_wait_time[] = { 40, 20, 10, 20 };
@@ -1705,11 +1705,11 @@
/* Calculate the loading indicator fill percent and display
* In the Game Menu do not display indicators
- * If _patches.loading_indicators == 2, show indicators (bool can be promoted to int as 0 or 1 - results in 2 > 0,1 )
- * if _patches.loading_indicators == 1, _local_player must be the owner or must be a spectator to show ind., so 1 > 0
- * if _patches.loading_indicators == 0, do not display indicators ... 0 is never greater than anything
+ * If _settings.gui.loading_indicators == 2, show indicators (bool can be promoted to int as 0 or 1 - results in 2 > 0,1 )
+ * if _settings.gui.loading_indicators == 1, _local_player must be the owner or must be a spectator to show ind., so 1 > 0
+ * if _settings.gui.loading_indicators == 0, do not display indicators ... 0 is never greater than anything
*/
- if (_game_mode != GM_MENU && (_patches.loading_indicators > (uint)(v->owner != _local_player && _local_player != PLAYER_SPECTATOR))) {
+ if (_game_mode != GM_MENU && (_settings.gui.loading_indicators > (uint)(v->owner != _local_player && _local_player != PLAYER_SPECTATOR))) {
StringID percent_up_down = STR_NULL;
int percent = CalcPercentVehicleFilled(v, &percent_up_down);
if (v->fill_percent_te_id == INVALID_TE_ID) {
@@ -1757,7 +1757,7 @@
void PlayersMonthlyLoop()
{
PlayersGenStatistics();
- if (_patches.inflation && _cur_year < MAX_YEAR)
+ if (_settings.economy.inflation && _cur_year < MAX_YEAR)
AddInflation();
PlayersPayInterest();
/* Reset the _current_player flag */
@@ -1827,7 +1827,7 @@
/* Check if buying shares is allowed (protection against modified clients) */
/* Cannot buy own shares */
- if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
+ if (!IsValidPlayer((PlayerID)p1) || !_settings.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
p = GetPlayer((PlayerID)p1);
@@ -1876,7 +1876,7 @@
/* Check if selling shares is allowed (protection against modified clients) */
/* Cannot sell own shares */
- if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
+ if (!IsValidPlayer((PlayerID)p1) || !_settings.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
p = GetPlayer((PlayerID)p1);
--- a/src/elrail_func.h Mon May 26 11:36:42 2008 +0000
+++ b/src/elrail_func.h Mon May 26 13:52:59 2008 +0000
@@ -25,7 +25,7 @@
*/
static inline bool HasCatenaryDrawn(RailType rt)
{
- return HasCatenary(rt) && !IsInvisibilitySet(TO_CATENARY) && !_patches.disable_elrails;
+ return HasCatenary(rt) && !IsInvisibilitySet(TO_CATENARY) && !_settings.vehicle.disable_elrails;
}
/**
@@ -37,6 +37,6 @@
void DrawCatenaryOnTunnel(const TileInfo *ti);
void DrawCatenaryOnBridge(const TileInfo *ti);
-int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
+int32 SettingsDisableElrail(int32 p1); ///< _settings.disable_elrail callback
#endif /* ELRAIL_FUNC_H */
--- a/src/engine.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/engine.cpp Mon May 26 13:52:59 2008 +0000
@@ -218,7 +218,7 @@
uint age = e->age;
/* Check for early retirement */
- if (e->player_avail != 0 && !_patches.never_expire_vehicles) {
+ if (e->player_avail != 0 && !_settings.vehicle.never_expire_vehicles) {
int retire_early = e->info.retire_early;
uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12);
if (retire_early != 0 && age >= retire_early_max_age) {
@@ -231,7 +231,7 @@
if (age < e->duration_phase_1) {
uint start = e->reliability_start;
e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start;
- } else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _patches.never_expire_vehicles) {
+ } else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _settings.vehicle.never_expire_vehicles) {
/* We are at the peak of this engines life. It will have max reliability.
* This is also true if the engines never expire. They will not go bad over time */
e->reliability = e->reliability_max;
@@ -294,10 +294,10 @@
CalcEngineReliability(e);
}
- e->lifelength = ei->lifelength + _patches.extend_vehicle_life;
+ e->lifelength = ei->lifelength + _settings.vehicle.extend_vehicle_life;
/* prevent certain engines from ever appearing. */
- if (!HasBit(ei->climates, _opt.landscape)) {
+ if (!HasBit(ei->climates, _settings.game_creation.landscape)) {
e->flags |= ENGINE_AVAILABLE;
e->player_avail = 0;
}
--- a/src/engine_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/engine_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -69,6 +69,7 @@
struct EnginePreviewWindow : Window {
EnginePreviewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
--- a/src/genworld.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/genworld.cpp Mon May 26 13:52:59 2008 +0000
@@ -91,8 +91,8 @@
_generating_world = true;
if (_network_dedicated) DEBUG(net, 0, "Generating map, please wait...");
/* Set the Random() seed to generation_seed so we produce the same map with the same seed */
- if (_patches.generation_seed == GENERATE_NEW_SEED) _patches.generation_seed = _patches_newgame.generation_seed = InteractiveRandom();
- _random.SetSeed(_patches.generation_seed);
+ if (_settings.game_creation.generation_seed == GENERATE_NEW_SEED) _settings.game_creation.generation_seed = _settings_newgame.game_creation.generation_seed = InteractiveRandom();
+ _random.SetSeed(_settings.game_creation.generation_seed);
SetGeneratingWorldProgress(GWP_MAP_INIT, 2);
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
@@ -105,7 +105,7 @@
SetGeneratingWorldProgress(GWP_UNMOVABLE, 1);
/* Make the map the height of the patch setting */
- if (_game_mode != GM_MENU) FlatEmptyWorld(_patches.se_flat_world_height);
+ if (_game_mode != GM_MENU) FlatEmptyWorld(_settings.game_creation.se_flat_world_height);
ConvertGroundTilesIntoWaterTiles();
IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
@@ -165,7 +165,7 @@
if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game");
- if (_patches.pause_on_newgame && _game_mode == GM_NORMAL) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
+ if (_settings.gui.pause_on_newgame && _game_mode == GM_NORMAL) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
} catch (...) {
_generating_world = false;
throw;
@@ -273,7 +273,7 @@
_current_player = OWNER_NONE;
/* Set the date before loading sprites as some newgrfs check it */
- SetDate(ConvertYMDToDate(_patches.starting_year, 0, 1));
+ SetDate(ConvertYMDToDate(_settings.game_creation.starting_year, 0, 1));
/* Load the right landscape stuff */
GfxLoadSprites();
--- a/src/genworld_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/genworld_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -48,7 +48,7 @@
static inline void SetNewLandscapeType(byte landscape)
{
- _opt_newgame.landscape = landscape;
+ _settings_newgame.game_creation.landscape = landscape;
InvalidateWindowClasses(WC_SELECT_GAME);
InvalidateWindowClasses(WC_GENERATE_LANDSCAPE);
}
@@ -206,8 +206,6 @@
/* Copy all XXX_newgame to XXX when coming from outside the editor */
UpdatePatches();
- _opt = _opt_newgame;
- _opt_ptr = &_opt;
ResetGRFConfig(true);
SndPlayFx(SND_15_BEEP);
@@ -255,9 +253,9 @@
GenerateLandscapeWindow(const WindowDesc *desc, WindowNumber number = 0) : QueryStringBaseWindow(desc, number)
{
- this->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
+ this->LowerWidget(_settings_newgame.game_creation.landscape + GLAND_TEMPERATE);
- snprintf(this->edit_str_buf, sizeof(this->edit_str_buf), "%u", _patches_newgame.generation_seed);
+ snprintf(this->edit_str_buf, sizeof(this->edit_str_buf), "%u", _settings_newgame.game_creation.generation_seed);
InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 120);
this->caption = STR_NULL;
this->afilter = CS_NUMERAL;
@@ -271,49 +269,49 @@
{
/* You can't select smoothness if not terragenesis */
if (mode == GLWP_GENERATE) {
- this->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0);
+ this->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _settings_newgame.game_creation.land_generator == 0);
}
/* Disable snowline if not hilly */
- this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _settings_newgame.game_creation.landscape != LT_ARCTIC);
/* Disable town, industry and trees in SE */
this->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
this->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
this->SetWidgetDisabledState(GLAND_TREE_PULLDOWN, _game_mode == GM_EDITOR);
- this->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR);
- this->SetWidgetDisabledState(GLAND_START_DATE_UP, _patches_newgame.starting_year >= MAX_YEAR);
- this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC);
- this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP, _patches_newgame.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
+ this->SetWidgetDisabledState(GLAND_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
+ this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _settings_newgame.game_creation.snow_line_height <= 2 || _settings_newgame.game_creation.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP, _settings_newgame.game_creation.snow_line_height >= MAX_SNOWLINE_HEIGHT || _settings_newgame.game_creation.landscape != LT_ARCTIC);
- this->SetWidgetLoweredState(GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
- this->SetWidgetLoweredState(GLAND_ARCTIC, _opt_newgame.landscape == LT_ARCTIC);
- this->SetWidgetLoweredState(GLAND_TROPICAL, _opt_newgame.landscape == LT_TROPIC);
- this->SetWidgetLoweredState(GLAND_TOYLAND, _opt_newgame.landscape == LT_TOYLAND);
+ this->SetWidgetLoweredState(GLAND_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
+ this->SetWidgetLoweredState(GLAND_ARCTIC, _settings_newgame.game_creation.landscape == LT_ARCTIC);
+ this->SetWidgetLoweredState(GLAND_TROPICAL, _settings_newgame.game_creation.landscape == LT_TROPIC);
+ this->SetWidgetLoweredState(GLAND_TOYLAND, _settings_newgame.game_creation.landscape == LT_TOYLAND);
if (_game_mode == GM_EDITOR) {
this->widget[GLAND_TOWN_PULLDOWN].data = STR_6836_OFF;
this->widget[GLAND_INDUSTRY_PULLDOWN].data = STR_6836_OFF;
} else {
- this->widget[GLAND_TOWN_PULLDOWN].data = _num_towns[_opt_newgame.diff.number_towns];
- this->widget[GLAND_INDUSTRY_PULLDOWN].data = _num_inds[_opt_newgame.diff.number_industries];
+ this->widget[GLAND_TOWN_PULLDOWN].data = _num_towns[_settings_newgame.difficulty.number_towns];
+ this->widget[GLAND_INDUSTRY_PULLDOWN].data = _num_inds[_settings_newgame.difficulty.number_industries];
}
if (mode == GLWP_GENERATE) {
- this->widget[GLAND_LANDSCAPE_PULLDOWN].data = _landscape[_patches_newgame.land_generator];
- this->widget[GLAND_TREE_PULLDOWN].data = _tree_placer[_patches_newgame.tree_placer];
- this->widget[GLAND_TERRAIN_PULLDOWN].data = _elevations[_opt_newgame.diff.terrain_type];
- this->widget[GLAND_WATER_PULLDOWN].data = _sea_lakes[_opt_newgame.diff.quantity_sea_lakes];
- this->widget[GLAND_SMOOTHNESS_PULLDOWN].data = _smoothness[_patches_newgame.tgen_smoothness];
+ this->widget[GLAND_LANDSCAPE_PULLDOWN].data = _landscape[_settings_newgame.game_creation.land_generator];
+ this->widget[GLAND_TREE_PULLDOWN].data = _tree_placer[_settings_newgame.game_creation.tree_placer];
+ this->widget[GLAND_TERRAIN_PULLDOWN].data = _elevations[_settings_newgame.difficulty.terrain_type];
+ this->widget[GLAND_WATER_PULLDOWN].data = _sea_lakes[_settings_newgame.difficulty.quantity_sea_lakes];
+ this->widget[GLAND_SMOOTHNESS_PULLDOWN].data = _smoothness[_settings_newgame.game_creation.tgen_smoothness];
} else {
- this->widget[GLAND_TREE_PULLDOWN].data = _tree_placer[_patches_newgame.tree_placer];
- this->widget[GLAND_HEIGHTMAP_ROTATION_PULLDOWN].data = _rotation[_patches_newgame.heightmap_rotation];
+ this->widget[GLAND_TREE_PULLDOWN].data = _tree_placer[_settings_newgame.game_creation.tree_placer];
+ this->widget[GLAND_HEIGHTMAP_ROTATION_PULLDOWN].data = _rotation[_settings_newgame.game_creation.heightmap_rotation];
}
/* Set parameters for widget text that requires them. */
- SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); // GLAND_START_DATE_TEXT
- SetDParam(1, 1 << _patches_newgame.map_x); // GLAND_MAPSIZE_X_PULLDOWN
- SetDParam(2, 1 << _patches_newgame.map_y); // GLAND_MAPSIZE_Y_PULLDOWN
- SetDParam(3, _patches_newgame.snow_line_height); // GLAND_SNOW_LEVEL_TEXT
+ SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); // GLAND_START_DATE_TEXT
+ SetDParam(1, 1 << _settings_newgame.game_creation.map_x); // GLAND_MAPSIZE_X_PULLDOWN
+ SetDParam(2, 1 << _settings_newgame.game_creation.map_y); // GLAND_MAPSIZE_Y_PULLDOWN
+ SetDParam(3, _settings_newgame.game_creation.snow_line_height); // GLAND_SNOW_LEVEL_TEXT
this->DrawWidgets();
@@ -322,7 +320,7 @@
if (mode != GLWP_GENERATE) {
char buffer[512];
- if (_patches_newgame.heightmap_rotation == HM_CLOCKWISE) {
+ if (_settings_newgame.game_creation.heightmap_rotation == HM_CLOCKWISE) {
SetDParam(0, this->y);
SetDParam(1, this->x);
} else {
@@ -347,29 +345,29 @@
case GLAND_ARCTIC:
case GLAND_TROPICAL:
case GLAND_TOYLAND:
- this->RaiseWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
+ this->RaiseWidget(_settings_newgame.game_creation.landscape + GLAND_TEMPERATE);
SetNewLandscapeType(widget - GLAND_TEMPERATE);
break;
case GLAND_MAPSIZE_X_PULLDOWN: // Mapsize X
- ShowDropDownList(this, BuildMapsizeDropDown(), _patches_newgame.map_x, GLAND_MAPSIZE_X_PULLDOWN);
+ ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, GLAND_MAPSIZE_X_PULLDOWN);
break;
case GLAND_MAPSIZE_Y_PULLDOWN: // Mapsize Y
- ShowDropDownList(this, BuildMapsizeDropDown(), _patches_newgame.map_y, GLAND_MAPSIZE_Y_PULLDOWN);
+ ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, GLAND_MAPSIZE_Y_PULLDOWN);
break;
case GLAND_TOWN_PULLDOWN: // Number of towns
- ShowDropDownMenu(this, _num_towns, _opt_newgame.diff.number_towns, GLAND_TOWN_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _num_towns, _settings_newgame.difficulty.number_towns, GLAND_TOWN_PULLDOWN, 0, 0);
break;
case GLAND_INDUSTRY_PULLDOWN: // Number of industries
- ShowDropDownMenu(this, _num_inds, _opt_newgame.diff.number_industries, GLAND_INDUSTRY_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _num_inds, _settings_newgame.difficulty.number_industries, GLAND_INDUSTRY_PULLDOWN, 0, 0);
break;
case GLAND_RANDOM_BUTTON: // Random seed
- _patches_newgame.generation_seed = InteractiveRandom();
- snprintf(this->edit_str_buf, lengthof(this->edit_str_buf), "%u", _patches_newgame.generation_seed);
+ _settings_newgame.game_creation.generation_seed = InteractiveRandom();
+ snprintf(this->edit_str_buf, lengthof(this->edit_str_buf), "%u", _settings_newgame.game_creation.generation_seed);
UpdateTextBufferSize(&this->text);
this->SetDirty();
break;
@@ -381,17 +379,17 @@
case GLAND_GENERATE_BUTTON: // Generate
UpdatePatches();
- if (_patches.town_layout == TL_NO_ROADS) {
+ if (_settings.economy.town_layout == TL_NO_ROADS) {
ShowQuery(
STR_TOWN_LAYOUT_WARNING_CAPTION,
STR_TOWN_LAYOUT_WARNING_MESSAGE,
this,
LandscapeGenerationCallback);
} else if (mode == GLWP_HEIGHTMAP &&
- (this->x * 2 < (1U << _patches_newgame.map_x) ||
- this->x / 2 > (1U << _patches_newgame.map_x) ||
- this->y * 2 < (1U << _patches_newgame.map_y) ||
- this->y / 2 > (1U << _patches_newgame.map_y))) {
+ (this->x * 2 < (1U << _settings_newgame.game_creation.map_x) ||
+ this->x / 2 > (1U << _settings_newgame.game_creation.map_x) ||
+ this->y * 2 < (1U << _settings_newgame.game_creation.map_y) ||
+ this->y / 2 > (1U << _settings_newgame.game_creation.map_y))) {
ShowQuery(
STR_HEIGHTMAP_SCALE_WARNING_CAPTION,
STR_HEIGHTMAP_SCALE_WARNING_MESSAGE,
@@ -409,14 +407,14 @@
this->HandleButtonClick(widget);
this->SetDirty();
- _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
+ _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
}
_left_button_clicked = false;
break;
case GLAND_START_DATE_TEXT: // Year text
this->widget_id = GLAND_START_DATE_TEXT;
- SetDParam(0, _patches_newgame.starting_year);
+ SetDParam(0, _settings_newgame.game_creation.starting_year);
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL);
break;
@@ -427,40 +425,40 @@
this->HandleButtonClick(widget);
this->SetDirty();
- _patches_newgame.snow_line_height = Clamp(_patches_newgame.snow_line_height + widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
+ _settings_newgame.game_creation.snow_line_height = Clamp(_settings_newgame.game_creation.snow_line_height + widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
}
_left_button_clicked = false;
break;
case GLAND_SNOW_LEVEL_TEXT: // Snow line text
this->widget_id = GLAND_SNOW_LEVEL_TEXT;
- SetDParam(0, _patches_newgame.snow_line_height);
+ SetDParam(0, _settings_newgame.game_creation.snow_line_height);
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, this, CS_NUMERAL);
break;
case GLAND_TREE_PULLDOWN: // Tree placer
- ShowDropDownMenu(this, _tree_placer, _patches_newgame.tree_placer, GLAND_TREE_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _tree_placer, _settings_newgame.game_creation.tree_placer, GLAND_TREE_PULLDOWN, 0, 0);
break;
case GLAND_LANDSCAPE_PULLDOWN: // Landscape generator OR Heightmap rotation
/* case GLAND_HEIGHTMAP_ROTATION_TEXT: case GLAND_HEIGHTMAP_ROTATION_PULLDOWN:*/
if (mode == GLWP_HEIGHTMAP) {
- ShowDropDownMenu(this, _rotation, _patches_newgame.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _rotation, _settings_newgame.game_creation.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
} else {
- ShowDropDownMenu(this, _landscape, _patches_newgame.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _landscape, _settings_newgame.game_creation.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0);
}
break;
case GLAND_TERRAIN_PULLDOWN: // Terrain type
- ShowDropDownMenu(this, _elevations, _opt_newgame.diff.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _elevations, _settings_newgame.difficulty.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0);
break;
case GLAND_WATER_PULLDOWN: // Water quantity
- ShowDropDownMenu(this, _sea_lakes, _opt_newgame.diff.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _sea_lakes, _settings_newgame.difficulty.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0);
break;
case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness
- ShowDropDownMenu(this, _smoothness, _patches_newgame.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _smoothness, _settings_newgame.game_creation.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0);
break;
}
}
@@ -479,49 +477,49 @@
* (use random seed) it should not be possible to be
* entered into the input field; the generate seed
* button can be used instead. */
- _patches_newgame.generation_seed = minu(strtoul(this->edit_str_buf, NULL, sizeof(this->edit_str_buf) - 1), MAX_UVALUE(uint32) - 1);
+ _settings_newgame.game_creation.generation_seed = minu(strtoul(this->edit_str_buf, NULL, sizeof(this->edit_str_buf) - 1), MAX_UVALUE(uint32) - 1);
return state;
}
virtual void OnDropdownSelect(int widget, int index)
{
switch (widget) {
- case GLAND_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = index; break;
- case GLAND_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = index; break;
- case GLAND_TREE_PULLDOWN: _patches_newgame.tree_placer = index; break;
- case GLAND_SMOOTHNESS_PULLDOWN: _patches_newgame.tgen_smoothness = index; break;
+ case GLAND_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break;
+ case GLAND_MAPSIZE_Y_PULLDOWN: _settings_newgame.game_creation.map_y = index; break;
+ case GLAND_TREE_PULLDOWN: _settings_newgame.game_creation.tree_placer = index; break;
+ case GLAND_SMOOTHNESS_PULLDOWN: _settings_newgame.game_creation.tgen_smoothness = index; break;
case GLAND_TOWN_PULLDOWN:
- _opt_newgame.diff.number_towns = index;
- if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- DoCommandP(0, 2, _opt_newgame.diff.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+ _settings_newgame.difficulty.number_towns = index;
+ if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ IConsoleSetPatchSetting("difficulty.number_towns", _settings_newgame.difficulty.number_towns);
break;
case GLAND_INDUSTRY_PULLDOWN:
- _opt_newgame.diff.number_industries = index;
- if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+ _settings_newgame.difficulty.number_industries = index;
+ if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ IConsoleSetPatchSetting("difficulty.number_industries", _settings_newgame.difficulty.number_industries);
break;
case GLAND_LANDSCAPE_PULLDOWN:
/* case GLAND_HEIGHTMAP_PULLDOWN: */
if (mode == GLWP_HEIGHTMAP) {
- _patches_newgame.heightmap_rotation = index;
+ _settings_newgame.game_creation.heightmap_rotation = index;
} else {
- _patches_newgame.land_generator = index;
+ _settings_newgame.game_creation.land_generator = index;
}
break;
case GLAND_TERRAIN_PULLDOWN:
- _opt_newgame.diff.terrain_type = index;
- if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- DoCommandP(0, 12, _opt_newgame.diff.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+ _settings_newgame.difficulty.terrain_type = index;
+ if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ IConsoleSetPatchSetting("difficulty.terrain_type", _settings_newgame.difficulty.terrain_type);
break;
case GLAND_WATER_PULLDOWN:
- _opt_newgame.diff.quantity_sea_lakes = index;
- if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- DoCommandP(0, 13, _opt_newgame.diff.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+ _settings_newgame.difficulty.quantity_sea_lakes = index;
+ if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ IConsoleSetPatchSetting("difficulty.quantity_sea_lakes", _settings_newgame.difficulty.quantity_sea_lakes);
break;
}
this->SetDirty();
@@ -535,12 +533,12 @@
switch (this->widget_id) {
case GLAND_START_DATE_TEXT:
this->InvalidateWidget(GLAND_START_DATE_TEXT);
- _patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
+ _settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
break;
case GLAND_SNOW_LEVEL_TEXT:
this->InvalidateWidget(GLAND_SNOW_LEVEL_TEXT);
- _patches_newgame.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
+ _settings_newgame.game_creation.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
break;
}
@@ -571,7 +569,7 @@
DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
/* Always give a new seed if not editor */
- if (_game_mode != GM_EDITOR) _patches_newgame.generation_seed = InteractiveRandom();
+ if (_game_mode != GM_EDITOR) _settings_newgame.game_creation.generation_seed = InteractiveRandom();
if (mode == GLWP_HEIGHTMAP) {
/* If the function returns negative, it means there was a problem loading the heightmap */
@@ -601,8 +599,8 @@
void StartScenarioEditor()
{
- if (_patches_newgame.town_layout == TL_NO_ROADS) {
- _patches_newgame.town_layout = TL_ORIGINAL;
+ if (_settings_newgame.economy.town_layout == TL_NO_ROADS) {
+ _settings_newgame.economy.town_layout = TL_ORIGINAL;
}
StartGeneratingLandscape(GLWP_SCENARIO);
@@ -611,7 +609,7 @@
void StartNewGameWithoutGUI(uint seed)
{
/* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
- _patches_newgame.generation_seed = seed;
+ _settings_newgame.game_creation.generation_seed = seed;
StartGeneratingLandscape(GLWP_GENERATE);
}
@@ -644,26 +642,27 @@
CreateScenarioWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
- this->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
+ this->LowerWidget(_settings_newgame.game_creation.landscape + CSCEN_TEMPERATE);
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
{
- this->SetWidgetDisabledState(CSCEN_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR);
- this->SetWidgetDisabledState(CSCEN_START_DATE_UP, _patches_newgame.starting_year >= MAX_YEAR);
- this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0);
- this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP, _patches_newgame.se_flat_world_height >= MAX_TILE_HEIGHT);
+ this->SetWidgetDisabledState(CSCEN_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
+ this->SetWidgetDisabledState(CSCEN_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
+ this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _settings_newgame.game_creation.se_flat_world_height <= 0);
+ this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP, _settings_newgame.game_creation.se_flat_world_height >= MAX_TILE_HEIGHT);
- this->SetWidgetLoweredState(CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
- this->SetWidgetLoweredState(CSCEN_ARCTIC, _opt_newgame.landscape == LT_ARCTIC);
- this->SetWidgetLoweredState(CSCEN_TROPICAL, _opt_newgame.landscape == LT_TROPIC);
- this->SetWidgetLoweredState(CSCEN_TOYLAND, _opt_newgame.landscape == LT_TOYLAND);
+ this->SetWidgetLoweredState(CSCEN_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
+ this->SetWidgetLoweredState(CSCEN_ARCTIC, _settings_newgame.game_creation.landscape == LT_ARCTIC);
+ this->SetWidgetLoweredState(CSCEN_TROPICAL, _settings_newgame.game_creation.landscape == LT_TROPIC);
+ this->SetWidgetLoweredState(CSCEN_TOYLAND, _settings_newgame.game_creation.landscape == LT_TOYLAND);
/* Set parameters for widget text that requires them */
- SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); // CSCEN_START_DATE_TEXT
- SetDParam(1, 1 << _patches_newgame.map_x); // CSCEN_MAPSIZE_X_PULLDOWN
- SetDParam(2, 1 << _patches_newgame.map_y); // CSCEN_MAPSIZE_Y_PULLDOWN
- SetDParam(3, _patches_newgame.se_flat_world_height); // CSCEN_FLAT_LAND_HEIGHT_TEXT
+ SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); // CSCEN_START_DATE_TEXT
+ SetDParam(1, 1 << _settings_newgame.game_creation.map_x); // CSCEN_MAPSIZE_X_PULLDOWN
+ SetDParam(2, 1 << _settings_newgame.game_creation.map_y); // CSCEN_MAPSIZE_Y_PULLDOWN
+ SetDParam(3, _settings_newgame.game_creation.se_flat_world_height); // CSCEN_FLAT_LAND_HEIGHT_TEXT
this->DrawWidgets();
}
@@ -675,16 +674,16 @@
case CSCEN_ARCTIC:
case CSCEN_TROPICAL:
case CSCEN_TOYLAND:
- this->RaiseWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
+ this->RaiseWidget(_settings_newgame.game_creation.landscape + CSCEN_TEMPERATE);
SetNewLandscapeType(widget - CSCEN_TEMPERATE);
break;
case CSCEN_MAPSIZE_X_PULLDOWN: // Mapsize X
- ShowDropDownList(this, BuildMapsizeDropDown(), _patches_newgame.map_x, CSCEN_MAPSIZE_X_PULLDOWN);
+ ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, CSCEN_MAPSIZE_X_PULLDOWN);
break;
case CSCEN_MAPSIZE_Y_PULLDOWN: // Mapsize Y
- ShowDropDownList(this, BuildMapsizeDropDown(), _patches_newgame.map_y, CSCEN_MAPSIZE_Y_PULLDOWN);
+ ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, CSCEN_MAPSIZE_Y_PULLDOWN);
break;
case CSCEN_EMPTY_WORLD: // Empty world / flat world
@@ -702,14 +701,14 @@
this->HandleButtonClick(widget);
this->SetDirty();
- _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
+ _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
}
_left_button_clicked = false;
break;
case CSCEN_START_DATE_TEXT: // Year text
this->widget_id = CSCEN_START_DATE_TEXT;
- SetDParam(0, _patches_newgame.starting_year);
+ SetDParam(0, _settings_newgame.game_creation.starting_year);
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, this, CS_NUMERAL);
break;
@@ -720,14 +719,14 @@
this->HandleButtonClick(widget);
this->SetDirty();
- _patches_newgame.se_flat_world_height = Clamp(_patches_newgame.se_flat_world_height + widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
+ _settings_newgame.game_creation.se_flat_world_height = Clamp(_settings_newgame.game_creation.se_flat_world_height + widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
}
_left_button_clicked = false;
break;
case CSCEN_FLAT_LAND_HEIGHT_TEXT: // Height level text
this->widget_id = CSCEN_FLAT_LAND_HEIGHT_TEXT;
- SetDParam(0, _patches_newgame.se_flat_world_height);
+ SetDParam(0, _settings_newgame.game_creation.se_flat_world_height);
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, this, CS_NUMERAL);
break;
}
@@ -736,8 +735,8 @@
virtual void OnDropdownSelect(int widget, int index)
{
switch (widget) {
- case CSCEN_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = index; break;
- case CSCEN_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = index; break;
+ case CSCEN_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break;
+ case CSCEN_MAPSIZE_Y_PULLDOWN: _settings_newgame.game_creation.map_y = index; break;
}
this->SetDirty();
}
@@ -750,12 +749,12 @@
switch (this->widget_id) {
case CSCEN_START_DATE_TEXT:
this->InvalidateWidget(CSCEN_START_DATE_TEXT);
- _patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
+ _settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
break;
case CSCEN_FLAT_LAND_HEIGHT_TEXT:
this->InvalidateWidget(CSCEN_FLAT_LAND_HEIGHT_TEXT);
- _patches_newgame.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT);
+ _settings_newgame.game_creation.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT);
break;
}
@@ -850,7 +849,10 @@
};
public:
- GenerateProgressWindow() : Window(&_generate_progress_desc) {};
+ GenerateProgressWindow() : Window(&_generate_progress_desc)
+ {
+ this->FindWindowPlacementAndResize(&_generate_progress_desc);
+ }
virtual void OnClick(Point pt, int widget)
{
--- a/src/gfx.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/gfx.cpp Mon May 26 13:52:59 2008 +0000
@@ -427,9 +427,9 @@
}
}
-/** Draw a given string with the centre around the given x coordinates
+/** Draw a given string with the centre around the given (x,y) coordinates
* @param x Centre the string around this pixel width
- * @param y Draw the string at this pixel height (first line's bottom)
+ * @param y Centre the string around this pixel height
* @param str String to draw
* @param maxw Maximum width the string can have before it is wrapped */
void DrawStringMultiCenter(int x, int y, StringID str, int maxw)
@@ -807,7 +807,7 @@
memcpy(old_val, d, c * sizeof(*old_val));
/* Dark blue water */
- s = (_opt.landscape == LT_TOYLAND) ? ev->ac : ev->a;
+ s = (_settings.game_creation.landscape == LT_TOYLAND) ? ev->ac : ev->a;
j = EXTR(320, 5);
for (i = 0; i != 5; i++) {
*d++ = s[j];
@@ -816,7 +816,7 @@
}
/* Glittery water */
- s = (_opt.landscape == LT_TOYLAND) ? ev->bc : ev->b;
+ s = (_settings.game_creation.landscape == LT_TOYLAND) ? ev->bc : ev->b;
j = EXTR(128, 15);
for (i = 0; i != 5; i++) {
*d++ = s[j];
@@ -876,7 +876,7 @@
/* Animate water for old DOS graphics */
if (_use_dos_palette) {
/* Dark blue water DOS */
- s = (_opt.landscape == LT_TOYLAND) ? ev->ac : ev->a;
+ s = (_settings.game_creation.landscape == LT_TOYLAND) ? ev->ac : ev->a;
j = EXTR(320, 5);
for (i = 0; i != 5; i++) {
*d++ = s[j];
@@ -885,7 +885,7 @@
}
/* Glittery water DOS */
- s = (_opt.landscape == LT_TOYLAND) ? ev->bc : ev->b;
+ s = (_settings.game_creation.landscape == LT_TOYLAND) ? ev->bc : ev->b;
j = EXTR(128, 15);
for (i = 0; i != 5; i++) {
*d++ = s[j];
--- a/src/gfxinit.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/gfxinit.cpp Mon May 26 13:52:59 2008 +0000
@@ -214,10 +214,10 @@
* This overwrites some of the temperate sprites, such as foundations
* and the ground sprites.
*/
- if (_opt.landscape != LT_TEMPERATE) {
+ if (_settings.game_creation.landscape != LT_TEMPERATE) {
LoadGrfIndexed(
- files->landscape[_opt.landscape - 1].filename,
- _landscape_spriteindexes[_opt.landscape - 1],
+ files->landscape[_settings.game_creation.landscape - 1].filename,
+ _landscape_spriteindexes[_settings.game_creation.landscape - 1],
i++
);
}
@@ -248,7 +248,7 @@
void GfxLoadSprites()
{
- DEBUG(sprite, 2, "Loading sprite set %d", _opt.landscape);
+ DEBUG(sprite, 2, "Loading sprite set %d", _settings.game_creation.landscape);
GfxInitSpriteMem();
LoadSpriteTables();
--- a/src/graph_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/graph_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -769,6 +769,7 @@
struct CompanyLeagueWindow : Window {
CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
--- a/src/heightmap.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/heightmap.cpp Mon May 26 13:52:59 2008 +0000
@@ -297,7 +297,7 @@
TileIndex tile;
/* Get map size and calculate scale and padding values */
- switch (_patches.heightmap_rotation) {
+ switch (_settings.game_creation.heightmap_rotation) {
default: NOT_REACHED();
case HM_COUNTER_CLOCKWISE:
width = MapSizeX();
@@ -322,7 +322,7 @@
/* Form the landscape */
for (row = 0; row < height - 1; row++) {
for (col = 0; col < width - 1; col++) {
- switch (_patches.heightmap_rotation) {
+ switch (_settings.game_creation.heightmap_rotation) {
default: NOT_REACHED();
case HM_COUNTER_CLOCKWISE: tile = TileXY(col, row); break;
case HM_CLOCKWISE: tile = TileXY(row, col); break;
@@ -337,7 +337,7 @@
/* Use nearest neighbor resizing to scale map data.
* We rotate the map 45 degrees (counter)clockwise */
img_row = (((row - row_pad) * num_div) / img_scale);
- switch (_patches.heightmap_rotation) {
+ switch (_settings.game_creation.heightmap_rotation) {
default: NOT_REACHED();
case HM_COUNTER_CLOCKWISE:
img_col = (((width - 1 - col - col_pad) * num_div) / img_scale);
--- a/src/industry_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/industry_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -70,7 +70,7 @@
/* once performed, enable only the current climate industries */
for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) {
_industry_specs[i].enabled = i < NEW_INDUSTRYOFFSET &&
- HasBit(_origin_industry_specs[i].climate_availability, _opt.landscape);
+ HasBit(_origin_industry_specs[i].climate_availability, _settings.game_creation.landscape);
}
memset(&_industry_tile_specs, 0, sizeof(_industry_tile_specs));
@@ -84,7 +84,7 @@
void ResetIndustryCreationProbility(IndustryType type)
{
assert(type < INVALID_INDUSTRYTYPE);
- _industry_specs[type].appear_creation[_opt.landscape] = 0;
+ _industry_specs[type].appear_creation[_settings.game_creation.landscape] = 0;
}
DEFINE_OLD_POOL_GENERIC(Industry, Industry)
@@ -377,7 +377,7 @@
{
const Industry *i = GetIndustryByTile(tile);
- td->owner = i->owner;
+ td->owner[0] = i->owner;
td->str = GetIndustrySpec(i->type)->name;
if (!IsIndustryCompleted(tile)) {
SetDParamX(td->dparam, 0, td->str);
@@ -888,14 +888,14 @@
uint field_type;
int type;
- if (_opt.landscape == LT_ARCTIC) {
+ if (_settings.game_creation.landscape == LT_ARCTIC) {
if (GetTileZ(tile) + TILE_HEIGHT * 2 >= GetSnowLine())
return;
}
/* determine field size */
r = (Random() & 0x303) + 0x404;
- if (_opt.landscape == LT_ARCTIC) r += 0x404;
+ if (_settings.game_creation.landscape == LT_ARCTIC) r += 0x404;
size_x = GB(r, 0, 8);
size_y = GB(r, 8, 8);
@@ -926,7 +926,7 @@
END_TILE_LOOP(cur_tile, size_x, size_y, tile)
type = 3;
- if (_opt.landscape != LT_ARCTIC && _opt.landscape != LT_TROPIC) {
+ if (_settings.game_creation.landscape != LT_ARCTIC && _settings.game_creation.landscape != LT_TROPIC) {
type = _plantfarmfield_type[Random() & 0xF];
}
@@ -1063,7 +1063,7 @@
static bool CheckNewIndustry_Forest(TileIndex tile)
{
- if (_opt.landscape == LT_ARCTIC) {
+ if (_settings.game_creation.landscape == LT_ARCTIC) {
if (GetTileZ(tile) < HighestSnowLine() + TILE_HEIGHT * 2U) {
_error_message = STR_4831_FOREST_CAN_ONLY_BE_PLANTED;
return false;
@@ -1075,7 +1075,7 @@
static bool CheckNewIndustry_OilRefinery(TileIndex tile)
{
if (_game_mode == GM_EDITOR) return true;
- if (DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _patches.oil_refinery_limit) return true;
+ if (DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _settings.game_creation.oil_refinery_limit) return true;
_error_message = STR_483B_CAN_ONLY_BE_POSITIONED;
return false;
@@ -1087,7 +1087,7 @@
{
if (_game_mode == GM_EDITOR && _ignore_restrictions) return true;
if (TileHeight(tile) == 0 &&
- DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _patches.oil_refinery_limit) return true;
+ DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _settings.game_creation.oil_refinery_limit) return true;
_error_message = STR_483B_CAN_ONLY_BE_POSITIONED;
return false;
@@ -1095,7 +1095,7 @@
static bool CheckNewIndustry_Farm(TileIndex tile)
{
- if (_opt.landscape == LT_ARCTIC) {
+ if (_settings.game_creation.landscape == LT_ARCTIC) {
if (GetTileZ(tile) + TILE_HEIGHT * 2 >= HighestSnowLine()) {
_error_message = STR_0239_SITE_UNSUITABLE;
return false;
@@ -1171,7 +1171,7 @@
t = ClosestTownFromTile(tile, (uint)-1);
- if (_patches.multiple_industry_per_town) return t;
+ if (_settings.economy.multiple_industry_per_town) return t;
FOR_ALL_INDUSTRIES(i) {
if (i->type == (byte)type &&
@@ -1257,7 +1257,7 @@
/* It is almost impossible to have a fully flat land in TG, so what we
* do is that we check if we can make the land flat later on. See
* CheckIfCanLevelIndustryPlatform(). */
- return !refused_slope || (_patches.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape && !_ignore_restrictions);
+ return !refused_slope || (_settings.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !custom_shape && !_ignore_restrictions);
}
static bool CheckIfIndustryIsAllowed(TileIndex tile, int type, const Town *t)
@@ -1387,7 +1387,7 @@
const IndustrySpec *indspec = GetIndustrySpec(type);
const Industry *i;
- if (_patches.same_industry_close && indspec->IsRawIndustry())
+ if (_settings.economy.same_industry_close && indspec->IsRawIndustry())
/* Allow primary industries to be placed close to any other industry */
return true;
@@ -1401,8 +1401,8 @@
indspec->accepts_cargo[0] == i->accepts_cargo[0] && (
/* at least one of those options must be true */
_game_mode != GM_EDITOR || // editor must not be stopped
- !_patches.same_industry_close ||
- !_patches.multiple_industry_per_town)) {
+ !_settings.economy.same_industry_close ||
+ !_settings.economy.multiple_industry_per_town)) {
_error_message = STR_INDUSTRY_TOO_CLOSE;
return false;
}
@@ -1449,7 +1449,7 @@
i->production_rate[1] = indspec->production_rate[1];
/* don't use smooth economy for industries using production related callbacks */
- if (_patches.smooth_economy &&
+ if (_settings.economy.smooth_economy &&
!(HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks
!(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE)) // production change callbacks
) {
@@ -1577,7 +1577,7 @@
if (!_check_new_industry_procs[indspec->check_proc](tile)) return NULL;
}
- if (!custom_shape_check && _patches.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL;
+ if (!custom_shape_check && _settings.game_creation.land_generator == LG_TERRAGENESIS && _generating_world && !_ignore_restrictions && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL;
if (!CheckIfFarEnoughFromIndustry(tile, type)) return NULL;
const Town *t = CheckMultipleIndustryInTown(tile, type);
@@ -1621,11 +1621,11 @@
/* If the patch for raw-material industries is not on, you cannot build raw-material industries.
* Raw material industries are industries that do not accept cargo (at least for now) */
- if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 0 && indspec->IsRawIndustry()) {
+ if (_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 0 && indspec->IsRawIndustry()) {
return CMD_ERROR;
}
- if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indspec->IsRawIndustry()) {
+ if (_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 2 && indspec->IsRawIndustry()) {
if (flags & DC_EXEC) {
/* Prospecting has a chance to fail, however we cannot guarantee that something can
* be built on the map, so the chance gets lower when the map is fuller, but there
@@ -1700,13 +1700,13 @@
{
/* We need to bypass the amount given in parameter if it exceeds the maximum dimension of the
* _numof_industry_table. newgrf can specify a big amount */
- int num = (amount > NB_NUMOFINDUSTRY) ? amount : _numof_industry_table[_opt.diff.number_industries][amount];
+ int num = (amount > NB_NUMOFINDUSTRY) ? amount : _numof_industry_table[_settings.difficulty.number_industries][amount];
const IndustrySpec *ind_spc = GetIndustrySpec(type);
/* These are always placed next to the coastline, so we scale by the perimeter instead. */
num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
- if (_opt.diff.number_industries != 0) {
+ if (_settings.difficulty.number_industries != 0) {
PlayerID old_player = _current_player;
_current_player = OWNER_NONE;
assert(num > 0);
@@ -1735,7 +1735,7 @@
const IndustrySpec *ind_spc;
/* Find the total amount of industries */
- if (_opt.diff.number_industries > 0) {
+ if (_settings.difficulty.number_industries > 0) {
for (it = 0; it < NUM_INDUSTRYTYPES; it++) {
ind_spc = GetIndustrySpec(it);
@@ -1744,12 +1744,12 @@
ResetIndustryCreationProbility(it);
}
- chance = ind_spc->appear_creation[_opt.landscape];
+ chance = ind_spc->appear_creation[_settings.game_creation.landscape];
if (ind_spc->enabled && chance > 0) {
/* once the chance of appearance is determind, it have to be scaled by
* the difficulty level. The "chance" in question is more an index into
* the _numof_industry_table,in fact */
- int num = (chance > NB_NUMOFINDUSTRY) ? chance : _numof_industry_table[_opt.diff.number_industries][chance];
+ int num = (chance > NB_NUMOFINDUSTRY) ? chance : _numof_industry_table[_settings.difficulty.number_industries][chance];
/* These are always placed next to the coastline, so we scale by the perimeter instead. */
num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
@@ -1760,7 +1760,7 @@
SetGeneratingWorldProgress(GWP_INDUSTRY, i);
- if (_opt.diff.number_industries > 0) {
+ if (_settings.difficulty.number_industries > 0) {
for (it = 0; it < NUM_INDUSTRYTYPES; it++) {
/* Once the number of industries has been determined, let's really create them.
* The test for chance allows us to try create industries that are available only
@@ -1769,7 +1769,7 @@
* processed that scaling above? No, don't think so. Will find a way. */
ind_spc = GetIndustrySpec(it);
if (ind_spc->enabled) {
- chance = ind_spc->appear_creation[_opt.landscape];
+ chance = ind_spc->appear_creation[_settings.game_creation.landscape];
if (chance > 0) PlaceInitialIndustry(it, chance);
}
}
@@ -1823,7 +1823,7 @@
/* Generate a list of all possible industries that can be built. */
for (j = 0; j < NUM_INDUSTRYTYPES; j++) {
ind_spc = GetIndustrySpec(j);
- byte chance = ind_spc->appear_ingame[_opt.landscape];
+ byte chance = ind_spc->appear_ingame[_settings.game_creation.landscape];
if (!ind_spc->enabled || chance == 0) continue;
@@ -1881,7 +1881,7 @@
const IndustrySpec *indspec = GetIndustrySpec(type);
/* oil wells (or the industries with that flag set) are always allowed to closedown */
- if (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD && _opt.landscape == LT_TEMPERATE) return false;
+ if (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD && _settings.game_creation.landscape == LT_TEMPERATE) return false;
return (indspec->behaviour & INDUSTRYBEH_CANCLOSE_LASTINSTANCE) == 0 && GetIndustryTypeCount(type) <= 1;
}
@@ -1953,10 +1953,9 @@
bool c_accepts = false;
bool c_produces = false;
if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
- const Vehicle *u = v;
- BEGIN_ENUM_WAGONS(u)
+ for (const Vehicle *u = v; u != NULL; u = u->Next()) {
CanCargoServiceIndustry(u->cargo_type, ind, &c_accepts, &c_produces);
- END_ENUM_WAGONS(u)
+ }
} else if (v->type == VEH_ROAD || v->type == VEH_SHIP || v->type == VEH_AIRCRAFT) {
CanCargoServiceIndustry(v->cargo_type, ind, &c_accepts, &c_produces);
} else {
@@ -2032,7 +2031,7 @@
bool standard = true;
bool suppress_message = false;
/* don't use smooth economy for industries using production related callbacks */
- bool smooth_economy = _patches.smooth_economy &&
+ bool smooth_economy = _settings.economy.smooth_economy &&
!(HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_256_TICKS) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) && // production callbacks
!(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE)); // production change callbacks
byte div = 0;
@@ -2073,7 +2072,7 @@
if (standard && (indspec->life_type & (INDUSTRYLIFE_ORGANIC | INDUSTRYLIFE_EXTRACTIVE)) != 0) {
/* decrease or increase */
- bool only_decrease = (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _opt.landscape == LT_TEMPERATE;
+ bool only_decrease = (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _settings.game_creation.landscape == LT_TEMPERATE;
if (smooth_economy) {
closeit = true;
@@ -2258,7 +2257,7 @@
Money IndustrySpec::GetConstructionCost() const
{
return (_price.build_industry *
- (_patches.raw_industry_construction == 1 && this->IsRawIndustry() ?
+ (_settings.construction.raw_industry_construction == 1 && this->IsRawIndustry() ?
this->raw_industry_cost_multiplier :
this->cost_multiplier
)) >> 8;
--- a/src/industry_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/industry_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -131,7 +131,7 @@
/* Rule is that editor mode loads all industries.
* In game mode, all non raw industries are loaded too
* and raw ones are loaded only when setting allows it */
- if (_game_mode != GM_EDITOR && indsp->IsRawIndustry() && _patches.raw_industry_construction == 0) {
+ if (_game_mode != GM_EDITOR && indsp->IsRawIndustry() && _settings.construction.raw_industry_construction == 0) {
/* Unselect if the industry is no longer in the list */
if (this->selected_type == ind) this->selected_index = -1;
continue;
@@ -195,10 +195,10 @@
* In Editor, you just build, while ingame, or you fund or you prospect */
if (_game_mode == GM_EDITOR) {
/* We've chosen many random industries but no industries have been specified */
- if (indsp == NULL) this->enabled[this->selected_index] = _opt.diff.number_industries != 0;
+ if (indsp == NULL) this->enabled[this->selected_index] = _settings.difficulty.number_industries != 0;
this->widget[DPIW_FUND_WIDGET].data = STR_BUILD_NEW_INDUSTRY;
} else {
- this->widget[DPIW_FUND_WIDGET].data = (_patches.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;
+ this->widget[DPIW_FUND_WIDGET].data = (_settings.construction.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;
}
this->SetWidgetDisabledState(DPIW_FUND_WIDGET, !this->enabled[this->selected_index]);
@@ -304,7 +304,7 @@
this->SetDirty();
- if ((_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
+ if ((_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 2 && indsp != NULL && indsp->IsRawIndustry()) ||
this->selected_type == INVALID_INDUSTRYTYPE) {
/* Reset the button state if going to prospecting or "build many industries" */
this->RaiseButtons();
@@ -325,7 +325,7 @@
GenerateIndustries();
_generating_world = false;
}
- } else if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
+ } else if (_game_mode != GM_EDITOR && _settings.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
DoCommandP(0, this->selected_type, InteractiveRandom(), NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
this->HandleButtonClick(DPIW_FUND_WIDGET);
} else {
@@ -721,6 +721,34 @@
static const Industry* _last_industry;
static int _internal_sort_order;
+/** Returns percents of cargo transported if industry produces this cargo, else -1
+ * @param i industry to check
+ * @param id cargo slot
+ * @return percents of cargo transported, or -1 if industry doesn't use this cargo slot
+ */
+static inline int GetCargoTransportedPercentsIfValid(const Industry *i, uint id)
+{
+ assert(id < lengthof(i->produced_cargo));
+
+ if (i->produced_cargo[id] == CT_INVALID) return 101;
+ return i->last_month_pct_transported[id] * 100 >> 8;
+}
+
+/** Returns value representing industry's transported cargo
+ * percentage for industry sorting
+ * @param i industry to check
+ * @return value used for sorting
+ */
+static int GetCargoTransportedSortValue(const Industry *i)
+{
+ int p1 = GetCargoTransportedPercentsIfValid(i, 0);
+ int p2 = GetCargoTransportedPercentsIfValid(i, 1);
+
+ if (p1 > p2) Swap(p1, p2); // lower value has higher priority
+
+ return (p1 << 8) + p2;
+}
+
static int CDECL GeneralIndustrySorter(const void *a, const void *b)
{
const Industry* i = *(const Industry**)a;
@@ -752,30 +780,7 @@
break;
case 3: /* Sort by transported fraction */
- if (i->produced_cargo[0] == CT_INVALID) {
- r = (j->produced_cargo[0] == CT_INVALID ? 0 : -1);
- } else {
- if (j->produced_cargo[0] == CT_INVALID) {
- r = 1;
- } else {
- int pi;
- int pj;
-
- pi = i->last_month_pct_transported[0] * 100 >> 8;
- if (i->produced_cargo[1] != CT_INVALID) {
- int p = i->last_month_pct_transported[1] * 100 >> 8;
- if (p < pi) pi = p;
- }
-
- pj = j->last_month_pct_transported[0] * 100 >> 8;
- if (j->produced_cargo[1] != CT_INVALID) {
- int p = j->last_month_pct_transported[1] * 100 >> 8;
- if (p < pj) pj = p;
- }
-
- r = pi - pj;
- }
- }
+ r = GetCargoTransportedSortValue(i) - GetCargoTransportedSortValue(j);
break;
}
--- a/src/intro_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/intro_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -49,7 +49,7 @@
static inline void SetNewLandscapeType(byte landscape)
{
- _opt_newgame.landscape = landscape;
+ _settings_newgame.game_creation.landscape = landscape;
InvalidateWindowClasses(WC_SELECT_GAME);
}
@@ -76,17 +76,17 @@
public:
SelectGameWindow(const WindowDesc *desc) : Window(desc)
{
- this->LowerWidget(_opt_newgame.landscape + SGI_TEMPERATE_LANDSCAPE);
+ this->LowerWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE);
this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
{
- this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _opt_newgame.landscape == LT_TEMPERATE);
- this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _opt_newgame.landscape == LT_ARCTIC);
- this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _opt_newgame.landscape == LT_TROPIC);
- this->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _opt_newgame.landscape == LT_TOYLAND);
- SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level);
+ this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
+ this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_ARCTIC);
+ this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TROPIC);
+ this->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TOYLAND);
+ SetDParam(0, STR_6801_EASY + _settings_newgame.difficulty.diff_level);
this->DrawWidgets();
}
@@ -115,7 +115,7 @@
case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE:
case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE:
- this->RaiseWidget(_opt_newgame.landscape + SGI_TEMPERATE_LANDSCAPE);
+ this->RaiseWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE);
SetNewLandscapeType(widget - SGI_TEMPERATE_LANDSCAPE);
break;
--- a/src/landscape.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/landscape.cpp Mon May 26 13:52:59 2008 +0000
@@ -526,7 +526,7 @@
*/
byte GetSnowLine(void)
{
- if (_snow_line == NULL) return _opt.snow_line;
+ if (_snow_line == NULL) return _settings.game_creation.snow_line;
YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd);
@@ -539,7 +539,7 @@
*/
byte HighestSnowLine(void)
{
- return _snow_line == NULL ? _opt.snow_line : _snow_line->highest_value;
+ return _snow_line == NULL ? _settings.game_creation.snow_line : _snow_line->highest_value;
}
/**
@@ -818,14 +818,14 @@
static const int gwp_desert_amount = 4 + 8;
if (mode == GW_HEIGHTMAP) {
- SetGeneratingWorldProgress(GWP_LANDSCAPE, (_opt.landscape == LT_TROPIC) ? 1 + gwp_desert_amount : 1);
+ SetGeneratingWorldProgress(GWP_LANDSCAPE, (_settings.game_creation.landscape == LT_TROPIC) ? 1 + gwp_desert_amount : 1);
LoadHeightmap(_file_to_saveload.name);
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
- } else if (_patches.land_generator == LG_TERRAGENESIS) {
- SetGeneratingWorldProgress(GWP_LANDSCAPE, (_opt.landscape == LT_TROPIC) ? 3 + gwp_desert_amount : 3);
+ } else if (_settings.game_creation.land_generator == LG_TERRAGENESIS) {
+ SetGeneratingWorldProgress(GWP_LANDSCAPE, (_settings.game_creation.landscape == LT_TROPIC) ? 3 + gwp_desert_amount : 3);
GenerateTerrainPerlin();
} else {
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_ARCTIC: {
SetGeneratingWorldProgress(GWP_LANDSCAPE, 2);
@@ -872,9 +872,9 @@
uint32 r = Random();
- uint i = ScaleByMapSize(GB(r, 0, 7) + (3 - _opt.diff.quantity_sea_lakes) * 256 + 100);
+ uint i = ScaleByMapSize(GB(r, 0, 7) + (3 - _settings.difficulty.quantity_sea_lakes) * 256 + 100);
for (; i != 0; --i) {
- GenerateTerrain(_opt.diff.terrain_type, 0);
+ GenerateTerrain(_settings.difficulty.terrain_type, 0);
}
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
} break;
@@ -883,7 +883,7 @@
ConvertGroundTilesIntoWaterTiles();
- if (_opt.landscape == LT_TROPIC) CreateDesertOrRainForest();
+ if (_settings.game_creation.landscape == LT_TROPIC) CreateDesertOrRainForest();
}
void OnTick_Town();
--- a/src/lang/english.txt Mon May 26 11:36:42 2008 +0000
+++ b/src/lang/english.txt Mon May 26 13:52:59 2008 +0000
@@ -486,6 +486,9 @@
STR_01A5_COST_TO_CLEAR :{BLACK}Cost to clear: {LTBLUE}{CURRENCY}
STR_01A6_N_A :N/A
STR_01A7_OWNER :{BLACK}Owner: {LTBLUE}{STRING1}
+STR_ROAD_OWNER :{BLACK}Road owner: {LTBLUE}{STRING1}
+STR_TRAM_OWNER :{BLACK}Tramway owner: {LTBLUE}{STRING1}
+STR_RAIL_OWNER :{BLACK}Railroad owner: {LTBLUE}{STRING1}
STR_01A8_LOCAL_AUTHORITY :{BLACK}Local authority: {LTBLUE}{STRING1}
STR_01A9_NONE :None
STR_01AA_NAME :{BLACK}Name
@@ -1715,6 +1718,7 @@
STR_1816_TREE_LINED_ROAD :Tree-lined road
STR_1817_ROAD_VEHICLE_DEPOT :Road vehicle depot
STR_1818_ROAD_RAIL_LEVEL_CROSSING :Road/rail level crossing
+STR_TRAMWAY :Tramway
STR_CAN_T_REMOVE_BUS_STATION :{WHITE}Can't remove bus station...
STR_CAN_T_REMOVE_TRUCK_STATION :{WHITE}Can't remove lorry station...
STR_CAN_T_REMOVE_PASSENGER_TRAM_STATION :{WHITE}Can't remove passenger tram station...
@@ -3556,4 +3560,10 @@
STR_AI_DEBUG_NAME_TIP :{BLACK}Name of the AI
STR_AI_DEBUG_RELOAD :{BLACK}Reload AI
STR_AI_DEBUG_RELOAD_TIP :{BLACK}Kill the AI, reload the script, and restart the AI
-########
\ No newline at end of file
+########
+
+############ town controlled noise level
+STR_CONFIG_PATCHES_NOISE_LEVEL :{LTBLUE}Allow town controlled noise level for airports: {ORANGE}{STRING}
+STR_NOISE_IN_TOWN :{BLACK}Noise limit in town: {ORANGE}{COMMA}{BLACK} max: {ORANGE}{COMMA}
+STR_STATION_NOISE :{BLACK}Noise generated: {GOLD}{COMMA}
+########
--- a/src/main_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/main_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -13,7 +13,7 @@
#include "viewport_func.h"
#include "command_func.h"
#include "news_gui.h"
-#include "console.h"
+#include "console_gui.h"
#include "waypoint.h"
#include "genworld.h"
#include "transparency_gui.h"
@@ -49,7 +49,7 @@
void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
#ifdef ENABLE_NETWORK
- if (!success || !_patches.give_money) return;
+ if (!success || !_settings.economy.give_money) return;
char msg[20];
/* Inform the player of this action */
@@ -345,7 +345,7 @@
if (cio == NULL) break;
/* Only players actually playing can speak to team. Eg spectators cannot */
- if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
+ if (_settings.gui.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
const NetworkClientInfo *ci;
FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
if (ci->client_playas == cio->client_playas && ci != cio) {
--- a/src/misc.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/misc.cpp Mon May 26 13:52:59 2008 +0000
@@ -68,9 +68,10 @@
_realtime_tick = 0;
_date_fract = 0;
_cur_tileloop_tile = 0;
+ _settings = _settings_newgame;
if ((mode & IG_DATE_RESET) == IG_DATE_RESET) {
- SetDate(ConvertYMDToDate(_patches.starting_year, 0, 1));
+ SetDate(ConvertYMDToDate(_settings.game_creation.starting_year, 0, 1));
InitializeOldNames();
}
--- a/src/misc/smallvec.h Mon May 26 11:36:42 2008 +0000
+++ b/src/misc/smallvec.h Mon May 26 13:52:59 2008 +0000
@@ -1,11 +1,12 @@
/* $Id$ */
-/** @file smallvec.h Simple vector class that allows allocating an item without the need to copy data needlessly. */
+/** @file smallvec.h Simple vector class that allows allocating an item without the need to copy this->data needlessly. */
#ifndef SMALLVEC_H
#define SMALLVEC_H
-template <typename T, uint S> struct SmallVector {
+template <typename T, uint S>
+struct SmallVector {
T *data;
uint items;
uint capacity;
@@ -14,7 +15,30 @@
~SmallVector()
{
- free(data);
+ free(this->data);
+ }
+
+ /**
+ * Remove all items from the list.
+ */
+ void Clear()
+ {
+ /* In fact we just reset the item counter avoiding the need to
+ * probably reallocate the same amount of memory the list was
+ * previously using. */
+ this->items = 0;
+ }
+
+ /**
+ * Compact the list down to the smallest block size boundary.
+ */
+ void Compact()
+ {
+ uint capacity = Align(this->items, S);
+ if (capacity >= this->capacity) return;
+
+ this->capacity = capacity;
+ this->data = ReallocT(this->data, this->capacity);
}
/**
@@ -22,42 +46,60 @@
*/
T *Append()
{
- if (items == capacity) {
- capacity += S;
- data = ReallocT(data, capacity);
+ if (this->items == this->capacity) {
+ this->capacity += S;
+ this->data = ReallocT(this->data, this->capacity);
}
- return &data[items++];
+ return &this->data[this->items++];
+ }
+
+ /**
+ * Get the number of items in the list.
+ */
+ uint Length() const
+ {
+ return this->items;
}
const T *Begin() const
{
- return data;
+ return this->data;
}
T *Begin()
{
- return data;
+ return this->data;
}
const T *End() const
{
- return &data[items];
+ return &this->data[this->items];
}
T *End()
{
- return &data[items];
+ return &this->data[this->items];
}
- const T *Get(size_t index) const
+ const T *Get(uint index) const
{
- return &data[index];
+ return &this->data[index];
}
- T *Get(size_t index)
+ T *Get(uint index)
{
- return &data[index];
+ return &this->data[index];
+ }
+
+ const T &operator[](uint index) const
+ {
+ return this->data[index];
+ }
+
+ T &operator[](uint index)
+ {
+ return this->data[index];
}
};
--- a/src/misc_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/misc_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -369,7 +369,7 @@
*/
CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- if (!_patches.give_money) return CMD_ERROR;
+ if (!_settings.economy.give_money) return CMD_ERROR;
const Player *p = GetPlayer(_current_player);
CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
@@ -389,35 +389,3 @@
/* Subtract money from local-player */
return amount;
}
-
-/** Change difficulty level/settings (server-only).
- * We cannot really check for valid values of p2 (too much work mostly); stored
- * in file 'settings_gui.c' _game_setting_info[]; we'll just trust the server it knows
- * what to do and does this correctly
- * @param tile unused
- * @param flags operation to perform
- * @param p1 the difficulty setting being changed. If it is -1, the difficulty level
- * itself is changed. The new value is inside p2
- * @param p2 new value for a difficulty setting or difficulty level
- */
-CommandCost CmdChangeDifficultyLevel(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
-{
- if (p1 != (uint32)-1L && ((int32)p1 >= GAME_DIFFICULTY_NUM || (int32)p1 < 0)) return CMD_ERROR;
-
- if (flags & DC_EXEC) {
- if (p1 != (uint32)-1L) {
- ((GDType*)&_opt_ptr->diff)[p1] = p2;
- _opt_ptr->diff_level = 3; // custom difficulty level
- } else {
- _opt_ptr->diff_level = p2;
- }
-
- /* If we are a network-client, update the difficult setting (if it is open).
- * Use this instead of just dirtying the window because we need to load in
- * the new difficulty settings */
- if (_networking && !_network_server && FindWindowById(WC_GAME_OPTIONS, 0) != NULL) {
- ShowGameDifficulty();
- }
- }
- return CommandCost();
-}
--- a/src/misc_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/misc_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -73,29 +73,36 @@
class LandInfoWindow : public Window {
enum {
- LAND_INFO_LINES = 7,
+ LAND_INFO_CENTERED_LINES = 9, ///< Up to 9 centered lines
+ LAND_INFO_MULTICENTER_LINE = LAND_INFO_CENTERED_LINES, ///< One multicenter line
+ LAND_INFO_LINE_END,
+
LAND_INFO_LINE_BUFF_SIZE = 512,
};
public:
- char landinfo_data[LAND_INFO_LINES][LAND_INFO_LINE_BUFF_SIZE];
+ char landinfo_data[LAND_INFO_LINE_END][LAND_INFO_LINE_BUFF_SIZE];
virtual void OnPaint()
{
this->DrawWidgets();
- DoDrawStringCentered(140, 16, this->landinfo_data[0], TC_LIGHT_BLUE);
- DoDrawStringCentered(140, 27, this->landinfo_data[1], TC_FROMSTRING);
- DoDrawStringCentered(140, 38, this->landinfo_data[2], TC_FROMSTRING);
- DoDrawStringCentered(140, 49, this->landinfo_data[3], TC_FROMSTRING);
- DoDrawStringCentered(140, 60, this->landinfo_data[4], TC_FROMSTRING);
- if (!StrEmpty(this->landinfo_data[5])) DrawStringMultiCenter(140, 76, BindCString(this->landinfo_data[5]), this->width - 4);
- if (!StrEmpty(this->landinfo_data[6])) DoDrawStringCentered(140, 71, this->landinfo_data[6], TC_FROMSTRING);
+ uint y = 16;
+ for (uint i = 0; i < LAND_INFO_CENTERED_LINES; i++) {
+ if (StrEmpty(this->landinfo_data[i])) continue;
+
+ DoDrawStringCentered(140, y, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING);
+ y += 11;
+ }
+
+ y += 5;
+
+ if (!StrEmpty(this->landinfo_data[LAND_INFO_MULTICENTER_LINE])) DrawStringMultiCenter(140, y, BindCString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]), this->width - 4);
}
LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
Player *p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
- Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
+ Town *t = ClosestTownFromTile(tile, _settings.economy.dist_local_authority);
Money old_money = p->player_money;
p->player_money = INT64_MAX;
@@ -107,38 +114,81 @@
AcceptedCargo ac;
td.build_date = 0;
+
+ /* Most tiles have only one owner, but
+ * - drivethrough roadstops can be build on town owned roads (up to 2 owners) and
+ * - roads can have up to four owners (railroad, road, tram, 3rd-roadtype "highway").
+ */
+ td.owner_type[0] = STR_01A7_OWNER; // At least one owner is displayed, though it might be "N/A".
+ td.owner_type[1] = STR_NULL; // STR_NULL results in skipping the owner
+ td.owner_type[2] = STR_NULL;
+ td.owner_type[3] = STR_NULL;
+ td.owner[0] = OWNER_NONE;
+ td.owner[1] = OWNER_NONE;
+ td.owner[2] = OWNER_NONE;
+ td.owner[3] = OWNER_NONE;
+
GetAcceptedCargo(tile, ac);
GetTileDesc(tile, &td);
- SetDParam(0, td.dparam[0]);
- GetString(this->landinfo_data[0], td.str, lastof(this->landinfo_data[0]));
+ uint line_nr = 0;
- SetDParam(0, STR_01A6_N_A);
- if (td.owner != OWNER_NONE && td.owner != OWNER_WATER) GetNameOfOwner(td.owner, tile);
- GetString(this->landinfo_data[1], STR_01A7_OWNER, lastof(this->landinfo_data[1]));
+ /* Tiletype */
+ SetDParam(0, td.dparam[0]);
+ GetString(this->landinfo_data[line_nr], td.str, lastof(this->landinfo_data[line_nr]));
+ line_nr++;
+ /* Up to four owners */
+ for (uint i = 0; i < 4; i++) {
+ if (td.owner_type[i] == STR_NULL) continue;
+
+ SetDParam(0, STR_01A6_N_A);
+ if (td.owner[i] != OWNER_NONE && td.owner[i] != OWNER_WATER) GetNameOfOwner(td.owner[i], tile);
+ GetString(this->landinfo_data[line_nr], td.owner_type[i], lastof(this->landinfo_data[line_nr]));
+ line_nr++;
+ }
+
+ /* Cost to clear */
StringID str = STR_01A4_COST_TO_CLEAR_N_A;
if (CmdSucceeded(costclear)) {
SetDParam(0, costclear.GetCost());
str = STR_01A5_COST_TO_CLEAR;
}
- GetString(this->landinfo_data[2], str, lastof(this->landinfo_data[2]));
+ GetString(this->landinfo_data[line_nr], str, lastof(this->landinfo_data[line_nr]));
+ line_nr++;
+ /* Location */
snprintf(_userstring, lengthof(_userstring), "0x%.4X", tile);
SetDParam(0, TileX(tile));
SetDParam(1, TileY(tile));
SetDParam(2, TileHeight(tile));
SetDParam(3, STR_SPEC_USERSTRING);
- GetString(this->landinfo_data[3], STR_LANDINFO_COORDS, lastof(this->landinfo_data[3]));
+ GetString(this->landinfo_data[line_nr], STR_LANDINFO_COORDS, lastof(this->landinfo_data[line_nr]));
+ line_nr++;
+ /* Local authority */
SetDParam(0, STR_01A9_NONE);
if (t != NULL && t->IsValid()) {
SetDParam(0, STR_TOWN);
SetDParam(1, t->index);
}
- GetString(this->landinfo_data[4], STR_01A8_LOCAL_AUTHORITY, lastof(this->landinfo_data[4]));
+ GetString(this->landinfo_data[line_nr], STR_01A8_LOCAL_AUTHORITY, lastof(this->landinfo_data[line_nr]));
+ line_nr++;
- char *strp = GetString(this->landinfo_data[5], STR_01CE_CARGO_ACCEPTED, lastof(this->landinfo_data[5]));
+ /* Build date */
+ if (td.build_date != 0) {
+ SetDParam(0, td.build_date);
+ GetString(this->landinfo_data[line_nr], STR_BUILD_DATE, lastof(this->landinfo_data[line_nr]));
+ line_nr++;
+ }
+
+ /* Remaining lines stay empty */
+ for (; line_nr < LAND_INFO_CENTERED_LINES; line_nr++) {
+ this->landinfo_data[line_nr][0] = '\0';
+ }
+
+ /* Cargo acceptance is displayed in a extra multiline */
+ char *strp = GetString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE], STR_01CE_CARGO_ACCEPTED, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
bool found = false;
for (CargoID i = 0; i < NUM_CARGO; ++i) {
@@ -154,20 +204,13 @@
if (ac[i] < 8) {
SetDParam(0, ac[i]);
SetDParam(1, GetCargo(i)->name);
- strp = GetString(strp, STR_01D1_8, lastof(this->landinfo_data[5]));
+ strp = GetString(strp, STR_01D1_8, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
} else {
- strp = GetString(strp, GetCargo(i)->name, lastof(this->landinfo_data[5]));
+ strp = GetString(strp, GetCargo(i)->name, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
}
}
}
- if (!found) this->landinfo_data[5][0] = '\0';
-
- if (td.build_date != 0) {
- SetDParam(0, td.build_date);
- GetString(this->landinfo_data[6], STR_BUILD_DATE, lastof(this->landinfo_data[6]));
- } else {
- this->landinfo_data[6][0] = '\0';
- }
+ if (!found) this->landinfo_data[LAND_INFO_MULTICENTER_LINE][0] = '\0';
#if defined(_DEBUG)
# define LANDINFOD_LEVEL 0
@@ -353,7 +396,7 @@
Window(pt.x, pt.y, width, height, WC_ERRMSG, widget),
show_player_face(show_player_face)
{
- this->duration = _patches.errmsg_duration;
+ this->duration = _settings.gui.errmsg_duration;
CopyOutDParam(this->decode_params, 0, lengthof(this->decode_params));
this->message_1 = msg1;
this->message_2 = msg2;
@@ -422,7 +465,7 @@
{
DeleteWindowById(WC_ERRMSG, 0);
- if (!_patches.errmsg_duration) return;
+ if (!_settings.gui.errmsg_duration) return;
if (msg_2 == STR_NULL) msg_2 = STR_EMPTY;
@@ -577,7 +620,7 @@
DeleteWindowById(WC_TOOLTIPS, 0);
/* We only show measurement tooltips with patch setting on */
- if (str == STR_NULL || (paramcount != 0 && !_patches.measure_tooltip)) return;
+ if (str == STR_NULL || (paramcount != 0 && !_settings.gui.measure_tooltip)) return;
for (uint i = 0; i != paramcount; i++) SetDParam(i, params[i]);
char buffer[512];
@@ -1121,11 +1164,11 @@
* Window used for asking the user a YES/NO question.
*/
struct QueryWindow : public Window {
- void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
- uint64 params[10]; ///< local copy of _decode_parameters
- StringID message; ///< message shown for query window
+ QueryCallbackProc *proc; ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
+ uint64 params[10]; ///< local copy of _decode_parameters
+ StringID message; ///< message shown for query window
- QueryWindow(const WindowDesc *desc, StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool)) : Window(desc)
+ QueryWindow(const WindowDesc *desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window(desc)
{
if (parent == NULL) parent = FindWindowById(WC_MAIN_WINDOW, 0);
this->parent = parent;
@@ -1159,12 +1202,17 @@
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
- case QUERY_WIDGET_YES:
- if (this->proc != NULL) {
- this->proc(this->parent, true);
- this->proc = NULL;
+ case QUERY_WIDGET_YES: {
+ /* in the Generate New World window, clicking 'Yes' causes
+ * DeleteNonVitalWindows() to be called - we shouldn't be in a window then */
+ QueryCallbackProc *proc = this->proc;
+ Window *parent = this->parent;
+ delete this;
+ if (proc != NULL) {
+ proc(parent, true);
+ proc = NULL;
}
- /* Fallthrough */
+ } break;
case QUERY_WIDGET_NO:
delete this;
break;
@@ -1215,7 +1263,7 @@
* @param parent pointer to parent window, if this pointer is NULL the parent becomes
* the main window WC_MAIN_WINDOW
* @param callback callback function pointer to set in the window descriptor*/
-void ShowQuery(StringID caption, StringID message, Window *parent, void (*callback)(Window*, bool))
+void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
{
new QueryWindow(&_query_desc, caption, message, parent, callback);
}
--- a/src/network/network.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/network/network.cpp Mon May 26 13:52:59 2008 +0000
@@ -23,7 +23,7 @@
#include "core/tcp.h"
#include "core/core.h"
#include "network_gui.h"
-#include "../console.h" /* IConsoleCmdExec */
+#include "../console_func.h"
#include <stdarg.h> /* va_list */
#include "../md5.h"
#include "../fileio.h"
@@ -141,7 +141,7 @@
// This puts a text-message to the console, or in the future, the chat-box,
// (to keep it all a bit more general)
// If 'self_send' is true, this is the client who is sending the message
-void CDECL NetworkTextMessage(NetworkAction action, uint16 color, bool self_send, const char *name, const char *str, ...)
+void CDECL NetworkTextMessage(NetworkAction action, ConsoleColour color, bool self_send, const char *name, const char *str, ...)
{
char buf[1024];
va_list va;
@@ -155,16 +155,16 @@
switch (action) {
case NETWORK_ACTION_SERVER_MESSAGE:
- color = 1;
+ color = CC_DEFAULT;
snprintf(message, sizeof(message), "*** %s", buf);
break;
case NETWORK_ACTION_JOIN:
- color = 1;
+ color = CC_DEFAULT;
GetString(temp, STR_NETWORK_CLIENT_JOINED, lastof(temp));
snprintf(message, sizeof(message), "*** %s %s", name, temp);
break;
case NETWORK_ACTION_LEAVE:
- color = 1;
+ color = CC_DEFAULT;
GetString(temp, STR_NETWORK_ERR_LEFT, lastof(temp));
snprintf(message, sizeof(message), "*** %s %s (%s)", name, temp, buf);
break;
@@ -651,7 +651,7 @@
GetNetworkErrorMsg(str, errorno, lastof(str));
- NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str);
+ NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "%s", str);
// Inform other clients of this... strange leaving ;)
FOR_ALL_CLIENTS(new_cs) {
@@ -1009,10 +1009,10 @@
_network_game_info.spectators_on = 0;
_network_game_info.game_date = _date;
- _network_game_info.start_date = ConvertYMDToDate(_patches.starting_year, 0, 1);
+ _network_game_info.start_date = ConvertYMDToDate(_settings.game_creation.starting_year, 0, 1);
_network_game_info.map_width = MapSizeX();
_network_game_info.map_height = MapSizeY();
- _network_game_info.map_set = _opt.landscape;
+ _network_game_info.map_set = _settings.game_creation.landscape;
_network_game_info.use_password = (_network_server_password[0] != '\0');
--- a/src/network/network_client.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/network/network_client.cpp Mon May 26 13:52:59 2008 +0000
@@ -14,7 +14,7 @@
#include "network_gui.h"
#include "../saveload.h"
#include "../command_func.h"
-#include "../console.h"
+#include "../console_func.h"
#include "../variables.h"
#include "../core/alloc_func.hpp"
#include "../fileio.h"
@@ -83,7 +83,7 @@
{
if (StrEmpty(_network_player_info[_local_player].password)) return;
- _password_game_seed = _patches.generation_seed;
+ _password_game_seed = _settings.game_creation.generation_seed;
ttd_strlcpy(_password_server_unique_id, _network_unique_id, sizeof(_password_server_unique_id));
const char *new_pw = GenerateCompanyPasswordHash(_network_player_info[_local_player].password);
@@ -414,7 +414,7 @@
if (ci != NULL) {
if (playas == ci->client_playas && strcmp(name, ci->client_name) != 0) {
// Client name changed, display the change
- NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, false, ci->client_name, "%s", name);
+ NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", name);
} else if (playas != ci->client_playas) {
// The player changed from client-player..
// Do not display that for now
@@ -622,8 +622,6 @@
/* If the savegame has successfully loaded, ALL windows have been removed,
* only toolbar/statusbar and gamefield are visible */
- _opt_ptr = &_opt; // during a network game you are always in-game
-
// Say we received the map and loaded it correctly!
SEND_COMMAND(PACKET_CLIENT_MAP_OK)();
@@ -761,7 +759,7 @@
}
if (ci != NULL)
- NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas), self_send, name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), self_send, name, "%s", msg);
return NETWORK_RECV_STATUS_OKAY;
}
@@ -776,7 +774,7 @@
ci = NetworkFindClientInfoFromIndex(index);
if (ci != NULL) {
- NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, ci->client_name, "%s", str);
+ NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, "%s", str);
// The client is gone, give the NetworkClientInfo free
ci->client_index = NETWORK_EMPTY_INDEX;
@@ -798,7 +796,7 @@
ci = NetworkFindClientInfoFromIndex(index);
if (ci != NULL) {
- NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, ci->client_name, "%s", str);
+ NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, "%s", str);
// The client is gone, give the NetworkClientInfo free
ci->client_index = NETWORK_EMPTY_INDEX;
@@ -821,7 +819,7 @@
ci = NetworkFindClientInfoFromIndex(index);
if (ci != NULL)
- NetworkTextMessage(NETWORK_ACTION_JOIN, 1, false, ci->client_name, "");
+ NetworkTextMessage(NETWORK_ACTION_JOIN, CC_DEFAULT, false, ci->client_name, "");
InvalidateWindow(WC_CLIENT_LIST, 0);
@@ -850,9 +848,8 @@
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_RCON)
{
char rcon_out[NETWORK_RCONCOMMAND_LENGTH];
- uint16 color_code;
- color_code = p->Recv_uint16();
+ ConsoleColour color_code = (ConsoleColour)p->Recv_uint16();
p->Recv_string(rcon_out, sizeof(rcon_out));
IConsolePrint(color_code, rcon_out);
--- a/src/network/network_data.h Mon May 26 11:36:42 2008 +0000
+++ b/src/network/network_data.h Mon May 26 13:52:59 2008 +0000
@@ -6,6 +6,7 @@
#define NETWORK_DATA_H
#include "../openttd.h"
+#include "../console_type.h"
#include "network.h"
#include "network_internal.h"
@@ -105,7 +106,7 @@
// from network.c
void NetworkCloseClient(NetworkTCPSocketHandler *cs);
-void CDECL NetworkTextMessage(NetworkAction action, uint16 color, bool self_send, const char *name, const char *str, ...);
+void CDECL NetworkTextMessage(NetworkAction action, ConsoleColour color, bool self_send, const char *name, const char *str, ...);
void NetworkGetClientName(char *clientname, size_t size, const NetworkTCPSocketHandler *cs);
uint NetworkCalculateLag(const NetworkTCPSocketHandler *cs);
byte NetworkGetCurrentLanguageIndex();
--- a/src/network/network_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/network/network_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -1342,7 +1342,7 @@
if (_network_own_client_index != ci->client_index) {
/* We are no spectator and the player we want to give money to is no spectator and money gifts are allowed */
- if (IsValidPlayer(_network_playas) && IsValidPlayer(ci->client_playas) && _patches.give_money) {
+ if (IsValidPlayer(_network_playas) && IsValidPlayer(ci->client_playas) && _settings.economy.give_money) {
GetString(this->action[i], STR_NETWORK_CLIENTLIST_GIVE_MONEY, lastof(this->action[i]));
this->proc[i++] = &ClientList_GiveMoney;
}
--- a/src/network/network_server.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/network/network_server.cpp Mon May 26 13:52:59 2008 +0000
@@ -15,7 +15,7 @@
#include "../date_func.h"
#include "network_server.h"
#include "network_udp.h"
-#include "../console.h"
+#include "../console_func.h"
#include "../command_func.h"
#include "../saveload.h"
#include "../station_base.h"
@@ -160,7 +160,7 @@
DEBUG(net, 1, "'%s' made an error and has been disconnected. Reason: '%s'", client_name, str);
- NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str);
+ NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "%s", str);
FOR_ALL_CLIENTS(new_cs) {
if (new_cs->status > STATUS_AUTH && new_cs != cs) {
@@ -229,7 +229,7 @@
Packet *p = NetworkSend_Init(PACKET_SERVER_NEED_PASSWORD);
p->Send_uint8(type);
- p->Send_uint32(_patches.generation_seed);
+ p->Send_uint32(_settings.game_creation.generation_seed);
p->Send_string(_network_unique_id);
cs->Send_Packet(p);
}
@@ -254,7 +254,7 @@
p = NetworkSend_Init(PACKET_SERVER_WELCOME);
p->Send_uint16(cs->index);
- p->Send_uint32(_patches.generation_seed);
+ p->Send_uint32(_settings.game_creation.generation_seed);
p->Send_string(_network_unique_id);
cs->Send_Packet(p);
@@ -779,7 +779,7 @@
NetworkGetClientName(client_name, sizeof(client_name), cs);
- NetworkTextMessage(NETWORK_ACTION_JOIN, 1, false, client_name, "");
+ NetworkTextMessage(NETWORK_ACTION_JOIN, CC_DEFAULT, false, client_name, "");
// Mark the client as pre-active, and wait for an ACK
// so we know he is done loading and in sync with us
@@ -822,17 +822,17 @@
byte flags = GetCommandFlags(cp->cmd);
if (flags & CMD_SERVER && ci->client_index != NETWORK_SERVER_INDEX) {
- IConsolePrintF(_icolour_err, "WARNING: server only command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: server only command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
return false;
}
if (flags & CMD_OFFLINE) {
- IConsolePrintF(_icolour_err, "WARNING: offline only command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: offline only command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
return false;
}
if (cp->cmd != CMD_PLAYER_CTRL && !IsValidPlayer(cp->player) && ci->client_index != NETWORK_SERVER_INDEX) {
- IConsolePrintF(_icolour_err, "WARNING: spectator issueing command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: spectator issueing command from client %d (IP: %s), kicking...", ci->client_index, GetPlayerIP(ci));
return false;
}
@@ -875,7 +875,7 @@
/* Check if cp->cmd is valid */
if (!IsValidCommand(cp->cmd)) {
- IConsolePrintF(_icolour_err, "WARNING: invalid command from client %d (IP: %s).", ci->client_index, GetPlayerIP(ci));
+ IConsolePrintF(CC_ERROR, "WARNING: invalid command from client %d (IP: %s).", ci->client_index, GetPlayerIP(ci));
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
free(cp);
return;
@@ -892,7 +892,7 @@
* something pretty naughty (or a bug), and will be kicked
*/
if (!(cp->cmd == CMD_PLAYER_CTRL && cp->p1 == 0) && ci->client_playas != cp->player) {
- IConsolePrintF(_icolour_err, "WARNING: player %d (IP: %s) tried to execute a command as player %d, kicking...",
+ IConsolePrintF(CC_ERROR, "WARNING: player %d (IP: %s) tried to execute a command as player %d, kicking...",
ci->client_playas + 1, GetPlayerIP(ci), cp->player + 1);
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_PLAYER_MISMATCH);
free(cp);
@@ -969,7 +969,7 @@
DEBUG(net, 2, "'%s' reported an error and is closing its connection (%s)", client_name, str);
- NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str);
+ NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "%s", str);
FOR_ALL_CLIENTS(new_cs) {
if (new_cs->status > STATUS_AUTH) {
@@ -998,7 +998,7 @@
NetworkGetClientName(client_name, sizeof(client_name), cs);
- NetworkTextMessage(NETWORK_ACTION_LEAVE, 1, false, client_name, "%s", str);
+ NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "%s", str);
FOR_ALL_CLIENTS(new_cs) {
if (new_cs->status > STATUS_AUTH) {
@@ -1052,7 +1052,7 @@
ci = NetworkFindClientInfoFromIndex(from_index);
/* Display the text locally, and that is it */
if (ci != NULL)
- NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
} else {
/* Else find the client to send the message to */
FOR_ALL_CLIENTS(cs) {
@@ -1069,7 +1069,7 @@
ci = NetworkFindClientInfoFromIndex(from_index);
ci_to = NetworkFindClientInfoFromIndex(dest);
if (ci != NULL && ci_to != NULL)
- NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas), true, ci_to->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), true, ci_to->client_name, "%s", msg);
} else {
FOR_ALL_CLIENTS(cs) {
if (cs->index == from_index) {
@@ -1097,7 +1097,7 @@
ci = NetworkFindClientInfoFromIndex(from_index);
ci_own = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
if (ci != NULL && ci_own != NULL && ci_own->client_playas == dest) {
- NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
if (from_index == NETWORK_SERVER_INDEX) show_local = false;
ci_to = ci_own;
}
@@ -1112,7 +1112,7 @@
StringID str = IsValidPlayer(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
SetDParam(0, ci_to->client_playas);
GetString(name, str, lastof(name));
- NetworkTextMessage(action, GetDrawStringPlayerColor(ci_own->client_playas), true, name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci_own->client_playas), true, name, "%s", msg);
} else {
FOR_ALL_CLIENTS(cs) {
if (cs->index == from_index) {
@@ -1132,7 +1132,7 @@
}
ci = NetworkFindClientInfoFromIndex(from_index);
if (ci != NULL)
- NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
+ NetworkTextMessage(action, (ConsoleColour)GetDrawStringPlayerColor(ci->client_playas), false, ci->client_name, "%s", msg);
break;
}
}
@@ -1175,7 +1175,7 @@
if (ci != NULL) {
// Display change
if (NetworkFindName(client_name)) {
- NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, false, ci->client_name, "%s", client_name);
+ NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", client_name);
ttd_strlcpy(ci->client_name, client_name, sizeof(ci->client_name));
NetworkUpdateClientInfo(ci->client_index);
}
@@ -1412,13 +1412,13 @@
if (_network_player_info[p->index].months_empty > _network_autoclean_unprotected && _network_player_info[p->index].password[0] == '\0') {
/* Shut the company down */
DoCommandP(0, 2, p->index, NULL, CMD_PLAYER_CTRL);
- IConsolePrintF(_icolour_def, "Auto-cleaned company #%d", p->index + 1);
+ IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d", p->index + 1);
}
/* Is the compnay empty for autoclean_protected-months, and there is a protection? */
if (_network_player_info[p->index].months_empty > _network_autoclean_protected && _network_player_info[p->index].password[0] != '\0') {
/* Unprotect the company */
_network_player_info[p->index].password[0] = '\0';
- IConsolePrintF(_icolour_def, "Auto-removed protection from company #%d", p->index+1);
+ IConsolePrintF(CC_DEFAULT, "Auto-removed protection from company #%d", p->index+1);
_network_player_info[p->index].months_empty = 0;
}
} else {
@@ -1527,14 +1527,14 @@
if (lag > 3) {
// Client did still not report in after 4 game-day, drop him
// (that is, the 3 of above, + 1 before any lag is counted)
- IConsolePrintF(_icolour_err,"Client #%d is dropped because the client did not respond for more than 4 game-days", cs->index);
+ IConsolePrintF(CC_ERROR,"Client #%d is dropped because the client did not respond for more than 4 game-days", cs->index);
NetworkCloseClient(cs);
continue;
}
// Report once per time we detect the lag
if (cs->lag_test == 0) {
- IConsolePrintF(_icolour_warn,"[%d] Client #%d is slow, try increasing *net_frame_freq to a higher value!", _frame_counter, cs->index);
+ IConsolePrintF(CC_WARNING,"[%d] Client #%d is slow, try increasing *net_frame_freq to a higher value!", _frame_counter, cs->index);
cs->lag_test = 1;
}
} else {
@@ -1543,13 +1543,13 @@
} else if (cs->status == STATUS_PRE_ACTIVE) {
int lag = NetworkCalculateLag(cs);
if (lag > _network_max_join_time) {
- IConsolePrintF(_icolour_err,"Client #%d is dropped because it took longer than %d ticks for him to join", cs->index, _network_max_join_time);
+ IConsolePrintF(CC_ERROR,"Client #%d is dropped because it took longer than %d ticks for him to join", cs->index, _network_max_join_time);
NetworkCloseClient(cs);
}
} else if (cs->status == STATUS_INACTIVE) {
int lag = NetworkCalculateLag(cs);
if (lag > 4 * DAY_TICKS) {
- IConsolePrintF(_icolour_err,"Client #%d is dropped because it took longer than %d ticks to start the joining process", cs->index, 4 * DAY_TICKS);
+ IConsolePrintF(CC_ERROR,"Client #%d is dropped because it took longer than %d ticks to start the joining process", cs->index, 4 * DAY_TICKS);
NetworkCloseClient(cs);
}
}
--- a/src/network/network_udp.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/network/network_udp.cpp Mon May 26 13:52:59 2008 +0000
@@ -77,7 +77,7 @@
_network_game_info.game_date = _date;
_network_game_info.map_width = MapSizeX();
_network_game_info.map_height = MapSizeY();
- _network_game_info.map_set = _opt.landscape;
+ _network_game_info.map_set = _settings.game_creation.landscape;
_network_game_info.companies_on = ActivePlayerCount();
_network_game_info.spectators_on = NetworkSpectatorCount();
_network_game_info.grfconfig = _grfconfig;
--- a/src/newgrf.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/newgrf.cpp Mon May 26 13:52:59 2008 +0000
@@ -326,7 +326,7 @@
/* Hack for add-on GRFs that need to modify another GRF's engines. This lets
* them use the same engine slots. */
const GRFFile *grf_match = NULL;
- if (_patches.dynamic_engines) {
+ if (_settings.vehicle.dynamic_engines) {
uint32 override = _grf_id_overrides[file->grfid];
if (override != 0) {
grf_match = GetFileByGRFID(override);
@@ -341,7 +341,7 @@
/* Check if this vehicle is already defined... */
Engine *e = NULL;
FOR_ALL_ENGINES(e) {
- if (_patches.dynamic_engines && e->grffile != NULL && e->grffile != file && e->grffile != grf_match) continue;
+ if (_settings.vehicle.dynamic_engines && e->grffile != NULL && e->grffile != file && e->grffile != grf_match) continue;
if (e->type != type) continue;
if (e->internal_id != internal_id) continue;
@@ -377,14 +377,14 @@
extern uint32 GetNewGRFOverride(uint32 grfid);
const GRFFile *grf_match = NULL;
- if (_patches.dynamic_engines) {
+ if (_settings.vehicle.dynamic_engines) {
uint32 override = _grf_id_overrides[file->grfid];
if (override != 0) grf_match = GetFileByGRFID(override);
}
const Engine *e = NULL;
FOR_ALL_ENGINES(e) {
- if (_patches.dynamic_engines && e->grffile != file && (grf_match == NULL || e->grffile != grf_match)) continue;
+ if (_settings.vehicle.dynamic_engines && e->grffile != file && (grf_match == NULL || e->grffile != grf_match)) continue;
if (e->type != type) continue;
if (e->internal_id != internal_id) continue;
@@ -1437,8 +1437,8 @@
/* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance.
* Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */
- CargoID cid = (goods >= 0) ? ((_opt.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) :
- ((_opt.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD);
+ CargoID cid = (goods >= 0) ? ((_settings.game_creation.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) :
+ ((_settings.game_creation.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD);
/* Make sure the cargo type is valid in this climate. */
if (!GetCargo(cid)->IsValid()) goods = 0;
@@ -2167,11 +2167,11 @@
break;
case 0x17: // Probability in random game
- indsp->appear_creation[_opt.landscape] = grf_load_byte(&buf);
+ indsp->appear_creation[_settings.game_creation.landscape] = grf_load_byte(&buf);
break;
case 0x18: // Probability during gameplay
- indsp->appear_ingame[_opt.landscape] = grf_load_byte(&buf);
+ indsp->appear_ingame[_settings.game_creation.landscape] = grf_load_byte(&buf);
break;
case 0x19: // Map color
@@ -3557,11 +3557,11 @@
return true;
case 0x03: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland
- *value = _opt.landscape;
+ *value = _settings.game_creation.landscape;
return true;
case 0x06: // road traffic side, bit 4 clear=left, set=right
- *value = _opt.road_side << 4;
+ *value = _settings.vehicle.road_side << 4;
return true;
case 0x09: // date fraction
@@ -3592,7 +3592,7 @@
case 0x0F: // Rail track type cost factors
*value = 0;
SB(*value, 0, 8, _railtype_cost_multiplier[0]); // normal rail
- if (_patches.disable_elrails) {
+ if (_settings.vehicle.disable_elrails) {
/* skip elrail multiplier - disabled */
SB(*value, 8, 8, _railtype_cost_multiplier[2]); // monorail
} else {
@@ -3635,7 +3635,7 @@
/* case 0x1F: // locale dependent settings not implemented */
case 0x20: // snow line height
- *value = _opt.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF;
+ *value = _settings.game_creation.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF;
return true;
case 0x21: // OpenTTD version
@@ -3643,7 +3643,7 @@
return true;
case 0x22: // difficulty level
- *value = _opt.diff_level;
+ *value = _settings.difficulty.diff_level;
return true;
default: return false;
@@ -4188,10 +4188,10 @@
{
switch (param) {
/* start year - 1920 */
- case 0x0B: return max(_patches.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR;
+ case 0x0B: return max(_settings.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR;
/* freight trains weight factor */
- case 0x0E: return _patches.freight_trains;
+ case 0x0E: return _settings.vehicle.freight_trains;
/* empty wagon speed increase */
case 0x0F: return 0;
@@ -4200,7 +4200,7 @@
* the following is good for 1x, 2x and 4x (most common?) and...
* well not really for 3x. */
case 0x10:
- switch (_patches.plane_speed) {
+ switch (_settings.vehicle.plane_speed) {
default:
case 4: return 1;
case 3: return 2;
@@ -4382,7 +4382,7 @@
case 0x01: // Road Vehicles
case 0x02: // Ships
case 0x03: // Aircraft
- if (!_patches.dynamic_engines) {
+ if (!_settings.vehicle.dynamic_engines) {
src1 = PerformGRM(&_grm_engines[_engine_offsets[feature]], _engine_counts[feature], count, op, target, "vehicles");
if (_skip_sprites == -1) return;
} else {
@@ -4544,7 +4544,7 @@
case 0x8F: // Rail track type cost factors
_railtype_cost_multiplier[0] = GB(res, 0, 8);
- if (_patches.disable_elrails) {
+ if (_settings.vehicle.disable_elrails) {
_railtype_cost_multiplier[1] = GB(res, 0, 8);
_railtype_cost_multiplier[2] = GB(res, 8, 8);
} else {
@@ -5079,84 +5079,84 @@
static void InitializeGRFSpecial()
{
- _ttdpatch_flags[0] = ((_patches.always_small_airport ? 1 : 0) << 0x0C) // keepsmallairport
- | (1 << 0x0D) // newairports
- | (1 << 0x0E) // largestations
- | ((_patches.longbridges ? 1 : 0) << 0x0F) // longbridges
- | (0 << 0x10) // loadtime
- | (1 << 0x12) // presignals
- | (1 << 0x13) // extpresignals
- | ((_patches.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist
- | (1 << 0x1B) // multihead
- | (1 << 0x1D) // lowmemory
- | (1 << 0x1E); // generalfixes
-
- _ttdpatch_flags[1] = (0 << 0x07) // moreairports - based on units of noise
- | ((_patches.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains
- | (1 << 0x09) // trainrefit
- | (0 << 0x0B) // subsidiaries
- | ((_patches.gradual_loading ? 1 : 0) << 0x0C) // gradualloading
- | (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD
- | (1 << 0x13) // unifiedmaglevmode - set bit 1 mode
- | (1 << 0x14) // bridgespeedlimits
- | (1 << 0x16) // eternalgame
- | (1 << 0x17) // newtrains
- | (1 << 0x18) // newrvs
- | (1 << 0x19) // newships
- | (1 << 0x1A) // newplanes
- | ((_patches.signal_side ? 1 : 0) << 0x1B) // signalsontrafficside
- | ((_patches.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway
-
- _ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote
- | (1 << 0x03) // semaphores
- | (0 << 0x0B) // enhancedgui
- | (0 << 0x0C) // newagerating
- | ((_patches.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes
- | (1 << 0x0E) // fullloadany
- | (1 << 0x0F) // planespeed
- | (0 << 0x10) // moreindustriesperclimate - obsolete
- | (0 << 0x11) // moretoylandfeatures
- | (1 << 0x12) // newstations
- | (1 << 0x13) // tracktypecostdiff
- | (1 << 0x14) // manualconvert
- | ((_patches.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts
- | (1 << 0x16) // canals
- | (1 << 0x17) // newstartyear
- | ((_patches.freight_trains > 1 ? 1 : 0) << 0x18) // freighttrains
- | (1 << 0x19) // newhouses
- | (1 << 0x1A) // newbridges
- | (1 << 0x1B) // newtownnames
- | (1 << 0x1C) // moreanimation
- | ((_patches.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits
- | (1 << 0x1E) // newshistory
- | (0 << 0x1F); // custombridgeheads
-
- _ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution
- | (1 << 0x01) // windowsnap
- | (0 << 0x02) // townbuildnoroad
- | (0 << 0x03) // pathbasedsignalling. To enable if ever pbs is back
- | (0 << 0x04) // aichoosechance
- | (1 << 0x05) // resolutionwidth
- | (1 << 0x06) // resolutionheight
- | (1 << 0x07) // newindustries
- | ((_patches.improved_load ? 1 : 0) << 0x08) // fifoloading
- | (0 << 0x09) // townroadbranchprob
- | (0 << 0x0A) // tempsnowline
- | (1 << 0x0B) // newcargo
- | (1 << 0x0C) // enhancemultiplayer
- | (1 << 0x0D) // onewayroads
- | ((_patches.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations
- | (1 << 0x0F) // statistics
- | (1 << 0x10) // newsounds
- | (1 << 0x11) // autoreplace
- | (1 << 0x12) // autoslope
- | (0 << 0x13) // followvehicle
- | (1 << 0x14) // trams
- | (0 << 0x15) // enhancetunnels
- | (1 << 0x16) // shortrvs
- | (1 << 0x17) // articulatedrvs
- | ((_patches.dynamic_engines ? 1 : 0) << 0x18) // dynamic engines
- | (1 << 0x1E); // variablerunningcosts
+ _ttdpatch_flags[0] = ((_settings.station.always_small_airport ? 1 : 0) << 0x0C) // keepsmallairport
+ | (1 << 0x0D) // newairports
+ | (1 << 0x0E) // largestations
+ | ((_settings.construction.longbridges ? 1 : 0) << 0x0F) // longbridges
+ | (0 << 0x10) // loadtime
+ | (1 << 0x12) // presignals
+ | (1 << 0x13) // extpresignals
+ | ((_settings.vehicle.never_expire_vehicles ? 1 : 0) << 0x16) // enginespersist
+ | (1 << 0x1B) // multihead
+ | (1 << 0x1D) // lowmemory
+ | (1 << 0x1E); // generalfixes
+
+ _ttdpatch_flags[1] = ((_settings.economy.station_noise_level ? 1 : 0) << 0x07) // moreairports - based on units of noise
+ | ((_settings.vehicle.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains
+ | (1 << 0x09) // trainrefit
+ | (0 << 0x0B) // subsidiaries
+ | ((_settings.order.gradual_loading ? 1 : 0) << 0x0C) // gradualloading
+ | (1 << 0x12) // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD
+ | (1 << 0x13) // unifiedmaglevmode - set bit 1 mode
+ | (1 << 0x14) // bridgespeedlimits
+ | (1 << 0x16) // eternalgame
+ | (1 << 0x17) // newtrains
+ | (1 << 0x18) // newrvs
+ | (1 << 0x19) // newships
+ | (1 << 0x1A) // newplanes
+ | ((_settings.construction.signal_side ? 1 : 0) << 0x1B) // signalsontrafficside
+ | ((_settings.vehicle.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway
+
+ _ttdpatch_flags[2] = (1 << 0x01) // loadallgraphics - obsolote
+ | (1 << 0x03) // semaphores
+ | (0 << 0x0B) // enhancedgui
+ | (0 << 0x0C) // newagerating
+ | ((_settings.construction.build_on_slopes ? 1 : 0) << 0x0D) // buildonslopes
+ | (1 << 0x0E) // fullloadany
+ | (1 << 0x0F) // planespeed
+ | (0 << 0x10) // moreindustriesperclimate - obsolete
+ | (0 << 0x11) // moretoylandfeatures
+ | (1 << 0x12) // newstations
+ | (1 << 0x13) // tracktypecostdiff
+ | (1 << 0x14) // manualconvert
+ | ((_settings.construction.build_on_slopes ? 1 : 0) << 0x15) // buildoncoasts
+ | (1 << 0x16) // canals
+ | (1 << 0x17) // newstartyear
+ | ((_settings.vehicle.freight_trains > 1 ? 1 : 0) << 0x18) // freighttrains
+ | (1 << 0x19) // newhouses
+ | (1 << 0x1A) // newbridges
+ | (1 << 0x1B) // newtownnames
+ | (1 << 0x1C) // moreanimation
+ | ((_settings.vehicle.wagon_speed_limits ? 1 : 0) << 0x1D) // wagonspeedlimits
+ | (1 << 0x1E) // newshistory
+ | (0 << 0x1F); // custombridgeheads
+
+ _ttdpatch_flags[3] = (0 << 0x00) // newcargodistribution
+ | (1 << 0x01) // windowsnap
+ | (0 << 0x02) // townbuildnoroad
+ | (0 << 0x03) // pathbasedsignalling. To enable if ever pbs is back
+ | (0 << 0x04) // aichoosechance
+ | (1 << 0x05) // resolutionwidth
+ | (1 << 0x06) // resolutionheight
+ | (1 << 0x07) // newindustries
+ | ((_settings.order.improved_load ? 1 : 0) << 0x08) // fifoloading
+ | (0 << 0x09) // townroadbranchprob
+ | (0 << 0x0A) // tempsnowline
+ | (1 << 0x0B) // newcargo
+ | (1 << 0x0C) // enhancemultiplayer
+ | (1 << 0x0D) // onewayroads
+ | ((_settings.station.nonuniform_stations ? 1 : 0) << 0x0E) // irregularstations
+ | (1 << 0x0F) // statistics
+ | (1 << 0x10) // newsounds
+ | (1 << 0x11) // autoreplace
+ | (1 << 0x12) // autoslope
+ | (0 << 0x13) // followvehicle
+ | (1 << 0x14) // trams
+ | (0 << 0x15) // enhancetunnels
+ | (1 << 0x16) // shortrvs
+ | (1 << 0x17) // articulatedrvs
+ | ((_settings.vehicle.dynamic_engines ? 1 : 0) << 0x18) // dynamic engines
+ | (1 << 0x1E); // variablerunningcosts
}
static void ResetCustomStations()
@@ -5352,7 +5352,7 @@
ResetNewGRFErrors();
/* Set up the default cargo types */
- SetupCargoForClimate(_opt.landscape);
+ SetupCargoForClimate(_settings.game_creation.landscape);
/* Reset misc GRF features and train list display variables */
_misc_grf_features = 0;
--- a/src/newgrf_commons.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/newgrf_commons.cpp Mon May 26 13:52:59 2008 +0000
@@ -278,7 +278,7 @@
* Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline */
uint32 GetTerrainType(TileIndex tile)
{
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_TROPIC: return GetTropicZone(tile);
case LT_ARCTIC: return GetTileZ(tile) > GetSnowLine() ? 4 : 0;
default: return 0;
--- a/src/newgrf_engine.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/newgrf_engine.cpp Mon May 26 13:52:59 2008 +0000
@@ -1123,7 +1123,7 @@
/* Populate map with current list positions */
Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) {
- if (!_patches.dynamic_engines || e->grffile == source_e->grffile) {
+ if (!_settings.vehicle.dynamic_engines || e->grffile == source_e->grffile) {
if (e->internal_id == target) target_e = e;
lptr_map[e->list_position] = e;
}
--- a/src/newgrf_town.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/newgrf_town.cpp Mon May 26 13:52:59 2008 +0000
@@ -21,7 +21,7 @@
switch (variable) {
/* Larger towns */
case 0x40:
- if (_patches.larger_towns == 0) return 2;
+ if (_settings.economy.larger_towns == 0) return 2;
if (t->larger_town) return 1;
return 0;
--- a/src/news_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/news_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -398,7 +398,7 @@
ni->flags = _news_subtype_data[subtype].flags;
/* show this news message in color? */
- if (_cur_year >= _patches.colored_news_year) ni->flags |= NF_INCOLOR;
+ if (_cur_year >= _settings.gui.colored_news_year) ni->flags |= NF_INCOLOR;
ni->data_a = data_a;
ni->data_b = data_b;
@@ -795,6 +795,8 @@
}
/* If all values are the same value, the ALL-button will take over this value */
this->state = all_val;
+
+ this->FindWindowPlacementAndResize(desc);
}
/**
--- a/src/npf.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/npf.cpp Mon May 26 13:52:59 2008 +0000
@@ -213,7 +213,7 @@
if (z2 - z1 > 1) {
/* Slope up */
- return _patches.npf_rail_slope_penalty;
+ return _settings.pf.npf.npf_rail_slope_penalty;
}
return 0;
/* Should we give a bonus for slope down? Probably not, we
@@ -260,10 +260,10 @@
cost = _trackdir_length[trackdir]; // Should be different for diagonal tracks
if (IsBuoyTile(current->tile) && IsDiagonalTrackdir(trackdir))
- cost += _patches.npf_buoy_penalty; // A small penalty for going over buoys
+ cost += _settings.pf.npf.npf_buoy_penalty; // A small penalty for going over buoys
if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction))
- cost += _patches.npf_water_curve_penalty;
+ cost += _settings.pf.npf.npf_water_curve_penalty;
/* @todo More penalties? */
@@ -285,13 +285,13 @@
case MP_ROAD:
cost = NPF_TILE_LENGTH;
/* Increase the cost for level crossings */
- if (IsLevelCrossing(tile)) cost += _patches.npf_crossing_penalty;
+ if (IsLevelCrossing(tile)) cost += _settings.pf.npf.npf_crossing_penalty;
break;
case MP_STATION:
cost = NPF_TILE_LENGTH;
/* Increase the cost for drive-through road stops */
- if (IsDriveThroughStopTile(tile)) cost += _patches.npf_road_drive_through_penalty;
+ if (IsDriveThroughStopTile(tile)) cost += _settings.pf.npf.npf_road_drive_through_penalty;
break;
default:
@@ -306,7 +306,7 @@
/* Check for turns. Road vehicles only really drive diagonal, turns are
* represented by non-diagonal tracks */
if (!IsDiagonalTrackdir((Trackdir)current->direction))
- cost += _patches.npf_road_curve_penalty;
+ cost += _settings.pf.npf.npf_road_curve_penalty;
NPFMarkTile(tile);
DEBUG(npf, 4, "Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost);
@@ -344,7 +344,7 @@
* give any station tile a penalty, because every possible route will get
* this penalty exactly once, on its end tile (if it's a station) and it
* will therefore not make a difference. */
- cost = NPF_TILE_LENGTH + _patches.npf_rail_station_penalty;
+ cost = NPF_TILE_LENGTH + _settings.pf.npf.npf_rail_station_penalty;
break;
default:
@@ -366,9 +366,9 @@
SignalType sigtype = GetSignalType(tile, TrackdirToTrack(trackdir));
if (sigtype == SIGTYPE_EXIT || sigtype == SIGTYPE_COMBO) {
/* Penalise exit and combo signals differently (heavier) */
- cost += _patches.npf_rail_firstred_exit_penalty;
+ cost += _settings.pf.npf.npf_rail_firstred_exit_penalty;
} else {
- cost += _patches.npf_rail_firstred_penalty;
+ cost += _settings.pf.npf.npf_rail_firstred_penalty;
}
}
/* Record the state of this signal */
@@ -386,14 +386,14 @@
* of course... */
new_node.path.node = *current;
if (as->EndNodeCheck(as, &new_node) == AYSTAR_FOUND_END_NODE && NPFGetFlag(current, NPF_FLAG_LAST_SIGNAL_RED))
- cost += _patches.npf_rail_lastred_penalty;
+ cost += _settings.pf.npf.npf_rail_lastred_penalty;
/* Check for slope */
cost += NPFSlopeCost(current);
/* Check for turns */
if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction))
- cost += _patches.npf_rail_curve_penalty;
+ cost += _settings.pf.npf.npf_rail_curve_penalty;
/*TODO, with realistic acceleration, also the amount of straight track between
* curves should be taken into account, as this affects the speed limit. */
@@ -402,7 +402,7 @@
/* Penalise any depot tile that is not the last tile in the path. This
* _should_ penalise every occurence of reversing in a depot (and only
* that) */
- cost += _patches.npf_rail_depot_reverse_penalty;
+ cost += _settings.pf.npf.npf_rail_depot_reverse_penalty;
}
/* Check for occupied track */
@@ -634,7 +634,7 @@
trackdirbits &= TrackdirReachesTrackdirs(src_trackdir);
/* Filter out trackdirs that would make 90 deg turns for trains */
- if (_patches.forbid_90_deg && (type == TRANSPORT_RAIL || type == TRANSPORT_WATER)) trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir);
+ if (_settings.pf.forbid_90_deg && (type == TRANSPORT_RAIL || type == TRANSPORT_WATER)) trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir);
DEBUG(npf, 6, "After filtering: (%d, %d), possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), trackdirbits);
@@ -970,7 +970,7 @@
//_npf_aystar.max_search_nodes = 0;
/* We will limit the number of nodes for now, until we have a better
* solution to really fix performance */
- _npf_aystar.max_search_nodes = _patches.npf_max_search_nodes;
+ _npf_aystar.max_search_nodes = _settings.pf.npf.npf_max_search_nodes;
}
void NPFFillWithOrderData(NPFFindStationOrTileData* fstd, Vehicle* v)
--- a/src/oldloader.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/oldloader.cpp Mon May 26 13:52:59 2008 +0000
@@ -318,8 +318,8 @@
/* Convert town-names if needed */
FOR_ALL_TOWNS(town) {
if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
- town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _opt.town_name;
- town->townnameparts = GetOldTownName(town->townnameparts, _opt.town_name);
+ town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _settings.game_creation.town_name;
+ town->townnameparts = GetOldTownName(town->townnameparts, _settings.game_creation.town_name);
}
}
}
@@ -1222,29 +1222,31 @@
}
static const OldChunks game_difficulty_chunk[] = {
- OCL_SVAR( OC_UINT16, GameDifficulty, max_no_competitors ),
- OCL_SVAR( OC_UINT16, GameDifficulty, competitor_start_time ),
- OCL_SVAR( OC_UINT16, GameDifficulty, number_towns ),
- OCL_SVAR( OC_UINT16, GameDifficulty, number_industries ),
- OCL_SVAR( OC_UINT16, GameDifficulty, max_loan ),
- OCL_SVAR( OC_UINT16, GameDifficulty, initial_interest ),
- OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_costs ),
- OCL_SVAR( OC_UINT16, GameDifficulty, competitor_speed ),
- OCL_SVAR( OC_UINT16, GameDifficulty, competitor_intelligence ),
- OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_breakdowns ),
- OCL_SVAR( OC_UINT16, GameDifficulty, subsidy_multiplier ),
- OCL_SVAR( OC_UINT16, GameDifficulty, construction_cost ),
- OCL_SVAR( OC_UINT16, GameDifficulty, terrain_type ),
- OCL_SVAR( OC_UINT16, GameDifficulty, quantity_sea_lakes ),
- OCL_SVAR( OC_UINT16, GameDifficulty, economy ),
- OCL_SVAR( OC_UINT16, GameDifficulty, line_reverse_mode ),
- OCL_SVAR( OC_UINT16, GameDifficulty, disasters ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, max_no_competitors ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, competitor_start_time ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, number_towns ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, number_industries ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U32, DifficultySettings, max_loan ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, initial_interest ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, vehicle_costs ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, competitor_speed ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, competitor_intelligence ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, vehicle_breakdowns ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, subsidy_multiplier ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, construction_cost ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, terrain_type ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, quantity_sea_lakes ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, economy ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, line_reverse_mode ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, disasters ),
OCL_END()
};
static inline bool LoadOldGameDifficulty(LoadgameState *ls, int num)
{
- return LoadChunk(ls, &_opt.diff, game_difficulty_chunk);
+ bool ret = LoadChunk(ls, &_settings.difficulty, game_difficulty_chunk);
+ _settings.difficulty.max_loan *= 1000;
+ return ret;
}
@@ -1422,8 +1424,8 @@
OCL_VAR ( OC_FILE_U8 | OC_VAR_U16, 1, &_station_tick_ctr ),
- OCL_VAR ( OC_UINT8, 1, &_opt.currency ),
- OCL_VAR ( OC_UINT8, 1, &_opt.units ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.gui.currency ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.gui.units ),
OCL_VAR ( OC_FILE_U8 | OC_VAR_U32, 1, &_cur_player_tick_index ),
OCL_NULL( 2 ), ///< Date stuff, calculated automatically
@@ -1433,19 +1435,19 @@
OCL_VAR ( OC_UINT8, 1, &_economy.infl_amount_pr ),
OCL_VAR ( OC_UINT8, 1, &_economy.interest_rate ),
OCL_NULL( 1 ), // available airports
- OCL_VAR ( OC_UINT8, 1, &_opt.road_side ),
- OCL_VAR ( OC_UINT8, 1, &_opt.town_name ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.vehicle.road_side ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.game_creation.town_name ),
OCL_CHUNK( 1, LoadOldGameDifficulty ),
OCL_ASSERT( 0x77130 ),
- OCL_VAR ( OC_UINT8, 1, &_opt.diff_level ),
- OCL_VAR ( OC_UINT8, 1, &_opt.landscape ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.difficulty.diff_level ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.game_creation.landscape ),
OCL_VAR ( OC_UINT8, 1, &_trees_tick_ctr ),
OCL_NULL( 1 ), ///< Custom vehicle types yes/no, no longer used
- OCL_VAR ( OC_UINT8, 1, &_opt.snow_line ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.game_creation.snow_line ),
OCL_NULL( 32 ), ///< new_industry_randtable, no longer used (because of new design)
OCL_NULL( 36 ), ///< cargo-stuff, calculated in InitializeLandscapeVariables
@@ -1480,7 +1482,7 @@
DEBUG(oldloader, 3, "Done, converting game data...");
/* Fix some general stuff */
- _opt.landscape = _opt.landscape & 0xF;
+ _settings.game_creation.landscape = _settings.game_creation.landscape & 0xF;
/* Remap some pointers */
_cur_town_ctr = REMAP_TOWN_IDX(_old_cur_town_ctr);
@@ -1542,7 +1544,7 @@
FixOldVehicles();
/* We have a new difficulty setting */
- _opt.diff.town_council_tolerance = Clamp(_opt.diff_level, 0, 2);
+ _settings.difficulty.town_council_tolerance = Clamp(_settings.difficulty.diff_level, 0, 2);
DEBUG(oldloader, 3, "Finished converting game data");
DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
--- a/src/openttd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/openttd.cpp Mon May 26 13:52:59 2008 +0000
@@ -41,7 +41,7 @@
#include "fios.h"
#include "airport.h"
#include "aircraft.h"
-#include "console.h"
+#include "console_func.h"
#include "screenshot.h"
#include "network/network.h"
#include "signs_base.h"
@@ -100,7 +100,7 @@
void ProcessAsyncSaveFinish();
void CallWindowTickEvent();
-extern void SetDifficultyLevel(int mode, GameOptions *gm_opt);
+extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
extern Player* DoStartupNewPlayer(bool is_ai);
extern void ShowOSErrorBox(const char *buf);
extern void InitializeRailGUI();
@@ -337,7 +337,6 @@
{
_game_mode = GM_MENU;
- _opt_ptr = &_opt_newgame;
ResetGRFConfig(false);
/* Setup main window */
@@ -496,8 +495,8 @@
if (!StrEmpty(blitter)) ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
if (!StrEmpty(ai)) AI_ForceAI(ai);
if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
- if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
- if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
+ if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
+ if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
/* The width and height must be at least 1 pixel, this
* way all internal drawing routines work correctly. */
@@ -594,15 +593,13 @@
ScanNewGRFFiles();
- _opt_ptr = &_opt_newgame;
ResetGRFConfig(false);
/* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */
- if (_opt_newgame.diff_level == 9) SetDifficultyLevel(0, &_opt_newgame);
+ if (_settings_newgame.difficulty.diff_level == 9) SetDifficultyLevel(0, &_settings_newgame.difficulty);
/* Make sure _patches is filled with _patches_newgame if we switch to a game directly */
if (_switch_mode != SM_NONE) {
- _opt = _opt_newgame;
UpdatePatches();
}
@@ -664,7 +661,7 @@
{
if (_game_mode == GM_MENU) { // do not ask to quit on the main screen
_exit_game = true;
- } else if (_patches.autosave_on_exit) {
+ } else if (_settings.gui.autosave_on_exit) {
DoExitSave();
_exit_game = true;
} else {
@@ -696,9 +693,9 @@
SetLocalPlayer(PLAYER_FIRST);
_current_player = _local_player;
- DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
+ DoCommandP(0, (_settings.gui.autorenew << 15 ) | (_settings.gui.autorenew_months << 16) | 4, _settings.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
- SettingsDisableElrail(_patches.disable_elrails);
+ SettingsDisableElrail(_settings.vehicle.disable_elrails);
InitializeRailGUI();
#ifdef ENABLE_NETWORK
@@ -723,7 +720,7 @@
_industry_mngr.ResetMapping();
GenerateWorldSetCallback(&MakeNewGameDone);
- GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _patches.map_x, 1 << _patches.map_y);
+ GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
}
static void MakeNewEditorWorldDone()
@@ -740,7 +737,7 @@
ResetGRFConfig(true);
GenerateWorldSetCallback(&MakeNewEditorWorldDone);
- GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y);
+ GenerateWorld(GW_EMPTY, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
}
void StartupPlayers();
@@ -779,9 +776,7 @@
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
}
- _opt_ptr = &_opt;
- _opt_ptr->diff = _opt_newgame.diff;
- _opt.diff_level = _opt_newgame.diff_level;
+ _settings.difficulty = _settings_newgame.difficulty;
/* Inititalize data */
StartupEconomy();
@@ -791,7 +786,7 @@
SetLocalPlayer(PLAYER_FIRST);
_current_player = _local_player;
- DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
+ DoCommandP(0, (_settings.gui.autorenew << 15 ) | (_settings.gui.autorenew_months << 16) | 4, _settings.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
MarkWholeScreenDirty();
}
@@ -850,8 +845,7 @@
/* check if we should reload the config */
if (_network_reload_cfg) {
LoadFromConfig();
- _patches = _patches_newgame;
- _opt = _opt_newgame;
+ _settings = _settings_newgame;
ResetGRFConfig(false);
}
NetworkServerStart();
@@ -887,7 +881,6 @@
break;
case SM_LOAD: { /* Load game, Play Scenario */
- _opt_ptr = &_opt;
ResetGRFConfig(true);
ResetWindowSystem();
@@ -925,16 +918,14 @@
case SM_LOAD_HEIGHTMAP: /* Load heightmap from scenario editor */
SetLocalPlayer(OWNER_NONE);
- GenerateWorld(GW_HEIGHTMAP, 1 << _patches.map_x, 1 << _patches.map_y);
+ GenerateWorld(GW_HEIGHTMAP, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
MarkWholeScreenDirty();
break;
case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */
if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR, NO_DIRECTORY)) {
- _opt_ptr = &_opt;
-
SetLocalPlayer(OWNER_NONE);
- _patches_newgame.starting_year = _cur_year;
+ _settings_newgame.game_creation.starting_year = _cur_year;
} else {
SetDParamStr(0, GetSaveLoadErrorString());
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
@@ -960,7 +951,7 @@
case SM_GENRANDLAND: /* Generate random land within scenario editor */
SetLocalPlayer(OWNER_NONE);
- GenerateWorld(GW_RANDOM, 1 << _patches.map_x, 1 << _patches.map_y);
+ GenerateWorld(GW_RANDOM, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
/* XXX: set date */
MarkWholeScreenDirty();
break;
@@ -1076,16 +1067,16 @@
if (_networking) return;
#endif /* PSP */
- if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
+ if (_settings.gui.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
SetDParam(0, _local_player);
SetDParam(1, _date);
GetString(buf, STR_4004, lastof(buf));
ttd_strlcat(buf, ".sav", lengthof(buf));
} else {
- /* generate a savegame name and number according to _patches.max_num_autosaves */
+ /* generate a savegame name and number according to _settings.gui.max_num_autosaves */
snprintf(buf, sizeof(buf), "autosave%d.sav", _autosave_ctr);
- if (++_autosave_ctr >= _patches.max_num_autosaves) _autosave_ctr = 0;
+ if (++_autosave_ctr >= _settings.gui.max_num_autosaves) _autosave_ctr = 0;
}
DEBUG(sl, 2, "Autosaving to '%s'", buf);
@@ -1275,7 +1266,7 @@
/* since savegame version 4.2 the currencies are arranged differently */
static void UpdateCurrencies()
{
- _opt.currency = convert_currency[_opt.currency];
+ _settings.gui.currency = convert_currency[_settings.gui.currency];
}
/* Up to revision 1413 the invisible tiles at the southern border have not been
@@ -1355,6 +1346,11 @@
SetCachedEngineCounts();
+ /* Towns have a noise controlled number of airports system
+ * So each airport's noise value must be added to the town->noise_reached value
+ * Reset each town's noise_reached value to '0' before. */
+ UpdateAirportsNoise();
+
return true;
}
@@ -1405,7 +1401,7 @@
Town *t;
FOR_ALL_TOWNS(t) {
t->name = CopyFromOldName(t->townnametype);
- if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _opt.town_name;
+ if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _settings.game_creation.town_name;
}
Waypoint *wp;
@@ -1419,7 +1415,7 @@
ResetOldNames();
/* convert road side to my format. */
- if (_opt.road_side) _opt.road_side = 1;
+ if (_settings.vehicle.road_side) _settings.vehicle.road_side = 1;
/* Check if all NewGRFs are present, we are very strict in MP mode */
GRFListCompatibility gcf_res = IsGoodGRFConfigList();
@@ -1439,7 +1435,7 @@
SetDate(_date);
/* Force dynamic engines off when loading older savegames */
- if (CheckSavegameVersion(95)) _patches.dynamic_engines = 0;
+ if (CheckSavegameVersion(95)) _settings.vehicle.dynamic_engines = 0;
/* Load the sprites */
GfxLoadSprites();
@@ -1646,9 +1642,9 @@
*/
if (!_network_dedicated && IsValidPlayer(PLAYER_FIRST)) {
p = GetPlayer(PLAYER_FIRST);
- p->engine_renew = _patches.autorenew;
- p->engine_renew_months = _patches.autorenew_months;
- p->engine_renew_money = _patches.autorenew_money;
+ p->engine_renew = _settings.gui.autorenew;
+ p->engine_renew_months = _settings.gui.autorenew_months;
+ p->engine_renew_money = _settings.gui.autorenew_money;
}
}
@@ -2033,9 +2029,9 @@
/* from version 38 we have optional elrails, since we cannot know the
* preference of a user, let elrails enabled; it can be disabled manually */
- if (CheckSavegameVersion(38)) _patches.disable_elrails = false;
+ if (CheckSavegameVersion(38)) _settings.vehicle.disable_elrails = false;
/* do the same as when elrails were enabled/disabled manually just now */
- SettingsDisableElrail(_patches.disable_elrails);
+ SettingsDisableElrail(_settings.vehicle.disable_elrails);
InitializeRailGUI();
/* From version 53, the map array was changed for house tiles to allow
@@ -2200,7 +2196,7 @@
Town *t;
FOR_ALL_TOWNS(t) {
- if (_patches.larger_towns != 0 && (t->index % _patches.larger_towns) == 0) {
+ if (_settings.economy.larger_towns != 0 && (t->index % _settings.economy.larger_towns) == 0) {
t->larger_town = true;
}
}
@@ -2237,12 +2233,12 @@
if (CheckSavegameVersion(58)) {
/* patch difficulty number_industries other then zero get bumped to +1
* since a new option (very low at position1) has been added */
- if (_opt.diff.number_industries > 0) {
- _opt.diff.number_industries++;
+ if (_settings.difficulty.number_industries > 0) {
+ _settings.difficulty.number_industries++;
}
/* Same goes for number of towns, although no test is needed, just an increment */
- _opt.diff.number_towns++;
+ _settings.difficulty.number_towns++;
}
if (CheckSavegameVersion(64)) {
@@ -2475,22 +2471,22 @@
}
/* Convert old PF settings to new */
- if (_patches.yapf.rail_use_yapf || CheckSavegameVersion(28)) {
- _patches.pathfinder_for_trains = VPF_YAPF;
+ if (_settings.pf.yapf.rail_use_yapf || CheckSavegameVersion(28)) {
+ _settings.pf.pathfinder_for_trains = VPF_YAPF;
} else {
- _patches.pathfinder_for_trains = (_patches.new_pathfinding_all ? VPF_NPF : VPF_NTP);
+ _settings.pf.pathfinder_for_trains = (_settings.pf.new_pathfinding_all ? VPF_NPF : VPF_NTP);
}
- if (_patches.yapf.road_use_yapf || CheckSavegameVersion(28)) {
- _patches.pathfinder_for_roadvehs = VPF_YAPF;
+ if (_settings.pf.yapf.road_use_yapf || CheckSavegameVersion(28)) {
+ _settings.pf.pathfinder_for_roadvehs = VPF_YAPF;
} else {
- _patches.pathfinder_for_roadvehs = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
+ _settings.pf.pathfinder_for_roadvehs = (_settings.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF);
}
- if (_patches.yapf.ship_use_yapf) {
- _patches.pathfinder_for_ships = VPF_YAPF;
+ if (_settings.pf.yapf.ship_use_yapf) {
+ _settings.pf.pathfinder_for_ships = VPF_YAPF;
} else {
- _patches.pathfinder_for_ships = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
+ _settings.pf.pathfinder_for_ships = (_settings.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF);
}
}
--- a/src/order_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/order_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -152,11 +152,15 @@
void Order::ConvertFromOldSavegame()
{
- /* First handle non-stop, because those bits are going to be reused. */
- if (_patches.sg_new_nonstop) {
- this->SetNonStopType((this->flags & 0x08) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+ uint8 old_flags = this->flags;
+ this->flags = 0;
+
+ /* First handle non-stop */
+ if (_settings.gui.sg_new_nonstop) {
+ /* OFB_NON_STOP */
+ this->SetNonStopType((old_flags & 8) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
} else {
- this->SetNonStopType((this->flags & 0x08) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
+ this->SetNonStopType((old_flags & 8) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
}
switch (this->GetType()) {
@@ -165,31 +169,31 @@
default: return;
}
- /* Then the load/depot action flags because those bits are going to be reused too
- * and they reuse the non-stop bits. */
if (this->GetType() != OT_GOTO_DEPOT) {
- if ((this->flags & 4) == 0) {
+ /* Then the load flags */
+ if ((old_flags & 2) != 0) { // OFB_UNLOAD
+ this->SetLoadType(OLFB_NO_LOAD);
+ } else if ((old_flags & 4) == 0) { // !OFB_FULL_LOAD
this->SetLoadType(OLF_LOAD_IF_POSSIBLE);
} else {
- this->SetLoadType(_patches.sg_full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD);
+ this->SetLoadType(_settings.gui.sg_full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD);
+ }
+
+ /* Finally fix the unload flags */
+ if ((old_flags & 1) != 0) { // OFB_TRANSFER
+ this->SetUnloadType(OUFB_TRANSFER);
+ } else if ((old_flags & 2) != 0) { // OFB_UNLOAD
+ this->SetUnloadType(OUFB_UNLOAD);
+ } else {
+ this->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE);
}
} else {
- this->SetDepotActionType(((this->flags & 6) == 4) ? ODATFB_HALT : ODATF_SERVICE_ONLY);
- }
+ /* Then the depot action flags */
+ this->SetDepotActionType(((old_flags & 6) == 4) ? ODATFB_HALT : ODATF_SERVICE_ONLY);
- /* Finally fix the unload/depot type flags. */
- if (this->GetType() != OT_GOTO_DEPOT) {
- uint t = ((this->flags & 1) == 0) ? OUF_UNLOAD_IF_POSSIBLE : OUFB_TRANSFER;
- if ((this->flags & 2) != 0) t |= OUFB_UNLOAD;
- this->SetUnloadType((OrderUnloadFlags)t);
-
- if ((this->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) {
- this->SetUnloadType(OUFB_TRANSFER);
- this->SetLoadType(OLFB_NO_LOAD);
- }
- } else {
- uint t = ((this->flags & 6) == 6) ? ODTFB_SERVICE : ODTF_MANUAL;
- if ((this->flags & 2) != 0) t |= ODTFB_PART_OF_ORDERS;
+ /* Finally fix the depot type flags */
+ uint t = ((old_flags & 6) == 6) ? ODTFB_SERVICE : ODTF_MANUAL;
+ if ((old_flags & 2) != 0) t |= ODTFB_PART_OF_ORDERS;
this->SetDepotOrderType((OrderDepotTypeFlags)t);
}
}
@@ -451,7 +455,7 @@
if (!HasOrderPoolFree(1)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);
- if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _patches.pathfinder_for_ships != VPF_NPF) {
+ if (v->type == VEH_SHIP && IsHumanPlayer(v->owner) && _settings.pf.pathfinder_for_ships != VPF_NPF) {
/* Make sure the new destination is not too far away from the previous */
const Order *prev = NULL;
uint n = 0;
@@ -1273,7 +1277,7 @@
}
/* Copy timetable if enabled */
- if (_patches.timetabling && !DoCommandP(0, v->index | (i << 16) | (1 << 25),
+ if (_settings.order.timetabling && !DoCommandP(0, v->index | (i << 16) | (1 << 25),
bak->order[i].wait_time << 16 | bak->order[i].travel_time, NULL,
CMD_CHANGE_TIMETABLE | CMD_NO_TEST_IF_IN_NETWORK)) {
break;
@@ -1386,13 +1390,13 @@
void CheckOrders(const Vehicle* v)
{
/* Does the user wants us to check things? */
- if (_patches.order_review_system == 0) return;
+ if (_settings.gui.order_review_system == 0) return;
/* Do nothing for crashed vehicles */
if (v->vehstatus & VS_CRASHED) return;
/* Do nothing for stopped vehicles if setting is '1' */
- if (_patches.order_review_system == 1 && v->vehstatus & VS_STOPPED)
+ if (_settings.gui.order_review_system == 1 && v->vehstatus & VS_STOPPED)
return;
/* do nothing we we're not the first vehicle in a share-chain */
@@ -1571,7 +1575,7 @@
Date GetServiceIntervalClamped(uint index)
{
- return (_patches.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
+ return (_settings.vehicle.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
}
/**
--- a/src/order_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/order_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -265,13 +265,13 @@
order.index = 0;
/* check depot first */
- if (_patches.gotodepot) {
+ if (_settings.order.gotodepot) {
switch (GetTileType(tile)) {
case MP_RAILWAY:
if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) {
if (IsRailDepot(tile)) {
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
- if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+ if (_settings.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
return order;
}
}
@@ -280,7 +280,7 @@
case MP_ROAD:
if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
- if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+ if (_settings.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
return order;
}
break;
@@ -313,7 +313,7 @@
IsTileOwner(tile, _local_player) &&
IsRailWaypoint(tile)) {
order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
- if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+ if (_settings.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
return order;
}
@@ -330,7 +330,7 @@
(facil = FACIL_TRUCK_STOP, 1);
if (st->facilities & facil) {
order.MakeGoToStation(st_index);
- if (_patches.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+ if (_settings.gui.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
return order;
}
}
@@ -611,7 +611,7 @@
this->resize.step_height = 10;
this->selected_order = -1;
this->vehicle = v;
- if (_patches.timetabling) {
+ if (_settings.order.timetabling) {
this->widget[ORDER_WIDGET_CAPTION].right -= 61;
} else {
this->HideWidget(ORDER_WIDGET_TIMETABLE_VIEW);
--- a/src/pathfind.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/pathfind.cpp Mon May 26 13:52:59 2008 +0000
@@ -778,7 +778,7 @@
tpf->enum_proc = enum_proc;
tpf->tracktype = TRANSPORT_RAIL;
tpf->railtypes = railtypes;
- tpf->maxlength = min(_patches.pf_maxlength * 3, 10000);
+ tpf->maxlength = min(_settings.pf.opf.pf_maxlength * 3, 10000);
tpf->nstack = 0;
tpf->new_link = tpf->links;
tpf->num_links_left = lengthof(tpf->links);
--- a/src/player_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/player_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -165,6 +165,8 @@
this->top = top;
this->left = left;
}
+
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
@@ -755,10 +757,9 @@
}
public:
- SelectPlayerFaceWindow(const WindowDesc *desc, Window *parent, bool advanced) : Window(desc, parent->window_number)
+ SelectPlayerFaceWindow(const WindowDesc *desc, Window *parent, bool advanced, int top, int left) : Window(desc, parent->window_number)
{
this->parent = parent;
- this->FindWindowPlacementAndResize(desc);
this->caption_color = this->window_number;
this->face = GetPlayer((PlayerID)this->window_number)->face;
this->advanced = advanced;
@@ -770,6 +771,8 @@
this->top = top;
this->left = left;
}
+
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
@@ -1032,7 +1035,7 @@
if (!IsValidPlayer((PlayerID)parent->window_number)) return;
if (BringWindowToFrontById(WC_PLAYER_FACE, parent->window_number)) return;
- new SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, parent, adv); // simple or advanced window
+ new SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, parent, adv, top, left); // simple or advanced window
}
@@ -1167,6 +1170,7 @@
PlayerCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
this->caption_color = this->window_number;
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
@@ -1187,7 +1191,7 @@
this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
if (!local) {
- if (_patches.allow_shares) { // Shares are allowed
+ if (_settings.economy.allow_shares) { // Shares are allowed
/* If all shares are owned by someone (none by nobody), disable buy button */
this->SetWidgetDisabledState(PCW_WIDGET_BUY_SHARE, GetAmountOwnedBy(p, PLAYER_SPECTATOR) == 0 ||
/* Only 25% left to buy. If the player is human, disable buying it up.. TODO issues! */
@@ -1357,6 +1361,7 @@
struct BuyCompanyWindow : Window {
BuyCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
@@ -1472,7 +1477,7 @@
} else {
/* in single player _local player is always valid */
const Player *p = GetPlayer(_local_player);
- this->window_number = _opt.diff_level;
+ this->window_number = _settings.difficulty.diff_level;
this->rank = SaveHighScoreValue(p);
}
@@ -1540,7 +1545,7 @@
this->SetupHighScoreEndWindow(&x, &y);
- SetDParam(0, _patches.ending_year);
+ SetDParam(0, _settings.gui.ending_year);
SetDParam(1, this->window_number + STR_6801_EASY);
DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500);
--- a/src/players.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/players.cpp Mon May 26 13:52:59 2008 +0000
@@ -64,9 +64,9 @@
/* Do not update the patches if we are in the intro GUI */
if (IsValidPlayer(new_player) && _game_mode != GM_MENU) {
const Player *p = GetPlayer(new_player);
- _patches.autorenew = p->engine_renew;
- _patches.autorenew_months = p->engine_renew_months;
- _patches.autorenew_money = p->engine_renew_money;
+ _settings.gui.autorenew = p->engine_renew;
+ _settings.gui.autorenew_months = p->engine_renew_months;
+ _settings.gui.autorenew_money = p->engine_renew_money;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
}
@@ -541,9 +541,9 @@
/* Engine renewal settings */
p->engine_renew_list = NULL;
p->renew_keep_length = false;
- p->engine_renew = _patches_newgame.autorenew;
- p->engine_renew_months = _patches_newgame.autorenew_months;
- p->engine_renew_money = _patches_newgame.autorenew_money;
+ p->engine_renew = _settings_newgame.gui.autorenew;
+ p->engine_renew_months = _settings_newgame.gui.autorenew_months;
+ p->engine_renew_money = _settings_newgame.gui.autorenew_money;
GeneratePresidentName(p);
@@ -562,7 +562,7 @@
void StartupPlayers()
{
/* The AI starts like in the setting with +2 month max */
- _next_competitor_start = _opt.diff.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1;
+ _next_competitor_start = _settings.difficulty.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1;
}
static void MaybeStartNewPlayer()
@@ -577,10 +577,10 @@
}
/* when there's a lot of computers in game, the probability that a new one starts is lower */
- if (n < (uint)_opt.diff.max_no_competitors &&
+ if (n < (uint)_settings.difficulty.max_no_competitors &&
n < (_network_server ?
- InteractiveRandomRange(_opt.diff.max_no_competitors + 2) :
- RandomRange(_opt.diff.max_no_competitors + 2)
+ InteractiveRandomRange(_settings.difficulty.max_no_competitors + 2) :
+ RandomRange(_settings.difficulty.max_no_competitors + 2)
)) {
/* Send a command to all clients to start up a new AI.
* Works fine for Multiplayer and Singleplayer */
@@ -588,7 +588,7 @@
}
/* The next AI starts like the difficulty setting said, with +2 month max */
- _next_competitor_start = _opt.diff.competitor_start_time * 90 * DAY_TICKS + 1;
+ _next_competitor_start = _settings.difficulty.competitor_start_time * 90 * DAY_TICKS + 1;
_next_competitor_start += _network_server ? InteractiveRandomRange(60 * DAY_TICKS) : RandomRange(60 * DAY_TICKS);
}
@@ -629,7 +629,7 @@
}
}
- if (_patches.show_finances && _local_player != PLAYER_SPECTATOR) {
+ if (_settings.gui.show_finances && _local_player != PLAYER_SPECTATOR) {
ShowPlayerFinances(_local_player);
p = GetPlayer(_local_player);
if (p->num_valid_stat_ent > 5 && p->old_economy[0].performance_history < p->old_economy[4].performance_history) {
@@ -694,7 +694,7 @@
if (flags & DC_EXEC) {
p->engine_renew = HasBit(p2, 0);
if (IsLocalPlayer()) {
- _patches.autorenew = p->engine_renew;
+ _settings.gui.autorenew = p->engine_renew;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
}
@@ -707,7 +707,7 @@
if (flags & DC_EXEC) {
p->engine_renew_months = (int16)p2;
if (IsLocalPlayer()) {
- _patches.autorenew_months = p->engine_renew_months;
+ _settings.gui.autorenew_months = p->engine_renew_months;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
}
@@ -720,7 +720,7 @@
if (flags & DC_EXEC) {
p->engine_renew_money = p2;
if (IsLocalPlayer()) {
- _patches.autorenew_money = p->engine_renew_money;
+ _settings.gui.autorenew_money = p->engine_renew_money;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
}
@@ -770,9 +770,9 @@
p->engine_renew_money = p2;
if (IsLocalPlayer()) {
- _patches.autorenew = p->engine_renew;
- _patches.autorenew_months = p->engine_renew_months;
- _patches.autorenew_money = p->engine_renew_money;
+ _settings.gui.autorenew = p->engine_renew;
+ _settings.gui.autorenew_months = p->engine_renew_months;
+ _settings.gui.autorenew_money = p->engine_renew_money;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
}
@@ -875,8 +875,8 @@
/* Now that we have a new player, broadcast its autorenew settings to
* all clients so everything is in sync */
DoCommand(0,
- (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4,
- _patches.autorenew_money,
+ (_settings.gui.autorenew << 15 ) | (_settings.gui.autorenew_months << 16) | 4,
+ _settings.gui.autorenew_money,
DC_EXEC,
CMD_SET_AUTOREPLACE
);
@@ -995,7 +995,7 @@
/** Save the highscore for the player */
int8 SaveHighScoreValue(const Player *p)
{
- HighScore *hs = _highscore_table[_opt.diff_level];
+ HighScore *hs = _highscore_table[_settings.difficulty.diff_level];
uint i;
uint16 score = p->old_economy[0].performance_history;
@@ -1123,7 +1123,7 @@
}
/* Initialize end of game variable (when to show highscore chart) */
- _patches.ending_year = 2051;
+ _settings.gui.ending_year = 2051;
}
/* Save/load of players */
--- a/src/rail.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/rail.cpp Mon May 26 13:52:59 2008 +0000
@@ -207,7 +207,7 @@
FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) {
const EngineInfo *ei = &e->info;
- if (HasBit(ei->climates, _opt.landscape) &&
+ if (HasBit(ei->climates, _settings.game_creation.landscape) &&
(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
const RailVehicleInfo *rvi = &e->u.rail;
--- a/src/rail_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/rail_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -292,7 +292,7 @@
/* check track/slope combination */
if ((f_new == FOUNDATION_INVALID) ||
- ((f_new != FOUNDATION_NONE) && (!_patches.build_on_slopes))
+ ((f_new != FOUNDATION_NONE) && (!_settings.construction.build_on_slopes))
) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
Foundation f_old = GetRailFoundation(tileh, existing);
@@ -755,7 +755,7 @@
*/
if (tileh != SLOPE_FLAT && (
- !_patches.build_on_slopes ||
+ !_settings.construction.build_on_slopes ||
IsSteepSlope(tileh) ||
!CanBuildDepotByTileh(dir, tileh)
)) {
@@ -1223,7 +1223,7 @@
RailType type = GetRailType(tile);
/* Converting to the same type or converting 'hidden' elrail -> rail */
- if (type == totype || (_patches.disable_elrails && totype == RAILTYPE_RAIL && type == RAILTYPE_ELECTRIC)) continue;
+ if (type == totype || (_settings.vehicle.disable_elrails && totype == RAILTYPE_RAIL && type == RAILTYPE_ELECTRIC)) continue;
/* Trying to convert other's rail */
if (!CheckTileOwnership(tile)) continue;
@@ -1419,7 +1419,7 @@
static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint image, uint pos)
{
- bool side = (_opt.road_side != 0) && _patches.signal_side;
+ bool side = (_settings.vehicle.road_side != 0) && _settings.construction.signal_side;
static const Point SignalPositions[2][12] = {
{ /* Signals on the left side */
/* LEFT LEFT RIGHT RIGHT UPPER UPPER */
@@ -1788,7 +1788,7 @@
/* adjust ground tile for desert
* don't adjust for snow, because snow in depots looks weird */
- if (IsSnowRailGround(ti->tile) && _opt.landscape == LT_TROPIC) {
+ if (IsSnowRailGround(ti->tile) && _settings.game_creation.landscape == LT_TROPIC) {
if (image != SPR_FLAT_GRASS_TILE) {
image += rti->snow_offset; // tile with tracks
} else {
@@ -1952,7 +1952,7 @@
return;
}
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_ARCTIC: {
uint z;
Slope slope = GetTileSlope(tile, &z);
@@ -2172,7 +2172,7 @@
static void GetTileDesc_Track(TileIndex tile, TileDesc *td)
{
- td->owner = GetTileOwner(tile);
+ td->owner[0] = GetTileOwner(tile);
switch (GetRailTileType(tile)) {
case RAIL_TILE_NORMAL:
td->str = STR_1021_RAILROAD_TRACK;
@@ -2328,7 +2328,7 @@
*/
static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_old, Slope tileh_old, uint z_new, Slope tileh_new, TrackBits rail_bits)
{
- if (!_patches.build_on_slopes || !AutoslopeEnabled()) return CMD_ERROR;
+ if (!_settings.construction.build_on_slopes || !AutoslopeEnabled()) return CMD_ERROR;
/* Is the slope-rail_bits combination valid in general? I.e. is it save to call GetRailFoundation() ? */
if (CmdFailed(CheckRailSlope(tileh_new, rail_bits, TRACK_BIT_NONE, tile))) return CMD_ERROR;
@@ -2404,7 +2404,7 @@
/* allow terraforming */
return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price.clear_water : (Money)0);
} else {
- if (_patches.build_on_slopes && AutoslopeEnabled()) {
+ if (_settings.construction.build_on_slopes && AutoslopeEnabled()) {
switch (GetRailTileType(tile)) {
case RAIL_TILE_WAYPOINT: {
CommandCost cost = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, GetRailWaypointBits(tile));
--- a/src/rail_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/rail_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -65,10 +65,10 @@
static void HandleStationPlacement(TileIndex start, TileIndex end);
-static void ShowBuildTrainDepotPicker();
-static void ShowBuildWaypointPicker();
-static void ShowStationBuilder();
-static void ShowSignalBuilder();
+static void ShowBuildTrainDepotPicker(Window *parent);
+static void ShowBuildWaypointPicker(Window *parent);
+static void ShowStationBuilder(Window *parent);
+static void ShowSignalBuilder(Window *parent);
void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
@@ -182,7 +182,7 @@
VpSetPlaceSizingLimit(-1);
} else if (_railstation.dragdrop) {
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
- VpSetPlaceSizingLimit(_patches.station_spread);
+ VpSetPlaceSizingLimit(_settings.station.station_spread);
} else {
DoCommandP(tile,
_railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24),
@@ -227,7 +227,7 @@
SB(p1, 7, 1, _convert_signal_button);
} else {
SB(p1, 3, 1, _ctrl_pressed);
- SB(p1, 4, 1, (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
+ SB(p1, 4, 1, (_cur_year < _settings.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
SB(p1, 5, 2, SIGTYPE_NORMAL);
SB(p1, 7, 1, 0);
}
@@ -392,7 +392,7 @@
static void BuildRailClick_Depot(Window *w)
{
if (HandlePlacePushButton(w, RTW_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, VHM_RECT, PlaceRail_Depot)) {
- ShowBuildTrainDepotPicker();
+ ShowBuildTrainDepotPicker(w);
}
}
@@ -407,7 +407,7 @@
_waypoint_count = GetNumCustomStations(STAT_CLASS_WAYP);
if (HandlePlacePushButton(w, RTW_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, VHM_RECT, PlaceRail_Waypoint) &&
_waypoint_count > 1) {
- ShowBuildWaypointPicker();
+ ShowBuildWaypointPicker(w);
}
}
@@ -418,7 +418,7 @@
*/
static void BuildRailClick_Station(Window *w)
{
- if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder();
+ if (HandlePlacePushButton(w, RTW_BUILD_STATION, SPR_CURSOR_RAIL_STATION, VHM_RECT, PlaceRail_Station)) ShowStationBuilder(w);
}
/**
@@ -429,8 +429,8 @@
*/
static void BuildRailClick_AutoSignals(Window *w)
{
- if (_patches.enable_signal_gui != _ctrl_pressed) {
- if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder();
+ if (_settings.gui.enable_signal_gui != _ctrl_pressed) {
+ if (HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals)) ShowSignalBuilder(w);
} else {
HandlePlacePushButton(w, RTW_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, VHM_RECT, PlaceRail_AutoSignals);
}
@@ -484,7 +484,7 @@
if (_railstation.orientation == 0) Swap(x, y);
SetTileSelectSize(x, y);
} else {
- VpSetPlaceSizingLimit(_patches.station_spread);
+ VpSetPlaceSizingLimit(_settings.station.station_spread);
}
}
}
@@ -547,15 +547,15 @@
SB(p2, 3, 1, 0);
SB(p2, 4, 1, _cur_signal_variant);
SB(p2, 6, 1, _ctrl_pressed);
- SB(p2, 24, 8, _patches.drag_signals_density);
+ SB(p2, 24, 8, _settings.gui.drag_signals_density);
} else {
SB(p2, 3, 1, 0);
- SB(p2, 4, 1, (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
+ SB(p2, 4, 1, (_cur_year < _settings.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
SB(p2, 6, 1, _ctrl_pressed);
- SB(p2, 24, 8, _patches.drag_signals_density);
+ SB(p2, 24, 8, _settings.gui.drag_signals_density);
}
- /* _patches.drag_signals_density is given as a parameter such that each user
+ /* _settings.gui.drag_signals_density is given as a parameter such that each user
* in a network game can specify his/her own signal density */
DoCommandP(
TileVirtXY(thd->selstart.x, thd->selstart.y),
@@ -617,12 +617,12 @@
this->DisableWidget(RTW_REMOVE);
this->FindWindowPlacementAndResize(desc);
- if (_patches.link_terraform_toolbar) ShowTerraformToolbar(this);
+ if (_settings.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}
~BuildRailToolbarWindow()
{
- if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
+ if (_settings.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
}
void UpdateRemoveWidgetStatus(int clicked_widget)
@@ -967,7 +967,7 @@
*/
public:
- BuildRailStationWindow(const WindowDesc *desc, bool newstation) : PickerWindowBase(desc)
+ BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent)
{
this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
if (_railstation.dragdrop) {
@@ -1008,13 +1008,13 @@
SetTileSelectSize(x, y);
}
- int rad = (_patches.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
+ int rad = (_settings.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
if (_station_show_coverage)
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
for (uint bits = 0; bits < 7; bits++) {
- bool disable = bits >= _patches.station_spread;
+ bool disable = bits >= _settings.station.station_spread;
if (statspec == NULL) {
this->SetWidgetDisabledState(bits + BRSW_PLATFORM_NUM_1, disable);
this->SetWidgetDisabledState(bits + BRSW_PLATFORM_LEN_1, disable);
@@ -1333,12 +1333,12 @@
};
/** Open station build window */
-static void ShowStationBuilder()
+static void ShowStationBuilder(Window *parent)
{
if (GetNumStationClasses() <= 2 && GetNumCustomStations(STAT_CLASS_DFLT) == 1) {
- new BuildRailStationWindow(&_station_builder_desc, false);
+ new BuildRailStationWindow(&_station_builder_desc, parent, false);
} else {
- new BuildRailStationWindow(&_newstation_builder_desc, true);
+ new BuildRailStationWindow(&_newstation_builder_desc, parent, true);
}
}
@@ -1379,7 +1379,7 @@
}
public:
- BuildSignalWindow(const WindowDesc *desc) : PickerWindowBase(desc)
+ BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->FindWindowPlacementAndResize(desc);
};
@@ -1390,8 +1390,8 @@
this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
- this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _patches.drag_signals_density == 1);
- this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _patches.drag_signals_density == 20);
+ this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _settings.gui.drag_signals_density == 1);
+ this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _settings.gui.drag_signals_density == 20);
this->DrawWidgets();
@@ -1406,7 +1406,7 @@
this->DrawSignalSprite(BSW_ELECTRIC_COMBO, SPR_IMG_SIGNAL_ELECTRIC_COMBO, -2, 6);
/* Draw dragging signal density value in the BSW_DRAG_SIGNALS_DENSITY widget */
- SetDParam(0, _patches.drag_signals_density);
+ SetDParam(0, _settings.gui.drag_signals_density);
DrawStringCentered(this->widget[BSW_DRAG_SIGNALS_DENSITY].left + (this->widget[BSW_DRAG_SIGNALS_DENSITY].right -
this->widget[BSW_DRAG_SIGNALS_DENSITY].left) / 2 + 1,
this->widget[BSW_DRAG_SIGNALS_DENSITY].top + 2, STR_JUST_INT, TC_ORANGE);
@@ -1434,15 +1434,15 @@
break;
case BSW_DRAG_SIGNALS_DENSITY_DECREASE:
- if (_patches.drag_signals_density > 1) {
- _patches.drag_signals_density--;
+ if (_settings.gui.drag_signals_density > 1) {
+ _settings.gui.drag_signals_density--;
SetWindowDirty(FindWindowById(WC_GAME_OPTIONS, 0));
}
break;
case BSW_DRAG_SIGNALS_DENSITY_INCREASE:
- if (_patches.drag_signals_density < 20) {
- _patches.drag_signals_density++;
+ if (_settings.gui.drag_signals_density < 20) {
+ _settings.gui.drag_signals_density++;
SetWindowDirty(FindWindowById(WC_GAME_OPTIONS, 0));
}
break;
@@ -1488,9 +1488,9 @@
/**
* Open the signal selection window
*/
-static void ShowSignalBuilder()
+static void ShowSignalBuilder(Window *parent)
{
- new BuildSignalWindow(&_signal_builder_desc);
+ new BuildSignalWindow(&_signal_builder_desc, parent);
}
struct BuildRailDepotWindow : public PickerWindowBase {
@@ -1507,7 +1507,7 @@
};
public:
- BuildRailDepotWindow(const WindowDesc *desc) : PickerWindowBase(desc)
+ BuildRailDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->LowerWidget(_build_depot_direction + BRDW_DEPOT_NE);
this->FindWindowPlacementAndResize(desc);
@@ -1559,9 +1559,9 @@
_build_depot_widgets,
};
-static void ShowBuildTrainDepotPicker()
+static void ShowBuildTrainDepotPicker(Window *parent)
{
- new BuildRailDepotWindow(&_build_depot_desc);
+ new BuildRailDepotWindow(&_build_depot_desc, parent);
}
struct BuildRailWaypointWindow : PickerWindowBase {
@@ -1580,7 +1580,7 @@
};
public:
- BuildRailWaypointWindow(const WindowDesc *desc) : PickerWindowBase(desc)
+ BuildRailWaypointWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->hscroll.cap = 5;
this->hscroll.count = _waypoint_count;
@@ -1660,9 +1660,9 @@
_build_waypoint_widgets,
};
-static void ShowBuildWaypointPicker()
+static void ShowBuildWaypointPicker(Window *parent)
{
- new BuildRailWaypointWindow(&_build_waypoint_desc);
+ new BuildRailWaypointWindow(&_build_waypoint_desc, parent);
}
/**
@@ -1701,7 +1701,7 @@
if (_local_player == PLAYER_SPECTATOR || !IsValidPlayer(_local_player)) return;
extern RailType _last_built_railtype;
- RailType rt = (RailType)_patches.default_rail_type;
+ RailType rt = (RailType)_settings.gui.default_rail_type;
if (rt >= RAILTYPE_END) {
if (rt == RAILTYPE_END + 2) {
/* Find the most used rail type */
@@ -1753,7 +1753,7 @@
*/
int32 ResetSignalVariant(int32 = 0)
{
- SignalVariant new_variant = (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
+ SignalVariant new_variant = (_cur_year < _settings.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
if (new_variant != _cur_signal_variant) {
Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
--- a/src/road.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/road.cpp Mon May 26 13:52:59 2008 +0000
@@ -103,7 +103,7 @@
FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
const EngineInfo *ei = &e->info;
- if (HasBit(ei->climates, _opt.landscape) &&
+ if (HasBit(ei->climates, _settings.game_creation.landscape) &&
(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
--- a/src/road_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/road_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -68,7 +68,11 @@
if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR;
if (flags & DC_EXEC) {
- _opt_ptr->road_side = p1;
+ if (_game_mode == GM_MENU) {
+ _settings.vehicle.road_side = p1;
+ } else {
+ _settings.vehicle.road_side = p1;
+ }
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
return CommandCost();
@@ -130,10 +134,18 @@
Foundation GetRoadFoundation(Slope tileh, RoadBits bits);
-bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt)
+/**
+ * Is it allowed to remove the given road bits from the given tile?
+ * @param tile the tile to remove the road from
+ * @param remove the roadbits that are going to be removed
+ * @param owner the actual owner of the roadbits of the tile
+ * @param rt the road type to remove the bits from
+ * @param flags command flags
+ * @param town_check Shall the town rating checked/affected
+ * @return true when it is allowed to remove the road bits
+ */
+bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType rt, uint32 flags, bool town_check)
{
- *edge_road = true;
-
if (_game_mode == GM_EDITOR || remove == ROAD_NONE) return true;
/* Water can always flood and towns can always remove "normal" road pieces.
@@ -146,8 +158,17 @@
* by a town */
if (owner != OWNER_TOWN) return (owner == OWNER_NONE) || CheckOwnership(owner);
+ if (!town_check) return true;
+
if (_cheats.magic_bulldozer.value) return true;
+ Town *t = ClosestTownFromTile(tile, UINT_MAX);
+ if (t == NULL) return true;
+
+ /* check if you're allowed to remove the street owned by a town
+ * removal allowance depends on difficulty setting */
+ if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return false;
+
/* Get a bitmask of which neighbouring roads has a tile */
RoadBits n = ROAD_NONE;
RoadBits present = GetAnyRoadBits(tile, rt);
@@ -156,28 +177,23 @@
if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0), rt) & ROAD_NE) n |= ROAD_SW;
if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0, -1), rt) & ROAD_SE) n |= ROAD_NW;
+ int rating_decrease = RATING_ROAD_DOWN_STEP_EDGE;
/* If 0 or 1 bits are set in n, or if no bits that match the bits to remove,
* then allow it */
if (KillFirstBit(n) != ROAD_NONE && (n & remove) != ROAD_NONE) {
- *edge_road = false;
/* you can remove all kind of roads with extra dynamite */
- if (_patches.extra_dynamite) return true;
-
- const Town *t = ClosestTownFromTile(tile, (uint)-1);
-
- SetDParam(0, t->index);
- _error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
- return false;
+ if (!_settings.construction.extra_dynamite) {
+ SetDParam(0, t->index);
+ _error_message = STR_2009_LOCAL_AUTHORITY_REFUSES;
+ return false;
+ }
+ rating_decrease = RATING_ROAD_DOWN_STEP_INNER;
}
+ ChangeTownRating(t, rating_decrease, RATING_ROAD_MINIMUM);
return true;
}
-static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool *edge_road, RoadType rt)
-{
- return CheckAllowRemoveRoad(tile, remove, GetRoadOwner(tile, rt), edge_road, rt);
-}
-
/** Delete a piece of road.
* @param tile tile where to remove road from
@@ -188,22 +204,20 @@
*/
static CommandCost RemoveRoad(TileIndex tile, uint32 flags, RoadBits pieces, RoadType rt, bool crossing_check, bool town_check = true)
{
- /* cost for removing inner/edge -roads */
- static const uint16 road_remove_cost[2] = {50, 18};
+ RoadTypes rts = GetRoadTypes(tile);
+ /* The tile doesn't have the given road type */
+ if (!HasBit(rts, rt)) return CMD_ERROR;
- /* true if the roadpiece was always removeable,
- * false if it was a center piece. Affects town ratings drop */
- bool edge_road;
+ bool town_road_under_stop = false;
- Town *t = NULL;
switch (GetTileType(tile)) {
case MP_ROAD:
- if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile);
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
break;
case MP_STATION:
if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
+ if (rt == ROADTYPE_ROAD) town_road_under_stop = GetStopBuiltOnTownRoad(tile);
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
break;
@@ -216,15 +230,7 @@
return CMD_ERROR;
}
- RoadTypes rts = GetRoadTypes(tile);
- /* The tile doesn't have the given road type */
- if (!HasBit(rts, rt)) return CMD_ERROR;
-
- if (!CheckAllowRemoveRoad(tile, pieces, &edge_road, rt)) return CMD_ERROR;
-
- /* check if you're allowed to remove the street owned by a town
- * removal allowance depends on difficulty setting */
- if (town_check && !CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR;
+ if (!CheckAllowRemoveRoad(tile, pieces, town_road_under_stop ? OWNER_TOWN : GetRoadOwner(tile, rt), rt, flags, town_check)) return CMD_ERROR;
if (!IsTileType(tile, MP_ROAD)) {
/* If it's the last roadtype, just clear the whole tile */
@@ -273,7 +279,7 @@
* @li if build on slopes is disabled */
if (IsSteepSlope(tileh) || (IsStraightRoad(other) &&
(other & _invalid_tileh_slopes_road[0][tileh & SLOPE_ELEVATED]) != ROAD_NONE) ||
- (tileh != SLOPE_FLAT && !_patches.build_on_slopes)) {
+ (tileh != SLOPE_FLAT && !_settings.construction.build_on_slopes)) {
pieces |= MirrorRoadBits(pieces);
}
@@ -290,7 +296,6 @@
return CMD_ERROR;
}
- if (town_check) ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
if (flags & DC_EXEC) {
if (HasRoadWorks(tile)) {
/* flooding tile with road works, don't forget to remove the effect vehicle too */
@@ -336,10 +341,6 @@
* we can't draw the crossing without trambits ;) */
if (rt == ROADTYPE_ROAD && HasTileRoadType(tile, ROADTYPE_TRAM) && (flags & DC_EXEC || crossing_check)) return CMD_ERROR;
- if (rt == ROADTYPE_ROAD) {
- if (town_check) ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
- }
-
if (flags & DC_EXEC) {
RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
if (rts == ROADTYPES_NONE) {
@@ -418,7 +419,7 @@
RoadBits type_bits = existing | *pieces;
/* Roads on slopes */
- if (_patches.build_on_slopes && (_invalid_tileh_slopes_road[0][tileh] & (other | type_bits)) == ROAD_NONE) {
+ if (_settings.construction.build_on_slopes && (_invalid_tileh_slopes_road[0][tileh] & (other | type_bits)) == ROAD_NONE) {
/* If we add leveling we've got to pay for it */
if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
@@ -438,7 +439,7 @@
if (IsSlopeWithOneCornerRaised(tileh)) {
/* Prevent build on slopes if it isn't allowed */
- if (_patches.build_on_slopes) {
+ if (_settings.construction.build_on_slopes) {
/* If we add foundation we've got to pay for it */
if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
@@ -501,7 +502,7 @@
}
if ((existing & pieces) == pieces) {
/* We only want to set the (dis)allowed road directions */
- if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && GetRoadOwner(tile, ROADTYPE_ROAD) == _current_player) {
+ if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && IsRoadOwner(tile, ROADTYPE_ROAD, _current_player)) {
if (crossing) return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION);
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
@@ -593,7 +594,7 @@
CommandCost ret = CheckRoadSlope(tileh, &pieces, existing, other_bits);
/* Return an error if we need to build a foundation (ret != 0) but the
* current patch-setting is turned off (or stupid AI@work) */
- if (CmdFailed(ret) || (ret.GetCost() != 0 && !_patches.build_on_slopes)) {
+ if (CmdFailed(ret) || (ret.GetCost() != 0 && !_settings.construction.build_on_slopes)) {
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
}
cost.AddCost(ret);
@@ -659,6 +660,7 @@
case MP_STATION:
SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
+ if (IsDriveThroughStopTile(tile) && rt == ROADTYPE_ROAD) SetStopBuiltOnTownRoad(tile, false);
break;
default:
@@ -847,7 +849,7 @@
Slope tileh = GetTileSlope(tile, NULL);
if (tileh != SLOPE_FLAT && (
- !_patches.build_on_slopes ||
+ !_settings.construction.build_on_slopes ||
IsSteepSlope(tileh) ||
!CanBuildDepotByTileh(dir, tileh)
)) {
@@ -893,8 +895,7 @@
/* Clear the road if only one piece is on the tile OR the AI tries
* to clear town road OR we are not using the DC_AUTO flag */
- if ((CountBits(b) == 1 && GetRoadBits(tile, ROADTYPE_TRAM) == ROAD_NONE) || !(flags & DC_AUTO)
- ) {
+ if ((CountBits(b) == 1 && GetRoadBits(tile, ROADTYPE_TRAM) == ROAD_NONE) || !(flags & DC_AUTO)) {
RoadTypes rts = GetRoadTypes(tile);
CommandCost ret(EXPENSES_CONSTRUCTION);
for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
@@ -996,7 +997,7 @@
static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside)
{
return (IsOnSnow(tile) &&
- !(_opt.landscape == LT_TROPIC && HasGrfMiscBit(GMB_DESERT_PAVED_ROADS) &&
+ !(_settings.game_creation.landscape == LT_TROPIC && HasGrfMiscBit(GMB_DESERT_PAVED_ROADS) &&
roadside != ROADSIDE_BARREN && roadside != ROADSIDE_GRASS && roadside != ROADSIDE_GRASS_ROAD_WORKS));
}
@@ -1287,7 +1288,7 @@
static void TileLoop_Road(TileIndex tile)
{
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_ARCTIC:
if (IsOnSnow(tile) != (GetTileZ(tile) > GetSnowLine())) {
ToggleSnow(tile);
@@ -1333,7 +1334,7 @@
{
/* Adjust road ground type depending on 'grp' (grp is the distance to the center) */
- const Roadside* new_rs = (_opt.landscape == LT_TOYLAND) ? _town_road_types_2[grp] : _town_road_types[grp];
+ const Roadside* new_rs = (_settings.game_creation.landscape == LT_TOYLAND) ? _town_road_types_2[grp] : _town_road_types[grp];
Roadside cur_rs = GetRoadside(tile);
/* We have our desired type, do nothing */
@@ -1355,7 +1356,7 @@
} else if (IncreaseRoadWorksCounter(tile)) {
TerminateRoadWorks(tile);
- if (_patches.mod_road_rebuild) {
+ if (_settings.economy.mod_road_rebuild) {
/* Generate a nicer town surface */
const RoadBits old_rb = GetAnyRoadBits(tile, ROADTYPE_ROAD);
const RoadBits new_rb = CleanUpRoadBits(tile, old_rb);
@@ -1444,11 +1445,53 @@
static void GetTileDesc_Road(TileIndex tile, TileDesc *td)
{
- td->owner = GetTileOwner(tile);
+ Owner rail_owner = INVALID_OWNER;
+ Owner road_owner = INVALID_OWNER;
+ Owner tram_owner = INVALID_OWNER;
+
switch (GetRoadTileType(tile)) {
- case ROAD_TILE_CROSSING: td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING; break;
- case ROAD_TILE_DEPOT: td->str = STR_1817_ROAD_VEHICLE_DEPOT; break;
- default: td->str = _road_tile_strings[GetRoadside(tile)]; break;
+ case ROAD_TILE_CROSSING: {
+ td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING;
+ RoadTypes rts = GetRoadTypes(tile);
+ rail_owner = GetTileOwner(tile);
+ if (HasBit(rts, ROADTYPE_ROAD)) road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
+ if (HasBit(rts, ROADTYPE_TRAM)) tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM);
+ break;
+ }
+
+ case ROAD_TILE_DEPOT:
+ td->str = STR_1817_ROAD_VEHICLE_DEPOT;
+ road_owner = GetTileOwner(tile); // Tile has only one owner, roadtype does not matter
+ break;
+
+ default: {
+ RoadTypes rts = GetRoadTypes(tile);
+ td->str = (HasBit(rts, ROADTYPE_ROAD) ? _road_tile_strings[GetRoadside(tile)] : STR_TRAMWAY);
+ if (HasBit(rts, ROADTYPE_ROAD)) road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
+ if (HasBit(rts, ROADTYPE_TRAM)) tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM);
+ break;
+ }
+ }
+
+ /* Now we have to discover, if the tile has only one owner or many:
+ * - Find a first_owner of the tile. (Currently road or tram must be present, but this will break when the third type becomes available)
+ * - Compare the found owner with the other owners, and test if they differ.
+ * Note: If road exists it will be the first_owner.
+ */
+ Owner first_owner = (road_owner == INVALID_OWNER ? tram_owner : road_owner);
+ bool mixed_owners = (tram_owner != INVALID_OWNER && tram_owner != first_owner) || (rail_owner != INVALID_OWNER && rail_owner != first_owner);
+
+ if (mixed_owners) {
+ /* Multiple owners */
+ td->owner_type[0] = (rail_owner == INVALID_OWNER ? STR_NULL : STR_RAIL_OWNER);
+ td->owner[0] = rail_owner;
+ td->owner_type[1] = (road_owner == INVALID_OWNER ? STR_NULL : STR_ROAD_OWNER);
+ td->owner[1] = road_owner;
+ td->owner_type[2] = (tram_owner == INVALID_OWNER ? STR_NULL : STR_TRAM_OWNER);
+ td->owner[2] = tram_owner;
+ } else {
+ /* One to rule them all */
+ td->owner[0] = first_owner;
}
}
@@ -1505,9 +1548,7 @@
}
for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
- /* ROADTYPE_ROAD denotes the tile owner, so update it too */
- if (rt != ROADTYPE_ROAD && !HasTileRoadType(tile, rt)) continue;
-
+ /* Update all roadtypes, no matter if they are present */
if (GetRoadOwner(tile, rt) == old_player) {
SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
}
@@ -1526,7 +1567,7 @@
static CommandCost TerraformTile_Road(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
{
- if (_patches.build_on_slopes && AutoslopeEnabled()) {
+ if (_settings.construction.build_on_slopes && AutoslopeEnabled()) {
switch (GetRoadTileType(tile)) {
case ROAD_TILE_CROSSING:
if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) && HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
--- a/src/road_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/road_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -28,8 +28,8 @@
#include "table/sprites.h"
#include "table/strings.h"
-static void ShowRVStationPicker(RoadStopType rs);
-static void ShowRoadDepotPicker();
+static void ShowRVStationPicker(Window *parent, RoadStopType rs);
+static void ShowRoadDepotPicker(Window *parent);
static bool _remove_button_clicked;
static bool _one_way_button_clicked;
@@ -324,19 +324,19 @@
static void BuildRoadClick_Depot(Window *w)
{
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
- if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, VHM_RECT, PlaceRoad_Depot)) ShowRoadDepotPicker();
+ if (HandlePlacePushButton(w, RTW_DEPOT, SPR_CURSOR_ROAD_DEPOT, VHM_RECT, PlaceRoad_Depot)) ShowRoadDepotPicker(w);
}
static void BuildRoadClick_BusStation(Window *w)
{
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
- if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(ROADSTOP_BUS);
+ if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, VHM_RECT, PlaceRoad_BusStation)) ShowRVStationPicker(w, ROADSTOP_BUS);
}
static void BuildRoadClick_TruckStation(Window *w)
{
if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
- if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(ROADSTOP_TRUCK);
+ if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, VHM_RECT, PlaceRoad_TruckStation)) ShowRVStationPicker(w, ROADSTOP_TRUCK);
}
/**
@@ -409,12 +409,12 @@
WIDGET_LIST_END);
this->FindWindowPlacementAndResize(desc);
- if (_patches.link_terraform_toolbar) ShowTerraformToolbar(this);
+ if (_settings.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
}
~BuildRoadToolbarWindow()
{
- if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
+ if (_settings.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
}
/**
@@ -729,7 +729,7 @@
};
public:
- BuildRoadDepotWindow(const WindowDesc *desc) : PickerWindowBase(desc)
+ BuildRoadDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
if ( _cur_roadtype == ROADTYPE_TRAM) {
@@ -788,9 +788,9 @@
_build_road_depot_widgets,
};
-static void ShowRoadDepotPicker()
+static void ShowRoadDepotPicker(Window *parent)
{
- new BuildRoadDepotWindow(&_build_road_depot_desc);
+ new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
}
struct BuildRoadStationWindow : public PickerWindowBase {
@@ -812,7 +812,7 @@
};
public:
- BuildRoadStationWindow(const WindowDesc *desc, RoadStopType rs) : PickerWindowBase(desc)
+ BuildRoadStationWindow(const WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent)
{
/* Trams don't have non-drivethrough stations */
if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
@@ -839,7 +839,7 @@
this->DrawWidgets();
if (_station_show_coverage) {
- int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
+ int rad = _settings.station.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
} else {
SetTileSelectSize(1, 1);
@@ -930,9 +930,9 @@
_rv_station_picker_widgets,
};
-static void ShowRVStationPicker(RoadStopType rs)
+static void ShowRVStationPicker(Window *parent, RoadStopType rs)
{
- new BuildRoadStationWindow(&_rv_station_picker_desc, rs);
+ new BuildRoadStationWindow(&_rv_station_picker_desc, parent, rs);
}
void InitializeRoadGui()
--- a/src/road_internal.h Mon May 26 11:36:42 2008 +0000
+++ b/src/road_internal.h Mon May 26 13:52:59 2008 +0000
@@ -20,11 +20,12 @@
* @param tile the tile to remove the road from
* @param remove the roadbits that are going to be removed
* @param owner the actual owner of the roadbits of the tile
- * @param edge_road are the removed bits from a town?
* @param rt the road type to remove the bits from
+ * @param flags command flags
+ * @param town_check Shall the town rating checked/affected
* @return true when it is allowed to remove the road bits
*/
-bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt);
+bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, RoadType rt, uint32 flags, bool town_check = true);
/**
* Draw the catenary for tram road bits
--- a/src/road_map.h Mon May 26 11:36:42 2008 +0000
+++ b/src/road_map.h Mon May 26 13:52:59 2008 +0000
@@ -187,6 +187,12 @@
}
}
+static inline bool IsRoadOwner(TileIndex t, RoadType rt, Owner o)
+{
+ assert(HasTileRoadType(t, rt));
+ return (GetRoadOwner(t, rt) == o);
+}
+
/** Which directions are disallowed ? */
enum DisallowedRoadDirections {
DRD_NONE, ///< None of the directions are disallowed
--- a/src/roadveh_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/roadveh_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -206,7 +206,7 @@
/* find the first free roadveh id */
unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_ROAD);
- if (unit_num > _patches.max_roadveh)
+ if (unit_num > _settings.vehicle.max_roadveh)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) {
@@ -258,7 +258,7 @@
v->name = NULL;
- v->service_interval = _patches.servint_roadveh;
+ v->service_interval = _settings.vehicle.servint_roadveh;
v->date_of_last_service = _date;
v->build_year = _cur_year;
@@ -420,7 +420,7 @@
static const Depot* FindClosestRoadDepot(const Vehicle* v)
{
- switch (_patches.pathfinder_for_roadvehs) {
+ switch (_settings.pf.pathfinder_for_roadvehs) {
case VPF_YAPF: /* YAPF */
return YapfFindNearestRoadDepot(v);
@@ -705,7 +705,7 @@
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
- SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ?
+ SndPlayVehicleFx((_settings.game_creation.landscape != LT_TOYLAND) ?
SND_0F_VEHICLE_BREAKDOWN : SND_35_COMEDY_BREAKDOWN, v);
}
@@ -866,7 +866,7 @@
/* updates statusbar only if speed have changed to save CPU time */
if (spd != v->cur_speed) {
v->cur_speed = spd;
- if (_patches.vehicle_speed) {
+ if (_settings.gui.vehicle_speed) {
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
}
}
@@ -1088,7 +1088,7 @@
trackdirs = TRACKDIR_BIT_NONE;
} else {
/* Proper station type, check if there is free loading bay */
- if (!_patches.roadveh_queue && IsStandardRoadStopTile(tile) &&
+ if (!_settings.pf.roadveh_queue && IsStandardRoadStopTile(tile) &&
!GetRoadStopByTile(tile, rstype)->HasFreeBay()) {
/* Station is full and RV queuing is off */
trackdirs = TRACKDIR_BIT_NONE;
@@ -1127,7 +1127,7 @@
return_track(FindFirstBit2x64(trackdirs));
}
- switch (_patches.pathfinder_for_roadvehs) {
+ switch (_settings.pf.pathfinder_for_roadvehs) {
case VPF_YAPF: { /* YAPF */
Trackdir trackdir = YapfChooseRoadTrack(v, tile, enterdir);
if (trackdir != INVALID_TRACKDIR) return_track(trackdir);
@@ -1214,7 +1214,7 @@
static uint RoadFindPathToStop(const Vehicle *v, TileIndex tile)
{
- if (_patches.pathfinder_for_roadvehs == VPF_YAPF) {
+ if (_settings.pf.pathfinder_for_roadvehs == VPF_YAPF) {
/* use YAPF */
return YapfRoadVehDistanceToTile(v, tile);
}
@@ -1276,7 +1276,7 @@
v->direction = DiagDirToDir(dir);
Trackdir tdir = _roadveh_depot_exit_trackdir[dir];
- const RoadDriveEntry *rdp = _road_drive_data[v->u.road.roadtype][(_opt.road_side << RVS_DRIVE_SIDE) + tdir];
+ const RoadDriveEntry *rdp = _road_drive_data[v->u.road.roadtype][(_settings.vehicle.road_side << RVS_DRIVE_SIDE) + tdir];
int x = TileX(v->tile) * TILE_SIZE + (rdp[RVC_DEPOT_START_FRAME].x & 0xF);
int y = TileY(v->tile) * TILE_SIZE + (rdp[RVC_DEPOT_START_FRAME].y & 0xF);
@@ -1454,7 +1454,7 @@
* In this case v->u.road.state is masked to give the road stop entry direction. */
rd = _road_drive_data[v->u.road.roadtype][(
(HasBit(v->u.road.state, RVS_IN_DT_ROAD_STOP) ? v->u.road.state & RVSB_ROAD_STOP_TRACKDIR_MASK : v->u.road.state) +
- (_opt.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking][v->u.road.frame + 1];
+ (_settings.vehicle.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking][v->u.road.frame + 1];
if (rd.x & RDE_NEXT_TILE) {
TileIndex tile = v->tile + TileOffsByDiagDir((DiagDirection)(rd.x & 3));
@@ -1532,7 +1532,7 @@
}
/* Get position data for first frame on the new tile */
- rdp = _road_drive_data[v->u.road.roadtype][(dir + (_opt.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking];
+ rdp = _road_drive_data[v->u.road.roadtype][(dir + (_settings.vehicle.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking];
x = TileX(tile) * TILE_SIZE + rdp[start_frame].x;
y = TileY(tile) * TILE_SIZE + rdp[start_frame].y;
@@ -1635,7 +1635,7 @@
return false;
}
- rdp = _road_drive_data[v->u.road.roadtype][(_opt.road_side << RVS_DRIVE_SIDE) + dir];
+ rdp = _road_drive_data[v->u.road.roadtype][(_settings.vehicle.road_side << RVS_DRIVE_SIDE) + dir];
x = TileX(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].x;
y = TileY(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].y;
@@ -1714,7 +1714,7 @@
* (the station test and stop type test ensure that other vehicles, using the road stop as
* a through route, do not stop) */
if (IsRoadVehFront(v) && ((IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) &&
- _road_veh_data_1[v->u.road.state - RVSB_IN_ROAD_STOP + (_opt.road_side << RVS_DRIVE_SIDE)] == v->u.road.frame) ||
+ _road_veh_data_1[v->u.road.state - RVSB_IN_ROAD_STOP + (_settings.vehicle.road_side << RVS_DRIVE_SIDE)] == v->u.road.frame) ||
(IsInsideMM(v->u.road.state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
@@ -1890,7 +1890,7 @@
static void CheckIfRoadVehNeedsService(Vehicle *v)
{
/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
- if (v->u.road.slot != NULL || _patches.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
+ if (v->u.road.slot != NULL || _settings.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
if (v->IsInDepot()) {
VehicleServiceInDepot(v);
return;
--- a/src/saveload.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/saveload.cpp Mon May 26 13:52:59 2008 +0000
@@ -35,7 +35,7 @@
#include "table/strings.h"
-extern const uint16 SAVEGAME_VERSION = 95;
+extern const uint16 SAVEGAME_VERSION = 97;
SavegameType _savegame_type; ///< type of savegame we are loading
@@ -1776,7 +1776,7 @@
}
}
-/** Do a save when exiting the game (patch option) _patches.autosave_on_exit */
+/** Do a save when exiting the game (patch option) _settings.gui.autosave_on_exit */
void DoExitSave()
{
SaveOrLoad("exit.sav", SL_SAVE, AUTOSAVE_DIR);
--- a/src/settings.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/settings.cpp Mon May 26 13:52:59 2008 +0000
@@ -28,7 +28,7 @@
#include "network/network_internal.h"
#include "settings_internal.h"
#include "command_func.h"
-#include "console.h"
+#include "console_func.h"
#include "saveload.h"
#include "npf.h"
#include "yapf/yapf.h"
@@ -60,14 +60,12 @@
#include "sound/sound_driver.hpp"
#include "music/music_driver.hpp"
#include "blitter/factory.hpp"
+#include "station_func.h"
#include "table/strings.h"
-GameOptions _opt;
-GameOptions _opt_newgame;
-GameOptions *_opt_ptr;
-Patches _patches;
-Patches _patches_newgame;
+Settings _settings;
+Settings _settings_newgame;
struct IniFile;
struct IniItem;
@@ -332,9 +330,11 @@
if (len == 0) len = strlen(name);
/* does it exist already? */
- for (group = ini->group; group; group = group->next)
- if (!memcmp(group->name, name, len) && group->name[len] == 0)
+ for (group = ini->group; group != NULL; group = group->next) {
+ if (!memcmp(group->name, name, len) && group->name[len] == 0) {
return group;
+ }
+ }
/* otherwise make a new one */
group = ini_group_alloc(ini, name, len);
@@ -342,14 +342,37 @@
return group;
}
+static void ini_removegroup(IniFile *ini, const char *name)
+{
+ size_t len = strlen(name);
+ IniGroup *prev = NULL;
+ IniGroup *group;
+
+ /* does it exist already? */
+ for (group = ini->group; group != NULL; prev = group, group = group->next) {
+ if (memcmp(group->name, name, len) == 0) {
+ break;
+ }
+ }
+
+ if (group == NULL) return;
+
+ if (prev != NULL) {
+ prev->next = prev->next->next;
+ } else {
+ ini->group = ini->group->next;
+ }
+}
+
/** lookup an item or make a new one */
static IniItem *ini_getitem(IniGroup *group, const char *name, bool create)
{
IniItem *item;
size_t len = strlen(name);
- for (item = group->item; item; item = item->next)
+ for (item = group->item; item != NULL; item = item->next) {
if (strcmp(item->name, name) == 0) return item;
+ }
if (!create) return NULL;
@@ -719,7 +742,7 @@
if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
- /* XXX - wtf is this?? (group override?) */
+ /* For patches.xx.yy load the settings from [xx] yy = ? */
s = strchr(sdb->name, '.');
if (s != NULL) {
group = ini_getgroup(ini, sdb->name, s - sdb->name);
@@ -730,8 +753,20 @@
}
item = ini_getitem(group, s, false);
+ if (item == NULL && group != group_def) {
+ /* For patches.xx.yy load the settings from [patches] yy = ? in case the previous
+ * did not exist (e.g. loading old config files with a [patches] section */
+ item = ini_getitem(group_def, s, false);
+ }
+ if (item == NULL) {
+ /* For patches.xx.zz.yy load the settings from [zz] yy = ? in case the previous
+ * did not exist (e.g. loading old config files with a [yapf] section */
+ const char *sc = strchr(s, '.');
+ if (sc != NULL) item = ini_getitem(ini_getgroup(ini, s, sc - s), sc + 1, false);
+ }
+
p = (item == NULL) ? sdb->def : string_to_val(sdb, item->value);
- ptr = GetVariableAddress(object, sld);
+ ptr = GetVariableAddress(sld->global ? NULL : object, sld);
switch (sdb->cmd) {
case SDT_BOOLX: /* All four are various types of (integer) numbers */
@@ -759,8 +794,11 @@
break;
case SDT_INTLIST: {
- if (!load_intlist((const char*)p, ptr, sld->length, GetVarMemType(sld->conv)))
+ if (!load_intlist((const char*)p, ptr, sld->length, GetVarMemType(sld->conv))) {
ShowInfoF("ini: error in array '%s'", sdb->name);
+ } else if (sd->desc.proc_cnvt != NULL) {
+ sd->desc.proc_cnvt((const char*)p);
+ }
break;
}
default: NOT_REACHED(); break;
@@ -1055,8 +1093,8 @@
SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, 0, NULL, str, proc, NULL, from, to)
#define SDT_LIST(base, var, type, flags, guiflags, def, str, proc)\
SDT_CONDLIST(base, var, type, 0, SL_MAX_VERSION, flags, guiflags, def, str, proc)
-#define SDT_CONDLISTO(base, var, length, type, from, to, flags, guiflags, def, str, proc)\
- SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, length, def, 0, 0, 0, NULL, str, proc, NULL, from, to)
+#define SDT_CONDLISTO(base, var, length, type, from, to, flags, guiflags, def, str, proc, load)\
+ SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, length, def, 0, 0, 0, NULL, str, proc, load, from, to)
#define SDT_CONDSTR(base, var, type, from, to, flags, guiflags, def, str, proc)\
SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, 0, NULL, str, proc, NULL, from, to)
@@ -1097,6 +1135,7 @@
#define NO SGF_NETWORK_ONLY
#define CR SGF_CURRENCY
#define NN SGF_NO_NETWORK
+#define NG SGF_NEWGAME_ONLY
/* Begin - Callback Functions for the various settings */
/* virtual PositionMainToolbar function, calls the right one.*/
@@ -1155,6 +1194,12 @@
return 0;
}
+static int32 InvalidateTownViewWindow(int32 p1)
+{
+ InvalidateWindowClassesData(WC_TOWN_VIEW, p1);
+ return 0;
+}
+
static int32 UpdateConsists(int32 p1)
{
Vehicle *v;
@@ -1169,7 +1214,7 @@
static int32 CheckInterval(int32 p1)
{
bool warning;
- const Patches *ptc = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
+ const VehicleSettings *ptc = (_game_mode == GM_MENU) ? &_settings_newgame.vehicle : &_settings.vehicle;
if (p1) {
warning = ( (IsInsideMM(ptc->servint_trains, 5, 90 + 1) || ptc->servint_trains == 0) &&
@@ -1191,19 +1236,19 @@
static int32 EngineRenewUpdate(int32 p1)
{
- DoCommandP(0, 0, _patches.autorenew, NULL, CMD_SET_AUTOREPLACE);
+ DoCommandP(0, 0, _settings.gui.autorenew, NULL, CMD_SET_AUTOREPLACE);
return 0;
}
static int32 EngineRenewMonthsUpdate(int32 p1)
{
- DoCommandP(0, 1, _patches.autorenew_months, NULL, CMD_SET_AUTOREPLACE);
+ DoCommandP(0, 1, _settings.gui.autorenew_months, NULL, CMD_SET_AUTOREPLACE);
return 0;
}
static int32 EngineRenewMoneyUpdate(int32 p1)
{
- DoCommandP(0, 2, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
+ DoCommandP(0, 2, _settings.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
return 0;
}
@@ -1225,6 +1270,92 @@
return 0;
}
+/*
+ * A: competitors
+ * B: start time in months / 3
+ * C: town count (3 = high, 0 = very low)
+ * D: industry count (4 = high, 0 = none)
+ * E: inital loan (in GBP)
+ * F: interest rate
+ * G: running costs (0 = low, 2 = high)
+ * H: construction speed of competitors (0 = very slow, 4 = very fast)
+ * I: intelligence (0-2)
+ * J: breakdowns (0 = off, 2 = normal)
+ * K: subsidy multiplier (0 = 1.5, 3 = 4.0)
+ * L: construction cost (0-2)
+ * M: terrain type (0 = very flat, 3 = mountainous)
+ * N: amount of water (0 = very low, 3 = high)
+ * O: economy (0 = steady, 1 = fluctuating)
+ * P: Train reversing (0 = end of line + stations, 1 = end of line)
+ * Q: disasters
+ * R: area restructuring (0 = permissive, 2 = hostile)
+ * S: the difficulty level
+ */
+static const DifficultySettings _default_game_diff[3] = { /*
+ A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S*/
+ {2, 2, 2, 4, 300000, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0}, ///< easy
+ {4, 1, 2, 3, 150000, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1}, ///< medium
+ {7, 0, 3, 3, 100000, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2, 2}, ///< hard
+};
+
+void SetDifficultyLevel(int mode, DifficultySettings *gm_opt)
+{
+ assert(mode <= 3);
+
+ if (mode != 3) {
+ *gm_opt = _default_game_diff[mode];
+ } else {
+ gm_opt->diff_level = 3;
+ }
+}
+
+/**
+ * Checks the difficulty levels read from the configuration and
+ * forces them to be correct when invalid.
+ */
+void CheckDifficultyLevels()
+{
+ if (_settings_newgame.difficulty.diff_level != 3) {
+ SetDifficultyLevel(_settings_newgame.difficulty.diff_level, &_settings_newgame.difficulty);
+ }
+}
+
+static int32 DifficultyReset(int32 level)
+{
+ SetDifficultyLevel(level, (_game_mode == GM_MENU) ? &_settings_newgame.difficulty : &_settings.difficulty);
+ return 0;
+}
+
+static int32 DifficultyChange(int32)
+{
+ if (_game_mode == GM_MENU) {
+ _settings_newgame.difficulty.diff_level = 3;
+ } else {
+ _settings.difficulty.diff_level = 3;
+ }
+
+ /* If we are a network-client, update the difficult setting (if it is open).
+ * Use this instead of just dirtying the window because we need to load in
+ * the new difficulty settings */
+ if (_networking && FindWindowById(WC_GAME_OPTIONS, 0) != NULL) {
+ ShowGameDifficulty();
+ }
+
+ return 0;
+}
+
+static int32 DifficultyNoiseChange(int32 i)
+{
+ if (_game_mode == GM_NORMAL) {
+ UpdateAirportsNoise();
+ if (_settings.economy.station_noise_level) {
+ InvalidateWindowClassesData(WC_TOWN_VIEW, 0);
+ }
+ }
+
+ return DifficultyChange(i);
+}
+
/**
* Check for right TownLayout usage in editor mode.
* The No Road mode is not desirable since towns have to be
@@ -1235,9 +1366,9 @@
*/
static int32 CheckTownLayout(int32 p1)
{
- if (_patches.town_layout == TL_NO_ROADS && _game_mode == GM_EDITOR) {
+ if (_settings.economy.town_layout == TL_NO_ROADS && _game_mode == GM_EDITOR) {
ShowErrorMessage(INVALID_STRING_ID, STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID, 0, 0);
- _patches.town_layout = TL_ORIGINAL;
+ _settings.economy.town_layout = TL_ORIGINAL;
}
return 0;
}
@@ -1254,6 +1385,21 @@
return lookup_oneofmany("normal|hilly|desert|candy", value);
}
+/**
+ * Check for decent values been supplied by the user for the noise tolerance setting.
+ * The primary idea is to avoid division by zero in game mode.
+ * The secondary idea is to make it so the values will be somewhat sane and that towns will
+ * not be overcrowed with airports. It would be easy to abuse such a feature
+ * So basically, 200, 400, 800 are the lowest allowed values */
+static int32 CheckNoiseToleranceLevel(const char *value)
+{
+ Settings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
+ for (uint16 i = 0; i < lengthof(s->economy.town_noise_population); i++) {
+ s->economy.town_noise_population[i] = max(uint16(200 * (i + 1)), s->economy.town_noise_population[i]);
+ }
+ return 0;
+}
+
/* End - Callback Functions */
#ifndef EXTERNAL_PLAYER
@@ -1353,6 +1499,9 @@
};
#endif /* ENABLE_NETWORK */
+static const uint GAME_DIFFICULTY_NUM = 18;
+uint16 _old_diff_custom[GAME_DIFFICULTY_NUM];
+
static const SettingDesc _gameopt_settings[] = {
/* In version 4 a new difficulty setting has been added to the difficulty settings,
* town attitude towards demolishing. Needs special handling because some dimwit thought
@@ -1363,18 +1512,19 @@
* and why not byte for example?
* 'SLE_FILE_I16 | SLE_VAR_U16' in "diff_custom" is needed to get around SlArray() hack
* for savegames version 0 - though it is an array, it has to go through the byteswap process */
- SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_FILE_I16 | SLE_VAR_U16, 0, 0, GameOptions, diff, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 0, 3),
- SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_UINT16, 0, 0, GameOptions, diff, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 4, SL_MAX_VERSION),
- SDT_VAR(GameOptions, diff_level, SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL),
- SDT_OMANY(GameOptions, currency, SLE_UINT8, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
- SDT_OMANY(GameOptions, units, SLE_UINT8, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
+ SDTG_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_FILE_I16 | SLE_VAR_U16, C, 0, _old_diff_custom, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, 0, 3),
+ SDTG_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_UINT16, C, 0, _old_diff_custom, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, 4, 96),
+
+ SDT_VAR(Settings, difficulty.diff_level, SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL),
+ SDT_OMANY(Settings, gui.currency, SLE_UINT8, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
+ SDT_OMANY(Settings, gui.units, SLE_UINT8, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
/* There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. */
- SDT_OMANY(GameOptions, town_name, SLE_UINT8, 0, 0, 0, 255, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
- SDT_OMANY(GameOptions, landscape, SLE_UINT8, 0, 0, 0, 3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
- SDT_VAR(GameOptions, snow_line, SLE_UINT8, 0, 0, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
- SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8, 0, 22, N, 0, 0, 0, "", STR_NULL, NULL, NULL),
- SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8,23, SL_MAX_VERSION, S, 0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL, NULL, NULL),
- SDT_OMANY(GameOptions, road_side, SLE_UINT8, 0, 0, 1, 1, "left|right", STR_NULL, NULL, NULL),
+ SDT_OMANY(Settings, game_creation.town_name, SLE_UINT8, 0, 0, 0, 255, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
+ SDT_OMANY(Settings, game_creation.landscape, SLE_UINT8, 0, 0, 0, 3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
+ SDT_VAR(Settings, game_creation.snow_line, SLE_UINT8, 0, 0, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
+ SDT_CONDOMANY(Settings, gui.autosave, SLE_UINT8, 0, 22, N, 0, 0, 0, "", STR_NULL, NULL, NULL),
+ SDT_CONDOMANY(Settings, gui.autosave, SLE_UINT8, 23, SL_MAX_VERSION, S, 0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL, NULL, NULL),
+ SDT_OMANY(Settings, vehicle.road_side, SLE_UINT8, 0, 0, 1, 1, "left|right", STR_NULL, NULL, NULL),
SDT_END()
};
@@ -1389,244 +1539,218 @@
* service depot, causing desyncs on a massive scale. */
const SettingDesc _patch_settings[] = {
/***************************************************************************/
- /* User-interface section of the GUI-configure patches window */
- SDT_BOOL(Patches, vehicle_speed, S, 0, true, STR_CONFIG_PATCHES_VEHICLESPEED, NULL),
- SDT_BOOL(Patches, status_long_date, S, 0, true, STR_CONFIG_PATCHES_LONGDATE, NULL),
- SDT_BOOL(Patches, show_finances, S, 0, true, STR_CONFIG_PATCHES_SHOWFINANCES, NULL),
- SDT_BOOL(Patches, autoscroll, S, 0, false, STR_CONFIG_PATCHES_AUTOSCROLL, NULL),
- SDT_BOOL(Patches, reverse_scroll, S, 0, false, STR_CONFIG_PATCHES_REVERSE_SCROLLING, NULL),
- SDT_BOOL(Patches, smooth_scroll, S, 0, false, STR_CONFIG_PATCHES_SMOOTH_SCROLLING, NULL),
- SDT_BOOL(Patches, measure_tooltip, S, 0, false, STR_CONFIG_PATCHES_MEASURE_TOOLTIP, NULL),
- SDT_VAR(Patches, errmsg_duration, SLE_UINT8, S, 0, 5, 0, 20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION, NULL),
- SDT_VAR(Patches, toolbar_pos, SLE_UINT8, S,MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS, v_PositionMainToolbar),
- SDT_VAR(Patches, window_snap_radius, SLE_UINT8, S,D0, 10, 1, 32, 0, STR_CONFIG_PATCHES_SNAP_RADIUS, NULL),
- SDT_BOOL(Patches, population_in_label, S, 0, true, STR_CONFIG_PATCHES_POPULATION_IN_LABEL, PopulationInLabelActive),
- SDT_VAR(Patches, map_x, SLE_UINT8, S, 0, 8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_X, NULL),
- SDT_VAR(Patches, map_y, SLE_UINT8, S, 0, 8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_Y, NULL),
- SDT_BOOL(Patches, link_terraform_toolbar, S, 0, false, STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR,NULL),
- SDT_VAR(Patches, liveries, SLE_UINT8, S,MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_LIVERIES, RedrawScreen),
- SDT_BOOL(Patches, prefer_teamchat, S, 0, false, STR_CONFIG_PATCHES_PREFER_TEAMCHAT, NULL),
- SDT_VAR(Patches, scrollwheel_scrolling,SLE_UINT8,S,MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING, NULL),
- SDT_VAR(Patches,scrollwheel_multiplier,SLE_UINT8,S, 0, 5, 1, 15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,NULL),
- SDT_BOOL(Patches, pause_on_newgame, S, 0, false, STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME, NULL),
- SDT_VAR(Patches,advanced_vehicle_list,SLE_UINT8,S,MS, 1, 0, 2, 0, STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS,NULL),
- SDT_BOOL(Patches, timetable_in_ticks, S, 0, false, STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS, NULL),
- SDT_VAR(Patches, loading_indicators, SLE_UINT8, S,MS, 1, 0, 2, 0, STR_CONFIG_PATCHES_LOADING_INDICATORS, RedrawScreen),
- SDT_VAR(Patches, default_rail_type, SLE_UINT8, S,MS, 4, 0, 6, 0, STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE, NULL),
-
- /***************************************************************************/
- /* Construction section of the GUI-configure patches window */
- SDT_BOOL(Patches, build_on_slopes, 0,NN, true, STR_CONFIG_PATCHES_BUILDONSLOPES, NULL),
- SDT_CONDBOOL(Patches, autoslope, 75, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_AUTOSLOPE, NULL),
- SDT_BOOL(Patches, extra_dynamite, 0, 0, false, STR_CONFIG_PATCHES_EXTRADYNAMITE, NULL),
- SDT_BOOL(Patches, longbridges, 0,NN, true, STR_CONFIG_PATCHES_LONGBRIDGES, NULL),
- SDT_BOOL(Patches, signal_side, N,NN, true, STR_CONFIG_PATCHES_SIGNALSIDE, RedrawScreen),
- SDT_BOOL(Patches, always_small_airport, 0,NN, false, STR_CONFIG_PATCHES_SMALL_AIRPORTS, NULL),
- SDT_BOOL(Patches, enable_signal_gui, S, 0, false, STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI, CloseSignalGUI),
- SDT_VAR(Patches, drag_signals_density,SLE_UINT8,S, 0, 4, 1, 20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,DragSignalsDensityChanged),
- SDT_VAR(Patches, semaphore_build_before,SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, ResetSignalVariant),
- SDT_CONDVAR(Patches, town_layout, SLE_UINT8, 59, SL_MAX_VERSION, 0, MS, TL_ORIGINAL, TL_NO_ROADS, NUM_TLS - 1, 1, STR_CONFIG_PATCHES_TOWN_LAYOUT, CheckTownLayout),
-
- /***************************************************************************/
- /* Vehicle section of the GUI-configure patches window */
- SDT_BOOL(Patches, realistic_acceleration, 0, 0, false, STR_CONFIG_PATCHES_REALISTICACCEL, RealisticAccelerationChanged),
- SDT_BOOL(Patches, forbid_90_deg, 0, 0, false, STR_CONFIG_PATCHES_FORBID_90_DEG, NULL),
- SDT_BOOL(Patches, mammoth_trains, 0,NN, true, STR_CONFIG_PATCHES_MAMMOTHTRAINS, NULL),
- SDT_BOOL(Patches, gotodepot, 0, 0, true, STR_CONFIG_PATCHES_GOTODEPOT, NULL),
- SDT_BOOL(Patches, roadveh_queue, 0, 0, true, STR_CONFIG_PATCHES_ROADVEH_QUEUE, NULL),
-
- SDT_CONDBOOL(Patches, new_pathfinding_all, 0,86, 0, 0, false, STR_NULL, NULL),
- SDT_CONDBOOL(Patches, yapf.ship_use_yapf, 28,86, 0, 0, false, STR_NULL, NULL),
- SDT_CONDBOOL(Patches, yapf.road_use_yapf, 28,86, 0, 0, true, STR_NULL, NULL),
- SDT_CONDBOOL(Patches, yapf.rail_use_yapf, 28,86, 0, 0, true, STR_NULL, NULL),
-
- SDT_CONDVAR(Patches, pathfinder_for_trains, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS, NULL),
- SDT_CONDVAR(Patches, pathfinder_for_roadvehs, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH, NULL),
- SDT_CONDVAR(Patches, pathfinder_for_ships, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS, NULL),
+ /* Saved patch variables. */
+ /* Do not ADD or REMOVE something in this "difficulty.XXX" table or before it. It breaks savegame compatability. */
+ SDT_CONDVAR(Settings, difficulty.max_no_competitors, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2, 0, 7, 1, STR_NULL, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.competitor_start_time, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 0, 3, 1, STR_6830_IMMEDIATE, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.number_towns, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 0, 3, 1, STR_NUM_VERY_LOW, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.number_industries, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 4, 0, 4, 1, STR_NONE, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.max_loan, SLE_UINT32, 97, SL_MAX_VERSION, 0,NG|CR,300000,100000,500000,50000,STR_NULL, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.initial_interest, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 2, 4, 1, STR_NULL, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.vehicle_costs, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 2, 1, STR_6820_LOW, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.competitor_speed, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2, 0, 4, 1, STR_681B_VERY_SLOW, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.competitor_intelligence, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 2, 1, STR_6820_LOW, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.vehicle_breakdowns, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 1, 0, 2, 1, STR_6823_NONE, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.subsidy_multiplier, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2, 0, 3, 1, STR_6826_X1_5, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.construction_cost, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 0, 0, 2, 1, STR_6820_LOW, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.terrain_type, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 1, 0, 3, 1, STR_682A_VERY_FLAT, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.quantity_sea_lakes, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 0, 0, 3, 1, STR_VERY_LOW, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.economy, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 1, 1, STR_682E_STEADY, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.line_reverse_mode, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 1, 1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.disasters, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 1, 1, STR_6836_OFF, DifficultyChange),
+ SDT_CONDVAR(Settings, difficulty.town_council_tolerance, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 2, 1, STR_PERMISSIVE, DifficultyNoiseChange),
+ SDT_CONDVAR(Settings, difficulty.diff_level, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 0, 0, 3, 0, STR_NULL, DifficultyReset),
- SDT_BOOL(Patches, train_income_warn, S, 0, true, STR_CONFIG_PATCHES_WARN_INCOME_LESS, NULL),
- SDT_VAR(Patches, order_review_system,SLE_UINT8, S,MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_ORDER_REVIEW, NULL),
- SDT_BOOL(Patches, never_expire_vehicles, 0,NN, false, STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES,NULL),
- SDT_BOOL(Patches, lost_train_warn, S, 0, true, STR_CONFIG_PATCHES_WARN_LOST_TRAIN, NULL),
- SDT_BOOL(Patches, autorenew, S, 0, false, STR_CONFIG_PATCHES_AUTORENEW_VEHICLE, EngineRenewUpdate),
- SDT_VAR(Patches, autorenew_months, SLE_INT16, S, 0, 6, -12, 12, 0, STR_CONFIG_PATCHES_AUTORENEW_MONTHS, EngineRenewMonthsUpdate),
- SDT_VAR(Patches, autorenew_money, SLE_UINT, S,CR,100000, 0, 2000000, 0, STR_CONFIG_PATCHES_AUTORENEW_MONEY, EngineRenewMoneyUpdate),
- SDT_BOOL(Patches, always_build_infrastructure, S, 0, false, STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE, RedrawScreen),
- SDT_VAR(Patches, max_trains, SLE_UINT16, 0, 0, 500, 0, 5000, 0, STR_CONFIG_PATCHES_MAX_TRAINS, RedrawScreen),
- SDT_VAR(Patches, max_roadveh, SLE_UINT16, 0, 0, 500, 0, 5000, 0, STR_CONFIG_PATCHES_MAX_ROADVEH, RedrawScreen),
- SDT_VAR(Patches, max_aircraft, SLE_UINT16, 0, 0, 200, 0, 5000, 0, STR_CONFIG_PATCHES_MAX_AIRCRAFT, RedrawScreen),
- SDT_VAR(Patches, max_ships, SLE_UINT16, 0, 0, 300, 0, 5000, 0, STR_CONFIG_PATCHES_MAX_SHIPS, RedrawScreen),
- SDT_BOOL(Patches, servint_ispercent, 0, 0, false, STR_CONFIG_PATCHES_SERVINT_ISPERCENT, CheckInterval),
- SDT_VAR(Patches, servint_trains, SLE_UINT16, 0,D0, 150, 5, 800, 0, STR_CONFIG_PATCHES_SERVINT_TRAINS, InValidateDetailsWindow),
- SDT_VAR(Patches, servint_roadveh, SLE_UINT16, 0,D0, 150, 5, 800, 0, STR_CONFIG_PATCHES_SERVINT_ROADVEH, InValidateDetailsWindow),
- SDT_VAR(Patches, servint_ships, SLE_UINT16, 0,D0, 360, 5, 800, 0, STR_CONFIG_PATCHES_SERVINT_SHIPS, InValidateDetailsWindow),
- SDT_VAR(Patches, servint_aircraft, SLE_UINT16, 0,D0, 100, 5, 800, 0, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT, InValidateDetailsWindow),
- SDT_BOOL(Patches, no_servicing_if_no_breakdowns, 0, 0, false, STR_CONFIG_PATCHES_NOSERVICE, NULL),
- SDT_BOOL(Patches, wagon_speed_limits, 0,NN, true, STR_CONFIG_PATCHES_WAGONSPEEDLIMITS, UpdateConsists),
- SDT_CONDBOOL(Patches, disable_elrails, 38, SL_MAX_VERSION, 0, NN, false, STR_CONFIG_PATCHES_DISABLE_ELRAILS, SettingsDisableElrail),
- SDT_CONDVAR(Patches, freight_trains, SLE_UINT8, 39, SL_MAX_VERSION, 0,NN, 1, 1, 255, 1, STR_CONFIG_PATCHES_FREIGHT_TRAINS, NULL),
- SDT_CONDBOOL(Patches, timetabling, 67, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_TIMETABLE_ALLOW, NULL),
- SDT_CONDVAR(Patches, plane_speed, SLE_UINT8, 90, SL_MAX_VERSION, 0, 0, 4, 1, 4, 0, STR_CONFIG_PATCHES_PLANE_SPEED, NULL),
- SDT_CONDBOOL(Patches, dynamic_engines, 95, SL_MAX_VERSION, 0,NN, false, STR_CONFIG_PATCHES_DYNAMIC_ENGINES, NULL),
+ /* There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. */
+ SDT_CONDOMANY(Settings, game_creation.town_name, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0, 255, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
+ SDT_CONDOMANY(Settings, game_creation.landscape, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0, 3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
+ SDT_CONDVAR(Settings, game_creation.snow_line, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
+ SDT_CONDOMANY(Settings, vehicle.road_side, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 1, 1, "left|right", STR_NULL, NULL, NULL),
- /***************************************************************************/
- /* Station section of the GUI-configure patches window */
- SDT_BOOL(Patches, join_stations, 0, 0, true, STR_CONFIG_PATCHES_JOINSTATIONS, NULL),
- SDT_CONDBOOL(Patches, sg_full_load_any, 0, 92, 0, 0, true, STR_NULL, NULL),
- SDT_BOOL(Patches, improved_load, 0,NN, false, STR_CONFIG_PATCHES_IMPROVEDLOAD, NULL),
- SDT_BOOL(Patches, selectgoods, 0, 0, true, STR_CONFIG_PATCHES_SELECTGOODS, NULL),
- SDT_BOOL(Patches, new_nonstop, S, 0, false, STR_CONFIG_PATCHES_NEW_NONSTOP, NULL),
- SDT_CONDBOOL(Patches, sg_new_nonstop, 0, 92, 0, 0, false, STR_NULL, NULL),
- SDT_BOOL(Patches, nonuniform_stations, 0,NN, true, STR_CONFIG_PATCHES_NONUNIFORM_STATIONS,NULL),
- SDT_VAR(Patches, station_spread,SLE_UINT8,0, 0, 12, 4, 64, 0, STR_CONFIG_PATCHES_STATION_SPREAD, InvalidateStationBuildWindow),
- SDT_BOOL(Patches, serviceathelipad, 0, 0, true, STR_CONFIG_PATCHES_SERVICEATHELIPAD, NULL),
- SDT_BOOL(Patches, modified_catchment, 0, 0, true, STR_CONFIG_PATCHES_CATCHMENT, NULL),
- SDT_CONDBOOL(Patches, gradual_loading, 40, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_GRADUAL_LOADING, NULL),
- SDT_CONDBOOL(Patches, road_stop_on_town_road, 47, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD, NULL),
- SDT_CONDBOOL(Patches, adjacent_stations, 62, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_ADJACENT_STATIONS, NULL),
+ SDT_BOOL(Settings, construction.build_on_slopes, 0,NN, true, STR_CONFIG_PATCHES_BUILDONSLOPES, NULL),
+ SDT_CONDBOOL(Settings, construction.autoslope, 75, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_AUTOSLOPE, NULL),
+ SDT_BOOL(Settings, construction.extra_dynamite, 0, 0, false, STR_CONFIG_PATCHES_EXTRADYNAMITE, NULL),
+ SDT_BOOL(Settings, construction.longbridges, 0,NN, true, STR_CONFIG_PATCHES_LONGBRIDGES, NULL),
+ SDT_BOOL(Settings, construction.signal_side, N,NN, true, STR_CONFIG_PATCHES_SIGNALSIDE, RedrawScreen),
+ SDT_BOOL(Settings, station.always_small_airport, 0,NN, false, STR_CONFIG_PATCHES_SMALL_AIRPORTS, NULL),
+ SDT_CONDVAR(Settings, economy.town_layout, SLE_UINT8, 59, SL_MAX_VERSION, 0,MS,TL_ORIGINAL,TL_NO_ROADS,NUM_TLS-1,1, STR_CONFIG_PATCHES_TOWN_LAYOUT, CheckTownLayout),
- /***************************************************************************/
- /* Economy section of the GUI-configure patches window */
- SDT_BOOL(Patches, inflation, 0, 0, true, STR_CONFIG_PATCHES_INFLATION, NULL),
- SDT_VAR(Patches, raw_industry_construction,SLE_UINT8,0,MS,0,0, 2, 0, STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD, InvalidateBuildIndustryWindow),
- SDT_BOOL(Patches, multiple_industry_per_town, 0, 0, false, STR_CONFIG_PATCHES_MULTIPINDTOWN, NULL),
- SDT_BOOL(Patches, same_industry_close, 0, 0, false, STR_CONFIG_PATCHES_SAMEINDCLOSE, NULL),
- SDT_BOOL(Patches, bribe, 0, 0, true, STR_CONFIG_PATCHES_BRIBE, NULL),
- SDT_CONDBOOL(Patches, exclusive_rights, 79, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE, NULL),
- SDT_CONDBOOL(Patches, give_money, 79, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY, NULL),
- SDT_VAR(Patches, snow_line_height,SLE_UINT8, 0, 0, 7, 2, 13, 0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT, NULL),
- SDT_VAR(Patches, colored_news_year,SLE_INT32, 0,NC, 2000, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL),
- SDT_VAR(Patches, starting_year, SLE_INT32, 0,NC, 1950, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
- SDT_VAR(Patches, ending_year, SLE_INT32,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_ENDING_YEAR, NULL),
- SDT_BOOL(Patches, smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL),
- SDT_BOOL(Patches, allow_shares, 0, 0, false, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL),
- SDT_CONDVAR(Patches, town_growth_rate, SLE_UINT8, 54, SL_MAX_VERSION, 0, MS, 2, 0, 4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH, NULL),
- SDT_CONDVAR(Patches, larger_towns, SLE_UINT8, 54, SL_MAX_VERSION, 0, D0, 4, 0, 255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS, NULL),
- SDT_CONDVAR(Patches, initial_city_size, SLE_UINT8, 56, SL_MAX_VERSION, 0, 0, 2, 1, 10, 1, STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER, NULL),
- SDT_CONDBOOL(Patches, mod_road_rebuild, 77, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_MODIFIED_ROAD_REBUILD, NULL),
+ SDT_BOOL(Settings, vehicle.realistic_acceleration, 0, 0, false, STR_CONFIG_PATCHES_REALISTICACCEL, RealisticAccelerationChanged),
+ SDT_BOOL(Settings, pf.forbid_90_deg, 0, 0, false, STR_CONFIG_PATCHES_FORBID_90_DEG, NULL),
+ SDT_BOOL(Settings, vehicle.mammoth_trains, 0,NN, true, STR_CONFIG_PATCHES_MAMMOTHTRAINS, NULL),
+ SDT_BOOL(Settings, order.gotodepot, 0, 0, true, STR_CONFIG_PATCHES_GOTODEPOT, NULL),
+ SDT_BOOL(Settings, pf.roadveh_queue, 0, 0, true, STR_CONFIG_PATCHES_ROADVEH_QUEUE, NULL),
+
+ SDT_CONDBOOL(Settings, pf.new_pathfinding_all, 0, 86, 0, 0, false, STR_NULL, NULL),
+ SDT_CONDBOOL(Settings, pf.yapf.ship_use_yapf, 28, 86, 0, 0, false, STR_NULL, NULL),
+ SDT_CONDBOOL(Settings, pf.yapf.road_use_yapf, 28, 86, 0, 0, true, STR_NULL, NULL),
+ SDT_CONDBOOL(Settings, pf.yapf.rail_use_yapf, 28, 86, 0, 0, true, STR_NULL, NULL),
+
+ SDT_CONDVAR(Settings, pf.pathfinder_for_trains, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_TRAINS, NULL),
+ SDT_CONDVAR(Settings, pf.pathfinder_for_roadvehs, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 2, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_ROADVEH, NULL),
+ SDT_CONDVAR(Settings, pf.pathfinder_for_ships, SLE_UINT8, 87, SL_MAX_VERSION, 0, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_PATHFINDER_FOR_SHIPS, NULL),
+
+ SDT_BOOL(Settings, vehicle.never_expire_vehicles, 0,NN, false, STR_CONFIG_PATCHES_NEVER_EXPIRE_VEHICLES, NULL),
+ SDT_VAR(Settings, vehicle.max_trains, SLE_UINT16, 0, 0, 500, 0, 5000, 0, STR_CONFIG_PATCHES_MAX_TRAINS, RedrawScreen),
+ SDT_VAR(Settings, vehicle.max_roadveh, SLE_UINT16, 0, 0, 500, 0, 5000, 0, STR_CONFIG_PATCHES_MAX_ROADVEH, RedrawScreen),
+ SDT_VAR(Settings, vehicle.max_aircraft, SLE_UINT16, 0, 0, 200, 0, 5000, 0, STR_CONFIG_PATCHES_MAX_AIRCRAFT, RedrawScreen),
+ SDT_VAR(Settings, vehicle.max_ships, SLE_UINT16, 0, 0, 300, 0, 5000, 0, STR_CONFIG_PATCHES_MAX_SHIPS, RedrawScreen),
+ SDT_BOOL(Settings, vehicle.servint_ispercent, 0, 0, false, STR_CONFIG_PATCHES_SERVINT_ISPERCENT, CheckInterval),
+ SDT_VAR(Settings, vehicle.servint_trains, SLE_UINT16, 0,D0, 150, 5, 800, 0, STR_CONFIG_PATCHES_SERVINT_TRAINS, InValidateDetailsWindow),
+ SDT_VAR(Settings, vehicle.servint_roadveh, SLE_UINT16, 0,D0, 150, 5, 800, 0, STR_CONFIG_PATCHES_SERVINT_ROADVEH, InValidateDetailsWindow),
+ SDT_VAR(Settings, vehicle.servint_ships, SLE_UINT16, 0,D0, 360, 5, 800, 0, STR_CONFIG_PATCHES_SERVINT_SHIPS, InValidateDetailsWindow),
+ SDT_VAR(Settings, vehicle.servint_aircraft, SLE_UINT16, 0,D0, 100, 5, 800, 0, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT, InValidateDetailsWindow),
+ SDT_BOOL(Settings, order.no_servicing_if_no_breakdowns, 0, 0, false, STR_CONFIG_PATCHES_NOSERVICE, NULL),
+ SDT_BOOL(Settings, vehicle.wagon_speed_limits, 0,NN, true, STR_CONFIG_PATCHES_WAGONSPEEDLIMITS, UpdateConsists),
+ SDT_CONDBOOL(Settings, vehicle.disable_elrails, 38, SL_MAX_VERSION, 0,NN, false, STR_CONFIG_PATCHES_DISABLE_ELRAILS, SettingsDisableElrail),
+ SDT_CONDVAR(Settings, vehicle.freight_trains, SLE_UINT8, 39, SL_MAX_VERSION, 0,NN, 1, 1, 255, 1, STR_CONFIG_PATCHES_FREIGHT_TRAINS, NULL),
+ SDT_CONDBOOL(Settings, order.timetabling, 67, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_TIMETABLE_ALLOW, NULL),
+ SDT_CONDVAR(Settings, vehicle.plane_speed, SLE_UINT8, 90, SL_MAX_VERSION, 0, 0, 4, 1, 4, 0, STR_CONFIG_PATCHES_PLANE_SPEED, NULL),
+ SDT_CONDBOOL(Settings, vehicle.dynamic_engines, 95, SL_MAX_VERSION, 0,NN, false, STR_CONFIG_PATCHES_DYNAMIC_ENGINES, NULL),
+
+ SDT_BOOL(Settings, station.join_stations, 0, 0, true, STR_CONFIG_PATCHES_JOINSTATIONS, NULL),
+ SDT_CONDBOOL(Settings, gui.sg_full_load_any, 0, 92, 0, 0 , true, STR_NULL, NULL),
+ SDT_BOOL(Settings, order.improved_load, 0,NN, true, STR_CONFIG_PATCHES_IMPROVEDLOAD, NULL),
+ SDT_BOOL(Settings, order.selectgoods, 0, 0, true, STR_CONFIG_PATCHES_SELECTGOODS, NULL),
+ SDT_CONDBOOL(Settings, gui.sg_new_nonstop, 0, 92, 0, 0, false, STR_NULL, NULL),
+ SDT_BOOL(Settings, station.nonuniform_stations, 0,NN, true, STR_CONFIG_PATCHES_NONUNIFORM_STATIONS, NULL),
+ SDT_VAR(Settings, station.station_spread, SLE_UINT8, 0, 0, 12, 4, 64, 0, STR_CONFIG_PATCHES_STATION_SPREAD, InvalidateStationBuildWindow),
+ SDT_BOOL(Settings, order.serviceathelipad, 0, 0, true, STR_CONFIG_PATCHES_SERVICEATHELIPAD, NULL),
+ SDT_BOOL(Settings, station.modified_catchment, 0, 0, true, STR_CONFIG_PATCHES_CATCHMENT, NULL),
+ SDT_CONDBOOL(Settings, order.gradual_loading, 40, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_GRADUAL_LOADING, NULL),
+ SDT_CONDBOOL(Settings, construction.road_stop_on_town_road, 47, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD, NULL),
+ SDT_CONDBOOL(Settings, station.adjacent_stations, 62, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_ADJACENT_STATIONS, NULL),
+ SDT_CONDBOOL(Settings, economy.station_noise_level, 96, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_NOISE_LEVEL, InvalidateTownViewWindow),
+
+ SDT_BOOL(Settings, economy.inflation, 0, 0, true, STR_CONFIG_PATCHES_INFLATION, NULL),
+ SDT_VAR(Settings, construction.raw_industry_construction, SLE_UINT8, 0,MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD, InvalidateBuildIndustryWindow),
+ SDT_BOOL(Settings, economy.multiple_industry_per_town, 0, 0, false, STR_CONFIG_PATCHES_MULTIPINDTOWN, NULL),
+ SDT_BOOL(Settings, economy.same_industry_close, 0, 0, false, STR_CONFIG_PATCHES_SAMEINDCLOSE, NULL),
+ SDT_BOOL(Settings, economy.bribe, 0, 0, true, STR_CONFIG_PATCHES_BRIBE, NULL),
+ SDT_CONDBOOL(Settings, economy.exclusive_rights, 79, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_ALLOW_EXCLUSIVE, NULL),
+ SDT_CONDBOOL(Settings, economy.give_money, 79, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_ALLOW_GIVE_MONEY, NULL),
+ SDT_VAR(Settings, game_creation.snow_line_height, SLE_UINT8, 0, 0, 7, 2, 13, 0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT, NULL),
+ SDT_VAR(Settings, gui.colored_news_year, SLE_INT32, 0,NC, 2000,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_PATCHES_COLORED_NEWS_YEAR, NULL),
+ SDT_VAR(Settings, game_creation.starting_year, SLE_INT32, 0,NC, 1950,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_PATCHES_STARTING_YEAR, NULL),
+ SDT_VAR(Settings, gui.ending_year, SLE_INT32, 0,NC|NO,2051,MIN_YEAR,MAX_YEAR,1,STR_CONFIG_PATCHES_ENDING_YEAR, NULL),
+ SDT_BOOL(Settings, economy.smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL),
+ SDT_BOOL(Settings, economy.allow_shares, 0, 0, false, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL),
+ SDT_CONDVAR(Settings, economy.town_growth_rate, SLE_UINT8, 54, SL_MAX_VERSION, 0, MS, 2, 0, 4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH, NULL),
+ SDT_CONDVAR(Settings, economy.larger_towns, SLE_UINT8, 54, SL_MAX_VERSION, 0, D0, 4, 0, 255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS, NULL),
+ SDT_CONDVAR(Settings, economy.initial_city_size, SLE_UINT8, 56, SL_MAX_VERSION, 0, 0, 2, 1, 10, 1, STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER, NULL),
+ SDT_CONDBOOL(Settings, economy.mod_road_rebuild, 77, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_MODIFIED_ROAD_REBUILD, NULL),
+
+ SDT_CONDNULL(1, 0, SL_NOAI_MAX_VERSION), // ai-new setting, became invalid with new AI system. Part of the NoAI 'hack' to retain savegame compatability with trunk.
+ SDT_BOOL(Settings, ai.ai_in_multiplayer, 0, 0, false, STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER, Ai_In_Multiplayer_Warning),
+ SDT_BOOL(Settings, ai.ai_disable_veh_train, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_TRAINS, NULL),
+ SDT_BOOL(Settings, ai.ai_disable_veh_roadveh, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH, NULL),
+ SDT_BOOL(Settings, ai.ai_disable_veh_aircraft, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT, NULL),
+ SDT_BOOL(Settings, ai.ai_disable_veh_ship, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS, NULL),
+
+ SDT_VAR(Settings, vehicle.extend_vehicle_life, SLE_UINT8, 0, 0, 0, 0, 100, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, economy.dist_local_authority, SLE_UINT8, 0, 0, 20, 5, 60, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.wait_oneway_signal, SLE_UINT8, 0, 0, 15, 2, 100, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.wait_twoway_signal, SLE_UINT8, 0, 0, 41, 2, 100, 0, STR_NULL, NULL),
+ SDT_CONDLISTO(Settings, economy.town_noise_population, 3, SLE_UINT16, 96, SL_MAX_VERSION, 0,D0, "800,2000,4000", STR_NULL, NULL, CheckNoiseToleranceLevel),
+
+ SDT_VAR(Settings, pf.opf.pf_maxlength, SLE_UINT16, 0, 0, 4096, 64, 65535, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.opf.pf_maxdepth, SLE_UINT8, 0, 0, 48, 4, 255, 0, STR_NULL, NULL),
+
+ SDT_VAR(Settings, pf.npf.npf_max_search_nodes, SLE_UINT, 0, 0, 10000, 500, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_rail_firstred_penalty, SLE_UINT, 0, 0, ( 10 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_rail_firstred_exit_penalty, SLE_UINT, 0, 0, (100 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_rail_lastred_penalty, SLE_UINT, 0, 0, ( 10 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_rail_station_penalty, SLE_UINT, 0, 0, ( 1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_rail_slope_penalty, SLE_UINT, 0, 0, ( 1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_rail_curve_penalty, SLE_UINT, 0, 0, 1, 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_rail_depot_reverse_penalty, SLE_UINT, 0, 0, ( 50 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_buoy_penalty, SLE_UINT, 0, 0, ( 2 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_water_curve_penalty, SLE_UINT, 0, 0, (NPF_TILE_LENGTH / 4), 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_road_curve_penalty, SLE_UINT, 0, 0, 1, 0, 100000, 0, STR_NULL, NULL),
+ SDT_VAR(Settings, pf.npf.npf_crossing_penalty, SLE_UINT, 0, 0, ( 3 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.npf.npf_road_drive_through_penalty, SLE_UINT, 47, SL_MAX_VERSION, 0, 0, ( 8 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
+
+
+ SDT_CONDBOOL(Settings, pf.yapf.disable_node_optimization, 28, SL_MAX_VERSION, 0, 0, false, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.max_search_nodes, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10000, 500, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDBOOL(Settings, pf.yapf.rail_firstred_twoway_eol, 28, SL_MAX_VERSION, 0, 0, true, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_firstred_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_firstred_exit_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 100 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_lastred_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_lastred_exit_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 100 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_station_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 30 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_slope_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 2 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_curve45_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_curve90_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 6 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_depot_reverse_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 50 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_crossing_penalty, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_look_ahead_max_signals, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10, 1, 100, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_look_ahead_signal_p0, SLE_INT, 28, SL_MAX_VERSION, 0, 0, 500, -1000000, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_look_ahead_signal_p1, SLE_INT, 28, SL_MAX_VERSION, 0, 0, -100, -1000000, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_look_ahead_signal_p2, SLE_INT, 28, SL_MAX_VERSION, 0, 0, 5, -1000000, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_longer_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_longer_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_shorter_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 40 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.rail_shorter_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.road_slope_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 2 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.road_curve_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.road_crossing_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, pf.yapf.road_stop_penalty, SLE_UINT, 47, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
+
+ SDT_CONDVAR(Settings, game_creation.land_generator, SLE_UINT8, 30, SL_MAX_VERSION, 0,MS, 1, 0, 1, 0, STR_CONFIG_PATCHES_LAND_GENERATOR, NULL),
+ SDT_CONDVAR(Settings, game_creation.oil_refinery_limit, SLE_UINT8, 30, SL_MAX_VERSION, 0, 0, 32, 12, 48, 0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE, NULL),
+ SDT_CONDVAR(Settings, game_creation.tgen_smoothness, SLE_UINT8, 30, SL_MAX_VERSION, 0,MS, 1, 0, 3, 0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN, NULL),
+ SDT_CONDVAR(Settings, game_creation.generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, UINT32_MAX, 0, STR_NULL, NULL),
+ SDT_CONDVAR(Settings, game_creation.tree_placer, SLE_UINT8, 30, SL_MAX_VERSION, 0,MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_TREE_PLACER, NULL),
+ SDT_VAR(Settings, game_creation.heightmap_rotation, SLE_UINT8, S,MS, 0, 0, 1, 0, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION, NULL),
+ SDT_VAR(Settings, game_creation.se_flat_world_height, SLE_UINT8, S, 0, 0, 0, 15, 0, STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT, NULL),
+
+ SDT_CONDOMANY(Settings, gui.currency, SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
+ SDT_CONDOMANY(Settings, gui.units, SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
/***************************************************************************/
- /* AI section of the GUI-configure patches window */
- SDT_CONDNULL(1, 0, SL_NOAI_MAX_VERSION), // ai-new setting, became invalid with new AI system. Part of the NoAI 'hack' to retain savegame compatability with trunk.
- SDT_BOOL(Patches, ai_in_multiplayer, 0, 0, false, STR_CONFIG_PATCHES_AI_IN_MULTIPLAYER, Ai_In_Multiplayer_Warning),
- SDT_BOOL(Patches, ai_disable_veh_train, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_TRAINS, NULL),
- SDT_BOOL(Patches, ai_disable_veh_roadveh, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_ROADVEH, NULL),
- SDT_BOOL(Patches, ai_disable_veh_aircraft,0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_AIRCRAFT,NULL),
- SDT_BOOL(Patches, ai_disable_veh_ship, 0, 0, false, STR_CONFIG_PATCHES_AI_BUILDS_SHIPS, NULL),
-
- /***************************************************************************/
- /* Patches without any GUI representation */
- SDT_BOOL(Patches, keep_all_autosave, S, 0, false, STR_NULL, NULL),
- SDT_BOOL(Patches, autosave_on_exit, S, 0, false, STR_NULL, NULL),
- SDT_VAR(Patches, max_num_autosaves, SLE_UINT8, S, 0, 16, 0, 255, 0, STR_NULL, NULL),
- SDT_BOOL(Patches, bridge_pillars, S, 0, true, STR_NULL, NULL),
- SDT_VAR(Patches, extend_vehicle_life, SLE_UINT8, 0, 0, 0, 0, 100, 0, STR_NULL, NULL),
- SDT_BOOL(Patches, auto_euro, S, 0, true, STR_NULL, NULL),
- SDT_VAR(Patches, dist_local_authority,SLE_UINT8, 0, 0, 20, 5, 60, 0, STR_NULL, NULL),
- SDT_VAR(Patches, wait_oneway_signal, SLE_UINT8, 0, 0, 15, 2, 100, 0, STR_NULL, NULL),
- SDT_VAR(Patches, wait_twoway_signal, SLE_UINT8, 0, 0, 41, 2, 100, 0, STR_NULL, NULL),
-
- /***************************************************************************/
- /* New Pathfinding patch settings */
- SDT_VAR(Patches, pf_maxlength, SLE_UINT16, 0, 0, 4096, 64, 65535, 0, STR_NULL, NULL),
- SDT_VAR(Patches, pf_maxdepth, SLE_UINT8, 0, 0, 48, 4, 255, 0, STR_NULL, NULL),
- /* The maximum number of nodes to search */
- SDT_VAR(Patches, npf_max_search_nodes,SLE_UINT, 0, 0, 10000, 500, 100000, 0, STR_NULL, NULL),
+ /* Unsaved patch variables. */
+ SDT_OMANY(Settings, gui.autosave, SLE_UINT8, S, 0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL, NULL, NULL),
+ SDT_BOOL(Settings, gui.vehicle_speed, S, 0, true, STR_CONFIG_PATCHES_VEHICLESPEED, NULL),
+ SDT_BOOL(Settings, gui.status_long_date, S, 0, true, STR_CONFIG_PATCHES_LONGDATE, NULL),
+ SDT_BOOL(Settings, gui.show_finances, S, 0, true, STR_CONFIG_PATCHES_SHOWFINANCES, NULL),
+ SDT_BOOL(Settings, gui.autoscroll, S, 0, false, STR_CONFIG_PATCHES_AUTOSCROLL, NULL),
+ SDT_BOOL(Settings, gui.reverse_scroll, S, 0, false, STR_CONFIG_PATCHES_REVERSE_SCROLLING, NULL),
+ SDT_BOOL(Settings, gui.smooth_scroll, S, 0, false, STR_CONFIG_PATCHES_SMOOTH_SCROLLING, NULL),
+ SDT_BOOL(Settings, gui.measure_tooltip, S, 0, false, STR_CONFIG_PATCHES_MEASURE_TOOLTIP, NULL),
+ SDT_VAR(Settings, gui.errmsg_duration, SLE_UINT8, S, 0, 5, 0, 20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION, NULL),
+ SDT_VAR(Settings, gui.toolbar_pos, SLE_UINT8, S,MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS, v_PositionMainToolbar),
+ SDT_VAR(Settings, gui.window_snap_radius, SLE_UINT8, S,D0, 10, 1, 32, 0, STR_CONFIG_PATCHES_SNAP_RADIUS, NULL),
+ SDT_BOOL(Settings, gui.population_in_label, S, 0, true, STR_CONFIG_PATCHES_POPULATION_IN_LABEL, PopulationInLabelActive),
+ SDT_BOOL(Settings, gui.link_terraform_toolbar, S, 0, false, STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR, NULL),
+ SDT_VAR(Settings, gui.liveries, SLE_UINT8, S,MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_LIVERIES, RedrawScreen),
+ SDT_BOOL(Settings, gui.prefer_teamchat, S, 0, false, STR_CONFIG_PATCHES_PREFER_TEAMCHAT, NULL),
+ SDT_VAR(Settings, gui.scrollwheel_scrolling, SLE_UINT8, S,MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING, NULL),
+ SDT_VAR(Settings, gui.scrollwheel_multiplier, SLE_UINT8, S, 0, 5, 1, 15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER, NULL),
+ SDT_BOOL(Settings, gui.pause_on_newgame, S, 0, false, STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME, NULL),
+ SDT_VAR(Settings, gui.advanced_vehicle_list, SLE_UINT8, S,MS, 1, 0, 2, 0, STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS, NULL),
+ SDT_BOOL(Settings, gui.timetable_in_ticks, S, 0, false, STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS, NULL),
+ SDT_VAR(Settings, gui.loading_indicators, SLE_UINT8, S,MS, 1, 0, 2, 0, STR_CONFIG_PATCHES_LOADING_INDICATORS, RedrawScreen),
+ SDT_VAR(Settings, gui.default_rail_type, SLE_UINT8, S,MS, 4, 0, 6, 0, STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE, NULL),
+ SDT_BOOL(Settings, gui.enable_signal_gui, S, 0, false, STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI, CloseSignalGUI),
+ SDT_VAR(Settings, gui.drag_signals_density, SLE_UINT8, S, 0, 4, 1, 20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY, DragSignalsDensityChanged),
+ SDT_VAR(Settings, gui.semaphore_build_before, SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, ResetSignalVariant),
+ SDT_BOOL(Settings, gui.train_income_warn, S, 0, true, STR_CONFIG_PATCHES_WARN_INCOME_LESS, NULL),
+ SDT_VAR(Settings, gui.order_review_system, SLE_UINT8, S,MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_ORDER_REVIEW, NULL),
+ SDT_BOOL(Settings, gui.lost_train_warn, S, 0, true, STR_CONFIG_PATCHES_WARN_LOST_TRAIN, NULL),
+ SDT_BOOL(Settings, gui.autorenew, S, 0, false, STR_CONFIG_PATCHES_AUTORENEW_VEHICLE, EngineRenewUpdate),
+ SDT_VAR(Settings, gui.autorenew_months, SLE_INT16, S, 0, 6, -12, 12, 0, STR_CONFIG_PATCHES_AUTORENEW_MONTHS, EngineRenewMonthsUpdate),
+ SDT_VAR(Settings, gui.autorenew_money, SLE_UINT, S,CR,100000, 0, 2000000, 0, STR_CONFIG_PATCHES_AUTORENEW_MONEY, EngineRenewMoneyUpdate),
+ SDT_BOOL(Settings, gui.always_build_infrastructure, S, 0, false, STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE, RedrawScreen),
+ SDT_BOOL(Settings, gui.new_nonstop, S, 0, false, STR_CONFIG_PATCHES_NEW_NONSTOP, NULL),
+ SDT_BOOL(Settings, gui.keep_all_autosave, S, 0, false, STR_NULL, NULL),
+ SDT_BOOL(Settings, gui.autosave_on_exit, S, 0, false, STR_NULL, NULL),
+ SDT_VAR(Settings, gui.max_num_autosaves, SLE_UINT8, S, 0, 16, 0, 255, 0, STR_NULL, NULL),
+ SDT_BOOL(Settings, gui.bridge_pillars, S, 0, true, STR_NULL, NULL),
+ SDT_BOOL(Settings, gui.auto_euro, S, 0, true, STR_NULL, NULL),
- /* When a red signal is encountered, a small detour can be made around
- * it. This specifically occurs when a track is doubled, in which case
- * the detour is typically 2 tiles. It is also often used at station
- * entrances, when there is a choice of multiple platforms. If we take
- * a typical 4 platform station, the detour is 4 tiles. To properly
- * support larger stations we increase this value.
- * We want to prevent that trains that want to leave at one side of a
- * station, leave through the other side, turn around, enter the
- * station on another platform and exit the station on the right side
- * again, just because the sign at the right side was red. If we take
- * a typical 5 length station, this detour is 10 or 11 tiles (not
- * sure), so we set the default penalty at 10 (the station tile
- * penalty will further prevent this.
- * We give presignal exits (and combo's) a different (larger) penalty, because
- * we really don't want trains waiting in front of a presignal exit. */
- SDT_VAR(Patches, npf_rail_firstred_penalty, SLE_UINT, 0, 0, (10 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
- SDT_VAR(Patches, npf_rail_firstred_exit_penalty,SLE_UINT, 0, 0, (100 * NPF_TILE_LENGTH),0, 100000, 0, STR_NULL, NULL),
- /* This penalty is for when the last signal before the target is red.
- * This is useful for train stations, where there are multiple
- * platforms to choose from, which lie in different signal blocks.
- * Every target in a occupied signal block (ie an occupied platform)
- * will get this penalty. */
- SDT_VAR(Patches, npf_rail_lastred_penalty, SLE_UINT, 0, 0, (10 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
- /* When a train plans a route over a station tile, this penalty is
- * applied. We want that trains plan a route around a typical, 4x5
- * station, which means two tiles to the right, and two tiles back to
- * the left around it, or 5 tiles of station through it. If we assign
- * a penalty of 1 tile for every station tile passed, the route will
- * be around it. */
- SDT_VAR(Patches, npf_rail_station_penalty, SLE_UINT, 0, 0, (1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
- SDT_VAR(Patches, npf_rail_slope_penalty, SLE_UINT, 0, 0, (1 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
- /* This penalty is applied when a train makes a turn. Its value of 1 makes
- * sure that it has a minimal impact on the pathfinding, only when two
- * paths have equal length it will make a difference */
- SDT_VAR(Patches, npf_rail_curve_penalty, SLE_UINT, 0, 0, 1, 0, 100000, 0, STR_NULL, NULL),
- /* Ths penalty is applied when a vehicle reverses inside a depot (doesn't
- * apply to ships, as they can just come out the other end). XXX: Is this a
- * good value? */
- SDT_VAR(Patches, npf_rail_depot_reverse_penalty,SLE_UINT, 0, 0, (NPF_TILE_LENGTH * 50), 0, 100000, 0, STR_NULL, NULL),
- SDT_VAR(Patches, npf_buoy_penalty, SLE_UINT, 0, 0, (2 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
- /* This penalty is applied when a ship makes a turn. It is bigger than the
- * rail curve penalty, since ships (realisticly) have more trouble with
- * making turns */
- SDT_VAR(Patches, npf_water_curve_penalty, SLE_UINT, 0, 0, (NPF_TILE_LENGTH / 4), 0, 100000, 0, STR_NULL, NULL),
- /* This is the penalty for road, same as for rail. */
- SDT_VAR(Patches, npf_road_curve_penalty, SLE_UINT, 0, 0, 1, 0, 100000, 0, STR_NULL, NULL),
- /* This is the penalty for level crossings, for both road and rail vehicles */
- SDT_VAR(Patches, npf_crossing_penalty, SLE_UINT, 0, 0, (3 * NPF_TILE_LENGTH), 0, 100000, 0, STR_NULL, NULL),
- /* This is the penalty for drive-through road, stops. */
- SDT_CONDVAR (Patches, npf_road_drive_through_penalty, SLE_UINT, 47, SL_MAX_VERSION, 0, 0, 8 * NPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
-
-
- /* The maximum number of nodes to search */
- SDT_CONDBOOL(Patches, yapf.disable_node_optimization , 28, SL_MAX_VERSION, 0, 0, false , STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.max_search_nodes , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10000 , 500, 1000000, 0, STR_NULL, NULL),
- SDT_CONDBOOL(Patches, yapf.rail_firstred_twoway_eol , 28, SL_MAX_VERSION, 0, 0, true , STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_firstred_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_firstred_exit_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 100 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_lastred_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_lastred_exit_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 100 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_station_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 30 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_slope_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 2 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_curve45_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_curve90_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 6 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- /* This penalty is applied when a train reverses inside a depot */
- SDT_CONDVAR (Patches, yapf.rail_depot_reverse_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 50 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- /* This is the penalty for level crossings (for trains only) */
- SDT_CONDVAR (Patches, yapf.rail_crossing_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- /* look-ahead how many signals are checked */
- SDT_CONDVAR (Patches, yapf.rail_look_ahead_max_signals, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10 , 1, 100, 0, STR_NULL, NULL),
- /* look-ahead n-th red signal penalty polynomial: penalty = p2 * n^2 + p1 * n + p0 */
- SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p0 , SLE_INT , 28, SL_MAX_VERSION, 0, 0, 500 , -1000000, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p1 , SLE_INT , 28, SL_MAX_VERSION, 0, 0, -100 , -1000000, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p2 , SLE_INT , 28, SL_MAX_VERSION, 0, 0, 5 , -1000000, 1000000, 0, STR_NULL, NULL),
- /* penalties for too long or too short station platforms */
- SDT_CONDVAR (Patches, yapf.rail_longer_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_longer_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_shorter_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 40 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.rail_shorter_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
- /* road vehicles - penalties */
- SDT_CONDVAR (Patches, yapf.road_slope_penalty , SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 2 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.road_curve_penalty , SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.road_crossing_penalty , SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- SDT_CONDVAR (Patches, yapf.road_stop_penalty , SLE_UINT, 47, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
-
- /***************************************************************************/
- /* Terrain genation related patch options */
- SDT_CONDVAR(Patches, land_generator, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 1, 0, STR_CONFIG_PATCHES_LAND_GENERATOR, NULL),
- SDT_CONDVAR(Patches, oil_refinery_limit, SLE_UINT8, 30, SL_MAX_VERSION, 0, 0, 32, 12, 48, 0, STR_CONFIG_PATCHES_OIL_REF_EDGE_DISTANCE, NULL),
- SDT_CONDVAR(Patches, tgen_smoothness, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 1, 0, 3, 0, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN, NULL),
- SDT_CONDVAR(Patches, generation_seed, SLE_UINT32, 30, SL_MAX_VERSION, 0, 0, GENERATE_NEW_SEED, 0, MAX_UVALUE(uint32), 0, STR_NULL, NULL),
- SDT_CONDVAR(Patches, tree_placer, SLE_UINT8, 30, SL_MAX_VERSION, 0, MS, 2, 0, 2, 0, STR_CONFIG_PATCHES_TREE_PLACER, NULL),
- SDT_VAR (Patches, heightmap_rotation, SLE_UINT8, S, MS, 0, 0, 1, 0, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION, NULL),
- SDT_VAR (Patches, se_flat_world_height, SLE_UINT8, S, 0, 0, 0, 15, 0, STR_CONFIG_PATCHES_SE_FLAT_WORLD_HEIGHT, NULL),
+ SDT_VAR(Settings, game_creation.map_x, SLE_UINT8, S, 0, 8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_X, NULL),
+ SDT_VAR(Settings, game_creation.map_y, SLE_UINT8, S, 0, 8, 6, 11, 0, STR_CONFIG_PATCHES_MAP_Y, NULL),
/*
* Since the network code (CmdChangePatchSetting and friends) use the index in this array to decide
@@ -1637,7 +1761,7 @@
#ifdef __APPLE__
/* We might need to emulate a right mouse button on mac */
- SDT_VAR(Patches,right_mouse_btn_emulation,SLE_UINT8,S,MS,0, 0, 2, 0, STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU, NULL),
+ SDT_VAR(Settings, gui.right_mouse_btn_emulation, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU, NULL),
#endif
SDT_END()
@@ -1663,6 +1787,31 @@
#undef NO
#undef CR
+static void PrepareOldDiffCustom()
+{
+ memset(_old_diff_custom, 0, sizeof(_old_diff_custom));
+}
+
+static void HandleOldDiffCustom()
+{
+ uint options_to_load = GAME_DIFFICULTY_NUM - (CheckSavegameVersion(4) ? 1 : 0);
+
+ /* If we did read to old_diff_custom, then at least one value must be non 0. */
+ bool old_diff_custom_used = false;
+ for (uint i = 0; i < options_to_load && !old_diff_custom_used; i++) {
+ old_diff_custom_used = (_old_diff_custom[i] != 0);
+ }
+
+ if (!old_diff_custom_used) return;
+
+ for (uint i = 0; i < options_to_load; i++) {
+ const SettingDesc *sd = &_patch_settings[i];
+ void *var = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings, &sd->save);
+ Write_ValidateSetting(var, sd, (int32)((i == 4 ? 1000 : 1) * _old_diff_custom[i]));
+ }
+}
+
+
static void NewsDisplayLoadConfig(IniFile *ini, const char *grpname)
{
IniGroup *group = ini_getgroup(ini, grpname);
@@ -1828,8 +1977,11 @@
proc(ini, (const SettingDesc*)_win32_settings, "win32", NULL);
#endif /* WIN32 */
- proc(ini, _gameopt_settings, "gameopt", &_opt_newgame);
- proc(ini, _patch_settings, "patches", &_patches_newgame);
+ PrepareOldDiffCustom();
+ proc(ini, _gameopt_settings, "gameopt", &_settings_newgame);
+ HandleOldDiffCustom();
+
+ proc(ini, _patch_settings, "patches", &_settings_newgame);
proc(ini, _currency_settings,"currency", &_custom_currency);
#ifdef ENABLE_NETWORK
@@ -1839,8 +1991,6 @@
#endif /* ENABLE_NETWORK */
}
-extern void CheckDifficultyLevels();
-
/** Load the values from the configuration files */
void LoadFromConfig()
{
@@ -1858,6 +2008,12 @@
void SaveToConfig()
{
IniFile *ini = ini_load(_config_file);
+
+ /* Remove some obsolete groups. These have all been loaded into other groups. */
+ ini_removegroup(ini, "patches");
+ ini_removegroup(ini, "yapf");
+ ini_removegroup(ini, "gameopt");
+
HandleSettingDescs(ini, ini_save_settings, ini_save_setting_list);
GRFSaveConfig(ini, "newgrf", _grfconfig_newgame);
GRFSaveConfig(ini, "newgrf-static", _grfconfig_static);
@@ -1890,10 +2046,11 @@
if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return CMD_ERROR;
if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return CMD_ERROR;
+ if ((sd->desc.flags & SGF_NEWGAME_ONLY) && _game_mode != GM_MENU) return CMD_ERROR;
if (flags & DC_EXEC) {
- Patches *patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
- void *var = GetVariableAddress(patches_ptr, &sd->save);
+ Settings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
+ void *var = GetVariableAddress(s, &sd->save);
Write_ValidateSetting(var, sd, (int32)p2);
if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
@@ -1910,7 +2067,7 @@
* This only affects patch-members that are not needed to be the same on all
* clients in a network game.
* @param value new value of the patch */
-bool SetPatchValue(uint index, const Patches *object, int32 value)
+bool SetPatchValue(uint index, const Settings *object, int32 value)
{
const SettingDesc *sd = &_patch_settings[index];
/* If an item is player-based, we do not send it over the network
@@ -1922,7 +2079,7 @@
Write_ValidateSetting(var, sd, value);
if (_game_mode != GM_MENU) {
- void *var2 = GetVariableAddress(&_patches_newgame, &sd->save);
+ void *var2 = GetVariableAddress(&_settings_newgame, &sd->save);
Write_ValidateSetting(var2, sd, value);
}
if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
@@ -1941,11 +2098,22 @@
{
const SettingDesc *sd;
+ /* First check all full names */
for (*i = 0, sd = _patch_settings; sd->save.cmd != SL_END; sd++, (*i)++) {
if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
if (strcmp(sd->desc.name, name) == 0) return sd;
}
+ /* Then check the shortcut variant of the name. */
+ for (*i = 0, sd = _patch_settings; sd->save.cmd != SL_END; sd++, (*i)++) {
+ if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
+ const char *short_name = strchr(sd->desc.name, '.');
+ if (short_name != NULL) {
+ short_name++;
+ if (strcmp(short_name, name) == 0) return sd;
+ }
+ }
+
return NULL;
}
@@ -1956,18 +2124,17 @@
bool success;
uint index;
const SettingDesc *sd = GetPatchFromName(name, &index);
- const Patches *patches_ptr;
void *ptr;
if (sd == NULL) {
- IConsolePrintF(_icolour_warn, "'%s' is an unknown patch setting.", name);
+ IConsolePrintF(CC_WARNING, "'%s' is an unknown patch setting.", name);
return true;
}
- patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
- ptr = GetVariableAddress(patches_ptr, &sd->save);
+ Settings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
+ ptr = GetVariableAddress(s, &sd->save);
- success = SetPatchValue(index, patches_ptr, value);
+ success = SetPatchValue(index, s, value);
return success;
}
@@ -1979,11 +2146,11 @@
const void *ptr;
if (sd == NULL) {
- IConsolePrintF(_icolour_warn, "'%s' is an unknown patch setting.", name);
+ IConsolePrintF(CC_WARNING, "'%s' is an unknown patch setting.", name);
return;
}
- ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_patches_newgame : &_patches, &sd->save);
+ ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings, &sd->save);
if (sd->desc.cmd == SDT_BOOLX) {
snprintf(value, sizeof(value), (*(bool*)ptr == 1) ? "on" : "off");
@@ -1991,27 +2158,27 @@
snprintf(value, sizeof(value), "%d", (int32)ReadValue(ptr, sd->save.conv));
}
- IConsolePrintF(_icolour_warn, "Current value for '%s' is: '%s' (min: %s%d, max: %d)",
+ IConsolePrintF(CC_WARNING, "Current value for '%s' is: '%s' (min: %s%d, max: %d)",
name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max);
}
void IConsoleListPatches()
{
- IConsolePrintF(_icolour_warn, "All patches with their current value:");
+ IConsolePrintF(CC_WARNING, "All patches with their current value:");
for (const SettingDesc *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);
+ const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_settings_newgame : &_settings, &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(CC_DEFAULT, "%s = %s", sd->desc.name, value);
}
- IConsolePrintF(_icolour_warn, "Use 'patch' command to change a value");
+ IConsolePrintF(CC_WARNING, "Use 'patch' command to change a value");
}
/** Save and load handler for patches/settings
@@ -2022,7 +2189,7 @@
{
for (; osd->save.cmd != SL_END; osd++) {
const SaveLoad *sld = &osd->save;
- void *ptr = GetVariableAddress(object, sld);
+ void *ptr = GetVariableAddress(sld->global ? NULL : object, sld);
if (!SlObjectMember(ptr, sld)) continue;
}
@@ -2072,13 +2239,9 @@
/* Copy over default setting since some might not get loaded in
* a networking environment. This ensures for example that the local
* autosave-frequency stays when joining a network-server */
- _opt = _opt_newgame;
- LoadSettings(_gameopt_settings, &_opt);
-}
-
-static void Save_OPTS()
-{
- SaveSettings(_gameopt_settings, &_opt);
+ PrepareOldDiffCustom();
+ LoadSettings(_gameopt_settings, &_settings);
+ HandleOldDiffCustom();
}
static void Load_PATS()
@@ -2086,22 +2249,21 @@
/* Copy over default setting since some might not get loaded in
* a networking environment. This ensures for example that the local
* signal_side stays when joining a network-server */
- _patches = _patches_newgame;
- LoadSettings(_patch_settings, &_patches);
+ LoadSettings(_patch_settings, &_settings);
}
static void Save_PATS()
{
- SaveSettings(_patch_settings, &_patches);
+ SaveSettings(_patch_settings, &_settings);
}
void CheckConfig()
{
// Increase old default values for pf_maxdepth and pf_maxlength
// to support big networks.
- if (_patches_newgame.pf_maxdepth == 16 && _patches_newgame.pf_maxlength == 512) {
- _patches_newgame.pf_maxdepth = 48;
- _patches_newgame.pf_maxlength = 4096;
+ if (_settings_newgame.pf.opf.pf_maxdepth == 16 && _settings_newgame.pf.opf.pf_maxlength == 512) {
+ _settings_newgame.pf.opf.pf_maxdepth = 48;
+ _settings_newgame.pf.opf.pf_maxlength = 4096;
}
}
@@ -2110,11 +2272,11 @@
/* Since old(er) savegames don't have any patches saved, we initialise
* them with the default values just as it was in the old days.
* Also new games need this copying-over */
- _patches = _patches_newgame; /* backwards compatibility */
+ _settings = _settings_newgame; /* backwards compatibility */
}
extern const ChunkHandler _setting_chunk_handlers[] = {
- { 'OPTS', Save_OPTS, Load_OPTS, CH_RIFF},
+ { 'OPTS', NULL, Load_OPTS, CH_RIFF},
{ 'PATS', Save_PATS, Load_PATS, CH_RIFF | CH_LAST},
};
--- a/src/settings_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/settings_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -142,8 +142,11 @@
static void ShowCustCurrency();
struct GameOptionsWindow : Window {
+ Settings *opt;
+
GameOptionsWindow(const WindowDesc *desc) : Window(desc)
{
+ this->opt = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
this->FindWindowPlacementAndResize(desc);
}
@@ -159,11 +162,11 @@
this->SetWidgetDisabledState(GAMEOPT_VEHICLENAME_SAVE, !(_vehicle_design_names & 1));
if (!this->IsWidgetDisabled(GAMEOPT_VEHICLENAME_SAVE)) str = STR_02BF_CUSTOM;
SetDParam(0, str);
- SetDParam(1, _currency_specs[_opt_ptr->currency].name);
- SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units);
- SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side);
- SetDParam(4, TownName(_opt_ptr->town_name));
- SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]);
+ SetDParam(1, _currency_specs[this->opt->gui.currency].name);
+ SetDParam(2, STR_UNITS_IMPERIAL + this->opt->gui.units);
+ SetDParam(3, STR_02E9_DRIVE_ON_LEFT + this->opt->vehicle.road_side);
+ SetDParam(4, TownName(this->opt->game_creation.town_name));
+ SetDParam(5, _autosave_dropdown[this->opt->gui.autosave]);
SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
int i = GetCurRes();
SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
@@ -178,11 +181,11 @@
{
switch (widget) {
case GAMEOPT_CURRENCY_BTN: // Setup currencies dropdown
- ShowDropDownMenu(this, BuildCurrencyDropdown(), _opt_ptr->currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
+ ShowDropDownMenu(this, BuildCurrencyDropdown(), this->opt->gui.currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
break;
case GAMEOPT_DISTANCE_BTN: // Setup distance unit dropdown
- ShowDropDownMenu(this, _units_dropdown, _opt_ptr->units, GAMEOPT_DISTANCE_BTN, 0, 0);
+ ShowDropDownMenu(this, _units_dropdown, this->opt->gui.units, GAMEOPT_DISTANCE_BTN, 0, 0);
break;
case GAMEOPT_ROADSIDE_BTN: { // Setup road-side dropdown
@@ -192,18 +195,18 @@
/* You can only change the drive side if you are in the menu or ingame with
* no vehicles present. In a networking game only the server can change it */
if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) {
- i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value
+ i = (-1) ^ (1 << this->opt->vehicle.road_side); // disable the other value
}
- ShowDropDownMenu(this, _driveside_dropdown, _opt_ptr->road_side, GAMEOPT_ROADSIDE_BTN, i, 0);
+ ShowDropDownMenu(this, _driveside_dropdown, this->opt->vehicle.road_side, GAMEOPT_ROADSIDE_BTN, i, 0);
} break;
case GAMEOPT_TOWNNAME_BTN: // Setup townname dropdown
- ShowTownnameDropdown(this, _opt_ptr->town_name);
+ ShowTownnameDropdown(this, this->opt->game_creation.town_name);
break;
case GAMEOPT_AUTOSAVE_BTN: // Setup autosave dropdown
- ShowDropDownMenu(this, _autosave_dropdown, _opt_ptr->autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0);
+ ShowDropDownMenu(this, _autosave_dropdown, this->opt->gui.autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0);
break;
case GAMEOPT_VEHICLENAME_BTN: // Setup customized vehicle-names dropdown
@@ -262,17 +265,17 @@
case GAMEOPT_CURRENCY_BTN: /* Currency */
if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
- _opt_ptr->currency = index;
+ this->opt->gui.currency = index;
MarkWholeScreenDirty();
break;
case GAMEOPT_DISTANCE_BTN: // Measuring units
- _opt_ptr->units = index;
+ this->opt->gui.units = index;
MarkWholeScreenDirty();
break;
case GAMEOPT_ROADSIDE_BTN: // Road side
- if (_opt_ptr->road_side != index) { // only change if setting changed
+ if (this->opt->vehicle.road_side != index) { // only change if setting changed
DoCommandP(0, index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
MarkWholeScreenDirty();
}
@@ -280,13 +283,13 @@
case GAMEOPT_TOWNNAME_BTN: // Town names
if (_game_mode == GM_MENU) {
- _opt_ptr->town_name = index;
+ this->opt->game_creation.town_name = index;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
break;
case GAMEOPT_AUTOSAVE_BTN: // Autosave options
- _opt.autosave = _opt_newgame.autosave = index;
+ _settings.gui.autosave = _settings_newgame.gui.autosave = index;
this->SetDirty();
break;
@@ -358,90 +361,6 @@
new GameOptionsWindow(&_game_options_desc);
}
-struct GameSettingData {
- int16 min;
- int16 max;
- int16 step;
- StringID str;
-};
-
-static const GameSettingData _game_setting_info[] = {
- { 0, 7, 1, STR_NULL},
- { 0, 3, 1, STR_6830_IMMEDIATE},
- { 0, 3, 1, STR_NUM_VERY_LOW},
- { 0, 4, 1, STR_NONE},
- {100, 500, 50, STR_NULL},
- { 2, 4, 1, STR_NULL},
- { 0, 2, 1, STR_6820_LOW},
- { 0, 4, 1, STR_681B_VERY_SLOW},
- { 0, 2, 1, STR_6820_LOW},
- { 0, 2, 1, STR_6823_NONE},
- { 0, 3, 1, STR_6826_X1_5},
- { 0, 2, 1, STR_6820_LOW},
- { 0, 3, 1, STR_682A_VERY_FLAT},
- { 0, 3, 1, STR_VERY_LOW},
- { 0, 1, 1, STR_682E_STEADY},
- { 0, 1, 1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS},
- { 0, 1, 1, STR_6836_OFF},
- { 0, 2, 1, STR_PERMISSIVE},
-};
-
-/*
- * A: competitors
- * B: start time in months / 3
- * C: town count (3 = high, 0 = very low)
- * D: industry count (4 = high, 0 = none)
- * E: inital loan / 1000 (in GBP)
- * F: interest rate
- * G: running costs (0 = low, 2 = high)
- * H: construction speed of competitors (0 = very slow, 4 = very fast)
- * I: intelligence (0-2)
- * J: breakdowns (0 = off, 2 = normal)
- * K: subsidy multiplier (0 = 1.5, 3 = 4.0)
- * L: construction cost (0-2)
- * M: terrain type (0 = very flat, 3 = mountainous)
- * N: amount of water (0 = very low, 3 = high)
- * O: economy (0 = steady, 1 = fluctuating)
- * P: Train reversing (0 = end of line + stations, 1 = end of line)
- * Q: disasters
- * R: area restructuring (0 = permissive, 2 = hostile)
- */
-static const GDType _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
- A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
- {2, 2, 2, 4, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, ///< easy
- {4, 1, 2, 3, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, ///< medium
- {7, 0, 3, 3, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, ///< hard
-};
-
-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++)
- ((GDType*)&gm_opt->diff)[i] = _default_game_diff[mode][i];
- }
-}
-
-/**
- * Checks the difficulty levels read from the configuration and
- * forces them to be correct when invalid.
- */
-void CheckDifficultyLevels()
-{
- if (_opt_newgame.diff_level != 3) {
- SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame);
- } else {
- for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) {
- GDType *diff = ((GDType*)&_opt_newgame.diff) + i;
- *diff = Clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
- *diff -= *diff % _game_setting_info[i].step;
- }
- }
-}
-
extern void StartupEconomy();
/* Widget definition for the game difficulty settings window */
@@ -469,20 +388,21 @@
_game_difficulty_widgets,
};
+void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
+
struct GameDifficultyWindow : public Window {
private:
+ static const uint GAME_DIFFICULTY_NUM = 18;
bool clicked_increase;
uint8 clicked_button;
uint8 timeout;
/* Temporary holding place of values in the difficulty window until 'Save' is clicked */
- GameOptions opt_mod_temp;
+ Settings opt_mod_temp;
enum {
GAMEDIFF_WND_TOP_OFFSET = 45,
GAMEDIFF_WND_ROWSIZE = 9,
- // 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
- DIFF_INGAME_DISABLED_BUTTONS = 0x383E,
NO_SETTINGS_BUTTON = 0xFF,
};
@@ -507,7 +427,7 @@
{
/* Copy current settings (ingame or in intro) to temporary holding place
* change that when setting stuff, copy back on clicking 'OK' */
- this->opt_mod_temp = *_opt_ptr;
+ this->opt_mod_temp = (_game_mode == GM_MENU) ? _settings_newgame : _settings;
this->clicked_increase = false;
this->clicked_button = NO_SETTINGS_BUTTON;
this->timeout = 0;
@@ -524,7 +444,7 @@
WIDGET_LIST_END);
this->SetWidgetDisabledState(GDW_HIGHSCORE, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
this->SetWidgetDisabledState(GDW_ACCEPT, _networking && !_network_server); // Save-button in multiplayer (and if client)
- this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level);
+ this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
this->FindWindowPlacementAndResize(&_game_difficulty_desc);
}
@@ -532,29 +452,20 @@
{
this->DrawWidgets();
- /* XXX - Disabled buttons in normal gameplay or during muliplayer as non server.
- * Bitshifted for each button to see if that bit is set. If it is set, the
- * button is disabled */
- uint32 disabled = 0;
- if (_networking && !_network_server) {
- disabled = MAX_UVALUE(uint32); // Disable all
- } else if (_game_mode == GM_NORMAL) {
- disabled = DIFF_INGAME_DISABLED_BUTTONS;
- }
-
- int value;
+ uint i;
+ const SettingDesc *sd = GetPatchFromName("difficulty.max_no_competitors", &i);
int y = GAMEDIFF_WND_TOP_OFFSET;
- for (uint i = 0; i != GAME_DIFFICULTY_NUM; i++) {
- const GameSettingData *gsd = &_game_setting_info[i];
- value = ((GDType*)&this->opt_mod_temp.diff)[i];
+ for (i = 0; i < GAME_DIFFICULTY_NUM; i++, sd++) {
+ const SettingDescBase *sdb = &sd->desc;
+ int32 value = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
+ bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0);
DrawArrowButtons(5, y, 3,
(this->clicked_button == i) ? 1 + !!this->clicked_increase : 0,
- !(HasBit(disabled, i) || gsd->min == value),
- !(HasBit(disabled, i) || gsd->max == value));
+ editable && sdb->min != value,
+ editable && sdb->max != value);
- value += _game_setting_info[i].str;
- if (i == 4) value *= 1000; // XXX - handle currency option
+ value += sdb->str;
SetDParam(0, value);
DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, TC_FROMSTRING);
@@ -579,30 +490,33 @@
const uint8 btn = y / (GAMEDIFF_WND_ROWSIZE + 2);
if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9) return;
+ uint i;
+ const SettingDesc *sd = GetPatchFromName("difficulty.max_no_competitors", &i) + btn;
+ const SettingDescBase *sdb = &sd->desc;
+
/* Clicked disabled button? */
- if (_game_mode == GM_NORMAL && HasBit((int)DIFF_INGAME_DISABLED_BUTTONS, btn)) return;
+ bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0);
+ if (!editable) return;
this->timeout = 5;
+ int32 val = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
- int16 val = ((GDType*)&this->opt_mod_temp.diff)[btn];
-
- const GameSettingData *info = &_game_setting_info[btn]; // get information about the difficulty setting
if (x >= 10) {
/* Increase button clicked */
- val = min(val + info->step, info->max);
+ val = min(val + sdb->interval, sdb->max);
this->clicked_increase = true;
} else {
/* Decrease button clicked */
- val -= info->step;
- val = max(val, info->min);
+ val -= sdb->interval;
+ val = max(val, sdb->min);
this->clicked_increase = false;
}
this->clicked_button = btn;
/* save value in temporary variable */
- ((GDType*)&this->opt_mod_temp.diff)[btn] = val;
- this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level);
- SetDifficultyLevel(3, &this->opt_mod_temp); // set difficulty level to custom
+ WriteValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv, val);
+ this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
+ SetDifficultyLevel(3, &this->opt_mod_temp.difficulty); // set difficulty level to custom
this->LowerWidget(GDW_LVL_CUSTOM);
this->SetDirty();
} break;
@@ -612,25 +526,32 @@
case GDW_LVL_HARD:
case GDW_LVL_CUSTOM:
/* temporarily change difficulty level */
- this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level);
- SetDifficultyLevel(widget - GDW_LVL_EASY, &this->opt_mod_temp);
- this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level);
+ this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
+ SetDifficultyLevel(widget - GDW_LVL_EASY, &this->opt_mod_temp.difficulty);
+ this->LowerWidget(GDW_LVL_EASY + this->opt_mod_temp.difficulty.diff_level);
this->SetDirty();
break;
case GDW_HIGHSCORE: // Highscore Table
- ShowHighscoreTable(this->opt_mod_temp.diff_level, -1);
+ ShowHighscoreTable(this->opt_mod_temp.difficulty.diff_level, -1);
break;
case GDW_ACCEPT: { // Save button - save changes
- GDType btn, val;
- for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
- val = ((GDType*)&this->opt_mod_temp.diff)[btn];
+ Settings *opt_ptr = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
+
+ uint i;
+ const SettingDesc *sd = GetPatchFromName("difficulty.max_no_competitors", &i);
+ for (uint btn = 0; btn != GAME_DIFFICULTY_NUM; btn++, sd++) {
+ int32 new_val = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv);
+ int32 cur_val = (int32)ReadValue(GetVariableAddress(opt_ptr, &sd->save), sd->save.conv);
/* if setting has changed, change it */
- if (val != ((GDType*)&_opt_ptr->diff)[btn])
- DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+ if (new_val != cur_val) {
+ DoCommandP(0, i + btn, new_val, NULL, CMD_CHANGE_PATCH_SETTING);
+ }
}
- DoCommandP(0, UINT_MAX, this->opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+
+ GetPatchFromName("difficulty.diff_level", &i);
+ DoCommandP(0, i, this->opt_mod_temp.difficulty.diff_level, NULL, CMD_CHANGE_PATCH_SETTING);
delete this;
/* If we are in the editor, we should reload the economy.
* This way when you load a game, the max loan and interest rate
@@ -662,123 +583,125 @@
}
static const char *_patches_ui[] = {
- "vehicle_speed",
- "status_long_date",
- "show_finances",
- "autoscroll",
- "reverse_scroll",
- "smooth_scroll",
- "errmsg_duration",
- "toolbar_pos",
- "measure_tooltip",
- "window_snap_radius",
- "population_in_label",
- "link_terraform_toolbar",
- "liveries",
- "prefer_teamchat",
+ "gui.vehicle_speed",
+ "gui.status_long_date",
+ "gui.show_finances",
+ "gui.autoscroll",
+ "gui.reverse_scroll",
+ "gui.smooth_scroll",
+ "gui.errmsg_duration",
+ "gui.toolbar_pos",
+ "gui.measure_tooltip",
+ "gui.window_snap_radius",
+ "gui.population_in_label",
+ "gui.link_terraform_toolbar",
+ "gui.liveries",
+ "gui.prefer_teamchat",
/* While the horizontal scrollwheel scrolling is written as general code, only
* the cocoa (OSX) driver generates input for it.
* Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
- "scrollwheel_scrolling",
- "scrollwheel_multiplier",
+ "gui.scrollwheel_scrolling",
+ "gui.scrollwheel_multiplier",
#ifdef __APPLE__
/* We might need to emulate a right mouse button on mac */
- "right_mouse_btn_emulation",
+ "gui.right_mouse_btn_emulation",
#endif
- "pause_on_newgame",
- "advanced_vehicle_list",
- "loading_indicators",
- "timetable_in_ticks",
- "default_rail_type",
- "always_build_infrastructure",
+ "gui.pause_on_newgame",
+ "gui.advanced_vehicle_list",
+ "gui.loading_indicators",
+ "gui.timetable_in_ticks",
+ "gui.default_rail_type",
+ "gui.always_build_infrastructure",
};
static const char *_patches_construction[] = {
- "build_on_slopes",
- "autoslope",
- "extra_dynamite",
- "longbridges",
- "signal_side",
- "always_small_airport",
- "enable_signal_gui",
- "drag_signals_density",
- "oil_refinery_limit",
- "semaphore_build_before",
+ "construction.build_on_slopes",
+ "construction.autoslope",
+ "construction.extra_dynamite",
+ "construction.longbridges",
+ "construction.signal_side",
+ "station.always_small_airport",
+ "gui.enable_signal_gui",
+ "gui.drag_signals_density",
+ "game_creation.oil_refinery_limit",
+ "gui.semaphore_build_before",
};
static const char *_patches_stations[] = {
- "join_stations",
- "improved_load",
- "selectgoods",
- "new_nonstop",
- "nonuniform_stations",
- "station_spread",
- "serviceathelipad",
- "modified_catchment",
- "gradual_loading",
- "road_stop_on_town_road",
- "adjacent_stations",
+ "station.join_stations",
+ "order.improved_load",
+ "order.selectgoods",
+ "gui.new_nonstop",
+ "station.nonuniform_stations",
+ "station.station_spread",
+ "order.serviceathelipad",
+ "station.modified_catchment",
+ "order.gradual_loading",
+ "construction.road_stop_on_town_road",
+ "station.adjacent_stations",
+ "economy.station_noise_level",
};
static const char *_patches_economy[] = {
- "inflation",
- "raw_industry_construction",
- "multiple_industry_per_town",
- "same_industry_close",
- "bribe",
- "exclusive_rights",
- "give_money",
- "colored_news_year",
- "ending_year",
- "smooth_economy",
- "allow_shares",
- "town_layout",
- "mod_road_rebuild",
- "town_growth_rate",
- "larger_towns",
- "initial_city_size",
+ "economy.inflation",
+ "construction.raw_industry_construction",
+ "economy.multiple_industry_per_town",
+ "economy.same_industry_close",
+ "economy.bribe",
+ "economy.exclusive_rights",
+ "economy.give_money",
+ "gui.colored_news_year",
+ "gui.ending_year",
+ "economy.smooth_economy",
+ "economy.allow_shares",
+ "economy.town_layout",
+ "economy.mod_road_rebuild",
+ "economy.town_growth_rate",
+ "economy.larger_towns",
+ "economy.initial_city_size",
};
static const char *_patches_ai[] = {
- "ai_in_multiplayer",
- "ai_disable_veh_train",
- "ai_disable_veh_roadveh",
- "ai_disable_veh_aircraft",
- "ai_disable_veh_ship",
+ "ai.ainew_active",
+ "ai.ai_in_multiplayer",
+ "ai.ai_disable_veh_train",
+ "ai.ai_disable_veh_roadveh",
+ "ai.ai_disable_veh_aircraft",
+ "ai.ai_disable_veh_ship",
};
static const char *_patches_vehicles[] = {
- "realistic_acceleration",
- "forbid_90_deg",
- "mammoth_trains",
- "gotodepot",
- "roadveh_queue",
- "pathfinder_for_trains",
- "pathfinder_for_roadvehs",
- "pathfinder_for_ships",
- "train_income_warn",
- "order_review_system",
- "never_expire_vehicles",
- "lost_train_warn",
- "autorenew",
- "autorenew_months",
- "autorenew_money",
- "max_trains",
- "max_roadveh",
- "max_aircraft",
- "max_ships",
- "servint_ispercent",
- "servint_trains",
- "servint_roadveh",
- "servint_ships",
- "servint_aircraft",
- "no_servicing_if_no_breakdowns",
- "wagon_speed_limits",
- "disable_elrails",
- "freight_trains",
- "plane_speed",
- "timetabling",
- "dynamic_engines",
+ "vehicle.realistic_acceleration",
+ "pf.forbid_90_deg",
+ "vehicle.mammoth_trains",
+ "order.gotodepot",
+ "pf.roadveh_queue",
+ "pf.pathfinder_for_trains",
+ "pf.pathfinder_for_roadvehs",
+ "pf.pathfinder_for_ships",
+ "gui.train_income_warn",
+ "gui.order_review_system",
+ "vehicle.never_expire_vehicles",
+ "gui.lost_train_warn",
+ "gui.autorenew",
+ "gui.autorenew_months",
+ "gui.autorenew_money",
+ "vehicle.max_trains",
+ "vehicle.max_roadveh",
+ "vehicle.max_aircraft",
+ "vehicle.max_ships",
+ "vehicle.servint_ispercent",
+ "vehicle.servint_trains",
+ "vehicle.servint_roadveh",
+ "vehicle.servint_ships",
+ "vehicle.servint_aircraft",
+ "order.no_servicing_if_no_breakdowns",
+ "vehicle.wagon_speed_limits",
+ "vehicle.disable_elrails",
+ "vehicle.freight_trains",
+ "vehicle.plane_speed",
+ "order.timetabling",
+ "vehicle.dynamic_engines",
};
struct PatchEntry {
@@ -815,7 +738,7 @@
};
struct PatchesSelectionWindow : Window {
- static Patches *patches_ptr;
+ static Settings *patches_ptr;
static int patches_max;
int page;
@@ -826,7 +749,7 @@
{
static bool first_time = true;
- patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
+ patches_ptr = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
/* Build up the dynamic settings-array only once per OpenTTD session */
if (first_time) {
@@ -1038,7 +961,7 @@
}
};
-Patches *PatchesSelectionWindow::patches_ptr = NULL;
+Settings *PatchesSelectionWindow::patches_ptr = NULL;
int PatchesSelectionWindow::patches_max = 0;
static const Widget _patches_selection_widgets[] = {
--- a/src/settings_internal.h Mon May 26 11:36:42 2008 +0000
+++ b/src/settings_internal.h Mon May 26 13:52:59 2008 +0000
@@ -39,8 +39,8 @@
SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games
SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate
SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game
- SGF_END = 1 << 6,
- /* 3 more possible flags */
+ SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in inside a game
+ SGF_END = 1 << 7,
};
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong);
@@ -84,6 +84,6 @@
};
const SettingDesc *GetPatchFromName(const char *name, uint *i);
-bool SetPatchValue(uint index, const Patches *object, int32 value);
+bool SetPatchValue(uint index, const Settings *object, int32 value);
#endif /* SETTINGS_H */
--- a/src/settings_type.h Mon May 26 11:36:42 2008 +0000
+++ b/src/settings_type.h Mon May 26 13:52:59 2008 +0000
@@ -5,240 +5,282 @@
#ifndef SETTINGS_TYPE_H
#define SETTINGS_TYPE_H
-#include "yapf/yapf_settings.h"
#include "date_type.h"
#include "town_type.h"
#include "transport_type.h"
-#define GAME_DIFFICULTY_NUM 18
-
-/** Specific type for Game Difficulty to ease changing the type */
-typedef uint16 GDType;
-struct GameDifficulty {
- GDType max_no_competitors;
- GDType competitor_start_time;
- GDType number_towns;
- GDType number_industries;
- GDType max_loan;
- GDType initial_interest;
- GDType vehicle_costs;
- GDType competitor_speed;
- GDType competitor_intelligence; ///< no longer in use
- GDType vehicle_breakdowns;
- GDType subsidy_multiplier;
- GDType construction_cost;
- GDType terrain_type;
- GDType quantity_sea_lakes;
- GDType economy;
- GDType line_reverse_mode;
- GDType disasters;
- GDType town_council_tolerance; ///< minimum required town ratings to be allowed to demolish stuff
-};
-
-struct GameOptions {
- GameDifficulty diff;
- byte diff_level;
- byte currency;
- byte units;
- byte town_name;
- byte landscape;
- byte snow_line;
- byte autosave;
- byte road_side;
+/** Settings related to the difficulty of the game */
+struct DifficultySettings {
+ byte max_no_competitors; ///< the number of competitors (AIs)
+ byte competitor_start_time; ///< how long to wait for the first competitors (AIs)
+ byte number_towns; ///< the amount of towns
+ byte number_industries; ///< the amount of industries
+ uint32 max_loan; ///< the maximum initial loan
+ byte initial_interest; ///< amount of interest (to pay over the loan)
+ byte vehicle_costs; ///< amount of money spent on vehicle running cost
+ byte competitor_speed; ///< the speed at which the AI builds
+ byte competitor_intelligence; ///< the competior's (AI) intelligence
+ byte vehicle_breakdowns; ///< likelihood of vehicles breaking down
+ byte subsidy_multiplier; ///< amount of subsidy
+ byte construction_cost; ///< how expensive is building
+ byte terrain_type; ///< the mountainousness of the landscape
+ byte quantity_sea_lakes; ///< the amount of seas/lakes
+ byte economy; ///< how volatile is the economy
+ byte line_reverse_mode; ///< reversing at stations or not
+ byte disasters; ///< are disasters enabled
+ byte town_council_tolerance; ///< minimum required town ratings to be allowed to demolish stuff
+ byte diff_level; ///< the difficulty level
};
-/* These are the options for the current game
- * either ingame, or loaded. Also used for networking games */
-extern GameOptions _opt;
-
-/* These are the default options for a new game */
-extern GameOptions _opt_newgame;
-
-/* Pointer to one of the two _opt OR _opt_newgame structs */
-extern GameOptions *_opt_ptr;
-
-struct Patches {
- bool modified_catchment; ///< different-size catchment areas
- bool vehicle_speed; ///< show vehicle speed
- bool build_on_slopes; ///< allow building on slopes
- bool mammoth_trains; ///< allow very long trains
- bool join_stations; ///< allow joining of train stations
- bool sg_full_load_any; ///< new full load calculation, any cargo must be full read from pre v93 savegames
- bool improved_load; ///< improved loading algorithm
- bool gradual_loading; ///< load vehicles gradually
- byte station_spread; ///< amount a station may spread
- bool inflation; ///< disable inflation
- bool selectgoods; ///< only send the goods to station if a train has been there
- bool longbridges; ///< allow 100 tile long bridges
- bool gotodepot; ///< allow goto depot in orders
- uint8 raw_industry_construction; ///< Type of (raw) industry construction (none, "normal", prospecting)
- bool multiple_industry_per_town; ///< allow many industries of the same type per town
- bool same_industry_close; ///< allow same type industries to be built close to each other
- bool lost_train_warn; ///< if a train can't find its destination, show a warning
- uint8 order_review_system;
- bool train_income_warn; ///< if train is generating little income, show a warning
- bool status_long_date; ///< always show long date in status bar
- bool signal_side; ///< show signals on right side
- bool show_finances; ///< show finances at end of year
- bool sg_new_nonstop; ///< ttdpatch compatible nonstop handling read from pre v93 savegames
- bool new_nonstop; ///< ttdpatch compatible nonstop handling
- bool roadveh_queue; ///< buggy road vehicle queueing
- bool autoscroll; ///< scroll when moving mouse to the edge.
- byte errmsg_duration; ///< duration of error message
- byte land_generator; ///< the landscape generator
- byte oil_refinery_limit; ///< distance oil refineries allowed from map edge
- byte snow_line_height; ///< a number 0-15 that configured snow line height
- byte tgen_smoothness; ///< how rough is the terrain from 0-3
- uint32 generation_seed; ///< noise seed for world generation
- byte tree_placer; ///< the tree placer algorithm
- byte heightmap_rotation; ///< rotation director for the heightmap
- byte se_flat_world_height; ///< land height a flat world gets in SE
- bool bribe; ///< enable bribing the local authority
- bool nonuniform_stations; ///< allow nonuniform train stations
- bool adjacent_stations; ///< allow stations to be built directly adjacent to other stations
- bool always_small_airport; ///< always allow small airports
- bool realistic_acceleration; ///< realistic acceleration for trains
- bool wagon_speed_limits; ///< enable wagon speed limits
- bool forbid_90_deg; ///< forbid trains to make 90 deg turns
- bool no_servicing_if_no_breakdowns; ///< dont send vehicles to depot when breakdowns are disabled
- bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars
- bool reverse_scroll; ///< Right-Click-Scrolling scrolls in the opposite direction
- bool smooth_scroll; ///< Smooth scroll viewports
- bool disable_elrails; ///< when true, the elrails are disabled
- bool measure_tooltip; ///< Show a permanent tooltip when dragging tools
- byte liveries; ///< Options for displaying company liveries, 0=none, 1=self, 2=all
- bool prefer_teamchat; ///< Choose the chat message target with <ENTER>, true=all players, false=your team
- uint8 advanced_vehicle_list; ///< Use the "advanced" vehicle list
- uint8 loading_indicators; ///< Show loading indicators
- uint8 default_rail_type; ///< The default rail type for the rail GUI
+/** Settings related to the GUI and other stuff that is not saved in the savegame. */
+struct GUISettings {
+ bool vehicle_speed; ///< show vehicle speed
+ bool sg_full_load_any; ///< new full load calculation, any cargo must be full read from pre v93 savegames
+ bool lost_train_warn; ///< if a train can't find its destination, show a warning
+ uint8 order_review_system; ///< perform order reviews on vehicles
+ bool train_income_warn; ///< if train is generating little income, show a warning
+ bool status_long_date; ///< always show long date in status bar
+ bool show_finances; ///< show finances at end of year
+ bool sg_new_nonstop; ///< ttdpatch compatible nonstop handling read from pre v93 savegames
+ bool new_nonstop; ///< ttdpatch compatible nonstop handling
+ bool autoscroll; ///< scroll when moving mouse to the edge
+ byte errmsg_duration; ///< duration of error message
+ bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars
+ bool reverse_scroll; ///< right-Click-Scrolling scrolls in the opposite direction
+ bool smooth_scroll; ///< smooth scroll viewports
+ bool measure_tooltip; ///< show a permanent tooltip when dragging tools
+ byte liveries; ///< options for displaying company liveries, 0=none, 1=self, 2=all
+ bool prefer_teamchat; ///< choose the chat message target with <ENTER>, true=all players, false=your team
+ uint8 advanced_vehicle_list; ///< use the "advanced" vehicle list
+ uint8 loading_indicators; ///< show loading indicators
+ uint8 default_rail_type; ///< the default rail type for the rail GUI
+ uint8 toolbar_pos; ///< position of toolbars, 0=left, 1=center, 2=right
+ uint8 window_snap_radius; ///< windows snap at each other if closer than this
+ bool always_build_infrastructure; ///< always allow building of infrastructure, even when you do not have the vehicles for it
+ byte autosave; ///< how often should we do autosaves?
+ bool keep_all_autosave; ///< name the autosave in a different way
+ bool autosave_on_exit; ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?"
+ byte max_num_autosaves; ///< controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1)
+ bool population_in_label; ///< show the population of a town in his label?
+ uint8 right_mouse_btn_emulation; ///< should we emulate right mouse clicking?
+ uint8 scrollwheel_scrolling; ///< scrolling using the scroll wheel?
+ uint8 scrollwheel_multiplier; ///< how much 'wheel' per incoming event from the OS?
+ bool pause_on_newgame; ///< whether to start new games paused or not
+ bool enable_signal_gui; ///< show the signal GUI when the signal button is pressed
+ Year ending_year; ///< end of the game (just show highscore)
+ Year colored_news_year; ///< when does newspaper become colored?
+ bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days
+ bool bridge_pillars; ///< show bridge pillars for high bridges
+ bool auto_euro; ///< automatically switch to euro in 2002
+ byte drag_signals_density; ///< many signals density
+ Year semaphore_build_before; ///< build semaphore signals automatically before this year
+ bool autorenew; ///< should autorenew be enabled for new companies?
+ int16 autorenew_months; ///< how many months from EOL of vehicles should autorenew trigger for new companies?
+ int32 autorenew_money; ///< how much money before autorenewing for new companies?
+ byte currency; ///< currency we currently use
+ byte units; ///< unit system we show everything
+};
- uint8 toolbar_pos; ///< position of toolbars, 0=left, 1=center, 2=right
- uint8 window_snap_radius; ///< Windows snap at each other if closer than this
-
- bool always_build_infrastructure; ///< Always allow building of infrastructure, even when you do not have the vehicles for it
- UnitID max_trains; ///< max trains in game per player (these are 16bit because the unitnumber field can't hold more)
- UnitID max_roadveh; ///< max trucks in game per player
- UnitID max_aircraft; ///< max planes in game per player
- UnitID max_ships; ///< max ships in game per player
-
- bool servint_ispercent; ///< service intervals are in percents
- uint16 servint_trains; ///< service interval for trains
- uint16 servint_roadveh; ///< service interval for road vehicles
- uint16 servint_aircraft; ///< service interval for aircraft
- uint16 servint_ships; ///< service interval for ships
-
- uint8 pathfinder_for_trains; ///< the pathfinder to use for trains
- uint8 pathfinder_for_roadvehs; ///< the pathfinder to use for roadvehicles
- uint8 pathfinder_for_ships; ///< the pathfinder to use for ships
-
- uint8 plane_speed; ///< divisor for speed of aircraft
-
- bool autorenew;
- int16 autorenew_months;
- int32 autorenew_money;
-
- byte pf_maxdepth; ///< maximum recursion depth when searching for a train route for new pathfinder
- uint16 pf_maxlength; ///< maximum length when searching for a train route for new pathfinder
-
- bool bridge_pillars; ///< show bridge pillars for high bridges
+/** Settings related to the creation of games. */
+struct GameCreationSettings {
+ uint32 generation_seed; ///< noise seed for world generation
+ Year starting_year; ///< starting date
+ uint8 map_x; ///< X size of map
+ uint8 map_y; ///< Y size of map
+ byte land_generator; ///< the landscape generator
+ byte oil_refinery_limit; ///< distance oil refineries allowed from map edge
+ byte snow_line_height; ///< a number 0-15 that configured snow line height
+ byte tgen_smoothness; ///< how rough is the terrain from 0-3
+ byte tree_placer; ///< the tree placer algorithm
+ byte heightmap_rotation; ///< rotation director for the heightmap
+ byte se_flat_world_height; ///< land height a flat world gets in SE
+ byte town_name; ///< the town name generator used for town names
+ byte landscape; ///< the landscape we're currently in
+ byte snow_line; ///< the snowline level in this game
+};
- bool ai_disable_veh_train; ///< disable types for AI
- bool ai_disable_veh_roadveh; ///< disable types for AI
- bool ai_disable_veh_aircraft; ///< disable types for AI
- bool ai_disable_veh_ship; ///< disable types for AI
- Year starting_year; ///< starting date
- Year ending_year; ///< end of the game (just show highscore)
- Year colored_news_year; ///< when does newspaper become colored?
-
- bool keep_all_autosave; ///< name the autosave in a different way.
- bool autosave_on_exit; ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?"
- byte max_num_autosaves; ///< controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1)
- bool extra_dynamite; ///< extra dynamite
- bool road_stop_on_town_road; ///< allow building of drive-through road stops on town owned roads
-
- bool never_expire_vehicles; ///< never expire vehicles
- byte extend_vehicle_life; ///< extend vehicle life by this many years
+/** Settings related to construction in-game */
+struct ConstructionSettings {
+ bool build_on_slopes; ///< allow building on slopes
+ bool autoslope; ///< allow terraforming under things
+ bool longbridges; ///< allow 100 tile long bridges
+ bool signal_side; ///< show signals on right side
+ bool extra_dynamite; ///< extra dynamite
+ bool road_stop_on_town_road; ///< allow building of drive-through road stops on town owned roads
+ uint8 raw_industry_construction; ///< type of (raw) industry construction (none, "normal", prospecting)
+};
- bool auto_euro; ///< automatically switch to euro in 2002
- bool serviceathelipad; ///< service helicopters at helipads automatically (no need to send to depot)
- bool smooth_economy; ///< smooth economy
- bool allow_shares; ///< allow the buying/selling of shares
- byte dist_local_authority; ///< distance for town local authority, default 20
-
- byte wait_oneway_signal; ///< waitingtime in days before a oneway signal
- byte wait_twoway_signal; ///< waitingtime in days before a twoway signal
+/** Settings related to the AI. */
+struct AISettings {
+ bool ai_in_multiplayer; ///< so we allow AIs in multiplayer
+ bool ai_disable_veh_train; ///< disable types for AI
+ bool ai_disable_veh_roadveh; ///< disable types for AI
+ bool ai_disable_veh_aircraft; ///< disable types for AI
+ bool ai_disable_veh_ship; ///< disable types for AI
+};
- uint8 map_x; ///< Size of map
- uint8 map_y;
+/** Settings related to the old pathfinder. */
+struct OPFSettings {
+ uint16 pf_maxlength; ///< maximum length when searching for a train route for new pathfinder
+ byte pf_maxdepth; ///< maximum recursion depth when searching for a train route for new pathfinder
+};
- byte drag_signals_density; ///< many signals density
- Year semaphore_build_before; ///< Build semaphore signals automatically before this year
- bool ai_in_multiplayer; ///< Do we allow AIs in multiplayer
-
- /*
- * New Path Finding
- */
- bool new_pathfinding_all; ///< Use the newest pathfinding algorithm for all
-
+/** Settings related to the new pathfinder. */
+struct NPFSettings {
/**
* The maximum amount of search nodes a single NPF run should take. This
* limit should make sure performance stays at acceptable levels at the cost
- * of not being perfect anymore. This will probably be fixed in a more
- * sophisticated way sometime soon
+ * of not being perfect anymore.
*/
uint32 npf_max_search_nodes;
- uint32 npf_rail_firstred_penalty; ///< The penalty for when the first signal is red (and it is not an exit or combo signal)
- uint32 npf_rail_firstred_exit_penalty; ///< The penalty for when the first signal is red (and it is an exit or combo signal)
- uint32 npf_rail_lastred_penalty; ///< The penalty for when the last signal is red
- uint32 npf_rail_station_penalty; ///< The penalty for station tiles
- uint32 npf_rail_slope_penalty; ///< The penalty for sloping upwards
- uint32 npf_rail_curve_penalty; ///< The penalty for curves
- uint32 npf_rail_depot_reverse_penalty; ///< The penalty for reversing in depots
- uint32 npf_buoy_penalty; ///< The penalty for going over (through) a buoy
- uint32 npf_water_curve_penalty; ///< The penalty for curves
- uint32 npf_road_curve_penalty; ///< The penalty for curves
- uint32 npf_crossing_penalty; ///< The penalty for level crossings
- uint32 npf_road_drive_through_penalty; ///< The penalty for going through a drive-through road stop
-
- bool population_in_label; ///< Show the population of a town in his label?
-
- uint8 freight_trains; ///< Value to multiply the weight of cargo by
-
- /** YAPF settings */
- YapfSettings yapf;
-
- uint8 right_mouse_btn_emulation;
-
- uint8 scrollwheel_scrolling;
- uint8 scrollwheel_multiplier;
-
- uint8 town_growth_rate; ///< Town growth rate
- uint8 larger_towns; ///< The number of cities to build. These start off larger and grow twice as fast
- uint8 initial_city_size; ///< Multiplier for the initial size of the cities compared to towns
-
- bool pause_on_newgame; ///< Whether to start new games paused or not.
-
- TownLayoutByte town_layout; ///< Select town layout
-
- bool timetabling; ///< Whether to allow timetabling.
- bool timetable_in_ticks; ///< Whether to show the timetable in ticks rather than days.
-
- bool autoslope; ///< Allow terraforming under things.
-
- bool mod_road_rebuild; ///< Roadworks remove unneccesary RoadBits
-
- bool exclusive_rights; ///< allow buying exclusive rights
- bool give_money; ///< allow giving other players money
-
- bool enable_signal_gui; ///< Show the signal GUI when the signal button is pressed
-
- bool dynamic_engines; ///< Enable dynamic allocation of engine data
+ uint32 npf_rail_firstred_penalty; ///< the penalty for when the first signal is red (and it is not an exit or combo signal)
+ uint32 npf_rail_firstred_exit_penalty; ///< the penalty for when the first signal is red (and it is an exit or combo signal)
+ uint32 npf_rail_lastred_penalty; ///< the penalty for when the last signal is red
+ uint32 npf_rail_station_penalty; ///< the penalty for station tiles
+ uint32 npf_rail_slope_penalty; ///< the penalty for sloping upwards
+ uint32 npf_rail_curve_penalty; ///< the penalty for curves
+ uint32 npf_rail_depot_reverse_penalty; ///< the penalty for reversing in depots
+ uint32 npf_buoy_penalty; ///< the penalty for going over (through) a buoy
+ uint32 npf_water_curve_penalty; ///< the penalty for curves
+ uint32 npf_road_curve_penalty; ///< the penalty for curves
+ uint32 npf_crossing_penalty; ///< the penalty for level crossings
+ uint32 npf_road_drive_through_penalty; ///< the penalty for going through a drive-through road stop
};
-extern Patches _patches;
+/** Settings related to the yet another pathfinder. */
+struct YAPFSettings {
+ bool disable_node_optimization; ///< whether to use exit-dir instead of trackdir in node key
+ uint32 max_search_nodes; ///< stop path-finding when this number of nodes visited
+ bool ship_use_yapf; ///< use YAPF for ships
+ bool road_use_yapf; ///< use YAPF for road
+ bool rail_use_yapf; ///< use YAPF for rail
+ uint32 road_slope_penalty; ///< penalty for up-hill slope
+ uint32 road_curve_penalty; ///< penalty for curves
+ uint32 road_crossing_penalty; ///< penalty for level crossing
+ uint32 road_stop_penalty; ///< penalty for going through a drive-through road stop
+ bool rail_firstred_twoway_eol; ///< treat first red two-way signal as dead end
+ uint32 rail_firstred_penalty; ///< penalty for first red signal
+ uint32 rail_firstred_exit_penalty; ///< penalty for first red exit signal
+ uint32 rail_lastred_penalty; ///< penalty for last red signal
+ uint32 rail_lastred_exit_penalty; ///< penalty for last red exit signal
+ uint32 rail_station_penalty; ///< penalty for non-target station tile
+ uint32 rail_slope_penalty; ///< penalty for up-hill slope
+ uint32 rail_curve45_penalty; ///< penalty for curve
+ uint32 rail_curve90_penalty; ///< penalty for 90-deg curve
+ uint32 rail_depot_reverse_penalty; ///< penalty for reversing in the depot
+ uint32 rail_crossing_penalty; ///< penalty for level crossing
+ uint32 rail_look_ahead_max_signals; ///< max. number of signals taken into consideration in look-ahead load balancer
+ int32 rail_look_ahead_signal_p0; ///< constant in polynomial penalty function
+ int32 rail_look_ahead_signal_p1; ///< constant in polynomial penalty function
+ int32 rail_look_ahead_signal_p2; ///< constant in polynomial penalty function
-/** The patch values that are used for new games and/or modified in config file */
-extern Patches _patches_newgame;
+ uint32 rail_longer_platform_penalty; ///< penalty for longer station platform than train
+ uint32 rail_longer_platform_per_tile_penalty; ///< penalty for longer station platform than train (per tile)
+ uint32 rail_shorter_platform_penalty; ///< penalty for shorter station platform than train
+ uint32 rail_shorter_platform_per_tile_penalty; ///< penalty for shorter station platform than train (per tile)
+};
+
+/** Settings related to all pathfinders. */
+struct PathfinderSettings {
+ uint8 pathfinder_for_trains; ///< the pathfinder to use for trains
+ uint8 pathfinder_for_roadvehs; ///< the pathfinder to use for roadvehicles
+ uint8 pathfinder_for_ships; ///< the pathfinder to use for ships
+ bool new_pathfinding_all; ///< use the newest pathfinding algorithm for all
+
+ bool roadveh_queue; ///< buggy road vehicle queueing
+ bool forbid_90_deg; ///< forbid trains to make 90 deg turns
+
+ byte wait_oneway_signal; ///< waitingtime in days before a oneway signal
+ byte wait_twoway_signal; ///< waitingtime in days before a twoway signal
+
+ OPFSettings opf; ///< pathfinder settings for the old pathfinder
+ NPFSettings npf; ///< pathfinder settings for the new pathfinder
+ YAPFSettings yapf; ///< pathfinder settings for the yet another pathfinder
+};
+
+/** Settings related to orders. */
+struct OrderSettings {
+ bool improved_load; ///< improved loading algorithm
+ bool gradual_loading; ///< load vehicles gradually
+ bool selectgoods; ///< only send the goods to station if a train has been there
+ bool gotodepot; ///< allow goto depot in orders
+ bool no_servicing_if_no_breakdowns; ///< dont send vehicles to depot when breakdowns are disabled
+ bool timetabling; ///< whether to allow timetabling
+ bool serviceathelipad; ///< service helicopters at helipads automatically (no need to send to depot)
+};
+
+/** Settings related to vehicles. */
+struct VehicleSettings {
+ bool mammoth_trains; ///< allow very long trains
+ bool realistic_acceleration; ///< realistic acceleration for trains
+ bool wagon_speed_limits; ///< enable wagon speed limits
+ bool disable_elrails; ///< when true, the elrails are disabled
+ UnitID max_trains; ///< max trains in game per player
+ UnitID max_roadveh; ///< max trucks in game per player
+ UnitID max_aircraft; ///< max planes in game per player
+ UnitID max_ships; ///< max ships in game per player
+ bool servint_ispercent; ///< service intervals are in percents
+ uint16 servint_trains; ///< service interval for trains
+ uint16 servint_roadveh; ///< service interval for road vehicles
+ uint16 servint_aircraft; ///< service interval for aircraft
+ uint16 servint_ships; ///< service interval for ships
+ uint8 plane_speed; ///< divisor for speed of aircraft
+ uint8 freight_trains; ///< value to multiply the weight of cargo by
+ bool dynamic_engines; ///< enable dynamic allocation of engine data
+ bool never_expire_vehicles; ///< never expire vehicles
+ byte extend_vehicle_life; ///< extend vehicle life by this many years
+ byte road_side; ///< the side of the road vehicles drive on
+};
+
+/** Settings related to the economy. */
+struct EconomySettings {
+ bool inflation; ///< disable inflation
+ bool bribe; ///< enable bribing the local authority
+ bool smooth_economy; ///< smooth economy
+ bool allow_shares; ///< allow the buying/selling of shares
+ byte dist_local_authority; ///< distance for town local authority, default 20
+ bool exclusive_rights; ///< allow buying exclusive rights
+ bool give_money; ///< allow giving other players money
+ bool mod_road_rebuild; ///< roadworks remove unneccesary RoadBits
+ bool multiple_industry_per_town; ///< allow many industries of the same type per town
+ bool same_industry_close; ///< allow same type industries to be built close to each other
+ uint8 town_growth_rate; ///< town growth rate
+ uint8 larger_towns; ///< the number of cities to build. These start off larger and grow twice as fast
+ uint8 initial_city_size; ///< multiplier for the initial size of the cities compared to towns
+ TownLayoutByte town_layout; ///< select town layout
+ bool station_noise_level; ///< build new airports when the town noise level is still within accepted limits
+ uint16 town_noise_population[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance)
+};
+
+/** Settings related to stations. */
+struct StationSettings {
+ bool modified_catchment; ///< different-size catchment areas
+ bool join_stations; ///< allow joining of train stations
+ bool nonuniform_stations; ///< allow nonuniform train stations
+ bool adjacent_stations; ///< allow stations to be built directly adjacent to other stations
+ bool always_small_airport; ///< always allow small airports
+ byte station_spread; ///< amount a station may spread
+};
+
+/** All settings together. */
+struct Settings {
+ DifficultySettings difficulty; ///< settings related to the difficulty
+ GUISettings gui; ///< settings related to the GUI
+ GameCreationSettings game_creation; ///< settings used during the creation of a game (map)
+ ConstructionSettings construction; ///< construction of things in-game
+ AISettings ai; ///< what may the AI do?
+ PathfinderSettings pf; ///< settings for all pathfinders
+ OrderSettings order; ///< settings related to orders
+ VehicleSettings vehicle; ///< options for vehicles
+ EconomySettings economy; ///< settings to change the economy
+ StationSettings station; ///< settings related to station management
+};
+
+/** The current settings. */
+extern Settings _settings;
+
+/** The settings values that are used for new games and/or modified in config file */
+extern Settings _settings_newgame;
#endif /* SETTINGS_TYPE_H */
--- a/src/ship_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/ship_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -107,7 +107,7 @@
static const Depot* FindClosestShipDepot(const Vehicle* v)
{
- if (_patches.pathfinder_for_ships == VPF_NPF) { /* NPF is used */
+ if (_settings.pf.pathfinder_for_ships == VPF_NPF) { /* NPF is used */
Trackdir trackdir = GetVehicleTrackdir(v);
NPFFoundTargetData ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
@@ -138,7 +138,7 @@
static void CheckIfShipNeedsService(Vehicle *v)
{
- if (_patches.servint_ships == 0 || !v->NeedsAutomaticServicing()) return;
+ if (_settings.vehicle.servint_ships == 0 || !v->NeedsAutomaticServicing()) return;
if (v->IsInDepot()) {
VehicleServiceInDepot(v);
return;
@@ -197,7 +197,7 @@
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
- SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ?
+ SndPlayVehicleFx((_settings.game_creation.landscape != LT_TOYLAND) ?
SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
}
@@ -321,7 +321,7 @@
/*updates statusbar only if speed have changed to save CPU time */
if (spd != v->cur_speed) {
v->cur_speed = spd;
- if (_patches.vehicle_speed)
+ if (_settings.gui.vehicle_speed)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
}
@@ -460,7 +460,7 @@
{
assert(IsValidDiagDirection(enterdir));
- switch (_patches.pathfinder_for_ships) {
+ switch (_settings.pf.pathfinder_for_ships) {
case VPF_YAPF: { /* YAPF */
Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
if (trackdir != INVALID_TRACKDIR) return TrackdirToTrack(trackdir);
@@ -760,7 +760,7 @@
unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP);
- if (!Vehicle::AllocateList(NULL, 1) || unit_num > _patches.max_ships)
+ if (!Vehicle::AllocateList(NULL, 1) || unit_num > _settings.vehicle.max_ships)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) {
@@ -804,7 +804,7 @@
v->name = NULL;
v->u.ship.state = TRACK_BIT_DEPOT;
- v->service_interval = _patches.servint_ships;
+ v->service_interval = _settings.vehicle.servint_ships;
v->date_of_last_service = _date;
v->build_year = _cur_year;
v->cur_image = 0x0E5E;
--- a/src/signal.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/signal.cpp Mon May 26 13:52:59 2008 +0000
@@ -465,7 +465,7 @@
* Updates blocks in _globset buffer
*
* @param owner player whose signals we are updating
- * @return false iff presignal entry would be green (needed for trains leaving depot)
+ * @return state of the first block from _globset
* @pre IsValidPlayer(owner)
*/
static SigSegState UpdateSignalsInBuffer(Owner owner)
@@ -630,7 +630,7 @@
* @param tile tile where we start
* @param side side of tile
* @param owner owner whose signals we will update
- * @return false iff train can leave depot
+ * @return the state of the signal segment
*/
SigSegState UpdateSignalsOnSegment(TileIndex tile, DiagDirection side, Owner owner)
{
--- a/src/smallmap_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/smallmap_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -459,7 +459,7 @@
case MP_TREES:
if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) {
- bits = (_opt.landscape == LT_ARCTIC) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2);
+ bits = (_settings.game_creation.landscape == LT_ARCTIC) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2);
} else {
bits = MKCOLOR(0x54575754);
}
@@ -490,6 +490,10 @@
case MP_INDUSTRY: o = OWNER_END; break;
case MP_HOUSE: o = OWNER_TOWN; break;
default: o = GetTileOwner(tile); break;
+ /* FIXME: For MP_ROAD there are multiple owners.
+ * GetTileOwner returns the rail owner (level crossing) resp. the owner of ROADTYPE_ROAD (normal road),
+ * even if there are no ROADTYPE_ROAD bits on the tile.
+ */
}
return _owner_colors[o];
--- a/src/station.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/station.cpp Mon May 26 13:52:59 2008 +0000
@@ -285,7 +285,7 @@
/* check new rect dimensions against preset max */
int w = new_rect.right - new_rect.left + 1;
int h = new_rect.bottom - new_rect.top + 1;
- if (mode != ADD_FORCE && (w > _patches.station_spread || h > _patches.station_spread)) {
+ if (mode != ADD_FORCE && (w > _settings.station.station_spread || h > _settings.station.station_spread)) {
assert(mode != ADD_TRY);
_error_message = STR_306C_STATION_TOO_SPREAD_OUT;
return false;
--- a/src/station_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/station_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -296,7 +296,7 @@
CountMapSquareAround(tile, CMSATree) >= 8 ||
CountMapSquareAround(tile, CMSAForest) >= 2)
) {
- return _opt.landscape == LT_TROPIC ? STR_SV_STNAME_FOREST : STR_SV_STNAME_WOODS;
+ return _settings.game_creation.landscape == LT_TROPIC ? STR_SV_STNAME_FOREST : STR_SV_STNAME_WOODS;
}
/* check elevation compared to town */
@@ -563,7 +563,7 @@
TileXY(rect.left, rect.bottom),
rect.right - rect.left + 1,
rect.top - rect.bottom + 1,
- _patches.modified_catchment ? FindCatchmentRadius(st) : (uint)CA_UNMODIFIED
+ _settings.station.modified_catchment ? FindCatchmentRadius(st) : (uint)CA_UNMODIFIED
);
} else {
memset(accepts, 0, sizeof(accepts));
@@ -692,7 +692,7 @@
* b) the build_on_slopes switch is disabled
*/
if (IsSteepSlope(tileh) ||
- ((!_patches.build_on_slopes) && tileh != SLOPE_FLAT)) {
+ ((!_settings.construction.build_on_slopes) && tileh != SLOPE_FLAT)) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
@@ -750,7 +750,7 @@
uint w = fin[1];
uint h = fin[2];
- if (_patches.nonuniform_stations) {
+ if (_settings.station.nonuniform_stations) {
/* determine new size of train station region.. */
int x = min(TileX(st->train_tile), TileX(tile));
int y = min(TileY(st->train_tile), TileY(tile));
@@ -794,7 +794,7 @@
}
}
/* make sure the final size is not too big. */
- if (curw > _patches.station_spread || curh > _patches.station_spread) {
+ if (curw > _settings.station.station_spread || curh > _settings.station.station_spread) {
_error_message = STR_306C_STATION_TOO_SPREAD_OUT;
return false;
}
@@ -883,7 +883,7 @@
w_org = numtracks;
}
- if (h_org > _patches.station_spread || w_org > _patches.station_spread) return CMD_ERROR;
+ if (h_org > _settings.station.station_spread || w_org > _settings.station.station_spread) return CMD_ERROR;
/* these values are those that will be stored in train_tile and station_platforms */
uint finalvalues[3];
@@ -896,14 +896,14 @@
/* If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug
* for detail info, see:
* https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365 */
- CommandCost ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL);
+ CommandCost ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _settings.station.nonuniform_stations ? &est : NULL);
if (CmdFailed(ret)) return ret;
CommandCost cost(EXPENSES_CONSTRUCTION, ret.GetCost() + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len);
Station *st = NULL;
bool check_surrounding = true;
- if (_patches.adjacent_stations) {
+ if (_settings.station.adjacent_stations) {
if (est != INVALID_STATION) {
if (HasBit(p1, 24)) {
/* You can't build an adjacent station over the top of one that
@@ -938,7 +938,7 @@
if (st->train_tile != 0) {
/* check if we want to expanding an already existing station? */
- if (!_patches.join_stations)
+ if (!_settings.station.join_stations)
return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD);
if (!CanExpandRailroadStation(st, finalvalues, axis))
return CMD_ERROR;
@@ -993,7 +993,7 @@
/* Now really clear the land below the station
* It should never return CMD_ERROR.. but you never know ;)
* (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags) */
- ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _patches.nonuniform_stations ? &est : NULL);
+ ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _settings.station.nonuniform_stations ? &est : NULL);
if (CmdFailed(ret)) return ret;
st->train_tile = finalvalues[0];
@@ -1162,7 +1162,7 @@
/* Do not allow removing from stations if non-uniform stations are not enabled
* The check must be here to give correct error message
*/
- if (!_patches.nonuniform_stations) return_cmd_error(STR_NONUNIFORM_STATIONS_DISALLOWED);
+ if (!_settings.station.nonuniform_stations) return_cmd_error(STR_NONUNIFORM_STATIONS_DISALLOWED);
/* If we reached here, the tile is valid so increase the quantity of tiles we will remove */
quantity++;
@@ -1207,7 +1207,7 @@
static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
{
/* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */
- if (_current_player == OWNER_WATER && _patches.nonuniform_stations) {
+ if (_current_player == OWNER_WATER && _settings.station.nonuniform_stations) {
return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION);
}
@@ -1300,7 +1300,7 @@
bool type = HasBit(p2, 0);
bool is_drive_through = HasBit(p2, 1);
bool build_over_road = is_drive_through && IsNormalRoadTile(tile);
- bool town_owned_road = build_over_road && IsTileOwner(tile, OWNER_TOWN);
+ bool town_owned_road = false;
RoadTypes rts = (RoadTypes)GB(p2, 2, 3);
if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, rts)) return CMD_ERROR;
@@ -1319,14 +1319,17 @@
/* Not allowed to build over this road */
if (build_over_road) {
- if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD);
-
RoadTypes cur_rts = GetRoadTypes(tile);
/* there is a road, check if we can build road+tram stop over it */
if (HasBit(cur_rts, ROADTYPE_ROAD)) {
Owner road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
- if (road_owner != OWNER_TOWN && road_owner != OWNER_NONE && !CheckOwnership(road_owner)) return CMD_ERROR;
+ if (road_owner == OWNER_TOWN) {
+ town_owned_road = true;
+ if (!_settings.construction.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD);
+ } else {
+ if (road_owner != OWNER_NONE && !CheckOwnership(road_owner)) return CMD_ERROR;
+ }
}
/* there is a tram, check if we can build road+tram stop over it */
@@ -1347,7 +1350,7 @@
Station *st = NULL;
- if (!_patches.adjacent_stations || !HasBit(p2, 5)) {
+ if (!_settings.station.adjacent_stations || !HasBit(p2, 5)) {
st = GetStationAround(tile, 1, 1, INVALID_STATION);
if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
}
@@ -1610,6 +1613,88 @@
_airport_sections_helistation // Helistation
};
+/** Recalculate the noise generated by the airports of each town */
+void UpdateAirportsNoise()
+{
+ Town *t;
+ const Station *st;
+
+ FOR_ALL_TOWNS(t) t->noise_reached = 0;
+
+ FOR_ALL_STATIONS(st) {
+ if (IsAirport(st->xy)) {
+ st->town->noise_reached += GetAirportNoiseLevelForTown(GetAirport(st->airport_type), st->town->xy, st->xy);
+ }
+ }
+}
+
+/** Get a possible noise reduction factor based on distance from town center.
+ * The further you get, the less noise you generate.
+ * So all those folks at city council can now happily slee... work in their offices
+ * @param afc AirportFTAClass pointer of the class being proposed
+ * @param town_tile TileIndex of town's center, the one who will receive the airport's candidature
+ * @param tile TileIndex where the new airport might be built
+ * @return the noise that will be generated, according to distance
+ */
+uint8 GetAirportNoiseLevelForTown(const AirportFTAClass *afc, TileIndex town_tile, TileIndex tile)
+{
+ struct TileIndexDistance {
+ TileIndex index;
+ uint distance;
+ };
+
+ uint distance;
+
+ /* 0 cannot be accounted, and 1 is the lowest that can be reduced from town.
+ * So no need to go any further*/
+ if (afc->noise_level < 2) return afc->noise_level;
+
+ /* Find the airport-to-be's closest corner to the town */
+ if (afc->size_x == 1 && afc->size_y == 1) {
+ distance = DistanceManhattan(town_tile, tile); // ont tile, one corner, it's THE corner
+ } else {
+ /* calculate manhattan distance to town of each side of the airport */
+ TileIndexDistance dist[4]; ///< Array that will contain all 4 corners in TileIndex and distance
+ uint min_tile = UINT_MAX; ///< Sentinel value
+ uint min_indice = 4;
+
+ /* Based on the size of the airport, establish location of each corner*/
+ dist[0].index = tile; // north tile
+ dist[1].index = TileAddWrap(tile, afc->size_x - 1, afc->size_y - 1); // south tile
+ dist[2].index = TileAddWrap(tile, afc->size_x - 1, 0); // west tile
+ dist[3].index = TileAddWrap(tile, 0, afc->size_y - 1); //east tile
+
+ /* now, go and find the smallest one, thus the closest to town */
+ for (uint i = 0; i < 4; i++) {
+ dist[i].distance = DistanceManhattan(town_tile, dist[i].index);
+
+ if (dist[i].distance < min_tile) {
+ min_tile = dist[i].distance; // here's a new candidate
+ min_indice = i;
+ }
+ }
+
+ distance = dist[min_indice].distance;
+ }
+
+ /* The steps for measuring noise reduction are based on the "magical" (and arbitrary) 8 base distance
+ * adding the town_council_tolerance 4 times, as a way to graduate, depending of the tolerance.
+ * Basically, it says that the less tolerant a town is, the bigger the distance before
+ * an actual decrease can be granted */
+ uint8 town_tolerance_distance = 8 + (_settings.difficulty.town_council_tolerance * 4);
+
+ /* The airport is in the "inner" distance where there is no noise reduction */
+ if (distance < town_tolerance_distance) return afc->noise_level;
+
+ /* now, we want to have the distance segmented using the distance judged bareable by town
+ * This will give us the coefficient of reduction the distance provides. */
+ uint noise_reduction = min(afc->noise_level, distance / town_tolerance_distance);
+
+ /* If the noise reduction equals the airport noise itself, don't give it for free. Use it all minus 1.
+ * Otherwise, simply reduce the airport's level. */
+ return max(1U, noise_reduction == afc->noise_level ? afc->noise_level - 1 : afc->noise_level - noise_reduction);
+}
+
/** Place an Airport.
* @param tile tile where airport will be built
* @param flags operation to perform
@@ -1633,7 +1718,7 @@
int h = afc->size_y;
Station *st = NULL;
- if (w > _patches.station_spread || h > _patches.station_spread) {
+ if (w > _settings.station.station_spread || h > _settings.station.station_spread) {
_error_message = STR_306C_STATION_TOO_SPREAD_OUT;
return CMD_ERROR;
}
@@ -1641,17 +1726,30 @@
CommandCost cost = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
if (CmdFailed(cost)) return cost;
- /* Check if local auth refuses a new airport */
- uint num = 0;
- FOR_ALL_STATIONS(st) {
- if (st->town == t && st->facilities & FACIL_AIRPORT && st->airport_type != AT_OILRIG) num++;
+ /* Go get the final noise level, that is base noise minus factor from distance to town center */
+ uint newnoise_level = GetAirportNoiseLevelForTown(afc, t->xy, tile);
+
+ /* Check if local auth would allow a new airport */
+ bool authority_refused;
+
+ if (_settings.economy.station_noise_level) {
+ /* do not allow to build a new airport if this raise the town noise over the maximum allowed by town */
+ authority_refused = (t->noise_reached + newnoise_level) > t->MaxTownNoise();
+ } else {
+ uint num = 0;
+ const Station *st;
+ FOR_ALL_STATIONS(st) {
+ if (st->town == t && st->facilities & FACIL_AIRPORT && st->airport_type != AT_OILRIG) num++;
+ }
+ authority_refused = (num >= 2);
}
- if (num >= 2) {
+
+ if (authority_refused) {
SetDParam(0, t->index);
return_cmd_error(STR_2035_LOCAL_AUTHORITY_REFUSES);
}
- if (!_patches.adjacent_stations || !HasBit(p2, 0)) {
+ if (!_settings.station.adjacent_stations || !HasBit(p2, 0)) {
st = GetStationAround(tile, w, h, INVALID_STATION);
if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
} else {
@@ -1693,6 +1791,9 @@
cost.AddCost(_price.build_airport * w * h);
if (flags & DC_EXEC) {
+ /* Always add the noise, so there will be no need to recalculate when option toggles */
+ st->town->noise_reached += newnoise_level;
+
st->airport_tile = tile;
st->AddFacility(FACIL_AIRPORT, tile);
st->airport_type = (byte)p1;
@@ -1722,6 +1823,10 @@
UpdateStationAcceptance(st, false);
InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
+
+ if (_settings.economy.station_noise_level) {
+ InvalidateWindow(WC_TOWN_VIEW, st->town->index);
+ }
}
return cost;
@@ -1764,12 +1869,22 @@
);
}
+ /* Go get the final noise level, that is base noise minus factor from distance to town center.
+ * And as for construction, always remove it, even if the patch is not set, in order to avoid the
+ * need of recalculation */
+ st->town->noise_reached -= GetAirportNoiseLevelForTown(afc, st->town->xy, tile);
+
st->rect.AfterRemoveRect(st, tile, w, h);
st->airport_tile = 0;
st->facilities &= ~FACIL_AIRPORT;
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
+
+ if (_settings.economy.station_noise_level) {
+ InvalidateWindow(WC_TOWN_VIEW, st->town->index);
+ }
+
UpdateStationVirtCoordDirty(st);
DeleteStationIfEmpty(st);
}
@@ -1929,7 +2044,7 @@
/* middle */
Station *st = NULL;
- if (!_patches.adjacent_stations || !HasBit(p1, 0)) {
+ if (!_settings.station.adjacent_stations || !HasBit(p1, 0)) {
st = GetStationAround(
tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
_dock_w_chk[direction], _dock_h_chk[direction], INVALID_STATION);
@@ -2188,7 +2303,12 @@
static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
{
- td->owner = GetTileOwner(tile);
+ td->owner[0] = GetTileOwner(tile);
+ if (IsDriveThroughStopTile(tile) && HasTileRoadType(tile, ROADTYPE_ROAD) && GetStopBuiltOnTownRoad(tile)) {
+ /* Display a second owner */
+ td->owner_type[1] = STR_ROAD_OWNER;
+ td->owner[1] = OWNER_TOWN;
+ }
td->build_date = GetStationByTile(tile)->build_date;
StringID str;
@@ -2654,7 +2774,7 @@
int w_prod; // width and height of the "producer" of the cargo
int h_prod;
int max_rad;
- if (_patches.modified_catchment) {
+ if (_settings.station.modified_catchment) {
w_prod = w;
h_prod = h;
w += 2 * MAX_CATCHMENT;
@@ -2677,7 +2797,7 @@
if (st->IsBuoy()) continue; // bouys don't accept cargo
- if (_patches.modified_catchment) {
+ if (_settings.station.modified_catchment) {
/* min and max coordinates of the producer relative */
const int x_min_prod = max_rad + 1;
const int x_max_prod = max_rad + w_prod;
@@ -2731,7 +2851,7 @@
if (st->goods[type].rating == 0) continue; // Lowest possible rating, better not to give cargo anymore
- if (_patches.selectgoods && st->goods[type].last_speed == 0) continue; // Selectively servicing stations, and not this one
+ if (_settings.order.selectgoods && st->goods[type].last_speed == 0) continue; // Selectively servicing stations, and not this one
if (IsCargoInClass(type, CC_PASSENGERS)) {
if (st->facilities == FACIL_TRUCK_STOP) continue; // passengers are never served by just a truck stop
@@ -2875,16 +2995,15 @@
* Road stops built on town-owned roads check the conditions
* that would allow clearing of the original road.
* @param tile road stop tile to check
+ * @param flags command flags
* @return true if the road can be cleared
*/
-static bool CanRemoveRoadWithStop(TileIndex tile)
+static bool CanRemoveRoadWithStop(TileIndex tile, uint32 flags)
{
/* The road can always be cleared if it was not a town-owned road */
if (!GetStopBuiltOnTownRoad(tile)) return true;
- bool edge_road;
- return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_ROAD), OWNER_TOWN, &edge_road, ROADTYPE_ROAD) &&
- CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_TRAM), OWNER_TOWN, &edge_road, ROADTYPE_TRAM);
+ return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_ROAD), OWNER_TOWN, ROADTYPE_ROAD, flags);
}
static CommandCost ClearTile_Station(TileIndex tile, byte flags)
@@ -2909,11 +3028,11 @@
case STATION_RAIL: return RemoveRailroadStation(st, tile, flags);
case STATION_AIRPORT: return RemoveAirport(st, flags);
case STATION_TRUCK:
- if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile))
+ if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile, flags))
return_cmd_error(STR_3047_MUST_DEMOLISH_TRUCK_STATION);
return RemoveRoadStop(st, flags, tile);
case STATION_BUS:
- if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile))
+ if (IsDriveThroughStopTile(tile) && !CanRemoveRoadWithStop(tile, flags))
return_cmd_error(STR_3046_MUST_DEMOLISH_BUS_STATION);
return RemoveRoadStop(st, flags, tile);
case STATION_BUOY: return RemoveBuoy(st, flags);
@@ -2957,7 +3076,7 @@
static CommandCost TerraformTile_Station(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
{
- if (_patches.build_on_slopes && AutoslopeEnabled()) {
+ if (_settings.construction.build_on_slopes && AutoslopeEnabled()) {
/* TODO: If you implement newgrf callback 149 'land slope check', you have to decide what to do with it here.
* TTDP does not call it.
*/
--- a/src/station_func.h Mon May 26 11:36:42 2008 +0000
+++ b/src/station_func.h Mon May 26 13:52:59 2008 +0000
@@ -47,5 +47,6 @@
/* Check if a rail station tile is electrifiable. */
bool IsStationTileElectrifiable(TileIndex tile);
+void UpdateAirportsNoise();
#endif /* STATION_FUNC_H */
--- a/src/station_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/station_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -318,6 +318,8 @@
/* set up resort timer */
this->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
+
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
--- a/src/station_map.h Mon May 26 11:36:42 2008 +0000
+++ b/src/station_map.h Mon May 26 13:52:59 2008 +0000
@@ -134,6 +134,12 @@
return HasBit(_m[t].m6, 2);
}
+static inline void SetStopBuiltOnTownRoad(TileIndex t, bool on_town_road)
+{
+ assert(IsDriveThroughStopTile(t));
+ SB(_m[t].m6, 2, 1, on_town_road);
+}
+
/**
* Gets the direction the road stop entrance points towards.
--- a/src/station_type.h Mon May 26 11:36:42 2008 +0000
+++ b/src/station_type.h Mon May 26 13:52:59 2008 +0000
@@ -57,7 +57,7 @@
CA_TRAIN = 4,
CA_DOCK = 5,
- CA_UNMODIFIED = 4, ///< Used when _patches.modified_catchment is false
+ CA_UNMODIFIED = 4, ///< Used when _settings.station.modified_catchment is false
MAX_CATCHMENT = 10, ///< Airports have a catchment up to this number.
};
--- a/src/statusbar_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/statusbar_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -82,7 +82,7 @@
this->DrawWidgets();
SetDParam(0, _date);
- DrawStringCentered(70, 1, (_pause_game || _patches.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING);
+ DrawStringCentered(70, 1, (_pause_game || _settings.gui.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING);
if (p != NULL) {
/* Draw player money */
--- a/src/strings.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/strings.cpp Mon May 26 13:52:59 2008 +0000
@@ -546,7 +546,7 @@
*/
uint ConvertSpeedToDisplaySpeed(uint speed)
{
- return (speed * units[_opt_ptr->units].s_m) >> units[_opt_ptr->units].s_s;
+ return (speed * units[_settings.gui.units].s_m) >> units[_settings.gui.units].s_s;
}
/**
@@ -556,7 +556,7 @@
*/
uint ConvertDisplaySpeedToSpeed(uint speed)
{
- return ((speed << units[_opt_ptr->units].s_s) + units[_opt_ptr->units].s_m / 2) / units[_opt_ptr->units].s_m;
+ return ((speed << units[_settings.gui.units].s_s) + units[_settings.gui.units].s_m / 2) / units[_settings.gui.units].s_m;
}
static char* FormatString(char* buff, const char* str, const int64* argv, uint casei, const char* last)
@@ -602,9 +602,9 @@
case SCC_VELOCITY: {// {VELOCITY}
int64 args[1];
- assert(_opt_ptr->units < lengthof(units));
+ assert(_settings.gui.units < lengthof(units));
args[0] = ConvertSpeedToDisplaySpeed(GetInt32(&argv));
- buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].velocity), args, modifier >> 24, last);
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].velocity), args, modifier >> 24, last);
modifier = 0;
break;
}
@@ -625,18 +625,18 @@
switch (cargo_str) {
case STR_TONS: {
int64 args[1];
- assert(_opt_ptr->units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt_ptr->units].w_m >> units[_opt_ptr->units].w_s;
- buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].l_weight), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].w_m >> units[_settings.gui.units].w_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_weight), args, modifier >> 24, last);
modifier = 0;
break;
}
case STR_LITERS: {
int64 args[1];
- assert(_opt_ptr->units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt_ptr->units].v_m >> units[_opt_ptr->units].v_s;
- buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].l_volume), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].v_m >> units[_settings.gui.units].v_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_volume), args, modifier >> 24, last);
modifier = 0;
break;
}
@@ -718,9 +718,9 @@
case SCC_VOLUME: { // {VOLUME}
int64 args[1];
- assert(_opt_ptr->units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt_ptr->units].v_m >> units[_opt_ptr->units].v_s;
- buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].l_volume), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].v_m >> units[_settings.gui.units].v_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_volume), args, modifier >> 24, last);
modifier = 0;
break;
}
@@ -763,45 +763,45 @@
case SCC_POWER: { // {POWER}
int64 args[1];
- assert(_opt_ptr->units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt_ptr->units].p_m >> units[_opt_ptr->units].p_s;
- buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].power), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].p_m >> units[_settings.gui.units].p_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].power), args, modifier >> 24, last);
modifier = 0;
break;
}
case SCC_VOLUME_SHORT: { // {VOLUME_S}
int64 args[1];
- assert(_opt_ptr->units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt_ptr->units].v_m >> units[_opt_ptr->units].v_s;
- buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].s_volume), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].v_m >> units[_settings.gui.units].v_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].s_volume), args, modifier >> 24, last);
modifier = 0;
break;
}
case SCC_WEIGHT: { // {WEIGHT}
int64 args[1];
- assert(_opt_ptr->units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt_ptr->units].w_m >> units[_opt_ptr->units].w_s;
- buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].l_weight), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].w_m >> units[_settings.gui.units].w_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_weight), args, modifier >> 24, last);
modifier = 0;
break;
}
case SCC_WEIGHT_SHORT: { // {WEIGHT_S}
int64 args[1];
- assert(_opt_ptr->units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt_ptr->units].w_m >> units[_opt_ptr->units].w_s;
- buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].s_weight), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].w_m >> units[_settings.gui.units].w_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].s_weight), args, modifier >> 24, last);
modifier = 0;
break;
}
case SCC_FORCE: { // {FORCE}
int64 args[1];
- assert(_opt_ptr->units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt_ptr->units].f_m >> units[_opt_ptr->units].f_s;
- buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].force), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].f_m >> units[_settings.gui.units].f_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].force), args, modifier >> 24, last);
modifier = 0;
break;
}
@@ -1137,7 +1137,7 @@
const char* const* base;
uint num;
- if (_opt_ptr->landscape == LT_TOYLAND) {
+ if (_settings.game_creation.landscape == LT_TOYLAND) {
base = _silly_surname_list;
num = lengthof(_silly_surname_list);
} else {
@@ -1167,7 +1167,7 @@
buff = strecpy(buff, initial, last);
}
- if (_opt_ptr->landscape == LT_TOYLAND) {
+ if (_settings.game_creation.landscape == LT_TOYLAND) {
base = _silly_surname_list;
num = lengthof(_silly_surname_list);
} else {
--- a/src/subsidy_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/subsidy_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -22,6 +22,7 @@
struct SubsidyListWindow : Window {
SubsidyListWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnClick(Point pt, int widget)
@@ -117,11 +118,14 @@
/* Displays the two offered towns */
SetupSubsidyDecodeParam(s, 1);
- x2 = DrawStringTruncated(x + 2, y, STR_2027_FROM_TO, TC_FROMSTRING, width);
+ x2 = DrawStringTruncated(x + 2, y, STR_2027_FROM_TO, TC_FROMSTRING, width - 2);
- /* Displays the deadline before voiding the proposal */
- SetDParam(0, _date - ymd.day + 384 - s->age * 32);
- DrawStringTruncated(x2, y, STR_2028_BY, TC_FROMSTRING, width - x2);
+ if (width - x2 > 10) {
+ /* Displays the deadline before voiding the proposal */
+ SetDParam(0, _date - ymd.day + 384 - s->age * 32);
+ DrawStringTruncated(x2, y, STR_2028_BY, TC_FROMSTRING, width - x2);
+ }
+
y += 10;
num++;
}
--- a/src/table/ai_rail.h Mon May 26 11:36:42 2008 +0000
+++ b/src/table/ai_rail.h Mon May 26 13:52:59 2008 +0000
@@ -593,15 +593,27 @@
MKEND(),
};
+static const AiDefaultBlockData _airportdata_ai_6[] = {
+ MKAIR(6, 0, 0),
+ MKEND(),
+};
+
static const AiDefaultBlockData _airportdata_ai_7[] = {
MKAIR(7, 0, 0),
MKEND(),
};
+static const AiDefaultBlockData _airportdata_ai_8[] = {
+ MKAIR(8, 0, 0),
+ MKEND(),
+};
+
#undef MKAIR
#undef MDEND
static const AiDefaultBlockData * const _airport_default_block_data[] = {
+ _airportdata_ai_8, // helistation
+ _airportdata_ai_6, // helidepot
_airportdata_ai_7, // intercontinental airport
_airportdata_ai_4, // international airport
_airportdata_ai_3, // metropolitan airport
--- a/src/terraform_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/terraform_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -183,29 +183,45 @@
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LEVEL_AREA);
}
+/** Enum referring to the widgets of the terraform toolbar */
+enum TerraformToolbarWidgets {
+ TTW_CLOSEBOX = 0, ///< Close window button
+ TTW_CAPTION, ///< Window caption
+ TTW_STICKY, ///< Sticky window button
+ TTW_SEPERATOR, ///< Thin seperator line between level land button and demolish button
+ TTW_BUTTONS_START, ///< Start of pushable buttons
+ TTW_LOWER_LAND = TTW_BUTTONS_START, ///< Lower land button
+ TTW_RAISE_LAND, ///< Raise land button
+ TTW_LEVEL_LAND, ///< Level land button
+ TTW_DEMOLISH, ///< Demolish aka dynamite button
+ TTW_BUY_LAND, ///< Buy land button
+ TTW_PLANT_TREES, ///< Plant trees button (note: opens seperate window, no place-push-button)
+ TTW_PLACE_SIGN, ///< Place sign button
+};
+
static void TerraformClick_Lower(Window *w)
{
- HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerLand);
+ HandlePlacePushButton(w, TTW_LOWER_LAND, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerLand);
}
static void TerraformClick_Raise(Window *w)
{
- HandlePlacePushButton(w, 5, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseLand);
+ HandlePlacePushButton(w, TTW_RAISE_LAND, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseLand);
}
static void TerraformClick_Level(Window *w)
{
- HandlePlacePushButton(w, 6, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
+ HandlePlacePushButton(w, TTW_LEVEL_LAND, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
}
static void TerraformClick_Dynamite(Window *w)
{
- HandlePlacePushButton(w, 7, ANIMCURSOR_DEMOLISH , VHM_RECT, PlaceProc_DemolishArea);
+ HandlePlacePushButton(w, TTW_DEMOLISH, ANIMCURSOR_DEMOLISH , VHM_RECT, PlaceProc_DemolishArea);
}
static void TerraformClick_BuyLand(Window *w)
{
- HandlePlacePushButton(w, 8, SPR_CURSOR_BUY_LAND, VHM_RECT, PlaceProc_BuyLand);
+ HandlePlacePushButton(w, TTW_BUY_LAND, SPR_CURSOR_BUY_LAND, VHM_RECT, PlaceProc_BuyLand);
}
static void TerraformClick_Trees(Window *w)
@@ -216,7 +232,7 @@
static void TerraformClick_PlaceSign(Window *w)
{
- HandlePlacePushButton(w, 10, SPR_CURSOR_SIGN, VHM_RECT, PlaceProc_Sign);
+ HandlePlacePushButton(w, TTW_PLACE_SIGN, SPR_CURSOR_SIGN, VHM_RECT, PlaceProc_Sign);
}
static OnButtonClick * const _terraform_button_proc[] = {
@@ -246,7 +262,7 @@
virtual void OnClick(Point pt, int widget)
{
- if (widget >= 4) _terraform_button_proc[widget - 4](this);
+ if (widget >= TTW_BUTTONS_START) _terraform_button_proc[widget - TTW_BUTTONS_START](this);
}
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
@@ -292,18 +308,18 @@
};
static const Widget _terraform_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 7, 11, 145, 0, 13, STR_LANDSCAPING_TOOLBAR, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{WWT_STICKYBOX, RESIZE_NONE, 7, 146, 157, 0, 13, STR_NULL, STR_STICKY_BUTTON},
+{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // TTW_CLOSEBOX
+{ WWT_CAPTION, RESIZE_NONE, 7, 11, 145, 0, 13, STR_LANDSCAPING_TOOLBAR, STR_018C_WINDOW_TITLE_DRAG_THIS}, // TTW_CAPTION
+{WWT_STICKYBOX, RESIZE_NONE, 7, 146, 157, 0, 13, STR_NULL, STR_STICKY_BUTTON}, // TTW_STICKY
-{ WWT_PANEL, RESIZE_NONE, 7, 66, 69, 14, 35, 0x0, STR_NULL},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 70, 91, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 92, 113, 14, 35, SPR_IMG_BUY_LAND, STR_0329_PURCHASE_LAND_FOR_FUTURE},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_PLANTTREES, STR_0185_PLANT_TREES_PLACE_SIGNS},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_SIGN, STR_0289_PLACE_SIGN},
+{ WWT_PANEL, RESIZE_NONE, 7, 66, 69, 14, 35, 0x0, STR_NULL}, // TTW_SEPERATOR
+{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND}, // TTW_LOWER_LAND
+{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND}, // TTW_RAISE_LAND
+{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP}, // TTW_LEVEL_LAND
+{ WWT_IMGBTN, RESIZE_NONE, 7, 70, 91, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // TTW_DEMOLISH
+{ WWT_IMGBTN, RESIZE_NONE, 7, 92, 113, 14, 35, SPR_IMG_BUY_LAND, STR_0329_PURCHASE_LAND_FOR_FUTURE}, // TTW_BUY_LAND
+{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_PLANTTREES, STR_0185_PLANT_TREES_PLACE_SIGNS}, // TTW_PLANT_TREES
+{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_SIGN, STR_0289_PLACE_SIGN}, // TTW_PLACE_SIGN
{ WIDGETS_END},
};
@@ -324,8 +340,8 @@
* toolbar to left of it
*/
w->top = 22;
+ w->SetDirty();
link->left = w->left - link->width;
-
link->SetDirty();
}
}
@@ -438,23 +454,23 @@
}
static const Widget _scen_edit_land_gen_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 7, 11, 191, 0, 13, STR_0223_LAND_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_STICKYBOX, RESIZE_NONE, 7, 192, 203, 0, 13, STR_NULL, STR_STICKY_BUTTON},
-{ WWT_PANEL, RESIZE_NONE, 7, 0, 203, 14, 102, 0x0, STR_NULL},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 23, 16, 37, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 24, 45, 16, 37, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 46, 67, 16, 37, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 68, 89, 16, 37, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 90, 111, 16, 37, SPR_IMG_BUILD_CANAL, STR_CREATE_LAKE},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 112, 133, 16, 37, SPR_IMG_BUILD_RIVER, STR_CREATE_RIVER},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 134, 156, 16, 37, SPR_IMG_ROCKS, STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 157, 179, 16, 37, SPR_IMG_LIGHTHOUSE_DESERT, STR_NULL}, // XXX - dynamic
-{ WWT_IMGBTN, RESIZE_NONE, 14, 180, 201, 16, 37, SPR_IMG_TRANSMITTER, STR_028E_PLACE_TRANSMITTER},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 150, 161, 45, 56, SPR_ARROW_UP, STR_0228_INCREASE_SIZE_OF_LAND_AREA},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 150, 161, 58, 69, SPR_ARROW_DOWN, STR_0229_DECREASE_SIZE_OF_LAND_AREA},
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 24, 179, 76, 87, STR_SE_NEW_WORLD, STR_022A_GENERATE_RANDOM_LAND},
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 24, 179, 89, 100, STR_022B_RESET_LANDSCAPE, STR_RESET_LANDSCAPE_TOOLTIP},
+{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // ETTW_CLOSEBOX
+{ WWT_CAPTION, RESIZE_NONE, 7, 11, 191, 0, 13, STR_0223_LAND_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, // ETTW_CAPTION
+{ WWT_STICKYBOX, RESIZE_NONE, 7, 192, 203, 0, 13, STR_NULL, STR_STICKY_BUTTON}, // ETTW_STICKY
+{ WWT_PANEL, RESIZE_NONE, 7, 0, 203, 14, 102, 0x0, STR_NULL}, // ETTW_BACKGROUND
+{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 23, 16, 37, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC}, // ETTW_DEMOLISH
+{ WWT_IMGBTN, RESIZE_NONE, 14, 24, 45, 16, 37, SPR_IMG_TERRAFORM_DOWN, STR_018E_LOWER_A_CORNER_OF_LAND}, // ETTW_LOWER_LAND
+{ WWT_IMGBTN, RESIZE_NONE, 14, 46, 67, 16, 37, SPR_IMG_TERRAFORM_UP, STR_018F_RAISE_A_CORNER_OF_LAND}, // ETTW_RAISE_LAND
+{ WWT_IMGBTN, RESIZE_NONE, 14, 68, 89, 16, 37, SPR_IMG_LEVEL_LAND, STR_LEVEL_LAND_TOOLTIP}, // ETTW_LEVEL_LAND
+{ WWT_IMGBTN, RESIZE_NONE, 14, 90, 111, 16, 37, SPR_IMG_BUILD_CANAL, STR_CREATE_LAKE}, // ETTW_BUILD_CANAL
+{ WWT_IMGBTN, RESIZE_NONE, 14, 112, 133, 16, 37, SPR_IMG_BUILD_RIVER, STR_CREATE_RIVER}, // ETTW_BUILD_RIVER
+{ WWT_IMGBTN, RESIZE_NONE, 14, 134, 156, 16, 37, SPR_IMG_ROCKS, STR_028C_PLACE_ROCKY_AREAS_ON_LANDSCAPE}, // ETTW_PLACE_ROCKS
+{ WWT_IMGBTN, RESIZE_NONE, 14, 157, 179, 16, 37, SPR_IMG_LIGHTHOUSE_DESERT, STR_NULL}, // ETTW_PLACE_DESERT_LIGHTHOUSE XXX - dynamic
+{ WWT_IMGBTN, RESIZE_NONE, 14, 180, 201, 16, 37, SPR_IMG_TRANSMITTER, STR_028E_PLACE_TRANSMITTER}, // ETTW_PLACE_TRANSMITTER
+{ WWT_IMGBTN, RESIZE_NONE, 14, 150, 161, 45, 56, SPR_ARROW_UP, STR_0228_INCREASE_SIZE_OF_LAND_AREA}, // ETTW_INCREASE_SIZE
+{ WWT_IMGBTN, RESIZE_NONE, 14, 150, 161, 58, 69, SPR_ARROW_DOWN, STR_0229_DECREASE_SIZE_OF_LAND_AREA}, // ETTW_DECREASE_SIZE
+{ WWT_TEXTBTN, RESIZE_NONE, 14, 24, 179, 76, 87, STR_SE_NEW_WORLD, STR_022A_GENERATE_RANDOM_LAND}, // ETTW_NEW_SCENARIO
+{ WWT_TEXTBTN, RESIZE_NONE, 14, 24, 179, 89, 100, STR_022B_RESET_LANDSCAPE, STR_RESET_LANDSCAPE_TOOLTIP}, // ETTW_RESET_LANDSCAPE
{ WIDGETS_END},
};
@@ -469,53 +485,77 @@
{-28, 0}, {-24, -2}, {-20, -4}, {-16, -6}, {-12, -8}, { -8,-10}, { -4,-12}, { 0,-14}, { 4,-12}, { 8,-10}, { 12, -8}, { 16, -6}, { 20, -4}, { 24, -2}, { 28, 0},
};
+/** Enum referring to the widgets of the editor terraform toolbar */
+enum EditorTerraformToolbarWidgets {
+ ETTW_START = 0, ///< Used for iterations
+ ETTW_CLOSEBOX = ETTW_START, ///< Close window button
+ ETTW_CAPTION, ///< Window caption
+ ETTW_STICKY, ///< Sticky window button
+ ETTW_BACKGROUND, ///< Background of the lower part of the window
+ ETTW_BUTTONS_START, ///< Start of pushable buttons
+ ETTW_DEMOLISH = ETTW_BUTTONS_START, ///< Demolish aka dynamite button
+ ETTW_LOWER_LAND, ///< Lower land button
+ ETTW_RAISE_LAND, ///< Raise land button
+ ETTW_LEVEL_LAND, ///< Level land button
+ ETTW_BUILD_CANAL, ///< Build canal button
+ ETTW_BUILD_RIVER, ///< Build river button
+ ETTW_PLACE_ROCKS, ///< Place rocks button
+ ETTW_PLACE_DESERT_LIGHTHOUSE, ///< Place desert button (in tropical climate) / place lighthouse button (else)
+ ETTW_PLACE_TRANSMITTER, ///< Place transmitter button
+ ETTW_BUTTONS_END, ///< End of pushable buttons
+ ETTW_INCREASE_SIZE = ETTW_BUTTONS_END, ///< Upwards arrow button to increase terraforming size
+ ETTW_DECREASE_SIZE, ///< Downwards arrow button to decrease terraforming size
+ ETTW_NEW_SCENARIO, ///< Button for generating a new scenario
+ ETTW_RESET_LANDSCAPE, ///< Button for removing all player-owned property
+};
+
/**
* @todo Merge with terraform_gui.cpp (move there) after I have cooled down at its braindeadness
* and changed OnButtonClick to include the widget as well in the function declaration. Post 0.4.0 - Darkvater
*/
static void EditorTerraformClick_Dynamite(Window *w)
{
- HandlePlacePushButton(w, 4, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
+ HandlePlacePushButton(w, ETTW_DEMOLISH, ANIMCURSOR_DEMOLISH, VHM_RECT, PlaceProc_DemolishArea);
}
static void EditorTerraformClick_LowerBigLand(Window *w)
{
- HandlePlacePushButton(w, 5, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerBigLand);
+ HandlePlacePushButton(w, ETTW_LOWER_LAND, ANIMCURSOR_LOWERLAND, VHM_POINT, PlaceProc_LowerBigLand);
}
static void EditorTerraformClick_RaiseBigLand(Window *w)
{
- HandlePlacePushButton(w, 6, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseBigLand);
+ HandlePlacePushButton(w, ETTW_RAISE_LAND, ANIMCURSOR_RAISELAND, VHM_POINT, PlaceProc_RaiseBigLand);
}
static void EditorTerraformClick_LevelLand(Window *w)
{
- HandlePlacePushButton(w, 7, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
+ HandlePlacePushButton(w, ETTW_LEVEL_LAND, SPR_CURSOR_LEVEL_LAND, VHM_POINT, PlaceProc_LevelLand);
}
static void EditorTerraformClick_WaterArea(Window *w)
{
- HandlePlacePushButton(w, 8, SPR_CURSOR_CANAL, VHM_RECT, PlaceProc_WaterArea);
+ HandlePlacePushButton(w, ETTW_BUILD_CANAL, SPR_CURSOR_CANAL, VHM_RECT, PlaceProc_WaterArea);
}
static void EditorTerraformClick_RiverArea(Window *w)
{
- HandlePlacePushButton(w, 9, SPR_CURSOR_RIVER, VHM_RECT, PlaceProc_RiverArea);
+ HandlePlacePushButton(w, ETTW_BUILD_RIVER, SPR_CURSOR_RIVER, VHM_RECT, PlaceProc_RiverArea);
}
static void EditorTerraformClick_RockyArea(Window *w)
{
- HandlePlacePushButton(w, 10, SPR_CURSOR_ROCKY_AREA, VHM_RECT, PlaceProc_RockyArea);
+ HandlePlacePushButton(w, ETTW_PLACE_ROCKS, SPR_CURSOR_ROCKY_AREA, VHM_RECT, PlaceProc_RockyArea);
}
static void EditorTerraformClick_DesertLightHouse(Window *w)
{
- HandlePlacePushButton(w, 11, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
+ HandlePlacePushButton(w, ETTW_PLACE_DESERT_LIGHTHOUSE, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_settings.game_creation.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
}
static void EditorTerraformClick_Transmitter(Window *w)
{
- HandlePlacePushButton(w, 12, SPR_CURSOR_TRANSMITTER, VHM_RECT, PlaceProc_Transmitter);
+ HandlePlacePushButton(w, ETTW_PLACE_TRANSMITTER, SPR_CURSOR_TRANSMITTER, VHM_RECT, PlaceProc_Transmitter);
}
static const uint16 _editor_terraform_keycodes[] = {
@@ -575,8 +615,7 @@
struct ScenarioEditorLandscapeGenerationWindow : Window {
ScenarioEditorLandscapeGenerationWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
- /* XXX - lighthouse button is widget 11!! Don't forget when changing */
- this->widget[11].tooltips = (_opt.landscape == LT_TROPIC) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE;
+ this->widget[ETTW_PLACE_DESERT_LIGHTHOUSE].tooltips = (_settings.game_creation.landscape == LT_TROPIC) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE;
this->FindWindowPlacementAndResize(desc);
}
@@ -592,7 +631,7 @@
coords += 2;
} while (--n);
- if (this->IsWidgetLowered(5) || this->IsWidgetLowered(6)) { // change area-size if raise/lower corner is selected
+ if (this->IsWidgetLowered(ETTW_LOWER_LAND) || this->IsWidgetLowered(ETTW_RAISE_LAND)) { // change area-size if raise/lower corner is selected
SetTileSelectSize(_terraform_size, _terraform_size);
}
}
@@ -610,43 +649,45 @@
virtual void OnClick(Point pt, int widget)
{
- switch (widget) {
- case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
- _editor_terraform_button_proc[widget - 4](this);
- break;
- case 13: case 14: { // Increase/Decrease terraform size
- int size = (widget == 13) ? 1 : -1;
- this->HandleButtonClick(widget);
- size += _terraform_size;
-
- if (!IsInsideMM(size, 1, 8 + 1)) return;
- _terraform_size = size;
+ if (IsInsideMM(widget, ETTW_BUTTONS_START, ETTW_BUTTONS_END)) {
+ _editor_terraform_button_proc[widget - ETTW_BUTTONS_START](this);
+ } else {
+ switch (widget) {
+ case ETTW_INCREASE_SIZE:
+ case ETTW_DECREASE_SIZE: { // Increase/Decrease terraform size
+ int size = (widget == ETTW_INCREASE_SIZE) ? 1 : -1;
+ this->HandleButtonClick(widget);
+ size += _terraform_size;
- SndPlayFx(SND_15_BEEP);
- this->SetDirty();
- } break;
- case 15: // gen random land
- this->HandleButtonClick(15);
- ShowCreateScenario();
- break;
- case 16: // Reset landscape
- ShowQuery(
- STR_022C_RESET_LANDSCAPE,
- STR_RESET_LANDSCAPE_CONFIRMATION_TEXT,
- NULL,
- ResetLandscapeConfirmationCallback);
- break;
+ if (!IsInsideMM(size, 1, 8 + 1)) return;
+ _terraform_size = size;
+
+ SndPlayFx(SND_15_BEEP);
+ this->SetDirty();
+ } break;
+ case ETTW_NEW_SCENARIO: // gen random land
+ this->HandleButtonClick(widget);
+ ShowCreateScenario();
+ break;
+ case ETTW_RESET_LANDSCAPE: // Reset landscape
+ ShowQuery(
+ STR_022C_RESET_LANDSCAPE,
+ STR_RESET_LANDSCAPE_CONFIRMATION_TEXT,
+ NULL,
+ ResetLandscapeConfirmationCallback);
+ break;
+ }
}
}
virtual void OnTimeout()
{
- for (uint i = 0; i < this->widget_count; i++) {
+ for (uint i = ETTW_START; i < this->widget_count; i++) {
+ if (i == ETTW_BUTTONS_START) i = ETTW_BUTTONS_END; // skip the buttons
if (this->IsWidgetLowered(i)) {
this->RaiseWidget(i);
this->InvalidateWidget(i);
}
- if (i == 3) i = 12;
}
}
--- a/src/textbuf_gui.h Mon May 26 11:36:42 2008 +0000
+++ b/src/textbuf_gui.h Mon May 26 13:52:59 2008 +0000
@@ -28,8 +28,10 @@
void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth);
void UpdateTextBufferSize(Textbuf *tb);
+typedef void QueryCallbackProc(Window*, bool);
+
void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth, Window *parent, CharSetFilter afilter);
-void ShowQuery(StringID caption, StringID message, Window *w, void (*callback)(Window*, bool));
+void ShowQuery(StringID caption, StringID message, Window *w, QueryCallbackProc *callback);
/** The number of 'characters' on the on-screen keyboard. */
static const uint OSK_KEYBOARD_ENTRIES = 50;
--- a/src/texteff.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/texteff.cpp Mon May 26 13:52:59 2008 +0000
@@ -6,7 +6,7 @@
#include "openttd.h"
#include "landscape.h"
#include "gfx_func.h"
-#include "console.h"
+#include "console_func.h"
#include "variables.h"
#include "blitter/factory.hpp"
#include "texteff.hpp"
@@ -392,7 +392,7 @@
dpi->top <= te->bottom &&
dpi->left + dpi->width > te->x &&
dpi->top + dpi->height > te->y) {
- if (te->mode == TE_RISING || (_patches.loading_indicators && !IsTransparencySet(TO_LOADING))) {
+ if (te->mode == TE_RISING || (_settings.gui.loading_indicators && !IsTransparencySet(TO_LOADING))) {
AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2);
}
}
@@ -407,7 +407,7 @@
dpi->top <= te->bottom * 2 - te->y &&
dpi->left + dpi->width > te->x &&
dpi->top + dpi->height > te->y) {
- if (te->mode == TE_RISING || (_patches.loading_indicators && !IsTransparencySet(TO_LOADING))) {
+ if (te->mode == TE_RISING || (_settings.gui.loading_indicators && !IsTransparencySet(TO_LOADING))) {
AddStringToDraw(te->x, te->y, (StringID)(te->string_id - 1), te->params_1, te->params_2);
}
}
--- a/src/tgp.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/tgp.cpp Mon May 26 13:52:59 2008 +0000
@@ -10,7 +10,6 @@
#include "variables.h"
#include "void_map.h"
#include "tgp.h"
-#include "console.h"
#include "genworld.h"
#include "core/alloc_func.hpp"
#include "core/random_func.hpp"
@@ -212,10 +211,10 @@
{1500, 1000, 1200, 1000, 500, 32, 20, 0, 0, 0, 0, 0},
};
-/** Desired water percentage (100% == 1024) - indexed by _opt.diff.quantity_sea_lakes */
+/** Desired water percentage (100% == 1024) - indexed by _settings.difficulty.quantity_sea_lakes */
static const amplitude_t _water_percent[4] = {20, 80, 250, 400};
-/** Desired maximum height - indexed by _opt.diff.terrain_type */
+/** Desired maximum height - indexed by _settings.difficulty.terrain_type */
static const int8 _max_height[4] = {
6, ///< Very flat
9, ///< Flat
@@ -343,7 +342,7 @@
do {
log_frequency = iteration_round - log_frequency_min;
if (log_frequency >= 0) {
- amplitude = _amplitudes_by_smoothness_and_frequency[_patches.tgen_smoothness][log_frequency];
+ amplitude = _amplitudes_by_smoothness_and_frequency[_settings.game_creation.tgen_smoothness][log_frequency];
} else {
amplitude = 0;
}
@@ -403,7 +402,7 @@
/* Transform height into 0..1 space */
fheight = (double)(*h - h_min) / (double)(h_max - h_min);
/* Apply sine transform depending on landscape type */
- switch(_opt.landscape) {
+ switch(_settings.game_creation.landscape) {
case LT_TOYLAND:
case LT_TEMPERATE:
/* Move and scale 0..1 into -1..+1 */
@@ -532,7 +531,7 @@
*/
static void HeightMapCoastLines()
{
- int smallest_size = min(_patches.map_x, _patches.map_y);
+ int smallest_size = min(_settings.game_creation.map_x, _settings.game_creation.map_y);
const int margin = 4;
uint y, x;
double max_x;
@@ -662,9 +661,9 @@
* - height histogram redistribution by sine wave transform */
static void HeightMapNormalize()
{
- const amplitude_t water_percent = _water_percent[_opt.diff.quantity_sea_lakes];
- const height_t h_max_new = I2H(_max_height[_opt.diff.terrain_type]);
- const height_t roughness = 7 + 3 * _patches.tgen_smoothness;
+ const amplitude_t water_percent = _water_percent[_settings.difficulty.quantity_sea_lakes];
+ const height_t h_max_new = I2H(_max_height[_settings.difficulty.terrain_type]);
+ const height_t roughness = 7 + 3 * _settings.game_creation.tgen_smoothness;
HeightMapAdjustWaterLevel(water_percent, h_max_new);
@@ -693,7 +692,7 @@
*/
static double int_noise(const long x, const long y, const int prime)
{
- long n = x + y * prime + _patches.generation_seed;
+ long n = x + y * prime + _settings.game_creation.generation_seed;
n = (n << 13) ^ n;
--- a/src/tile_cmd.h Mon May 26 11:36:42 2008 +0000
+++ b/src/tile_cmd.h Mon May 26 13:52:59 2008 +0000
@@ -49,7 +49,8 @@
struct TileDesc {
StringID str;
- Owner owner;
+ Owner owner[4];
+ StringID owner_type[4];
Date build_date;
uint64 dparam[2];
};
--- a/src/timetable_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/timetable_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -54,7 +54,7 @@
*/
CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- if (!_patches.timetabling) return CMD_ERROR;
+ if (!_settings.order.timetabling) return CMD_ERROR;
VehicleID veh = GB(p1, 0, 16);
if (!IsValidVehicleID(veh)) return CMD_ERROR;
@@ -90,7 +90,7 @@
*/
CommandCost CmdSetVehicleOnTime(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- if (!_patches.timetabling) return CMD_ERROR;
+ if (!_settings.order.timetabling) return CMD_ERROR;
VehicleID veh = GB(p1, 0, 16);
if (!IsValidVehicleID(veh)) return CMD_ERROR;
@@ -116,7 +116,7 @@
*/
CommandCost CmdAutofillTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- if (!_patches.timetabling) return CMD_ERROR;
+ if (!_settings.order.timetabling) return CMD_ERROR;
VehicleID veh = GB(p1, 0, 16);
if (!IsValidVehicleID(veh)) return CMD_ERROR;
@@ -157,7 +157,7 @@
v->current_order_time = 0;
- if (!_patches.timetabling) return;
+ if (!_settings.order.timetabling) return;
/* Make sure the timetable only starts when the vehicle reaches the first
* order, not when travelling from the depot to the first station. */
--- a/src/timetable_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/timetable_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -38,7 +38,7 @@
void SetTimetableParams(int param1, int param2, uint32 time)
{
- if (_patches.timetable_in_ticks) {
+ if (_settings.gui.timetable_in_ticks) {
SetDParam(param1, STR_TIMETABLE_TICKS);
SetDParam(param2, time);
} else {
@@ -56,6 +56,8 @@
this->vscroll.cap = 8;
this->resize.step_height = 10;
this->sel_index = -1;
+
+ this->FindWindowPlacementAndResize(desc);
}
int GetOrderFromTimetableWndPt(int y, const Vehicle *v)
@@ -170,7 +172,7 @@
}
y += 10;
- if (v->lateness_counter == 0 || (!_patches.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) {
+ if (v->lateness_counter == 0 || (!_settings.gui.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) {
DrawString(2, y, STR_TIMETABLE_STATUS_ON_TIME, TC_BLACK);
} else {
SetTimetableParams(0, 1, abs(v->lateness_counter));
@@ -220,7 +222,7 @@
if (order != NULL) {
uint time = (selected % 2 == 1) ? order->travel_time : order->wait_time;
- if (!_patches.timetable_in_ticks) time /= DAY_TICKS;
+ if (!_settings.gui.timetable_in_ticks) time /= DAY_TICKS;
if (time != 0) {
SetDParam(0, time);
@@ -257,7 +259,7 @@
uint32 p1 = PackTimetableArgs(v, this->sel_index);
uint64 time = StrEmpty(str) ? 0 : strtoul(str, NULL, 10);
- if (!_patches.timetable_in_ticks) time *= DAY_TICKS;
+ if (!_settings.gui.timetable_in_ticks) time *= DAY_TICKS;
uint32 p2 = minu(time, MAX_UVALUE(uint16));
--- a/src/toolbar_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/toolbar_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -35,7 +35,7 @@
#include "signs_func.h"
#include "fios.h"
#include "functions.h"
-#include "console.h"
+#include "console_gui.h"
#include "news_gui.h"
#include "ai/ai_gui.hpp"
#include "tilehighlight_func.h"
@@ -544,8 +544,8 @@
w->HandleButtonClick(6);
w->SetDirty();
- _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year - 1, MIN_YEAR, MAX_YEAR);
- SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
+ _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year - 1, MIN_YEAR, MAX_YEAR);
+ SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
}
_left_button_clicked = false;
}
@@ -557,8 +557,8 @@
w->HandleButtonClick(7);
w->SetDirty();
- _patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + 1, MIN_YEAR, MAX_YEAR);
- SetDate(ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
+ _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + 1, MIN_YEAR, MAX_YEAR);
+ SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
}
_left_button_clicked = false;
}
@@ -907,8 +907,8 @@
virtual void OnPaint()
{
- this->SetWidgetDisabledState(6, _patches_newgame.starting_year <= MIN_YEAR);
- this->SetWidgetDisabledState(7, _patches_newgame.starting_year >= MAX_YEAR);
+ this->SetWidgetDisabledState(6, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
+ this->SetWidgetDisabledState(7, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
/* Draw brown-red toolbar bg. */
GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
@@ -916,7 +916,7 @@
this->DrawWidgets();
- SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
+ SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
DrawStringCenteredTruncated(this->widget[6].right, this->widget[7].left, 6, STR_00AF, TC_FROMSTRING);
/* We hide this panel when the toolbar space gets too small */
@@ -1155,7 +1155,7 @@
ToolbarMenuWindow(int x, int y, int width, int height, const Widget *widgets, int item_count,
int sel_index, int parent_button, StringID base_string, int checked_items,
- int disabled_mask) :
+ int disabled_items) :
Window(x, y, width, height, WC_TOOLBAR_MENU, widgets),
item_count(item_count), sel_index(sel_index), main_button(GB(parent_button, 0, 8)),
action_id((GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button),
@@ -1324,6 +1324,8 @@
this->sel_index = 0;
}
}
+
+ this->FindWindowPlacementAndResize(width, height);
}
~ToolbarPlayerMenuWindow()
--- a/src/town.h Mon May 26 11:36:42 2008 +0000
+++ b/src/town.h Mon May 26 13:52:59 2008 +0000
@@ -116,6 +116,9 @@
* bit 2 = STADIUM */
byte flags12;
+ /* level of noise that all the airports are generating */
+ uint16 noise_reached;
+
/* Which players have a statue? */
byte statues;
@@ -184,6 +187,18 @@
void InitializeLayout();
inline TownLayout GetActiveLayout() const;
+
+ /** Calculate the max town noise
+ * The value is counted using the population divided by the content of the
+ * entry in town_noise_population corespondig to the town's tolerance.
+ * To this result, we add 3, which is the noise of the lowest airport.
+ * So user can at least buld that airport
+ * @return the maximum noise level the town will tolerate */
+ inline uint16 MaxTownNoise() const {
+ if (this->population == 0) return 0; // no population? no noise
+
+ return ((this->population / _settings.economy.town_noise_population[_settings.difficulty.town_council_tolerance]) + 3);
+ }
};
/**
@@ -192,7 +207,7 @@
*/
inline TownLayout Town::GetActiveLayout() const
{
- return (_patches.town_layout == TL_RANDOM) ? this->layout : _patches.town_layout;
+ return (_settings.economy.town_layout == TL_RANDOM) ? this->layout : _settings.economy.town_layout;
}
struct HouseSpec {
--- a/src/town_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/town_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -324,7 +324,7 @@
SetDParam(0, t->index);
SetDParam(1, t->population);
UpdateViewportSignPos(&t->sign, pt.x, pt.y - 24,
- _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL);
+ _settings.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL);
MarkTownSignDirty(t);
}
@@ -596,7 +596,7 @@
if (callback != CALLBACK_FAILED) {
if (accepts[0] != CT_INVALID) ac[accepts[0]] = GB(callback, 0, 4);
if (accepts[1] != CT_INVALID) ac[accepts[1]] = GB(callback, 4, 4);
- if (_opt.landscape != LT_TEMPERATE && HasBit(callback, 12)) {
+ if (_settings.game_creation.landscape != LT_TEMPERATE && HasBit(callback, 12)) {
/* The 'S' bit indicates food instead of goods */
ac[CT_FOOD] = GB(callback, 8, 4);
} else {
@@ -620,7 +620,7 @@
td->str = STR_2058_UNDER_CONSTRUCTION;
}
- td->owner = OWNER_TOWN;
+ td->owner[0] = OWNER_TOWN;
}
static TrackStatus GetTileTrackStatus_Town(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
@@ -1212,14 +1212,14 @@
do target_dir = RandomDiagDir(); while (!(cur_rb & DiagDirToRoadBits(target_dir)));
tile = TileAddByDiagDir(tile, target_dir);
- if (IsTileType(tile, MP_ROAD)) {
+ if (IsTileType(tile, MP_ROAD) && !IsRoadDepot(tile) && HasTileRoadType(tile, ROADTYPE_ROAD)) {
/* Don't allow building over roads of other cities */
- if (IsTileOwner(tile, OWNER_TOWN) && GetTownByTile(tile) != t) {
+ if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN) && GetTownByTile(tile) != t) {
_grow_town_result = GROWTH_SUCCEED;
- } else if (IsTileOwner(tile, OWNER_NONE) && _game_mode == GM_EDITOR) {
+ } else if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_NONE) && _game_mode == GM_EDITOR) {
/* If we are in the SE, and this road-piece has no town owner yet, it just found an
* owner :) (happy happy happy road now) */
- SetTileOwner(tile, OWNER_TOWN);
+ SetRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN);
SetTownIndex(tile, t->index);
}
}
@@ -1255,7 +1255,7 @@
/* Let the town be a ghost town
* The player wanted it in such a way. Thus there he has it. ;)
* Never reached in editor mode. */
- if (_patches.town_layout == TL_NO_ROADS && _generating_world) {
+ if (_settings.economy.town_layout == TL_NO_ROADS && _generating_world) {
return false;
}
@@ -1367,9 +1367,9 @@
* the other towns may take considerable amount of time (10000 is
* too much). */
int tries = 1000;
- bool grf = (_opt.town_name >= _nb_orig_names);
- uint32 grfid = grf ? GetGRFTownNameId(_opt.town_name - _nb_orig_names) : 0;
- uint16 townnametype = grf ? GetGRFTownNameType(_opt.town_name - _nb_orig_names) : SPECSTR_TOWNNAME_START + _opt.town_name;
+ bool grf = (_settings.game_creation.town_name >= _nb_orig_names);
+ uint32 grfid = grf ? GetGRFTownNameId(_settings.game_creation.town_name - _nb_orig_names) : 0;
+ uint16 townnametype = grf ? GetGRFTownNameType(_settings.game_creation.town_name - _nb_orig_names) : SPECSTR_TOWNNAME_START + _settings.game_creation.town_name;
assert(townnameparts != NULL);
@@ -1453,14 +1453,14 @@
t->exclusive_counter = 0;
t->statues = 0;
- if (_opt.town_name < _nb_orig_names) {
+ if (_settings.game_creation.town_name < _nb_orig_names) {
/* Original town name */
t->townnamegrfid = 0;
- t->townnametype = SPECSTR_TOWNNAME_START + _opt.town_name;
+ t->townnametype = SPECSTR_TOWNNAME_START + _settings.game_creation.town_name;
} else {
/* Newgrf town name */
- t->townnamegrfid = GetGRFTownNameId(_opt.town_name - _nb_orig_names);
- t->townnametype = GetGRFTownNameType(_opt.town_name - _nb_orig_names);
+ t->townnamegrfid = GetGRFTownNameId(_settings.game_creation.town_name - _nb_orig_names);
+ t->townnametype = GetGRFTownNameType(_settings.game_creation.town_name - _nb_orig_names);
}
t->townnameparts = townnameparts;
@@ -1485,11 +1485,13 @@
break;
case TSM_CITY:
- x *= _patches.initial_city_size;
+ x *= _settings.economy.initial_city_size;
t->larger_town = true;
break;
}
+ t->noise_reached = 0;
+
t->num_houses += x;
UpdateTownRadius(t);
@@ -1578,13 +1580,13 @@
return NULL;
}
-static const byte _num_initial_towns[4] = {5, 11, 23, 46};
+static const byte _num_initial_towns[4] = {5, 11, 23, 46}; // very low, low, normal, high
bool GenerateTowns()
{
uint num = 0;
- uint n = ScaleByMapSize(_num_initial_towns[_opt.diff.number_towns] + (Random() & 7));
- uint num_cities = _patches.larger_towns == 0 ? 0 : n / _patches.larger_towns;
+ uint n = ScaleByMapSize(_num_initial_towns[_settings.difficulty.number_towns] + (Random() & 7));
+ uint num_cities = _settings.economy.larger_towns == 0 ? 0 : n / _settings.economy.larger_towns;
SetGeneratingWorldProgress(GWP_TOWN, n);
@@ -1592,7 +1594,7 @@
IncreaseGeneratingWorldProgress(GWP_TOWN);
/* try 20 times to create a random-sized town for the first loop. */
TownSizeMode mode = num_cities > 0 ? TSM_CITY : TSM_RANDOM;
- if (CreateRandomTown(20, mode, _patches.initial_city_size) != NULL) num++;
+ if (CreateRandomTown(20, mode, _settings.economy.initial_city_size) != NULL) num++;
if (num_cities > 0) num_cities--;
} while (--n);
@@ -1877,8 +1879,8 @@
HouseZonesBits rad = GetTownRadiusGroup(t, tile);
/* Above snow? */
- int land = _opt.landscape;
- if (land == LT_ARCTIC && z >= _opt.snow_line) land = -1;
+ int land = _settings.game_creation.landscape;
+ if (land == LT_ARCTIC && z >= _settings.game_creation.snow_line) land = -1;
uint bitmask = (1 << rad) + (1 << (land + 12));
@@ -2217,7 +2219,7 @@
static void TownActionBuyRights(Town *t)
{
/* Check if it's allowed to by the rights */
- if (!_patches.exclusive_rights) return;
+ if (!_settings.economy.exclusive_rights) return;
t->exclusive_counter = 12;
t->exclusivity = _current_player;
@@ -2331,7 +2333,7 @@
}
ClrBit(t->flags12, TOWN_IS_FUNDED);
- if (_patches.town_growth_rate == 0 && t->fund_buildings_months == 0) return;
+ if (_settings.economy.town_growth_rate == 0 && t->fund_buildings_months == 0) return;
/** Towns are processed every TOWN_GROWTH_FREQUENCY ticks, and this is the
* number of times towns are processed before a new building is built. */
@@ -2350,17 +2352,17 @@
if (n == 0 && !Chance16(1, 12)) return;
}
- if (_opt.landscape == LT_ARCTIC) {
+ if (_settings.game_creation.landscape == LT_ARCTIC) {
if (TilePixelHeight(t->xy) >= GetSnowLine() && t->act_food == 0 && t->population > 90)
return;
- } else if (_opt.landscape == LT_TROPIC) {
+ } else if (_settings.game_creation.landscape == LT_TROPIC) {
if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food == 0 || t->act_water == 0) && t->population > 60)
return;
}
/* Use the normal growth rate values if new buildings have been funded in
* this town and the growth rate is set to none. */
- uint growth_multiplier = _patches.town_growth_rate != 0 ? _patches.town_growth_rate - 1 : 1;
+ uint growth_multiplier = _settings.economy.town_growth_rate != 0 ? _settings.economy.town_growth_rate - 1 : 1;
m >>= growth_multiplier;
if (t->larger_town) m /= 2;
@@ -2403,7 +2405,7 @@
{
if (!IsValidPlayer(_current_player)) return true;
- Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
+ Town *t = ClosestTownFromTile(tile, _settings.economy.dist_local_authority);
if (t == NULL) return true;
if (t->ratings[_current_player] > RATING_VERYPOOR) return true;
@@ -2436,8 +2438,8 @@
Town *ClosestTownFromTile(TileIndex tile, uint threshold)
{
if (IsTileType(tile, MP_HOUSE) || (
- IsTileType(tile, MP_ROAD) &&
- GetRoadOwner(tile, ROADTYPE_ROAD) == OWNER_TOWN
+ IsTileType(tile, MP_ROAD) && HasTileRoadType(tile, ROADTYPE_ROAD) &&
+ IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN)
)) {
return GetTownByTile(tile);
} else {
@@ -2522,7 +2524,7 @@
* owned by a town no removal if rating is lower than ... depends now on
* difficulty setting. Minimum town rating selected by difficulty level
*/
- int modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type];
+ int modemod = _default_rating_settings[_settings.difficulty.town_council_tolerance][type];
if (GetRating(t) < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
SetDParam(0, t->index);
--- a/src/town_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/town_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -31,16 +31,6 @@
extern bool GenerateTowns();
static int _scengen_town_size = 1; // depress medium-sized towns per default
-enum TownAuthorityWidget {
- TWA_CLOSEBOX = 0,
- TWA_CAPTION,
- TWA_RATING_INFO,
- TWA_COMMAND_LIST,
- TWA_SCROLLBAR,
- TWA_ACTION_INFO,
- TWA_EXECUTE,
-};
-
static const Widget _town_authority_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // TWA_CLOSEBOX
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 316, 0, 13, STR_2022_LOCAL_AUTHORITY, STR_018C_WINDOW_TITLE_DRAG_THIS}, // TWA_CAPTION
@@ -86,7 +76,7 @@
TownActions buttons = TACT_NONE;
/* Spectators and unwanted have no options */
- if (pid != PLAYER_SPECTATOR && !(_patches.bribe && t->unwanted[pid])) {
+ if (pid != PLAYER_SPECTATOR && !(_settings.economy.bribe && t->unwanted[pid])) {
/* Things worth more than this are not shown */
Money avail = GetPlayer(pid)->player_money + _price.station_value * 200;
@@ -98,11 +88,11 @@
const TownActions cur = (TownActions)(1 << i);
/* Is the player not able to bribe ? */
- if (cur == TACT_BRIBE && (!_patches.bribe || t->ratings[pid] >= RATING_BRIBE_MAXIMUM))
+ if (cur == TACT_BRIBE && (!_settings.economy.bribe || t->ratings[pid] >= RATING_BRIBE_MAXIMUM))
continue;
/* Is the player not able to buy exclusive rights ? */
- if (cur == TACT_BUY_RIGHTS && !_patches.exclusive_rights)
+ if (cur == TACT_BUY_RIGHTS && !_settings.economy.exclusive_rights)
continue;
/* Is the player not able to build a statue ? */
@@ -142,11 +132,25 @@
}
struct TownAuthorityWindow : Window {
+private:
+ Town *town;
int sel_index;
+ enum TownAuthorityWidget {
+ TWA_CLOSEBOX = 0,
+ TWA_CAPTION,
+ TWA_RATING_INFO,
+ TWA_COMMAND_LIST,
+ TWA_SCROLLBAR,
+ TWA_ACTION_INFO,
+ TWA_EXECUTE,
+ };
+
+public:
TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) :
Window(desc, window_number), sel_index(-1)
{
+ this->town = GetTown(this->window_number);
this->vscroll.cap = 5;
this->FindWindowPlacementAndResize(desc);
@@ -154,9 +158,8 @@
virtual void OnPaint()
{
- const Town *t = GetTown(this->window_number);
int numact;
- uint buttons = GetMaskOfTownActions(&numact, _local_player, t);
+ uint buttons = GetMaskOfTownActions(&numact, _local_player, this->town);
SetVScrollCount(this, numact + 1);
@@ -176,13 +179,13 @@
const Player *p;
FOR_ALL_PLAYERS(p) {
- if (p->is_active && (HasBit(t->have_ratings, p->index) || t->exclusivity == p->index)) {
+ if (p->is_active && (HasBit(this->town->have_ratings, p->index) || this->town->exclusivity == p->index)) {
DrawPlayerIcon(p->index, 2, y);
SetDParam(0, p->index);
SetDParam(1, p->index);
- int r = t->ratings[p->index];
+ int r = this->town->ratings[p->index];
StringID str;
(str = STR_3035_APPALLING, r <= RATING_APPALLING) || // Apalling
(str++, r <= RATING_VERYPOOR) || // Very Poor
@@ -194,7 +197,7 @@
(str++, true); // Outstanding
SetDParam(2, str);
- if (t->exclusivity == p->index) { // red icon for player with exclusive rights
+ if (this->town->exclusivity == p->index) { // red icon for player with exclusive rights
DrawSprite(SPR_BLOT, PALETTE_TO_RED, 18, y);
}
@@ -233,12 +236,11 @@
{
switch (widget) {
case TWA_COMMAND_LIST: {
- const Town *t = GetTown(this->window_number);
int y = (pt.y - 0x6B) / 10;
if (!IsInsideMM(y, 0, 5)) return;
- y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, t), y + this->vscroll.pos - 1);
+ y = GetNthSetBit(GetMaskOfTownActions(NULL, _local_player, this->town), y + this->vscroll.pos - 1);
if (y >= 0) {
this->sel_index = y;
this->SetDirty();
@@ -248,7 +250,7 @@
}
case TWA_EXECUTE:
- DoCommandP(GetTown(this->window_number)->xy, this->window_number, this->sel_index, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
+ DoCommandP(this->town->xy, this->window_number, this->sel_index, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
break;
}
}
@@ -271,27 +273,32 @@
AllocateWindowDescFront<TownAuthorityWindow>(&_town_authority_desc, town);
}
+struct TownViewWindow : Window {
+private:
+ Town *town;
-enum TownViewWidget {
- TVW_CAPTION = 1,
- TVW_STICKY,
- TVW_CENTERVIEW = 6,
- TVW_SHOWAUTORITY,
- TVW_CHANGENAME,
- TVW_EXPAND,
- TVW_DELETE,
-};
+ enum TownViewWidget {
+ TVW_CAPTION = 1,
+ TVW_STICKY,
+ TVW_VIEWPORTPANEL,
+ TVW_INFOPANEL = 5,
+ TVW_CENTERVIEW,
+ TVW_SHOWAUTORITY,
+ TVW_CHANGENAME,
+ TVW_EXPAND,
+ TVW_DELETE,
+ };
-struct TownViewWindow : Window {
+public:
TownViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
- const Town *t = GetTown(this->window_number);
+ this->town = GetTown(this->window_number);
+ bool ingame = _game_mode != GM_EDITOR;
this->flags4 |= WF_DISABLE_VP_SCROLL;
- InitializeWindowViewport(this, 3, 17, 254, 86, t->xy, ZOOM_LVL_TOWN);
+ InitializeWindowViewport(this, 3, 17, 254, 86, this->town->xy, ZOOM_LVL_TOWN);
- bool ingame = _game_mode != GM_EDITOR;
- if (t->larger_town) this->widget[TVW_CAPTION].data = STR_CITY;
+ if (this->town->larger_town) this->widget[TVW_CAPTION].data = STR_CITY;
this->SetWidgetHiddenState(TVW_DELETE, ingame); // hide delete button on game mode
this->SetWidgetHiddenState(TVW_EXPAND, ingame); // hide expand button on game mode
this->SetWidgetHiddenState(TVW_SHOWAUTORITY, !ingame); // hide autority button on editor mode
@@ -305,44 +312,52 @@
this->widget[TVW_CHANGENAME].right = this->widget[TVW_STICKY].right;
}
+ /* Space required for showing noise level information */
+ if (_settings.economy.station_noise_level) {
+ ResizeWindowForWidget(this, TVW_INFOPANEL, 0, 10);
+ }
+
this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
{
- const Town *t = GetTown(this->window_number);
-
/* disable renaming town in network games if you are not the server */
this->SetWidgetDisabledState(TVW_CHANGENAME, _networking && !_network_server);
- SetDParam(0, t->index);
+ SetDParam(0, this->town->index);
this->DrawWidgets();
- SetDParam(0, t->population);
- SetDParam(1, t->num_houses);
+ SetDParam(0, this->town->population);
+ SetDParam(1, this->town->num_houses);
DrawString(2, 107, STR_2006_POPULATION, TC_FROMSTRING);
- SetDParam(0, t->act_pass);
- SetDParam(1, t->max_pass);
+ SetDParam(0, this->town->act_pass);
+ SetDParam(1, this->town->max_pass);
DrawString(2, 117, STR_200D_PASSENGERS_LAST_MONTH_MAX, TC_FROMSTRING);
- SetDParam(0, t->act_mail);
- SetDParam(1, t->max_mail);
+ SetDParam(0, this->town->act_mail);
+ SetDParam(1, this->town->max_mail);
DrawString(2, 127, STR_200E_MAIL_LAST_MONTH_MAX, TC_FROMSTRING);
this->DrawViewport();
+
+ /* only show the town noise, if the noise option is activated. */
+ if (_settings.economy.station_noise_level) {
+ SetDParam(0, this->town->noise_reached);
+ SetDParam(1, this->town->MaxTownNoise());
+ DrawString(2, 137, STR_NOISE_IN_TOWN, 0);
+ }
}
virtual void OnClick(Point pt, int widget)
{
- Town *t = GetTown(this->window_number);
-
switch (widget) {
case TVW_CENTERVIEW: /* scroll to location */
if (_ctrl_pressed) {
- ShowExtraViewPortWindow(t->xy);
+ ShowExtraViewPortWindow(this->town->xy);
} else {
- ScrollMainWindowToTile(t->xy);
+ ScrollMainWindowToTile(this->town->xy);
}
break;
@@ -356,15 +371,31 @@
break;
case TVW_EXPAND: /* expand town - only available on Scenario editor */
- ExpandTown(t);
+ ExpandTown(this->town);
break;
case TVW_DELETE: /* delete town - only available on Scenario editor */
- delete t;
+ delete this->town;
break;
}
}
+ virtual void OnInvalidateData(int data = 0)
+ {
+ /* Called when setting station noise have changed, in order to resize the window */
+ this->SetDirty(); // refresh display for current size. This will allow to avoid glitches when downgrading
+
+ if (_settings.economy.station_noise_level) { // adjust depending
+ if (this->height == 150) { // window is smaller, needs to be bigger
+ ResizeWindowForWidget(this, TVW_INFOPANEL, 0, 10);
+ }
+ } else {
+ if (this->height != 150) { // window is bigger, needs to be smaller
+ ResizeWindowForWidget(this, TVW_INFOPANEL, 0, -10);
+ }
+ }
+ }
+
virtual void OnQueryTextFinished(char *str)
{
if (!StrEmpty(str)) {
@@ -476,12 +507,14 @@
struct TownDirectoryWindow : public Window {
+private:
enum TownDirectoryWidget {
TDW_SORTNAME = 3,
TDW_SORTPOPULATION,
TDW_CENTERTOWN,
};
+public:
TownDirectoryWindow(const WindowDesc *desc) : Window(desc, 0)
{
this->vscroll.cap = 16;
@@ -585,6 +618,7 @@
void ShowTownDirectory()
{
+ if (BringWindowToFrontById(WC_TOWN_DIRECTORY, 0)) return;
new TownDirectoryWindow(&_town_directory_desc);
}
@@ -603,16 +637,6 @@
DoCommandP(tile, size, mode, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE));
}
-enum TownScenarioEditorWidget {
- TSEW_NEWTOWN = 4,
- TSEW_RANDOMTOWN,
- TSEW_MANYRANDOMTOWNS,
- TSEW_SMALLTOWN,
- TSEW_MEDIUMTOWN,
- TSEW_LARGETOWN,
- TSEW_CITY,
-};
-
static const Widget _scen_edit_town_gen_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
@@ -631,9 +655,22 @@
struct ScenarioEditorTownGenerationWindow : Window
{
+private:
+ enum TownScenarioEditorWidget {
+ TSEW_NEWTOWN = 4,
+ TSEW_RANDOMTOWN,
+ TSEW_MANYRANDOMTOWNS,
+ TSEW_SMALLTOWN,
+ TSEW_MEDIUMTOWN,
+ TSEW_LARGETOWN,
+ TSEW_CITY,
+ };
+
+public:
ScenarioEditorTownGenerationWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
this->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN);
+ this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
--- a/src/town_type.h Mon May 26 11:36:42 2008 +0000
+++ b/src/town_type.h Mon May 26 13:52:59 2008 +0000
@@ -54,7 +54,8 @@
RATING_INDUSTRY_DOWN_STEP = -1500,
RATING_INDUSTRY_MINIMUM = RATING_MINIMUM,
- RATING_ROAD_DOWN_STEP = -50,
+ RATING_ROAD_DOWN_STEP_INNER = -50, ///< removing a roadpiece in the middle
+ RATING_ROAD_DOWN_STEP_EDGE = -18, ///< removing a roadpiece at the edge
RATING_ROAD_MINIMUM = -100,
RATING_HOUSE_MINIMUM = RATING_MINIMUM,
--- a/src/train_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/train_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -93,7 +93,7 @@
byte FreightWagonMult(CargoID cargo)
{
if (!GetCargo(cargo)->is_freight) return 1;
- return _patches.freight_trains;
+ return _settings.vehicle.freight_trains;
}
@@ -279,7 +279,7 @@
}
/* max speed is the minimum of the speed limits of all vehicles in the consist */
- if ((rvi_u->railveh_type != RAILVEH_WAGON || _patches.wagon_speed_limits) && !UsesWagonOverride(u)) {
+ if ((rvi_u->railveh_type != RAILVEH_WAGON || _settings.vehicle.wagon_speed_limits) && !UsesWagonOverride(u)) {
uint16 speed = GetVehicleProperty(u, 0x09, rvi_u->max_speed);
if (speed != 0) max_speed = min(speed, max_speed);
}
@@ -727,7 +727,7 @@
Vehicle *v = vl[0];
UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_TRAIN);
- if (unit_num > _patches.max_trains)
+ if (unit_num > _settings.vehicle.max_trains)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) {
@@ -766,7 +766,7 @@
v->u.rail.railtype = rvi->railtype;
_new_vehicle_id = v->index;
- v->service_interval = _patches.servint_trains;
+ v->service_interval = _settings.vehicle.servint_trains;
v->date_of_last_service = _date;
v->build_year = _cur_year;
v->cur_image = 0xAC2;
@@ -1002,7 +1002,7 @@
if (HasBit(p2, 0) && src_head == dst_head) return CommandCost();
{
- int max_len = _patches.mammoth_trains ? 100 : 10;
+ int max_len = _settings.vehicle.mammoth_trains ? 100 : 10;
/* check if all vehicles in the source train are stopped inside a depot. */
int src_len = CheckTrainStoppedInDepot(src_head);
@@ -1045,7 +1045,7 @@
/* moving a loco to a new line?, then we need to assign a unitnumber. */
if (dst == NULL && !IsFrontEngine(src) && IsTrainEngine(src)) {
UnitID unit_num = GetFreeUnitNumber(VEH_TRAIN);
- if (unit_num > _patches.max_trains)
+ if (unit_num > _settings.vehicle.max_trains)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) src->unitnumber = unit_num;
@@ -1545,7 +1545,7 @@
int old = v->u.rail.last_speed;
if (spd != old) {
v->u.rail.last_speed = spd;
- if (_patches.vehicle_speed || (old == 0) != (spd == 0)) {
+ if (_settings.gui.vehicle_speed || (old == 0) != (spd == 0)) {
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
}
}
@@ -1884,7 +1884,7 @@
if (v->vehstatus & VS_CRASHED || v->breakdown_ctr != 0) return CMD_ERROR;
if (flags & DC_EXEC) {
- if (_patches.realistic_acceleration && v->cur_speed != 0) {
+ if (_settings.vehicle.realistic_acceleration && v->cur_speed != 0) {
ToggleBit(v->u.rail.flags, VRF_REVERSING);
} else {
v->cur_speed = 0;
@@ -2059,7 +2059,7 @@
return tfdd;
}
- switch (_patches.pathfinder_for_trains) {
+ switch (_settings.pf.pathfinder_for_trains) {
case VPF_YAPF: { /* YAPF */
bool found = YapfFindNearestRailDepotTwoWay(v, max_distance, NPF_INFINITE_PENALTY, &tfdd.tile, &tfdd.reverse);
tfdd.best_length = found ? max_distance / 2 : UINT_MAX; // some fake distance or NOT_FOUND
@@ -2370,7 +2370,7 @@
/* quick return in case only one possible track is available */
if (KillFirstBit(tracks) == TRACK_BIT_NONE) return FindFirstTrack(tracks);
- switch (_patches.pathfinder_for_trains) {
+ switch (_settings.pf.pathfinder_for_trains) {
case VPF_YAPF: { /* YAPF */
Trackdir trackdir = YapfChooseRailTrack(v, tile, enterdir, tracks, &path_not_found);
if (trackdir != INVALID_TRACKDIR) {
@@ -2447,7 +2447,7 @@
/* it is first time the problem occurred, set the "path not found" flag */
SetBit(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
/* and notify user about the event */
- if (_patches.lost_train_warn && v->owner == _local_player) {
+ if (_settings.gui.lost_train_warn && v->owner == _local_player) {
SetDParam(0, v->unitnumber);
AddNewsItem(
STR_TRAIN_IS_LOST,
@@ -2476,7 +2476,7 @@
static bool CheckReverseTrain(Vehicle *v)
{
- if (_opt.diff.line_reverse_mode != 0 ||
+ if (_settings.difficulty.line_reverse_mode != 0 ||
v->u.rail.track == TRACK_BIT_DEPOT || v->u.rail.track == TRACK_BIT_WORMHOLE ||
!(v->direction & 1)) {
return false;
@@ -2489,7 +2489,7 @@
assert(v->u.rail.track);
- switch (_patches.pathfinder_for_trains) {
+ switch (_settings.pf.pathfinder_for_trains) {
case VPF_YAPF: /* YAPF */
reverse_best = YapfCheckReverseTrain(v);
break;
@@ -2609,13 +2609,13 @@
uint accel;
if (v->vehstatus & VS_STOPPED || HasBit(v->u.rail.flags, VRF_REVERSING)) {
- if (_patches.realistic_acceleration) {
+ if (_settings.vehicle.realistic_acceleration) {
accel = GetTrainAcceleration(v, AM_BRAKE) * 2;
} else {
accel = v->acceleration * -2;
}
} else {
- if (_patches.realistic_acceleration) {
+ if (_settings.vehicle.realistic_acceleration) {
accel = GetTrainAcceleration(v, AM_ACCEL);
} else {
accel = v->acceleration;
@@ -2756,7 +2756,7 @@
/** Modify the speed of the vehicle due to a turn */
static inline void AffectSpeedByDirChange(Vehicle *v, Direction new_dir)
{
- if (_patches.realistic_acceleration) return;
+ if (_settings.vehicle.realistic_acceleration) return;
DirDiff diff = DirDifference(v->direction, new_dir);
if (diff == DIRDIFF_SAME) return;
@@ -2768,7 +2768,7 @@
/** Modify the speed of the vehicle due to a change in altitude */
static inline void AffectSpeedByZChange(Vehicle *v, byte old_z)
{
- if (old_z == v->z_pos || _patches.realistic_acceleration) return;
+ if (old_z == v->z_pos || _settings.vehicle.realistic_acceleration) return;
const RailtypeSlowdownParams *rsp = &_railtype_slowdown[v->u.rail.railtype];
@@ -2809,10 +2809,10 @@
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
- BEGIN_ENUM_WAGONS(v)
+ for (; v != NULL; v = v->Next()) {
v->vehstatus |= VS_CRASHED;
MarkSingleVehicleDirty(v);
- END_ENUM_WAGONS(v)
+ }
/* must be updated after the train has been marked crashed */
if (crossing != INVALID_TILE) UpdateLevelCrossing(crossing);
@@ -2821,9 +2821,11 @@
static uint CountPassengersInTrain(const Vehicle *v)
{
uint num = 0;
- BEGIN_ENUM_WAGONS(v)
+
+ for (; v != NULL; v = v->Next()) {
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) num += v->cargo.Count();
- END_ENUM_WAGONS(v)
+ }
+
return num;
}
@@ -2972,7 +2974,7 @@
TrackBits red_signals = TrackdirBitsToTrackBits(TrackStatusToRedSignals(ts) & reachable_trackdirs);
TrackBits bits = TrackdirBitsToTrackBits(trackdirbits);
- if (_patches.pathfinder_for_trains != VPF_NTP && _patches.forbid_90_deg && prev == NULL) {
+ if (_settings.pf.pathfinder_for_trains != VPF_NTP && _settings.pf.forbid_90_deg && prev == NULL) {
/* We allow wagons to make 90 deg turns, because forbid_90_deg
* can be switched on halfway a turn */
bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track));
@@ -3000,12 +3002,12 @@
v->cur_speed = 0;
v->subspeed = 0;
v->progress = 255 - 100;
- if (++v->load_unload_time_rem < _patches.wait_oneway_signal * 20) return;
+ if (++v->load_unload_time_rem < _settings.pf.wait_oneway_signal * 20) return;
} else if (HasSignalOnTrackdir(gp.new_tile, i)) {
v->cur_speed = 0;
v->subspeed = 0;
v->progress = 255 - 10;
- if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) {
+ if (++v->load_unload_time_rem < _settings.pf.wait_twoway_signal * 73) {
TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir);
Direction rdir = ReverseDir(dir);
@@ -3247,7 +3249,7 @@
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
- SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ?
+ SndPlayVehicleFx((_settings.game_creation.landscape != LT_TOYLAND) ?
SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
}
@@ -3407,7 +3409,7 @@
/* mask unreachable track bits if we are forbidden to do 90deg turns */
TrackBits bits = TrackdirBitsToTrackBits(trackdirbits);
- if (_patches.pathfinder_for_trains != VPF_NTP && _patches.forbid_90_deg) {
+ if (_settings.pf.pathfinder_for_trains != VPF_NTP && _settings.pf.forbid_90_deg) {
bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track));
}
@@ -3540,7 +3542,7 @@
{
static const uint MAX_ACCEPTABLE_DEPOT_DIST = 16;
- if (_patches.servint_trains == 0 || !v->NeedsAutomaticServicing()) return;
+ if (_settings.vehicle.servint_trains == 0 || !v->NeedsAutomaticServicing()) return;
if (v->IsInDepot()) {
VehicleServiceInDepot(v);
return;
@@ -3616,7 +3618,7 @@
if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
/* show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
if (v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
- if (_patches.train_income_warn && v->owner == _local_player) {
+ if (_settings.gui.train_income_warn && v->owner == _local_player) {
SetDParam(1, v->GetDisplayProfitThisYear());
SetDParam(0, v->unitnumber);
AddNewsItem(
@@ -3657,9 +3659,7 @@
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
- Vehicle *u = v;
-
- BEGIN_ENUM_WAGONS(u) {
+ for (Vehicle *u = v; u != NULL; u = u->Next()) {
if (u->u.rail.other_multiheaded_part != NULL) continue; // we already linked this one
if (IsMultiheaded(u)) {
@@ -3684,7 +3684,7 @@
ClearMultiheaded(u);
}
}
- } END_ENUM_WAGONS(u)
+ }
}
}
}
@@ -3705,9 +3705,7 @@
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN) {
if (HasBit(v->subtype, 7) && ((v->subtype & ~0x80) == 0 || (v->subtype & ~0x80) == 4)) {
- Vehicle *u = v;
-
- BEGIN_ENUM_WAGONS(u) {
+ for (Vehicle *u = v; u != NULL; u = u->Next()) {
const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
ClrBit(u->subtype, 7);
@@ -3746,7 +3744,7 @@
break;
default: NOT_REACHED(); break;
}
- } END_ENUM_WAGONS(u)
+ }
}
}
}
--- a/src/train_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/train_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -28,8 +28,8 @@
if (!success) return;
/* find a locomotive in the depot. */
- Vehicle *found = NULL;
- Vehicle *v;
+ const Vehicle *found = NULL;
+ const Vehicle *v;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN && IsFrontEngine(v) &&
v->tile == tile &&
@@ -124,7 +124,7 @@
SetDParam(0, v->cargo_type);
SetDParam(1, v->cargo.Count());
SetDParam(2, v->cargo.Source());
- SetDParam(3, _patches.freight_trains);
+ SetDParam(3, _settings.vehicle.freight_trains);
str = FreightWagonMult(v->cargo_type) > 1 ? STR_FROM_MULT : STR_8813_FROM;
}
DrawString(x, y, str, TC_FROMSTRING);
@@ -150,7 +150,7 @@
if (v->cargo_cap != 0) {
SetDParam(0, v->cargo_type);
SetDParam(1, v->cargo_cap);
- SetDParam(2, _patches.freight_trains);
+ SetDParam(2, _settings.vehicle.freight_trains);
DrawString(x, y, FreightWagonMult(v->cargo_type) > 1 ? STR_CAPACITY_MULT : STR_013F_CAPACITY, TC_FROMSTRING);
}
}
@@ -249,7 +249,7 @@
SetDParam(1, act_cargo[i]); // {CARGO} #2
SetDParam(2, i); // {SHORTCARGO} #1
SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
- SetDParam(4, _patches.freight_trains);
+ SetDParam(4, _settings.vehicle.freight_trains);
DrawString(x, y + 2, FreightWagonMult(i) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_TOTAL_CAPACITY, TC_FROMSTRING);
}
}
--- a/src/tree_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/tree_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -112,7 +112,7 @@
*/
static TreeType GetRandomTreeType(TileIndex tile, uint seed)
{
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_TEMPERATE:
return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE);
@@ -249,7 +249,7 @@
if (CanPlantTreesOnTile(tile, true)) {
PlaceTree(tile, r);
- if (_patches.tree_placer != TP_IMPROVED) continue;
+ if (_settings.game_creation.tree_placer != TP_IMPROVED) continue;
/* Place a number of trees based on the tile height.
* This gives a cool effect of multiple trees close together.
@@ -259,7 +259,7 @@
j = GetTileZ(tile) / TILE_HEIGHT * 2;
while (j--) {
/* Above snowline more trees! */
- if (_opt.landscape == LT_ARCTIC && ht > GetSnowLine()) {
+ if (_settings.game_creation.landscape == LT_ARCTIC && ht > GetSnowLine()) {
PlaceTreeAtSameHeight(tile, ht);
PlaceTreeAtSameHeight(tile, ht);
};
@@ -270,7 +270,7 @@
} while (--i);
/* place extra trees at rainforest area */
- if (_opt.landscape == LT_TROPIC) {
+ if (_settings.game_creation.landscape == LT_TROPIC) {
i = ScaleByMapSize(15000);
do {
@@ -296,18 +296,18 @@
{
uint i, total;
- if (_patches.tree_placer == TP_NONE) return;
+ if (_settings.game_creation.tree_placer == TP_NONE) return;
- if (_opt.landscape != LT_TOYLAND) PlaceMoreTrees();
+ if (_settings.game_creation.landscape != LT_TOYLAND) PlaceMoreTrees();
- switch (_patches.tree_placer) {
- case TP_ORIGINAL: i = _opt.landscape == LT_ARCTIC ? 15 : 6; break;
- case TP_IMPROVED: i = _opt.landscape == LT_ARCTIC ? 4 : 2; break;
+ switch (_settings.game_creation.tree_placer) {
+ case TP_ORIGINAL: i = _settings.game_creation.landscape == LT_ARCTIC ? 15 : 6; break;
+ case TP_IMPROVED: i = _settings.game_creation.landscape == LT_ARCTIC ? 4 : 2; break;
default: NOT_REACHED(); return;
}
total = ScaleByMapSize(1000);
- if (_opt.landscape == LT_TROPIC) total += ScaleByMapSize(15000);
+ if (_settings.game_creation.landscape == LT_TROPIC) total += ScaleByMapSize(15000);
total *= i;
SetGeneratingWorldProgress(GWP_TREE, total);
@@ -332,7 +332,7 @@
if (p2 >= MapSize()) return CMD_ERROR;
/* Check the tree type. It can be random or some valid value within the current climate */
- if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_opt.landscape] >= _tree_count_by_landscape[_opt.landscape]) return CMD_ERROR;
+ if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_settings.game_creation.landscape] >= _tree_count_by_landscape[_settings.game_creation.landscape]) return CMD_ERROR;
// make sure sx,sy are smaller than ex,ey
ex = TileX(tile);
@@ -390,7 +390,7 @@
}
if (_game_mode != GM_EDITOR && IsValidPlayer(_current_player)) {
- Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
+ Town *t = ClosestTownFromTile(tile, _settings.economy.dist_local_authority);
if (t != NULL) ChangeTownRating(t, RATING_TREE_UP_STEP, RATING_TREE_MAXIMUM);
}
@@ -533,7 +533,7 @@
uint num;
if (IsValidPlayer(_current_player)) {
- Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
+ Town *t = ClosestTownFromTile(tile, _settings.economy.dist_local_authority);
if (t != NULL) ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
}
@@ -560,7 +560,7 @@
td->str = tt == TREE_CACTUS ? STR_2810_CACTUS_PLANTS : STR_280E_TREES;
}
- td->owner = GetTileOwner(tile);
+ td->owner[0] = GetTileOwner(tile);
}
static void AnimateTile_Trees(TileIndex tile)
@@ -626,7 +626,7 @@
if (GetTreeGround(tile) == TREE_GROUND_SHORE) {
TileLoop_Water(tile);
} else {
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_TROPIC: TileLoopTreesDesert(tile); break;
case LT_ARCTIC: TileLoopTreesAlps(tile); break;
}
@@ -652,7 +652,7 @@
switch (GetTreeGrowth(tile)) {
case 3: /* regular sized tree */
- if (_opt.landscape == LT_TROPIC &&
+ if (_settings.game_creation.landscape == LT_TROPIC &&
GetTreeType(tile) != TREE_CACTUS &&
GetTropicZone(tile) == TROPICZONE_DESERT) {
AddTreeGrowth(tile, 1);
@@ -704,7 +704,7 @@
case TREE_GROUND_GRASS: MakeClear(tile, CLEAR_GRASS, GetTreeDensity(tile)); break;
case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break;
default: // snow or desert
- MakeClear(tile, _opt.landscape == LT_TROPIC ? CLEAR_DESERT : CLEAR_SNOW, GetTreeDensity(tile));
+ MakeClear(tile, _settings.game_creation.landscape == LT_TROPIC ? CLEAR_DESERT : CLEAR_SNOW, GetTreeDensity(tile));
break;
}
}
@@ -725,7 +725,7 @@
TreeType tree;
/* place a tree at a random rainforest spot */
- if (_opt.landscape == LT_TROPIC &&
+ if (_settings.game_creation.landscape == LT_TROPIC &&
(r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) &&
CanPlantTreesOnTile(tile, false) &&
(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
--- a/src/tree_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/tree_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -74,8 +74,8 @@
this->DrawWidgets();
- int i = this->base = _tree_base_by_landscape[_opt.landscape];
- int count = this->count = _tree_count_by_landscape[_opt.landscape];
+ int i = this->base = _tree_base_by_landscape[_settings.game_creation.landscape];
+ int count = this->count = _tree_count_by_landscape[_settings.game_creation.landscape];
int x = 18;
int y = 54;
--- a/src/tunnelbridge_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/tunnelbridge_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -169,7 +169,7 @@
if (b->avail_year > _cur_year) return false;
max = b->max_length;
- if (max >= 16 && _patches.longbridges) max = 100;
+ if (max >= 16 && _settings.construction.longbridges) max = 100;
return b->min_length <= bridge_len && bridge_len <= max;
}
@@ -311,7 +311,7 @@
} else {
/* Build a new bridge. */
- bool allow_on_slopes = _patches.build_on_slopes;
+ bool allow_on_slopes = _settings.construction.build_on_slopes;
/* Try and clear the start landscape */
ret = DoCommand(tile_start, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -576,7 +576,7 @@
/* Obviously if the bridge/tunnel belongs to us, or no-one, we can remove it */
if (CheckTileOwnership(tile) || IsTileOwner(tile, OWNER_NONE)) return true;
/* Otherwise we can only remove town-owned stuff with extra patch-settings, or cheat */
- if (IsTileOwner(tile, OWNER_TOWN) && (_patches.extra_dynamite || _cheats.magic_bulldozer.value)) return true;
+ if (IsTileOwner(tile, OWNER_TOWN) && (_settings.construction.extra_dynamite || _cheats.magic_bulldozer.value)) return true;
return false;
}
@@ -1123,7 +1123,7 @@
DrawGroundSpriteAt(image, pal, x, y, z);
}
- } else if (_patches.bridge_pillars) {
+ } else if (_settings.gui.bridge_pillars) {
/* draw pillars below for high bridges */
DrawBridgePillars(psid, ti, axis, type, x, y, z);
}
@@ -1188,7 +1188,7 @@
} else { //so it must be a bridge
td->str = GetBridgeSpec(GetBridgeType(tile))->transport_name[GetTunnelBridgeTransportType(tile)];
}
- td->owner = GetTileOwner(tile);
+ td->owner[0] = GetTileOwner(tile);
}
@@ -1200,7 +1200,7 @@
static void TileLoop_TunnelBridge(TileIndex tile)
{
bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile);
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_ARCTIC:
if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) {
SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
@@ -1388,7 +1388,7 @@
static CommandCost TerraformTile_TunnelBridge(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
{
- if (_patches.build_on_slopes && AutoslopeEnabled() && IsBridge(tile)) {
+ if (_settings.construction.build_on_slopes && AutoslopeEnabled() && IsBridge(tile)) {
DiagDirection direction = GetTunnelBridgeDirection(tile);
Axis axis = DiagDirToAxis(direction);
CommandCost res;
--- a/src/unmovable_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/unmovable_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -312,7 +312,7 @@
case UNMOVABLE_OWNED_LAND: td->str = STR_5805_COMPANY_OWNED_LAND; break;
default: td->str = STR_5803_COMPANY_HEADQUARTERS; break;
}
- td->owner = GetTileOwner(tile);
+ td->owner[0] = GetTileOwner(tile);
}
static void AnimateTile_Unmovable(TileIndex tile)
@@ -375,11 +375,11 @@
void GenerateUnmovables()
{
- if (_opt.landscape == LT_TOYLAND) return;
+ if (_settings.game_creation.landscape == LT_TOYLAND) return;
/* add radio tower */
int radiotowser_to_build = ScaleByMapSize(15); // maximum number of radio towers on the map
- int lighthouses_to_build = _opt.landscape == LT_TROPIC ? 0 : ScaleByMapSize1D((Random() & 3) + 7);
+ int lighthouses_to_build = _settings.game_creation.landscape == LT_TROPIC ? 0 : ScaleByMapSize1D((Random() & 3) + 7);
SetGeneratingWorldProgress(GWP_UNMOVABLE, radiotowser_to_build + lighthouses_to_build);
for (uint i = ScaleByMapSize(1000); i != 0; i--) {
@@ -395,7 +395,7 @@
}
}
- if (_opt.landscape == LT_TROPIC) return;
+ if (_settings.game_creation.landscape == LT_TROPIC) return;
/* add lighthouses */
uint maxx = MapMaxX();
--- a/src/vehicle.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/vehicle.cpp Mon May 26 13:52:59 2008 +0000
@@ -51,6 +51,7 @@
#include "animated_tile_func.h"
#include "effectvehicle_base.h"
#include "ai/ai.h"
+#include "core/alloc_func.hpp"
#include "table/sprites.h"
#include "table/strings.h"
@@ -59,7 +60,7 @@
#define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6))
VehicleID _vehicle_id_ctr_day;
-Vehicle *_place_clicked_vehicle;
+const Vehicle *_place_clicked_vehicle;
VehicleID _new_vehicle_id;
uint16 _returned_refit_capacity;
@@ -127,20 +128,20 @@
{
if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false;
- if (_patches.no_servicing_if_no_breakdowns && _opt.diff.vehicle_breakdowns == 0) {
+ if (_settings.order.no_servicing_if_no_breakdowns && _settings.difficulty.vehicle_breakdowns == 0) {
/* Vehicles set for autoreplacing needs to go to a depot even if breakdowns are turned off.
* Note: If servicing is enabled, we postpone replacement till next service. */
return EngineHasReplacementForPlayer(GetPlayer(this->owner), this->engine_type, this->group_id);
}
- return _patches.servint_ispercent ?
+ return _settings.vehicle.servint_ispercent ?
(this->reliability < GetEngine(this->engine_type)->reliability * (100 - this->service_interval) / 100) :
(this->date_of_last_service + this->service_interval < _date);
}
bool Vehicle::NeedsAutomaticServicing() const
{
- if (_patches.gotodepot && VehicleHasDepotOrders(this)) return false;
+ if (_settings.order.gotodepot && VehicleHasDepotOrders(this)) return false;
if (this->current_order.IsType(OT_LOADING)) return false;
if (this->current_order.IsType(OT_GOTO_DEPOT) && this->current_order.GetDepotOrderType() != ODTFB_SERVICE) return false;
return NeedsServicing();
@@ -532,6 +533,12 @@
return v;
}
+const Vehicle *GetLastVehicleInChain(const Vehicle *v)
+{
+ while (v->Next() != NULL) v = v->Next();
+ return v;
+}
+
uint CountVehiclesInChain(const Vehicle* v)
{
uint count = 0;
@@ -907,7 +914,7 @@
if ((rel_old >> 8) != (rel >> 8)) InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (v->breakdown_ctr != 0 || v->vehstatus & VS_STOPPED ||
- _opt.diff.vehicle_breakdowns < 1 ||
+ _settings.difficulty.vehicle_breakdowns < 1 ||
v->cur_speed < 5 || _game_mode == GM_MENU) {
return;
}
@@ -924,7 +931,7 @@
if (v->type == VEH_SHIP) rel += 0x6666;
/* reduced breakdowns? */
- if (_opt.diff.vehicle_breakdowns == 1) rel += 0x6666;
+ if (_settings.difficulty.vehicle_breakdowns == 1) rel += 0x6666;
/* check if to break down */
if (_breakdown_chance[(uint)min(rel, 0xffff) >> 10] <= v->breakdown_chance) {
@@ -983,9 +990,7 @@
*/
CommandCost CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- Vehicle **vl = NULL;
- uint16 engine_list_length = 0;
- uint16 engine_count = 0;
+ VehicleList list;
CommandCost return_value = CMD_ERROR;
uint stop_command;
VehicleType vehicle_type = (VehicleType)GB(p2, 0, 5);
@@ -1004,14 +1009,14 @@
uint32 id = p1;
uint16 window_type = p2 & VLW_MASK;
- engine_count = GenerateVehicleSortList((const Vehicle***)&vl, &engine_list_length, vehicle_type, _current_player, id, window_type);
+ GenerateVehicleSortList(&list, vehicle_type, _current_player, id, window_type);
} else {
/* Get the list of vehicles in the depot */
- BuildDepotVehicleList(vehicle_type, tile, &vl, &engine_list_length, &engine_count, NULL, NULL, NULL);
+ BuildDepotVehicleList(vehicle_type, tile, &list, NULL);
}
- for (uint i = 0; i < engine_count; i++) {
- const Vehicle *v = vl[i];
+ for (uint i = 0; i < list.Length(); i++) {
+ const Vehicle *v = list[i];
if (!!(v->vehstatus & VS_STOPPED) != start_stop) continue;
@@ -1033,7 +1038,6 @@
}
}
- free(vl);
return return_value;
}
@@ -1045,15 +1049,10 @@
*/
CommandCost CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- Vehicle **engines = NULL;
- Vehicle **wagons = NULL;
- uint16 engine_list_length = 0;
- uint16 engine_count = 0;
- uint16 wagon_list_length = 0;
- uint16 wagon_count = 0;
+ VehicleList list;
CommandCost cost(EXPENSES_NEW_VEHICLES);
- uint sell_command, total_number_vehicles;
+ uint sell_command;
VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
switch (vehicle_type) {
@@ -1065,26 +1064,13 @@
}
/* Get the list of vehicles in the depot */
- BuildDepotVehicleList(vehicle_type, tile, &engines, &engine_list_length, &engine_count,
- &wagons, &wagon_list_length, &wagon_count);
-
- total_number_vehicles = engine_count + wagon_count;
- for (uint i = 0; i < total_number_vehicles; i++) {
- const Vehicle *v;
-
- if (i < engine_count) {
- v = engines[i];
- } else {
- v = wagons[i - engine_count];
- }
-
- CommandCost ret = DoCommand(tile, v->index, 1, flags, sell_command);
-
+ BuildDepotVehicleList(vehicle_type, tile, &list, &list);
+
+ for (uint i = 0; i < list.Length(); i++) {
+ CommandCost ret = DoCommand(tile, list[i]->index, 1, flags, sell_command);
if (CmdSucceeded(ret)) cost.AddCost(ret);
}
- free(engines);
- free(wagons);
if (cost.GetCost() == 0) return CMD_ERROR; // no vehicles to sell
return cost;
}
@@ -1100,9 +1086,7 @@
*/
CommandCost CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- Vehicle **vl = NULL;
- uint16 engine_list_length = 0;
- uint16 engine_count = 0;
+ VehicleList list;
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES);
VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
bool all_or_nothing = HasBit(p2, 0);
@@ -1110,10 +1094,10 @@
if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
/* Get the list of vehicles in the depot */
- BuildDepotVehicleList(vehicle_type, tile, &vl, &engine_list_length, &engine_count, &vl, &engine_list_length, &engine_count);
-
- for (uint i = 0; i < engine_count; i++) {
- Vehicle *v = vl[i];
+ BuildDepotVehicleList(vehicle_type, tile, &list, &list);
+
+ for (uint i = 0; i < list.Length(); i++) {
+ Vehicle *v = (Vehicle*)list[i];
/* Ensure that the vehicle completely in the depot */
if (!v->IsInDepot()) continue;
@@ -1128,22 +1112,18 @@
* We should never reach this if DC_EXEC is set since then it should
* have failed the estimation guess. */
assert(!(flags & DC_EXEC));
- /* Now we will have to return an error.
- * This goto will leave the loop and it's ok to do so because
- * there is no point in the rest of the loop. */
- goto error;
+ /* Now we will have to return an error. */
+ return CMD_ERROR;
}
}
}
if (cost.GetCost() == 0) {
-error:
/* Either we didn't replace anything or something went wrong.
* Either way we want to return an error and not execute this command. */
cost = CMD_ERROR;
}
- free(vl);
return cost;
}
@@ -1312,92 +1292,47 @@
return total_cost;
}
-
-/* Extend the list size for BuildDepotVehicleList() */
-static inline void ExtendVehicleListSize(const Vehicle ***engine_list, uint16 *engine_list_length, uint16 step_size)
-{
- *engine_list_length = min(*engine_list_length + step_size, GetMaxVehicleIndex() + 1);
- *engine_list = ReallocT(*engine_list, *engine_list_length);
-}
-
-/** Generates a list of vehicles inside a depot
- * Will enlarge allocated space for the list if they are too small, so it's ok to call with (pointer to NULL array, pointer to uninitised uint16, pointer to 0)
- * If one of the lists is not needed (say wagons when finding ships), all the pointers regarding that list should be set to NULL
- * @param type Type of vehicle
- * @param tile The tile the depot is located in
- * @param ***engine_list Pointer to a pointer to an array of vehicles in the depot (old list is freed and a new one is malloced)
- * @param *engine_list_length Allocated size of engine_list. Needs to be set to 0 when engine_list points to a NULL array
- * @param *engine_count The number of engines stored in the list
- * @param ***wagon_list Pointer to a pointer to an array of free wagons in the depot (old list is freed and a new one is malloced)
- * @param *wagon_list_length Allocated size of wagon_list. Needs to be set to 0 when wagon_list points to a NULL array
- * @param *wagon_count The number of engines stored in the list
+/**
+ * Generate a list of vehicles inside a depot.
+ * @param type Type of vehicle
+ * @param tile The tile the depot is located on
+ * @param engines Pointer to list to add vehicles to
+ * @param wagons Pointer to list to add wagons to (can be NULL)
*/
-void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count)
+void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons)
{
- Vehicle *v;
-
- /* This function should never be called without an array to store results */
- assert(!(engine_list == NULL && type != VEH_TRAIN));
- assert(!(type == VEH_TRAIN && engine_list == NULL && wagon_list == NULL));
-
- /* Both array and the length should either be NULL to disable the list or both should not be NULL */
- assert((engine_list == NULL && engine_list_length == NULL) || (engine_list != NULL && engine_list_length != NULL));
- assert((wagon_list == NULL && wagon_list_length == NULL) || (wagon_list != NULL && wagon_list_length != NULL));
-
- assert(!(engine_list != NULL && engine_count == NULL));
- assert(!(wagon_list != NULL && wagon_count == NULL));
-
- if (engine_count != NULL) *engine_count = 0;
- if (wagon_count != NULL) *wagon_count = 0;
-
- switch (type) {
- case VEH_TRAIN:
- FOR_ALL_VEHICLES(v) {
- if (v->tile == tile && v->type == VEH_TRAIN && v->u.rail.track == TRACK_BIT_DEPOT) {
- if (IsFrontEngine(v)) {
- if (engine_list == NULL) continue;
- if (*engine_count == *engine_list_length) ExtendVehicleListSize((const Vehicle***)engine_list, engine_list_length, 25);
- (*engine_list)[(*engine_count)++] = v;
- } else if (IsFreeWagon(v)) {
- if (wagon_list == NULL) continue;
- if (*wagon_count == *wagon_list_length) ExtendVehicleListSize((const Vehicle***)wagon_list, wagon_list_length, 25);
- (*wagon_list)[(*wagon_count)++] = v;
- }
+ engines->Clear();
+ if (wagons != NULL && wagons != engines) wagons->Clear();
+
+ const Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ /* General tests for all vehicle types */
+ if (v->type != type) continue;
+ if (v->tile != tile) continue;
+
+ switch (type) {
+ case VEH_TRAIN:
+ if (v->u.rail.track != TRACK_BIT_DEPOT) continue;
+ if (wagons != NULL && IsFreeWagon(v)) {
+ *wagons->Append() = v;
+ continue;
}
- }
- break;
-
- case VEH_ROAD:
- FOR_ALL_VEHICLES(v) {
- if (v->tile == tile && v->type == VEH_ROAD && v->IsInDepot() && IsRoadVehFront(v)) {
- if (*engine_count == *engine_list_length) ExtendVehicleListSize((const Vehicle***)engine_list, engine_list_length, 25);
- (*engine_list)[(*engine_count)++] = v;
- }
- }
- break;
-
- case VEH_SHIP:
- FOR_ALL_VEHICLES(v) {
- if (v->tile == tile && v->type == VEH_SHIP && v->IsInDepot()) {
- if (*engine_count == *engine_list_length) ExtendVehicleListSize((const Vehicle***)engine_list, engine_list_length, 25);
- (*engine_list)[(*engine_count)++] = v;
- }
- }
- break;
-
- case VEH_AIRCRAFT:
- FOR_ALL_VEHICLES(v) {
- if (v->tile == tile &&
- v->type == VEH_AIRCRAFT && IsNormalAircraft(v) &&
- v->IsInDepot()) {
- if (*engine_count == *engine_list_length) ExtendVehicleListSize((const Vehicle***)engine_list, engine_list_length, 25);
- (*engine_list)[(*engine_count)++] = v;
- }
- }
- break;
-
- default: NOT_REACHED();
+ break;
+
+ default:
+ if (!v->IsInDepot()) continue;
+ break;
+ }
+
+ if (!v->IsPrimaryVehicle()) continue;
+
+ *engines->Append() = v;
}
+
+ /* Ensure the lists are not wasting too much space. If the lists are fresh
+ * (i.e. built within a command) then this will actually do nothing. */
+ engines->Compact();
+ if (wagons != NULL && wagons != engines) wagons->Compact();
}
/**
@@ -1418,78 +1353,95 @@
*/
uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type)
{
- uint n = 0;
+ VehicleList list;
+ GenerateVehicleSortList(&list, type, owner, index, window_type);
+
+ if (list.Length() > 0) {
+ *sort_list = ReallocT(*sort_list, list.Length());
+ memcpy(*sort_list, list.Begin(), sizeof(list.Begin()) * list.Length());
+ }
+
+ return list.Length();
+}
+
+/**
+ * Generate a list of vehicles based on window type.
+ * @param list Pointer to list to add vehicles to
+ * @param type Type of vehicle
+ * @param owner Player to generate list for
+ * @param index This parameter has different meanings depending on window_type
+ * <ul>
+ * <li>VLW_STATION_LIST: index of station to generate a list for</li>
+ * <li>VLW_SHARED_ORDERS: index of order to generate a list for<li>
+ * <li>VLW_STANDARD: not used<li>
+ * <li>VLW_DEPOT_LIST: TileIndex of the depot/hangar to make the list for</li>
+ * <li>VLW_GROUP_LIST: index of group to generate a list for</li>
+ * </ul>
+ * @param window_type The type of window the list is for, using the VLW_ flags in vehicle_gui.h
+ */
+void GenerateVehicleSortList(VehicleList *list, VehicleType type, PlayerID owner, uint32 index, uint16 window_type)
+{
+ list->Clear();
+
const Vehicle *v;
switch (window_type) {
- case VLW_STATION_LIST: {
+ case VLW_STATION_LIST:
FOR_ALL_VEHICLES(v) {
if (v->type == type && v->IsPrimaryVehicle()) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
if (order->IsType(OT_GOTO_STATION) && order->GetDestination() == index) {
- if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, 50);
- (*sort_list)[n++] = v;
+ *list->Append() = v;
break;
}
}
}
}
break;
- }
-
- case VLW_SHARED_ORDERS: {
+
+ case VLW_SHARED_ORDERS:
FOR_ALL_VEHICLES(v) {
/* Find a vehicle with the order in question */
- if (v->orders != NULL && v->orders->index == index) break;
- }
-
- if (v != NULL && v->orders != NULL && v->orders->index == index) {
- /* Only try to make the list if we found a vehicle using the order in question */
- for (v = GetFirstVehicleFromSharedList(v); v != NULL; v = v->next_shared) {
- if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, 25);
- (*sort_list)[n++] = v;
+ if (v->orders != NULL && v->orders->index == index) {
+ /* Add all vehicles from this vehicle's shared order list */
+ for (v = GetFirstVehicleFromSharedList(v); v != NULL; v = v->next_shared) {
+ *list->Append() = v;
+ }
+ break;
}
}
break;
- }
-
- case VLW_STANDARD: {
+
+ case VLW_STANDARD:
FOR_ALL_VEHICLES(v) {
if (v->type == type && v->owner == owner && v->IsPrimaryVehicle()) {
- /* TODO find a better estimate on the total number of vehicles for current player */
- if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, GetNumVehicles() / 4);
- (*sort_list)[n++] = v;
+ *list->Append() = v;
}
}
break;
- }
-
- case VLW_DEPOT_LIST: {
+
+ case VLW_DEPOT_LIST:
FOR_ALL_VEHICLES(v) {
if (v->type == type && v->IsPrimaryVehicle()) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
if (order->IsType(OT_GOTO_DEPOT) && order->GetDestination() == index) {
- if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, 25);
- (*sort_list)[n++] = v;
+ *list->Append() = v;
break;
}
}
}
}
break;
- }
case VLW_GROUP_LIST:
FOR_ALL_VEHICLES(v) {
if (v->type == type && v->IsPrimaryVehicle() &&
v->owner == owner && v->group_id == index) {
- if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, GetNumVehicles() / 4);
-
- (*sort_list)[n++] = v;
+ *list->Append() = v;
}
}
break;
@@ -1497,16 +1449,7 @@
default: NOT_REACHED(); break;
}
- if ((n + 100) < *length_of_array) {
- /* We allocated way too much for sort_list.
- * Now we will reduce how much we allocated.
- * We will still make it have room for 50 extra vehicles to prevent having
- * to move the whole array if just one vehicle is added later */
- *length_of_array = n + 50;
- *sort_list = ReallocT(*sort_list, (*length_of_array) * sizeof((*sort_list)[0]));
- }
-
- return n;
+ list->Compact();
}
/**
@@ -1520,14 +1463,13 @@
*/
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
{
- const Vehicle **sort_list = NULL;
- uint16 array_length = 0;
-
- uint n = GenerateVehicleSortList(&sort_list, &array_length, type, owner, id, vlw_flag);
+ VehicleList list;
+
+ GenerateVehicleSortList(&list, type, owner, id, vlw_flag);
/* Send all the vehicles to a depot */
- for (uint i = 0; i < n; i++) {
- const Vehicle *v = sort_list[i];
+ for (uint i = 0; i < list.Length(); i++) {
+ const Vehicle *v = list[i];
CommandCost ret = DoCommand(v->tile, v->index, (service ? 1 : 0) | DEPOT_DONT_CANCEL, flags, GetCmdSendToDepot(type));
/* Return 0 if DC_EXEC is not set this is a valid goto depot command)
@@ -1535,12 +1477,10 @@
* and we will issue the command. We can now safely quit the loop, knowing
* it will succeed at least once. With DC_EXEC we really need to send them to the depot */
if (CmdSucceeded(ret) && !(flags & DC_EXEC)) {
- free((void*)sort_list);
return CommandCost();
}
}
- free((void*)sort_list);
return (flags & DC_EXEC) ? CommandCost() : CMD_ERROR;
}
@@ -1917,10 +1857,10 @@
static UnitID gmax = 0;
switch (type) {
- case VEH_TRAIN: max = _patches.max_trains; break;
- case VEH_ROAD: max = _patches.max_roadveh; break;
- case VEH_SHIP: max = _patches.max_ships; break;
- case VEH_AIRCRAFT: max = _patches.max_aircraft; break;
+ case VEH_TRAIN: max = _settings.vehicle.max_trains; break;
+ case VEH_ROAD: max = _settings.vehicle.max_roadveh; break;
+ case VEH_SHIP: max = _settings.vehicle.max_ships; break;
+ case VEH_AIRCRAFT: max = _settings.vehicle.max_aircraft; break;
default: NOT_REACHED();
}
@@ -1970,14 +1910,14 @@
assert(IsPlayerBuildableVehicleType(type));
if (!IsValidPlayer(_current_player)) return false;
- if (_patches.always_build_infrastructure) return true;
+ if (_settings.gui.always_build_infrastructure) return true;
UnitID max;
switch (type) {
- case VEH_TRAIN: max = _patches.max_trains; break;
- case VEH_ROAD: max = _patches.max_roadveh; break;
- case VEH_SHIP: max = _patches.max_ships; break;
- case VEH_AIRCRAFT: max = _patches.max_aircraft; break;
+ case VEH_TRAIN: max = _settings.vehicle.max_trains; break;
+ case VEH_ROAD: max = _settings.vehicle.max_roadveh; break;
+ case VEH_SHIP: max = _settings.vehicle.max_ships; break;
+ case VEH_AIRCRAFT: max = _settings.vehicle.max_aircraft; break;
default: NOT_REACHED();
}
@@ -2009,7 +1949,7 @@
/* The default livery is always available for use, but its in_use flag determines
* whether any _other_ liveries are in use. */
- if (p->livery[LS_DEFAULT].in_use && (_patches.liveries == 2 || (_patches.liveries == 1 && player == _local_player))) {
+ if (p->livery[LS_DEFAULT].in_use && (_settings.gui.liveries == 2 || (_settings.gui.liveries == 1 && player == _local_player))) {
/* Determine the livery scheme to use */
switch (GetEngine(engine_type)->type) {
default: NOT_REACHED();
@@ -2576,7 +2516,7 @@
/* Not the first call for this tick, or still loading */
if (mode || !HasBit(this->vehicle_flags, VF_LOADING_FINISHED) ||
- (_patches.timetabling && this->current_order_time < wait_time)) return;
+ (_settings.order.timetabling && this->current_order_time < wait_time)) return;
this->PlayLeaveStationSound();
--- a/src/vehicle_base.h Mon May 26 11:36:42 2008 +0000
+++ b/src/vehicle_base.h Mon May 26 13:52:59 2008 +0000
@@ -564,9 +564,6 @@
void Tick() {}
};
-#define BEGIN_ENUM_WAGONS(v) do {
-#define END_ENUM_WAGONS(v) } while ((v = v->Next()) != NULL);
-
static inline VehicleID GetMaxVehicleIndex()
{
/* TODO - This isn't the real content of the function, but
--- a/src/vehicle_func.h Mon May 26 11:36:42 2008 +0000
+++ b/src/vehicle_func.h Mon May 26 13:52:59 2008 +0000
@@ -25,6 +25,7 @@
void VehicleServiceInDepot(Vehicle *v);
void VehiclePositionChanged(Vehicle *v);
Vehicle *GetLastVehicleInChain(Vehicle *v);
+const Vehicle *GetLastVehicleInChain(const Vehicle *v);
uint CountVehiclesInChain(const Vehicle *v);
bool IsEngineCountable(const Vehicle *v);
void DeleteVehicleChain(Vehicle *v);
@@ -68,8 +69,10 @@
void TrainPowerChanged(Vehicle *v);
Money GetTrainRunningCost(const Vehicle *v);
+/* Old style list kept for migration */
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
-void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
+void GenerateVehicleSortList(VehicleList *list, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
+void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine_list, VehicleList *wagon_list);
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
void VehicleEnterDepot(Vehicle *v);
@@ -174,7 +177,7 @@
void StopAllVehicles();
extern VehicleID _vehicle_id_ctr_day;
-extern Vehicle *_place_clicked_vehicle;
+extern const Vehicle *_place_clicked_vehicle;
extern VehicleID _new_vehicle_id;
extern uint16 _returned_refit_capacity;
--- a/src/vehicle_gui.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/vehicle_gui.cpp Mon May 26 13:52:59 2008 +0000
@@ -117,10 +117,11 @@
vl->vehicles.flags &= ~VL_RESORT;
}
-void DepotSortList(Vehicle **v, uint16 length)
+void DepotSortList(VehicleList *list)
{
_internal_sort_order = 0;
- qsort((void*)v, length, sizeof(v[0]), _vehicle_sorter[0]);
+ if (list->Length() < 2) return;
+ qsort((void*)list->Begin(), list->Length(), sizeof(list->Begin()), _vehicle_sorter[0]);
}
/** draw the vehicle profit button in the vehicle list window. */
@@ -1219,12 +1220,12 @@
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type)
{
- /* If _patches.advanced_vehicle_list > 1, display the Advanced list
- * if _patches.advanced_vehicle_list == 1, display Advanced list only for local player
+ /* If _settings.gui.advanced_vehicle_list > 1, display the Advanced list
+ * if _settings.gui.advanced_vehicle_list == 1, display Advanced list only for local player
* if _ctrl_pressed, do the opposite action (Advanced list x Normal list)
*/
- if ((_patches.advanced_vehicle_list > (uint)(player != _local_player)) != _ctrl_pressed) {
+ if ((_settings.gui.advanced_vehicle_list > (uint)(player != _local_player)) != _ctrl_pressed) {
ShowPlayerGroup(player, vehicle_type);
} else {
ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0);
@@ -1401,6 +1402,8 @@
this->caption_color = v->owner;
this->tab = 0;
+
+ this->FindWindowPlacementAndResize(desc);
}
/** Checks whether service interval is enabled for the vehicle. */
@@ -1408,10 +1411,10 @@
{
switch (vehicle_type) {
default: NOT_REACHED();
- case VEH_TRAIN: return _patches.servint_trains != 0; break;
- case VEH_ROAD: return _patches.servint_roadveh != 0; break;
- case VEH_SHIP: return _patches.servint_ships != 0; break;
- case VEH_AIRCRAFT: return _patches.servint_aircraft != 0; break;
+ case VEH_TRAIN: return _settings.vehicle.servint_trains != 0; break;
+ case VEH_ROAD: return _settings.vehicle.servint_roadveh != 0; break;
+ case VEH_SHIP: return _settings.vehicle.servint_ships != 0; break;
+ case VEH_AIRCRAFT: return _settings.vehicle.servint_aircraft != 0; break;
}
return false; // kill a compiler warning
}
@@ -1483,7 +1486,7 @@
SetDParam(1, v->u.rail.cached_power);
SetDParam(0, v->u.rail.cached_weight);
SetDParam(3, v->u.rail.cached_max_te / 1000);
- DrawString(2, 25, (_patches.realistic_acceleration && v->u.rail.railtype != RAILTYPE_MAGLEV) ?
+ DrawString(2, 25, (_settings.vehicle.realistic_acceleration && v->u.rail.railtype != RAILTYPE_MAGLEV) ?
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, TC_FROMSTRING);
break;
@@ -1511,7 +1514,7 @@
/* Draw service interval text */
SetDParam(0, v->service_interval);
SetDParam(1, v->date_of_last_service);
- DrawString(13, this->height - (v->type != VEH_TRAIN ? 11 : 23), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, TC_FROMSTRING);
+ DrawString(13, this->height - (v->type != VEH_TRAIN ? 11 : 23), _settings.vehicle.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, TC_FROMSTRING);
switch (v->type) {
case VEH_TRAIN:
@@ -1873,6 +1876,8 @@
default: NOT_REACHED();
}
+
+ this->FindWindowPlacementAndResize(desc);
}
~VehicleViewWindow()
@@ -1948,7 +1953,7 @@
}
} else {
SetDParam(0, v->GetDisplaySpeed());
- str = STR_TRAIN_STOPPING + _patches.vehicle_speed;
+ str = STR_TRAIN_STOPPING + _settings.gui.vehicle_speed;
}
} else { // no train
str = STR_8861_STOPPED;
@@ -1958,7 +1963,7 @@
case OT_GOTO_STATION: {
SetDParam(0, v->current_order.GetDestination());
SetDParam(1, v->GetDisplaySpeed());
- str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
+ str = STR_HEADING_FOR_STATION + _settings.gui.vehicle_speed;
} break;
case OT_GOTO_DEPOT: {
@@ -1972,9 +1977,9 @@
SetDParam(1, v->GetDisplaySpeed());
}
if ((v->current_order.GetDepotActionType() & ODATFB_HALT) && !(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) {
- str = _heading_for_depot_strings[v->type] + _patches.vehicle_speed;
+ str = _heading_for_depot_strings[v->type] + _settings.gui.vehicle_speed;
} else {
- str = _heading_for_depot_service_strings[v->type] + _patches.vehicle_speed;
+ str = _heading_for_depot_service_strings[v->type] + _settings.gui.vehicle_speed;
}
} break;
@@ -1985,7 +1990,7 @@
case OT_GOTO_WAYPOINT: {
assert(v->type == VEH_TRAIN);
SetDParam(0, v->current_order.GetDestination());
- str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed;
+ str = STR_HEADING_FOR_WAYPOINT + _settings.gui.vehicle_speed;
SetDParam(1, v->GetDisplaySpeed());
break;
}
@@ -1999,7 +2004,7 @@
default:
if (v->num_orders == 0) {
- str = STR_NO_ORDERS + _patches.vehicle_speed;
+ str = STR_NO_ORDERS + _settings.gui.vehicle_speed;
SetDParam(0, v->GetDisplaySpeed());
} else {
str = STR_EMPTY;
--- a/src/vehicle_type.h Mon May 26 11:36:42 2008 +0000
+++ b/src/vehicle_type.h Mon May 26 13:52:59 2008 +0000
@@ -6,6 +6,7 @@
#define VEHICLE_TYPE_H
#include "core/enum_type.hpp"
+#include "misc/smallvec.h"
typedef uint16 VehicleID;
@@ -56,4 +57,6 @@
DEPOT_COMMAND_MASK = 0xF,
};
+typedef SmallVector<const Vehicle*, 32> VehicleList;
+
#endif /* VEHICLE_TYPE_H */
--- a/src/video/cocoa/event.mm Mon May 26 11:36:42 2008 +0000
+++ b/src/video/cocoa/event.mm Mon May 26 13:52:59 2008 +0000
@@ -288,9 +288,9 @@
}
if (_current_mods & NSShiftKeyMask) key |= WKC_SHIFT;
- if (_current_mods & NSControlKeyMask) key |= (_patches.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_CTRL : WKC_META);
+ if (_current_mods & NSControlKeyMask) key |= (_settings.gui.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_CTRL : WKC_META);
if (_current_mods & NSAlternateKeyMask) key |= WKC_ALT;
- if (_current_mods & NSCommandKeyMask) key |= (_patches.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_META : WKC_CTRL);
+ if (_current_mods & NSCommandKeyMask) key |= (_settings.gui.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_META : WKC_CTRL);
return key << 16;
}
@@ -459,8 +459,8 @@
case NSLeftMouseDown:
{
uint32 keymask = 0;
- if (_patches.right_mouse_btn_emulation == RMBE_COMMAND) keymask |= NSCommandKeyMask;
- if (_patches.right_mouse_btn_emulation == RMBE_CONTROL) keymask |= NSControlKeyMask;
+ if (_settings.gui.right_mouse_btn_emulation == RMBE_COMMAND) keymask |= NSCommandKeyMask;
+ if (_settings.gui.right_mouse_btn_emulation == RMBE_CONTROL) keymask |= NSControlKeyMask;
pt = _cocoa_subdriver->GetMouseLocation(event);
@@ -602,8 +602,8 @@
} /* else: deltaY was 0.0 and we don't want to do anything */
/* Set the scroll count for scrollwheel scrolling */
- _cursor.h_wheel -= (int)([ event deltaX ]* 5 * _patches.scrollwheel_multiplier);
- _cursor.v_wheel -= (int)([ event deltaY ]* 5 * _patches.scrollwheel_multiplier);
+ _cursor.h_wheel -= (int)([ event deltaX ]* 5 * _settings.gui.scrollwheel_multiplier);
+ _cursor.v_wheel -= (int)([ event deltaY ]* 5 * _settings.gui.scrollwheel_multiplier);
break;
default:
@@ -671,7 +671,7 @@
bool old_ctrl_pressed = _ctrl_pressed;
- _ctrl_pressed = !!(_current_mods & ( _patches.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask));
+ _ctrl_pressed = !!(_current_mods & ( _settings.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask));
_shift_pressed = !!(_current_mods & NSShiftKeyMask);
if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
--- a/src/video/dedicated_v.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/video/dedicated_v.cpp Mon May 26 13:52:59 2008 +0000
@@ -11,7 +11,7 @@
#include "../gfx_func.h"
#include "../network/network.h"
#include "../network/network_internal.h"
-#include "../console.h"
+#include "../console_func.h"
#include "../variables.h"
#include "../genworld.h"
#include "../fileio.h"
--- a/src/viewport.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/viewport.cpp Mon May 26 13:52:59 2008 +0000
@@ -1020,7 +1020,7 @@
right > t->sign.left &&
left < t->sign.left + t->sign.width_1) {
AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
- _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
+ _settings.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
t->index, t->population);
}
}
@@ -1036,7 +1036,7 @@
right > t->sign.left &&
left < t->sign.left + t->sign.width_1 * 2) {
AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
- _patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
+ _settings.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
t->index, t->population);
}
}
@@ -1591,7 +1591,7 @@
int delta_y = w->viewport->dest_scrollpos_y - w->viewport->scrollpos_y;
if (delta_x != 0 || delta_y != 0) {
- if (_patches.smooth_scroll) {
+ if (_settings.gui.smooth_scroll) {
int max_scroll = ScaleByMapSize1D(512);
/* Not at our desired positon yet... */
w->viewport->scrollpos_x += Clamp(delta_x / 4, -max_scroll, max_scroll);
@@ -2510,7 +2510,7 @@
}
}
- if (_patches.measure_tooltip) {
+ if (_settings.gui.measure_tooltip) {
TileIndex t0 = TileVirtXY(thd->selstart.x, thd->selstart.y);
TileIndex t1 = TileVirtXY(x, y);
uint distance = DistanceManhattan(t0, t1) + 1;
@@ -2590,7 +2590,7 @@
style = HT_DIR_X;
calc_heightdiff_single_direction:;
- if (_patches.measure_tooltip) {
+ if (_settings.gui.measure_tooltip) {
TileIndex t0 = TileVirtXY(sx, sy);
TileIndex t1 = TileVirtXY(x, y);
uint distance = DistanceManhattan(t0, t1) + 1;
@@ -2618,7 +2618,7 @@
y = sy + Clamp(y - sy, -limit, limit);
} /* Fallthrough */
case VPM_X_AND_Y: { /* drag an X by Y area */
- if (_patches.measure_tooltip) {
+ if (_settings.gui.measure_tooltip) {
static const StringID measure_strings_area[] = {
STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF
};
--- a/src/water_cmd.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/water_cmd.cpp Mon May 26 13:52:59 2008 +0000
@@ -738,7 +738,7 @@
default: assert(0); break;
}
- td->owner = GetTileOwner(tile);
+ td->owner[0] = GetTileOwner(tile);
}
static void AnimateTile_Water(TileIndex tile)
@@ -771,7 +771,7 @@
}
/* if non-uniform stations are disabled, flood some train in this train station (if there is any) */
- if (!_patches.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) {
+ if (!_settings.station.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) {
const Station *st = GetStationByTile(tile);
BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
@@ -819,19 +819,15 @@
if (v->z_pos != airport->delta_z + 1) return;
}
- Vehicle *u;
if (v->type != VEH_AIRCRAFT) v = v->First();
- u = v;
/* crash all wagons, and count passengers */
- BEGIN_ENUM_WAGONS(v)
- if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo.Count();
- v->vehstatus |= VS_CRASHED;
- MarkSingleVehicleDirty(v);
- END_ENUM_WAGONS(v)
-
- v = u;
+ for (Vehicle *u = v; u != NULL; u = u->Next()) {
+ if (IsCargoInClass(u->cargo_type, CC_PASSENGERS)) pass += u->cargo.Count();
+ u->vehstatus |= VS_CRASHED;
+ MarkSingleVehicleDirty(u);
+ }
switch (v->type) {
default: NOT_REACHED();
--- a/src/waypoint.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/waypoint.cpp Mon May 26 13:52:59 2008 +0000
@@ -210,7 +210,7 @@
tileh = GetTileSlope(tile, NULL);
if (tileh != SLOPE_FLAT &&
- (!_patches.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) {
+ (!_settings.construction.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
--- a/src/window.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/window.cpp Mon May 26 13:52:59 2008 +0000
@@ -8,7 +8,8 @@
#include "debug.h"
#include "player_func.h"
#include "gfx_func.h"
-#include "console.h"
+#include "console_func.h"
+#include "console_gui.h"
#include "viewport_func.h"
#include "variables.h"
#include "genworld.h"
@@ -1216,11 +1217,11 @@
int nx = x;
int ny = y;
- if (_patches.window_snap_radius != 0) {
+ if (_settings.gui.window_snap_radius != 0) {
Window* const *vz;
- int hsnap = _patches.window_snap_radius;
- int vsnap = _patches.window_snap_radius;
+ int hsnap = _settings.gui.window_snap_radius;
+ int vsnap = _settings.gui.window_snap_radius;
int delta;
FOR_ALL_WINDOWS(vz) {
@@ -1466,7 +1467,7 @@
static bool HandleViewportScroll()
{
- bool scrollwheel_scrolling = _patches.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
+ bool scrollwheel_scrolling = _settings.gui.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
if (!_scrolling_viewport) return true;
@@ -1486,7 +1487,7 @@
}
Point delta;
- if (_patches.reverse_scroll) {
+ if (_settings.gui.reverse_scroll) {
delta.x = -_cursor.delta.x;
delta.y = -_cursor.delta.y;
} else {
@@ -1666,7 +1667,7 @@
return;
}
- if (_patches.autoscroll && _game_mode != GM_MENU && !IsGeneratingWorld()) {
+ if (_settings.gui.autoscroll && _game_mode != GM_MENU && !IsGeneratingWorld()) {
int x = _cursor.pos.x;
int y = _cursor.pos.y;
Window *w = FindWindowFromPt(x, y);
@@ -1718,7 +1719,7 @@
if (!HandleViewportScroll()) return;
if (!HandleMouseOver()) return;
- bool scrollwheel_scrolling = _patches.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
+ bool scrollwheel_scrolling = _settings.gui.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
if (click == MC_NONE && mousewheel == 0 && !scrollwheel_scrolling) return;
int x = _cursor.pos.x;
@@ -1733,7 +1734,7 @@
if (vp != NULL && (_game_mode == GM_MENU || IsGeneratingWorld())) return;
if (mousewheel != 0) {
- if (_patches.scrollwheel_scrolling == 0) {
+ if (_settings.gui.scrollwheel_scrolling == 0) {
/* Send mousewheel event to window */
w->OnMouseWheel(mousewheel);
}
@@ -2058,7 +2059,7 @@
w = FindWindowById(WC_MAIN_TOOLBAR, 0);
}
- switch (_patches.toolbar_pos) {
+ switch (_settings.gui.toolbar_pos) {
case 1: w->left = (_screen.width - w->width) / 2; break;
case 2: w->left = _screen.width - w->width; break;
default: w->left = 0;
--- a/src/window_gui.h Mon May 26 11:36:42 2008 +0000
+++ b/src/window_gui.h Mon May 26 13:52:59 2008 +0000
@@ -426,7 +426,10 @@
class PickerWindowBase : public Window {
public:
- PickerWindowBase(const WindowDesc *desc) : Window(desc) {}; // nothing special yet, just propagation
+ PickerWindowBase(const WindowDesc *desc, Window *parent) : Window(desc)
+ {
+ this->parent = parent;
+ };
virtual ~PickerWindowBase();
};
--- a/src/yapf/yapf_base.hpp Mon May 26 11:36:42 2008 +0000
+++ b/src/yapf/yapf_base.hpp Mon May 26 13:52:59 2008 +0000
@@ -6,6 +6,7 @@
#define YAPF_BASE_HPP
#include "../debug.h"
+#include "../settings_type.h"
extern int _total_pf_time_us;
@@ -52,7 +53,7 @@
protected:
Node* m_pBestDestNode; ///< pointer to the destination node found at last round
Node* m_pBestIntermediateNode; ///< here should be node closest to the destination if path not found
- const YapfSettings *m_settings; ///< current settings (_patches.yapf)
+ const YAPFSettings *m_settings; ///< current settings (_settings.yapf)
int m_max_search_nodes; ///< maximum number of nodes we are allowed to visit before we give up
const Vehicle* m_veh; ///< vehicle that we are trying to drive
@@ -73,7 +74,7 @@
FORCEINLINE CYapfBaseT()
: m_pBestDestNode(NULL)
, m_pBestIntermediateNode(NULL)
- , m_settings(&_patches.yapf)
+ , m_settings(&_settings.pf.yapf)
, m_max_search_nodes(PfGetSettings().max_search_nodes)
, m_veh(NULL)
, m_stats_cost_calcs(0)
@@ -91,7 +92,7 @@
public:
/// return current settings (can be custom - player based - but later)
- FORCEINLINE const YapfSettings& PfGetSettings() const
+ FORCEINLINE const YAPFSettings& PfGetSettings() const
{
return *m_settings;
}
--- a/src/yapf/yapf_rail.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/yapf/yapf_rail.cpp Mon May 26 13:52:59 2008 +0000
@@ -254,7 +254,7 @@
PfnChooseRailTrack pfnChooseRailTrack = &CYapfRail1::stChooseRailTrack;
// check if non-default YAPF type needed
- if (_patches.forbid_90_deg) {
+ if (_settings.pf.forbid_90_deg) {
pfnChooseRailTrack = &CYapfRail2::stChooseRailTrack; // Trackdir, forbid 90-deg
}
@@ -311,7 +311,7 @@
PfnCheckReverseTrain pfnCheckReverseTrain = CYapfRail1::stCheckReverseTrain;
// check if non-default YAPF type needed
- if (_patches.forbid_90_deg) {
+ if (_settings.pf.forbid_90_deg) {
pfnCheckReverseTrain = &CYapfRail2::stCheckReverseTrain; // Trackdir, forbid 90-deg
}
@@ -341,7 +341,7 @@
PfnFindNearestDepotTwoWay pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail1::stFindNearestDepotTwoWay;
// check if non-default YAPF type needed
- if (_patches.forbid_90_deg) {
+ if (_settings.pf.forbid_90_deg) {
pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail2::stFindNearestDepotTwoWay; // Trackdir, forbid 90-deg
}
--- a/src/yapf/yapf_road.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/yapf/yapf_road.cpp Mon May 26 13:52:59 2008 +0000
@@ -407,7 +407,7 @@
PfnChooseRoadTrack pfnChooseRoadTrack = &CYapfRoad2::stChooseRoadTrack; // default: ExitDir, allow 90-deg
// check if non-default YAPF type should be used
- if (_patches.yapf.disable_node_optimization)
+ if (_settings.pf.yapf.disable_node_optimization)
pfnChooseRoadTrack = &CYapfRoad1::stChooseRoadTrack; // Trackdir, allow 90-deg
Trackdir td_ret = pfnChooseRoadTrack(v, tile, enterdir);
@@ -421,7 +421,7 @@
PfnDistanceToTile pfnDistanceToTile = &CYapfRoad2::stDistanceToTile; // default: ExitDir, allow 90-deg
// check if non-default YAPF type should be used
- if (_patches.yapf.disable_node_optimization)
+ if (_settings.pf.yapf.disable_node_optimization)
pfnDistanceToTile = &CYapfRoad1::stDistanceToTile; // Trackdir, allow 90-deg
// measure distance in YAPF units
@@ -450,7 +450,7 @@
PfnFindNearestDepot pfnFindNearestDepot = &CYapfRoadAnyDepot2::stFindNearestDepot;
// check if non-default YAPF type should be used
- if (_patches.yapf.disable_node_optimization)
+ if (_settings.pf.yapf.disable_node_optimization)
pfnFindNearestDepot = &CYapfRoadAnyDepot1::stFindNearestDepot; // Trackdir, allow 90-deg
Depot* ret = pfnFindNearestDepot(v, tile, trackdir);
--- a/src/yapf/yapf_settings.h Mon May 26 11:36:42 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/* $Id$ */
-
-/** @file yapf_settings.h Penalty settings for YAPF. */
-
-#if !defined(YAPF_SETTINGS_H) || defined(YS_DEF)
-
-# ifndef YAPF_SETTINGS_H
-# define YAPF_SETTINGS_H
-# endif
-
-# ifndef YS_DEF
-/*
- * if YS_DEF is not defined, we will only do following declaration:
- * struct YapfSettings {
- * bool disable_node_optimization;
- * uint32 max_search_nodes;
- * .... all other yapf related settings ...
- * };
- *
- * otherwise we will just expand YS_DEF_xx macros and then #undef them
- */
-# define YS_DEF_BEGIN struct YapfSettings {
-# define YS_DEF(type, name) type name;
-# define YS_DEF_END };
-
-# endif /* !YS_DEF */
-
-# ifndef YS_DEF_BEGIN
-# define YS_DEF_BEGIN
-# endif // YS_DEF_BEGIN
-
-# ifndef YS_DEF_END
-# define YS_DEF_END
-# endif // YS_DEF_END
-
-YS_DEF_BEGIN
- YS_DEF(bool , disable_node_optimization) ///< whether to use exit-dir instead of trackdir in node key
- YS_DEF(uint32, max_search_nodes) ///< stop path-finding when this number of nodes visited
- YS_DEF(bool , ship_use_yapf) ///< use YAPF for ships
- YS_DEF(bool , road_use_yapf) ///< use YAPF for road
- YS_DEF(bool , rail_use_yapf) ///< use YAPF for rail
- YS_DEF(uint32, road_slope_penalty) ///< penalty for up-hill slope
- YS_DEF(uint32, road_curve_penalty) ///< penalty for curves
- YS_DEF(uint32, road_crossing_penalty) ///< penalty for level crossing
- YS_DEF(uint32, road_stop_penalty) ///< penalty for going through a drive-through road stop
- YS_DEF(bool , rail_firstred_twoway_eol) ///< treat first red two-way signal as dead end
- YS_DEF(uint32, rail_firstred_penalty) ///< penalty for first red signal
- YS_DEF(uint32, rail_firstred_exit_penalty) ///< penalty for first red exit signal
- YS_DEF(uint32, rail_lastred_penalty) ///< penalty for last red signal
- YS_DEF(uint32, rail_lastred_exit_penalty) ///< penalty for last red exit signal
- YS_DEF(uint32, rail_station_penalty) ///< penalty for non-target station tile
- YS_DEF(uint32, rail_slope_penalty) ///< penalty for up-hill slope
- YS_DEF(uint32, rail_curve45_penalty) ///< penalty for curve
- YS_DEF(uint32, rail_curve90_penalty) ///< penalty for 90-deg curve
- YS_DEF(uint32, rail_depot_reverse_penalty) ///< penalty for reversing in the depot
- YS_DEF(uint32, rail_crossing_penalty) ///< penalty for level crossing
- YS_DEF(uint32, rail_look_ahead_max_signals)///< max. number of signals taken into consideration in look-ahead load balancer
- YS_DEF(int32 , rail_look_ahead_signal_p0) ///< constant in polynomial penalty function
- YS_DEF(int32 , rail_look_ahead_signal_p1) ///< constant in polynomial penalty function
- YS_DEF(int32 , rail_look_ahead_signal_p2) ///< constant in polynomial penalty function
-
- YS_DEF(uint32, rail_longer_platform_penalty) ///< penalty for longer station platform than train
- YS_DEF(uint32, rail_longer_platform_per_tile_penalty) ///< penalty for longer station platform than train (per tile)
- YS_DEF(uint32, rail_shorter_platform_penalty) ///< penalty for shorter station platform than train
- YS_DEF(uint32, rail_shorter_platform_per_tile_penalty) ///< penalty for shorter station platform than train (per tile)
-YS_DEF_END
-
-#undef YS_DEF_BEGIN
-#undef YS_DEF
-#undef YS_DEF_END
-
-#endif /* !YAPF_SETTINGS_H || YS_DEF */
--- a/src/yapf/yapf_ship.cpp Mon May 26 11:36:42 2008 +0000
+++ b/src/yapf/yapf_ship.cpp Mon May 26 13:52:59 2008 +0000
@@ -154,9 +154,9 @@
PfnChooseShipTrack pfnChooseShipTrack = CYapfShip2::ChooseShipTrack; // default: ExitDir, allow 90-deg
// check if non-default YAPF type needed
- if (_patches.forbid_90_deg)
+ if (_settings.pf.forbid_90_deg)
pfnChooseShipTrack = &CYapfShip3::ChooseShipTrack; // Trackdir, forbid 90-deg
- else if (_patches.yapf.disable_node_optimization)
+ else if (_settings.pf.yapf.disable_node_optimization)
pfnChooseShipTrack = &CYapfShip1::ChooseShipTrack; // Trackdir, allow 90-deg
Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks);