- fixed recursion issue with menu and CON scripting.

Curse all those busy loops in the engine.
This commit is contained in:
Christoph Oelckers 2019-11-24 17:52:54 +01:00
parent 52cfb7fb92
commit a96f1b25f7
3 changed files with 26 additions and 14 deletions

View file

@ -10040,8 +10040,22 @@ void DrawFullscreenBlends();
//
void videoNextPage(void)
{
static bool recursion;
permfifotype *per;
if (!recursion)
{
// This protection is needed because the menu can call scripts and the scripts can call the busy-looping Screen_Play script event
// which calls videoNextPage for page flipping again. In this loop the UI drawers may not get called again.
// Ideally this stuff should be moved out of videoNextPage so that all those busy loops won't call UI overlays at all.
recursion = true;
M_Drawer();
FStat::PrintStat();
C_DrawConsole();
recursion = false;
}
if (in3dmode())
{
// software rendering only
@ -10058,25 +10072,13 @@ void videoNextPage(void)
g_beforeSwapTime = timerGetHiTicks();
// Draw the ImGui menu on top of the game content, but below the console (if open.)
if (GUICapture & 6)
{
ImGui::Render();
GLInterface.DrawImGui(ImGui::GetDrawData());
GUICapture &= ~4;
}
// Draw the console plus debug output on top of everything else.
DrawFullscreenBlends();
M_Drawer();
FStat::PrintStat();
C_DrawConsole();
GLInterface.Draw2D(&twod);
videoShowFrame(0);
// software rendering only
videoBeginDrawing(); //{{{
for (bssize_t i=permtail; i!=permhead; i=((i+1)&(MAXPERMS-1)))
{

View file

@ -40,6 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "menu/menu.h"
#include "debugbreak.h"
extern bool rotatesprite_2doverride;
BEGIN_DUKE_NS
@ -1219,13 +1220,17 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, fix16_t a, fix16_t horiz, int sect, i
renderSetAspect(viewingRange, yxAspect);
}
void Screen_Play(void)
{
bool running = true;
I_ClearAllInput();
do
// This needs to be disabled during the loop.
auto r2dover = rotatesprite_2doverride;
rotatesprite_2doverride = false;
do
{
gameHandleEvents();
@ -1242,6 +1247,7 @@ void Screen_Play(void)
videoNextPage();
I_ClearAllInput();
} while (running);
rotatesprite_2doverride = r2dover;
}
#if !defined LUNATIC

View file

@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gamecvars.h"
#include "debugbreak.h"
extern bool rotatesprite_2doverride;
BEGIN_RR_NS
@ -1120,7 +1121,9 @@ void Screen_Play(void)
I_ClearAllInput();
do
auto r2dover = rotatesprite_2doverride;
rotatesprite_2doverride = false;
do
{
G_HandleAsync();
@ -1136,6 +1139,7 @@ void Screen_Play(void)
videoNextPage();
I_ClearAllInput();
} while (running);
rotatesprite_2doverride = r2dover;
}
GAMEEXEC_STATIC void VM_Execute(native_t loop)