From ba8422354bbbe7b3a28db8a4bb3eaacff35cb655 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 13 Apr 2010 21:32:29 +0000 Subject: [PATCH] (svn r19623) [1.0] -Backport from trunk: - Fix: Company related graphs were not updated correctly after changing the company colour [FS#3763] (r19615) - Fix: Crash when opening a savegame with a waypoint from around 0.4.0 [FS#3756] (r19612) - Fix: Presence of online content was not properly updated after download due to duplicate slashes in the path (r19600) - Fix: [NewGRF] Setting industry prop 0x24 to 0 caused empty station names (r19590) --- bin/ai/regression/regression.nut | 1 + bin/ai/regression/regression.txt | 1 + src/ai/api/ai_changelog.hpp | 5 +++++ src/ai/api/ai_rail.cpp | 7 +++++++ src/ai/api/ai_rail.hpp | 12 ++++++++++++ src/ai/api/ai_rail.hpp.sq | 1 + src/company_cmd.cpp | 7 +++++++ src/graph_gui.cpp | 2 +- src/network/network_content.cpp | 1 + src/newgrf.cpp | 2 +- src/saveload/waypoint_sl.cpp | 7 ++++++- 11 files changed, 43 insertions(+), 3 deletions(-) diff --git a/bin/ai/regression/regression.nut b/bin/ai/regression/regression.nut index c27929d6b9..a54c643c3c 100644 --- a/bin/ai/regression/regression.nut +++ b/bin/ai/regression/regression.nut @@ -1027,6 +1027,7 @@ function Regression::RailTypeList() for (local i = list.Begin(); list.HasNext(); i = list.Next()) { print(" RailType: " + i); print(" IsRailTypeAvailable(): " + AIRail.IsRailTypeAvailable(i)); + print(" GetMaxSpeed(): " + AIRail.GetMaxSpeed(i)); } } diff --git a/bin/ai/regression/regression.txt b/bin/ai/regression/regression.txt index 5a50a0b5cb..d53666106d 100644 --- a/bin/ai/regression/regression.txt +++ b/bin/ai/regression/regression.txt @@ -7208,6 +7208,7 @@ ERROR: HasNext() is invalid as Begin() is never called ListDump: RailType: 0 IsRailTypeAvailable(): true + GetMaxSpeed(): 0 --Road-- Road diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp index 4aa6e7a51b..d79431811d 100644 --- a/src/ai/api/ai_changelog.hpp +++ b/src/ai/api/ai_changelog.hpp @@ -14,6 +14,11 @@ * functions may still be available if you return an older API version * in GetAPIVersion() in info.nut. * + * \b 1.0.1 + * + * API additions: + * \li AIRail::GetMaxSpeed + * * \b 1.0.0 * * API additions: diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp index ae349ccde0..1db02e274f 100644 --- a/src/ai/api/ai_rail.cpp +++ b/src/ai/api/ai_rail.cpp @@ -469,3 +469,10 @@ static bool IsValidSignalType(int signal_type) default: return -1; } } + +/* static */ int32 AIRail::GetMaxSpeed(RailType railtype) +{ + if (!AIRail::IsRailTypeAvailable(railtype)) return -1; + + return ::GetRailTypeInfo((::RailType)railtype)->max_speed; +} diff --git a/src/ai/api/ai_rail.hpp b/src/ai/api/ai_rail.hpp index e82d01ae9f..5a8a3d111a 100644 --- a/src/ai/api/ai_rail.hpp +++ b/src/ai/api/ai_rail.hpp @@ -440,6 +440,18 @@ public: * @return The baseprice of building the given object. */ static Money GetBuildCost(RailType railtype, BuildType build_type); + + /** + * Get the maximum speed of trains running on this railtype. + * @param railtype The railtype to get the maximum speed of. + * @pre IsRailTypeAvailable(railtype) + * @return The maximum speed trains can run on this railtype + * or 0 if there is no limit. + * @note The speed is in OpenTTD's internal speed unit. + * This is mph / 1.6, which is roughly km/h. + * To get km/h multiply this number by 1.00584. + */ + static int32 GetMaxSpeed(RailType railtype); }; #endif /* AI_RAIL_HPP */ diff --git a/src/ai/api/ai_rail.hpp.sq b/src/ai/api/ai_rail.hpp.sq index 9184cb41c1..d39571ad20 100644 --- a/src/ai/api/ai_rail.hpp.sq +++ b/src/ai/api/ai_rail.hpp.sq @@ -106,6 +106,7 @@ void SQAIRail_Register(Squirrel *engine) SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildSignal, "BuildSignal", 4, ".iii"); SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveSignal, "RemoveSignal", 3, ".ii"); SQAIRail.DefSQStaticMethod(engine, &AIRail::GetBuildCost, "GetBuildCost", 3, ".ii"); + SQAIRail.DefSQStaticMethod(engine, &AIRail::GetMaxSpeed, "GetMaxSpeed", 2, ".i"); SQAIRail.PostRegister(engine); } diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 29343a09b9..1439df596d 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -965,6 +965,13 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, ResetVehicleColourMap(); MarkWholeScreenDirty(); + /* All graph related to companies use the company colour. */ + InvalidateWindowData(WC_INCOME_GRAPH, 0); + InvalidateWindowData(WC_OPERATING_PROFIT, 0); + InvalidateWindowData(WC_DELIVERED_CARGO, 0); + InvalidateWindowData(WC_PERFORMANCE_HISTORY, 0); + InvalidateWindowData(WC_COMPANY_VALUE, 0); + /* Company colour data is indirectly cached. */ Vehicle *v; FOR_ALL_VEHICLES(v) { diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index b793c57f05..55bf5a494a 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -528,7 +528,7 @@ public: virtual void OnInvalidateData(int data) { - this->OnTick(); + this->UpdateStatistics(true); } /** diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 7e9dea5d40..e9c6103edf 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -604,6 +604,7 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l p = strrchr(str, '/'); check_not_null(p); + p++; // Start after the '/' char tmp[MAX_PATH]; if (strecpy(tmp, p, lastof(tmp)) == lastof(tmp)) { diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 881ba9e0c4..24673bd402 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2636,7 +2636,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, case 0x24: // name for nearby station indsp->station_name = buf->ReadWord(); - _string_to_grf_mapping[&indsp->station_name] = _cur_grffile->grfid; + if (indsp->station_name != STR_NULL) _string_to_grf_mapping[&indsp->station_name] = _cur_grffile->grfid; break; default: diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp index 2cd95e104f..ae5c36ac18 100644 --- a/src/saveload/waypoint_sl.cpp +++ b/src/saveload/waypoint_sl.cpp @@ -70,7 +70,12 @@ void MoveWaypointsToBaseStations() * waypoint struct. */ if (CheckSavegameVersion(17)) { for (OldWaypoint *wp = _old_waypoints.Begin(); wp != _old_waypoints.End(); wp++) { - if (wp->delete_ctr == 0 && HasBit(_m[wp->xy].m3, 4)) { + if (wp->delete_ctr != 0) continue; // The waypoint was deleted + + /* Waypoint indices were not added to the map prior to this. */ + _m[wp->xy].m2 = wp->index; + + if (HasBit(_m[wp->xy].m3, 4)) { wp->spec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1); } }