diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index ab71aaca7..fd2df47b6 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -477,7 +477,7 @@ void A_DeleteSprite(int32_t s) return; } - if (apScriptGameEvent[EVENT_KILLIT]) + if (G_HaveEvent(EVENT_KILLIT)) { int32_t p, pl=A_FindPlayer(&sprite[s],&p); @@ -8199,7 +8199,7 @@ void G_MoveWorld(void) { int32_t j = nextspritestat[i]; - if (!apScriptGameEvent[EVENT_PREGAME] || A_CheckSpriteFlags(i, SPRITE_NOEVENTCODE)) + if (!G_HaveEvent(EVENT_PREGAME) || A_CheckSpriteFlags(i, SPRITE_NOEVENTCODE)) { i = j; continue; @@ -8246,7 +8246,7 @@ void G_MoveWorld(void) if (getrendermode() == 4) A_DoLight(i); #endif - if (!apScriptGameEvent[EVENT_GAME] || A_CheckSpriteFlags(i, SPRITE_NOEVENTCODE)) + if (!G_HaveEvent(EVENT_GAME) || A_CheckSpriteFlags(i, SPRITE_NOEVENTCODE)) { i = j; continue; diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 391701e31..dfba0385d 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -131,6 +131,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "gameexec.h" #include "gamevars.h" +#ifdef LUNATIC +# include "lunatic_game.h" +#endif + +static inline int32_t G_HaveEvent(int32_t iEventID) +{ + return +#ifdef LUNATIC + El_HaveEvent(iEventID) || +#endif + apScriptGameEvent[iEventID]!=NULL; +} + #ifdef EXTERNC } #endif diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 72f900c6f..f431e716d 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -2871,10 +2871,7 @@ void G_DisplayRest(int32_t smoothratio) } } -#ifndef LUNATIC - // TODO: get rid of the other outer apScriptGameEvent checks, too - if (apScriptGameEvent[EVENT_DISPLAYREST]) -#endif + if (G_HaveEvent(EVENT_DISPLAYREST)) { int32_t vr=viewingrange, asp=yxaspect; VM_OnEvent(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek, -1, 0); @@ -3141,7 +3138,7 @@ void G_DrawBackground(void) #define MENUTILE (!getrendermode()?MENUSCREEN:LOADSCREEN) // Gv_SetVar(g_iReturnVarID,tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE, -1, -1); bgtile = (tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE); - if (apScriptGameEvent[EVENT_GETMENUTILE]) + if (G_HaveEvent(EVENT_GETMENUTILE)) bgtile = VM_OnEvent(EVENT_GETMENUTILE, -1, myconnectindex, -1, bgtile); if (Gv_GetVarByLabel("MENU_TILE", tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?0:1, -1, -1)) { @@ -3725,7 +3722,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) 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! - if (apScriptGameEvent[EVENT_DISPLAYROOMS]) + if (G_HaveEvent(EVENT_DISPLAYROOMS)) dont_draw = VM_OnEvent(EVENT_DISPLAYROOMS, g_player[screenpeek].ps->i, screenpeek, -1, 0); ud.camerahoriz = clamp(ud.camerahoriz, HORIZ_MIN, HORIZ_MAX); @@ -4014,7 +4011,7 @@ int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int3 A_ResetVars(i); - if (apScriptGameEvent[EVENT_EGS]) + if (G_HaveEvent(EVENT_EGS)) { extern int32_t block_deletesprite; int32_t pl=A_FindPlayer(s, &p); @@ -5802,7 +5799,7 @@ int32_t A_Spawn(int32_t j, int32_t pn) OSD_Printf_nowarn(OSD_ERROR "Found lonely Sector Effector (lotag 0) at (%d,%d)\n", TrackerCast(sp->x),TrackerCast(sp->y)); changespritestat(i, STAT_ACTOR); - if (apScriptGameEvent[EVENT_SPAWN]) + if (G_HaveEvent(EVENT_SPAWN)) { int32_t pl=A_FindPlayer(&sprite[i],&p); VM_OnEvent(EVENT_SPAWN,i, pl, p, 0); @@ -6033,7 +6030,7 @@ int32_t A_Spawn(int32_t j, int32_t pn) } SPAWN_END: - if (apScriptGameEvent[EVENT_SPAWN]) + if (G_HaveEvent(EVENT_SPAWN)) { int32_t pl=A_FindPlayer(&sprite[i],&p); VM_OnEvent(EVENT_SPAWN,i, pl, p, 0); @@ -7008,7 +7005,7 @@ skip: */ } - if (apScriptGameEvent[EVENT_ANIMATESPRITES]) + if (G_HaveEvent(EVENT_ANIMATESPRITES)) { for (j = spritesortcnt-1; j>=0; j--) G_DoEventAnimSprites(j); diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 2ed58f915..d8e99e083 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -97,7 +97,7 @@ extern int32_t voting; void M_ChangeMenu(int32_t cm) { - if (apScriptGameEvent[EVENT_CHANGEMENU]) + if (G_HaveEvent(EVENT_CHANGEMENU)) cm = VM_OnEvent(EVENT_CHANGEMENU, g_player[myconnectindex].ps->i, myconnectindex, -1, cm); if (cm >= 0) @@ -851,7 +851,7 @@ void M_DisplayMenus(void) walock[TILE_LOADSHOT] = 1; return; } - if (apScriptGameEvent[EVENT_DISPLAYMENU]) + if (G_HaveEvent(EVENT_DISPLAYMENU)) VM_OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek, -1, 0); g_player[myconnectindex].ps->gm &= (0xff-MODE_TYPE); @@ -5412,7 +5412,7 @@ VOLUME_ALL_40x: break; } - if (apScriptGameEvent[EVENT_DISPLAYMENUREST]) + if (G_HaveEvent(EVENT_DISPLAYMENUREST)) VM_OnEvent(EVENT_DISPLAYMENUREST, g_player[screenpeek].ps->i, screenpeek, -1, 0); if (I_EscapeTrigger()) diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 9b8a66416..794245e2c 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -342,7 +342,7 @@ static int32_t GetAutoAimAngle(int32_t i, int32_t p, int32_t atwith, Gv_SetVar(g_iAimAngleVarID, AUTO_AIM_ANGLE, i, p); - if (apScriptGameEvent[EVENT_GETAUTOAIMANGLE]) + if (G_HaveEvent(EVENT_GETAUTOAIMANGLE)) VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1, 0); j = -1; @@ -674,7 +674,7 @@ int32_t A_Shoot(int32_t i, int32_t atwith) Gv_SetVar(g_iAngRangeVarID,angRange, i,p); Gv_SetVar(g_iZRangeVarID,zRange,i,p); - if (apScriptGameEvent[EVENT_GETSHOTRANGE]) + if (G_HaveEvent(EVENT_GETSHOTRANGE)) VM_OnEvent(EVENT_GETSHOTRANGE, i,p, -1, 0); angRange=Gv_GetVar(g_iAngRangeVarID,i,p); @@ -1209,7 +1209,7 @@ DOSKIPBULLETHOLE: Gv_SetVar(g_iAngRangeVarID,angRange, i,p); Gv_SetVar(g_iZRangeVarID,zRange,i,p); - if (apScriptGameEvent[EVENT_GETSHOTRANGE]) + if (G_HaveEvent(EVENT_GETSHOTRANGE)) VM_OnEvent(EVENT_GETSHOTRANGE, i,p, -1, 0); angRange=Gv_GetVar(g_iAngRangeVarID,i,p); @@ -3089,10 +3089,10 @@ void getinput(int32_t snum) loc.extbits |= (BUTTON(gamefunc_Strafe_Left) || (svel > 0))<<2; loc.extbits |= (BUTTON(gamefunc_Strafe_Right) || (svel < 0))<<3; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNLEFT]) + if (G_HaveEvent(EVENT_PROCESSINPUT) || G_HaveEvent(EVENT_TURNLEFT)) loc.extbits |= BUTTON(gamefunc_Turn_Left)<<4; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNRIGHT]) + if (G_HaveEvent(EVENT_PROCESSINPUT) || G_HaveEvent(EVENT_TURNRIGHT)) loc.extbits |= BUTTON(gamefunc_Turn_Right)<<5; // used for changing team @@ -3382,7 +3382,7 @@ void P_ChangeWeapon(DukePlayer_t *p,int32_t weapon) if (p->reloading) return; - if (p->curr_weapon != weapon && apScriptGameEvent[EVENT_CHANGEWEAPON]) + if (p->curr_weapon != weapon && G_HaveEvent(EVENT_CHANGEWEAPON)) i = VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1, weapon); if (i == -1) @@ -3898,7 +3898,7 @@ void P_ProcessWeapon(int32_t snum) if (VM_OnEvent(EVENT_FIRE, p->i, snum, -1, 0) == 0) { - if (apScriptGameEvent[EVENT_FIREWEAPON]) // this event is deprecated + if (G_HaveEvent(EVENT_FIREWEAPON)) // this event is deprecated VM_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1, 0); switch (aplWeaponWorksLike[p->curr_weapon][snum]) diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index b9ff63d47..691944873 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -716,7 +716,7 @@ void P_ResetPlayer(int32_t snum) pl->movement_lock = 0; - if (apScriptGameEvent[EVENT_RESETPLAYER]) + if (G_HaveEvent(EVENT_RESETPLAYER)) VM_OnEvent(EVENT_RESETPLAYER, pl->i, snum, -1, 0); } diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 05b43ea08..f81582b0c 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -542,7 +542,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos) const DukePlayer_t *const myps = g_player[myconnectindex].ps; const DukePlayer_t *peekps; - if (apScriptGameEvent[EVENT_SOUND]) + if (G_HaveEvent(EVENT_SOUND)) num = VM_OnEvent(EVENT_SOUND, i, screenpeek, -1, num); if ((unsigned)num > (unsigned)g_maxSoundPos || @@ -682,7 +682,7 @@ int32_t S_PlaySound(int32_t num) int32_t pitch; int32_t voice, j; - if (apScriptGameEvent[EVENT_SOUND]) + if (G_HaveEvent(EVENT_SOUND)) num = VM_OnEvent(EVENT_SOUND, g_player[screenpeek].ps->i, screenpeek, -1, num); if (ud.config.FXDevice < 0) return -1;