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
  • 622-teamlives-hud
  • 64-gl-log
  • COM_ImmedExecute-lua
  • DJGPP
  • accel-momentum
  • add-arg-passing-alias
  • add-forth-interpreter
  • add-ipv6-indicator
  • add-namechange-lua-hook
  • add-server-pm-logging
  • add-textinput-hook
  • add-unblockable-console-key
  • alien-breed-3d
  • allow-non-important-files-dedicated
  • allow-percent-ipv6-address
  • appveyor
  • avoid-double-checkmobjtrigger-call
  • avoid-frame-cap-busywait
  • bbox
  • bbox-tweaks
  • blend-locking
  • blentran
  • blua-unary-not-fix
  • boost-tickrate
  • botchanges
  • bustablemobjzfix
  • bustablesoundz
  • checksector-refactor
  • cleanup-opengl
  • cleanupmusic
  • close-connection-timeout
  • cmake-clang-tidy
  • cmake-enable-cxx
  • cmake-valgrind
  • compile-ffast-math
  • crawlacommander-sprites
  • cutscene-cleanup
  • dd-music-bypass
  • dd-music-fix
  • deprecate-lua-dedicated-server
  • doomcom-global-refactor
  • dpl-2
  • dropshadows-spawning
  • emblem-drawing
  • ensure-ackpak-response
  • exchndl-xp-fix
  • few-kart-lua-changes
  • ffloorclip
  • fix-acknum-not-incrementing
  • fix-bot-2pai-desync
  • fix-compiler-error-touch
  • fix-cvar-conflicts
  • fix-dedicated-segfault
  • fix-move-mobj-reference
  • fix-netxcmd-integer-overflow
  • fix-opengl-shear-roll
  • fix-removemobj-seesound
  • fix-silver-segfault
  • fix-tty-not-resetting-properly
  • fix-unack-lockup
  • flipfuncpointers
  • floorsprite-and-shadow-fake-planes-fix
  • fof-lightlist-fixes
  • font-FUCK
  • font_drawer
  • forceverticalflipflag
  • forkmaster
  • frictionrefactor
  • fuck-macros-1
  • fullscreen-toggle
  • gamepad-luakeydown
  • gamepad-morefixes
  • gamepad_experiments
  • ghost-networking
  • gif-splitting
  • gitlab-ci
  • grr-lj
  • hitboxviewer
  • hwr-texture-cache-refactor
  • hwrender2
  • improve-439
  • increase-packet-tics
  • increase-unlockables
  • inline-mobjwasremoved
  • input-display
  • input-display-translucency
  • io
  • io-limit
  • ipv6
  • joystick-juggling-maz
  • keycodes-only
  • ksf-wadfiles
  • 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.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
138 results
Show changes
Showing with 717 additions and 105 deletions
......@@ -77,6 +77,31 @@ typedef struct
INT16 x, y;
}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.
typedef struct
......@@ -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);\
}\
}
......
......@@ -2270,6 +2270,11 @@ boolean G_LuaResponder(event_t *ev)
cancelled = LUA_HookKey(ev, HOOK(KeyUp));
LUA_InvalidateUserdata(ev);
}
else if (ev->type == ev_text)
{
cancelled = LUA_HookText(ev, HOOK(TextInput));
LUA_InvalidateUserdata(ev);
}
return cancelled;
}
......@@ -4335,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,11 +483,14 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex, GLMipmap_t
realpatch = W_CachePatchNumPwad(wadnum, lumpnum, PU_PATCH);
}
if (realpatch != NULL)
{
HWR_DrawTexturePatchInCache(mipmap, blockwidth, blockheight, texture, patch, 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)
{
......
......@@ -256,8 +256,8 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
}
// positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1
cx = -1 + (cx / (vid.width/2));
cy = 1 - (cy / (vid.height/2));
cx = -1.0f + (cx / (vid.width / 2.0f));
cy = 1.0f - (cy / (vid.height / 2.0f));
// fwidth and fheight are similar
fwidth /= vid.width / 2;
......@@ -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
// 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)
{
FOutVector v[4];
const size_t len = W_LumpLength(flatlumpnum);
UINT16 flatflag = R_GetFlatSize(len) - 1;
double dflatsize = (double)(flatflag + 1);
UINT16 flatflag = R_GetFlatSize(len);
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
// | /|
// |/ |
// 0--1
v[0].x = v[3].x = (x - 160.0f)/160.0f;
v[2].x = v[1].x = ((x+w) - 160.0f)/160.0f;
v[0].y = v[1].y = -(y - 100.0f)/100.0f;
v[2].y = v[3].y = -((y+h) - 100.0f)/100.0f;
// position vertices
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 = (float)((x & flatflag)/dflatsize);
v[2].s = v[1].s = (float)(v[0].s + w/dflatsize);
v[0].t = v[1].t = (float)((y & flatflag)/dflatsize);
v[2].t = v[3].t = (float)(v[0].t + h/dflatsize);
// sides
v[0].s = v[3].s = (float)(flatflag/dflatsize) * 2;
v[2].s = v[1].s = (float)(v[0].s + w/dflatsize) * 2;
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
// it not a problem since they don't have any transparent pixel
// 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?
// needed to texture the poly
HWR_GetRawFlat(flatlumpnum);
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
}
// --------------------------------------------------------------------------
// 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
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;
......@@ -1308,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
......@@ -1317,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
......
......@@ -2671,45 +2671,31 @@ fixed_t *hwbbox;
static void HWR_RenderBSPNode(INT32 bspnum)
{
node_t *bsp = &nodes[bspnum];
// Decide which side the view point is on
node_t *bsp;
INT32 side;
ps_numbspcalls.value.i++;
// Found a subsector?
if (bspnum & NF_SUBSECTOR)
{
if (bspnum == -1)
{
//*(gl_drawsubsector_p++) = 0;
HWR_Subsector(0);
}
else
while (!(bspnum & NF_SUBSECTOR)) // Found a subsector?
{
//*(gl_drawsubsector_p++) = bspnum&(~NF_SUBSECTOR);
HWR_Subsector(bspnum&(~NF_SUBSECTOR));
}
return;
}
bsp = &nodes[bspnum];
// Decide which side the view point is on.
side = R_PointOnSide(viewx, viewy, bsp);
// BP: big hack for a test in lighning ref : 1249753487AB
hwbbox = bsp->bbox[side];
// Recursively divide front space.
HWR_RenderBSPNode(bsp->children[side]);
// Possibly divide back space.
if (HWR_CheckBBox(bsp->bbox[side^1]))
{
// BP: big hack for a test in lighning ref : 1249753487AB
hwbbox = bsp->bbox[side^1];
HWR_RenderBSPNode(bsp->children[side^1]);
if (!HWR_CheckBBox(bsp->bbox[side^1]))
return;
bspnum = bsp->children[side^1];
}
HWR_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR);
}
// ==========================================================================
......@@ -5675,7 +5661,6 @@ void HWR_LoadLevel(void)
// ==========================================================================
static CV_PossibleValue_t glshaders_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Ignore custom shaders"}, {0, NULL}};
static CV_PossibleValue_t glmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}};
static CV_PossibleValue_t glfakecontrast_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}};
static CV_PossibleValue_t glshearing_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Third-person"}, {0, NULL}};
......@@ -5704,7 +5689,7 @@ consvar_t cv_glcoronasize = CVAR_INIT ("gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0
#endif
consvar_t cv_glmodels = CVAR_INIT ("gr_models", "Off", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glmodelinterpolation = CVAR_INIT ("gr_modelinterpolation", "Sometimes", CV_SAVE, glmodelinterpolation_cons_t, NULL);
consvar_t cv_glmodelinterpolation = CVAR_INIT ("gr_modelinterpolation", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_glmodellighting = CVAR_INIT ("gr_modellighting", "Off", CV_SAVE|CV_CALL, CV_OnOff, CV_glmodellighting_OnChange);
consvar_t cv_glshearing = CVAR_INIT ("gr_shearing", "Off", CV_SAVE, glshearing_cons_t, NULL);
......
......@@ -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.
......
......@@ -1062,15 +1062,11 @@ static boolean HWR_AllowModel(mobj_t *mobj)
static boolean HWR_CanInterpolateModel(mobj_t *mobj, model_t *model)
{
if (cv_glmodelinterpolation.value == 2) // Always interpolate
return true;
return model->interpolate[(mobj->frame & FF_FRAMEMASK)];
}
static boolean HWR_CanInterpolateSprite2(modelspr2frames_t *spr2frame)
{
if (cv_glmodelinterpolation.value == 2) // Always interpolate
return true;
return spr2frame->interpolate;
}
......
......@@ -52,6 +52,7 @@
#include "lua_hud.h"
#include "lua_hudlib_drawlist.h"
#include "lua_hook.h"
#include "lua_libs.h"
// coords are scaled
#define HU_INPUTX 0
......@@ -396,7 +397,10 @@ void HU_AddChatText(const char *text, boolean playsound)
if (OLDCHAT) // if we're using oldchat, print directly in console
CONS_Printf("%s\n", text);
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.
......@@ -1013,7 +1017,7 @@ static void HU_sendChatMessage(void)
void HU_clearChatChars(void)
{
memset(w_chat, '\0', sizeof(w_chat));
I_SetTextInputMode(false);
I_SetTextInputMode(textinputmodeenabledbylua);
chat_on = false;
c_input = 0;
......@@ -1150,7 +1154,7 @@ boolean HU_Responder(event_t *ev)
if (!CHAT_MUTE)
HU_sendChatMessage();
I_SetTextInputMode(false);
I_SetTextInputMode(textinputmodeenabledbylua);
chat_on = false;
c_input = 0; // reset input cursor
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)
|| 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.
{
I_SetTextInputMode(false);
I_SetTextInputMode(textinputmodeenabledbylua);
chat_on = false;
c_input = 0; // reset input cursor
I_UpdateMouseGrab();
......@@ -1747,6 +1751,9 @@ static void HU_DrawDemoInfo(void)
// Heads up displays drawer, call each frame
//
void HU_Drawer(void)
{
if (LUA_HudEnabled(hud_chat))
{
// draw chat string plus cursor
if (chat_on)
......@@ -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)
HU_drawMiniChat(); // draw messages in a cool fashion.
}
}
if (cechotimer)
if (cechotimer && LUA_HudEnabled(hud_cecho))
HU_DrawCEcho();
if (demoplayback && hu_showscores)
......
......@@ -2,7 +2,7 @@
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2024 by Sonic Team Junior.
// Copyright (C) 1999-2025 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
......@@ -4187,7 +4187,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_JETFUMEFLASH, // meleestate
S_NULL, // missilestate
S_NULL, // deathstate
S_NULL, // xdeathstate
......@@ -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"},
......@@ -238,7 +240,10 @@ static const struct {
{META_LUABANKS, "luabanks[]"},
{META_KEYEVENT, "keyevent_t"},
{META_TEXTEVENT, "textevent_t"},
{META_MOUSE, "mouse_t"},
{META_INTERCEPT, "intercept_t"},
{NULL, NULL}
};
......@@ -3166,7 +3171,10 @@ static int lib_rCheckTextureNumForName(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
//HUDSAFE
lua_pushinteger(L, R_CheckTextureNumForName(name));
INT32 num = R_CheckTextureNumForName(name, TEXTURETYPE_TEXTURE);
if (num == -1)
num = R_CheckTextureNumForName(name, TEXTURETYPE_FLAT);
lua_pushinteger(L, num);
return 1;
}
......@@ -3735,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
////////////
......@@ -4620,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},
......@@ -4658,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 */\
......@@ -75,6 +77,7 @@ automatically.
X (AddonLoaded),\
X (KeyDown),\
X (KeyUp),\
X (TextInput),\
#define STRING_HOOK_LIST(X) \
X (BotAI),/* B_BuildTailsTiccmd by skin name */\
......@@ -135,6 +138,7 @@ void LUA_HookBool(boolean value, int hook);
int LUA_HookPlayer(player_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_HookText(event_t *event, int hook); // Hooks for text events
void LUA_HookPreThinkFrame(void);
void LUA_HookThinkFrame(void);
......
......@@ -690,6 +690,17 @@ int LUA_HookKey(event_t *event, int hook_type)
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)
{
Hook_State hook;
......
......@@ -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",
......@@ -461,15 +466,29 @@ static int camera_set(lua_State *L)
static int libd_patchExists(lua_State *L)
{
HUDONLY
lua_pushboolean(L, W_LumpExists(luaL_checkstring(L, 1)));
return 1;
}
static int libd_cachePatch(lua_State *L)
{
HUDONLY
LUA_PushUserdata(L, W_CachePatchLongName(luaL_checkstring(L, 1), PU_PATCH), META_PATCH);
const char *name = luaL_checkstring(L, 1);
patch_t *patch = W_CachePatchLongName(name, PU_PATCH);
#ifdef ROTSPRITE
if (lua_isnumber(L, 2))
{
angle_t rollangle = luaL_checkangle(L, 2);
INT32 rot = R_GetRollAngle(rollangle);
if (rot) {
patch_t *rotpatch = Patch_GetRotated(patch, rot, false);
LUA_PushUserdata(L, rotpatch, META_PATCH);
return 1;
}
}
#endif
LUA_PushUserdata(L, patch, META_PATCH);
return 1;
}
......@@ -481,7 +500,6 @@ static int libd_getSpritePatch(lua_State *L)
UINT8 angle = 0;
spritedef_t *sprdef;
spriteframe_t *sprframe;
HUDONLY
if (lua_isnumber(L, 1)) // sprite number given, e.g. SPR_THOK
{
......@@ -555,7 +573,6 @@ static int libd_getSprite2Patch(lua_State *L)
spritedef_t *sprdef;
spriteframe_t *sprframe;
boolean super = false; // add SPR2F_SUPER to sprite2 if true
HUDONLY
// get skin first!
if (lua_isnumber(L, 1)) // find skin by number
......@@ -875,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;
......@@ -1130,13 +1169,12 @@ static int libd_levelTitleHeight(lua_State *L)
static int libd_getColormap(lua_State *L)
{
HUDONLY
INT32 skinnum = TC_DEFAULT;
skincolornum_t color = luaL_optinteger(L, 2, 0);
UINT8* colormap = NULL;
int translation_id = -1;
HUDONLY
if (lua_isnoneornil(L, 1))
; // defaults to TC_DEFAULT
else if (lua_type(L, 1) == LUA_TNUMBER) // skin number
......@@ -1176,9 +1214,10 @@ static int libd_getColormap(lua_State *L)
static int libd_getStringColormap(lua_State *L)
{
HUDONLY
INT32 flags = luaL_checkinteger(L, 1);
UINT8* colormap = NULL;
HUDONLY
colormap = V_GetStringColormap(flags & V_CHARCOLORMASK);
if (colormap) {
LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use!
......@@ -1189,6 +1228,7 @@ static int libd_getStringColormap(lua_State *L)
static int libd_getSectorColormap(lua_State *L)
{
HUDONLY
boolean has_sector = false;
sector_t *sector = NULL;
if (!lua_isnoneornil(L, 1))
......@@ -1264,21 +1304,18 @@ static int libd_fadeScreen(lua_State *L)
static int libd_width(lua_State *L)
{
HUDONLY
lua_pushinteger(L, vid.width); // push screen width
return 1;
}
static int libd_height(lua_State *L)
{
HUDONLY
lua_pushinteger(L, vid.height); // push screen height
return 1;
}
static int libd_dup(lua_State *L)
{
HUDONLY
lua_pushinteger(L, vid.dup); // push integral scale (patch scale)
lua_pushfixed(L, vid.fdup); // push fixed point scale (position scale)
return 2;
......@@ -1286,7 +1323,6 @@ static int libd_dup(lua_State *L)
static int libd_renderer(lua_State *L)
{
HUDONLY
switch (rendermode) {
case render_opengl: lua_pushliteral(L, "opengl"); break; // OpenGL renderer
case render_soft: lua_pushliteral(L, "software"); break; // Software renderer
......@@ -1300,14 +1336,12 @@ static int libd_renderer(lua_State *L)
static int libd_RandomFixed(lua_State *L)
{
HUDONLY
lua_pushfixed(L, M_RandomFixed());
return 1;
}
static int libd_RandomByte(lua_State *L)
{
HUDONLY
lua_pushinteger(L, M_RandomByte());
return 1;
}
......@@ -1316,7 +1350,6 @@ static int libd_RandomKey(lua_State *L)
{
INT32 a = (INT32)luaL_checkinteger(L, 1);
HUDONLY
lua_pushinteger(L, M_RandomKey(a));
return 1;
}
......@@ -1326,7 +1359,6 @@ static int libd_RandomRange(lua_State *L)
INT32 a = (INT32)luaL_checkinteger(L, 1);
INT32 b = (INT32)luaL_checkinteger(L, 2);
HUDONLY
lua_pushinteger(L, M_RandomRange(a, b));
return 1;
}
......@@ -1334,7 +1366,6 @@ static int libd_RandomRange(lua_State *L)
// Macros.
static int libd_SignedRandom(lua_State *L)
{
HUDONLY
lua_pushinteger(L, M_SignedRandom());
return 1;
}
......@@ -1342,7 +1373,6 @@ static int libd_SignedRandom(lua_State *L)
static int libd_RandomChance(lua_State *L)
{
fixed_t p = luaL_checkfixed(L, 1);
HUDONLY
lua_pushboolean(L, M_RandomChance(p));
return 1;
}
......@@ -1351,7 +1381,6 @@ static int libd_RandomChance(lua_State *L)
// Could as well be thrown in global vars for ease of access but I guess it makes sense for it to be a HUD fn
static int libd_getlocaltransflag(lua_State *L)
{
HUDONLY
lua_pushinteger(L, (10-st_translucency)*V_10TRANS);
return 1;
}
......@@ -1359,7 +1388,6 @@ static int libd_getlocaltransflag(lua_State *L)
// Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int
static int libd_getusertransflag(lua_State *L)
{
HUDONLY
lua_pushinteger(L, (10-cv_translucenthud.value)*V_10TRANS); // A bit weird that it's called "translucenthud" yet 10 is fully opaque :V
return 1;
}
......@@ -1381,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},
......@@ -1452,6 +1481,26 @@ static luaL_Reg lib_hud[] = {
{"disable", lib_huddisable},
{"enabled", lib_hudenabled},
{"add", lib_hudadd},
{"patchExists", libd_patchExists},
{"cachePatch", libd_cachePatch},
{"getSpritePatch", libd_getSpritePatch},
{"getSprite2Patch", libd_getSprite2Patch},
{"width", libd_width},
{"height", libd_height},
{"scale", libd_dup},
{"renderer", libd_renderer},
{NULL, NULL}
};
// globalized client_side random functions.
static luaL_Reg lib_randomclient[] = {
// m_random
{"localFixed",libd_RandomFixed},
{"localByte",libd_RandomByte},
{"localKey",libd_RandomKey},
{"localRange",libd_RandomRange},
{"localSignedRandom",libd_SignedRandom}, // MACRO
{"localChance",libd_RandomChance}, // MACRO
{NULL, NULL}
};
......@@ -1478,6 +1527,7 @@ int LUA_HudLib(lua_State *L)
LUA_RegisterGlobalUserdata(L, "hudinfo", lib_getHudInfo, NULL, lib_hudinfolen);
luaL_register(L, "hud", lib_hud);
luaL_register(L, "random", lib_randomclient);
return 0;
}
......
......@@ -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,
......
......@@ -1158,6 +1158,7 @@ enum mobjinfo_e
mobjinfo_activesound,
mobjinfo_flags,
mobjinfo_raisestate,
mobjinfo_name,
};
const char *const mobjinfo_opt[] = {
......@@ -1185,6 +1186,7 @@ const char *const mobjinfo_opt[] = {
"activesound",
"flags",
"raisestate",
"name",
NULL,
};
......@@ -1199,6 +1201,8 @@ static int mobjinfo_get(lua_State *L)
I_Assert(info != NULL);
I_Assert(info >= mobjinfo);
mobjtype_t id = info-mobjinfo;
switch (field)
{
case mobjinfo_doomednum:
......@@ -1273,6 +1277,21 @@ static int mobjinfo_get(lua_State *L)
case mobjinfo_raisestate:
lua_pushinteger(L, info->raisestate);
break;
case mobjinfo_name:
if (id < MT_FIRSTFREESLOT)
{
lua_pushstring(L, MOBJTYPE_LIST[id]+3);
return 1;
}
id -= MT_FIRSTFREESLOT;
if (id < NUMMOBJFREESLOTS && FREE_MOBJS[id])
{
lua_pushstring(L, FREE_MOBJS[id]);
return 1;
}
return 0;
default:
lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS);
I_Assert(lua_istable(L, -1));
......
......@@ -10,16 +10,19 @@
/// \brief input library for Lua scripting
#include "doomdef.h"
#include "doomstat.h"
#include "fastcmp.h"
#include "g_input.h"
#include "g_game.h"
#include "hu_stuff.h"
#include "i_system.h"
#include "console.h"
#include "lua_script.h"
#include "lua_libs.h"
boolean mousegrabbedbylua = true;
boolean textinputmodeenabledbylua = false;
boolean ignoregameinputs = false;
///////////////
......@@ -129,6 +132,20 @@ static int lib_getCursorPosition(lua_State *L)
return 2;
}
static int lib_setTextInputMode(lua_State *L)
{
textinputmodeenabledbylua = luaL_checkboolean(L, 1);
if (!(menuactive || CON_Ready() || chat_on))
I_SetTextInputMode(textinputmodeenabledbylua);
return 0;
}
static int lib_getTextInputMode(lua_State *L)
{
lua_pushinteger(L, textinputmodeenabledbylua);
return 1;
}
static luaL_Reg lib[] = {
{"gameControlDown", lib_gameControlDown},
{"gameControl2Down", lib_gameControl2Down},
......@@ -143,6 +160,8 @@ static luaL_Reg lib[] = {
{"getMouseGrab", lib_getMouseGrab},
{"setMouseGrab", lib_setMouseGrab},
{"getCursorPosition", lib_getCursorPosition},
{"setTextInputMode", lib_setTextInputMode},
{"getTextInputMode", lib_getTextInputMode},
{NULL, NULL}
};
......@@ -220,6 +239,28 @@ static int lib_lenGameKeyDown(lua_State *L)
return 1;
}
////////////////
// TEXT EVENT //
////////////////
static int textevent_get(lua_State *L)
{
event_t *event = *((event_t **)luaL_checkudata(L, 1, META_TEXTEVENT));
const char *field = luaL_checkstring(L, 2);
I_Assert(event != NULL);
if (fastcmp(field,"text"))
{
char s[2] = { event->key, 0 };
lua_pushstring(L, s);
}
else
return luaL_error(L, "textevent_t has no field named %s", field);
return 1;
}
///////////////
// KEY EVENT //
///////////////
......@@ -285,6 +326,7 @@ static int mouse_num(lua_State *L)
int LUA_InputLib(lua_State *L)
{
LUA_RegisterUserdataMetatable(L, META_TEXTEVENT, textevent_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_KEYEVENT, keyevent_get, NULL, NULL);
LUA_RegisterUserdataMetatable(L, META_MOUSE, mouse_get, NULL, mouse_num);
......
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2024-2024 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file lua_interceptlib.c
/// \brief intercept library for Lua scripting
#include "doomdef.h"
#include "fastcmp.h"
#include "p_local.h"
#include "lua_script.h"
#include "lua_libs.h"
#include "lua_hud.h" // hud_running errors
#define NOHUD if (hud_running)\
return luaL_error(L, "HUD rendering code should not call this function!");
enum intercept_e {
intercept_valid = 0,
intercept_frac,
intercept_thing,
intercept_line
};
static const char *const intercept_opt[] = {
"valid",
"frac",
"thing",
"line",
NULL};
static int intercept_fields_ref = LUA_NOREF;
static boolean Lua_PathTraverser(intercept_t *in)
{
boolean traverse = false;
I_Assert(in != NULL);
lua_settop(gL, 6);
lua_pushcfunction(gL, LUA_GetErrorMessage);
I_Assert(lua_isfunction(gL, -2));
lua_pushvalue(gL, -2);
LUA_PushUserdata(gL, in, META_INTERCEPT);
LUA_Call(gL, 1, 1, -3);
traverse = lua_toboolean(gL, -1);
lua_pop(gL, 1);
return !traverse; // Stay consistent with the MobjMoveCollide hook
}
static int intercept_get(lua_State *L)
{
intercept_t *in = *((intercept_t **)luaL_checkudata(L, 1, META_INTERCEPT));
enum intercept_e field = Lua_optoption(L, 2, intercept_valid, intercept_fields_ref);
if (!in)
{
if (field == intercept_valid) {
lua_pushboolean(L, 0);
return 1;
}
return luaL_error(L, "accessed intercept_t doesn't exist anymore.");
}
switch(field)
{
case intercept_valid: // valid
lua_pushboolean(L, 1);
return 1;
case intercept_frac:
lua_pushfixed(L, in->frac);
return 1;
case intercept_thing:
if (in->isaline)
return 0;
LUA_PushUserdata(L, in->d.thing, META_MOBJ);
return 1;
case intercept_line:
if (!in->isaline)
return 0;
LUA_PushUserdata(L, in->d.line, META_LINE);
return 1;
}
return 0;
}
static int lib_pPathTraverse(lua_State *L)
{
fixed_t px1 = luaL_checkfixed(L, 1);
fixed_t py1 = luaL_checkfixed(L, 2);
fixed_t px2 = luaL_checkfixed(L, 3);
fixed_t py2 = luaL_checkfixed(L, 4);
INT32 flags = (INT32)luaL_checkinteger(L, 5);
luaL_checktype(L, 6, LUA_TFUNCTION);
NOHUD
INLEVEL
lua_pushboolean(L, P_PathTraverse(px1, py1, px2, py2, flags, Lua_PathTraverser));
return 1;
}
int LUA_InterceptLib(lua_State *L)
{
LUA_RegisterUserdataMetatable(L, META_INTERCEPT, intercept_get, NULL, NULL);
intercept_fields_ref = Lua_CreateFieldTable(L, intercept_opt);
lua_register(L, "P_PathTraverse", lib_pPathTraverse);
return 0;
}