From 47e7a982078ab866726f5a1371930561a2519115 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 18 Nov 2011 21:15:09 +0000 Subject: [PATCH] (svn r23257) [1.1] -Backport from trunk: - Fix: [NoAI] Hide AIObject from the documentation as it cannot be used (r23204, r23201) - Fix: [Network] Unstable sorting in the network list when two servers had the exact same name [FS#4829] (r23202) - Fix: Oil rigs that "expired" did not get removed from the station list [FS#4822] (r23199) --- src/ai/api/Doxyfile | 2 +- src/ai/api/ai_bridge.hpp | 2 +- src/ai/api/ai_event_types.hpp | 2 +- src/ai/api/ai_info_docs.hpp | 2 +- src/ai/api/ai_list.hpp | 4 ++-- src/ai/api/ai_object.hpp | 9 ++------- src/ai/api/ai_order.hpp | 4 ++-- src/ai/api/ai_tunnel.hpp | 4 ++-- src/ai/api/squirrel_export.awk | 6 +++--- src/network/network_gui.cpp | 3 ++- src/order_backup.cpp | 3 +++ src/order_base.h | 2 +- src/order_cmd.cpp | 21 +++++++++++++++++++++ src/station.cpp | 7 ++++++- 14 files changed, 48 insertions(+), 23 deletions(-) diff --git a/src/ai/api/Doxyfile b/src/ai/api/Doxyfile index ae031b6c86..f830dbd180 100644 --- a/src/ai/api/Doxyfile +++ b/src/ai/api/Doxyfile @@ -206,7 +206,7 @@ EXPAND_ONLY_PREDEF = YES SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = -PREDEFINED = DOXYGEN_SKIP +PREDEFINED = DOXYGEN_AI_DOCS EXPAND_AS_DEFINED = DEF_COMMAND SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- diff --git a/src/ai/api/ai_bridge.hpp b/src/ai/api/ai_bridge.hpp index 78f62522ef..92204d1233 100644 --- a/src/ai/api/ai_bridge.hpp +++ b/src/ai/api/ai_bridge.hpp @@ -109,7 +109,7 @@ public: */ static int32 GetMinLength(BridgeID bridge_id); -#ifndef DOXYGEN_SKIP +#ifndef DOXYGEN_AI_DOCS /** * Internal function to help BuildBridge in case of road. */ diff --git a/src/ai/api/ai_event_types.hpp b/src/ai/api/ai_event_types.hpp index 51bfa6cd96..6dda3be443 100644 --- a/src/ai/api/ai_event_types.hpp +++ b/src/ai/api/ai_event_types.hpp @@ -278,7 +278,7 @@ public: */ Money GetRunningCost(); -#ifdef DOXYGEN_SKIP +#ifdef DOXYGEN_AI_DOCS /** * Get the type of the offered engine. * @return The type the engine has. diff --git a/src/ai/api/ai_info_docs.hpp b/src/ai/api/ai_info_docs.hpp index 8eb54d3c15..93e039b650 100644 --- a/src/ai/api/ai_info_docs.hpp +++ b/src/ai/api/ai_info_docs.hpp @@ -10,7 +10,7 @@ /** @file ai_info_docs.hpp Description of the functions an AI can/must provide in AIInfo. */ /* This file exists purely for doxygen purposes. */ -#ifdef DOXYGEN_SKIP +#ifdef DOXYGEN_AI_DOCS /** * 'Abstract' class of the class AIs/AI libraries use to register themselves. * diff --git a/src/ai/api/ai_list.hpp b/src/ai/api/ai_list.hpp index ce1c8e04ed..05f7aeb4c0 100644 --- a/src/ai/api/ai_list.hpp +++ b/src/ai/api/ai_list.hpp @@ -239,7 +239,7 @@ public: */ void KeepList(AIList *list); -#ifndef DOXYGEN_SKIP +#ifndef DOXYGEN_AI_DOCS /** * Used for 'foreach()' and [] get from Squirrel. */ @@ -280,7 +280,7 @@ public: * list.Valuate(MyVal, 12); */ void Valuate(void *valuator_function, int params, ...); -#endif /* DOXYGEN_SKIP */ +#endif /* DOXYGEN_AI_DOCS */ }; #endif /* AI_LIST_HPP */ diff --git a/src/ai/api/ai_object.hpp b/src/ai/api/ai_object.hpp index 02311745ff..bcb4ea0640 100644 --- a/src/ai/api/ai_object.hpp +++ b/src/ai/api/ai_object.hpp @@ -38,6 +38,7 @@ class AIObject : public SimpleCountedObject { friend void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2); friend class AIInstance; friend class AIController; +#ifndef DOXYGEN_AI_DOCS protected: /** * Executes a raw DoCommand for the AI. @@ -180,51 +181,45 @@ protected: public: /** * Store the latest result of a DoCommand per company. - * @note NEVER use this yourself in your AI! * @param res The result of the last command. */ static void SetLastCommandRes(bool res); /** * Store a new_vehicle_id per company. - * @note NEVER use this yourself in your AI! * @param vehicle_id The new VehicleID. */ static void SetNewVehicleID(VehicleID vehicle_id); /** * Store a new_sign_id per company. - * @note NEVER use this yourself in your AI! * @param sign_id The new SignID. */ static void SetNewSignID(SignID sign_id); /** * Store a new_tunnel_endtile per company. - * @note NEVER use this yourself in your AI! * @param tile The new TileIndex. */ static void SetNewTunnelEndtile(TileIndex tile); /** * Store a new_group_id per company. - * @note NEVER use this yourself in your AI! * @param group_id The new GroupID. */ static void SetNewGroupID(GroupID group_id); /** * Store a allow_do_command per company. - * @note NEVER use this yourself in your AI! * @param allow The new allow. */ static void SetAllowDoCommand(bool allow); /** * Get the pointer to store log message in. - * @note NEVER use this yourself in your AI! */ static void *&GetLogPointer(); +#endif /* DOXYGEN_AI_DOCS */ }; #endif /* AI_OBJECT_HPP */ diff --git a/src/ai/api/ai_order.hpp b/src/ai/api/ai_order.hpp index 14f07e6de0..6d10039e13 100644 --- a/src/ai/api/ai_order.hpp +++ b/src/ai/api/ai_order.hpp @@ -443,12 +443,12 @@ public: */ static bool RemoveOrder(VehicleID vehicle_id, OrderPosition order_position); -#ifndef DOXYGEN_SKIP +#ifndef DOXYGEN_AI_DOCS /** * Internal function to help SetOrderFlags. */ static bool _SetOrderFlags(); -#endif /* DOXYGEN_SKIP */ +#endif /* DOXYGEN_AI_DOCS */ /** * Changes the order flags of the given order. diff --git a/src/ai/api/ai_tunnel.hpp b/src/ai/api/ai_tunnel.hpp index f1d8beae3f..b788f45114 100644 --- a/src/ai/api/ai_tunnel.hpp +++ b/src/ai/api/ai_tunnel.hpp @@ -65,7 +65,7 @@ public: */ static TileIndex GetOtherTunnelEnd(TileIndex tile); -#ifndef DOXYGEN_SKIP +#ifndef DOXYGEN_AI_DOCS /** * Internal function to help BuildTunnel in case of road. */ @@ -75,7 +75,7 @@ public: * Internal function to help BuildTunnel in case of road. */ static bool _BuildTunnelRoad2(); -#endif /* DOXYGEN_SKIP */ +#endif /* DOXYGEN_AI_DOCS */ /** * Builds a tunnel starting at start. The direction of the tunnel depends diff --git a/src/ai/api/squirrel_export.awk b/src/ai/api/squirrel_export.awk index dcd39547e4..5a817f94da 100644 --- a/src/ai/api/squirrel_export.awk +++ b/src/ai/api/squirrel_export.awk @@ -102,9 +102,9 @@ BEGIN { /^( *)private/ { if (cls_level == 1) public = "false"; next; } # Ignore special doxygen blocks -/^#ifndef DOXYGEN_SKIP/ { doxygen_skip = "next"; next; } -/^#ifdef DOXYGEN_SKIP/ { doxygen_skip = "true"; next; } -/^#endif \/\* DOXYGEN_SKIP \*\// { doxygen_skip = "false"; next; } +/^#ifndef DOXYGEN_AI_DOCS/ { doxygen_skip = "next"; next; } +/^#ifdef DOXYGEN_AI_DOCS/ { doxygen_skip = "true"; next; } +/^#endif \/\* DOXYGEN_AI_DOCS \*\// { doxygen_skip = "false"; next; } /^#else/ { if (doxygen_skip == "next") { doxygen_skip = "true"; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index ccf40238e0..859ffc15a9 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -280,7 +280,8 @@ protected: /** Sort servers by name. */ static int CDECL NGameNameSorter(NetworkGameList * const *a, NetworkGameList * const *b) { - return strnatcmp((*a)->info.server_name, (*b)->info.server_name); // Sort by name (natural sorting). + int r = strnatcmp((*a)->info.server_name, (*b)->info.server_name); // Sort by name (natural sorting). + return r == 0 ? (*a)->address.CompareTo((*b)->address) : r; } /** diff --git a/src/order_backup.cpp b/src/order_backup.cpp index 8764f6b802..2a0b7be216 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -16,6 +16,7 @@ #include "network/network_func.h" #include "order_backup.h" #include "vehicle_base.h" +#include "window_func.h" OrderBackupPool _order_backup_pool("BackupOrder"); INSTANTIATE_POOL_METHODS(OrderBackup) @@ -84,6 +85,8 @@ void OrderBackup::DoRestore(Vehicle *v) } else if (this->orders != NULL && OrderList::CanAllocateItem()) { v->orders.list = new OrderList(this->orders, v); this->orders = NULL; + /* Make sure buoys/oil rigs are updated in the station list. */ + InvalidateWindowClassesData(WC_STATION_LIST, 0); } uint num_orders = v->GetNumOrders(); diff --git a/src/order_base.h b/src/order_base.h index 241e8b1b39..9eba338ab8 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -51,7 +51,7 @@ public: uint16 travel_time; ///< How long in ticks the journey to this destination should take. Order() : refit_cargo(CT_NO_REFIT) {} - ~Order() {} + ~Order(); Order(uint32 packed); diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 6a3893950a..80dc0ce719 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -41,6 +41,19 @@ INSTANTIATE_POOL_METHODS(Order) OrderListPool _orderlist_pool("OrderList"); INSTANTIATE_POOL_METHODS(OrderList) +/** Clean everything up. */ +Order::~Order() +{ + if (CleaningPool()) return; + + /* We can visit oil rigs and buoys that are not our own. They will be shown in + * the list of stations. So, we need to invalidate that window if needed. */ + if (this->IsType(OT_GOTO_STATION) || this->IsType(OT_GOTO_WAYPOINT)) { + BaseStation *bs = BaseStation::GetIfValid(this->GetDestination()); + if (bs != NULL && bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0); + } +} + /** * 'Free' the order * @note ONLY use on "current_order" vehicle orders! @@ -367,6 +380,14 @@ void OrderList::InsertOrderAt(Order *new_order, int index) ++this->num_orders; if (!new_order->IsType(OT_IMPLICIT)) ++this->num_manual_orders; this->timetable_duration += new_order->wait_time + new_order->travel_time; + + /* We can visit oil rigs and buoys that are not our own. They will be shown in + * the list of stations. So, we need to invalidate that window if needed. */ + if (new_order->IsType(OT_GOTO_STATION) || new_order->IsType(OT_GOTO_WAYPOINT)) { + BaseStation *bs = BaseStation::Get(new_order->GetDestination()); + if (bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0); + } + } diff --git a/src/station.cpp b/src/station.cpp index 9f59d72f81..5ec0be4e22 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -90,7 +90,12 @@ Station::~Station() } } - InvalidateWindowData(WC_STATION_LIST, this->owner, 0); + if (this->owner == OWNER_NONE) { + /* Invalidate all in case of oil rigs. */ + InvalidateWindowClassesData(WC_STATION_LIST, 0); + } else { + InvalidateWindowData(WC_STATION_LIST, this->owner, 0); + } DeleteWindowById(WC_STATION_VIEW, index);