mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
Got_Luacmd: always read netxcmd data, even if command is not executed
This commit is contained in:
parent
63ff2f3f66
commit
c0a6d20cec
1 changed files with 12 additions and 3 deletions
|
|
@ -39,8 +39,18 @@ static void clear_lua_stack(void)
|
||||||
void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||||
{
|
{
|
||||||
UINT8 i, argc, flags;
|
UINT8 i, argc, flags;
|
||||||
|
const char *argv[256];
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
|
argc = READUINT8(*cp);
|
||||||
|
argv[0] = (const char*)*cp;
|
||||||
|
SKIPSTRINGN(*cp, 255);
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
{
|
||||||
|
argv[i] = (const char*)*cp;
|
||||||
|
SKIPSTRINGN(*cp, 255);
|
||||||
|
}
|
||||||
|
|
||||||
// don't use I_Assert here, goto the deny code below
|
// don't use I_Assert here, goto the deny code below
|
||||||
// to clean up and kick people who try nefarious exploits
|
// to clean up and kick people who try nefarious exploits
|
||||||
// like sending random junk lua commands to crash the server
|
// like sending random junk lua commands to crash the server
|
||||||
|
|
@ -53,8 +63,7 @@ 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;
|
||||||
|
|
||||||
argc = READUINT8(*cp);
|
strlcpy(buf, argv[0], 255);
|
||||||
READSTRINGN(*cp, buf, 255);
|
|
||||||
strlwr(buf); // must lowercase buffer
|
strlwr(buf); // must lowercase buffer
|
||||||
lua_getfield(gL, -1, buf); // push command info table
|
lua_getfield(gL, -1, buf); // push command info table
|
||||||
if (!lua_istable(gL, -1)) goto deny;
|
if (!lua_istable(gL, -1)) goto deny;
|
||||||
|
|
@ -90,7 +99,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||||
LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
|
LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
READSTRINGN(*cp, buf, 255);
|
strlcpy(buf, argv[i], 255);
|
||||||
lua_pushstring(gL, buf);
|
lua_pushstring(gL, buf);
|
||||||
}
|
}
|
||||||
LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too.
|
LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue