mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
Add print and print.center GIB commands and fix a nasty bug with threads
that could cause a double free.
This commit is contained in:
parent
a0f49816e5
commit
9c4f2d32ca
2 changed files with 34 additions and 1 deletions
|
@ -55,6 +55,7 @@ static const char rcsid[] =
|
|||
#include "QF/sys.h"
|
||||
#include "QF/va.h"
|
||||
#include "QF/vid.h"
|
||||
#include "QF/gib_builtin.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
|
@ -339,6 +340,19 @@ C_SayTeam (const char *line)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
C_GIB_Print_Center_f (void)
|
||||
{
|
||||
if (GIB_Argc () != 2) {
|
||||
Cbuf_Error ("syntax",
|
||||
"print.center: invalid syntax\n"
|
||||
"usage: print.center text");
|
||||
return;
|
||||
}
|
||||
SCR_CenterPrint (GIB_Argv(1));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
C_Init (void)
|
||||
{
|
||||
|
@ -393,6 +407,10 @@ C_Init (void)
|
|||
Cmd_AddCommand ("clear", Clear_f, "Clear the console");
|
||||
Cmd_AddCommand ("condump", Condump_f, "dump the console text to a "
|
||||
"file");
|
||||
|
||||
// register GIB builtins
|
||||
GIB_Builtin_Add ("print.center", C_GIB_Print_Center_f, GIB_BUILTIN_NORMAL);
|
||||
|
||||
con_initialized = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -477,7 +477,9 @@ GIB_Thread_Kill_f (void)
|
|||
return;
|
||||
}
|
||||
for (cur = thread->cbuf; cur; cur = cur->down) {
|
||||
GIB_DATA(cur)->type = GIB_BUFFER_NORMAL;
|
||||
// Kill all loops
|
||||
if (GIB_DATA(cur)->type == GIB_BUFFER_LOOP)
|
||||
GIB_DATA(cur)->type = GIB_BUFFER_PROXY; // Proxy to prevent shared locals being freed
|
||||
dstring_clearstr (cur->line);
|
||||
dstring_clearstr (cur->buf);
|
||||
}
|
||||
|
@ -660,6 +662,18 @@ GIB_Range_f (void)
|
|||
dstring_delete (dstr);
|
||||
}
|
||||
|
||||
void
|
||||
GIB_Print_f (void)
|
||||
{
|
||||
if (GIB_Argc() != 2) {
|
||||
Cbuf_Error ("syntax",
|
||||
"print: invalid syntax\n"
|
||||
"usage: print text");
|
||||
return;
|
||||
}
|
||||
Sys_Printf ("%s", GIB_Argv(1));
|
||||
}
|
||||
|
||||
void
|
||||
GIB_Builtin_Init (void)
|
||||
{
|
||||
|
@ -685,4 +699,5 @@ GIB_Builtin_Init (void)
|
|||
GIB_Builtin_Add ("file.write", GIB_File_Write_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("file.find", GIB_File_Find_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("range", GIB_Range_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("print", GIB_Print_f, GIB_BUILTIN_NORMAL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue