From 714f2ced4c41702ed38e90799b35343ef6cafe89 Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Sun, 1 Dec 2002 07:22:42 +0000 Subject: [PATCH] Fixed several GIB bugs, optimized Cbuf_Execute_Stack a bit, changed QW clients to use a separate buffer for stufftext commands. --- libs/gib/gib_builtin.c | 11 +++++------ libs/util/cbuf.c | 4 +++- qw/include/client.h | 2 +- qw/source/cl_main.c | 3 +++ qw/source/cl_parse.c | 6 +++--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libs/gib/gib_builtin.c b/libs/gib/gib_builtin.c index 92ef22e91..1677851f0 100644 --- a/libs/gib/gib_builtin.c +++ b/libs/gib/gib_builtin.c @@ -236,9 +236,10 @@ GIB_Return_f (void) if (GIB_Argc () == 1) return; if (!sp->up || // Nothing above us on the stack - GIB_DATA(sp->up)->type != GIB_BUFFER_PROXY || // No proxy buffer created + sp->up->interpreter != &gib_interp || // Not a GIB buffer + GIB_DATA(sp->up)->type != GIB_BUFFER_PROXY || // Not a proxy buffer !sp->up->up || // Nothing above proxy buffer on the stack - sp->up->up->interpreter != &gib_interp || // Not a GIB buffer + sp->up->up->interpreter != &gib_interp || // Not a GIB buffer to return to !GIB_DATA(sp->up->up)->ret.waiting) // Buffer doesn't want a return value Sys_Printf("Warning: unwanted return value discarded.\n"); // Not a serious error else { @@ -395,9 +396,7 @@ GIB_For_f (void) ifs = " \n\r\t"; dstring_append (GIB_DATA(sub)->loop_data, ifs, strlen(ifs)+1); // Store pointers to data - ll = GIB_DATA(sub)->loop_data->str; - while (isspace ((byte) *ll)) - ll++; + for (ll = GIB_DATA(sub)->loop_data->str; *ll && strchr (ifs, *ll); ll++); GIB_DATA(sub)->loop_list_p = ll; // List to iterate through GIB_DATA(sub)->loop_var_p = GIB_DATA(sub)->loop_data->str + strlen(GIB_Argv(3))+1; // Var to use GIB_DATA(sub)->loop_ifs_p = GIB_DATA(sub)->loop_var_p + strlen(GIB_Argv(1))+1; // Internal field separator @@ -599,7 +598,7 @@ GIB_Thread_Kill_f (void) unsigned long int id = strtoul (GIB_Argv(1), 0, 10); thread = GIB_Thread_Find (id); if (!thread) { - Cbuf_Error ("thread", "thread.kill: thread %ul does not exist.", id); + Cbuf_Error ("thread", "thread.kill: thread %lu does not exist.", id); return; } for (cur = thread->cbuf; cur; cur = cur->down) { diff --git a/libs/util/cbuf.c b/libs/util/cbuf.c index 5e73641f6..8eed7aa26 100644 --- a/libs/util/cbuf.c +++ b/libs/util/cbuf.c @@ -184,12 +184,14 @@ Cbuf_Execute_Stack (cbuf_t *cbuf) sp = sp->down; continue; } else if (sp->state == CBUF_STATE_ERROR) - break; + goto ERROR; else return; } sp = sp->up; } + return; +ERROR: dstring_clearstr (cbuf->buf); dstring_clearstr (cbuf->line); if (cbuf->down) { diff --git a/qw/include/client.h b/qw/include/client.h index 12f666f66..aa49e036e 100644 --- a/qw/include/client.h +++ b/qw/include/client.h @@ -348,7 +348,7 @@ extern char *server_version; // version of server we connected to extern double realtime; extern struct cbuf_s *cl_cbuf; - +extern struct cbuf_s *cl_stbuf; void Cvar_Info (struct cvar_s *var); diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 819582f43..1c0daf8d0 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -119,6 +119,7 @@ static plugin_list_t client_plugin_list[] = { qboolean noclip_anglehack; // remnant from old quake cbuf_t *cl_cbuf; +cbuf_t *cl_stbuf; cvar_t *fs_globalcfg; cvar_t *fs_usercfg; @@ -1515,6 +1516,7 @@ Host_Frame (float time) // process console commands Cbuf_Execute_Stack (cl_cbuf); + Cbuf_Execute_Stack (cl_stbuf); // fetch results from server CL_ReadPackets (); @@ -1657,6 +1659,7 @@ void Host_Init (void) { cl_cbuf = Cbuf_New (&id_interp); + cl_stbuf = Cbuf_New (&id_interp); Cvar_Init_Hash (); Cmd_Init_Hash (); diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index f658d4686..4ab5117bb 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -1305,12 +1305,12 @@ CL_ParseServerMessage (void) if (s[strlen (s) - 1] == '\n') { if (stuffbuf && stuffbuf->str[0]) { Con_DPrintf ("stufftext: %s%s\n", stuffbuf->str, s); - Cbuf_AddText (cl_cbuf, stuffbuf->str); + Cbuf_AddText (cl_stbuf, stuffbuf->str); dstring_clearstr (stuffbuf); } else { Con_DPrintf ("stufftext: %s\n", s); } - Cbuf_AddText (cl_cbuf, s); + Cbuf_AddText (cl_stbuf, s); } else { Con_DPrintf ("partial stufftext: %s\n", s); if (!stuffbuf) @@ -1325,7 +1325,7 @@ CL_ParseServerMessage (void) case svc_serverdata: // make sure any stuffed commands are done - Cbuf_Execute (cl_cbuf); + Cbuf_Execute_Stack (cl_stbuf); CL_ParseServerData (); vid.recalc_refdef = true; // leave full screen intermission break;