From 2a13e8c184a9f2aac8d169dc8123f38511a57763 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 26 Mar 2012 20:41:21 +0000 Subject: [PATCH] (svn r24075) [1.2] -Backport from trunk: - Fix: Reversing trains while they were entering or leaving a depot could lead to stuck trains [FS#5093] (r24071) - Fix: The 'last joined' server was not properly selected anymore [FS#5098] (r24070) - Fix: Immediately start querying the last joined server instead of waiting for the requery loop [FS#5097] (r24069, r24062) - Fix: Make the full snowedness level of houses the same as roads and rails [FS#5121] (r24064) --- src/network/network_gamelist.cpp | 6 +++--- src/network/network_gui.cpp | 14 ++++++-------- src/network/network_internal.h | 2 +- src/network/network_udp.cpp | 2 +- src/pbs.cpp | 3 ++- src/town_cmd.cpp | 7 +++---- src/train_cmd.cpp | 2 ++ 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp index 8df84a80e8..9acc09cd17 100644 --- a/src/network/network_gamelist.cpp +++ b/src/network/network_gamelist.cpp @@ -62,7 +62,7 @@ static void NetworkGameListHandleDelayedInsert() } item->manually |= ins_item->manually; if (item->manually) NetworkRebuildHostList(); - UpdateNetworkGameWindow(false); + UpdateNetworkGameWindow(); } free(ins_item); } @@ -105,7 +105,7 @@ NetworkGameList *NetworkGameListAddItem(NetworkAddress address) } DEBUG(net, 4, "[gamelist] added server to list"); - UpdateNetworkGameWindow(false); + UpdateNetworkGameWindow(); return item; } @@ -132,7 +132,7 @@ void NetworkGameListRemoveItem(NetworkGameList *remove) DEBUG(net, 4, "[gamelist] removed server from list"); NetworkRebuildHostList(); - UpdateNetworkGameWindow(false); + UpdateNetworkGameWindow(); return; } prev_item = item; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 2b15ef0fcd..151776d749 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -72,9 +72,9 @@ void SortNetworkLanguages() * found on the network. * @param unselect unselect the currently selected item */ -void UpdateNetworkGameWindow(bool unselect) +void UpdateNetworkGameWindow() { - InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME, unselect ? 1 : 0); + InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME, 0); } typedef GUIList GUIGameServerList; @@ -438,6 +438,9 @@ protected: public: NetworkGameWindow(const WindowDesc *desc) : QueryStringBaseWindow(NETWORK_CLIENT_NAME_LENGTH) { + this->list_pos = SLP_INVALID; + this->server = NULL; + this->CreateNestedTree(desc); this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR); this->FinishInitNested(desc, WN_NETWORK_WINDOW_GAME); @@ -447,11 +450,10 @@ public: InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, 120); this->SetFocusedWidget(WID_NG_CLIENT); - UpdateNetworkGameWindow(true); - this->field = WID_NG_CLIENT; this->last_joined = NetworkGameListAddItem(NetworkAddress(_settings_client.network.last_host, _settings_client.network.last_port)); this->server = this->last_joined; + if (this->last_joined != NULL) NetworkUDPQueryServer(this->last_joined->address); this->servers.SetListing(this->last_sorting); this->servers.SetSortFuncs(this->sorter_funcs); @@ -790,10 +792,6 @@ public: */ virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { - if (data == 1) { - this->server = NULL; - this->list_pos = SLP_INVALID; - } this->servers.ForceRebuild(); this->SetDirty(); } diff --git a/src/network/network_internal.h b/src/network/network_internal.h index b024b7c023..938682981e 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -145,7 +145,7 @@ void NetworkTCPQueryServer(NetworkAddress address); void GetBindAddresses(NetworkAddressList *addresses, uint16 port); void NetworkAddServer(const char *b); void NetworkRebuildHostList(); -void UpdateNetworkGameWindow(bool unselect); +void UpdateNetworkGameWindow(); bool IsNetworkCompatibleVersion(const char *version); diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index a1eef9a9ec..f58a393429 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -395,7 +395,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(Packet *p, NetworkAd item->online = true; - UpdateNetworkGameWindow(false); + UpdateNetworkGameWindow(); } void ClientNetworkUDPSocketHandler::Receive_MASTER_RESPONSE_LIST(Packet *p, NetworkAddress *client_addr) diff --git a/src/pbs.cpp b/src/pbs.cpp index 01e7b2f377..3dbd5b8830 100644 --- a/src/pbs.cpp +++ b/src/pbs.cpp @@ -369,7 +369,8 @@ Train *GetTrainForReservation(TileIndex tile, Track track) */ bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg) { - if (IsRailDepotTile(tile)) return true; + /* A depot is safe if we enter it, but not when we exit. */ + if (IsRailDepotTile(tile) && TrackdirToExitdir(trackdir) != GetRailDepotDirection(tile)) return true; if (IsTileType(tile, MP_RAILWAY)) { /* For non-pbs signals, stop on the signal tile. */ diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 87b55146ab..8731a5d789 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2171,8 +2171,8 @@ static bool BuildTownHouse(Town *t, TileIndex tile) /* no house allowed at all, bail out */ if (!CanBuildHouseHere(tile, t->index, false)) return false; - int z; - Slope slope = GetTileSlope(tile, &z); + Slope slope = GetTileSlope(tile); + int maxz = GetTileMaxZ(tile); /* Get the town zone type of the current tile, as well as the climate. * This will allow to easily compare with the specs of the new house to build */ @@ -2180,7 +2180,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile) /* Above snow? */ int land = _settings_game.game_creation.landscape; - if (land == LT_ARCTIC && z >= HighestSnowLine()) land = -1; + if (land == LT_ARCTIC && maxz > HighestSnowLine()) land = -1; uint bitmask = (1 << rad) + (1 << (land + 12)); @@ -2215,7 +2215,6 @@ static bool BuildTownHouse(Town *t, TileIndex tile) houses[num++] = (HouseID)i; } - int maxz = GetTileMaxZ(tile); TileIndex baseTile = tile; while (probability_max > 0) { diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 4473c5265c..101aeca0a1 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2200,6 +2200,8 @@ void FreeTrainTrackReservation(const Train *v, TileIndex origin, Trackdir orig_t bool free_tile = tile != v->tile || !(IsRailStationTile(v->tile) || IsTileType(v->tile, MP_TUNNELBRIDGE)); StationID station_id = IsRailStationTile(v->tile) ? GetStationIndex(v->tile) : INVALID_STATION; + /* A train inside a depot can't have a reservation. */ + if (v->track == TRACK_BIT_DEPOT) return; /* Don't free reservation if it's not ours. */ if (TracksOverlap(GetReservedTrackbits(tile) | TrackToTrackBits(TrackdirToTrack(td)))) return;