mirror of https://github.com/OpenTTD/OpenTTD
(svn r8625) [0.5] -Backport from trunk (8253, 8273, 8497, 8520 + 8542):
-Codechange: Be more strict about language generation and fail any languages not having the mandatory ##name, ##ownname and ##isocode pragma's. -Fix: return value from clamp was ignored -Codechange: Increase the size of the sound/video/music-drivers to 32 bytes (instead of 16) so their actual parameters can be passed. Sound has for example 'bufsize' and 'hz'. -Fix/Feature: requery gameservers that did not respond to their first query.release/0.5
parent
1584e061eb
commit
4e3652f337
|
@ -1822,7 +1822,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
/* Increase or decrease the value and clamp it to extremes */
|
/* Increase or decrease the value and clamp it to extremes */
|
||||||
value += (x >= 30) ? step : -step;
|
value += (x >= 30) ? step : -step;
|
||||||
clamp(value, ce->min, ce->max);
|
value = clamp(value, ce->min, ce->max);
|
||||||
|
|
||||||
// take whatever the function returns
|
// take whatever the function returns
|
||||||
value = ce->proc(value, (x >= 30) ? 1 : -1);
|
value = ce->proc(value, (x >= 30) ? 1 : -1);
|
||||||
|
|
|
@ -1267,6 +1267,7 @@ void NetworkUDPGameLoop(void)
|
||||||
} else if (_udp_client_socket != INVALID_SOCKET) {
|
} else if (_udp_client_socket != INVALID_SOCKET) {
|
||||||
NetworkUDPReceive(_udp_client_socket);
|
NetworkUDPReceive(_udp_client_socket);
|
||||||
if (_network_udp_broadcast > 0) _network_udp_broadcast--;
|
if (_network_udp_broadcast > 0) _network_udp_broadcast--;
|
||||||
|
NetworkGameListRequery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,7 @@ typedef struct NetworkGameList {
|
||||||
uint16 port;
|
uint16 port;
|
||||||
bool online; // False if the server did not respond (default status)
|
bool online; // False if the server did not respond (default status)
|
||||||
bool manually; // True if the server was added manually
|
bool manually; // True if the server was added manually
|
||||||
|
uint8 retries;
|
||||||
struct NetworkGameList *next;
|
struct NetworkGameList *next;
|
||||||
} NetworkGameList;
|
} NetworkGameList;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "network_data.h"
|
#include "network_data.h"
|
||||||
#include "newgrf_config.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
|
// This file handles the GameList
|
||||||
// Also, it handles the request to a server for data about the server
|
// Also, it handles the request to a server for data about the server
|
||||||
|
@ -39,6 +43,7 @@ NetworkGameList *NetworkGameListAddItem(uint32 ip, uint16 port)
|
||||||
DEBUG(net, 4) ("[NET][GameList] Added server to list");
|
DEBUG(net, 4) ("[NET][GameList] Added server to list");
|
||||||
|
|
||||||
UpdateNetworkGameWindow(false);
|
UpdateNetworkGameWindow(false);
|
||||||
|
_stop_requerying = false;
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -71,4 +76,38 @@ void NetworkGameListRemoveItem(NetworkGameList *remove)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
|
@ -7,5 +7,6 @@ void NetworkGameListClear(void);
|
||||||
NetworkGameList *NetworkGameListAddItem(uint32 ip, uint16 port);
|
NetworkGameList *NetworkGameListAddItem(uint32 ip, uint16 port);
|
||||||
void NetworkGameListRemoveItem(NetworkGameList *remove);
|
void NetworkGameListRemoveItem(NetworkGameList *remove);
|
||||||
void NetworkGameListAddQueriedItem(const NetworkGameInfo *info, bool server_online);
|
void NetworkGameListAddQueriedItem(const NetworkGameInfo *info, bool server_online);
|
||||||
|
void NetworkGameListRequery(void);
|
||||||
|
|
||||||
#endif /* NETWORK_GAMELIST_H */
|
#endif /* NETWORK_GAMELIST_H */
|
||||||
|
|
14
openttd.c
14
openttd.c
|
@ -141,7 +141,7 @@ static void showhelp(void)
|
||||||
"\n"
|
"\n"
|
||||||
"Command line options:\n"
|
"Command line options:\n"
|
||||||
" -v drv = Set video driver (see below)\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"
|
" -m drv = Set music driver (see below)\n"
|
||||||
" -r res = Set resolution (for instance 800x600)\n"
|
" -r res = Set resolution (for instance 800x600)\n"
|
||||||
" -h = Display this help text\n"
|
" -h = Display this help text\n"
|
||||||
|
@ -326,7 +326,7 @@ int ttd_main(int argc, char *argv[])
|
||||||
MyGetOptData mgo;
|
MyGetOptData mgo;
|
||||||
int i;
|
int i;
|
||||||
const char *optformat;
|
const char *optformat;
|
||||||
char musicdriver[16], sounddriver[16], videodriver[16];
|
char musicdriver[32], sounddriver[32], videodriver[32];
|
||||||
int resolution[2] = {0,0};
|
int resolution[2] = {0,0};
|
||||||
Year startyear = INVALID_YEAR;
|
Year startyear = INVALID_YEAR;
|
||||||
uint generation_seed = GENERATE_NEW_SEED;
|
uint generation_seed = GENERATE_NEW_SEED;
|
||||||
|
@ -334,7 +334,7 @@ int ttd_main(int argc, char *argv[])
|
||||||
bool network = false;
|
bool network = false;
|
||||||
char *network_conn = NULL;
|
char *network_conn = NULL;
|
||||||
|
|
||||||
musicdriver[0] = sounddriver[0] = videodriver[0] = 0;
|
musicdriver[0] = sounddriver[0] = videodriver[0] = '\0';
|
||||||
|
|
||||||
_game_mode = GM_MENU;
|
_game_mode = GM_MENU;
|
||||||
_switch_mode = SM_MENU;
|
_switch_mode = SM_MENU;
|
||||||
|
@ -410,10 +410,10 @@ int ttd_main(int argc, char *argv[])
|
||||||
LoadFromHighScore();
|
LoadFromHighScore();
|
||||||
|
|
||||||
// override config?
|
// override config?
|
||||||
if (musicdriver[0]) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
|
if (musicdriver[0] != '\0') ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
|
||||||
if (sounddriver[0]) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
|
if (sounddriver[0] != '\0') ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
|
||||||
if (videodriver[0]) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
|
if (videodriver[0] != '\0') ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
|
||||||
if (resolution[0]) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
|
if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
|
||||||
if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
|
if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
|
||||||
if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
|
if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
|
||||||
|
|
||||||
|
|
|
@ -910,12 +910,12 @@ static void ParseFile(const char *file, bool english)
|
||||||
|
|
||||||
_file = file;
|
_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;
|
_numgenders = 0;
|
||||||
|
_lang_name[0] = _lang_ownname[0] = _lang_isocode[0] = '\0';
|
||||||
// TODO:!! We can't reset the cases. In case the translated strings
|
// TODO:!! We can't reset the cases. In case the translated strings
|
||||||
// derive some strings from english....
|
// derive some strings from english....
|
||||||
|
|
||||||
|
|
||||||
in = fopen(file, "r");
|
in = fopen(file, "r");
|
||||||
if (in == NULL) fatal("Cannot open file");
|
if (in == NULL) fatal("Cannot open file");
|
||||||
_cur_line = 1;
|
_cur_line = 1;
|
||||||
|
@ -925,6 +925,10 @@ static void ParseFile(const char *file, bool english)
|
||||||
_cur_line++;
|
_cur_line++;
|
||||||
}
|
}
|
||||||
fclose(in);
|
fclose(in);
|
||||||
|
|
||||||
|
if (_lang_name[0] == '\0' || _lang_ownname[0] == '\0' || _lang_isocode[0] == '\0') {
|
||||||
|
fatal("Language must include ##name, ##ownname and ##isocode");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -319,7 +319,7 @@ VARDEF byte _get_z_hint; // used as a hint to getslopez to return the right heig
|
||||||
|
|
||||||
VARDEF Vehicle *_place_clicked_vehicle;
|
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
|
// Used for dynamic language support
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in New Issue