mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-30 12:40:42 +00:00
Fixed Cmd_If_f so that embedded commands work again.
This commit is contained in:
parent
1f468e2508
commit
7121891895
2 changed files with 11 additions and 4 deletions
|
@ -63,6 +63,7 @@ typedef struct cmd_buffer_s {
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
qboolean subroutine; // Temporarily stopped so a subroutine can run
|
qboolean subroutine; // Temporarily stopped so a subroutine can run
|
||||||
|
qboolean again; // The last command needs to be executed again for some reason
|
||||||
qboolean wait; // Execution paused until next frame
|
qboolean wait; // Execution paused until next frame
|
||||||
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
|
||||||
|
|
|
@ -459,6 +459,7 @@ Cbuf_ExecuteBuffer (cmd_buffer_t *buffer)
|
||||||
|
|
||||||
cmd_activebuffer = buffer;
|
cmd_activebuffer = buffer;
|
||||||
buffer->wait = false;
|
buffer->wait = false;
|
||||||
|
buffer->again = false;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (!strlen(buffer->buffer->str) && buffer->position == cmd_ready) {
|
if (!strlen(buffer->buffer->str) && buffer->position == cmd_ready) {
|
||||||
if (buffer->loop) {
|
if (buffer->loop) {
|
||||||
|
@ -489,7 +490,7 @@ Cbuf_ExecuteBuffer (cmd_buffer_t *buffer)
|
||||||
}
|
}
|
||||||
if (buffer->position == cmd_processed) {
|
if (buffer->position == cmd_processed) {
|
||||||
Cmd_ExecuteParsed (src_command);
|
Cmd_ExecuteParsed (src_command);
|
||||||
if (cmd_error)
|
if (cmd_error || buffer->again)
|
||||||
break;
|
break;
|
||||||
buffer->position = cmd_ready;
|
buffer->position = cmd_ready;
|
||||||
if (buffer->wait || buffer->subroutine)
|
if (buffer->wait || buffer->subroutine)
|
||||||
|
@ -1334,6 +1335,7 @@ Cmd_ProcessToken (cmd_token_t *token)
|
||||||
return res;
|
return res;
|
||||||
Cmd_ProcessTags (token->processed);
|
Cmd_ProcessTags (token->processed);
|
||||||
Cmd_ProcessEscapes (token->processed);
|
Cmd_ProcessEscapes (token->processed);
|
||||||
|
token->state = cmd_done;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1360,7 +1362,7 @@ Cmd_Process (void)
|
||||||
res = Cmd_ProcessToken (cmd_activebuffer->argv[arg]);
|
res = Cmd_ProcessToken (cmd_activebuffer->argv[arg]);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return res;
|
return res;
|
||||||
cmd_activebuffer->argv[arg]->state = cmd_done;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1900,6 +1902,7 @@ void
|
||||||
Cmd_If_f (void)
|
Cmd_If_f (void)
|
||||||
{
|
{
|
||||||
long int num;
|
long int num;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if ((Cmd_Argc () !=3 && !(Cmd_Argc () >= 5)) || (Cmd_Argc () > 5 && strcmp(Cmd_Argv(3),"else"))) {
|
if ((Cmd_Argc () !=3 && !(Cmd_Argc () >= 5)) || (Cmd_Argc () > 5 && strcmp(Cmd_Argv(3),"else"))) {
|
||||||
Sys_Printf ("Usage: if {condition} {commands} else {commands}\n");
|
Sys_Printf ("Usage: if {condition} {commands} else {commands}\n");
|
||||||
|
@ -1912,9 +1915,12 @@ Cmd_If_f (void)
|
||||||
of sync, but since if uses Cmd_Argsu (4) and no other commands
|
of sync, but since if uses Cmd_Argsu (4) and no other commands
|
||||||
will need these tokens, it is safe.
|
will need these tokens, it is safe.
|
||||||
*/
|
*/
|
||||||
if (Cmd_ProcessToken (cmd_activebuffer->argv[1]) < 0)
|
ret = Cmd_ProcessToken (cmd_activebuffer->argv[1]);
|
||||||
|
if (ret < 0) {
|
||||||
|
if (ret == -2)
|
||||||
|
cmd_activebuffer->again = true; // Embedded command needs a return value first
|
||||||
return;
|
return;
|
||||||
cmd_activebuffer->argv[1]->state = cmd_done;
|
}
|
||||||
|
|
||||||
num = strtol (Cmd_Argv(1), 0, 10);
|
num = strtol (Cmd_Argv(1), 0, 10);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue