From 67dd9ffe8c2b90d01682b260327f52ea174fb892 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 18 Jul 2019 17:46:02 +0100 Subject: [PATCH 1/8] Use light blue colour for station tile coverage highlight --- src/viewport.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/viewport.cpp b/src/viewport.cpp index fd2b70cdc5..b593e2c56c 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1110,6 +1110,7 @@ enum TileHighlightType { THT_WHITE, THT_BLUE, THT_RED, + THT_LIGHT_BLUE, }; const Station *_viewport_highlight_station; ///< Currently selected station for coverage area highlight @@ -1123,7 +1124,7 @@ const Town *_viewport_highlight_town; ///< Currently selected town for cov static TileHighlightType GetTileHighlightType(TileIndex t) { if (_viewport_highlight_station != nullptr) { - if (IsTileType(t, MP_STATION) && GetStationIndex(t) == _viewport_highlight_station->index) return THT_WHITE; + if (IsTileType(t, MP_STATION) && GetStationIndex(t) == _viewport_highlight_station->index) return THT_LIGHT_BLUE; if (_viewport_highlight_station->TileIsInCatchment(t)) return THT_BLUE; } @@ -1161,6 +1162,7 @@ static void DrawTileHighlightType(const TileInfo *ti, TileHighlightType tht) case THT_WHITE: DrawTileSelectionRect(ti, PAL_NONE); break; case THT_BLUE: DrawTileSelectionRect(ti, PALETTE_SEL_TILE_BLUE); break; case THT_RED: DrawTileSelectionRect(ti, PALETTE_TILE_RED_PULSATING); break; + case THT_LIGHT_BLUE: DrawTileSelectionRect(ti, SPR_ZONING_INNER_HIGHLIGHT_LIGHT_BLUE); break; } } From 163192b5e079da312972a0d0a2041aaf301e57a8 Mon Sep 17 00:00:00 2001 From: stormcone <48624099+stormcone@users.noreply.github.com> Date: Tue, 23 Jul 2019 21:31:45 +0200 Subject: [PATCH 2/8] Fix #7667: Buying an engine after buying wagons doesn't give a complete train. (cherry picked from commit 2e686ad5d5cb3ae0a3e50b79050af74f672e7854) --- src/vehicle_cmd.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 4d8cec69a8..55cd267462 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -147,10 +147,10 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint Vehicle *v = nullptr; switch (type) { - case VEH_TRAIN: value.AddCost(CmdBuildRailVehicle(tile, subflags, e, GB(p1, 24, 8), &v)); break; - case VEH_ROAD: value.AddCost(CmdBuildRoadVehicle(tile, subflags, e, GB(p1, 24, 8), &v)); break; - case VEH_SHIP: value.AddCost(CmdBuildShip (tile, subflags, e, GB(p1, 24, 8), &v)); break; - case VEH_AIRCRAFT: value.AddCost(CmdBuildAircraft (tile, subflags, e, GB(p1, 24, 8), &v)); break; + case VEH_TRAIN: value.AddCost(CmdBuildRailVehicle(tile, subflags, e, GB(p1, 16, 8), &v)); break; + case VEH_ROAD: value.AddCost(CmdBuildRoadVehicle(tile, subflags, e, GB(p1, 16, 8), &v)); break; + case VEH_SHIP: value.AddCost(CmdBuildShip (tile, subflags, e, GB(p1, 16, 8), &v)); break; + case VEH_AIRCRAFT: value.AddCost(CmdBuildAircraft (tile, subflags, e, GB(p1, 16, 8), &v)); break; default: NOT_REACHED(); // Safe due to IsDepotTile() } From 99949d6559561deabbdd88f6009e150d5ecfc505 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 26 Jul 2019 18:26:09 +0100 Subject: [PATCH 3/8] Crash log: Fix counts in recent news messages header --- src/crashlog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crashlog.cpp b/src/crashlog.cpp index 16c0dd2b7b..abf13f5383 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -343,7 +343,7 @@ char *CrashLog::LogGamelog(char *buffer, const char *last) const char *CrashLog::LogRecentNews(char *buffer, const char *last) const { uint total = 0; - for (NewsItem *news = _latest_news; news != nullptr; news = news->next) { + for (NewsItem *news = _latest_news; news != nullptr; news = news->prev) { total++; } uint show = min(total, 32); From 942dd353805722cd3d786fd8fbcea7df999c7553 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 29 Jul 2019 18:48:59 +0100 Subject: [PATCH 4/8] Add game events for industry create/destroy --- src/industry_cmd.cpp | 3 +++ src/openttd.cpp | 2 ++ src/openttd.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 5b9646170f..96231cf15c 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -186,6 +186,8 @@ Industry::~Industry() for (Station *st : this->stations_near) { st->industries_near.erase(this); } + + if (_game_mode == GM_NORMAL) RegisterGameEvents(GEF_INDUSTRY_DELETE); } /** @@ -1865,6 +1867,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, 0); if (!_generating_world) PopulateStationsNearby(i); + if (_game_mode == GM_NORMAL) RegisterGameEvents(GEF_INDUSTRY_CREATE); } /** diff --git a/src/openttd.cpp b/src/openttd.cpp index a407cbd555..a106cec7b6 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1837,5 +1837,7 @@ char *DumpGameEventFlags(GameEventFlags events, char *b, const char *last) dump('t', GEF_TBTR_REPLACEMENT); dump('D', GEF_DISASTER_VEH); dump('c', GEF_TRAIN_CRASH); + dump('i', GEF_INDUSTRY_CREATE); + dump('j', GEF_INDUSTRY_DELETE); return b; } diff --git a/src/openttd.h b/src/openttd.h index e4523bbe69..39a5bf2825 100644 --- a/src/openttd.h +++ b/src/openttd.h @@ -93,6 +93,8 @@ enum GameEventFlags : uint32 { GEF_TBTR_REPLACEMENT = 1 << 3, ///< (t) CMD_TEMPLATE_REPLACE_VEHICLE has been called GEF_DISASTER_VEH = 1 << 4, ///< (D) A disaster vehicle exists or has been created GEF_TRAIN_CRASH = 1 << 5, ///< (c) A train crash has occurred + GEF_INDUSTRY_CREATE = 1 << 6, ///< (i) An industry has been created (in game) + GEF_INDUSTRY_DELETE = 1 << 7, ///< (j) An industry has been deleted (in game) }; DECLARE_ENUM_AS_BIT_SET(GameEventFlags) From 162fcb050e15375ec534a038f594b3455cf49316 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 29 Jul 2019 19:36:35 +0100 Subject: [PATCH 5/8] Only set TBTR replacement game event flag when replacement action occurs --- src/train_cmd.cpp | 2 ++ src/vehicle.cpp | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index a6f558ece5..a682361bfa 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -5446,6 +5446,8 @@ CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint3 } } + if (need_replacement || (need_refit && use_refit)) RegisterGameEvents(GEF_TBTR_REPLACEMENT); + /* define replacement behavior */ bool reuseDepot = tv->IsSetReuseDepotVehicles(); bool keepRemainders = tv->IsSetKeepRemainingVehicles(); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index c92880e7a9..1c2fedd63b 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1388,8 +1388,6 @@ void CallVehicleTicks() bool leaveDepot = it->second; _vehicles_to_autoreplace.erase(it); - RegisterGameEvents(GEF_TBTR_REPLACEMENT); - /* Store the position of the effect as the vehicle pointer will become invalid later */ int x = t->x_pos; int y = t->y_pos; From 89a6cc3e03b7d326be388a7a0dd2222d83e0d16f Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 29 Jul 2019 19:39:01 +0100 Subject: [PATCH 6/8] Add game event flag for virtual train creation --- src/openttd.cpp | 1 + src/openttd.h | 1 + src/train_cmd.cpp | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/openttd.cpp b/src/openttd.cpp index a106cec7b6..0d8cabc2ca 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1839,5 +1839,6 @@ char *DumpGameEventFlags(GameEventFlags events, char *b, const char *last) dump('c', GEF_TRAIN_CRASH); dump('i', GEF_INDUSTRY_CREATE); dump('j', GEF_INDUSTRY_DELETE); + dump('v', GEF_VIRT_TRAIN); return b; } diff --git a/src/openttd.h b/src/openttd.h index 39a5bf2825..8ea88939c7 100644 --- a/src/openttd.h +++ b/src/openttd.h @@ -95,6 +95,7 @@ enum GameEventFlags : uint32 { GEF_TRAIN_CRASH = 1 << 5, ///< (c) A train crash has occurred GEF_INDUSTRY_CREATE = 1 << 6, ///< (i) An industry has been created (in game) GEF_INDUSTRY_DELETE = 1 << 7, ///< (j) An industry has been deleted (in game) + GEF_VIRT_TRAIN = 1 << 8, ///< (v) A virtual train has been created }; DECLARE_ENUM_AS_BIT_SET(GameEventFlags) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index a682361bfa..2a146dc2a6 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -5255,6 +5255,8 @@ Train* CmdBuildVirtualRailVehicle(EngineID eid, StringID &error) return nullptr; } + RegisterGameEvents(GEF_VIRT_TRAIN); + if (rvi->railveh_type == RAILVEH_WAGON) { return CmdBuildVirtualRailWagon(e); } From d99b867f442eccc304fd51c850fb639fb0952d91 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 29 Jul 2019 22:49:24 +0100 Subject: [PATCH 7/8] Fix crash when removing signal from tunnel/bridge with trainless reservation --- src/rail_cmd.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index e61af4161f..6cb8be77f3 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1912,8 +1912,10 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1 auto check_reservation = [&](TileIndex t) { if (HasAcrossTunnelBridgeReservation(t)) { Train *v = GetTrainForReservation(t, FindFirstTrack(GetAcrossTunnelBridgeReservationTrackBits(t))); - if (v != nullptr) FreeTrainTrackReservation(v); - re_reserve_trains.push_back(v); + if (v != nullptr) { + FreeTrainTrackReservation(v); + re_reserve_trains.push_back(v); + } } }; check_reservation(tile); From 704eaf80f6554b1db8ffb098fd4e5a5125c6cd45 Mon Sep 17 00:00:00 2001 From: TTrebron Date: Sat, 27 Jul 2019 00:32:43 +0200 Subject: [PATCH 8/8] Fix #7655: Decrease buttons in cheat window do not work properly (cherry picked from commit 425cd3e4ca8cf6812bdf015c649a7bf4b76a71a1) --- src/cheat_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 2cd8b90f00..3d338e91a6 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -370,7 +370,7 @@ struct CheatWindow : Window { default: /* Take whatever the function returns */ - value = ce->proc(value + ((x >= 20 + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= 10 + this->box_width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1); + value = ce->proc(value + ((x >= 10 + this->box_width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= 10 + this->box_width + SETTING_BUTTON_WIDTH / 2) ? 1 : -1); /* The first cheat (money), doesn't return a different value. */ if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 10 + this->box_width + SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);