Lunatic translator: handle LOGO_FLAGS.

This is the only gamevar of its kind that is handled for Lunatic, neither
PLR_MORALE nor LOGO_FLAGS are.

git-svn-id: https://svn.eduke32.com/eduke32@3556 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-03-13 10:48:14 +00:00
parent 88313f7b50
commit 6b1df7f1e9
5 changed files with 51 additions and 14 deletions

View File

@ -1177,6 +1177,15 @@ static int32_t G_GetInvOn(const DukePlayer_t *p)
return 0x80000000;
}
static int32_t G_GetMorale(int32_t p_i, int32_t snum)
{
#if !defined LUNATIC
return Gv_GetVarByLabel("PLR_MORALE",-1, p_i, snum);
#else
return -1;
#endif
}
static void G_DrawStatusBar(int32_t snum)
{
const DukePlayer_t *const p = g_player[snum].ps;
@ -1267,8 +1276,9 @@ static void G_DrawStatusBar(int32_t snum)
rotatesprite_fs(sbarx(62),sbary(200-25),sb15h,0,SHIELD,0,0,10+16+256);
{
int32_t lAmount=Gv_GetVarByLabel("PLR_MORALE",-1, p->i, snum);
if (lAmount == -1) lAmount = p->inv_amount[GET_SHIELD];
int32_t lAmount = G_GetMorale(p->i, snum);
if (lAmount == -1)
lAmount = p->inv_amount[GET_SHIELD];
G_DrawAltDigiNum(105,-(200-22),lAmount,-16,10+16+256);
}
@ -1442,11 +1452,9 @@ static void G_DrawStatusBar(int32_t snum)
}
{
int32_t lAmount=Gv_GetVarByLabel("PLR_MORALE",-1, p->i, snum);
int32_t lAmount = G_GetMorale(p->i, snum);
if (lAmount == -1)
lAmount = p->inv_amount[GET_SHIELD];
if (sbar.inv_amount[GET_SHIELD] != lAmount)
{
sbar.inv_amount[GET_SHIELD] = lAmount;
@ -1585,8 +1593,11 @@ static void G_DrawStatusBar(int32_t snum)
}
if (u&2)
{
int32_t lAmount=Gv_GetVarByLabel("PLR_MORALE",-1, p->i, snum);
if (u != -1) G_PatchStatusBar(52,SBY+17,75,SBY+17+11);
int32_t lAmount = G_GetMorale(p->i, snum);
if (u != -1)
G_PatchStatusBar(52,SBY+17,75,SBY+17+11);
if (lAmount == -1)
G_DrawDigiNum(64,SBY+17,p->inv_amount[GET_SHIELD],-16,10+16);
else
@ -2009,9 +2020,22 @@ static void fadepaltile(int32_t r, int32_t g, int32_t b, int32_t start, int32_t
while (start != end+step);
}
#ifdef LUNATIC
int32_t g_logoFlags = 255;
#endif
static int32_t G_GetLogoFlags(void)
{
#if !defined LUNATIC
return Gv_GetVarByLabel("LOGO_FLAGS",255, -1, -1);
#else
return g_logoFlags;
#endif
}
static void G_DisplayExtraScreens(void)
{
int32_t flags = Gv_GetVarByLabel("LOGO_FLAGS",255, -1, -1);
int32_t flags = G_GetLogoFlags();
S_StopMusic();
FX_StopAllSounds();
@ -3141,7 +3165,11 @@ void G_DrawBackground(void)
if (G_HaveEvent(EVENT_GETMENUTILE))
bgtile = VM_OnEvent(EVENT_GETMENUTILE, -1, myconnectindex, -1, bgtile);
// MENU_TILE: is the menu tile tileable?
#if !defined LUNATIC
if (Gv_GetVarByLabel("MENU_TILE", !fstilep, -1, -1))
#else
if (!fstilep)
#endif
{
for (y=y1; y<y2; y+=tilesizy[bgtile])
for (x=0; x<xdim; x+=tilesizx[bgtile])
@ -9320,7 +9348,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
static void G_DisplayLogo(void)
{
int32_t soundanm = 0;
int32_t logoflags=Gv_GetVarByLabel("LOGO_FLAGS",255, -1, -1);
int32_t logoflags = G_GetLogoFlags();
ready2send = 0;

View File

@ -100,11 +100,7 @@ int32_t __fastcall Gv_GetVar(register int32_t id,register int32_t iActor,registe
void __fastcall Gv_SetVar(register int32_t id,register int32_t lValue,register int32_t iActor,register int32_t iPlayer);
int32_t __fastcall Gv_GetVarX(register int32_t id);
void __fastcall Gv_SetVarX(register int32_t id,register int32_t lValue);
#endif
#ifdef LUNATIC
# define Gv_GetVarByLabel(szGameLabel, lDefault, iActor, iPlayer) (lDefault)
#else
int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t lDefault,int32_t iActor,int32_t iPlayer);
int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags);
int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);

View File

@ -505,6 +505,7 @@ typedef struct {
ffi.cdef[[
const int32_t screenpeek;
hudweapon_t hudweap;
int32_t g_logoFlags;
]]
-- INTERNAL VARIABLES/FUNCTIONS
@ -1538,7 +1539,14 @@ local tmpmt = {
end
error("access forbidden", 2)
end,
__newindex = function() error("write access forbidden", 2) end,
__newindex = function(gv, key, val)
if (key=="g_logoFlags") then
ffiC[key] = val
else
error("write access forbidden", 2)
end
end,
}
setmtonce(gv, tmpmt)

View File

@ -118,6 +118,7 @@ g_scriptVersion;
g_currentFrameRate;
g_currentMenu;
g_earthquakeTime;
g_logoFlags;
luaJIT_BC_lunacon;
luaJIT_BC_con_lang;

View File

@ -194,6 +194,10 @@ local function new_initial_gvartab()
LOTAG = RW(CSV".LOTAG"),
TEXTURE = RW(CSV".TEXTURE"),
-- This will warn when defining from CON, but it's the most
-- straightforward implementation.
LOGO_FLAGS = RW "_gv.g_logoFlags",
xdim = RO "_gv.xdim",
ydim = RO "_gv.ydim",
windowx1 = RO "_gv.windowx1",