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); 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); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 363c44634b..54fe847a26 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -193,6 +193,8 @@ Industry::~Industry() for (Station *st : this->stations_near) { st->industries_near.erase(this); } + + if (_game_mode == GM_NORMAL) RegisterGameEvents(GEF_INDUSTRY_DELETE); } /** @@ -1872,6 +1874,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 c5f6fc54fd..ac3b495d85 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1839,5 +1839,8 @@ 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); + dump('v', GEF_VIRT_TRAIN); return b; } diff --git a/src/openttd.h b/src/openttd.h index e4523bbe69..8ea88939c7 100644 --- a/src/openttd.h +++ b/src/openttd.h @@ -93,6 +93,9 @@ 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) + GEF_VIRT_TRAIN = 1 << 8, ///< (v) A virtual train has been created }; DECLARE_ENUM_AS_BIT_SET(GameEventFlags) diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 6d4a6ca8f7..cafc63e59f 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1926,8 +1926,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); diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index a6f558ece5..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); } @@ -5446,6 +5448,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 3d6cd86e01..ea67c4513f 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; 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() } diff --git a/src/viewport.cpp b/src/viewport.cpp index 5203af0f4b..06d452ac5e 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; } }