From f8214341955f7a9f7773812216066cb8953e67b9 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sun, 8 Mar 2015 07:58:24 +0000 Subject: [PATCH] CON: Add EVENT_DISPLAYROOMSCAMERA and EVENT_DISPLAYSTART. EVENT_DISPLAYROOMSCAMERA functions exactly like EVENT_DISPLAYROOMS, including RETURN values, but for the ud.camerasprite >= 0 case. EVENT_DISPLAYSTART is executed immediately after the screen background is cleared and drawn. Ensure its RETURN value is zero, because it is currently not being used. WARNING: Consult the devs before using EVENT_DISPLAYSTART. Its position in the display code sequence is not finalized. git-svn-id: https://svn.eduke32.com/eduke32@5047 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/events_defs.h | 2 ++ polymer/eduke32/source/game.c | 33 ++++++++++++++------- polymer/eduke32/source/gamedef.c | 2 ++ polymer/eduke32/source/lunatic/con_lang.lua | 4 ++- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/polymer/eduke32/source/events_defs.h b/polymer/eduke32/source/events_defs.h index fe2ee6ddb..bed5d76dd 100644 --- a/polymer/eduke32/source/events_defs.h +++ b/polymer/eduke32/source/events_defs.h @@ -108,6 +108,8 @@ enum GameEvent_t { EVENT_DISPLAYCURSOR, EVENT_DISPLAYLEVELSTATS, EVENT_DISPLAYCAMERAOSD, + EVENT_DISPLAYROOMSCAMERA, + EVENT_DISPLAYSTART, #ifdef LUNATIC EVENT_ANIMATEALLSPRITES, #endif diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index c0dca4011..88e917189 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -4450,6 +4450,8 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) pub = 0; } + VM_OnEvent(EVENT_DISPLAYSTART, p->i, snum); + if (ud.overhead_on == 2 || ud.show_help || (p->cursectnum == -1 && getrendermode() != REND_CLASSIC)) return; @@ -4459,7 +4461,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) setaspect_new(); } - if (ud.pause_on || g_player[snum].ps->on_crane > -1) + if (ud.pause_on || p->on_crane > -1) smoothratio = 65536; else smoothratio = calc_smoothratio(totalclock, ototalclock); @@ -4484,18 +4486,28 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) CAMERA(ang) = actor[ud.camerasprite].tempang + mulscale16(((s->ang+1024-actor[ud.camerasprite].tempang)&2047)-1024, smoothratio); + + dont_draw = VM_OnEvent(EVENT_DISPLAYROOMSCAMERA, p->i, snum); + + if (dont_draw != 1) // event return values other than 0 and 1 are reserved + { + if (EDUKE32_PREDICT_FALSE(dont_draw != 0)) + OSD_Printf(OSD_ERROR "ERROR: EVENT_DISPLAYROOMSCAMERA return value must be 0 or 1, " + "other values are reserved.\n"); + #ifdef LEGACY_ROR - G_SE40(smoothratio); + G_SE40(smoothratio); #endif #ifdef POLYMER - if (getrendermode() == REND_POLYMER) - polymer_setanimatesprites(G_DoSpriteAnimations, s->x, s->y, CAMERA(ang), smoothratio); + if (getrendermode() == REND_POLYMER) + polymer_setanimatesprites(G_DoSpriteAnimations, s->x, s->y, CAMERA(ang), smoothratio); #endif - yax_preparedrawrooms(); - drawrooms(s->x,s->y,s->z-(4<<8),CAMERA(ang),s->yvel,s->sectnum); - yax_drawrooms(G_DoSpriteAnimations, s->sectnum, 0, smoothratio); - G_DoSpriteAnimations(s->x,s->y,CAMERA(ang),smoothratio); - drawmasks(); + yax_preparedrawrooms(); + drawrooms(s->x,s->y,s->z-(4<<8),CAMERA(ang),s->yvel,s->sectnum); + yax_drawrooms(G_DoSpriteAnimations, s->sectnum, 0, smoothratio); + G_DoSpriteAnimations(s->x,s->y,CAMERA(ang),smoothratio); + drawmasks(); + } } else { @@ -4737,10 +4749,9 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) break; } - dont_draw = 0; // NOTE: might be rendering off-screen here, so CON commands that draw stuff // like showview must cope with that situation or bail out! - dont_draw = VM_OnEvent(EVENT_DISPLAYROOMS, g_player[screenpeek].ps->i, screenpeek); + dont_draw = VM_OnEvent(EVENT_DISPLAYROOMS, p->i, snum); CAMERA(horiz) = clamp(CAMERA(horiz), HORIZ_MIN, HORIZ_MAX); diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 2898c1667..193c3c373 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -673,6 +673,8 @@ const char *EventNames[MAXEVENTS] = "EVENT_DISPLAYCURSOR", "EVENT_DISPLAYLEVELSTATS", "EVENT_DISPLAYCAMERAOSD", + "EVENT_DISPLAYROOMSCAMERA", + "EVENT_DISPLAYSTART", #ifdef LUNATIC "EVENT_ANIMATEALLSPRITES", #endif diff --git a/polymer/eduke32/source/lunatic/con_lang.lua b/polymer/eduke32/source/lunatic/con_lang.lua index 19b082b28..1fc807d7a 100644 --- a/polymer/eduke32/source/lunatic/con_lang.lua +++ b/polymer/eduke32/source/lunatic/con_lang.lua @@ -180,11 +180,13 @@ EVENT = { EVENT_DISPLAYCURSOR = 100, EVENT_DISPLAYLEVELSTATS = 101, EVENT_DISPLAYCAMERAOSD = 102, + EVENT_DISPLAYROOMSCAMERA = 103, + EVENT_DISPLAYSTART = 104, -- EVENT_ANIMATEALLSPRITES = previous+1, -- internal -- KEEPINSYNC with MAXEVENTS below } -MAXEVENTS = 103 -- KEEPINSYNC with above EVENT_* list +MAXEVENTS = 105 -- KEEPINSYNC with above EVENT_* list -- NOTE: negated values are not exported to the ffi.C namespace or CON. -- See TWEAK_SFLAG below.