summaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 293ce406d..8e7db97e7 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -32,6 +32,7 @@
#include "command_func.h"
#include "console_func.h"
#include "pathfinder/pathfinder_type.h"
+#include "layer_type.h"
#include "genworld.h"
#include "train.h"
#include "news_func.h"
@@ -64,6 +65,9 @@
#include "roadveh.h"
#include "fios.h"
#include "strings_func.h"
+#include "trafficlight_func.h"
+#include "industry.h"
+#include "cargodest_func.h"
#include "void_map.h"
#include "station_base.h"
@@ -1170,6 +1174,21 @@ static size_t ConvertLandscape(const char *value)
return LookupOneOfMany("normal|hilly|desert|candy", value);
}
+/**
+ * What to do when traffic light Setting was changed.
+ * @param p1 unused
+ * @return always 0
+ */
+static bool TLSettingChanged(int32 p1)
+{
+ /* Road building gui changed. */
+ MarkWholeScreenDirty();
+
+ /* If traffic lights got disabled, clear them all. */
+ if (!_settings_game.construction.traffic_lights) ClearAllTrafficLights();
+ return true;
+}
+
static bool CheckFreeformEdges(int32 p1)
{
if (_game_mode == GM_MENU) return true;
@@ -1253,6 +1272,64 @@ static bool StationCatchmentChanged(int32 p1)
return true;
}
+bool CargodestModeChanged(int32 p1)
+{
+ /* Clear route links and destinations for cargoes that aren't routed anymore. */
+ Station *st;
+ FOR_ALL_STATIONS(st) {
+ for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
+ if (CargoHasDestinations(cid)) continue;
+
+ /* Clear route links. */
+ for (RouteLinkList::iterator i = st->goods[cid].routes.begin(); i != st->goods[cid].routes.end(); ++i) {
+ delete *i;
+ }
+ st->goods[cid].routes.clear();
+
+ /* Remove destinations from cargo packets. */
+ for (StationCargoList::Iterator i = st->goods[cid].cargo.packets.begin(); i != st->goods[cid].cargo.packets.end(); ++i) {
+ (*i)->dest_id = INVALID_SOURCE;
+ (*i)->next_order = INVALID_ORDER;
+ (*i)->next_station = INVALID_STATION;
+ }
+ st->goods[cid].cargo.InvalidateCache();
+ }
+ }
+
+ Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ if (v->IsFrontEngine()) PrefillRouteLinks(v);
+ if (CargoHasDestinations(v->cargo_type)) continue;
+ /* Remove destination from all cargoes that aren't routed anymore. */
+ for (VehicleCargoList::Iterator i = v->cargo.packets.begin(); i != v->cargo.packets.end(); ++i) {
+ (*i)->dest_id = INVALID_SOURCE;
+ (*i)->next_order = INVALID_ORDER;
+ (*i)->next_station = INVALID_STATION;
+ }
+ v->cargo.InvalidateCache();
+ }
+
+ /* Clear all links for cargoes that aren't routed anymore. */
+ CargoSourceSink *css;
+ FOR_ALL_TOWNS(css) {
+ for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
+ if (!CargoHasDestinations(cid)) css->cargo_links[cid].Clear();
+ }
+ }
+ FOR_ALL_INDUSTRIES(css) {
+ for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
+ if (!CargoHasDestinations(cid)) css->cargo_links[cid].Clear();
+ }
+ }
+
+ /* Recount incoming cargo links. */
+ RebuildCargoLinkCounts();
+
+ /* Update remaining links. */
+ UpdateCargoLinks();
+
+ return true;
+}
#ifdef ENABLE_NETWORK