This commit is contained in:
momo5502 2016-08-07 18:25:44 +02:00
parent 799a7583ef
commit ab3d0b789d
6 changed files with 35 additions and 3 deletions

View File

@ -86,6 +86,23 @@ namespace Components
} }
} }
Game::cmd_function_t* Command::Find(std::string command)
{
Game::cmd_function_t* cmdFunction = *Game::cmd_functions;
while (cmdFunction)
{
if (cmdFunction->name && cmdFunction->name == command)
{
return cmdFunction;
}
cmdFunction = cmdFunction->next;
}
return nullptr;
}
Game::cmd_function_t* Command::Allocate() Game::cmd_function_t* Command::Allocate()
{ {
Game::cmd_function_t* cmd = new Game::cmd_function_t; Game::cmd_function_t* cmd = new Game::cmd_function_t;

View File

@ -33,6 +33,8 @@ namespace Components
static void AddRawSV(const char* name, void(*callback)()); static void AddRawSV(const char* name, void(*callback)());
static void Execute(std::string command, bool sync = true); static void Execute(std::string command, bool sync = true);
static Game::cmd_function_t* Find(std::string command);
private: private:
static Game::cmd_function_t* Allocate(); static Game::cmd_function_t* Allocate();
static std::vector<Game::cmd_function_t*> Functions; static std::vector<Game::cmd_function_t*> Functions;

View File

@ -120,9 +120,13 @@ namespace Components
if (args.Length() >= 4) if (args.Length() >= 4)
{ {
Game::dvar_t* dvar = Game::Dvar_FindVar(args[3]); std::string cmd = args[0];
std::string table = args[1];
std::string col = args[2];
std::string dvarName = args[3];
Game::dvar_t* dvar = Game::Dvar_FindVar(dvarName.data());
if (!dvar || dvar->flags & Game::DVAR_FLAG_WRITEPROTECTED || dvar->flags & Game::DVAR_FLAG_CHEAT || dvar->flags & Game::DVAR_FLAG_READONLY) if (Command::Find(dvarName) || (dvar && (dvar->flags & Game::DVAR_FLAG_WRITEPROTECTED || dvar->flags & Game::DVAR_FLAG_CHEAT || dvar->flags & Game::DVAR_FLAG_READONLY)))
{ {
return; return;
} }

View File

@ -199,6 +199,8 @@ namespace Game
DWORD* cmd_argc_sv = (DWORD*)0x1ACF8E4; DWORD* cmd_argc_sv = (DWORD*)0x1ACF8E4;
char*** cmd_argv_sv = (char***)0x1ACF904; char*** cmd_argv_sv = (char***)0x1ACF904;
cmd_function_t** cmd_functions = (cmd_function_t**)0x1AAC658;
source_t **sourceFiles = (source_t **)0x7C4A98; source_t **sourceFiles = (source_t **)0x7C4A98;
keywordHash_t **menuParseKeywordHash = (keywordHash_t **)0x63AE928; keywordHash_t **menuParseKeywordHash = (keywordHash_t **)0x63AE928;

View File

@ -442,6 +442,8 @@ namespace Game
extern DWORD* cmd_argc_sv; extern DWORD* cmd_argc_sv;
extern char*** cmd_argv_sv; extern char*** cmd_argv_sv;
extern cmd_function_t** cmd_functions;
extern int* svs_numclients; extern int* svs_numclients;
extern client_t* svs_clients; extern client_t* svs_clients;

View File

@ -131,7 +131,12 @@ namespace Game
typedef struct cmd_function_s typedef struct cmd_function_s
{ {
char pad[24]; cmd_function_s *next;
const char *name;
const char *autoCompleteDir;
const char *autoCompleteExt;
void(__cdecl *function)();
int pad;
} cmd_function_t; } cmd_function_t;
typedef struct typedef struct