Added < 0 checks to all three variables added in last commit
(no point checking >= MAXPLAYERS tbh, there's no reason the game would even set those values that I can think of offhand)
This commit is contained in:
parent
240aa34794
commit
fa444a37eb
|
@ -9934,17 +9934,17 @@ static inline int lib_getenum(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
// local player variables, by popular request
|
// local player variables, by popular request
|
||||||
} else if (fastcmp(word,"consoleplayer")) { // player controlling console (aka local player 1)
|
} else if (fastcmp(word,"consoleplayer")) { // player controlling console (aka local player 1)
|
||||||
if (!playeringame[consoleplayer])
|
if (consoleplayer < 0 || !playeringame[consoleplayer])
|
||||||
return 0;
|
return 0;
|
||||||
LUA_PushUserdata(L, &players[consoleplayer], META_PLAYER);
|
LUA_PushUserdata(L, &players[consoleplayer], META_PLAYER);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (fastcmp(word,"displayplayer")) { // player visible on screen (aka display player 1)
|
} else if (fastcmp(word,"displayplayer")) { // player visible on screen (aka display player 1)
|
||||||
if (!playeringame[displayplayer])
|
if (displayplayer < 0 || !playeringame[displayplayer])
|
||||||
return 0;
|
return 0;
|
||||||
LUA_PushUserdata(L, &players[displayplayer], META_PLAYER);
|
LUA_PushUserdata(L, &players[displayplayer], META_PLAYER);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (fastcmp(word,"secondarydisplayplayer")) { // local/display player 2, for splitscreen
|
} else if (fastcmp(word,"secondarydisplayplayer")) { // local/display player 2, for splitscreen
|
||||||
if (!splitscreen || !playeringame[secondarydisplayplayer])
|
if (!splitscreen || secondarydisplayplayer < 0 || consoleplayer >= MAXPLAYERS || !playeringame[secondarydisplayplayer])
|
||||||
return 0;
|
return 0;
|
||||||
LUA_PushUserdata(L, &players[secondarydisplayplayer], META_PLAYER);
|
LUA_PushUserdata(L, &players[secondarydisplayplayer], META_PLAYER);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue