From 3409df483eaa7c48adb274e29932d3eb34c32103 Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 1 Jul 2021 21:05:45 +0000 Subject: [PATCH] Try to resolve some of the things RennyC complained about. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5938 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_plugin.inc | 6 +++--- engine/client/cl_ui.c | 8 ++++---- engine/client/m_items.c | 27 ++++++++++++++++----------- engine/client/m_mp3.c | 6 +++--- engine/client/menu.c | 12 ++++++------ engine/client/menu.h | 5 +++-- engine/client/p_script.c | 4 ++-- engine/client/pr_menu.c | 24 ++++++++++++++++-------- engine/gl/gl_backend.c | 21 +++++++++++++++++++++ 9 files changed, 74 insertions(+), 39 deletions(-) diff --git a/engine/client/cl_plugin.inc b/engine/client/cl_plugin.inc index 927592023..06e4947f9 100644 --- a/engine/client/cl_plugin.inc +++ b/engine/client/cl_plugin.inc @@ -4,7 +4,7 @@ static plugin_t *protocolclientplugin; -static void PlugMenu_Close(menu_t *m) +static void PlugMenu_Close(menu_t *m, qboolean forced) { Z_Free(m); } @@ -48,7 +48,7 @@ static qboolean QDECL Plug_SetMenuFocus (qboolean wantkeyfocus, const char *curs } } else if (m) - Menu_Unlink(m); + Menu_Unlink(m, false); if (wantkeyfocus) { @@ -1058,7 +1058,7 @@ static void Plug_Client_Close(plugin_t *plug) Plug_FreePlugImages(plug); if (m) - Menu_Unlink(m); + Menu_Unlink(m, true); if (protocolclientplugin == plug) { protocolclientplugin = NULL; diff --git a/engine/client/cl_ui.c b/engine/client/cl_ui.c index 995dc3ef5..9562d1eee 100644 --- a/engine/client/cl_ui.c +++ b/engine/client/cl_ui.c @@ -41,7 +41,7 @@ void Q3_SetKeyCatcher(int newcatcher) if (newcatcher&2) Menu_Push(&uimenu, false); else - Menu_Unlink(&uimenu); + Menu_Unlink(&uimenu, false); } } int Q3_GetKeyCatcher(void) @@ -1739,7 +1739,7 @@ static qintptr_t EXPORT_FN UI_SystemCallsNative(qintptr_t arg, ...) return UI_SystemCalls(NULL, ~(quintptr_t)0, arg, args); } -static void UI_Release(menu_t *m) +static void UI_Release(menu_t *m, qboolean forced) { keycatcher &= ~2; } @@ -1800,7 +1800,7 @@ static qboolean UI_MousePosition(struct menu_s *m, qboolean abs, unsigned int de void UI_Reset(void) { - Menu_Unlink(&uimenu); + Menu_Unlink(&uimenu, true); if (qrenderer == QR_NONE) //no renderer loaded UI_Stop(); @@ -1810,7 +1810,7 @@ void UI_Reset(void) void UI_Stop (void) { - Menu_Unlink(&uimenu); + Menu_Unlink(&uimenu, true); if (uivm) { diff --git a/engine/client/m_items.c b/engine/client/m_items.c index 843c0fc07..cd8479256 100644 --- a/engine/client/m_items.c +++ b/engine/client/m_items.c @@ -1776,7 +1776,7 @@ static qboolean M_KeyEvent(menu_t *m, qboolean isdown, unsigned int devid, int k } } -void M_Release (menu_t *m) +void M_Release (menu_t *m, qboolean forced) { emenu_t *menu = (emenu_t*)m; menuoption_t *op, *oop; @@ -1836,7 +1836,7 @@ emenu_t *M_CreateMenu (int extrasize) } void M_RemoveMenu (emenu_t *menu) { - Menu_Unlink((menu_t*)menu); + Menu_Unlink((menu_t*)menu, false); } void M_ReloadMenus(void) @@ -1851,24 +1851,29 @@ void M_ReloadMenus(void) } void M_RemoveAllMenus (qboolean leaveprompts) -{ - menu_t **link, *m; +{ //certain menuqc mods are evil and force themselves open again each time we ask them to close, which means we get into an infinite loop trying to ask them to kindly fuck off. + //so only kill the current ones. + menu_t **list, *m; + int count = 0; + for (m = topmenu; m; m = m->prev) + count++; + list = BZ_Malloc(count * sizeof(list)); - for (link = &topmenu; *link; ) + for (count = 0, m = topmenu; m; m = m->prev) { - m = *link; if (m->persist && leaveprompts) - link = &m->prev; - else - Menu_Unlink(m); + continue; + list[count++] = m; } - + while(count --> 0) + Menu_Unlink(list[count], true); + BZ_Free(list); } void M_MenuPop_f (void) { if (!topmenu) return; - Menu_Unlink(topmenu); + Menu_Unlink(topmenu, false); } static menuoption_t *M_NextItem(emenu_t *m, menuoption_t *old) diff --git a/engine/client/m_mp3.c b/engine/client/m_mp3.c index 9338ef0ae..a770547e1 100644 --- a/engine/client/m_mp3.c +++ b/engine/client/m_mp3.c @@ -2538,7 +2538,7 @@ static void MediaView_DrawFilm(menu_t *m) } } else if (!videoshader) - Menu_Unlink(m); + Menu_Unlink(m, true); } static qboolean MediaView_KeyEvent(menu_t *m, qboolean isdown, unsigned int devid, int key, int unicode) { @@ -2560,7 +2560,7 @@ static qboolean MediaView_MouseMove(menu_t *m, qboolean isabs, unsigned int devi cin->cursormove(cin, x, y); return true; } -static void MediaView_StopFilm(menu_t *m) +static void MediaView_StopFilm(menu_t *m, qboolean forced) { //display is going away for some reason. might as well kill them all Media_StopFilm(true); } @@ -2612,7 +2612,7 @@ static qboolean Media_BeginNextFilm(void) Menu_Push(&videomenu, false); } else - Menu_Unlink(&videomenu); + Menu_Unlink(&videomenu, true); return !!videoshader; } qboolean Media_StopFilm(qboolean all) diff --git a/engine/client/menu.c b/engine/client/menu.c index fc03548dc..0c1f4d548 100644 --- a/engine/client/menu.c +++ b/engine/client/menu.c @@ -75,7 +75,7 @@ menu_t *Menu_FindContext(void *ctx) } return NULL; } -void Menu_Unlink(menu_t *menu) +void Menu_Unlink(menu_t *menu, qboolean forced) { menu_t **link; for (link = &promptmenu; *link; link = &(*link)->prev) @@ -84,7 +84,7 @@ void Menu_Unlink(menu_t *menu) { *link = menu->prev; if (menu->release) - menu->release(menu); + menu->release(menu, forced); Menu_UpdateFocus(); return; @@ -96,7 +96,7 @@ void Menu_Unlink(menu_t *menu) { *link = menu->prev; if (menu->release) - menu->release(menu); + menu->release(menu, forced); Menu_UpdateFocus(); return; @@ -150,7 +150,7 @@ void Menu_PopAll(void) } //third link to actually unlink them safely without unlinking multiple times etc (grr menuqc mods re-grabbing focus when closing) for (i = 0; i < count; i++) - Menu_Unlink(menus[i]); + Menu_Unlink(menus[i], true); } void Menu_Draw(void) @@ -511,7 +511,7 @@ static qboolean Prompt_MenuKeyEvent(struct menu_s *gm, qboolean isdown, unsigned return false; // no idea what that is m->callback = NULL; //so the remove handler can't fire. - Menu_Unlink(&m->m); + Menu_Unlink(&m->m, false); if (callback) callback(ctx, action); @@ -580,7 +580,7 @@ static void Prompt_Draw(struct menu_s *g) } } } -static void Prompt_Release(struct menu_s *gm) +static void Prompt_Release(struct menu_s *gm, qboolean forced) { promptmenu_t *m = (promptmenu_t*)gm; void (*callback)(void *, promptbutton_t) = m->callback; diff --git a/engine/client/menu.h b/engine/client/menu.h index 095410950..f6f50de11 100644 --- a/engine/client/menu.h +++ b/engine/client/menu.h @@ -102,7 +102,7 @@ typedef struct menu_s { void *ctx; //for finding a specific menu void (*videoreset) (struct menu_s *); //called after a video mode switch / shader reload. - void (*release) (struct menu_s *); // + void (*release) (struct menu_s *, qboolean forced); //forced says 'dont load any other menus'. qboolean (*keyevent)(struct menu_s *, qboolean isdown, unsigned int devid, int key, int unicode); //true if key was handled qboolean (*mousemove)(struct menu_s *, qboolean abs, unsigned int devid, float x, float y); qboolean (*joyaxis) (struct menu_s *, unsigned int devid, int axis, float val); @@ -117,9 +117,10 @@ void Menu_KeyEvent(qboolean down, int qdeviceid, int key, int unicode); void Menu_Draw(void); void Prompts_Draw(void); void Menu_PopAll(void); //attempts to pop all menus (this is for map starts, some might linger) -void Menu_Unlink(menu_t *menu); +void Menu_Unlink(menu_t *menu, qboolean forced); void Menu_Push(menu_t *menu, qboolean prompt); menu_t *Menu_FindContext(void *ctx); +qboolean Menu_IsLinked(menu_t *menu); typedef enum { diff --git a/engine/client/p_script.c b/engine/client/p_script.c index 284de9281..6273e517e 100644 --- a/engine/client/p_script.c +++ b/engine/client/p_script.c @@ -7191,8 +7191,8 @@ static void PScript_DrawParticleTypes (void) RQ_AddDistReorder(pdraw, p, type->slooks, p->org); // make sure emitter runs at least once - if (type->emit >= 0 && type->emitstart <= 0) - P_RunParticleEffectType(p->org, p->vel, 1, type->emit); + if (type->emit >= 0 && type->emitstart <= 0 && pframetime) + P_RunParticleEffectType(p->org, p->vel, pframetime, type->emit); // make sure stain effect runs if (type->stainonimpact && r_bloodstains.value) diff --git a/engine/client/pr_menu.c b/engine/client/pr_menu.c index a231969ff..e29bcf120 100644 --- a/engine/client/pr_menu.c +++ b/engine/client/pr_menu.c @@ -1622,7 +1622,7 @@ void QCBUILTIN PF_cl_setkeydest (pubprogfuncs_t *prinst, struct globalvars_s *pr // key_game if (Key_Dest_Has(kdm_menu)) { - Menu_Unlink(&menuqc); + Menu_Unlink(&menuqc, false); Key_Dest_Remove(kdm_menu); // Key_Dest_Remove(kdm_message); // if (cls.state == ca_disconnected) @@ -2881,12 +2881,6 @@ static qboolean MP_KeyEvent(menu_t *menu, qboolean isdown, unsigned int devid, i R2D_Flush(); return result; } -static void MP_TryRelease(menu_t *m) -{ - if (inmenuprogs) - return; //if the qc asked for it, the qc probably already knows about it. don't recurse. - MP_Toggle(0); -} void MP_Shutdown (void) { @@ -2895,7 +2889,7 @@ void MP_Shutdown (void) return; menuqc.release = NULL; //don't notify - Menu_Unlink(&menuqc); + Menu_Unlink(&menuqc, false); /* { char *buffer; @@ -2926,6 +2920,20 @@ void MP_Shutdown (void) key_dest_absolutemouse &= ~kdm_menu; } +static void MP_TryRelease(menu_t *m, qboolean force) +{ + if (inmenuprogs) + return; //if the qc asked for it, the qc probably already knows about it. don't recurse. + MP_Toggle(0); + + if (force && Menu_IsLinked(m)) + { + Con_Printf(CON_ERROR"Menuqc retook key grabs when ordered to yield. Killing.\n"); + MP_Shutdown(); + M_Init_Internal(); + } +} + void *VARGS PR_CB_Malloc(int size); //these functions should be tracked by the library reliably, so there should be no need to track them ourselves. void VARGS PR_CB_Free(void *mem); diff --git a/engine/gl/gl_backend.c b/engine/gl/gl_backend.c index f08a37b0f..113f8d5fd 100644 --- a/engine/gl/gl_backend.c +++ b/engine/gl/gl_backend.c @@ -5911,6 +5911,27 @@ int GLBE_FBO_Update(fbostate_t *state, unsigned int enables, texid_t *destcol, i Con_Printf("glCheckFramebufferStatus returned %#x\n", i); break; } + + Con_Printf("FBO Enables: %x %i*%i\n", enables, width, height); + for (i = 0; i < mrt; i++) + { + if (destcol[i]) + { + Con_Printf("^[\\imgptr\\%#"PRIxSIZE"^]", (quintptr_t)destcol[i]); + Con_Printf("Colour%i: \"%s\" %x %i*%i*%i%s %s\n", i, destcol[i]->ident, destcol[i]->flags, destcol[i]->width, destcol[i]->height, destcol[i]->depth, (destcol[i]->status != TEX_LOADED)?" NOT LOADED":"", Image_FormatName(destcol[i]->format)); + } + else + Con_Printf("Colour%i: \n", i); + } + if (enables & FBO_TEX_DEPTH && destdepth) + { + Con_Printf("^[\\imgptr\\%#"PRIxSIZE"^]", (quintptr_t)destdepth); + Con_Printf("Depth: \"%s\" %x %i*%i*%i%s %s\n", destdepth->ident, destdepth->flags, destdepth->width, destdepth->height, destdepth->depth, (destdepth->status != TEX_LOADED)?" NOT LOADED":"", Image_FormatName(destdepth->format)); + } + else if (enables & FBO_TEX_DEPTH) + Con_Printf("Depth: \n"); + else if (enables & FBO_RB_DEPTH) + Con_Printf("Depth: \n"); } return old; }