[qwaq] Adapt startup code for use in a game engine

Until now, the new qwaq startup was used only in command-line tools and
console applications where things like Ruamoko security and having a
hunk were not an issue. Now the start up code (qwaq-*.c) can specify
that Ruamoko is to be secured and provide a hunk on a per-thread basis,
and the thread data is passed into the progs code via a progs resource.
This commit is contained in:
Bill Currie 2021-12-20 20:13:21 +09:00
parent d3853a2430
commit ad83422c56
4 changed files with 17 additions and 25 deletions

View file

@ -55,7 +55,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$";
#include "QF/sound.h"
#include "QF/sys.h"
#include "QF/vid.h"
#include "QF/zone.h"
#include "QF/plugin/console.h"
#include "QF/plugin/vid_render.h"
@ -137,17 +136,16 @@ bi_shutdown (void *data)
void
BI_Graphics_Init (progs_t *pr)
{
qwaq_thread_t *thread = PR_Resources_Find (pr, "qwaq_thread");
byte *basepal, *colormap;
size_t memsize = 8 * 1024 * 1024;
memhunk_t *hunk = Memory_Init (Sys_Alloc (memsize), memsize);
PR_RegisterBuiltins (pr, builtins);
QFS_Init (hunk, "nq");
QFS_Init (thread->hunk, "nq");
PI_Init ();
PI_RegisterPlugins (client_plugin_list);
Sys_RegisterShutdown (bi_shutdown, 0);
Sys_RegisterShutdown (bi_shutdown, pr);
VID_Init_Cvars ();
IN_Init_Cvars ();

View file

@ -189,6 +189,11 @@ common_builtins_init (progs_t *pr)
PR_RegisterBuiltins (pr, common_builtins);
}
static void
qwaq_thread_clear (progs_t *pr, void *_thread)
{
}
static progs_t *
create_progs (qwaq_thread_t *thread)
{
@ -203,7 +208,8 @@ create_progs (qwaq_thread_t *thread)
PR_Init_Cvars ();
PR_Init (pr);
RUA_Init (pr, 0);
PR_Resources_Register (pr, "qwaq_thread", thread, qwaq_thread_clear);
RUA_Init (pr, thread->rua_security);
common_builtins_init (pr);
while (*funcs) {
(*funcs++) (pr);

View file

@ -33,22 +33,7 @@
#include <string.h>
//#include "QF/cbuf.h"
//#include "QF/cmd.h"
//#include "QF/cvar.h"
//#include "QF/gib.h"
//#include "QF/idparse.h"
#include "QF/input.h"
//#include "QF/keys.h"
//#include "QF/progs.h"
//#include "QF/qargs.h"
//#include "QF/quakefs.h"
//#include "QF/ruamoko.h"
//#include "QF/sys.h"
//#include "QF/va.h"
//#include "QF/zone.h"
//#include "compat.h"
#include "QF/zone.h"
#include "ruamoko/qwaq/qwaq.h"
@ -74,13 +59,12 @@ int
qwaq_init_threads (qwaq_thread_set_t *thread_data)
{
int main_ind = -1;
size_t memsize = 8 * 1024 * 1024;
memhunk_t *hunk = Memory_Init (Sys_Alloc (memsize), memsize);
logfile = fopen ("qwaq-graphics.log", "wt");
Sys_SetStdPrintf (qwaq_print);
IN_Init_Cvars ();
//IN_Init ();
for (size_t i = 1, thread_ind = 0; i < thread_data->size; i++) {
qwaq_thread_t *thread = thread_data->a[i];
progsinit_f *app_funcs = 0;//secondary_app;
@ -101,6 +85,8 @@ qwaq_init_threads (qwaq_thread_set_t *thread_data)
app_funcs = main_app;
}
thread->progsinit = app_funcs;
thread->rua_security = 1;
thread->hunk = hunk; //FIXME shared (but currently only one thread)
}
return main_ind;
}

View file

@ -16,6 +16,8 @@ typedef struct qwaq_thread_s {
sys_printf_t sys_printf;
progsinit_f*progsinit;
progs_t *pr;
int rua_security;
struct memhunk_s *hunk;
struct hashlink_s *hashlink_freelist;
func_t main_func;
void *data;