diff --git a/docs/multiplayer.txt b/docs/multiplayer.txt index 760e3aacae..7f4227cd8a 100644 --- a/docs/multiplayer.txt +++ b/docs/multiplayer.txt @@ -1,5 +1,5 @@ Multiplayer manual for OpenTTD -Last updated: 2011-01-20 +Last updated: 2011-02-16 ------------------------------------------------------------------------ @@ -17,6 +17,12 @@ Table of contents 1.0) Starting a server ---- ----------------- + - Make sure that you have your firewall of the computer as well as possible + routers or modems of the server configured such that: + * port 3979 is free for both UDP and TCP connections in- and outgoing + * port 3978 is free outbound for UDP in order to advertise with the master + server (if desired). Otherwise you'll have to tell players your IP. + * port 3977 if use of the admin interface is desired (see admin_network.txt) - Click "multiplayer" on the startup screen - Click "start server" - Type in a game name @@ -206,7 +212,8 @@ Table of contents 6.0) Troubleshooting ---- --------------- - My advertising server does not show up in list at servers.openttd.org - Run openttd with the '-d net=2' parameter, as this will show whether it - receives replies from the master server. If it does not receive replies it - is most likely that you need to configure your router to forward ports - 3979 (both TCP and UDP) to the computer that is hosting the game. + Run openttd with the '-d net=2' parameter. That will show which incoming + communication is received, whether the replies from the master server or + communication from an admin tool reach the programme. See section 1 + 'Starting a server' further up for the ports and protocols used by OpenTTD. + The ports can be configured in the config file. diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 8619bd6947..686877bf38 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -95,8 +95,14 @@ static uint16 ParseKeycode(const char *start, const char *end) uint16 code = ParseCode(start, cur); if (code == 0) return 0; if (code & WKC_SPECIAL_KEYS) { + /* Some completely wrong keycode we don't support. */ + if (code & ~WKC_SPECIAL_KEYS) return 0; keycode |= code; } else { + /* Ignore invalid keycodes */ + if (code >= 128) { + return 0; + } /* Ignore the code if it has more then 1 letter. */ if (keycode & ~WKC_SPECIAL_KEYS) return 0; keycode |= code; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 371e4dbe88..e62f2bcaee 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -347,7 +347,12 @@ protected: /** Sort the server list */ void SortNetworkGameList() { - if (!this->servers.Sort()) return; + bool did_sort = this->servers.Sort(); + /* In case of 0 or 1 servers there is no sorting, thus this->list_pos + * isn't set to a "sane" value. So, we only take the short way out + * when we did not (re)sort and we have a valid this->list_pos, or + * there are no servers to actually select. */ + if (!did_sort && (this->list_pos != SLP_INVALID || this->servers.Length() == 0)) return; /* After sorting ngl->sort_list contains the sorted items. Put these back * into the original list. Basically nothing has changed, we are only diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 463db68556..0b86031cb2 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -285,7 +285,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta NetworkClientSocket *cs; FOR_ALL_CLIENT_SOCKETS(cs) { if (cs->writable) { - if (cs->SendPackets() && cs->status == STATUS_MAP) { + if (cs->SendPackets() != SPS_CLOSED && cs->status == STATUS_MAP) { /* This client is in the middle of a map-send, call the function for that */ cs->SendMap(); } diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index badcb844cb..3ca3e3ddb9 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2419,7 +2419,7 @@ CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 try_clear = true; } else { /* Tell to find a new town. */ - o->town = NULL; + if (flags & DC_EXEC) o->town = NULL; } } }