From ca66a61cc951e8da72b3a42742012cafcb1815f8 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 22 Aug 2009 15:38:42 +0000 Subject: [PATCH] (svn r17260) [0.7] -Backport from trunk: - Fix: Other tunnel end not shown if building rail tunnels and the first railtype is not available yet [FS#3141] (r17251) - Fix: One could, via unselect all, also unselect already installed content; it would not uninstall it though [FS#3137] (r17245) - Change: Make overbuilding the front tile of a road station/depot with road consistent with overbuilding the front tile of tunnels/bridges [FS#2802] (r17239) - Change [NoAI]: Load the API before compiling an AI script so AIs can subclass API classes and use API constants as part of their own constants (r17043) --- src/ai/ai_instance.cpp | 6 +++--- src/network/network_content.cpp | 2 +- src/rail_gui.cpp | 2 +- src/road_cmd.cpp | 9 ++++++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index e31c8772c5..fdf3809f72 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -119,6 +119,9 @@ AIInstance::AIInstance(AIInfo *info) : /* Register the AIController */ SQAIController_Register(this->engine); + /* Register the API functions and classes */ + this->RegisterAPI(); + /* Load and execute the script for this AI */ const char *main_script = info->GetMainScript(); if (strcmp(main_script, "%_dummy") == 0) { @@ -135,9 +138,6 @@ AIInstance::AIInstance(AIInfo *info) : this->Died(); return; } - - /* Register the API functions and classes */ - this->RegisterAPI(); } AIInstance::~AIInstance() diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 798f24fd0b..b884455920 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -606,7 +606,7 @@ void ClientNetworkContentSocketHandler::UnselectAll() { for (ContentIterator iter = this->infos.Begin(); iter != this->infos.End(); iter++) { ContentInfo *ci = *iter; - if (ci->IsSelected()) ci->state = ContentInfo::UNSELECTED; + if (ci->IsSelected() && ci->state != ContentInfo::ALREADY_HERE) ci->state = ContentInfo::UNSELECTED; } } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 875a4fee8b..31a4b687d3 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -752,7 +752,7 @@ struct BuildRailToolbarWindow : Window { virtual void OnPlacePresize(Point pt, TileIndex tile) { - DoCommand(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL); + DoCommand(tile, _cur_railtype, 0, DC_AUTO, CMD_BUILD_TUNNEL); VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); } diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 8142f09a9d..f38a789a8c 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -514,9 +514,11 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); break; - default: case ROAD_TILE_DEPOT: + if ((GetAnyRoadBits(tile, rt) & pieces) == pieces) return_cmd_error(STR_1007_ALREADY_BUILT); goto do_clear; + + default: NOT_REACHED(); } break; @@ -563,6 +565,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } case MP_STATION: { + if ((GetAnyRoadBits(tile, rt) & pieces) == pieces) return_cmd_error(STR_1007_ALREADY_BUILT); if (!IsDriveThroughStopTile(tile)) goto do_clear; RoadBits curbits = AxisToRoadBits(DiagDirToAxis(GetRoadStopDir(tile))); @@ -573,8 +576,8 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } break; case MP_TUNNELBRIDGE: - if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; - if (MirrorRoadBits(DiagDirToRoadBits(GetTunnelBridgeDirection(tile))) != pieces) return CMD_ERROR; + if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) goto do_clear; + if (MirrorRoadBits(DiagDirToRoadBits(GetTunnelBridgeDirection(tile))) != pieces) goto do_clear; if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); /* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */ if (HasVehicleOnTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile))) return CMD_ERROR;