mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-25 11:50:50 +00:00
And now Lua yells at you for doing what I just fixed
This commit is contained in:
parent
fbce35d27e
commit
3235351b99
2 changed files with 15 additions and 0 deletions
|
@ -115,6 +115,8 @@ static int lib_pRandomKey(lua_State *L)
|
|||
INT32 a = (INT32)luaL_checkinteger(L, 1);
|
||||
|
||||
NOHUD
|
||||
if (a > 65536)
|
||||
LUA_UsageWarning(L, "P_RandomKey: range > 65536 is undefined behavior");
|
||||
lua_pushinteger(L, P_RandomKey(a));
|
||||
return 1;
|
||||
}
|
||||
|
@ -130,6 +132,8 @@ static int lib_pRandomRange(lua_State *L)
|
|||
a = b;
|
||||
b = c;
|
||||
}
|
||||
if ((b-a+1) > 65536)
|
||||
LUA_UsageWarning(L, "P_RandomRange: range > 65536 is undefined behavior");
|
||||
lua_pushinteger(L, P_RandomRange(a, b));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -81,4 +81,15 @@ void COM_Lua_f(void);
|
|||
}\
|
||||
}
|
||||
|
||||
// Warnings about incorrect function usage.
|
||||
// Shows once, then never again, like deprecation
|
||||
#define LUA_UsageWarning(L, warningmsg)\
|
||||
{\
|
||||
static UINT8 seen = 0;\
|
||||
if (!seen) {\
|
||||
seen = 1;\
|
||||
CONS_Alert(CONS_WARNING,"%s\n", warningmsg);\
|
||||
}\
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue