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
  • 64-gl-log
  • DJGPP
  • S_SKIN-missing-flag
  • appveyor
  • better-download
  • better-refusal
  • blend-locking
  • boost-tickrate
  • cleanup-opengl
  • continue_tweaks
  • crawlacommander-sprites
  • cutscene-cleanup
  • dd-music-bypass
  • dd-music-fix
  • delete-connection-screen-and-midgame-joins
  • delete-lua
  • delete-slopes
  • dofile
  • dpl-2
  • dropshadows-spawning
  • dynres
  • exchndl-xp-fix
  • fix-allowjoin
  • fix-autoexec-netvars
  • fix-cvar-conflicts
  • fix-ded-servers
  • fix-fire-shield
  • fix-input-buffer
  • fix-intermission-mouse
  • fix-keepbody-ping
  • fix-packet-name
  • fix-polyobject-rotation-crash
  • fix-rollout-rock-crash
  • fix-spawn-desynch
  • fix-splitscreen
  • fix-timeout
  • flipfuncpointers
  • flipfuncpointers-master
  • float-stepup
  • fof-lightlist-fixes
  • font-FUCK
  • fuck-macros-1
  • g_findmap-lua
  • gamepad_experiments
  • grr-lj
  • http-mserv
  • increase-input-buffer
  • increase-input-buffer-more
  • increase-packet-tics
  • input-display
  • input-display-translucency
  • inputviewer-toggle
  • io
  • join-delay
  • joystick-juggling-maz
  • keep-body
  • keycodes-only
  • ld413-mp-fix
  • libpng-version-support
  • lj-test
  • lol-states
  • long-names
  • lower-unpegged-fix
  • lua-command-netids
  • lua-hook-cleanup
  • lua-io
  • lua-local
  • makefile-tinkering
  • map-components-signedness-fixes
  • marathonmode
  • master
  • missing-gcc-flags
  • more-cleanup
  • musicdef-lua
  • netcode-tests
  • next
  • nexttest
  • no-airwalking
  • ogl-pal
  • ogl-palette-update
  • opengl-skydome-fixes
  • optimise-archiving
  • overlay-fpcam
  • palette
  • parser-fixes
  • patch-cache-refactor
  • personal
  • personal-amalgamate
  • pictureformats
  • pictureformats-depth
  • pictureformats-software
  • pivot
  • prescott-march
  • public_flatsprite
  • ra-menus
  • realtics-is-stupid
  • reduced_palette
  • remove-slopelaunchnerf
  • resend-gamestate
  • 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.2
  • SRB2_release_2.2.3
  • SRB2_release_2.2.4
  • SRB2_release_2.2.5
  • SRB2_release_2.2.6
  • td-release-v1.0.0
134 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
  • 1392-2-2-15-attempting-to-draw-a-hud-graphic-with-the-same-lump-name-as-a-lua-script-crashes-the
  • 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
  • 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
Show changes
Commits on Source (1)
...@@ -298,6 +298,7 @@ typedef struct xcommand_s ...@@ -298,6 +298,7 @@ typedef struct xcommand_s
} xcommand_t; } xcommand_t;
static xcommand_t *com_commands = NULL; // current commands static xcommand_t *com_commands = NULL; // current commands
static UINT16 com_last_netid = 1;
#define MAX_ARGS 80 #define MAX_ARGS 80
static size_t com_argc; static size_t com_argc;
...@@ -499,6 +500,18 @@ void COM_AddCommand(const char *name, com_func_t func) ...@@ -499,6 +500,18 @@ void COM_AddCommand(const char *name, com_func_t func)
com_commands = cmd; com_commands = cmd;
} }
/** Allocates a new netid for commands. Only applicable for Lua commands.
*
* \return The new netid, or zero if we ran out.
*/
UINT16 COM_NewNetID(void)
{
if (com_last_netid > 0)
return ++com_last_netid;
else
return 0;
}
/** Adds a console command for Lua. /** Adds a console command for Lua.
* No I_Errors allowed; return a negative code instead. * No I_Errors allowed; return a negative code instead.
* *
......
...@@ -36,6 +36,8 @@ enum ...@@ -36,6 +36,8 @@ enum
typedef void (*com_func_t)(void); typedef void (*com_func_t)(void);
UINT16 COM_NewNetID(void);
void COM_AddCommand(const char *name, com_func_t func); void COM_AddCommand(const char *name, com_func_t func);
int COM_AddLuaCommand(const char *name); int COM_AddLuaCommand(const char *name);
......
...@@ -33,6 +33,7 @@ static const char *cvname = NULL; ...@@ -33,6 +33,7 @@ static const char *cvname = NULL;
void Got_Luacmd(UINT8 **cp, INT32 playernum) void Got_Luacmd(UINT8 **cp, INT32 playernum)
{ {
UINT8 i, argc, flags; UINT8 i, argc, flags;
UINT16 netid;
char buf[256]; char buf[256];
// don't use I_Assert here, goto the deny code below // don't use I_Assert here, goto the deny code below
...@@ -43,10 +44,9 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum) ...@@ -43,10 +44,9 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command
if (!lua_istable(gL, -1)) goto deny; if (!lua_istable(gL, -1)) goto deny;
netid = READUINT16(*cp);
argc = READUINT8(*cp); argc = READUINT8(*cp);
READSTRINGN(*cp, buf, 255); lua_rawgeti(gL, -1, netid); // push command info table
strlwr(buf); // must lowercase buffer
lua_getfield(gL, -1, buf); // push command info table
if (!lua_istable(gL, -1)) goto deny; if (!lua_istable(gL, -1)) goto deny;
lua_remove(gL, -2); // pop COM_Command lua_remove(gL, -2); // pop COM_Command
...@@ -129,6 +129,12 @@ void COM_Lua_f(void) ...@@ -129,6 +129,12 @@ void COM_Lua_f(void)
if (netgame && !( flags & COM_LOCAL ))/* don't send local commands */ if (netgame && !( flags & COM_LOCAL ))/* don't send local commands */
{ // Send the command through the network { // Send the command through the network
UINT8 argc; UINT8 argc;
UINT16 netid;
lua_rawgeti(gL, -1, 3); // push netid from command info table
netid = lua_tonumber(gL, -1);
lua_pop(gL, -1); // pop netid
lua_pop(gL, 1); // pop command info table lua_pop(gL, 1); // pop command info table
if (flags & COM_ADMIN && !server && !IsPlayerAdmin(playernum)) // flag 1: only server/admin can use this command. if (flags & COM_ADMIN && !server && !IsPlayerAdmin(playernum)) // flag 1: only server/admin can use this command.
...@@ -144,12 +150,13 @@ void COM_Lua_f(void) ...@@ -144,12 +150,13 @@ void COM_Lua_f(void)
if (argc == UINT8_MAX) if (argc == UINT8_MAX)
len = UINT16_MAX; len = UINT16_MAX;
else else
len = (argc+1)*256; len = (argc)*256;
buf = malloc(len); buf = malloc(sizeof (UINT16) + len);
p = buf; p = buf;
WRITEUINT16(p, netid);
WRITEUINT8(p, argc); WRITEUINT8(p, argc);
for (i = 0; i < argc; i++) for (i = 1; i < argc; i++)
WRITESTRINGN(p, COM_Argv(i), 255); WRITESTRINGN(p, COM_Argv(i), 255);
if (flags & COM_SPLITSCREEN) if (flags & COM_SPLITSCREEN)
SendNetXCmd2(XD_LUACMD, buf, p-buf); SendNetXCmd2(XD_LUACMD, buf, p-buf);
...@@ -176,6 +183,8 @@ static int lib_comAddCommand(lua_State *L) ...@@ -176,6 +183,8 @@ static int lib_comAddCommand(lua_State *L)
int com_return = -1; int com_return = -1;
const char *luaname = luaL_checkstring(L, 1); const char *luaname = luaL_checkstring(L, 1);
UINT16 netid;
// must store in all lowercase // must store in all lowercase
char *name = Z_StrDup(luaname); char *name = Z_StrDup(luaname);
strlwr(name); strlwr(name);
...@@ -202,16 +211,44 @@ static int lib_comAddCommand(lua_State *L) ...@@ -202,16 +211,44 @@ static int lib_comAddCommand(lua_State *L)
lua_pushinteger(L, 0); lua_pushinteger(L, 0);
} }
if (!( lua_tonumber(L, 3) & COM_LOCAL ))
{
netid = COM_NewNetID();
if (! netid)
{ // no more netids -- free the lowercased name and return error
Z_Free(name);
return luaL_error(L,
"Couldn't add a new console command \"%s\", too many", luaname);
}
}
else
netid = 0;
lua_getfield(L, LUA_REGISTRYINDEX, "COM_Command"); lua_getfield(L, LUA_REGISTRYINDEX, "COM_Command");
I_Assert(lua_istable(L, -1)); I_Assert(lua_istable(L, -1));
lua_createtable(L, 2, 0); lua_createtable(L, ( (netid > 0) ? 3 : 2 ), 0);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
lua_rawseti(L, -2, 1); lua_rawseti(L, -2, 1);
lua_pushvalue(L, 3); lua_pushvalue(L, 3);
lua_rawseti(L, -2, 2); lua_rawseti(L, -2, 2);
lua_setfield(L, -2, name);
if (netid > 0)
{
lua_pushnumber(L, netid);
lua_rawseti(L, -2, 3);
}
if (netid > 0)
{
lua_pushvalue(L, -1);/* push the table again to reference it :V */
lua_setfield(L, -3, name);
lua_rawseti(L, -2, netid);
}
else
lua_setfield(L, -2, name);
// Try to add the Lua command // Try to add the Lua command
com_return = COM_AddLuaCommand(name); com_return = COM_AddLuaCommand(name);
......