Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
  • Jisk/srb-2-beef-jerky
117 results
Select Git revision
Show changes
Commits on Source (94)
......@@ -104,6 +104,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
lua_hudlib_drawlist.c
lua_colorlib.c
lua_inputlib.c
lua_interceptlib.c
)
# This updates the modification time for comptime.c at the
......
......@@ -98,3 +98,4 @@ lua_hudlib.c
lua_hudlib_drawlist.c
lua_inputlib.c
lua_colorlib.c
lua_interceptlib.c
......@@ -39,13 +39,26 @@
// Allow scripters to write files of these types to SRB2's folder
static const char *whitelist[] = {
".bmp",
".cfg",
".csv",
".dat",
".bin",
".bmp",
".png",
".sav2",
".obj",
".json",
".yaml",
".xml",
".csv",
".soc",
".cfg",
".ini",
".txt",
".log",
".md",
".sav2",
};
......@@ -183,7 +196,7 @@ void MakePathDirs(char *path)
}
static int CheckFileName(lua_State *L, const char *filename)
static int CheckFileName(lua_State* L, const char* filename, boolean extensioncheck)
{
int length = strlen(filename);
boolean pass = false;
......@@ -192,15 +205,23 @@ static int CheckFileName(lua_State *L, const char *filename)
if (strchr(filename, '\\'))
{
luaL_error(L, "access denied to %s: \\ is not allowed, use / instead", filename);
return pushresult(L,0,filename);
return pushresult(L, 0, filename);
}
if (extensioncheck)
{
for (i = 0; i < (sizeof(whitelist) / sizeof(const char*)); i++)
if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i]))
{
pass = true;
break;
}
}
else
{
pass = true;
}
for (i = 0; i < (sizeof (whitelist) / sizeof(const char *)); i++)
if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i]))
{
pass = true;
break;
}
if (strstr(filename, "./")
|| strstr(filename, "..") || strchr(filename, ':')
|| filename[0] == '/'
......@@ -218,7 +239,7 @@ static int io_open (lua_State *L) {
const char *mode = luaL_optstring(L, 2, "r");
int checkresult;
checkresult = CheckFileName(L, filename);
checkresult = CheckFileName(L, filename, false);
if (checkresult)
return checkresult;
......@@ -241,7 +262,10 @@ static int io_openlocal (lua_State *L) {
luafiletransfer_t *filetransfer;
int checkresult;
checkresult = CheckFileName(L, filename);
// Decision was made for normal reading (binary + text) to have no whitelist restrictions
boolean readcheck = (strchr(mode, 'w') != NULL) || (strchr(mode, 'a') != NULL) || (strchr(mode, '+') != NULL);
checkresult = CheckFileName(L, filename, readcheck);
if (checkresult)
return checkresult;
......
......@@ -1757,6 +1757,8 @@ static void CON_DrawBackpic(void)
// Cache the patch.
con_backpic = W_CachePatchNum(piclump, PU_PATCH);
if (con_backpic == NULL)
return;
// Center the backpic, and draw a vertically cropped patch.
w = con_backpic->width * vid.dup;
......
......@@ -93,6 +93,7 @@
#endif
#include "lua_script.h"
#include "lua_hud.h"
// Version numbers for netplay :upside_down_face:
int VERSION;
......@@ -578,7 +579,7 @@ static void D_Display(void)
V_SetPalette(0);
// draw pause pic
if (paused && cv_showhud.value && (!menuactive || netgame))
if (paused && cv_showhud.value && LUA_HudEnabled(hud_pause) && (!menuactive || netgame))
{
#if 0
INT32 py;
......
......@@ -25,6 +25,7 @@
#include "g_game.h" // Joystick axes (for lua)
#include "i_joy.h"
#include "g_input.h" // Game controls (for lua)
#include "p_maputl.h" // P_PathTraverse constants (for lua)
#include "deh_tables.h"
......@@ -5829,6 +5830,11 @@ struct int_const_s const INT_CONST[] = {
{"MB_BUTTON8",MB_BUTTON8},
{"MB_SCROLLUP",MB_SCROLLUP},
{"MB_SCROLLDOWN",MB_SCROLLDOWN},
// P_PathTraverse constants
{"PT_ADDLINES",PT_ADDLINES},
{"PT_ADDTHINGS",PT_ADDTHINGS},
{"PT_EARLYOUT",PT_EARLYOUT},
// screen.h constants
{"BASEVIDWIDTH",BASEVIDWIDTH},
......
......@@ -75,7 +75,32 @@ enum
typedef struct
{
INT16 x, y;
}ATTRPACK mapvertex_t;
}ATTRPACK mapvertex_t;
typedef enum {
UDMF_TYPE_STRING,
UDMF_TYPE_FIXED,
UDMF_TYPE_NUMERIC,
UDMF_TYPE_BOOLEAN
} udmf_field_type_t;
typedef union { // v added to avoid random compilers cry about nonsense
char* vstring;
fixed_t vfloat;
INT32 vint;
boolean vbool;
} udmf_field_value_t;
// UDMF's Custom Arguments
typedef struct customargs_s
{
char* name;
udmf_field_type_t type;
udmf_field_value_t value;
struct customargs_s* next;
}ATTRPACK customargs_t;
// A SideDef, defining the visual appearance of a wall,
// by setting textures and offsets.
......@@ -218,6 +243,7 @@ typedef struct
fixed_t spritexscale, spriteyscale;
INT32 args[NUMMAPTHINGARGS];
char *stringargs[NUMMAPTHINGSTRINGARGS];
struct customargs_s* customargs;
struct mobj_s *mobj;
} mapthing_t;
......
......@@ -4589,9 +4589,9 @@ void F_TextPromptDrawer(void)
players[j].powers[pw_nocontrol] = 1;\
if (players[j].mo)\
{\
if (players[j].mo->state == states+S_PLAY_STND && players[j].mo->tics != -1)\
if (P_IsPlayerInState(&players[j], S_PLAY_STND) && players[j].mo->tics != -1)\
players[j].mo->tics++;\
else if (players[j].mo->state == states+S_PLAY_WAIT)\
else if (P_IsPlayerInState(&players[j], S_PLAY_WAIT))\
P_SetMobjState(players[j].mo, S_PLAY_STND);\
}\
}
......
......@@ -4340,6 +4340,8 @@ static void G_DoContinued(void)
// when something new is added.
void G_EndGame(void)
{
LUA_HookVoid(HOOK(GameEnd));
// Only do evaluation and credits in coop games.
if (gametyperules & GTR_CUTSCENES)
{
......
......@@ -483,10 +483,13 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, GLMipmap_t
realpatch = W_CachePatchNumPwad(wadnum, lumpnum, PU_PATCH);
}
HWR_DrawTexturePatchInCache(mipmap, blockwidth, blockheight, texture, patch, realpatch);
if (realpatch != NULL)
{
HWR_DrawTexturePatchInCache(mipmap, blockwidth, blockheight, texture, patch, realpatch);
if (free_patch)
Patch_Free(realpatch);
if (free_patch)
Patch_Free(realpatch);
}
}
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
if (format2bpp(mipmap->format)==4)
......
......@@ -1173,10 +1173,12 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT32
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
{
FOutVector v[4];
FBITFIELD flags;
FSurfaceInfo Surf;
float fx, fy, fw, fh;
RGBA_t *palette = HWR_GetTexturePalette();
UINT8 alphalevel = ((color & V_ALPHAMASK) >> V_ALPHASHIFT);
UINT8 blendmode = ((color & V_BLENDMASK) >> V_BLENDSHIFT);
UINT8 perplayershuffle = 0;
......@@ -1341,6 +1343,199 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
Surf.PolyColor = palette[color&0xFF];
flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest|PF_NoTexture|PF_Modulated;
if (alphalevel)
{
if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; // V_HUDTRANSHALF
else if (alphalevel == 11) Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; // V_HUDTRANS
else if (alphalevel == 12) Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; // V_HUDTRANSDOUBLE
else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel];
}
HWD.pfnDrawPolygon(&Surf, v, 4,
flags);
}
// -----------------+
// HWR_DrawFixedFill: draw flat coloured rectangle, with no texture (with fixed point values !!)
// -----------------+
void HWR_DrawFixedFill(fixed_t x, fixed_t y, fixed_t w, fixed_t h, INT32 color)
{
FOutVector v[4];
FSurfaceInfo Surf;
FBITFIELD flags;
float fx = FIXED_TO_FLOAT(x);
float fy = FIXED_TO_FLOAT(y);
float fw = FIXED_TO_FLOAT(w);
float fh = FIXED_TO_FLOAT(h);
RGBA_t *palette = HWR_GetTexturePalette();
UINT8 alphalevel = ((color & V_ALPHAMASK) >> V_ALPHASHIFT);
UINT8 blendmode = ((color & V_BLENDMASK) >> V_BLENDSHIFT);
UINT8 perplayershuffle = 0;
// 3--2
// | /|
// |/ |
// 0--1
if (splitscreen && (color & V_PERPLAYER))
{
float adjusty = ((color & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f;
fh /= 1;
fy /= 2;
#ifdef QUADS
if (splitscreen > 1) // 3 or 4 players
{
float adjustx = ((color & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f;
fw /= 2;
fx /= 2;
if (stplyr == &players[displayplayer])
{
if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM)))
perplayershuffle |= 1;
if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT)))
perplayershuffle |= 4;
color &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT;
}
else if (stplyr == &players[secondarydisplayplayer])
{
if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM)))
perplayershuffle |= 1;
if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT)))
perplayershuffle |= 8;
fx += adjustx;
color &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT;
}
else if (stplyr == &players[thirddisplayplayer])
{
if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM)))
perplayershuffle |= 2;
if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT)))
perplayershuffle |= 4;
fy += adjusty;
color &= ~V_SNAPTOTOP|V_SNAPTORIGHT;
}
else //if (stplyr == &players[fourthdisplayplayer])
{
if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM)))
perplayershuffle |= 2;
if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT)))
perplayershuffle |= 8;
fx += adjustx;
fy += adjusty;
color &= ~V_SNAPTOTOP|V_SNAPTOLEFT;
}
}
else
#endif
// 2 players
{
if (stplyr == &players[displayplayer])
{
if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM)))
perplayershuffle |= 1;
color &= ~V_SNAPTOBOTTOM;
}
else //if (stplyr == &players[secondarydisplayplayer])
{
if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM)))
perplayershuffle |= 2;
fy += adjusty;
color &= ~V_SNAPTOTOP;
}
}
}
if (!(color & V_NOSCALESTART))
{
/*
if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT)
{
RGBA_t rgbaColour = palette[color&0xFF];
FRGBAFloat clearColour;
clearColour.red = (float)rgbaColour.s.red / 255;
clearColour.green = (float)rgbaColour.s.green / 255;
clearColour.blue = (float)rgbaColour.s.blue / 255;
clearColour.alpha = 1;
HWD.pfnClearBuffer(true, false, &clearColour);
return;
}
*/
fx *= vid.dup;
fy *= vid.dup;
fw *= vid.dup;
fh *= vid.dup;
if (fabsf((float)vid.width - (float)BASEVIDWIDTH * vid.dup) > 1.0E-36f)
{
if (color & V_SNAPTORIGHT)
fx += ((float)vid.width - ((float)BASEVIDWIDTH * vid.dup));
else if (!(color & V_SNAPTOLEFT))
fx += ((float)vid.width - ((float)BASEVIDWIDTH * vid.dup)) / 2;
if (perplayershuffle & 4)
fx -= ((float)vid.width - ((float)BASEVIDWIDTH * vid.dup)) / 4;
else if (perplayershuffle & 8)
fx += ((float)vid.width - ((float)BASEVIDWIDTH * vid.dup)) / 4;
}
if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * vid.dup) > 1.0E-36f)
{
// same thing here
if (color & V_SNAPTOBOTTOM)
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * vid.dup));
else if (!(color & V_SNAPTOTOP))
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * vid.dup)) / 2;
if (perplayershuffle & 1)
fy -= ((float)vid.height - ((float)BASEVIDHEIGHT * vid.dup)) / 4;
else if (perplayershuffle & 2)
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * vid.dup)) / 4;
}
}
if (fx >= vid.width || fy >= vid.height)
return;
if (fx < 0)
{
fw += fx;
fx = 0;
}
if (fy < 0)
{
fh += fy;
fy = 0;
}
if (fw <= 0 || fh <= 0)
return;
if (fx + fw > vid.width)
fw = (float)vid.width - fx;
if (fy + fh > vid.height)
fh = (float)vid.height - fy;
fx = -1.0f + (fx / (vid.width / 2.0f));
fy = 1.0f - (fy / (vid.height / 2.0f));
fw = fw / (vid.width / 2);
fh = fh / (vid.height / 2);
v[0].x = v[3].x = fx;
v[2].x = v[1].x = fx + fw;
v[0].y = v[1].y = fy;
v[2].y = v[3].y = fy - fh;
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
v[0].s = v[3].s = 0.0f;
v[2].s = v[1].s = 1.0f;
v[0].t = v[1].t = 0.0f;
v[2].t = v[3].t = 1.0f;
Surf.PolyColor = palette[color&0xFF];
flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest|PF_NoTexture|PF_Modulated;
if (alphalevel)
{
if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; // V_HUDTRANSHALF
......@@ -1350,7 +1545,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
}
HWD.pfnDrawPolygon(&Surf, v, 4,
PF_Modulated|PF_NoTexture|PF_NoDepthTest|PF_Translucent);
flags);
}
#ifdef HAVE_PNG
......
......@@ -43,6 +43,7 @@ void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipma
void HWR_CreatePlanePolygons(INT32 bspnum);
void HWR_CreateStaticLightmaps(INT32 bspnum);
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color);
void HWR_DrawFixedFill(fixed_t x, fixed_t y, fixed_t w, fixed_t h, INT32 color);
void HWR_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT16 actualcolor, UINT8 strength);
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT32 actualcolor); // Lat: separate flags from color since color needs to be an uint to work right.
......
......@@ -1752,24 +1752,28 @@ static void HU_DrawDemoInfo(void)
//
void HU_Drawer(void)
{
// draw chat string plus cursor
if (chat_on)
if (LUA_HudEnabled(hud_chat))
{
if (!OLDCHAT)
HU_DrawChat();
// draw chat string plus cursor
if (chat_on)
{
if (!OLDCHAT)
HU_DrawChat();
else
HU_DrawChat_Old();
}
else
HU_DrawChat_Old();
}
else
{
typelines = 1;
chat_scrolltime = 0;
{
typelines = 1;
chat_scrolltime = 0;
if (!OLDCHAT && cv_consolechat.value < 2 && netgame) // Don't display minimized chat if you set the mode to Window (Hidden)
HU_drawMiniChat(); // draw messages in a cool fashion.
if (!OLDCHAT && cv_consolechat.value < 2 && netgame) // Don't display minimized chat if you set the mode to Window (Hidden)
HU_drawMiniChat(); // draw messages in a cool fashion.
}
}
if (cechotimer)
if (cechotimer && LUA_HudEnabled(hud_cecho))
HU_DrawCEcho();
if (demoplayback && hu_showscores)
......
......@@ -4518,7 +4518,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
sfx_pop, // deathsound
0, // speed
12*FRACUNIT, // radius
64*FRACUNIT, // height
32*FRACUNIT, // height
0, // display offset
100, // mass
0, // damage
......
......@@ -189,6 +189,8 @@ static const struct {
{META_SKINSPRITESLIST, "skin_t.skinsprites[]"},
{META_SKINSPRITESCOMPAT, "skin_t.sprites"}, // TODO: 2.3: Delete
{META_MUSICDEF, "musicdef_t"},
{META_VERTEX, "vertex_t"},
{META_LINE, "line_t"},
{META_SIDE, "side_t"},
......@@ -240,6 +242,8 @@ static const struct {
{META_KEYEVENT, "keyevent_t"},
{META_TEXTEVENT, "textevent_t"},
{META_MOUSE, "mouse_t"},
{META_INTERCEPT, "intercept_t"},
{NULL, NULL}
};
......@@ -3739,6 +3743,73 @@ static int lib_sResumeMusic(lua_State *L)
return 1;
}
enum musicdef_e
{
musicdef_name,
musicdef_title,
musicdef_alttitle,
musicdef_authors
};
static const char *const musicdef_opt[] = {
"name",
"title",
"alttitle",
"authors",
NULL,
};
static int musicdef_fields_ref = LUA_NOREF;
static int musicdef_get(lua_State *L)
{
musicdef_t *musicdef = *((musicdef_t **)luaL_checkudata(L, 1, META_MUSICDEF));
enum musicdef_e field = Lua_optoption(L, 2, -1, musicdef_fields_ref);
lua_settop(L, 2);
if (!musicdef)
return LUA_ErrInvalid(L, "musicdef_t");
switch (field)
{
case musicdef_name:
lua_pushstring(L, musicdef->name);
break;
case musicdef_title:
lua_pushstring(L, musicdef->title);
break;
case musicdef_alttitle:
lua_pushstring(L, musicdef->alttitle);
break;
case musicdef_authors:
lua_pushstring(L, musicdef->authors);
break;
default:
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
I_Assert(lua_istable(L, -1));
lua_pushlightuserdata(L, musicdef);
lua_rawget(L, -2);
if (!lua_istable(L, -1)) { // no extra values table
CONS_Debug(DBG_LUA, M_GetText("'%s' has no extvars table or field named '%s'; returning nil.\n"), "musicdef_t", lua_tostring(L, 2));
return 0;
}
lua_pushvalue(L, 2); // field name
lua_gettable(L, -2);
if (lua_isnil(L, -1)) // no value for this field
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "musicdef_t", lua_tostring(L, 2));
break;
}
return 1;
}
static int lib_sMusicInfo(lua_State *L)
{
const char *music_name = lua_tolstring(L, 1, NULL);
LUA_PushUserdata(L, S_MusicInfo(music_name), META_MUSICDEF);
return 1;
}
// G_GAME
////////////
......@@ -4624,6 +4695,7 @@ static luaL_Reg lib[] = {
{"S_GetMusicLoopPoint",lib_sGetMusicLoopPoint},
{"S_PauseMusic",lib_sPauseMusic},
{"S_ResumeMusic", lib_sResumeMusic},
{"S_MusicInfo", lib_sMusicInfo},
// g_game
{"G_AddGametype", lib_gAddGametype},
......@@ -4662,6 +4734,11 @@ static luaL_Reg lib[] = {
int LUA_BaseLib(lua_State *L)
{
// musicdef_t
// Sound should have its whole own file for Lua, but this will do for now.
LUA_RegisterUserdataMetatable(L, META_MUSICDEF, musicdef_get, NULL, NULL);
musicdef_fields_ref = Lua_CreateFieldTable(L, musicdef_opt);
// Set metatable for string
lua_pushliteral(L, ""); // dummy string
lua_getmetatable(L, -1); // get string metatable
......
......@@ -67,7 +67,9 @@ automatically.
X (ViewpointSwitch),/* spy mode (no trickstabs) */\
X (SeenPlayer),/* MT_NAMECHECK */\
X (PlayerThink),/* P_PlayerThink */\
X (GameStart),\
X (GameQuit),\
X (GameEnd),\
X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\
X (MusicChange),\
X (PlayerHeight),/* override player height */\
......
......@@ -20,6 +20,10 @@ enum hud {
hud_textspectator,
hud_crosshair,
hud_powerups,
hud_gameover,
hud_pause,
hud_cecho,
hud_chat,
// Singleplayer / Co-op
hud_score,
hud_time,
......@@ -30,6 +34,7 @@ enum hud {
hud_weaponrings,
hud_powerstones,
hud_teamscores,
hud_itemhunt,
// NiGHTS mode
hud_nightslink,
hud_nightsdrill,
......
......@@ -42,6 +42,10 @@ static const char *const hud_disable_options[] = {
"textspectator",
"crosshair",
"powerups",
"gameover",
"pause",
"cecho",
"chat",
"score",
"time",
......@@ -52,6 +56,7 @@ static const char *const hud_disable_options[] = {
"weaponrings",
"powerstones",
"teamscores",
"itemhunt",
"nightslink",
"nightsdrill",
......@@ -887,6 +892,28 @@ static int libd_drawFill(lua_State *L)
return 0;
}
static int libd_drawFixedFill(lua_State *L)
{
huddrawlist_h list;
INT32 x = luaL_optinteger(L, 1, 0);
INT32 y = luaL_optinteger(L, 2, 0);
INT32 w = luaL_optinteger(L, 3, BASEVIDWIDTH << FRACBITS);
INT32 h = luaL_optinteger(L, 4, BASEVIDHEIGHT << FRACBITS);
INT32 c = luaL_optinteger(L, 5, 31);
HUDONLY
lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
list = (huddrawlist_h) lua_touserdata(L, -1);
lua_pop(L, 1);
if (LUA_HUD_IsDrawListValid(list))
LUA_HUD_AddDrawFixedFill(list, x, y, w, h, c);
else
V_DrawFixedFill(x, y, w, h, c);
return 0;
}
static int libd_drawString(lua_State *L)
{
huddrawlist_h list;
......@@ -1382,6 +1409,7 @@ static luaL_Reg lib_draw[] = {
{"drawNum", libd_drawNum},
{"drawPaddedNum", libd_drawPaddedNum},
{"drawFill", libd_drawFill},
{"drawFixedFill", libd_drawFixedFill},
{"drawString", libd_drawString},
{"drawNameTag", libd_drawNameTag},
{"drawScaledNameTag", libd_drawScaledNameTag},
......
......@@ -25,6 +25,7 @@ enum drawitem_e {
DI_DrawNum,
DI_DrawPaddedNum,
DI_DrawFill,
DI_DrawFixedFill,
DI_DrawString,
DI_DrawNameTag,
DI_DrawScaledNameTag,
......@@ -346,6 +347,25 @@ void LUA_HUD_AddDrawFill(
item->c = c;
}
void LUA_HUD_AddDrawFixedFill(
huddrawlist_h list,
fixed_t x,
fixed_t y,
fixed_t w,
fixed_t h,
INT32 c
)
{
size_t i = AllocateDrawItem(list);
drawitem_t *item = &list->items[i];
item->type = DI_DrawFixedFill;
item->x = x;
item->y = y;
item->w = w;
item->h = h;
item->c = c;
}
void LUA_HUD_AddDrawString(
huddrawlist_h list,
fixed_t x,
......@@ -482,6 +502,9 @@ void LUA_HUD_DrawList(huddrawlist_h list)
case DI_DrawFill:
V_DrawFill(item->x, item->y, item->w, item->h, item->c);
break;
case DI_DrawFixedFill:
V_DrawFixedFill(item->x, item->y, item->w, item->h, item->c);
break;
case DI_DrawString:
switch(item->align)
{
......
......@@ -98,6 +98,14 @@ void LUA_HUD_AddDrawFill(
INT32 h,
INT32 c
);
void LUA_HUD_AddDrawFixedFill(
huddrawlist_h list,
fixed_t x,
fixed_t y,
fixed_t w,
fixed_t h,
INT32 c
);
void LUA_HUD_AddDrawString(
huddrawlist_h list,
fixed_t x,
......