From 5a726b5ea6c29fea77fe90194ab5222d8a9dbee3 Mon Sep 17 00:00:00 2001 From: kungfooman Date: Thu, 21 Mar 2019 02:12:15 +0100 Subject: [PATCH] proper cgame layout --- cg_consolecmds.cpp | 17 +++++++++++++++++ cg_local.h | 6 ++++++ cg_public.h | 3 +++ cl_main.cpp | 3 +++ 4 files changed, 29 insertions(+) create mode 100644 cg_consolecmds.cpp create mode 100644 cg_local.h create mode 100644 cg_public.h diff --git a/cg_consolecmds.cpp b/cg_consolecmds.cpp new file mode 100644 index 0000000..7291855 --- /dev/null +++ b/cg_consolecmds.cpp @@ -0,0 +1,17 @@ +#include "stdheader.h" +#include "cg_local.h" + +// example: /cg_abc 1 2.2 three +// output: argc=4 (int, float, string) = (1, 2.2, "three") + +void CG_abc_f() { + int a = atoi(CG_Argv(1)); + float b = atof(CG_Argv(2)); + char *c = CG_Argv(3); + Com_Printf("argc=%d (int, float, string) = (%d, %f, \"%s\")", CG_Argc(), a, b, c); +} + +void CG_InitConsoleCommands(void) { + + Cmd_AddCommand("cg_abc", CG_abc_f); +} \ No newline at end of file diff --git a/cg_local.h b/cg_local.h new file mode 100644 index 0000000..1752c67 --- /dev/null +++ b/cg_local.h @@ -0,0 +1,6 @@ +#pragma once + +// cg_servercmds.cpp +unsigned int CG_Argc(); +char *CG_Argv(int i); +void CG_ServerCommand(void); diff --git a/cg_public.h b/cg_public.h new file mode 100644 index 0000000..ae74bd7 --- /dev/null +++ b/cg_public.h @@ -0,0 +1,3 @@ +#pragma once + +void CG_InitConsoleCommands(void); diff --git a/cl_main.cpp b/cl_main.cpp index 12677db..3bbc9db 100644 --- a/cl_main.cpp +++ b/cl_main.cpp @@ -2,6 +2,7 @@ #include "gl33.h" //#pragma comment(lib, "opengl32.lib") #include "imgui.h" +#include "cg_public.h" void Cmd_Moto_f() { @@ -137,4 +138,6 @@ void CL_Init( void ) Com_Printf("^6bla: %d\n", GetCurrentThreadId()); //cl_inited = true; + + CG_InitConsoleCommands(); } \ No newline at end of file