CV_NOLUA for when a cvar should not be changed via Lua
This commit is contained in:
parent
f26bdf00fe
commit
cb29a9dd0a
|
@ -2064,6 +2064,9 @@ static boolean CV_Command(void)
|
||||||
if (!v)
|
if (!v)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (( com_flags & COM_SAFE ) && ( v->flags & CV_NOLUA ))
|
||||||
|
return false;
|
||||||
|
|
||||||
// perform a variable print or set
|
// perform a variable print or set
|
||||||
if (COM_Argc() == 1)
|
if (COM_Argc() == 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
// Command buffer & command execution
|
// Command buffer & command execution
|
||||||
//===================================
|
//===================================
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
COM_SAFE = 1,
|
||||||
|
};
|
||||||
|
|
||||||
typedef void (*com_func_t)(void);
|
typedef void (*com_func_t)(void);
|
||||||
|
|
||||||
void COM_AddCommand(const char *name, com_func_t func);
|
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
|
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
|
// can only be set when we have the pointer to it
|
||||||
// used on menus
|
// 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;
|
} cvflags_t;
|
||||||
|
|
||||||
typedef struct CV_PossibleValue_s
|
typedef struct CV_PossibleValue_s
|
||||||
|
|
|
@ -9462,6 +9462,7 @@ struct {
|
||||||
{"CV_HIDEN",CV_HIDEN},
|
{"CV_HIDEN",CV_HIDEN},
|
||||||
{"CV_HIDDEN",CV_HIDEN},
|
{"CV_HIDDEN",CV_HIDEN},
|
||||||
{"CV_CHEAT",CV_CHEAT},
|
{"CV_CHEAT",CV_CHEAT},
|
||||||
|
{"CV_NOLUA",CV_NOLUA},
|
||||||
|
|
||||||
// v_video flags
|
// v_video flags
|
||||||
{"V_NOSCALEPATCH",V_NOSCALEPATCH},
|
{"V_NOSCALEPATCH",V_NOSCALEPATCH},
|
||||||
|
|
|
@ -245,7 +245,7 @@ static int lib_comBufAddText(lua_State *L)
|
||||||
return LUA_ErrInvalid(L, "player_t");
|
return LUA_ErrInvalid(L, "player_t");
|
||||||
if (plr != &players[consoleplayer])
|
if (plr != &players[consoleplayer])
|
||||||
return 0;
|
return 0;
|
||||||
COM_BufAddText(va("%s\n", luaL_checkstring(L, 2)));
|
COM_BufAddTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ static int lib_comBufInsertText(lua_State *L)
|
||||||
return LUA_ErrInvalid(L, "player_t");
|
return LUA_ErrInvalid(L, "player_t");
|
||||||
if (plr != &players[consoleplayer])
|
if (plr != &players[consoleplayer])
|
||||||
return 0;
|
return 0;
|
||||||
COM_BufInsertText(va("%s\n", luaL_checkstring(L, 2)));
|
COM_BufInsertTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue