From 3e4a0dadf55201b305a1c65ce9f3cc68b8c1df40 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 24 Mar 2013 18:52:41 +0000 Subject: [PATCH] Lunatic: cancel logo on EVENT_LOGO error, fix CON mulscale and writable gv. git-svn-id: https://svn.eduke32.com/eduke32@3593 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/game.c | 8 +++++++- polymer/eduke32/source/lunatic/control.lua | 7 +++++++ polymer/eduke32/source/lunatic/defs.ilua | 4 +++- polymer/eduke32/source/lunatic/lunacon.lua | 2 +- polymer/eduke32/source/lunatic/lunatic_game.c | 4 ++++ polymer/eduke32/source/lunatic/lunatic_game.h | 2 ++ 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index a1a661fa8..7a8471600 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -9512,8 +9512,10 @@ static void G_DisplayLogo(void) } } +#ifdef LUNATIC + g_elEventError = 0; +#endif VM_OnEvent(EVENT_LOGO, -1, screenpeek, -1, 0); - G_HandleAsync(); if (g_restorePalette) @@ -9521,6 +9523,10 @@ static void G_DisplayLogo(void) P_SetGamePalette(g_player[myconnectindex].ps,g_player[myconnectindex].ps->palette,0); g_restorePalette = 0; } +#ifdef LUNATIC + if (g_elEventError) + break; +#endif nextpage(); } } diff --git a/polymer/eduke32/source/lunatic/control.lua b/polymer/eduke32/source/lunatic/control.lua index b4de93a61..af5574ffd 100644 --- a/polymer/eduke32/source/lunatic/control.lua +++ b/polymer/eduke32/source/lunatic/control.lua @@ -1596,6 +1596,13 @@ function _startlevel(volume, level) end function _setaspect(viewingrange, yxaspect) + if (viewingrange==0) then + error('invalid argument #1: must be nonzero', 2) + end + if (yxaspect==0) then + error('invalid argument #2: must be nonzero', 2) + end + -- XXX: surely not all values are sane ffiC.setaspect(viewingrange, yxaspect) end diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index 8a82e5eef..66864b545 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -949,6 +949,7 @@ local weaponaccess_mt = { return ffiC.g_playerWeapon[wa._p][key] end + -- TODO: use bcarray? return ffiC.g_playerWeapon[wa._p][ffiC[key.."_WEAPON"]] end, } @@ -1576,7 +1577,8 @@ local tmpmt = { end, __newindex = function(gv, key, val) - if (key=="g_logoFlags") then + if (gv_access[key] == nil) then + -- Read-only vars handled by LuaJIT. ffiC[key] = val else error("write access forbidden", 2) diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index 1cb3265c4..d64dffe06 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -1846,7 +1846,7 @@ local Cinner = { cos = cmd(W,R) / "%1=_xmath.kcos(%2)", mulscale = cmd(W,R,R,R) - / "%1=_gv.Mulscale(%1,%2,%3)", + / "%1=_gv.Mulscale(%2,%3,%4)", getangle = cmd(W,R,R) / "%1=_gv.getangle(%2,%3)", getincangle = cmd(W,R,R) diff --git a/polymer/eduke32/source/lunatic/lunatic_game.c b/polymer/eduke32/source/lunatic/lunatic_game.c index 615f17e98..440d10a98 100644 --- a/polymer/eduke32/source/lunatic/lunatic_game.c +++ b/polymer/eduke32/source/lunatic/lunatic_game.c @@ -23,6 +23,9 @@ uint8_t g_elEvents[MAXEVENTS]; // same thing for actors: el_actor_t g_elActors[MAXTILES]; +// Set to 1 on error in event. +int32_t g_elEventError; + int32_t g_elCallDepth = 0; int32_t g_elEventRETURN; @@ -496,6 +499,7 @@ int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t if (i != 0) { + g_elEventError = 1; g_eventIdx = eventidx; return L_HandleError(L, i, &El_EventErrorPrint); } diff --git a/polymer/eduke32/source/lunatic/lunatic_game.h b/polymer/eduke32/source/lunatic/lunatic_game.h index 58c40de28..af25c108d 100644 --- a/polymer/eduke32/source/lunatic/lunatic_game.h +++ b/polymer/eduke32/source/lunatic/lunatic_game.h @@ -22,6 +22,8 @@ typedef struct extern uint8_t g_elEvents[MAXEVENTS]; // shouldn't be used directly extern el_actor_t g_elActors[MAXTILES]; +extern int32_t g_elEventError; + extern uint32_t g_eventCalls[MAXEVENTS], g_actorCalls[MAXTILES]; extern double g_eventTotalMs[MAXEVENTS], g_actorTotalMs[MAXTILES], g_actorMinMs[MAXTILES], g_actorMaxMs[MAXTILES];