mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-29 20:20:43 +00:00
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:
parent
55e54bd9f9
commit
e4f740bf02
2 changed files with 4 additions and 1 deletions
|
@ -69,6 +69,7 @@ typedef struct cmd_buffer_s {
|
||||||
qboolean legacy; // Backwards compatible with old console buffer
|
qboolean legacy; // Backwards compatible with old console buffer
|
||||||
qboolean ownvars; // Buffer has its own private local variables
|
qboolean ownvars; // Buffer has its own private local variables
|
||||||
qboolean loop; // Buffer loops itself
|
qboolean loop; // Buffer loops itself
|
||||||
|
qboolean embedded; // Buffer exists to evaluate embedded command
|
||||||
|
|
||||||
// Execution position
|
// Execution position
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -1265,6 +1265,7 @@ Cmd_ProcessEmbeddedSingle (dstring_t * dstr, int start)
|
||||||
} else {
|
} else {
|
||||||
command = dstring_newstr ();
|
command = dstring_newstr ();
|
||||||
sub = Cmd_NewBuffer (false);
|
sub = Cmd_NewBuffer (false);
|
||||||
|
sub->embedded = true;
|
||||||
sub->locals = cmd_activebuffer->locals;
|
sub->locals = cmd_activebuffer->locals;
|
||||||
dstring_insert (command, dstr->str + start + 2, n - 2, 0);
|
dstring_insert (command, dstr->str + start + 2, n - 2, 0);
|
||||||
Cbuf_InsertTextTo (sub, command->str);
|
Cbuf_InsertTextTo (sub, command->str);
|
||||||
|
@ -2038,7 +2039,8 @@ Cmd_Return_f (void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dstring_clearstr (cmd_activebuffer->buffer); // Clear the buffer out no matter what
|
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)
|
if (argc == 2)
|
||||||
Cmd_Return (val);
|
Cmd_Return (val);
|
||||||
cmd_activebuffer = old;
|
cmd_activebuffer = old;
|
||||||
|
|
Loading…
Reference in a new issue