Changeset - r19182:8f0b5a1acb1c
[Not reviewed]
master
0 4 0
rubidium - 13 years ago 2012-03-25 19:46:59
rubidium@openttd.org
(svn r24070) -Fix [FS#5098]: the 'last joined' server was not properly selected anymore (adf88)
4 files changed with 10 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/network/network_gamelist.cpp
Show inline comments
 
@@ -59,13 +59,13 @@ static void NetworkGameListHandleDelayed
 
				strecpy(item->info.server_name, ins_item->info.server_name, lastof(item->info.server_name));
 
				strecpy(item->info.hostname, ins_item->info.hostname, lastof(item->info.hostname));
 
				item->online = false;
 
			}
 
			item->manually |= ins_item->manually;
 
			if (item->manually) NetworkRebuildHostList();
 
			UpdateNetworkGameWindow(false);
 
			UpdateNetworkGameWindow();
 
		}
 
		free(ins_item);
 
	}
 
	_network_game_list_mutex->EndCritical();
 
}
 

	
 
@@ -102,13 +102,13 @@ NetworkGameList *NetworkGameListAddItem(
 
		_network_game_list = item;
 
	} else {
 
		prev_item->next = item;
 
	}
 
	DEBUG(net, 4, "[gamelist] added server to list");
 

	
 
	UpdateNetworkGameWindow(false);
 
	UpdateNetworkGameWindow();
 

	
 
	return item;
 
}
 

	
 
/**
 
 * Remove an item from the gamelist linked list
 
@@ -129,13 +129,13 @@ void NetworkGameListRemoveItem(NetworkGa
 
			ClearGRFConfigList(&remove->info.grfconfig);
 
			free(remove);
 
			remove = NULL;
 

	
 
			DEBUG(net, 4, "[gamelist] removed server from list");
 
			NetworkRebuildHostList();
 
			UpdateNetworkGameWindow(false);
 
			UpdateNetworkGameWindow();
 
			return;
 
		}
 
		prev_item = item;
 
	}
 
}
 

	
src/network/network_gui.cpp
Show inline comments
 
@@ -69,15 +69,15 @@ void SortNetworkLanguages()
 

	
 
/**
 
 * Update the network new window because a new server is
 
 * 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<NetworkGameList*> GUIGameServerList;
 
typedef uint16 ServerListPosition;
 
static const ServerListPosition SLP_INVALID = 0xFFFF;
 

	
 
@@ -435,23 +435,24 @@ protected:
 
		this->vscroll->ScrollTowards(this->list_pos);
 
	}
 

	
 
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);
 

	
 
		ttd_strlcpy(this->edit_str_buf, _settings_client.network.client_name, this->edit_str_size);
 
		this->afilter = CS_ALPHANUMERAL;
 
		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);
 
@@ -788,16 +789,12 @@ public:
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	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();
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
src/network/network_internal.h
Show inline comments
 
@@ -142,13 +142,13 @@ extern CompanyMask _network_company_pass
 

	
 
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);
 

	
 
/* From network_command.cpp */
 
/**
 
 * Everything we need to know about a command to be able to execute it.
src/network/network_udp.cpp
Show inline comments
 
@@ -392,13 +392,13 @@ void ClientNetworkUDPSocketHandler::Rece
 
	/* Check if we are allowed on this server based on the revision-match */
 
	item->info.version_compatible = IsNetworkCompatibleVersion(item->info.server_revision);
 
	item->info.compatible &= item->info.version_compatible; // Already contains match for GRFs
 

	
 
	item->online = true;
 

	
 
	UpdateNetworkGameWindow(false);
 
	UpdateNetworkGameWindow();
 
}
 

	
 
void ClientNetworkUDPSocketHandler::Receive_MASTER_RESPONSE_LIST(Packet *p, NetworkAddress *client_addr)
 
{
 
	/* packet begins with the protocol version (uint8)
 
	 * then an uint16 which indicates how many
0 comments (0 inline, 0 general)