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
  • 21-installer-nodd
  • 2210-pre1
  • 2210-pre2
  • 2210-rc1
  • 2210-rc2
  • 2210-rc3
  • 2211-pre1
  • 2211-pre2
  • 2211-rc1
  • 2212-pre1
  • 2212-pre2
  • 2212-pre3
  • 2212-rc1
  • 2213
  • 2214-pre1
  • 2214-pre2
  • 2214-pre3
  • 2214-pre4
  • 2_2_12
  • 64-gl-log
  • COM_ImmedExecute-lua
  • DJGPP
  • accel-momentum
  • acs
  • action-args
  • alpha-fixes
  • any-resolution
  • appveyor
  • blend-locking
  • blentran
  • blua-unary-not-fix
  • boost-tickrate
  • bustablesoundz
  • cleanup-opengl
  • cleanupmusic
  • clipmidtex
  • cmake-valgrind
  • crawlacommander-sprites
  • custom-map-names
  • custom-teams
  • cutscene-cleanup
  • dd-music-bypass
  • dd-music-fix
  • delfile2
  • deprecate-lua-dedicated-server
  • dpl-2
  • dropshadows-spawning
  • dynabsp
  • emblem-drawing
  • exchndl-xp-fix
  • extra-textures
  • few-kart-lua-changes
  • ffloorclip
  • fix-167
  • fix-cvar-conflicts
  • fix-opengl-parameter-crash
  • fix-opengl-shear-roll
  • flipfuncpointers
  • fof-lightlist-fixes
  • font-FUCK
  • frictionrefactor
  • fuck-macros-1
  • gamepad-luakeydown
  • gamepad-morefixes
  • gamepad_experiments
  • gametype-refactor
  • gametype-refactor-1
  • gametype-refactor-player-spawns
  • ghost-networking
  • gif-splitting
  • grr-lj
  • hitboxviewer
  • hwr-texture-cache-refactor
  • hwrender2
  • improve-439
  • increase-maxconditionsets
  • increase-packet-tics
  • input-display
  • input-display-translucency
  • io
  • joystick-juggling-maz
  • just-in-case
  • keycodes-only
  • ksf-wadfiles
  • ld413-mp-fix
  • levelstruct
  • libpng-version-support
  • linedef-actions
  • lj-test
  • lol-states
  • loopedsounds
  • lower-unpegged-fix
  • lua-change-gametype
  • lua-command-netids
  • lua-gfx-2
  • lua-gfx-sprites
  • lua-local
  • makefile-auto-mingw-gcc
  • makefile-tinkering
  • map-components-signedness-fixes
  • SRB2_release_2.1
  • SRB2_release_2.1.1
  • SRB2_release_2.1.10
  • SRB2_release_2.1.11
  • SRB2_release_2.1.12
  • SRB2_release_2.1.14
  • SRB2_release_2.1.15
  • SRB2_release_2.1.16
  • SRB2_release_2.1.16a
  • SRB2_release_2.1.17
  • SRB2_release_2.1.18
  • SRB2_release_2.1.19
  • SRB2_release_2.1.2
  • SRB2_release_2.1.20
  • SRB2_release_2.1.21
  • SRB2_release_2.1.22
  • SRB2_release_2.1.23
  • SRB2_release_2.1.24
  • SRB2_release_2.1.25
  • SRB2_release_2.1.3
  • SRB2_release_2.1.4
  • SRB2_release_2.1.5
  • SRB2_release_2.1.6
  • SRB2_release_2.1.7
  • SRB2_release_2.1.8
  • SRB2_release_2.1.9
  • SRB2_release_2.2.0
  • SRB2_release_2.2.1
  • SRB2_release_2.2.10
  • SRB2_release_2.2.11
  • SRB2_release_2.2.12
  • SRB2_release_2.2.13
  • SRB2_release_2.2.15
  • SRB2_release_2.2.2
  • SRB2_release_2.2.3
  • SRB2_release_2.2.4
  • SRB2_release_2.2.5
  • SRB2_release_2.2.6
  • SRB2_release_2.2.7
  • SRB2_release_2.2.8
  • SRB2_release_2.2.9
  • td-release-v1.0.0
142 results

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
  • 21-installer-nodd
  • 2210-pre1
  • 2210-pre2
  • 2210-rc1
  • 2210-rc2
  • 2210-rc3
  • 2211-pre1
  • 2211-pre2
  • 2211-rc1
  • 2212-pre1
  • 2212-pre2
  • 2212-pre3
  • 2212-rc1
  • 2213
  • 2_2_12
  • 64-gl-log
  • COM_ImmedExecute-lua
  • DJGPP
  • accel-momentum
  • acs
  • action-args
  • alpha-fixes
  • any-resolution
  • appveyor
  • better-player-states
  • betterfakecontrast
  • blend-locking
  • blentran
  • blua-unary-not-fix
  • boost-tickrate
  • bustablesoundz
  • cleanup-opengl
  • cleanupmusic
  • clipmidtex
  • cmake-valgrind
  • crawlacommander-sprites
  • custom-map-names
  • custom-teams
  • cutscene-cleanup
  • dd-music-bypass
  • dd-music-fix
  • delfile2
  • deprecate-lua-dedicated-server
  • dpl-2
  • dropshadows-spawning
  • dynabsp
  • emblem-drawing
  • exchndl-xp-fix
  • extra-textures
  • few-kart-lua-changes
  • ffloorclip
  • fix-167
  • fix-cvar-conflicts
  • fix-ogl-spriteclipping
  • fix-opengl-shear-roll
  • fix-va-bufferoverflow
  • fixinterpstats
  • flipfuncpointers
  • fof-lightlist-fixes
  • font-FUCK
  • frictionrefactor
  • fuck-macros-1
  • gamepad-luakeydown
  • gamepad-morefixes
  • gamepad_experiments
  • gametype-refactor
  • gametype-refactor-1
  • gametype-refactor-player-spawns
  • ghost-networking
  • gif-splitting
  • gitlab-ci
  • grr-lj
  • hitboxviewer
  • hwr-texture-cache-refactor
  • hwrender2
  • improve-439
  • increase-maxconditionsets
  • increase-packet-tics
  • input-display
  • input-display-translucency
  • io
  • joystick-juggling-maz
  • keycodes-only
  • ksf-wadfiles
  • ld413-mp-fix
  • levelinterpobjectplace
  • levelstruct
  • libpng-version-support
  • linedef-actions
  • lj-test
  • lol-states
  • loopedsounds
  • lower-unpegged-fix
  • lua-change-gametype
  • lua-command-netids
  • lua-debug-library
  • lua-gfx-2
  • lua-gfx-sprites
  • lua-local
  • makefile-auto-mingw-gcc
  • SRB2_release_2.1
  • SRB2_release_2.1.1
  • SRB2_release_2.1.10
  • SRB2_release_2.1.11
  • SRB2_release_2.1.12
  • SRB2_release_2.1.14
  • SRB2_release_2.1.15
  • SRB2_release_2.1.16
  • SRB2_release_2.1.16a
  • SRB2_release_2.1.17
  • SRB2_release_2.1.18
  • SRB2_release_2.1.19
  • SRB2_release_2.1.2
  • SRB2_release_2.1.20
  • SRB2_release_2.1.21
  • SRB2_release_2.1.22
  • SRB2_release_2.1.23
  • SRB2_release_2.1.24
  • SRB2_release_2.1.25
  • SRB2_release_2.1.3
  • SRB2_release_2.1.4
  • SRB2_release_2.1.5
  • SRB2_release_2.1.6
  • SRB2_release_2.1.7
  • SRB2_release_2.1.8
  • SRB2_release_2.1.9
  • SRB2_release_2.2.0
  • SRB2_release_2.2.1
  • SRB2_release_2.2.10
  • SRB2_release_2.2.11
  • SRB2_release_2.2.12
  • SRB2_release_2.2.13
  • SRB2_release_2.2.2
  • SRB2_release_2.2.3
  • SRB2_release_2.2.4
  • SRB2_release_2.2.5
  • SRB2_release_2.2.6
  • SRB2_release_2.2.7
  • SRB2_release_2.2.8
  • SRB2_release_2.2.9
  • td-release-v1.0.0
141 results
Show changes
Commits on Source (194)
version: 2.2.14.{branch}-{build} version: 2.2.16.{branch}-{build}
os: MinGW os: MinGW
environment: environment:
......
...@@ -104,6 +104,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ...@@ -104,6 +104,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
lua_hudlib_drawlist.c lua_hudlib_drawlist.c
lua_colorlib.c lua_colorlib.c
lua_inputlib.c lua_inputlib.c
lua_interceptlib.c
) )
# This updates the modification time for comptime.c at the # This updates the modification time for comptime.c at the
......
...@@ -98,3 +98,4 @@ lua_hudlib.c ...@@ -98,3 +98,4 @@ lua_hudlib.c
lua_hudlib_drawlist.c lua_hudlib_drawlist.c
lua_inputlib.c lua_inputlib.c
lua_colorlib.c lua_colorlib.c
lua_interceptlib.c
...@@ -39,13 +39,26 @@ ...@@ -39,13 +39,26 @@
// Allow scripters to write files of these types to SRB2's folder // Allow scripters to write files of these types to SRB2's folder
static const char *whitelist[] = { static const char *whitelist[] = {
".bmp",
".cfg",
".csv",
".dat", ".dat",
".bin",
".bmp",
".png", ".png",
".sav2",
".obj",
".json",
".yaml",
".xml",
".csv",
".soc",
".cfg",
".ini",
".txt", ".txt",
".log",
".md",
".sav2",
}; };
...@@ -183,7 +196,7 @@ void MakePathDirs(char *path) ...@@ -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); int length = strlen(filename);
boolean pass = false; boolean pass = false;
...@@ -195,12 +208,20 @@ static int CheckFileName(lua_State *L, const char *filename) ...@@ -195,12 +208,20 @@ static int CheckFileName(lua_State *L, const char *filename)
return pushresult(L, 0, filename); return pushresult(L, 0, filename);
} }
if (extensioncheck)
{
for (i = 0; i < (sizeof(whitelist) / sizeof(const char*)); i++) for (i = 0; i < (sizeof(whitelist) / sizeof(const char*)); i++)
if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i])) if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i]))
{ {
pass = true; pass = true;
break; break;
} }
}
else
{
pass = true;
}
if (strstr(filename, "./") if (strstr(filename, "./")
|| strstr(filename, "..") || strchr(filename, ':') || strstr(filename, "..") || strchr(filename, ':')
|| filename[0] == '/' || filename[0] == '/'
...@@ -218,7 +239,7 @@ static int io_open (lua_State *L) { ...@@ -218,7 +239,7 @@ static int io_open (lua_State *L) {
const char *mode = luaL_optstring(L, 2, "r"); const char *mode = luaL_optstring(L, 2, "r");
int checkresult; int checkresult;
checkresult = CheckFileName(L, filename); checkresult = CheckFileName(L, filename, false);
if (checkresult) if (checkresult)
return checkresult; return checkresult;
...@@ -241,7 +262,10 @@ static int io_openlocal (lua_State *L) { ...@@ -241,7 +262,10 @@ static int io_openlocal (lua_State *L) {
luafiletransfer_t *filetransfer; luafiletransfer_t *filetransfer;
int checkresult; 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) if (checkresult)
return checkresult; return checkresult;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "m_menu.h" #include "m_menu.h"
#include "filesrch.h" #include "filesrch.h"
#include "m_misc.h" #include "m_misc.h"
#include "lua_libs.h"
#ifdef _WINDOWS #ifdef _WINDOWS
#include "win32/win_main.h" #include "win32/win_main.h"
...@@ -918,6 +919,22 @@ static void CON_InputDelChar(void) ...@@ -918,6 +919,22 @@ static void CON_InputDelChar(void)
// ---- // ----
// //
//
// Same as CON_Responder, but is process before everything else, so it cannot be blocked.
//
boolean CON_PreResponder(event_t *ev)
{
if (ev->type == ev_keydown && shiftdown == 1 && ev->key == KEY_ESCAPE)
{
I_SetTextInputMode(con_destlines == 0 ? true : textinputmodeenabledbylua); // inverse, since this is changed next tic.
consoletoggle = true;
return true;
}
return false;
}
//
// Handles console key input // Handles console key input
// //
boolean CON_Responder(event_t *ev) boolean CON_Responder(event_t *ev)
...@@ -954,7 +971,10 @@ boolean CON_Responder(event_t *ev) ...@@ -954,7 +971,10 @@ boolean CON_Responder(event_t *ev)
if ((key == gamecontrol[GC_CONSOLE][0] || key == gamecontrol[GC_CONSOLE][1]) && !shiftdown) if ((key == gamecontrol[GC_CONSOLE][0] || key == gamecontrol[GC_CONSOLE][1]) && !shiftdown)
{ {
I_SetTextInputMode(con_destlines == 0); // inverse, since this is changed next tic. if (con_destlines == 0 && I_GetTextInputMode())
return false; // some other component is holding keyboard input, don't hijack it!
I_SetTextInputMode(con_destlines == 0 ? true : textinputmodeenabledbylua); // inverse, since this is changed next tic.
consoletoggle = true; consoletoggle = true;
return true; return true;
} }
...@@ -974,7 +994,7 @@ boolean CON_Responder(event_t *ev) ...@@ -974,7 +994,7 @@ boolean CON_Responder(event_t *ev)
// escape key toggle off console // escape key toggle off console
if (key == KEY_ESCAPE) if (key == KEY_ESCAPE)
{ {
I_SetTextInputMode(false); I_SetTextInputMode(textinputmodeenabledbylua);
consoletoggle = true; consoletoggle = true;
return true; return true;
} }
...@@ -1737,6 +1757,8 @@ static void CON_DrawBackpic(void) ...@@ -1737,6 +1757,8 @@ static void CON_DrawBackpic(void)
// Cache the patch. // Cache the patch.
con_backpic = W_CachePatchNum(piclump, PU_PATCH); con_backpic = W_CachePatchNum(piclump, PU_PATCH);
if (con_backpic == NULL)
return;
// Center the backpic, and draw a vertically cropped patch. // Center the backpic, and draw a vertically cropped patch.
w = con_backpic->width * vid.dup; w = con_backpic->width * vid.dup;
......
...@@ -19,6 +19,7 @@ void CON_Init(void); ...@@ -19,6 +19,7 @@ void CON_Init(void);
void CON_StartRefresh(void); void CON_StartRefresh(void);
void CON_StopRefresh(void); void CON_StopRefresh(void);
boolean CON_PreResponder(event_t *ev);
boolean CON_Responder(event_t *ev); boolean CON_Responder(event_t *ev);
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
......
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
#endif #endif
#include "lua_script.h" #include "lua_script.h"
#include "lua_hud.h"
// Version numbers for netplay :upside_down_face: // Version numbers for netplay :upside_down_face:
int VERSION; int VERSION;
...@@ -227,6 +228,9 @@ void D_ProcessEvents(void) ...@@ -227,6 +228,9 @@ void D_ProcessEvents(void)
} }
} }
if (CON_PreResponder(ev))
continue;
// Screenshots over everything so that they can be taken anywhere. // Screenshots over everything so that they can be taken anywhere.
if (M_ScreenshotResponder(ev)) if (M_ScreenshotResponder(ev))
continue; // ate the event continue; // ate the event
...@@ -575,7 +579,7 @@ static void D_Display(void) ...@@ -575,7 +579,7 @@ static void D_Display(void)
V_SetPalette(0); V_SetPalette(0);
// draw pause pic // draw pause pic
if (paused && cv_showhud.value && (!menuactive || netgame)) if (paused && cv_showhud.value && LUA_HudEnabled(hud_pause) && (!menuactive || netgame))
{ {
#if 0 #if 0
INT32 py; INT32 py;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "g_game.h" // Joystick axes (for lua) #include "g_game.h" // Joystick axes (for lua)
#include "i_joy.h" #include "i_joy.h"
#include "g_input.h" // Game controls (for lua) #include "g_input.h" // Game controls (for lua)
#include "p_maputl.h" // P_PathTraverse constants (for lua)
#include "deh_tables.h" #include "deh_tables.h"
...@@ -5830,6 +5831,11 @@ struct int_const_s const INT_CONST[] = { ...@@ -5830,6 +5831,11 @@ struct int_const_s const INT_CONST[] = {
{"MB_SCROLLUP",MB_SCROLLUP}, {"MB_SCROLLUP",MB_SCROLLUP},
{"MB_SCROLLDOWN",MB_SCROLLDOWN}, {"MB_SCROLLDOWN",MB_SCROLLDOWN},
// P_PathTraverse constants
{"PT_ADDLINES",PT_ADDLINES},
{"PT_ADDTHINGS",PT_ADDTHINGS},
{"PT_EARLYOUT",PT_EARLYOUT},
// screen.h constants // screen.h constants
{"BASEVIDWIDTH",BASEVIDWIDTH}, {"BASEVIDWIDTH",BASEVIDWIDTH},
{"BASEVIDHEIGHT",BASEVIDHEIGHT}, {"BASEVIDHEIGHT",BASEVIDHEIGHT},
......
...@@ -77,6 +77,31 @@ typedef struct ...@@ -77,6 +77,31 @@ typedef struct
INT16 x, y; 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, // A SideDef, defining the visual appearance of a wall,
// by setting textures and offsets. // by setting textures and offsets.
typedef struct typedef struct
...@@ -218,6 +243,7 @@ typedef struct ...@@ -218,6 +243,7 @@ typedef struct
fixed_t spritexscale, spriteyscale; fixed_t spritexscale, spriteyscale;
INT32 args[NUMMAPTHINGARGS]; INT32 args[NUMMAPTHINGARGS];
char *stringargs[NUMMAPTHINGSTRINGARGS]; char *stringargs[NUMMAPTHINGSTRINGARGS];
struct customargs_s* customargs;
struct mobj_s *mobj; struct mobj_s *mobj;
} mapthing_t; } mapthing_t;
......
...@@ -4589,9 +4589,9 @@ void F_TextPromptDrawer(void) ...@@ -4589,9 +4589,9 @@ void F_TextPromptDrawer(void)
players[j].powers[pw_nocontrol] = 1;\ players[j].powers[pw_nocontrol] = 1;\
if (players[j].mo)\ 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++;\ 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);\ P_SetMobjState(players[j].mo, S_PLAY_STND);\
}\ }\
} }
......
...@@ -2270,6 +2270,11 @@ boolean G_LuaResponder(event_t *ev) ...@@ -2270,6 +2270,11 @@ boolean G_LuaResponder(event_t *ev)
cancelled = LUA_HookKey(ev, HOOK(KeyUp)); cancelled = LUA_HookKey(ev, HOOK(KeyUp));
LUA_InvalidateUserdata(ev); LUA_InvalidateUserdata(ev);
} }
else if (ev->type == ev_text)
{
cancelled = LUA_HookText(ev, HOOK(TextInput));
LUA_InvalidateUserdata(ev);
}
return cancelled; return cancelled;
} }
...@@ -4335,6 +4340,8 @@ static void G_DoContinued(void) ...@@ -4335,6 +4340,8 @@ static void G_DoContinued(void)
// when something new is added. // when something new is added.
void G_EndGame(void) void G_EndGame(void)
{ {
LUA_HookVoid(HOOK(GameEnd));
// Only do evaluation and credits in coop games. // Only do evaluation and credits in coop games.
if (gametyperules & GTR_CUTSCENES) if (gametyperules & GTR_CUTSCENES)
{ {
......
...@@ -483,11 +483,14 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, GLMipmap_t ...@@ -483,11 +483,14 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, GLMipmap_t
realpatch = W_CachePatchNumPwad(wadnum, lumpnum, PU_PATCH); realpatch = W_CachePatchNumPwad(wadnum, lumpnum, PU_PATCH);
} }
if (realpatch != NULL)
{
HWR_DrawTexturePatchInCache(mipmap, blockwidth, blockheight, texture, patch, realpatch); HWR_DrawTexturePatchInCache(mipmap, blockwidth, blockheight, texture, patch, realpatch);
if (free_patch) if (free_patch)
Patch_Free(realpatch); Patch_Free(realpatch);
} }
}
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
if (format2bpp(mipmap->format)==4) if (format2bpp(mipmap->format)==4)
{ {
......
...@@ -598,43 +598,76 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, ...@@ -598,43 +598,76 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Fills a box of pixels using a flat texture as a pattern // Fills a box of pixels using a flat texture as a pattern
// Fixed to properly align like the other draw functions -luigi budd
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum) void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum)
{ {
FOutVector v[4]; FOutVector v[4];
const size_t len = W_LumpLength(flatlumpnum); const size_t len = W_LumpLength(flatlumpnum);
UINT16 flatflag = R_GetFlatSize(len) - 1; UINT16 flatflag = R_GetFlatSize(len);
double dflatsize = (double)(flatflag + 1); double dflatsize = (double)(flatflag);
// compilers are COOL!
float dup = (float)vid.dup;
float fx = (float)x * dup;
float fy = (float)y * dup;
float fw = (float)w * dup;
float fh = (float)h * dup;
/*
fx *= dup;
fy *= dup;
fw *= dup;
fh *= dup;
*/
if (fw <= 0 || fh <= 0)
return;
if (fabsf((float)vid.width - (float)BASEVIDWIDTH * vid.dup) > 1.0E-36f)
{
fx += ((float)vid.width - ((float)BASEVIDWIDTH * vid.dup)) / 2;
}
if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * vid.dup) > 1.0E-36f)
{
fy += ((float)vid.height - ((float)BASEVIDHEIGHT * vid.dup)) / 2;
}
if (fx >= vid.width || fy >= vid.height)
return;
fx = -1.0f + (fx / (vid.width / 2.0f));
fy = 1.0f - (fy / (vid.height / 2.0f));
fw /= vid.width / 2;
fh /= vid.height / 2;
// 3--2 // 3--2
// | /| // | /|
// |/ | // |/ |
// 0--1 // 0--1
v[0].x = v[3].x = (x - 160.0f)/160.0f; // position vertices
v[2].x = v[1].x = ((x+w) - 160.0f)/160.0f; v[0].x = v[3].x = fx;
v[0].y = v[1].y = -(y - 100.0f)/100.0f; v[2].x = v[1].x = fx + fw;
v[2].y = v[3].y = -((y+h) - 100.0f)/100.0f;
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].z = v[1].z = v[2].z = v[3].z = 1.0f;
v[0].s = v[3].s = (float)((x & flatflag)/dflatsize); // sides
v[2].s = v[1].s = (float)(v[0].s + w/dflatsize); v[0].s = v[3].s = (float)(flatflag/dflatsize) * 2;
v[0].t = v[1].t = (float)((y & flatflag)/dflatsize); v[2].s = v[1].s = (float)(v[0].s + w/dflatsize) * 2;
v[2].t = v[3].t = (float)(v[0].t + h/dflatsize);
HWR_GetRawFlat(flatlumpnum); // top/bottom
v[0].t = v[1].t = (float)(flatflag/dflatsize) * 2;
v[2].t = v[3].t = (float)(v[0].t + h/dflatsize) * 2;
//Hurdler: Boris, the same comment as above... but maybe for pics // needed to texture the poly
// it not a problem since they don't have any transparent pixel HWR_GetRawFlat(flatlumpnum);
// if I'm right !?
// BTW, I see we put 0 for PFs, and If I'm right, that
// means we take the previous PFs as default
// how can we be sure they are ok?
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent); HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Fade down the screen so that the menu drawn on top of it looks brighter // Fade down the screen so that the menu drawn on top of it looks brighter
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -1140,10 +1173,12 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT32 ...@@ -1140,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) void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
{ {
FOutVector v[4]; FOutVector v[4];
FBITFIELD flags;
FSurfaceInfo Surf; FSurfaceInfo Surf;
float fx, fy, fw, fh; float fx, fy, fw, fh;
RGBA_t *palette = HWR_GetTexturePalette(); RGBA_t *palette = HWR_GetTexturePalette();
UINT8 alphalevel = ((color & V_ALPHAMASK) >> V_ALPHASHIFT); UINT8 alphalevel = ((color & V_ALPHAMASK) >> V_ALPHASHIFT);
UINT8 blendmode = ((color & V_BLENDMASK) >> V_BLENDSHIFT);
UINT8 perplayershuffle = 0; UINT8 perplayershuffle = 0;
...@@ -1308,6 +1343,199 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) ...@@ -1308,6 +1343,199 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
Surf.PolyColor = palette[color&0xFF]; 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)
{ {
if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; // V_HUDTRANSHALF if (alphalevel == 10) Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; // V_HUDTRANSHALF
...@@ -1317,7 +1545,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) ...@@ -1317,7 +1545,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
} }
HWD.pfnDrawPolygon(&Surf, v, 4, HWD.pfnDrawPolygon(&Surf, v, 4,
PF_Modulated|PF_NoTexture|PF_NoDepthTest|PF_Translucent); flags);
} }
#ifdef HAVE_PNG #ifdef HAVE_PNG
......
...@@ -43,6 +43,7 @@ void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipma ...@@ -43,6 +43,7 @@ void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipma
void HWR_CreatePlanePolygons(INT32 bspnum); void HWR_CreatePlanePolygons(INT32 bspnum);
void HWR_CreateStaticLightmaps(INT32 bspnum); void HWR_CreateStaticLightmaps(INT32 bspnum);
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); 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_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. 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.
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "lua_hud.h" #include "lua_hud.h"
#include "lua_hudlib_drawlist.h" #include "lua_hudlib_drawlist.h"
#include "lua_hook.h" #include "lua_hook.h"
#include "lua_libs.h"
// coords are scaled // coords are scaled
#define HU_INPUTX 0 #define HU_INPUTX 0
...@@ -396,7 +397,10 @@ void HU_AddChatText(const char *text, boolean playsound) ...@@ -396,7 +397,10 @@ void HU_AddChatText(const char *text, boolean playsound)
if (OLDCHAT) // if we're using oldchat, print directly in console if (OLDCHAT) // if we're using oldchat, print directly in console
CONS_Printf("%s\n", text); CONS_Printf("%s\n", text);
else // if we aren't, still save the message to log.txt else // if we aren't, still save the message to log.txt
CON_LogMessage(va("%s\n", text)); {
CON_LogMessage(text);
CON_LogMessage("\n"); // Add newline. Don't use va for that, since `text` might be refering to va's buffer itself
}
} }
/** Runs a say command, sending an ::XD_SAY message. /** Runs a say command, sending an ::XD_SAY message.
...@@ -1013,7 +1017,7 @@ static void HU_sendChatMessage(void) ...@@ -1013,7 +1017,7 @@ static void HU_sendChatMessage(void)
void HU_clearChatChars(void) void HU_clearChatChars(void)
{ {
memset(w_chat, '\0', sizeof(w_chat)); memset(w_chat, '\0', sizeof(w_chat));
I_SetTextInputMode(false); I_SetTextInputMode(textinputmodeenabledbylua);
chat_on = false; chat_on = false;
c_input = 0; c_input = 0;
...@@ -1150,7 +1154,7 @@ boolean HU_Responder(event_t *ev) ...@@ -1150,7 +1154,7 @@ boolean HU_Responder(event_t *ev)
if (!CHAT_MUTE) if (!CHAT_MUTE)
HU_sendChatMessage(); HU_sendChatMessage();
I_SetTextInputMode(false); I_SetTextInputMode(textinputmodeenabledbylua);
chat_on = false; chat_on = false;
c_input = 0; // reset input cursor c_input = 0; // reset input cursor
chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :) chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :)
...@@ -1161,7 +1165,7 @@ boolean HU_Responder(event_t *ev) ...@@ -1161,7 +1165,7 @@ boolean HU_Responder(event_t *ev)
|| c == gamecontrol[GC_TEAMKEY][0] || c == gamecontrol[GC_TEAMKEY][1]) || c == gamecontrol[GC_TEAMKEY][0] || c == gamecontrol[GC_TEAMKEY][1])
&& c >= KEY_MOUSE1)) // If it's not a keyboard key, then the chat button is used as a toggle. && c >= KEY_MOUSE1)) // If it's not a keyboard key, then the chat button is used as a toggle.
{ {
I_SetTextInputMode(false); I_SetTextInputMode(textinputmodeenabledbylua);
chat_on = false; chat_on = false;
c_input = 0; // reset input cursor c_input = 0; // reset input cursor
I_UpdateMouseGrab(); I_UpdateMouseGrab();
...@@ -1747,6 +1751,9 @@ static void HU_DrawDemoInfo(void) ...@@ -1747,6 +1751,9 @@ static void HU_DrawDemoInfo(void)
// Heads up displays drawer, call each frame // Heads up displays drawer, call each frame
// //
void HU_Drawer(void) void HU_Drawer(void)
{
if (LUA_HudEnabled(hud_chat))
{ {
// draw chat string plus cursor // draw chat string plus cursor
if (chat_on) if (chat_on)
...@@ -1764,8 +1771,9 @@ void HU_Drawer(void) ...@@ -1764,8 +1771,9 @@ void HU_Drawer(void)
if (!OLDCHAT && cv_consolechat.value < 2 && netgame) // Don't display minimized chat if you set the mode to Window (Hidden) 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. HU_drawMiniChat(); // draw messages in a cool fashion.
} }
}
if (cechotimer) if (cechotimer && LUA_HudEnabled(hud_cecho))
HU_DrawCEcho(); HU_DrawCEcho();
if (demoplayback && hu_showscores) if (demoplayback && hu_showscores)
......
...@@ -4518,7 +4518,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = ...@@ -4518,7 +4518,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
sfx_pop, // deathsound sfx_pop, // deathsound
0, // speed 0, // speed
12*FRACUNIT, // radius 12*FRACUNIT, // radius
64*FRACUNIT, // height 32*FRACUNIT, // height
0, // display offset 0, // display offset
100, // mass 100, // mass
0, // damage 0, // damage
......
...@@ -189,6 +189,8 @@ static const struct { ...@@ -189,6 +189,8 @@ static const struct {
{META_SKINSPRITESLIST, "skin_t.skinsprites[]"}, {META_SKINSPRITESLIST, "skin_t.skinsprites[]"},
{META_SKINSPRITESCOMPAT, "skin_t.sprites"}, // TODO: 2.3: Delete {META_SKINSPRITESCOMPAT, "skin_t.sprites"}, // TODO: 2.3: Delete
{META_MUSICDEF, "musicdef_t"},
{META_VERTEX, "vertex_t"}, {META_VERTEX, "vertex_t"},
{META_LINE, "line_t"}, {META_LINE, "line_t"},
{META_SIDE, "side_t"}, {META_SIDE, "side_t"},
...@@ -238,7 +240,10 @@ static const struct { ...@@ -238,7 +240,10 @@ static const struct {
{META_LUABANKS, "luabanks[]"}, {META_LUABANKS, "luabanks[]"},
{META_KEYEVENT, "keyevent_t"}, {META_KEYEVENT, "keyevent_t"},
{META_TEXTEVENT, "textevent_t"},
{META_MOUSE, "mouse_t"}, {META_MOUSE, "mouse_t"},
{META_INTERCEPT, "intercept_t"},
{NULL, NULL} {NULL, NULL}
}; };
...@@ -3738,6 +3743,73 @@ static int lib_sResumeMusic(lua_State *L) ...@@ -3738,6 +3743,73 @@ static int lib_sResumeMusic(lua_State *L)
return 1; 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 // G_GAME
//////////// ////////////
...@@ -4623,6 +4695,7 @@ static luaL_Reg lib[] = { ...@@ -4623,6 +4695,7 @@ static luaL_Reg lib[] = {
{"S_GetMusicLoopPoint",lib_sGetMusicLoopPoint}, {"S_GetMusicLoopPoint",lib_sGetMusicLoopPoint},
{"S_PauseMusic",lib_sPauseMusic}, {"S_PauseMusic",lib_sPauseMusic},
{"S_ResumeMusic", lib_sResumeMusic}, {"S_ResumeMusic", lib_sResumeMusic},
{"S_MusicInfo", lib_sMusicInfo},
// g_game // g_game
{"G_AddGametype", lib_gAddGametype}, {"G_AddGametype", lib_gAddGametype},
...@@ -4661,6 +4734,11 @@ static luaL_Reg lib[] = { ...@@ -4661,6 +4734,11 @@ static luaL_Reg lib[] = {
int LUA_BaseLib(lua_State *L) 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 // Set metatable for string
lua_pushliteral(L, ""); // dummy string lua_pushliteral(L, ""); // dummy string
lua_getmetatable(L, -1); // get string metatable lua_getmetatable(L, -1); // get string metatable
......
...@@ -67,7 +67,9 @@ automatically. ...@@ -67,7 +67,9 @@ automatically.
X (ViewpointSwitch),/* spy mode (no trickstabs) */\ X (ViewpointSwitch),/* spy mode (no trickstabs) */\
X (SeenPlayer),/* MT_NAMECHECK */\ X (SeenPlayer),/* MT_NAMECHECK */\
X (PlayerThink),/* P_PlayerThink */\ X (PlayerThink),/* P_PlayerThink */\
X (GameStart),\
X (GameQuit),\ X (GameQuit),\
X (GameEnd),\
X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\ X (PlayerCmd),/* building the player's ticcmd struct (Ported from SRB2Kart) */\
X (MusicChange),\ X (MusicChange),\
X (PlayerHeight),/* override player height */\ X (PlayerHeight),/* override player height */\
...@@ -75,6 +77,7 @@ automatically. ...@@ -75,6 +77,7 @@ automatically.
X (AddonLoaded),\ X (AddonLoaded),\
X (KeyDown),\ X (KeyDown),\
X (KeyUp),\ X (KeyUp),\
X (TextInput),\
#define STRING_HOOK_LIST(X) \ #define STRING_HOOK_LIST(X) \
X (BotAI),/* B_BuildTailsTiccmd by skin name */\ X (BotAI),/* B_BuildTailsTiccmd by skin name */\
...@@ -135,6 +138,7 @@ void LUA_HookBool(boolean value, int hook); ...@@ -135,6 +138,7 @@ void LUA_HookBool(boolean value, int hook);
int LUA_HookPlayer(player_t *, int hook); int LUA_HookPlayer(player_t *, int hook);
int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook); int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook);
int LUA_HookKey(event_t *event, int hook); // Hooks for key events int LUA_HookKey(event_t *event, int hook); // Hooks for key events
int LUA_HookText(event_t *event, int hook); // Hooks for text events
void LUA_HookPreThinkFrame(void); void LUA_HookPreThinkFrame(void);
void LUA_HookThinkFrame(void); void LUA_HookThinkFrame(void);
......
...@@ -690,6 +690,17 @@ int LUA_HookKey(event_t *event, int hook_type) ...@@ -690,6 +690,17 @@ int LUA_HookKey(event_t *event, int hook_type)
return hook.status; return hook.status;
} }
int LUA_HookText(event_t *event, int hook_type)
{
Hook_State hook;
if (prepare_hook(&hook, false, hook_type))
{
LUA_PushUserdata(gL, event, META_TEXTEVENT);
call_hooks(&hook, 1, res_true);
}
return hook.status;
}
void LUA_HookHUD(int hook_type, huddrawlist_h list) void LUA_HookHUD(int hook_type, huddrawlist_h list)
{ {
Hook_State hook; Hook_State hook;
......
...@@ -20,6 +20,10 @@ enum hud { ...@@ -20,6 +20,10 @@ enum hud {
hud_textspectator, hud_textspectator,
hud_crosshair, hud_crosshair,
hud_powerups, hud_powerups,
hud_gameover,
hud_pause,
hud_cecho,
hud_chat,
// Singleplayer / Co-op // Singleplayer / Co-op
hud_score, hud_score,
hud_time, hud_time,
...@@ -30,6 +34,7 @@ enum hud { ...@@ -30,6 +34,7 @@ enum hud {
hud_weaponrings, hud_weaponrings,
hud_powerstones, hud_powerstones,
hud_teamscores, hud_teamscores,
hud_itemhunt,
// NiGHTS mode // NiGHTS mode
hud_nightslink, hud_nightslink,
hud_nightsdrill, hud_nightsdrill,
......