From cf893a192109d0c421a69415ae7dfb584e31abe2 Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 7 Aug 2013 14:13:18 +0000 Subject: [PATCH] minor tweaks. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4455 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/fs.c | 18 ++++++++++++++---- engine/common/plugin.c | 17 ++++++++++++----- engine/shaders/glsl/defaultwall.glsl | 2 ++ plugins/berkelium/plugapi.cpp | 8 +++++--- plugins/engine.h | 2 ++ 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/engine/common/fs.c b/engine/common/fs.c index 880c9c951..27a7a9e2f 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -215,6 +215,8 @@ static ftemanifest_t *FS_Manifest_Clone(ftemanifest_t *oldm) newm->formalname = Z_StrDup(oldm->formalname); if (oldm->protocolname) newm->protocolname = Z_StrDup(oldm->protocolname); + if (oldm->defaultexec) + newm->defaultexec = Z_StrDup(oldm->defaultexec); for (i = 0; i < sizeof(newm->gamepath) / sizeof(newm->gamepath[0]); i++) { @@ -236,15 +238,18 @@ static ftemanifest_t *FS_Manifest_Clone(ftemanifest_t *oldm) void FS_Manifest_Print(ftemanifest_t *man) { + char buffer[1024]; int i, j; if (man->updateurl) - Con_Printf("updateurl \"%s\"\n", man->updateurl); + Con_Printf("updateurl \"%s\"\n", COM_QuotedString(man->updateurl, buffer, sizeof(buffer))); if (man->installation) - Con_Printf("game \"%s\"\n", man->installation); + Con_Printf("game \"%s\"\n", COM_QuotedString(man->installation, buffer, sizeof(buffer))); if (man->formalname) - Con_Printf("name \"%s\"\n", man->formalname); + Con_Printf("name \"%s\"\n", COM_QuotedString(man->formalname, buffer, sizeof(buffer))); if (man->protocolname) - Con_Printf("protocolname \"%s\"\n", man->protocolname); + Con_Printf("protocolname \"%s\"\n", COM_QuotedString(man->protocolname, buffer, sizeof(buffer))); + if (man->defaultexec) + Con_Printf("defaultexec %s\n", COM_QuotedString(man->defaultexec, buffer, sizeof(buffer))); for (i = 0; i < sizeof(man->gamepath) / sizeof(man->gamepath[0]); i++) { @@ -322,6 +327,11 @@ static void FS_Manifest_ParseTokens(ftemanifest_t *man) Z_Free(man->protocolname); man->protocolname = Z_StrDup(Cmd_Argv(1)); } + else if (!stricmp(fname, "defaultexec")) + { + Z_Free(man->defaultexec); + man->defaultexec = Z_StrDup(Cmd_Argv(1)); + } else if (!stricmp(fname, "basegame") || !stricmp(fname, "gamedir")) { int i; diff --git a/engine/common/plugin.c b/engine/common/plugin.c index db632e220..3538ce08b 100644 --- a/engine/common/plugin.c +++ b/engine/common/plugin.c @@ -1613,6 +1613,16 @@ void Plug_Close(plugin_t *plug) } Con_Printf("Closing plugin %s\n", plug->name); + + //ensure any active contexts provided by the plugin are closed (stuff with destroy callbacks) +#if defined(PLUGINS) && !defined(NOMEDIA) && !defined(SERVERONLY) + Media_UnregisterDecoder(plug, NULL); + Media_UnregisterEncoder(plug, NULL); +#endif + FS_UnRegisterFileSystemModule(plug); + + //tell the plugin that everything is closed and that it should free up any lingering memory/stuff + //it is still allowed to create/have open files. if (plug->shutdown) { plugin_t *cp = currentplug; @@ -1620,13 +1630,10 @@ void Plug_Close(plugin_t *plug) VM_Call(plug->vm, plug->shutdown); currentplug = cp; } -#if defined(PLUGINS) && !defined(NOMEDIA) && !defined(SERVERONLY) - Media_UnregisterDecoder(plug, NULL); - Media_UnregisterEncoder(plug, NULL); -#endif - FS_UnRegisterFileSystemModule(plug); + VM_Destroy(plug->vm); + //make sure anything else that was left is unlinked (stuff without destroy callbacks). for (i = 0; i < pluginstreamarraylen; i++) { if (pluginstreamarray[i].plugin == plug) diff --git a/engine/shaders/glsl/defaultwall.glsl b/engine/shaders/glsl/defaultwall.glsl index 7b49994d0..64d3460a0 100644 --- a/engine/shaders/glsl/defaultwall.glsl +++ b/engine/shaders/glsl/defaultwall.glsl @@ -65,7 +65,9 @@ uniform sampler2D s_t1; //lightmap0 #if defined(BUMP) && (defined(OFFSETMAPPING) || defined(DELUXE) || defined(SPECULAR)) uniform sampler2D s_t2; //normal.rgb+height.a #endif +#ifdef DELUXE uniform sampler2D s_t3; //deluxe0 +#endif #ifdef FULLBRIGHT uniform sampler2D s_t4; //fullbright #endif diff --git a/plugins/berkelium/plugapi.cpp b/plugins/berkelium/plugapi.cpp index 6d2b42365..07ed72b91 100644 --- a/plugins/berkelium/plugapi.cpp +++ b/plugins/berkelium/plugapi.cpp @@ -237,7 +237,8 @@ static void *Dec_DisplayFrame(void *vctx, qboolean nosound, enum uploadfmt_e *fm static void Dec_Destroy(void *vctx) { decctx *ctx = (decctx*)vctx; - ctx->wnd->destroy(); + if (inited) //make sure things don't happen in the wrong order. we can still leak though + ctx->wnd->destroy(); delete ctx; } static void Dec_GetSize (void *vctx, int *width, int *height) @@ -412,6 +413,7 @@ static qintptr_t Dec_Shutdown(qintptr_t *args) static media_decoder_funcs_t decoderfuncs = { + "berkelium", Dec_Create, Dec_DisplayFrame, NULL,//doneframe @@ -434,8 +436,8 @@ extern "C" qintptr_t Plug_Init(qintptr_t *args) } if (!Plug_Export("Shutdown", Dec_Shutdown)) { - Con_Printf("Berkelium plugin warning: Engine doesn't support Shutdown feature\n"); -// return false; + Con_Printf("Berkelium plugin failed: Engine doesn't support Shutdown feature\n"); + return false; } if (!Plug_ExportNative("Media_VideoDecoder", &decoderfuncs)) { diff --git a/plugins/engine.h b/plugins/engine.h index f21d8a843..d31d237ec 100644 --- a/plugins/engine.h +++ b/plugins/engine.h @@ -10,6 +10,7 @@ typedef enum uploadfmt_e typedef struct { + char *drivername; void *(QDECL *createdecoder)(char *name); //needed void *(QDECL *decodeframe)(void *ctx, qboolean nosound, uploadfmt_t *fmt, int *width, int *height); //needed void (QDECL *doneframe)(void *ctx, void *img); //basically a free() @@ -26,6 +27,7 @@ typedef struct typedef struct { + char *drivername; void *(QDECL *capture_begin) (char *streamname, int videorate, int width, int height, int *sndkhz, int *sndchannels, int *sndbits); void (QDECL *capture_video) (void *ctx, void *data, int frame, int width, int height); void (QDECL *capture_audio) (void *ctx, void *data, int bytes);