diff --git a/include/QF/quakefs.h b/include/QF/quakefs.h index 761997eea..064193ce9 100644 --- a/include/QF/quakefs.h +++ b/include/QF/quakefs.h @@ -107,6 +107,7 @@ extern int qfs_filesize; struct cache_user_s; struct dstring_s; +struct memhunk_s; /** Initialize the Quake Filesystem. @@ -114,13 +115,14 @@ struct dstring_s; \c fs_dirconf Cvars. It then loads the \ref dirconf and parses the \c -game command line option. + \param hunk Memory pool to use for hunk-based allocations. \param game The game type used for searching the directory configuration. Currently, this is \"qw\" for quakeworld clients and servers, and one of \"nq\", \"hexen\", \"rogue\" or \"abyss\" for the netquake clients and servers. */ -void QFS_Init (const char *game); +void QFS_Init (struct memhunk_s *hunk, const char *game); /** Change the current game directory. diff --git a/libs/audio/test/testsound.c b/libs/audio/test/testsound.c index ce157c067..1af4730c1 100644 --- a/libs/audio/test/testsound.c +++ b/libs/audio/test/testsound.c @@ -68,9 +68,9 @@ init (void) COM_ParseConfig (testsound_cbuf); Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL); - Memory_Init (Sys_Alloc (MEMSIZE), MEMSIZE); + memhunk_t *hunk = Memory_Init (Sys_Alloc (MEMSIZE), MEMSIZE); - QFS_Init ("qw"); + QFS_Init (hunk, "qw"); PI_Init (); S_Init_Cvars (); diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index 34d4988f9..7ca9f8cab 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -122,6 +122,7 @@ int fnmatch (const char *__pattern, const char *__string, int __flags); // QUAKE FILESYSTEM +static memhunk_t *qfs_hunk; static cvar_t *fs_userpath; static cvar_t *fs_sharepath; static cvar_t *fs_dirconf; @@ -1427,10 +1428,12 @@ qfs_shutdown (void *data) } VISIBLE void -QFS_Init (const char *game) +QFS_Init (memhunk_t *hunk, const char *game) { int i; + qfs_hunk = hunk; + fs_sharepath = Cvar_Get ("fs_sharepath", FS_SHAREPATH, CVAR_ROM, qfs_path_cvar, "location of shared (read-only) game " diff --git a/nq/include/game.h b/nq/include/game.h index 44eb7ee19..6cf6a978f 100644 --- a/nq/include/game.h +++ b/nq/include/game.h @@ -158,6 +158,7 @@ extern qboolean isDedicated; extern qboolean standard_quake; extern struct cvar_s *registered; -void Game_Init (void); +struct memhunk_s; +void Game_Init (struct memhunk_s *hunk); #endif // __game_h diff --git a/nq/source/game.c b/nq/source/game.c index 356cbb05b..6fc7c225b 100644 --- a/nq/source/game.c +++ b/nq/source/game.c @@ -72,7 +72,7 @@ Game_CheckRegistered (void) } void -Game_Init (void) +Game_Init (memhunk_t *hunk) { int i; const char *game = "nq"; @@ -89,7 +89,7 @@ Game_Init (void) } else if ((i = COM_CheckParm ("-abyss"))) { game = "abyss"; } - QFS_Init (game); + QFS_Init (hunk, game); registered = Cvar_Get ("registered", "0", CVAR_NONE, NULL, "Is the game the registered version. 1 yes 0 no"); diff --git a/nq/source/host.c b/nq/source/host.c index d4d33e10c..be2b2d232 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -808,7 +808,7 @@ Host_InitVCR (quakeparms_t *parms) } -static void +static memhunk_t * Host_Init_Memory (void) { int mem_parm = COM_CheckParm ("-mem"); @@ -843,9 +843,10 @@ Host_Init_Memory (void) Sys_Error ("Can't allocate %zd", mem_size); Sys_PageIn (mem_base, mem_size); - Memory_Init (mem_base, mem_size); + memhunk_t *hunk = Memory_Init (mem_base, mem_size); Sys_Printf ("%4.1f megabyte heap\n", host_mem_size->value); + return hunk; } static void @@ -887,11 +888,11 @@ Host_Init (void) GIB_Key_Init (); COM_ParseConfig (host_cbuf); - Host_Init_Memory (); + memhunk_t *hunk = Host_Init_Memory (); PI_Init (); - Game_Init (); + Game_Init (hunk); if (!isDedicated) CL_InitCvars (); diff --git a/qtv/source/qtv.c b/qtv/source/qtv.c index d1da80448..e00bbaf31 100644 --- a/qtv/source/qtv.c +++ b/qtv/source/qtv.c @@ -202,7 +202,7 @@ qtv_end_redirect (void) qtv_redirect_client = 0; } -static void +static memhunk_t * qtv_memory_init (void) { int mem_size; @@ -217,7 +217,7 @@ qtv_memory_init (void) mem_base = Sys_Alloc (mem_size); if (!mem_base) Sys_Error ("Can't allocate %d", mem_size); - Memory_Init (mem_base, mem_size); + return Memory_Init (mem_base, mem_size); } static void @@ -258,9 +258,9 @@ qtv_init (void) COM_ParseConfig (qtv_cbuf); Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL); - qtv_memory_init (); + memhunk_t *hunk = qtv_memory_init (); - QFS_Init ("qw"); + QFS_Init (hunk, "qw"); PI_Init (); qtv_console_plugin = Cvar_Get ("qtv_console_plugin", "server", diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index df48b4614..6585ce04f 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -1756,7 +1756,7 @@ Host_Frame (float time) fps_count++; } -static void +static memhunk_t * CL_Init_Memory (void) { int mem_parm = COM_CheckParm ("-mem"); @@ -1786,9 +1786,10 @@ CL_Init_Memory (void) Sys_Error ("Can't allocate %zd", mem_size); Sys_PageIn (mem_base, mem_size); - Memory_Init (mem_base, mem_size); + memhunk_t *hunk = Memory_Init (mem_base, mem_size); Sys_Printf ("%4.1f megabyte heap.\n", cl_mem_size->value); + return hunk; } static void @@ -1822,11 +1823,11 @@ Host_Init (void) GIB_Key_Init (); COM_ParseConfig (cl_cbuf); - CL_Init_Memory (); + memhunk_t *hunk = CL_Init_Memory (); pr_gametype = "quakeworld"; - QFS_Init ("qw"); + QFS_Init (hunk, "qw"); QFS_GamedirCallback (CL_Autoexec); PI_Init (); diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index 0e1904137..915ea58ea 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -2446,7 +2446,7 @@ SV_InitNet (void) sv_net_initialized = 1; } -static void +static memhunk_t * SV_Init_Memory (void) { int mem_parm = COM_CheckParm ("-mem"); @@ -2475,7 +2475,7 @@ SV_Init_Memory (void) if (!mem_base) Sys_Error ("Can't allocate %zd", mem_size); - Memory_Init (mem_base, mem_size); + return Memory_Init (mem_base, mem_size); } void @@ -2495,7 +2495,7 @@ SV_Init (void) // snax: Init experimental object system and run a test //Object_Init(); - SV_Init_Memory (); + memhunk_t *hunk = SV_Init_Memory (); QFS_GamedirCallback (gamedir_f); svs.maxclients = MAX_CLIENTS; @@ -2504,7 +2504,7 @@ SV_Init (void) SV_InitOperatorCommands (); SV_GIB_Init (); - QFS_Init ("qw"); + QFS_Init (hunk, "qw"); PI_Init (); sv_console_plugin = Cvar_Get ("sv_console_plugin", "server", diff --git a/ruamoko/qwaq/builtins/qwaq-bi.c b/ruamoko/qwaq/builtins/qwaq-bi.c index 4353d5c14..8c30dd47c 100644 --- a/ruamoko/qwaq/builtins/qwaq-bi.c +++ b/ruamoko/qwaq/builtins/qwaq-bi.c @@ -151,13 +151,13 @@ bi_shutdown (void *data) } void -BI_Init (progs_t *pr) +BI_Init (memhunk_t *hunk, progs_t *pr) { byte *basepal, *colormap; PR_RegisterBuiltins (pr, builtins); - QFS_Init ("nq"); + QFS_Init (hunk, "nq"); PI_Init (); PI_RegisterPlugins (client_plugin_list); diff --git a/ruamoko/qwaq/builtins/qwaq.c b/ruamoko/qwaq/builtins/qwaq.c index 00a7ca135..b23f1c632 100644 --- a/ruamoko/qwaq/builtins/qwaq.c +++ b/ruamoko/qwaq/builtins/qwaq.c @@ -114,7 +114,8 @@ init_qf (void) //Cvar_Set (developer, "1"); - Memory_Init (Sys_Alloc (8 * 1024 * 1024), 8 * 1024 * 1024); + size_t memsize = 8 * 1024 * 1024; + memhunk_t *hunk = Memory_Init (Sys_Alloc (memsize), memsize); Cvar_Get ("pr_debug", "2", 0, 0, 0); Cvar_Get ("pr_boundscheck", "0", 0, 0, 0); @@ -131,7 +132,7 @@ init_qf (void) PR_Init (&pr); RUA_Init (&pr, 0); PR_Cmds_Init (&pr); - BI_Init (&pr); + BI_Init (hunk, &pr); } static int diff --git a/ruamoko/qwaq/qwaq.h b/ruamoko/qwaq/qwaq.h index 899fb1c51..0a919a0c8 100644 --- a/ruamoko/qwaq/qwaq.h +++ b/ruamoko/qwaq/qwaq.h @@ -23,7 +23,8 @@ typedef struct qwaq_thread_s { typedef struct qwaq_thread_set_s DARRAY_TYPE(qwaq_thread_t *) qwaq_thread_set_t; -void BI_Init (progs_t *pr); +struct memhunk_s; +void BI_Init (struct memhunk_s *hunk, progs_t *pr); void BI_Curses_Init (progs_t *pr); void BI_Input_Init (progs_t *pr); void QWAQ_EditBuffer_Init (progs_t *pr);