mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-29 07:32:02 +00:00
[quakefs] Take in the pointer to the global hunk
This is needed for cleaning up excess memsets when loading files because Hunk_RawAllocName has nonnull on its hunk pointer (as the rest of the hunk functions really should, but not just yet).
This commit is contained in:
parent
39c020908c
commit
2086125e0b
12 changed files with 38 additions and 28 deletions
|
@ -107,6 +107,7 @@ extern int qfs_filesize;
|
||||||
|
|
||||||
struct cache_user_s;
|
struct cache_user_s;
|
||||||
struct dstring_s;
|
struct dstring_s;
|
||||||
|
struct memhunk_s;
|
||||||
|
|
||||||
/** Initialize the Quake Filesystem.
|
/** 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 fs_dirconf Cvars. It then loads the \ref dirconf and parses the
|
||||||
\c -game command line option.
|
\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
|
\param game The game type used for searching the directory
|
||||||
configuration. Currently, this is \"qw\" for
|
configuration. Currently, this is \"qw\" for
|
||||||
quakeworld clients and servers, and one of \"nq\",
|
quakeworld clients and servers, and one of \"nq\",
|
||||||
\"hexen\", \"rogue\" or \"abyss\" for the netquake
|
\"hexen\", \"rogue\" or \"abyss\" for the netquake
|
||||||
clients and servers.
|
clients and servers.
|
||||||
*/
|
*/
|
||||||
void QFS_Init (const char *game);
|
void QFS_Init (struct memhunk_s *hunk, const char *game);
|
||||||
|
|
||||||
/** Change the current game directory.
|
/** Change the current game directory.
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,9 @@ init (void)
|
||||||
COM_ParseConfig (testsound_cbuf);
|
COM_ParseConfig (testsound_cbuf);
|
||||||
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
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 ();
|
PI_Init ();
|
||||||
|
|
||||||
S_Init_Cvars ();
|
S_Init_Cvars ();
|
||||||
|
|
|
@ -122,6 +122,7 @@ int fnmatch (const char *__pattern, const char *__string, int __flags);
|
||||||
|
|
||||||
// QUAKE FILESYSTEM
|
// QUAKE FILESYSTEM
|
||||||
|
|
||||||
|
static memhunk_t *qfs_hunk;
|
||||||
static cvar_t *fs_userpath;
|
static cvar_t *fs_userpath;
|
||||||
static cvar_t *fs_sharepath;
|
static cvar_t *fs_sharepath;
|
||||||
static cvar_t *fs_dirconf;
|
static cvar_t *fs_dirconf;
|
||||||
|
@ -1427,10 +1428,12 @@ qfs_shutdown (void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE void
|
VISIBLE void
|
||||||
QFS_Init (const char *game)
|
QFS_Init (memhunk_t *hunk, const char *game)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
qfs_hunk = hunk;
|
||||||
|
|
||||||
fs_sharepath = Cvar_Get ("fs_sharepath", FS_SHAREPATH, CVAR_ROM,
|
fs_sharepath = Cvar_Get ("fs_sharepath", FS_SHAREPATH, CVAR_ROM,
|
||||||
qfs_path_cvar,
|
qfs_path_cvar,
|
||||||
"location of shared (read-only) game "
|
"location of shared (read-only) game "
|
||||||
|
|
|
@ -158,6 +158,7 @@ extern qboolean isDedicated;
|
||||||
extern qboolean standard_quake;
|
extern qboolean standard_quake;
|
||||||
extern struct cvar_s *registered;
|
extern struct cvar_s *registered;
|
||||||
|
|
||||||
void Game_Init (void);
|
struct memhunk_s;
|
||||||
|
void Game_Init (struct memhunk_s *hunk);
|
||||||
|
|
||||||
#endif // __game_h
|
#endif // __game_h
|
||||||
|
|
|
@ -72,7 +72,7 @@ Game_CheckRegistered (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Game_Init (void)
|
Game_Init (memhunk_t *hunk)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char *game = "nq";
|
const char *game = "nq";
|
||||||
|
@ -89,7 +89,7 @@ Game_Init (void)
|
||||||
} else if ((i = COM_CheckParm ("-abyss"))) {
|
} else if ((i = COM_CheckParm ("-abyss"))) {
|
||||||
game = "abyss";
|
game = "abyss";
|
||||||
}
|
}
|
||||||
QFS_Init (game);
|
QFS_Init (hunk, game);
|
||||||
|
|
||||||
registered = Cvar_Get ("registered", "0", CVAR_NONE, NULL,
|
registered = Cvar_Get ("registered", "0", CVAR_NONE, NULL,
|
||||||
"Is the game the registered version. 1 yes 0 no");
|
"Is the game the registered version. 1 yes 0 no");
|
||||||
|
|
|
@ -808,7 +808,7 @@ Host_InitVCR (quakeparms_t *parms)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static memhunk_t *
|
||||||
Host_Init_Memory (void)
|
Host_Init_Memory (void)
|
||||||
{
|
{
|
||||||
int mem_parm = COM_CheckParm ("-mem");
|
int mem_parm = COM_CheckParm ("-mem");
|
||||||
|
@ -843,9 +843,10 @@ Host_Init_Memory (void)
|
||||||
Sys_Error ("Can't allocate %zd", mem_size);
|
Sys_Error ("Can't allocate %zd", mem_size);
|
||||||
|
|
||||||
Sys_PageIn (mem_base, 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);
|
Sys_Printf ("%4.1f megabyte heap\n", host_mem_size->value);
|
||||||
|
return hunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -887,11 +888,11 @@ Host_Init (void)
|
||||||
GIB_Key_Init ();
|
GIB_Key_Init ();
|
||||||
COM_ParseConfig (host_cbuf);
|
COM_ParseConfig (host_cbuf);
|
||||||
|
|
||||||
Host_Init_Memory ();
|
memhunk_t *hunk = Host_Init_Memory ();
|
||||||
|
|
||||||
PI_Init ();
|
PI_Init ();
|
||||||
|
|
||||||
Game_Init ();
|
Game_Init (hunk);
|
||||||
|
|
||||||
if (!isDedicated)
|
if (!isDedicated)
|
||||||
CL_InitCvars ();
|
CL_InitCvars ();
|
||||||
|
|
|
@ -202,7 +202,7 @@ qtv_end_redirect (void)
|
||||||
qtv_redirect_client = 0;
|
qtv_redirect_client = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static memhunk_t *
|
||||||
qtv_memory_init (void)
|
qtv_memory_init (void)
|
||||||
{
|
{
|
||||||
int mem_size;
|
int mem_size;
|
||||||
|
@ -217,7 +217,7 @@ qtv_memory_init (void)
|
||||||
mem_base = Sys_Alloc (mem_size);
|
mem_base = Sys_Alloc (mem_size);
|
||||||
if (!mem_base)
|
if (!mem_base)
|
||||||
Sys_Error ("Can't allocate %d", mem_size);
|
Sys_Error ("Can't allocate %d", mem_size);
|
||||||
Memory_Init (mem_base, mem_size);
|
return Memory_Init (mem_base, mem_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -258,9 +258,9 @@ qtv_init (void)
|
||||||
COM_ParseConfig (qtv_cbuf);
|
COM_ParseConfig (qtv_cbuf);
|
||||||
Cvar_Get ("cmd_warncmd", "1", CVAR_NONE, NULL, NULL);
|
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 ();
|
PI_Init ();
|
||||||
|
|
||||||
qtv_console_plugin = Cvar_Get ("qtv_console_plugin", "server",
|
qtv_console_plugin = Cvar_Get ("qtv_console_plugin", "server",
|
||||||
|
|
|
@ -1756,7 +1756,7 @@ Host_Frame (float time)
|
||||||
fps_count++;
|
fps_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static memhunk_t *
|
||||||
CL_Init_Memory (void)
|
CL_Init_Memory (void)
|
||||||
{
|
{
|
||||||
int mem_parm = COM_CheckParm ("-mem");
|
int mem_parm = COM_CheckParm ("-mem");
|
||||||
|
@ -1786,9 +1786,10 @@ CL_Init_Memory (void)
|
||||||
Sys_Error ("Can't allocate %zd", mem_size);
|
Sys_Error ("Can't allocate %zd", mem_size);
|
||||||
|
|
||||||
Sys_PageIn (mem_base, 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);
|
Sys_Printf ("%4.1f megabyte heap.\n", cl_mem_size->value);
|
||||||
|
return hunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1822,11 +1823,11 @@ Host_Init (void)
|
||||||
GIB_Key_Init ();
|
GIB_Key_Init ();
|
||||||
COM_ParseConfig (cl_cbuf);
|
COM_ParseConfig (cl_cbuf);
|
||||||
|
|
||||||
CL_Init_Memory ();
|
memhunk_t *hunk = CL_Init_Memory ();
|
||||||
|
|
||||||
pr_gametype = "quakeworld";
|
pr_gametype = "quakeworld";
|
||||||
|
|
||||||
QFS_Init ("qw");
|
QFS_Init (hunk, "qw");
|
||||||
QFS_GamedirCallback (CL_Autoexec);
|
QFS_GamedirCallback (CL_Autoexec);
|
||||||
PI_Init ();
|
PI_Init ();
|
||||||
|
|
||||||
|
|
|
@ -2446,7 +2446,7 @@ SV_InitNet (void)
|
||||||
sv_net_initialized = 1;
|
sv_net_initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static memhunk_t *
|
||||||
SV_Init_Memory (void)
|
SV_Init_Memory (void)
|
||||||
{
|
{
|
||||||
int mem_parm = COM_CheckParm ("-mem");
|
int mem_parm = COM_CheckParm ("-mem");
|
||||||
|
@ -2475,7 +2475,7 @@ SV_Init_Memory (void)
|
||||||
if (!mem_base)
|
if (!mem_base)
|
||||||
Sys_Error ("Can't allocate %zd", mem_size);
|
Sys_Error ("Can't allocate %zd", mem_size);
|
||||||
|
|
||||||
Memory_Init (mem_base, mem_size);
|
return Memory_Init (mem_base, mem_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2495,7 +2495,7 @@ SV_Init (void)
|
||||||
// snax: Init experimental object system and run a test
|
// snax: Init experimental object system and run a test
|
||||||
//Object_Init();
|
//Object_Init();
|
||||||
|
|
||||||
SV_Init_Memory ();
|
memhunk_t *hunk = SV_Init_Memory ();
|
||||||
|
|
||||||
QFS_GamedirCallback (gamedir_f);
|
QFS_GamedirCallback (gamedir_f);
|
||||||
svs.maxclients = MAX_CLIENTS;
|
svs.maxclients = MAX_CLIENTS;
|
||||||
|
@ -2504,7 +2504,7 @@ SV_Init (void)
|
||||||
SV_InitOperatorCommands ();
|
SV_InitOperatorCommands ();
|
||||||
SV_GIB_Init ();
|
SV_GIB_Init ();
|
||||||
|
|
||||||
QFS_Init ("qw");
|
QFS_Init (hunk, "qw");
|
||||||
PI_Init ();
|
PI_Init ();
|
||||||
|
|
||||||
sv_console_plugin = Cvar_Get ("sv_console_plugin", "server",
|
sv_console_plugin = Cvar_Get ("sv_console_plugin", "server",
|
||||||
|
|
|
@ -151,13 +151,13 @@ bi_shutdown (void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BI_Init (progs_t *pr)
|
BI_Init (memhunk_t *hunk, progs_t *pr)
|
||||||
{
|
{
|
||||||
byte *basepal, *colormap;
|
byte *basepal, *colormap;
|
||||||
|
|
||||||
PR_RegisterBuiltins (pr, builtins);
|
PR_RegisterBuiltins (pr, builtins);
|
||||||
|
|
||||||
QFS_Init ("nq");
|
QFS_Init (hunk, "nq");
|
||||||
PI_Init ();
|
PI_Init ();
|
||||||
PI_RegisterPlugins (client_plugin_list);
|
PI_RegisterPlugins (client_plugin_list);
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,8 @@ init_qf (void)
|
||||||
|
|
||||||
//Cvar_Set (developer, "1");
|
//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_debug", "2", 0, 0, 0);
|
||||||
Cvar_Get ("pr_boundscheck", "0", 0, 0, 0);
|
Cvar_Get ("pr_boundscheck", "0", 0, 0, 0);
|
||||||
|
@ -131,7 +132,7 @@ init_qf (void)
|
||||||
PR_Init (&pr);
|
PR_Init (&pr);
|
||||||
RUA_Init (&pr, 0);
|
RUA_Init (&pr, 0);
|
||||||
PR_Cmds_Init (&pr);
|
PR_Cmds_Init (&pr);
|
||||||
BI_Init (&pr);
|
BI_Init (hunk, &pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -23,7 +23,8 @@ typedef struct qwaq_thread_s {
|
||||||
|
|
||||||
typedef struct qwaq_thread_set_s DARRAY_TYPE(qwaq_thread_t *) qwaq_thread_set_t;
|
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_Curses_Init (progs_t *pr);
|
||||||
void BI_Input_Init (progs_t *pr);
|
void BI_Input_Init (progs_t *pr);
|
||||||
void QWAQ_EditBuffer_Init (progs_t *pr);
|
void QWAQ_EditBuffer_Init (progs_t *pr);
|
||||||
|
|
Loading…
Reference in a new issue