CV_NOLUA for when a cvar should not be changed via Lua

This commit is contained in:
James R 2019-12-26 18:15:19 -08:00
parent f26bdf00fe
commit cb29a9dd0a
4 changed files with 13 additions and 3 deletions

View File

@ -2064,6 +2064,9 @@ static boolean CV_Command(void)
if (!v)
return false;
if (( com_flags & COM_SAFE ) && ( v->flags & CV_NOLUA ))
return false;
// perform a variable print or set
if (COM_Argc() == 1)
{

View File

@ -20,6 +20,11 @@
// Command buffer & command execution
//===================================
enum
{
COM_SAFE = 1,
};
typedef void (*com_func_t)(void);
void COM_AddCommand(const char *name, com_func_t func);
@ -103,7 +108,8 @@ typedef enum
CV_HIDEN = 1024, // variable is not part of the cvar list so cannot be accessed by the console
// can only be set when we have the pointer to it
// used on menus
CV_CHEAT = 2048 // Don't let this be used in multiplayer unless cheats are on.
CV_CHEAT = 2048, // Don't let this be used in multiplayer unless cheats are on.
CV_NOLUA = 4096,/* don't let this be called from Lua */
} cvflags_t;
typedef struct CV_PossibleValue_s

View File

@ -9462,6 +9462,7 @@ struct {
{"CV_HIDEN",CV_HIDEN},
{"CV_HIDDEN",CV_HIDEN},
{"CV_CHEAT",CV_CHEAT},
{"CV_NOLUA",CV_NOLUA},
// v_video flags
{"V_NOSCALEPATCH",V_NOSCALEPATCH},

View File

@ -245,7 +245,7 @@ static int lib_comBufAddText(lua_State *L)
return LUA_ErrInvalid(L, "player_t");
if (plr != &players[consoleplayer])
return 0;
COM_BufAddText(va("%s\n", luaL_checkstring(L, 2)));
COM_BufAddTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE);
return 0;
}
@ -262,7 +262,7 @@ static int lib_comBufInsertText(lua_State *L)
return LUA_ErrInvalid(L, "player_t");
if (plr != &players[consoleplayer])
return 0;
COM_BufInsertText(va("%s\n", luaL_checkstring(L, 2)));
COM_BufInsertTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE);
return 0;
}