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
This commit is contained in:
Brian Koropoff 2002-05-09 20:12:12 +00:00
parent 55e54bd9f9
commit e4f740bf02
2 changed files with 4 additions and 1 deletions

View file

@ -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 {

View file

@ -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;