And now Lua yells at you for doing what I just fixed

This commit is contained in:
Inuyasha 2016-05-11 14:33:50 -07:00
parent fbce35d27e
commit 3235351b99
2 changed files with 15 additions and 0 deletions

View File

@ -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;
}

View File

@ -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