[server] Add console command stubs

This commit is contained in:
RD42 2023-11-01 21:30:19 +08:00
parent d7101d3a02
commit 40f38a892e
2 changed files with 81 additions and 0 deletions

View File

@ -1,6 +1,55 @@
#include "main.h"
void con_exit() {} // TODO: con_exit W: 0048A4F0 L: 0809EC60
void con_echo() {} // TODO: con_echo W: 0048A500 L: 0809EC70
void con_exec() {} // TODO: con_exec W: 0048BA80 L: 080A0340
void con_kick() {} // TODO: con_kick W: 0048A530 L: 0809ECB0
void con_ban() {} // TODO: con_ban W: 0048A5D0 L: 0809ED80
void con_banip() {} // TODO: con_banip W: 0048A740 L: 0809EF40
void con_unbanip() {} // TODO: con_unbanip W: 0048A790 L: 0809EFB0
void con_gmx() {} // TODO: con_gmx W: 0048A7D0 L: 0809F000
void con_changemode() {} // TODO: con_changemode W: 0048A800 L: 0809F050
void con_varlist() {} // TODO: con_varlist W: 0048B2F0 L: 0809F970
void con_say() {} // TODO: con_say W: 0048A830 L: 0809F0A0
void con_reloadbans() {} // TODO: con_reloadbans W: 0048A880 L: 0809F110
void con_reloadlog() {} // TODO: con_reloadlog W: 0048A890 L: 0809F130
void con_players() {} // TODO: con_players W: 0048A8A0 L: 0809F140
void con_gravity() {} // TODO: con_gravity W: 0048A950 L: 0809F220
void con_weather() {} // TODO: con_weather W: 0048A980 L: 0809F260
void con_loadfs() {} // TODO: con_loadfs W: 0048A9B0 L: 0809F2A0
void con_reloadfs() {} // TODO: con_reloadfs W: 0048AA20 L: 0809F330
void con_unloadfs() {} // TODO: con_unloadfs W: 0048AAC0 L: 0809F410
void con_cmdlist() {} // TODO: con_cmdlist W: 0048AB30 L: 0809F4A0
struct ConsoleCommand_s
{
char CmdName[255];
DWORD CmdFlags;
void (*CmdFunc)();
} ConsoleCommands[] = {
{"echo", 0, con_echo},
{"exec", 0, con_exec},
{"cmdlist", 0, con_cmdlist},
{"varlist", 0, con_varlist},
{"exit", 0, con_exit},
{"kick", 0, con_kick},
{"ban", 0, con_ban},
{"gmx", 0, con_gmx},
{"changemode", 0, con_changemode},
{"say", 0, con_say},
{"reloadbans", 0, con_reloadbans},
{"reloadlog", 0, con_reloadlog},
{"players", 0, con_players},
{"banip", 0, con_banip},
{"unbanip", 0, con_unbanip},
{"gravity", 0, con_gravity},
{"weather", 0, con_weather},
{"loadfs", 0, con_loadfs},
{"unloadfs", 0, con_unloadfs},
{"reloadfs", 0, con_reloadfs},
};
CConsole::CConsole()
{
@ -189,4 +238,31 @@ void CConsole::SetBoolVariable(char* pVarName, bool bBool)
void CConsole::Execute(char* pExecLine)
{
// TODO: CConsole::Execute W: 0048B610 L: 0809FBD0
if (!pExecLine) return;
// Ya can't strtok on a read-only string!
char cpy[256];
memset(cpy,0,sizeof(cpy));
strncpy(cpy, pExecLine, 255);
char* tmp = strtok(cpy, " ");
if(!tmp) return;
char* cmd = strlwr(tmp);
for (int i=0; i<ARRAY_SIZE(ConsoleCommands); i++)
{
if (stricmp(cmd, ConsoleCommands[i].CmdName) == 0)
{
if (ConsoleCommands[i].CmdFlags & 1)
{
#ifndef _DEBUG
logprintf("Unable to execute command '%s'. Debug mode required.", ConsoleCommands[i].CmdName);
return;
#endif
}
ConsoleCommands[i].CmdFunc();
return;
}
}
}

View File

@ -5,6 +5,8 @@
#define DEFAULT_MAX_PLAYERS 50
#define DEFAULT_LISTEN_PORT 8192
#define ARRAY_SIZE(a) ( sizeof((a)) / sizeof(*(a)) )
// ------------
// VERSION INFO
// ------------
@ -21,6 +23,9 @@
#include <windows.h>
#include <time.h>
#else
#ifndef stricmp
#define stricmp strcasecmp
#endif
#endif
// --------