mirror of https://github.com/OpenTTD/OpenTTD
(svn r1057) -Add: [Network] 'set port <port>' changes the port of the server (after reboot)
-Fix: [Network] Fixed warnings that came with last revision -Cleanup: [Network] Removed an unused var (_network_client_port)release/0.4.5
parent
549dafc241
commit
b153236503
|
@ -552,6 +552,9 @@ DEF_CONSOLE_CMD(ConSayClient)
|
||||||
/* the "set" command */
|
/* the "set" command */
|
||||||
/* **************************** */
|
/* **************************** */
|
||||||
|
|
||||||
|
extern void ConsoleSetPatchSetting(char *name, char *value);
|
||||||
|
extern void ConsoleGetPatchSetting(char *name);
|
||||||
|
|
||||||
DEF_CONSOLE_CMD(ConSet) {
|
DEF_CONSOLE_CMD(ConSet) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
IConsolePrint(_iconsole_color_warning, "Unknonw usage. Usage: set [setting] [value].");
|
IConsolePrint(_iconsole_color_warning, "Unknonw usage. Usage: set [setting] [value].");
|
||||||
|
@ -562,8 +565,8 @@ DEF_CONSOLE_CMD(ConSet) {
|
||||||
|
|
||||||
// setting the server password
|
// setting the server password
|
||||||
if ((strcmp(argv[1],"server_pw") == 0) || (strcmp(argv[1],"server_password") == 0)) {
|
if ((strcmp(argv[1],"server_pw") == 0) || (strcmp(argv[1],"server_password") == 0)) {
|
||||||
if (!_networking) {
|
if (!_network_server) {
|
||||||
IConsolePrintF(_iconsole_color_error,"No network game running");
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
|
@ -639,8 +642,8 @@ DEF_CONSOLE_CMD(ConSet) {
|
||||||
|
|
||||||
// setting the server name
|
// setting the server name
|
||||||
if (strcmp(argv[1],"server_name") == 0) {
|
if (strcmp(argv[1],"server_name") == 0) {
|
||||||
if (!_networking) {
|
if (!_network_server) {
|
||||||
IConsolePrintF(_iconsole_color_error,"No network game running");
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
|
@ -654,6 +657,19 @@ DEF_CONSOLE_CMD(ConSet) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setting the server name
|
||||||
|
if (strcmp(argv[1],"port") == 0) {
|
||||||
|
if (argc == 3 && atoi(argv[2]) != 0) {
|
||||||
|
_network_server_port = atoi(argv[2]);
|
||||||
|
IConsolePrintF(_iconsole_color_warning, "Server-port changed to '%d'", _network_server_port);
|
||||||
|
IConsolePrintF(_iconsole_color_warning, "Changes will take effect the next time you start a server.");
|
||||||
|
} else {
|
||||||
|
IConsolePrintF(_iconsole_color_default, "Current server-port is '%d'", _network_server_port);
|
||||||
|
IConsolePrint(_iconsole_color_warning, "Usage: set server_port <port>.");
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Patch-options
|
// Patch-options
|
||||||
|
|
|
@ -137,7 +137,6 @@ VARDEF uint16 _network_game_count;
|
||||||
|
|
||||||
VARDEF uint16 _network_lobby_company_count;
|
VARDEF uint16 _network_lobby_company_count;
|
||||||
|
|
||||||
VARDEF uint _network_client_port;
|
|
||||||
VARDEF uint _network_server_port;
|
VARDEF uint _network_server_port;
|
||||||
VARDEF bool _is_network_server; // Does this client wants to be a network-server?
|
VARDEF bool _is_network_server; // Does this client wants to be a network-server?
|
||||||
VARDEF char _network_server_name[NETWORK_NAME_LENGTH];
|
VARDEF char _network_server_name[NETWORK_NAME_LENGTH];
|
||||||
|
|
|
@ -723,10 +723,9 @@ static const SettingDesc misc_settings[] = {
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
static const SettingDesc network_settings[] = {
|
static const SettingDesc network_settings[] = {
|
||||||
{"port", SDT_UINT | SDT_NOSAVE, (void*)NETWORK_DISCOVER_PORT, &_network_client_port, NULL},
|
|
||||||
{"server_port", SDT_UINT | SDT_NOSAVE, (void*)NETWORK_DEFAULT_PORT, &_network_server_port, NULL},
|
|
||||||
{"sync_freq", SDT_UINT16 | SDT_NOSAVE, (void*)100, &_network_sync_freq, NULL},
|
{"sync_freq", SDT_UINT16 | SDT_NOSAVE, (void*)100, &_network_sync_freq, NULL},
|
||||||
{"frame_freq", SDT_UINT8 | SDT_NOSAVE, (void*)0, &_network_frame_freq, NULL},
|
{"frame_freq", SDT_UINT8 | SDT_NOSAVE, (void*)0, &_network_frame_freq, NULL},
|
||||||
|
{"server_port", SDT_UINT, (void*)NETWORK_DEFAULT_PORT, &_network_server_port, NULL},
|
||||||
{"player_name", SDT_STRINGBUF | (lengthof(_network_player_name) << 16), NULL, &_network_player_name, NULL},
|
{"player_name", SDT_STRINGBUF | (lengthof(_network_player_name) << 16), NULL, &_network_player_name, NULL},
|
||||||
{"server_password", SDT_STRINGBUF | (lengthof(_network_game_info.server_password) << 16), NULL, &_network_game_info.server_password, NULL},
|
{"server_password", SDT_STRINGBUF | (lengthof(_network_game_info.server_password) << 16), NULL, &_network_game_info.server_password, NULL},
|
||||||
{"server_name", SDT_STRINGBUF | (lengthof(_network_server_name) << 16), NULL, &_network_server_name, NULL},
|
{"server_name", SDT_STRINGBUF | (lengthof(_network_server_name) << 16), NULL, &_network_server_name, NULL},
|
||||||
|
|
Loading…
Reference in New Issue