From c2340dd409a5a8d09cd1677b8467f19acea75c3b Mon Sep 17 00:00:00 2001 From: pogokeen Date: Tue, 25 Jun 2019 18:35:08 +0000 Subject: [PATCH] Add EVENT_RESETGOTPICS which gives scripts the chance to reset gotpics (and similar effects trackers) for effects that run in EVENT_DISPLAYROOMS. EVENT_RESETGOTPICS is called after the last call to EVENT_DISPLAYROOMS in a frame, but before any engine-side calls to renderDrawRoomsQ16() git-svn-id: https://svn.eduke32.com/eduke32@7734 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/events_defs.h | 1 + source/duke3d/src/game.cpp | 8 ++++++++ source/duke3d/src/gamedef.cpp | 1 + source/duke3d/src/lunatic/con_lang.lua | 3 ++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/duke3d/src/events_defs.h b/source/duke3d/src/events_defs.h index a6f0cd334..a63129492 100644 --- a/source/duke3d/src/events_defs.h +++ b/source/duke3d/src/events_defs.h @@ -156,6 +156,7 @@ enum GameEvent_t { EVENT_DAMAGEFLOOR, EVENT_DAMAGECEILING, EVENT_DISPLAYROOMSCAMERATILE, + EVENT_RESETGOTPICS, #ifdef LUNATIC EVENT_ANIMATEALLSPRITES, #endif diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 2c1508f1a..031b57867 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -582,6 +582,10 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz // NOTE: We can have g_mirrorCount==0 but gotpic'd MIRROR, // for example in LNGA2. gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7)); + + //give scripts the chance to reset gotpics for effects that run in EVENT_DISPLAYROOMS + //EVENT_RESETGOTPICS must be called after the last call to EVENT_DISPLAYROOMS in a frame, but before any engine-side renderDrawRoomsQ16 + VM_OnEvent(EVENT_RESETGOTPICS, -1, -1); return; } @@ -651,6 +655,10 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz CAMERA(q16ang) = origCamq16ang; CAMERA(q16horiz) = origCamq16horiz; + //give scripts the chance to reset gotpics for effects that run in EVENT_DISPLAYROOMS + //EVENT_RESETGOTPICS must be called after the last call to EVENT_DISPLAYROOMS in a frame, but before any engine-side renderDrawRoomsQ16 + VM_OnEvent(EVENT_RESETGOTPICS, -1, -1); + //prepare to render the mirror renderPrepareMirror(x, y, a, g_mirrorWall[i], &tposx, &tposy, &tang); diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 2f425bd91..19c144678 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -983,6 +983,7 @@ const char *EventNames[MAXEVENTS] = "EVENT_DAMAGEFLOOR", "EVENT_DAMAGECEILING", "EVENT_DISPLAYROOMSCAMERATILE", + "EVENT_RESETGOTPICS", #ifdef LUNATIC "EVENT_ANIMATEALLSPRITES", #endif diff --git a/source/duke3d/src/lunatic/con_lang.lua b/source/duke3d/src/lunatic/con_lang.lua index e20e054a7..09c1de09d 100644 --- a/source/duke3d/src/lunatic/con_lang.lua +++ b/source/duke3d/src/lunatic/con_lang.lua @@ -192,11 +192,12 @@ EVENT = { EVENT_DISPLAYSCUBA = 112, EVENT_DISPLAYTIP = 113, EVENT_DISPLAYACCESS = 114, + EVENT_RESETGOTPICS = 115, -- EVENT_ANIMATEALLSPRITES = previous+1, -- internal -- KEEPINSYNC with MAXEVENTS below } -MAXEVENTS = 115 -- KEEPINSYNC with above EVENT_* list +MAXEVENTS = 116 -- KEEPINSYNC with above EVENT_* list -- NOTE: negated values are not exported to the ffi.C namespace or CON. -- See TWEAK_SFLAG below.