From 592b054f827901ffe6d25c2d27188b23ca64d81e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 20 Feb 2000 04:20:00 +0000 Subject: [PATCH] common/gl_vidglx.c: some tweeks in an attempt to improve shutdown. NOT the final say qw_server/sv_ccmds.c: comment correction common/quakefs.c uquake/host_cmd.c: knghtbrd's gamedir patch, plus some Hunk_Alloc -> Z_Malloc changes. --- common/gl_vidglx.c | 14 +++++++++----- common/quakefs.c | 12 ++++++++++-- qw_server/sv_ccmds.c | 1 - uquake/host_cmd.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/common/gl_vidglx.c b/common/gl_vidglx.c index 6cab736..6523fb3 100644 --- a/common/gl_vidglx.c +++ b/common/gl_vidglx.c @@ -141,10 +141,12 @@ void D_EndDirectRect (int x, int y, int width, int height) void VID_Shutdown(void) { - if (!ctx) return; + Con_Printf("VID_Shutdown\n"); - glXDestroyContext(x_disp, ctx); - ctx = NULL; + if (x_disp && ctx) { + glXDestroyContext(x_disp, ctx); + ctx = NULL; + } #ifdef HAS_DGA if (hasvidmode) { int i; @@ -162,8 +164,10 @@ VID_Shutdown(void) } #endif - XCloseDisplay(x_disp); - x_disp = NULL; + if (x_disp) { + XCloseDisplay(x_disp); + x_disp = NULL; + } } diff --git a/common/quakefs.c b/common/quakefs.c index f9f9508..f1bd0c8 100644 --- a/common/quakefs.c +++ b/common/quakefs.c @@ -689,7 +689,7 @@ COM_LoadGameDirectory(char *dir) if( !pak ) { done = true; } else { - search = Hunk_Alloc (sizeof(searchpath_t)); + search = Z_Malloc (sizeof(searchpath_t)); search->pack = pak; search->next = com_searchpaths; com_searchpaths = search; @@ -737,7 +737,7 @@ void COM_AddGameDirectory (char *dir) // // add the directory to the search path // - search = Hunk_Alloc (sizeof(searchpath_t)); + search = Z_Malloc (sizeof(searchpath_t)); strcpy (search->filename, dir); search->next = com_searchpaths; com_searchpaths = search; @@ -802,10 +802,18 @@ void COM_Gamedir (char *dir) // // add the directory to the search path // +#if 1 + //search = Hunk_Alloc (sizeof(searchpath_t)); + search = Z_Malloc (sizeof(searchpath_t)); + strcpy (search->filename, dir); + search->next = com_searchpaths; + com_searchpaths = search; +#else search = Z_Malloc (sizeof(searchpath_t)); strcpy (search->filename, com_gamedir); search->next = com_searchpaths; com_searchpaths = search; +#endif // // add any pak files in the format pak0.pak pak1.pak, ... diff --git a/qw_server/sv_ccmds.c b/qw_server/sv_ccmds.c index 630ef5c..925fedd 100644 --- a/qw_server/sv_ccmds.c +++ b/qw_server/sv_ccmds.c @@ -685,7 +685,6 @@ void SV_Gamedir (void) ================ SV_Floodport_f -Sets the gamedir and path to a different directory. ================ */ diff --git a/uquake/host_cmd.c b/uquake/host_cmd.c index 67acfad..0c39b65 100644 --- a/uquake/host_cmd.c +++ b/uquake/host_cmd.c @@ -192,6 +192,43 @@ void Host_Noclip_f (void) } } +/* +================ +Host_Gamedir_f + +Sets the gamedir and path to a different directory. +================ +*/ +char gamedirfile[MAX_OSPATH]; +void +Host_Gamedir_f (void) +{ + char *dir; + + if (Cmd_Argc() == 1) + { + Con_Printf ("Current gamedir: %s\n", com_gamedir); + return; + } + + if (Cmd_Argc() != 2) + { + Con_Printf ("Usage: gamedir \n"); + return; + } + + dir = Cmd_Argv(1); + + if (strstr(dir, "..") || strstr(dir, "/") + || strstr(dir, "\\") || strstr(dir, ":") ) + { + Con_Printf ("Gamedir should be a single filename, not a path\n"); + return; + } + + COM_Gamedir (dir); +} + /* ================== Host_Fly_f @@ -1917,4 +1954,5 @@ void Host_InitCommands (void) Cmd_AddCommand ("viewprev", Host_Viewprev_f); Cmd_AddCommand ("mcache", Mod_Print); + Cmd_AddCommand ("gamedir", Host_Gamedir_f); }