2004-09-12 21:49:38 +00:00
|
|
|
/* -------------------- dont cross this line --------------------- */
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ttd.h"
|
|
|
|
#include "console.h"
|
2005-02-05 15:58:59 +00:00
|
|
|
#include "debug.h"
|
2004-09-12 21:49:38 +00:00
|
|
|
#include "engine.h"
|
|
|
|
#include "functions.h"
|
2005-02-06 13:41:02 +00:00
|
|
|
#include "string.h"
|
2004-09-12 21:49:38 +00:00
|
|
|
#include "variables.h"
|
2004-12-04 17:54:56 +00:00
|
|
|
#include "network_data.h"
|
|
|
|
#include "network_client.h"
|
|
|
|
#include "network_server.h"
|
2004-12-22 19:16:10 +00:00
|
|
|
#include "network_udp.h"
|
2004-12-04 17:54:56 +00:00
|
|
|
#include "command.h"
|
2004-12-13 15:07:33 +00:00
|
|
|
#include "settings.h"
|
2005-01-04 15:06:08 +00:00
|
|
|
#include "hal.h" /* for file list */
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-09-14 16:10:20 +00:00
|
|
|
|
|
|
|
// ** scriptfile handling ** //
|
|
|
|
static FILE * _script_file;
|
|
|
|
static bool _script_running;
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
// ** console command / variable defines ** //
|
2004-09-14 16:10:20 +00:00
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
#define DEF_CONSOLE_CMD(yyyy) static _iconsole_var * yyyy(byte argc, char* argv[], byte argt[])
|
2004-09-12 21:49:38 +00:00
|
|
|
#define DEF_CONSOLE_CMD_HOOK(yyyy) static bool yyyy(_iconsole_cmd * hookcmd)
|
|
|
|
#define DEF_CONSOLE_VAR_HOOK(yyyy) static bool yyyy(_iconsole_var * hookvar)
|
|
|
|
|
2004-09-14 16:10:20 +00:00
|
|
|
|
|
|
|
// ** supporting functions ** //
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
static uint32 GetArgumentInteger(const char* arg)
|
2004-09-12 21:49:38 +00:00
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
uint32 result;
|
|
|
|
sscanf(arg, "%u", &result);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
|
|
|
if (result == 0 && arg[0] == '0' && arg[1] == 'x')
|
2004-09-19 15:24:45 +00:00
|
|
|
sscanf(arg, "%x", &result);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* **************************** */
|
|
|
|
/* variable and command hooks */
|
|
|
|
/* **************************** */
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetwork)
|
|
|
|
{
|
|
|
|
if (_networking) {
|
2004-09-21 21:40:59 +00:00
|
|
|
IConsoleError("This command is forbidden in multiplayer.");
|
2004-09-12 21:49:38 +00:00
|
|
|
return false;
|
2004-09-19 15:24:45 +00:00
|
|
|
}
|
2004-09-12 21:49:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetClient)
|
2004-09-12 21:49:38 +00:00
|
|
|
{
|
2004-12-05 12:25:25 +00:00
|
|
|
if (!_network_available) {
|
|
|
|
IConsoleError("You can not use this command because there is no network available.");
|
|
|
|
return false;
|
|
|
|
}
|
2004-12-04 17:54:56 +00:00
|
|
|
if (!_network_server) {
|
|
|
|
IConsoleError("This variable only makes sense for a network server.");
|
2004-09-12 21:49:38 +00:00
|
|
|
return false;
|
2004-09-19 15:24:45 +00:00
|
|
|
}
|
2004-09-12 21:49:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetClient)
|
2004-09-12 21:49:38 +00:00
|
|
|
{
|
2004-12-05 12:25:25 +00:00
|
|
|
if (!_network_available) {
|
|
|
|
IConsoleError("You can not use this command because there is no network available.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!_network_server) {
|
2004-12-04 17:54:56 +00:00
|
|
|
IConsoleError("This command is only available for a network server.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetServer)
|
|
|
|
{
|
2004-12-05 12:25:25 +00:00
|
|
|
if (!_network_available) {
|
|
|
|
IConsoleError("You can not use this command because there is no network available.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (_network_server) {
|
|
|
|
IConsoleError("You can not use this command because you are a network-server.");
|
2004-09-12 21:49:38 +00:00
|
|
|
return false;
|
2004-09-19 15:24:45 +00:00
|
|
|
}
|
2004-09-12 21:49:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
DEF_CONSOLE_CMD_HOOK(ConCmdHookNeedNetwork)
|
|
|
|
{
|
2004-12-05 12:25:25 +00:00
|
|
|
if (!_network_available) {
|
|
|
|
IConsoleError("You can not use this command because there is no network available.");
|
|
|
|
return false;
|
|
|
|
}
|
2004-12-04 17:54:56 +00:00
|
|
|
if (!_networking) {
|
|
|
|
IConsoleError("Not connected. Multiplayer only command.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
/* **************************** */
|
|
|
|
/* reset commands */
|
|
|
|
/* **************************** */
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConResetEngines)
|
|
|
|
{
|
|
|
|
StartupEngines();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
#ifdef _DEBUG
|
2004-09-12 21:49:38 +00:00
|
|
|
DEF_CONSOLE_CMD(ConResetTile)
|
|
|
|
{
|
|
|
|
if (argc == 2) {
|
|
|
|
TileIndex tile = (TileIndex)GetArgumentInteger(argv[1]);
|
|
|
|
DoClearSquare(tile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2004-09-19 15:24:45 +00:00
|
|
|
#endif
|
2004-09-12 21:49:38 +00:00
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConScrollToTile)
|
|
|
|
{
|
|
|
|
if (argc == 2) {
|
|
|
|
TileIndex tile = (TileIndex)GetArgumentInteger(argv[1]);
|
|
|
|
ScrollMainWindowToTile(tile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-01-04 15:06:08 +00:00
|
|
|
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm);
|
2005-01-22 20:23:18 +00:00
|
|
|
extern void BuildFileList(void);
|
2005-01-04 15:06:08 +00:00
|
|
|
extern void SetFiosType(const byte fiostype);
|
|
|
|
|
2005-03-25 18:26:49 +00:00
|
|
|
/* Save the map to current dir */
|
|
|
|
static void SaveMap(const char *filename)
|
|
|
|
{
|
|
|
|
char buf[200];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s%s%s.sav", _path.save_dir, PATHSEP, filename);
|
|
|
|
IConsolePrint(_iconsole_color_default, "Saving map...");
|
|
|
|
|
|
|
|
if (SaveOrLoad(buf, SL_SAVE) != SL_OK) {
|
|
|
|
IConsolePrint(_iconsole_color_error, "SaveMap failed");
|
|
|
|
} else
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Map sucessfully saved to %s", buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the map to a file */
|
|
|
|
DEF_CONSOLE_CMD(ConSave)
|
|
|
|
{
|
|
|
|
/* We need 1 argument */
|
|
|
|
if (argc == 2) {
|
|
|
|
/* Save the map */
|
|
|
|
SaveMap(argv[1]);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Give usage */
|
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: save <filename>");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-04 15:06:08 +00:00
|
|
|
/* Load a file-number from current dir */
|
|
|
|
static void LoadMap(uint no)
|
|
|
|
{
|
|
|
|
/* Build file list */
|
|
|
|
BuildFileList();
|
|
|
|
|
|
|
|
/* Check if in range */
|
2005-01-04 16:04:28 +00:00
|
|
|
if (no != 0 && no <= (uint)_fios_num) {
|
2005-01-04 15:06:08 +00:00
|
|
|
const FiosItem *item = &_fios_list[no - 1];
|
|
|
|
|
2005-01-08 00:48:10 +00:00
|
|
|
if (item->type == FIOS_TYPE_FILE) {
|
|
|
|
/* Load the file */
|
|
|
|
_switch_mode = SM_LOAD;
|
|
|
|
SetFiosType(item->type);
|
|
|
|
strcpy(_file_to_saveload.name, FiosBrowseTo(item));
|
2005-01-04 15:06:08 +00:00
|
|
|
|
2005-01-08 00:48:10 +00:00
|
|
|
IConsolePrint(_iconsole_color_default, "Loading map...");
|
|
|
|
} else
|
|
|
|
IConsolePrint(_iconsole_color_error, "That is not a map.");
|
|
|
|
|
|
|
|
} else /* Show usages */
|
|
|
|
IConsolePrint(_iconsole_color_error, "Unknown map. Use 'list_files' and 'goto_dir' to find the numbers of the savegame.");
|
2005-01-04 15:06:08 +00:00
|
|
|
|
|
|
|
/* Free the file-list */
|
|
|
|
FiosFreeSavegameList();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load a file from a map */
|
|
|
|
DEF_CONSOLE_CMD(ConLoad)
|
|
|
|
{
|
|
|
|
/* We need 1 argument */
|
|
|
|
if (argc == 2) {
|
|
|
|
/* Load the map */
|
|
|
|
LoadMap(atoi(argv[1]));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Give usage */
|
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: load <file-no>");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* List all the files in the current dir via console */
|
|
|
|
DEF_CONSOLE_CMD(ConListFiles)
|
|
|
|
{
|
|
|
|
const FiosItem *item;
|
|
|
|
int pos = 0;
|
|
|
|
|
|
|
|
/* Build the file-list */
|
|
|
|
BuildFileList();
|
|
|
|
|
|
|
|
/* As long as we have files */
|
|
|
|
while (pos < _fios_num) {
|
|
|
|
item = _fios_list + pos;
|
|
|
|
pos++;
|
|
|
|
/* Show them */
|
|
|
|
IConsolePrintF(_iconsole_color_default, "%d) %s", pos, item->title[0] ? item->title : item->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Destroy the file list */
|
|
|
|
FiosFreeSavegameList();
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-08 00:48:10 +00:00
|
|
|
/* Get an Specific file */
|
|
|
|
DEF_CONSOLE_CMD(ConScanFiles)
|
|
|
|
{
|
|
|
|
const FiosItem *item;
|
|
|
|
int pos = 0;
|
|
|
|
_iconsole_var* result;
|
|
|
|
|
|
|
|
|
|
|
|
result = IConsoleVarAlloc(ICONSOLE_VAR_STRING);
|
2005-01-15 08:58:31 +00:00
|
|
|
|
2005-01-08 00:48:10 +00:00
|
|
|
if (argc <= 1) {
|
|
|
|
IConsoleVarSetString(result, "0");
|
|
|
|
return result; // return an zero
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Build the file-list */
|
|
|
|
BuildFileList();
|
|
|
|
|
|
|
|
/* As long as we have files */
|
|
|
|
while (pos < _fios_num) {
|
|
|
|
item = _fios_list + pos;
|
2005-01-15 08:58:31 +00:00
|
|
|
pos++;
|
2005-01-08 00:48:10 +00:00
|
|
|
if (strcmp(argv[1], "..") == 0) {
|
|
|
|
if (item->type == FIOS_TYPE_PARENT) {
|
|
|
|
// huh we are searching for the parent directory
|
|
|
|
char buffer[10];
|
2005-01-08 08:29:12 +00:00
|
|
|
sprintf(buffer, "%d", pos);
|
2005-01-08 00:48:10 +00:00
|
|
|
IConsoleVarSetString(result, buffer);
|
|
|
|
return result;
|
|
|
|
}
|
2005-01-15 08:58:31 +00:00
|
|
|
} else
|
2005-01-08 00:48:10 +00:00
|
|
|
// file records ?
|
|
|
|
if (item->type == FIOS_TYPE_FILE) {
|
|
|
|
if (strcmp(argv[1], item->name) == 0) {
|
|
|
|
char buffer[10];
|
2005-01-08 08:29:12 +00:00
|
|
|
sprintf(buffer, "%d", pos);
|
2005-01-08 00:48:10 +00:00
|
|
|
IConsoleVarSetString(result, buffer);
|
|
|
|
return result;
|
2005-01-15 08:58:31 +00:00
|
|
|
}
|
2005-01-08 00:48:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Destroy the file list */
|
|
|
|
FiosFreeSavegameList();
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-04 15:06:08 +00:00
|
|
|
/* Change the dir via console */
|
|
|
|
DEF_CONSOLE_CMD(ConGotoDir)
|
|
|
|
{
|
|
|
|
char *file;
|
|
|
|
int no;
|
|
|
|
|
|
|
|
/* We need 1 argument */
|
|
|
|
if (argc != 2) {
|
2005-01-24 17:49:22 +00:00
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: goto_dir <dir-no>");
|
2005-01-04 15:06:08 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
no = atoi(argv[1]);
|
|
|
|
|
|
|
|
/* Make the file list */
|
|
|
|
BuildFileList();
|
|
|
|
|
|
|
|
/* Check if we are in range */
|
|
|
|
if (no != 0 && no <= _fios_num) {
|
|
|
|
const FiosItem *item = &_fios_list[no - 1];
|
|
|
|
/* Only DIR and PARENT we do allow here */
|
|
|
|
if (item->type == FIOS_TYPE_DIR || item->type == FIOS_TYPE_PARENT) {
|
|
|
|
/* Goto the map */
|
|
|
|
file = FiosBrowseTo(item);
|
|
|
|
FiosFreeSavegameList();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Report error */
|
|
|
|
IConsolePrint(_iconsole_color_default, "That number is no directory.");
|
|
|
|
FiosFreeSavegameList();
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
// ********************************* //
|
|
|
|
// * Network Core Console Commands * //
|
|
|
|
// ********************************* //
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
2005-01-02 12:03:43 +00:00
|
|
|
DEF_CONSOLE_CMD(ConBan)
|
|
|
|
{
|
|
|
|
NetworkClientInfo *ci;
|
|
|
|
|
|
|
|
if (argc == 2) {
|
|
|
|
uint32 index = atoi(argv[1]);
|
2005-01-22 18:51:09 +00:00
|
|
|
if (index == NETWORK_SERVER_INDEX) {
|
2005-01-02 12:03:43 +00:00
|
|
|
IConsolePrint(_iconsole_color_default, "Silly boy, you can not ban yourself!");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (index == 0) {
|
|
|
|
IConsoleError("Invalid Client-ID");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ci = NetworkFindClientInfoFromIndex(index);
|
|
|
|
|
|
|
|
if (ci != NULL) {
|
|
|
|
uint i;
|
|
|
|
/* Add user to ban-list */
|
|
|
|
for (i = 0; i < lengthof(_network_ban_list); i++) {
|
|
|
|
if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0') {
|
|
|
|
_network_ban_list[i] = strdup(inet_ntoa(*(struct in_addr *)&ci->client_ip));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
IConsoleError("Client-ID not found");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: ban <client-id>. For client-ids, see 'clients'.");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConUnBan)
|
|
|
|
{
|
|
|
|
if (argc == 2) {
|
|
|
|
uint i;
|
|
|
|
for (i = 0; i < lengthof(_network_ban_list); i++) {
|
|
|
|
if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strncmp(_network_ban_list[i], argv[1], strlen(_network_ban_list[i])) == 0) {
|
|
|
|
_network_ban_list[i][0] = '\0';
|
|
|
|
IConsolePrint(_iconsole_color_default, "IP unbanned.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IConsolePrint(_iconsole_color_default, "IP not in ban-list.");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: unban <ip>.");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConBanList)
|
|
|
|
{
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
IConsolePrint(_iconsole_color_default, "Banlist: ");
|
|
|
|
|
|
|
|
for (i = 0; i < lengthof(_network_ban_list); i++) {
|
|
|
|
if (_network_ban_list[i] == NULL || _network_ban_list[i][0] == '\0')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
IConsolePrintF(_iconsole_color_default, " %d) %s", i + 1, _network_ban_list[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-24 21:33:44 +00:00
|
|
|
DEF_CONSOLE_CMD(ConPauseGame)
|
|
|
|
{
|
|
|
|
if (_pause == 0) {
|
|
|
|
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
|
|
|
|
IConsolePrint(_iconsole_color_default, "Game paused.");
|
|
|
|
} else
|
|
|
|
IConsolePrint(_iconsole_color_default, "Game is already paused.");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConUnPauseGame)
|
|
|
|
{
|
|
|
|
if (_pause != 0) {
|
|
|
|
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
|
|
|
|
IConsolePrint(_iconsole_color_default, "Game unpaused.");
|
|
|
|
} else
|
|
|
|
IConsolePrint(_iconsole_color_default, "Game is already unpaused.");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-15 20:09:16 +00:00
|
|
|
DEF_CONSOLE_CMD(ConRcon)
|
|
|
|
{
|
|
|
|
if (argc < 3) {
|
|
|
|
IConsolePrint(_iconsole_color_default, "Usage: rcon <password> <command>");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SEND_COMMAND(PACKET_CLIENT_RCON)(argv[1], argv[2]);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
DEF_CONSOLE_CMD(ConStatus)
|
|
|
|
{
|
|
|
|
const char *status;
|
|
|
|
int lag;
|
2004-12-19 10:17:26 +00:00
|
|
|
const NetworkClientState *cs;
|
2004-12-04 17:54:56 +00:00
|
|
|
const NetworkClientInfo *ci;
|
|
|
|
FOR_ALL_CLIENTS(cs) {
|
|
|
|
lag = NetworkCalculateLag(cs);
|
|
|
|
ci = DEREF_CLIENT_INFO(cs);
|
|
|
|
|
|
|
|
switch (cs->status) {
|
|
|
|
case STATUS_INACTIVE:
|
|
|
|
status = "inactive";
|
|
|
|
break;
|
|
|
|
case STATUS_AUTH:
|
|
|
|
status = "authorized";
|
|
|
|
break;
|
|
|
|
case STATUS_MAP:
|
|
|
|
status = "loading map";
|
|
|
|
break;
|
|
|
|
case STATUS_DONE_MAP:
|
|
|
|
status = "done map";
|
|
|
|
break;
|
|
|
|
case STATUS_PRE_ACTIVE:
|
|
|
|
status = "ready";
|
|
|
|
break;
|
|
|
|
case STATUS_ACTIVE:
|
|
|
|
status = "active";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
status = "unknown";
|
|
|
|
break;
|
|
|
|
}
|
2004-12-12 16:04:32 +00:00
|
|
|
IConsolePrintF(8, "Client #%d/%s status: %s frame-lag: %d play-as: %d unique-id: %s",
|
|
|
|
cs->index, ci->client_name, status, lag, ci->client_playas, ci->unique_id);
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConKick)
|
|
|
|
{
|
|
|
|
NetworkClientInfo *ci;
|
|
|
|
|
|
|
|
if (argc == 2) {
|
|
|
|
uint32 index = atoi(argv[1]);
|
2005-01-15 20:09:16 +00:00
|
|
|
if (index == NETWORK_SERVER_INDEX) {
|
2004-12-04 17:54:56 +00:00
|
|
|
IConsolePrint(_iconsole_color_default, "Silly boy, you can not kick yourself!");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (index == 0) {
|
|
|
|
IConsoleError("Invalid Client-ID");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ci = NetworkFindClientInfoFromIndex(index);
|
|
|
|
|
|
|
|
if (ci != NULL) {
|
|
|
|
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
IConsoleError("Client-ID not found");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: kick <client-id>. For client-ids, see 'clients'.");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-16 11:36:57 +00:00
|
|
|
DEF_CONSOLE_CMD(ConResetCompany)
|
|
|
|
{
|
|
|
|
Player *p;
|
2004-12-19 10:17:26 +00:00
|
|
|
NetworkClientState *cs;
|
2004-12-16 11:36:57 +00:00
|
|
|
NetworkClientInfo *ci;
|
|
|
|
|
|
|
|
if (argc == 2) {
|
2005-01-23 23:58:35 +00:00
|
|
|
byte index = atoi(argv[1]);
|
2004-12-16 11:36:57 +00:00
|
|
|
|
|
|
|
/* Check valid range */
|
|
|
|
if (index < 1 || index > MAX_PLAYERS) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "Company does not exist. Company-ID must be between 1 and %d.", MAX_PLAYERS);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if company does exist */
|
|
|
|
index--;
|
|
|
|
p = DEREF_PLAYER(index);
|
|
|
|
if (!p->is_active) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "Company does not exist.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p->is_ai) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "Company is owned by an AI.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the company has active players */
|
|
|
|
FOR_ALL_CLIENTS(cs) {
|
|
|
|
ci = DEREF_CLIENT_INFO(cs);
|
|
|
|
if (ci->client_playas-1 == index) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "Cannot remove company: a client is connected to that company.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
|
|
|
|
if (ci->client_playas-1 == index) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "Cannot remove company: a client is connected to that company.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* It is safe to remove this company */
|
|
|
|
DoCommandP(0, 2, index, NULL, CMD_PLAYER_CTRL);
|
|
|
|
IConsolePrint(_iconsole_color_default, "Company deleted.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: reset_company <company-id>.");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
DEF_CONSOLE_CMD(ConNetworkClients)
|
|
|
|
{
|
|
|
|
NetworkClientInfo *ci;
|
|
|
|
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) {
|
|
|
|
if (ci->client_index != NETWORK_EMPTY_INDEX) {
|
|
|
|
IConsolePrintF(8,"Client #%d name: %s play-as: %d", ci->client_index, ci->client_name, ci->client_playas);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
DEF_CONSOLE_CMD(ConNetworkConnect)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
char* ip;
|
2005-02-06 22:25:27 +00:00
|
|
|
const char *port = NULL;
|
|
|
|
const char *player = NULL;
|
2004-09-12 21:49:38 +00:00
|
|
|
uint16 rport;
|
|
|
|
|
|
|
|
if (argc<2) return NULL;
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
if (_networking) {
|
|
|
|
// We are in network-mode, first close it!
|
|
|
|
NetworkDisconnect();
|
|
|
|
}
|
|
|
|
|
2004-09-12 23:35:01 +00:00
|
|
|
ip = argv[1];
|
2004-12-04 17:54:56 +00:00
|
|
|
rport = NETWORK_DEFAULT_PORT;
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-09-12 23:35:01 +00:00
|
|
|
ParseConnectionString(&player, &port, ip);
|
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsolePrintF(_iconsole_color_default, "Connecting to %s...", ip);
|
2004-12-04 17:54:56 +00:00
|
|
|
if (player != NULL) {
|
2004-09-12 21:49:38 +00:00
|
|
|
_network_playas = atoi(player);
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsolePrintF(_iconsole_color_default, " player-no: %s", player);
|
2004-09-12 21:49:38 +00:00
|
|
|
}
|
2004-12-04 17:54:56 +00:00
|
|
|
if (port != NULL) {
|
2004-09-12 21:49:38 +00:00
|
|
|
rport = atoi(port);
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsolePrintF(_iconsole_color_default, " port: %s", port);
|
2004-09-12 21:49:38 +00:00
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
NetworkClientConnectGame(ip, rport);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-09-14 16:10:20 +00:00
|
|
|
/* ******************************** */
|
|
|
|
/* script file console commands */
|
|
|
|
/* ******************************** */
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConExec)
|
|
|
|
{
|
|
|
|
char cmd[1024];
|
|
|
|
|
2005-02-18 08:49:04 +00:00
|
|
|
if (argc < 2) return NULL;
|
2004-09-14 16:10:20 +00:00
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
_script_file = fopen(argv[1], "r");
|
2004-09-14 16:10:20 +00:00
|
|
|
|
|
|
|
if (_script_file == NULL) {
|
2005-02-18 08:49:04 +00:00
|
|
|
if (argc <= 2 || atoi(argv[2]) != 0) IConsoleError("script file not found");
|
2004-09-14 16:10:20 +00:00
|
|
|
return NULL;
|
2005-02-18 08:49:04 +00:00
|
|
|
}
|
2004-09-14 16:10:20 +00:00
|
|
|
|
|
|
|
_script_running = true;
|
|
|
|
|
2005-02-18 08:36:11 +00:00
|
|
|
while (_script_running && fgets(cmd, sizeof(cmd), _script_file) != NULL) {
|
2005-02-17 17:38:17 +00:00
|
|
|
IConsoleCmdExec(cmd);
|
2005-02-18 08:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ferror(_script_file)) {
|
|
|
|
IConsoleError("Encountered errror while trying to read from script file");
|
2004-09-14 16:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_script_running = false;
|
|
|
|
fclose(_script_file);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConReturn)
|
|
|
|
{
|
|
|
|
_script_running = false;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
/* **************************** */
|
|
|
|
/* default console commands */
|
|
|
|
/* **************************** */
|
2005-01-16 18:19:33 +00:00
|
|
|
extern bool CloseConsoleLogIfActive(void);
|
2005-01-15 16:38:10 +00:00
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConScript)
|
|
|
|
{
|
|
|
|
extern FILE* _iconsole_output_file;
|
|
|
|
if (!CloseConsoleLogIfActive()) {
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argc < 2) return NULL;
|
2005-01-15 16:38:10 +00:00
|
|
|
IConsolePrintF(_iconsole_color_default, "file output started to: %s", argv[1]);
|
2004-09-19 15:24:45 +00:00
|
|
|
_iconsole_output_file = fopen(argv[1], "ab");
|
2004-09-14 16:10:20 +00:00
|
|
|
if (_iconsole_output_file == NULL) IConsoleError("could not open file");
|
|
|
|
}
|
2005-01-15 16:38:10 +00:00
|
|
|
|
2004-09-14 16:10:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
DEF_CONSOLE_CMD(ConEcho)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argc < 2) return NULL;
|
2004-09-12 21:49:38 +00:00
|
|
|
IConsolePrint(_iconsole_color_default, argv[1]);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConEchoC)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argc < 3) return NULL;
|
2004-09-12 21:49:38 +00:00
|
|
|
IConsolePrint(atoi(argv[1]), argv[2]);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
extern void SwitchMode(int new_mode);
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConNewGame)
|
|
|
|
{
|
|
|
|
_docommand_recursive = 0;
|
|
|
|
|
|
|
|
_random_seeds[0][0] = Random();
|
|
|
|
_random_seeds[0][1] = InteractiveRandom();
|
|
|
|
|
|
|
|
SwitchMode(SM_NEWGAME);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
DEF_CONSOLE_CMD(ConPrintF)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argc < 3) return NULL;
|
|
|
|
IConsolePrintF(_iconsole_color_default, argv[1] , argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11], argv[12], argv[13], argv[14], argv[15], argv[16], argv[17], argv[18], argv[19]); /* XXX ugh... */
|
2004-09-12 21:49:38 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConPrintFC)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argc < 3) return NULL;
|
|
|
|
IConsolePrintF(atoi(argv[1]), argv[2] , argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11], argv[12], argv[13], argv[14], argv[15], argv[16], argv[17], argv[18], argv[19]); /* XXX ugh... */
|
2004-09-12 21:49:38 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-13 18:51:08 +00:00
|
|
|
DEF_CONSOLE_CMD(ConAlias)
|
|
|
|
{
|
2004-12-13 22:13:02 +00:00
|
|
|
_iconsole_alias* alias;
|
|
|
|
|
2004-12-13 18:51:08 +00:00
|
|
|
if (argc < 3) return NULL;
|
2004-12-13 22:13:02 +00:00
|
|
|
|
|
|
|
alias = IConsoleAliasGet(argv[1]);
|
|
|
|
if (alias == NULL) {
|
|
|
|
IConsoleAliasRegister(argv[1],argv[2]);
|
|
|
|
} else {
|
|
|
|
free(alias->cmdline);
|
|
|
|
alias->cmdline = strdup(argv[2]);
|
|
|
|
}
|
2004-12-13 18:51:08 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
DEF_CONSOLE_CMD(ConScreenShot)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argc < 2) {
|
|
|
|
_make_screenshot = 1;
|
2004-09-12 21:49:38 +00:00
|
|
|
} else {
|
2004-09-19 15:24:45 +00:00
|
|
|
if (strcmp(argv[1], "big") == 0)
|
2004-09-12 21:49:38 +00:00
|
|
|
_make_screenshot=2;
|
2004-09-19 15:24:45 +00:00
|
|
|
if (strcmp(argv[1], "no_con") == 0) {
|
2004-09-12 21:49:38 +00:00
|
|
|
IConsoleClose();
|
2004-09-19 15:24:45 +00:00
|
|
|
_make_screenshot = 1;
|
2004-09-12 21:49:38 +00:00
|
|
|
}
|
2004-09-19 15:24:45 +00:00
|
|
|
}
|
2004-09-12 21:49:38 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-13 06:56:30 +00:00
|
|
|
DEF_CONSOLE_CMD(ConInfoVar)
|
2004-09-12 21:49:38 +00:00
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argc < 2) return NULL;
|
|
|
|
if (argt[1] != ICONSOLE_VAR_REFERENCE) {
|
2004-09-13 09:21:42 +00:00
|
|
|
IConsoleError("first argument has to be a variable reference");
|
2004-09-19 15:24:45 +00:00
|
|
|
} else {
|
|
|
|
_iconsole_var* item;
|
|
|
|
item = (_iconsole_var*)argv[1];
|
|
|
|
IConsolePrintF(_iconsole_color_default, "var_name: %s", item->name);
|
|
|
|
IConsolePrintF(_iconsole_color_default, "var_type: %i", item->type);
|
|
|
|
IConsolePrintF(_iconsole_color_default, "var_addr: %i", item->data.addr);
|
|
|
|
if (item->_malloc)
|
|
|
|
IConsolePrintF(_iconsole_color_default, "var_malloc: internal");
|
|
|
|
else
|
|
|
|
IConsolePrintF(_iconsole_color_default, "var_malloc: external");
|
2004-09-14 16:10:20 +00:00
|
|
|
if (item->hook_access) IConsoleWarning("var_access hooked");
|
|
|
|
if (item->hook_before_change) IConsoleWarning("var_before_change hooked");
|
2004-09-13 06:56:30 +00:00
|
|
|
if (item->hook_after_change) IConsoleWarning("var_after_change hooked");
|
2004-09-19 15:24:45 +00:00
|
|
|
}
|
2004-09-12 21:49:38 +00:00
|
|
|
return NULL;
|
2004-09-14 16:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConInfoCmd)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argc < 2) return NULL;
|
|
|
|
if (argt[1] != ICONSOLE_VAR_UNKNOWN) {
|
2004-09-14 16:10:20 +00:00
|
|
|
IConsoleError("first argument has to be a command name");
|
2004-09-19 15:24:45 +00:00
|
|
|
} else {
|
|
|
|
_iconsole_cmd* item;
|
2004-09-14 16:10:20 +00:00
|
|
|
item = IConsoleCmdGet(argv[1]);
|
2004-09-19 15:24:45 +00:00
|
|
|
if (item == NULL) {
|
2004-09-14 16:10:20 +00:00
|
|
|
IConsoleError("the given command was not found");
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsolePrintF(_iconsole_color_default, "cmd_name: %s", item->name);
|
|
|
|
IConsolePrintF(_iconsole_color_default, "cmd_addr: %i", item->addr);
|
2004-09-14 16:10:20 +00:00
|
|
|
if (item->hook_access) IConsoleWarning("cmd_access hooked");
|
|
|
|
if (item->hook_before_exec) IConsoleWarning("cmd_before_exec hooked");
|
|
|
|
if (item->hook_after_exec) IConsoleWarning("cmd_after_exec hooked");
|
2004-09-19 15:24:45 +00:00
|
|
|
}
|
2004-09-14 16:10:20 +00:00
|
|
|
return NULL;
|
2004-09-12 21:49:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConDebugLevel)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argc < 2) return NULL;
|
2004-09-12 21:49:38 +00:00
|
|
|
SetDebugString(argv[1]);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConExit)
|
|
|
|
{
|
|
|
|
_exit_game = true;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConHelp)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsolePrint(13, " -- console help -- ");
|
|
|
|
IConsolePrint( 1, " variables: [command to list them: list_vars]");
|
2004-12-04 17:54:56 +00:00
|
|
|
IConsolePrint( 1, " temp_string = \"my little \"");
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsolePrint( 1, "");
|
|
|
|
IConsolePrint( 1, " commands: [command to list them: list_cmds]");
|
|
|
|
IConsolePrint( 1, " [command] [\"string argument with spaces\"] [argument 2] ...");
|
2004-12-04 17:54:56 +00:00
|
|
|
IConsolePrint( 1, " printf \"%s world\" temp_string");
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsolePrint( 1, "");
|
|
|
|
IConsolePrint( 1, " command/variable returning a value into an variable:");
|
2004-12-04 17:54:56 +00:00
|
|
|
IConsolePrint( 1, " temp_uint16 << random");
|
|
|
|
IConsolePrint( 1, " temp_uint16 << temp_uint16_2");
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsolePrint( 1, "");
|
2004-09-12 21:49:38 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConRandom)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
_iconsole_var* result;
|
2004-09-12 21:49:38 +00:00
|
|
|
result = IConsoleVarAlloc(ICONSOLE_VAR_UINT16);
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsoleVarSetValue(result, rand());
|
2004-09-12 21:49:38 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConListCommands)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
const _iconsole_cmd* item;
|
|
|
|
size_t l = 0;
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argv[1] != NULL) l = strlen(argv[1]);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
for (item = _iconsole_cmds; item != NULL; item = item->_next)
|
|
|
|
if (argv[1] == NULL || strncmp(item->name, argv[1], l) == 0)
|
|
|
|
IConsolePrintF(_iconsole_color_default, "%s", item->name);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConListVariables)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
const _iconsole_var* item;
|
|
|
|
size_t l = 0;
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argv[1] != NULL) l = strlen(argv[1]);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
for (item = _iconsole_vars; item != NULL; item = item->_next)
|
|
|
|
if (argv[1] == NULL || strncmp(item->name, argv[1], l) == 0)
|
|
|
|
IConsolePrintF(_iconsole_color_default, "%s", item->name);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-13 18:51:08 +00:00
|
|
|
DEF_CONSOLE_CMD(ConListAliases)
|
|
|
|
{
|
|
|
|
const _iconsole_alias* item;
|
|
|
|
size_t l = 0;
|
|
|
|
|
|
|
|
if (argv[1] != NULL) l = strlen(argv[1]);
|
|
|
|
|
|
|
|
for (item = _iconsole_aliases; item != NULL; item = item->_next)
|
|
|
|
if (argv[1] == NULL || strncmp(item->name, argv[1], l) == 0)
|
|
|
|
IConsolePrintF(_iconsole_color_default, "%s => %s", item->name, item->cmdline);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
DEF_CONSOLE_CMD(ConListDumpVariables)
|
|
|
|
{
|
2004-09-19 15:24:45 +00:00
|
|
|
const _iconsole_var* item;
|
|
|
|
size_t l = 0;
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
if (argv[1] != NULL) l = strlen(argv[1]);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-09-19 15:24:45 +00:00
|
|
|
for (item = _iconsole_vars; item != NULL; item = item->_next)
|
|
|
|
if (argv[1] == NULL || strncmp(item->name, argv[1], l) == 0)
|
|
|
|
IConsoleVarDump(item, NULL);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConSay)
|
|
|
|
{
|
|
|
|
if (argc == 2) {
|
|
|
|
if (!_network_server)
|
|
|
|
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0 /* param does not matter */, argv[1]);
|
|
|
|
else
|
|
|
|
NetworkServer_HandleChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, argv[1], NETWORK_SERVER_INDEX);
|
|
|
|
} else
|
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: say \"<msg>\"");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConSayPlayer)
|
|
|
|
{
|
|
|
|
if (argc == 3) {
|
|
|
|
if (atoi(argv[1]) < 1 || atoi(argv[1]) > MAX_PLAYERS) {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_network_server)
|
|
|
|
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2]);
|
|
|
|
else
|
|
|
|
NetworkServer_HandleChat(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2], NETWORK_SERVER_INDEX);
|
|
|
|
} else
|
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: say_player <playerno> \"<msg>\"");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_CONSOLE_CMD(ConSayClient)
|
|
|
|
{
|
|
|
|
if (argc == 3) {
|
|
|
|
if (!_network_server)
|
|
|
|
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2]);
|
|
|
|
else
|
|
|
|
NetworkServer_HandleChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2], NETWORK_SERVER_INDEX);
|
|
|
|
} else
|
|
|
|
IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: say_client <clientno> \"<msg>\"");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-13 15:07:33 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
|
|
|
|
/* **************************** */
|
|
|
|
/* the "set" command */
|
|
|
|
/* **************************** */
|
|
|
|
|
2004-12-13 17:04:41 +00:00
|
|
|
extern void ConsoleSetPatchSetting(char *name, char *value);
|
|
|
|
extern void ConsoleGetPatchSetting(char *name);
|
|
|
|
|
2004-12-13 15:07:33 +00:00
|
|
|
DEF_CONSOLE_CMD(ConSet) {
|
|
|
|
if (argc < 2) {
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Unknonw usage. Usage: set [setting] [value].");
|
|
|
|
return NULL;
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
|
|
|
|
2004-12-13 15:07:33 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
2004-12-04 17:54:56 +00:00
|
|
|
|
2004-12-13 15:07:33 +00:00
|
|
|
// setting the server password
|
|
|
|
if ((strcmp(argv[1],"server_pw") == 0) || (strcmp(argv[1],"server_password") == 0)) {
|
2004-12-13 17:04:41 +00:00
|
|
|
if (!_network_server) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
2004-12-13 15:07:33 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (argc == 3) {
|
|
|
|
// Change server password
|
2004-12-15 17:31:18 +00:00
|
|
|
if (strncmp(argv[2], "*", NETWORK_PASSWORD_LENGTH) == 0) {
|
2005-01-15 20:09:16 +00:00
|
|
|
_network_server_password[0] = '\0';
|
2004-12-13 15:07:33 +00:00
|
|
|
_network_game_info.use_password = 0;
|
|
|
|
} else {
|
2005-01-15 20:09:16 +00:00
|
|
|
ttd_strlcpy(_network_server_password, argv[2], sizeof(_network_server_password));
|
2004-12-13 15:07:33 +00:00
|
|
|
_network_game_info.use_password = 1;
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
2005-01-15 20:09:16 +00:00
|
|
|
IConsolePrintF(_iconsole_color_warning, "Game-password changed to '%s'", _network_server_password);
|
|
|
|
ttd_strlcpy(_network_game_info.server_password, _network_server_password, sizeof(_network_game_info.server_password));
|
2004-12-13 15:07:33 +00:00
|
|
|
} else {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Current game-password is set to '%s'", _network_game_info.server_password);
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set server_pw \"<password>\". Use * as <password> to set no password.");
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
2004-12-13 15:07:33 +00:00
|
|
|
return NULL;
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 20:09:16 +00:00
|
|
|
// setting the rcon password
|
|
|
|
if ((strcmp(argv[1], "rcon_pw") == 0) || (strcmp(argv[1], "rcon_password") == 0)) {
|
|
|
|
if (!_network_server) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (argc == 3) {
|
|
|
|
// Change server password
|
|
|
|
if (strncmp(argv[2], "*", NETWORK_PASSWORD_LENGTH) == 0) {
|
|
|
|
_network_rcon_password[0] = '\0';
|
|
|
|
} else {
|
|
|
|
ttd_strlcpy(_network_rcon_password, argv[2], sizeof(_network_rcon_password));
|
|
|
|
}
|
|
|
|
IConsolePrintF(_iconsole_color_warning, "Rcon-password changed to '%s'", _network_rcon_password);
|
|
|
|
ttd_strlcpy(_network_game_info.rcon_password, _network_rcon_password, sizeof(_network_game_info.rcon_password));
|
|
|
|
} else {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Current rcon-password is set to '%s'", _network_game_info.rcon_password);
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set rcon_pw \"<password>\". Use * as <password> to disable rcon.");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-13 15:07:33 +00:00
|
|
|
// setting the company password
|
|
|
|
if ((strcmp(argv[1],"company_pw") == 0) || (strcmp(argv[1],"company_password") == 0)) {
|
|
|
|
if (!_networking) {
|
|
|
|
IConsolePrintF(_iconsole_color_error,"No network game running");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (_local_player >= MAX_PLAYERS) {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "You have to own a company to make use of this command.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (argc == 3) {
|
2004-12-22 23:24:53 +00:00
|
|
|
NetworkChangeCompanyPassword(argv[2]);
|
2004-12-13 15:07:33 +00:00
|
|
|
} else {
|
2004-12-22 23:24:53 +00:00
|
|
|
IConsolePrint(_iconsole_color_default, "'set company_pw' sets a password for your company, so no-one without the correct password can join.");
|
2004-12-13 15:07:33 +00:00
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set company_pw \"<password>\". Use * as <password> to set no password.");
|
|
|
|
}
|
2004-12-04 17:54:56 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2004-12-13 15:07:33 +00:00
|
|
|
|
|
|
|
// setting the player name
|
|
|
|
if (strcmp(argv[1],"name") == 0) {
|
|
|
|
NetworkClientInfo *ci;
|
|
|
|
|
|
|
|
if (!_networking) {
|
|
|
|
IConsolePrintF(_iconsole_color_error,"No network game running");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
|
|
|
|
|
|
|
|
if (argc == 3 && ci != NULL) {
|
2005-02-22 12:27:33 +00:00
|
|
|
// Don't change the name if it is the same as the old name
|
2005-02-22 13:13:57 +00:00
|
|
|
if (strcmp(ci->client_name, argv[2]) != 0) {
|
2005-02-22 12:27:33 +00:00
|
|
|
if (!_network_server) {
|
|
|
|
SEND_COMMAND(PACKET_CLIENT_SET_NAME)(argv[2]);
|
|
|
|
} else {
|
|
|
|
if (NetworkFindName(argv[2])) {
|
|
|
|
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, false, ci->client_name, argv[2]);
|
|
|
|
ttd_strlcpy(ci->client_name, argv[2], sizeof(ci->client_name));
|
|
|
|
NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
|
|
|
|
}
|
2004-12-13 15:07:33 +00:00
|
|
|
}
|
2005-02-22 12:27:33 +00:00
|
|
|
/* Also keep track of the new name on the client itself */
|
|
|
|
ttd_strlcpy(_network_player_name, argv[2], sizeof(_network_player_name));
|
2004-12-13 15:07:33 +00:00
|
|
|
}
|
2004-12-04 17:54:56 +00:00
|
|
|
} else {
|
2004-12-13 15:07:33 +00:00
|
|
|
IConsolePrint(_iconsole_color_default, "With 'set name' you can change your network-player name.");
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set name \"<name>\".");
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
2004-12-13 15:07:33 +00:00
|
|
|
return NULL;
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
|
|
|
|
2004-12-13 15:07:33 +00:00
|
|
|
// setting the server name
|
|
|
|
if (strcmp(argv[1],"server_name") == 0) {
|
2004-12-13 17:04:41 +00:00
|
|
|
if (!_network_server) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
2004-12-13 15:07:33 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (argc == 3) {
|
2004-12-16 15:51:18 +00:00
|
|
|
ttd_strlcpy(_network_server_name, argv[2], sizeof(_network_server_name));
|
2004-12-13 15:07:33 +00:00
|
|
|
IConsolePrintF(_iconsole_color_warning, "Server-name changed to '%s'", _network_server_name);
|
2004-12-15 17:31:18 +00:00
|
|
|
ttd_strlcpy(_network_game_info.server_name, _network_server_name, sizeof(_network_game_info.server_name));
|
2004-12-04 17:54:56 +00:00
|
|
|
} else {
|
2004-12-13 15:07:33 +00:00
|
|
|
IConsolePrintF(_iconsole_color_default, "Current server-name is '%s'", _network_server_name);
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set server_name \"<GameName>\".");
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
2004-12-13 15:07:33 +00:00
|
|
|
return NULL;
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
|
|
|
|
2004-12-13 17:47:21 +00:00
|
|
|
// setting the server port
|
|
|
|
if (strcmp(argv[1],"server_port") == 0) {
|
2004-12-13 17:04:41 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-12-13 17:47:21 +00:00
|
|
|
// setting the server ip
|
|
|
|
if (strcmp(argv[1],"server_bind_ip") == 0 || strcmp(argv[1],"server_ip_bind") == 0 ||
|
|
|
|
strcmp(argv[1],"server_ip") == 0 || strcmp(argv[1],"server_bind") == 0) {
|
|
|
|
if (argc == 3) {
|
|
|
|
_network_server_bind_ip = inet_addr(argv[2]);
|
|
|
|
snprintf(_network_server_bind_ip_host, sizeof(_network_server_bind_ip_host), "%s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip));
|
|
|
|
IConsolePrintF(_iconsole_color_warning, "Server-bind-ip changed to '%s'", _network_server_bind_ip_host);
|
|
|
|
IConsolePrintF(_iconsole_color_warning, "Changes will take effect the next time you start a server.");
|
|
|
|
} else {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Current server-bind-ip is '%s'", _network_server_bind_ip_host);
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set server_bind_ip <ip>.");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-15 22:06:47 +00:00
|
|
|
// setting the server advertising on/off
|
|
|
|
if (strcmp(argv[1],"server_advertise") == 0) {
|
2004-12-16 11:36:57 +00:00
|
|
|
if (!_network_server) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-12-15 22:06:47 +00:00
|
|
|
if (argc == 3) {
|
|
|
|
if (strcmp(argv[2], "on") == 0 || atoi(argv[2]) == 1)
|
|
|
|
_network_advertise = true;
|
2004-12-22 18:56:52 +00:00
|
|
|
else {
|
|
|
|
NetworkUDPRemoveAdvertise();
|
2004-12-15 22:06:47 +00:00
|
|
|
_network_advertise = false;
|
2004-12-22 18:56:52 +00:00
|
|
|
}
|
2004-12-15 22:06:47 +00:00
|
|
|
IConsolePrintF(_iconsole_color_warning, "Server-advertise changed to '%s'", (_network_advertise)?"on":"off");
|
|
|
|
} else {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Current server-advertise is '%s'", (_network_advertise)?"on":"off");
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set server_advertise on/off.");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-16 13:59:23 +00:00
|
|
|
// setting the server autoclean on/off
|
|
|
|
if (strcmp(argv[1],"autoclean_companies") == 0) {
|
|
|
|
if (!_network_server) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (argc == 3) {
|
|
|
|
if (strcmp(argv[2], "on") == 0 || atoi(argv[2]) == 1)
|
|
|
|
_network_autoclean_companies = true;
|
|
|
|
else
|
|
|
|
_network_autoclean_companies = false;
|
|
|
|
IConsolePrintF(_iconsole_color_warning, "Autoclean-companies changed to '%s'", (_network_autoclean_companies)?"on":"off");
|
|
|
|
} else {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Current autoclean-companies is '%s'", (_network_autoclean_companies)?"on":"off");
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set autoclean_companies on/off.");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setting the server autoclean protected
|
|
|
|
if (strcmp(argv[1],"autoclean_protected") == 0) {
|
|
|
|
if (!_network_server) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (argc == 3) {
|
|
|
|
_network_autoclean_protected = atoi(argv[2]);
|
|
|
|
IConsolePrintF(_iconsole_color_warning, "Autoclean-protected changed to '%d'", _network_autoclean_protected);
|
|
|
|
} else {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Current autoclean-protected is '%d'", _network_autoclean_protected);
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set autoclean_protected <months>.");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setting the server autoclean protected
|
|
|
|
if (strcmp(argv[1],"autoclean_unprotected") == 0) {
|
|
|
|
if (!_network_server) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (argc == 3) {
|
|
|
|
_network_autoclean_unprotected = atoi(argv[2]);
|
|
|
|
IConsolePrintF(_iconsole_color_warning, "Autoclean-unprotected changed to '%d'", _network_autoclean_unprotected);
|
|
|
|
} else {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Current autoclean-unprotected is '%d'", _network_autoclean_unprotected);
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set autoclean_unprotected <months>.");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-23 17:37:26 +00:00
|
|
|
// setting the server auto restart date
|
|
|
|
if (strcmp(argv[1],"restart_game_date") == 0) {
|
|
|
|
if (!_network_server) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (argc == 3) {
|
|
|
|
_network_restart_game_date = atoi(argv[2]);
|
|
|
|
IConsolePrintF(_iconsole_color_warning, "Restart Game Date changed to '%d'", _network_restart_game_date);
|
|
|
|
} else {
|
|
|
|
IConsolePrintF(_iconsole_color_default, "Current Restart Game Date is '%d'", _network_restart_game_date);
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set restart_game_date <year>. '0' means disabled.");
|
|
|
|
IConsolePrint(_iconsole_color_warning, " Auto-restart the server when 1 jan of this year is reached (e.g.: 2030).");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-13 17:47:21 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
2004-12-13 15:07:33 +00:00
|
|
|
|
2004-12-13 16:16:28 +00:00
|
|
|
// Patch-options
|
|
|
|
if (strcmp(argv[1],"patch") == 0) {
|
|
|
|
if (_networking && !_network_server) {
|
|
|
|
IConsolePrintF(_iconsole_color_error, "You are not the server");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (argc == 3)
|
|
|
|
ConsoleGetPatchSetting(argv[2]);
|
|
|
|
else if (argc == 4)
|
|
|
|
ConsoleSetPatchSetting(argv[2], argv[3]);
|
|
|
|
else
|
|
|
|
IConsolePrint(_iconsole_color_warning, "Usage: set patch <patch_name> [<value>].");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-13 17:47:21 +00:00
|
|
|
IConsolePrint(_iconsole_color_error, "Unknown setting");
|
|
|
|
IConsolePrint(_iconsole_color_error, "Known settings are:");
|
|
|
|
#ifdef ENABLE_NETWORK
|
2004-12-16 13:59:23 +00:00
|
|
|
IConsolePrint(_iconsole_color_error, " - autoclean_companies on/off");
|
|
|
|
IConsolePrint(_iconsole_color_error, " - autoclean_protected <months>");
|
|
|
|
IConsolePrint(_iconsole_color_error, " - autoclean_unprotected <months>");
|
2004-12-13 17:47:21 +00:00
|
|
|
IConsolePrint(_iconsole_color_error, " - company_pw \"<password>\"");
|
|
|
|
IConsolePrint(_iconsole_color_error, " - name \"<playername>\"");
|
2005-01-15 20:09:16 +00:00
|
|
|
IConsolePrint(_iconsole_color_error, " - rcon_pw \"<password>\"");
|
2004-12-16 13:59:23 +00:00
|
|
|
IConsolePrint(_iconsole_color_error, " - server_name \"<name>\"");
|
2004-12-15 22:06:47 +00:00
|
|
|
IConsolePrint(_iconsole_color_error, " - server_advertise on/off");
|
2004-12-16 13:59:23 +00:00
|
|
|
IConsolePrint(_iconsole_color_error, " - server_bind_ip <ip>");
|
|
|
|
IConsolePrint(_iconsole_color_error, " - server_port <port>");
|
|
|
|
IConsolePrint(_iconsole_color_error, " - server_pw \"<password>\"");
|
2004-12-23 17:37:26 +00:00
|
|
|
IConsolePrint(_iconsole_color_error, " - restart_game_date \"<year>\"");
|
2004-12-13 17:47:21 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
|
|
|
IConsolePrint(_iconsole_color_error, " - patch <patch_name> [<value>]");
|
2004-12-13 15:07:33 +00:00
|
|
|
|
|
|
|
return NULL;
|
2004-12-04 17:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-12 21:49:38 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
/* ****************************************** */
|
|
|
|
/* debug commands and variables */
|
|
|
|
/* ****************************************** */
|
|
|
|
|
2005-01-22 22:47:58 +00:00
|
|
|
static void IConsoleDebugLibRegister(void)
|
2004-09-12 21:49:38 +00:00
|
|
|
{
|
2004-12-05 12:25:25 +00:00
|
|
|
// debugging variables and functions
|
2004-09-19 15:24:45 +00:00
|
|
|
extern bool _stdlib_con_developer; /* XXX extern in .c */
|
|
|
|
|
|
|
|
IConsoleVarRegister("con_developer", &_stdlib_con_developer, ICONSOLE_VAR_BOOLEAN);
|
2004-12-05 12:25:25 +00:00
|
|
|
IConsoleVarMemRegister("temp_string2", ICONSOLE_VAR_STRING);
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsoleVarMemRegister("temp_uint16_2", ICONSOLE_VAR_UINT16);
|
|
|
|
IConsoleCmdRegister("resettile", ConResetTile);
|
2004-12-13 18:51:08 +00:00
|
|
|
IConsoleAliasRegister("dbg_echo","echo %A; echo %B");
|
|
|
|
IConsoleAliasRegister("dbg_echo2","echo %+");
|
2004-09-12 21:49:38 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ****************************************** */
|
|
|
|
/* console command and variable registration */
|
|
|
|
/* ****************************************** */
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
void IConsoleStdLibRegister(void)
|
2004-09-12 21:49:38 +00:00
|
|
|
{
|
|
|
|
// stdlib
|
2004-09-19 15:24:45 +00:00
|
|
|
extern byte _stdlib_developer; /* XXX extern in .c */
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-12-05 12:25:25 +00:00
|
|
|
// default variables and functions
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsoleCmdRegister("debug_level", ConDebugLevel);
|
|
|
|
IConsoleCmdRegister("dump_vars", ConListDumpVariables);
|
|
|
|
IConsoleCmdRegister("echo", ConEcho);
|
|
|
|
IConsoleCmdRegister("echoc", ConEchoC);
|
|
|
|
IConsoleCmdRegister("exec", ConExec);
|
|
|
|
IConsoleCmdRegister("exit", ConExit);
|
|
|
|
IConsoleCmdRegister("help", ConHelp);
|
|
|
|
IConsoleCmdRegister("info_cmd", ConInfoCmd);
|
|
|
|
IConsoleCmdRegister("info_var", ConInfoVar);
|
|
|
|
IConsoleCmdRegister("list_cmds", ConListCommands);
|
|
|
|
IConsoleCmdRegister("list_vars", ConListVariables);
|
2004-12-13 18:51:08 +00:00
|
|
|
IConsoleCmdRegister("list_aliases", ConListAliases);
|
2004-12-04 17:54:56 +00:00
|
|
|
IConsoleCmdRegister("newgame", ConNewGame);
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsoleCmdRegister("printf", ConPrintF);
|
|
|
|
IConsoleCmdRegister("printfc", ConPrintFC);
|
|
|
|
IConsoleCmdRegister("quit", ConExit);
|
|
|
|
IConsoleCmdRegister("random", ConRandom);
|
|
|
|
IConsoleCmdRegister("resetengines", ConResetEngines);
|
|
|
|
IConsoleCmdRegister("return", ConReturn);
|
2004-12-05 12:25:25 +00:00
|
|
|
IConsoleCmdRegister("screenshot", ConScreenShot);
|
|
|
|
IConsoleCmdRegister("script", ConScript);
|
|
|
|
IConsoleCmdRegister("scrollto", ConScrollToTile);
|
2004-12-13 15:07:33 +00:00
|
|
|
IConsoleCmdRegister("set", ConSet);
|
2004-12-13 18:51:08 +00:00
|
|
|
IConsoleCmdRegister("alias", ConAlias);
|
2005-01-04 15:06:08 +00:00
|
|
|
IConsoleCmdRegister("load", ConLoad);
|
2005-03-25 18:26:49 +00:00
|
|
|
IConsoleCmdRegister("save", ConSave);
|
2005-01-04 15:06:08 +00:00
|
|
|
IConsoleCmdRegister("list_files", ConListFiles);
|
2005-01-08 00:48:10 +00:00
|
|
|
IConsoleCmdRegister("scan_files", ConScanFiles);
|
2005-01-04 15:06:08 +00:00
|
|
|
IConsoleCmdRegister("goto_dir", ConGotoDir);
|
2005-01-08 00:48:10 +00:00
|
|
|
IConsoleAliasRegister("new_game", "newgame");
|
|
|
|
IConsoleAliasRegister("newmap", "newgame");
|
|
|
|
IConsoleAliasRegister("new_map", "newgame");
|
|
|
|
IConsoleAliasRegister("load_game", "temp_string << scan_files %!;load temp_string");
|
2004-12-05 12:25:25 +00:00
|
|
|
|
|
|
|
IConsoleVarRegister("developer", &_stdlib_developer, ICONSOLE_VAR_BYTE);
|
|
|
|
|
2005-01-08 00:48:10 +00:00
|
|
|
// temporary data containers for alias scripting
|
|
|
|
IConsoleVarMemRegister("temp_string", ICONSOLE_VAR_STRING);
|
|
|
|
IConsoleVarMemRegister("temp_bool", ICONSOLE_VAR_BOOLEAN);
|
|
|
|
IConsoleVarMemRegister("temp_int16", ICONSOLE_VAR_INT16);
|
|
|
|
IConsoleVarMemRegister("temp_int32", ICONSOLE_VAR_INT32);
|
|
|
|
IConsoleVarMemRegister("temp_pointer", ICONSOLE_VAR_POINTER);
|
|
|
|
IConsoleVarMemRegister("temp_uint16", ICONSOLE_VAR_UINT16);
|
|
|
|
IConsoleVarMemRegister("temp_uint32", ICONSOLE_VAR_UINT32);
|
|
|
|
|
|
|
|
|
2004-12-05 12:25:25 +00:00
|
|
|
// networking variables and functions
|
2004-12-04 17:54:56 +00:00
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
IConsoleCmdRegister("say", ConSay);
|
|
|
|
IConsoleCmdHook("say", ICONSOLE_HOOK_ACCESS, ConCmdHookNeedNetwork);
|
|
|
|
IConsoleCmdRegister("say_player", ConSayPlayer);
|
|
|
|
IConsoleCmdHook("say_player", ICONSOLE_HOOK_ACCESS, ConCmdHookNeedNetwork);
|
|
|
|
IConsoleCmdRegister("say_client", ConSayClient);
|
|
|
|
IConsoleCmdHook("say_client", ICONSOLE_HOOK_ACCESS, ConCmdHookNeedNetwork);
|
2004-12-05 12:25:25 +00:00
|
|
|
IConsoleCmdRegister("kick", ConKick);
|
|
|
|
IConsoleCmdHook("kick", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
|
2004-12-16 11:36:57 +00:00
|
|
|
IConsoleCmdRegister("reset_company", ConResetCompany);
|
|
|
|
IConsoleCmdHook("reset_company", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
|
2004-12-05 12:25:25 +00:00
|
|
|
IConsoleCmdRegister("connect", ConNetworkConnect);
|
|
|
|
IConsoleCmdHook("connect", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetServer);
|
|
|
|
IConsoleCmdRegister("clients", ConNetworkClients);
|
2004-12-04 17:54:56 +00:00
|
|
|
IConsoleCmdRegister("status", ConStatus);
|
|
|
|
IConsoleCmdHook("status", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
|
2004-12-05 12:25:25 +00:00
|
|
|
IConsoleCmdHook("resetengines", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetwork);
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2005-01-15 20:09:16 +00:00
|
|
|
IConsoleCmdRegister("rcon", ConRcon);
|
|
|
|
IConsoleCmdHook("rcon", ICONSOLE_HOOK_ACCESS, ConCmdHookNeedNetwork);
|
|
|
|
|
2005-01-02 12:03:43 +00:00
|
|
|
IConsoleCmdRegister("ban", ConBan);
|
|
|
|
IConsoleCmdHook("ban", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
|
|
|
|
IConsoleCmdRegister("unban", ConUnBan);
|
|
|
|
IConsoleCmdHook("unban", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
|
|
|
|
IConsoleCmdRegister("banlist", ConBanList);
|
|
|
|
IConsoleCmdHook("banlist", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
|
2005-01-24 21:33:44 +00:00
|
|
|
IConsoleCmdRegister("pause", ConPauseGame);
|
|
|
|
IConsoleCmdHook("pause", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
|
|
|
|
IConsoleCmdRegister("unpause", ConUnPauseGame);
|
|
|
|
IConsoleCmdHook("unpause", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
|
2005-01-02 12:03:43 +00:00
|
|
|
|
2004-12-23 17:12:30 +00:00
|
|
|
IConsoleAliasRegister("clean_company", "reset_company %A");
|
2004-12-16 11:36:57 +00:00
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
IConsoleVarRegister("net_frame_freq", &_network_frame_freq, ICONSOLE_VAR_UINT8);
|
2004-12-05 12:25:25 +00:00
|
|
|
IConsoleVarHook("net_frame_freq", ICONSOLE_HOOK_ACCESS, ConVarHookNoNetClient);
|
2004-09-19 15:24:45 +00:00
|
|
|
IConsoleVarRegister("net_sync_freq", &_network_sync_freq, ICONSOLE_VAR_UINT16);
|
2004-12-05 12:25:25 +00:00
|
|
|
IConsoleVarHook("net_sync_freq", ICONSOLE_HOOK_ACCESS, ConVarHookNoNetClient);
|
2004-12-04 17:54:56 +00:00
|
|
|
#endif /* ENABLE_NETWORK */
|
2004-09-12 21:49:38 +00:00
|
|
|
|
2004-12-05 12:25:25 +00:00
|
|
|
// debugging stuff
|
|
|
|
#ifdef _DEBUG
|
|
|
|
IConsoleDebugLibRegister();
|
|
|
|
#endif
|
2004-09-12 21:49:38 +00:00
|
|
|
|
|
|
|
}
|
2004-09-19 15:24:45 +00:00
|
|
|
/* -------------------- don't cross this line --------------------- */
|