--- a/misc_gui.c Thu Feb 08 10:04:57 2007 +0000
+++ b/misc_gui.c Thu Feb 08 10:19:03 2007 +0000
@@ -1822,7 +1822,7 @@
/* Increase or decrease the value and clamp it to extremes */
value += (x >= 30) ? step : -step;
- clamp(value, ce->min, ce->max);
+ value = clamp(value, ce->min, ce->max);
// take whatever the function returns
value = ce->proc(value, (x >= 30) ? 1 : -1);
--- a/network.c Thu Feb 08 10:04:57 2007 +0000
+++ b/network.c Thu Feb 08 10:19:03 2007 +0000
@@ -1267,6 +1267,7 @@
} else if (_udp_client_socket != INVALID_SOCKET) {
NetworkUDPReceive(_udp_client_socket);
if (_network_udp_broadcast > 0) _network_udp_broadcast--;
+ NetworkGameListRequery();
}
}
--- a/network.h Thu Feb 08 10:04:57 2007 +0000
+++ b/network.h Thu Feb 08 10:19:03 2007 +0000
@@ -130,6 +130,7 @@
uint16 port;
bool online; // False if the server did not respond (default status)
bool manually; // True if the server was added manually
+ uint8 retries;
struct NetworkGameList *next;
} NetworkGameList;
--- a/network_gamelist.c Thu Feb 08 10:04:57 2007 +0000
+++ b/network_gamelist.c Thu Feb 08 10:19:03 2007 +0000
@@ -6,6 +6,10 @@
#include "debug.h"
#include "network_data.h"
#include "newgrf_config.h"
+#include "network_udp.h"
+
+/** Should we stop/contiue requerying of offline servers? */
+static bool _stop_requerying = false;
// This file handles the GameList
// Also, it handles the request to a server for data about the server
@@ -39,6 +43,7 @@
DEBUG(net, 4) ("[NET][GameList] Added server to list");
UpdateNetworkGameWindow(false);
+ _stop_requerying = false;
return item;
}
@@ -71,4 +76,38 @@
}
}
+enum {
+ MAX_GAME_LIST_REQUERY_COUNT = 5,
+ REQUERY_EVERY_X_GAMELOOPS = 60,
+};
+
+/** Requeries the (game) servers we have not gotten a reply from */
+void NetworkGameListRequery(void)
+{
+ static uint8 requery_cnt = 0;
+ struct in_addr ip;
+ NetworkGameList *item;
+
+ if (_stop_requerying || ++requery_cnt < REQUERY_EVERY_X_GAMELOOPS) return;
+
+ requery_cnt = 0;
+ _stop_requerying = true;
+
+ for (item = _network_game_list; item != NULL; item = item->next) {
+ uint8 retries;
+
+ if (item->online || item->retries >= MAX_GAME_LIST_REQUERY_COUNT) continue;
+
+ ip.s_addr = item->ip;
+
+ /* item gets mostly zeroed by NetworkUDPQueryServer */
+ retries = item->retries;
+ NetworkUDPQueryServer(inet_ntoa(ip), item->port);
+ item->retries = retries + 1;
+
+ _stop_requerying = false;
+ }
+
+}
+
#endif /* ENABLE_NETWORK */
--- a/network_gamelist.h Thu Feb 08 10:04:57 2007 +0000
+++ b/network_gamelist.h Thu Feb 08 10:19:03 2007 +0000
@@ -7,5 +7,6 @@
NetworkGameList *NetworkGameListAddItem(uint32 ip, uint16 port);
void NetworkGameListRemoveItem(NetworkGameList *remove);
void NetworkGameListAddQueriedItem(const NetworkGameInfo *info, bool server_online);
+void NetworkGameListRequery(void);
#endif /* NETWORK_GAMELIST_H */
--- a/openttd.c Thu Feb 08 10:04:57 2007 +0000
+++ b/openttd.c Thu Feb 08 10:19:03 2007 +0000
@@ -141,7 +141,7 @@
"\n"
"Command line options:\n"
" -v drv = Set video driver (see below)\n"
- " -s drv = Set sound driver (see below)\n"
+ " -s drv = Set sound driver (see below) (param bufsize,hz)\n"
" -m drv = Set music driver (see below)\n"
" -r res = Set resolution (for instance 800x600)\n"
" -h = Display this help text\n"
@@ -326,7 +326,7 @@
MyGetOptData mgo;
int i;
const char *optformat;
- char musicdriver[16], sounddriver[16], videodriver[16];
+ char musicdriver[32], sounddriver[32], videodriver[32];
int resolution[2] = {0,0};
Year startyear = INVALID_YEAR;
uint generation_seed = GENERATE_NEW_SEED;
@@ -334,7 +334,7 @@
bool network = false;
char *network_conn = NULL;
- musicdriver[0] = sounddriver[0] = videodriver[0] = 0;
+ musicdriver[0] = sounddriver[0] = videodriver[0] = '\0';
_game_mode = GM_MENU;
_switch_mode = SM_MENU;
@@ -410,10 +410,10 @@
LoadFromHighScore();
// override config?
- if (musicdriver[0]) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
- if (sounddriver[0]) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
- if (videodriver[0]) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
- if (resolution[0]) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
+ if (musicdriver[0] != '\0') ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
+ if (sounddriver[0] != '\0') ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
+ if (videodriver[0] != '\0') ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
+ if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
--- a/strgen/strgen.c Thu Feb 08 10:04:57 2007 +0000
+++ b/strgen/strgen.c Thu Feb 08 10:19:03 2007 +0000
@@ -910,12 +910,12 @@
_file = file;
- // For each new file we parse, reset the genders.
+ /* For each new file we parse, reset the genders, and language codes */
_numgenders = 0;
+ _lang_name[0] = _lang_ownname[0] = _lang_isocode[0] = '\0';
// TODO:!! We can't reset the cases. In case the translated strings
// derive some strings from english....
-
in = fopen(file, "r");
if (in == NULL) fatal("Cannot open file");
_cur_line = 1;
@@ -925,6 +925,10 @@
_cur_line++;
}
fclose(in);
+
+ if (_lang_name[0] == '\0' || _lang_ownname[0] == '\0' || _lang_isocode[0] == '\0') {
+ fatal("Language must include ##name, ##ownname and ##isocode");
+ }
}
--- a/variables.h Thu Feb 08 10:04:57 2007 +0000
+++ b/variables.h Thu Feb 08 10:19:03 2007 +0000
@@ -319,7 +319,7 @@
VARDEF Vehicle *_place_clicked_vehicle;
-VARDEF char _ini_videodriver[16], _ini_musicdriver[16], _ini_sounddriver[16];
+VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32];
// Used for dynamic language support
typedef struct {