From e4f740bf0274eef53f239e0a70b5296522be97ca Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Thu, 9 May 2002 20:12:12 +0000 Subject: [PATCH] Buffers created for embedded commands are now marked with a special flag. This allows Cmd_Return_f to decide which buffer it should return a value to. End result: you can put blocks of code with a return statement inside an embedded command statement. I hope nobody minded me using my quakeforge.net account to code a bit :P --- include/QF/cmd.h | 1 + libs/util/cmd.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/QF/cmd.h b/include/QF/cmd.h index 97a803867..8ab906021 100644 --- a/include/QF/cmd.h +++ b/include/QF/cmd.h @@ -69,6 +69,7 @@ typedef struct cmd_buffer_s { qboolean legacy; // Backwards compatible with old console buffer qboolean ownvars; // Buffer has its own private local variables qboolean loop; // Buffer loops itself + qboolean embedded; // Buffer exists to evaluate embedded command // Execution position enum { diff --git a/libs/util/cmd.c b/libs/util/cmd.c index 085ff0f51..a2554b61c 100644 --- a/libs/util/cmd.c +++ b/libs/util/cmd.c @@ -1265,6 +1265,7 @@ Cmd_ProcessEmbeddedSingle (dstring_t * dstr, int start) } else { command = dstring_newstr (); sub = Cmd_NewBuffer (false); + sub->embedded = true; sub->locals = cmd_activebuffer->locals; dstring_insert (command, dstr->str + start + 2, n - 2, 0); Cbuf_InsertTextTo (sub, command->str); @@ -2038,7 +2039,8 @@ Cmd_Return_f (void) { return; } dstring_clearstr (cmd_activebuffer->buffer); // Clear the buffer out no matter what - cmd_activebuffer = cmd_activebuffer->prev; + if (!cmd_activebuffer->embedded) + cmd_activebuffer = cmd_activebuffer->prev; if (argc == 2) Cmd_Return (val); cmd_activebuffer = old;