diff --git a/include/QF/idparse.h b/include/QF/idparse.h index 6a595cbd2..b2faa27c1 100644 --- a/include/QF/idparse.h +++ b/include/QF/idparse.h @@ -28,9 +28,16 @@ */ +#ifndef __QF_idparse_h +#define __QF_idparse_h + extern const char *com_token; +struct cbuf_args_s; + const char *COM_Parse (const char *data); -void COM_TokenizeString (const char *str, cbuf_args_t *args); +void COM_TokenizeString (const char *str, struct cbuf_args_s *args); extern struct cbuf_interpreter_s id_interp; + +#endif//__QF_idparse_h diff --git a/include/QF/keys.h b/include/QF/keys.h index 7db0b2ba8..b9d01ca56 100644 --- a/include/QF/keys.h +++ b/include/QF/keys.h @@ -380,12 +380,12 @@ extern imt_t game_target; extern struct keybind_s { char *str; - struct cbuf_s *cbuf; } keybindings[IMT_LAST][QFK_LAST]; extern int keydown[QFK_LAST]; +struct cbuf_s; void Key_Event (knum_t key, short unicode, qboolean down); -void Key_Init (void); +void Key_Init (struct cbuf_s *cb); void Key_Init_Cvars (void); void Key_WriteBindings (VFile *f); void Key_ClearStates (void); diff --git a/libs/gamecode/builtins/bi_keys.c b/libs/gamecode/builtins/bi_keys.c index 8cbc45d34..666f292ae 100644 --- a/libs/gamecode/builtins/bi_keys.c +++ b/libs/gamecode/builtins/bi_keys.c @@ -38,21 +38,10 @@ static const char rcsid[] = # include #endif -#include "QF/cbuf.h" -#include "QF/idparse.h" #include "QF/keys.h" #include "QF/progs.h" #include "QF/zone.h" -static cbuf_t *cbuf; //FIXME use a properly allocated cbuf rather than this hack - -static inline void -check_cbuf (void) -{ - if (!cbuf) - cbuf = Cbuf_New (&id_interp); -} - /* bi_Key_SetBinding @@ -64,16 +53,12 @@ bi_Key_SetBinding (progs_t *pr) int target = P_INT (pr, 0); int keynum = P_INT (pr, 1); const char *binding = P_STRING (pr, 2); - cbuf_t *tcb = cbuf_active; if(strlen(binding) == 0 || binding[0] == '\0') { binding = NULL; /* unbind a binding */ } - check_cbuf (); - cbuf_active = cbuf; Key_SetBinding (target, keynum, binding); - cbuf_active = tcb; } /* diff --git a/libs/video/targets/keys.c b/libs/video/targets/keys.c index 03a36b558..8c7687235 100644 --- a/libs/video/targets/keys.c +++ b/libs/video/targets/keys.c @@ -64,6 +64,7 @@ struct keybind_s keybindings[IMT_LAST][QFK_LAST]; int keydown[QFK_LAST]; static int keyhelp; +static cbuf_t *cbuf; typedef struct { char *name; @@ -386,10 +387,8 @@ Key_Game (knum_t key, short unicode) { const char *kb; char cmd[1024]; - cbuf_t *cbuf; kb = Key_GetBinding(game_target, key); - cbuf = keybindings[game_target][key].cbuf; if (!kb && (game_target > IMT_0)) kb = Key_GetBinding(IMT_0, key); @@ -794,8 +793,10 @@ Key_ClearStates (void) } void -Key_Init (void) +Key_Init (cbuf_t *cb) { + cbuf = cb; + OK_Init (); // register our functions @@ -848,5 +849,4 @@ Key_SetBinding (imt_t target, knum_t keynum, const char *binding) if (binding) { keybindings[target][keynum].str = strdup(binding); } - keybindings[target][keynum].cbuf = cbuf_active; } diff --git a/nq/source/host.c b/nq/source/host.c index cecb9d636..0fa039c57 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -934,7 +934,7 @@ Host_Init (void) NET_Init (); W_LoadWadFile ("gfx.wad"); - Key_Init (); + Key_Init (host_cbuf); Mod_Init (); CL_Demo_Init (); diff --git a/nq/source/sv_ded.c b/nq/source/sv_ded.c index d543a1974..e593a0d9b 100644 --- a/nq/source/sv_ded.c +++ b/nq/source/sv_ded.c @@ -219,7 +219,7 @@ IN_Shutdown (void) } void -Key_Init (void) +Key_Init (struct cbuf_s *cb) { } diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 4272848c8..8c1592309 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -1757,7 +1757,7 @@ Host_Init (void) } W_LoadWadFile ("gfx.wad"); - Key_Init (); + Key_Init (cl_cbuf); Mod_Init (); CL_Demo_Init();