mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-25 22:01:01 +00:00
Merge COM_SAFE with other COM flags
Renames COM_SAFE to COM_LUA.
This commit is contained in:
parent
ff0f6e9b74
commit
0405df1a47
3 changed files with 16 additions and 18 deletions
|
@ -109,6 +109,7 @@ static cmdalias_t *com_alias; // aliases list
|
|||
// =========================================================================
|
||||
|
||||
static vsbuf_t com_text; // variable sized buffer
|
||||
static com_flags_t com_flags = 0;
|
||||
|
||||
/** Purges control characters out of some text.
|
||||
*
|
||||
|
@ -141,7 +142,7 @@ COM_Purge (char *s, int *np)
|
|||
* \param ptext The text to add.
|
||||
* \sa COM_BufInsertTextEx
|
||||
*/
|
||||
void COM_BufAddTextEx(const char *ptext, int flags)
|
||||
void COM_BufAddTextEx(const char *ptext, com_flags_t flags)
|
||||
{
|
||||
int l;
|
||||
char *text;
|
||||
|
@ -164,7 +165,7 @@ void COM_BufAddTextEx(const char *ptext, int flags)
|
|||
* \param ptext The text to execute. A newline is automatically added.
|
||||
* \sa COM_BufAddTextEx
|
||||
*/
|
||||
void COM_BufInsertTextEx(const char *ptext, int flags)
|
||||
void COM_BufInsertTextEx(const char *ptext, com_flags_t flags)
|
||||
{
|
||||
const INT32 old_wait = com_wait;
|
||||
|
||||
|
@ -320,7 +321,6 @@ static size_t com_argc;
|
|||
static char *com_argv[MAX_ARGS];
|
||||
static const char *com_null_string = "";
|
||||
static char *com_args = NULL; // current command args or NULL
|
||||
static int com_flags;
|
||||
|
||||
static void Got_NetVar(UINT8 **p, INT32 playernum);
|
||||
|
||||
|
@ -1124,7 +1124,7 @@ void VS_Write(vsbuf_t *buf, const void *data, size_t length)
|
|||
M_Memcpy(VS_GetSpace(buf, length), data, length);
|
||||
}
|
||||
|
||||
void VS_WriteEx(vsbuf_t *buf, const void *data, size_t length, int flags)
|
||||
void VS_WriteEx(vsbuf_t *buf, const void *data, size_t length, com_flags_t flags)
|
||||
{
|
||||
char *p;
|
||||
p = VS_GetSpace(buf, 2 + length);
|
||||
|
@ -2472,7 +2472,7 @@ void CV_SaveVariables(FILE *f)
|
|||
static boolean CV_Immutable(const consvar_t *var)
|
||||
{
|
||||
// Currently operating from Lua
|
||||
if (com_flags & COM_SAFE)
|
||||
if (com_flags & COM_LUA)
|
||||
{
|
||||
if (!(var->flags & CV_ALLOWLUA))
|
||||
{
|
||||
|
|
|
@ -20,19 +20,17 @@
|
|||
// Command buffer & command execution
|
||||
//===================================
|
||||
|
||||
/* Lua command registration flags. */
|
||||
enum
|
||||
/* Command registration flags. */
|
||||
typedef enum
|
||||
{
|
||||
COM_ADMIN = 1,
|
||||
COM_SPLITSCREEN = 2,
|
||||
COM_LOCAL = 4,
|
||||
};
|
||||
|
||||
/* Command buffer flags. */
|
||||
enum
|
||||
{
|
||||
COM_SAFE = 1,
|
||||
};
|
||||
// COM_BufInsertText etc: can only access cvars
|
||||
// with CV_ALLOWLUA set.
|
||||
COM_LUA = 8,
|
||||
} com_flags_t;
|
||||
|
||||
typedef void (*com_func_t)(void);
|
||||
|
||||
|
@ -53,11 +51,11 @@ const char *COM_CompleteAlias(const char *partial, INT32 skips);
|
|||
|
||||
// insert at queu (at end of other command)
|
||||
#define COM_BufAddText(s) COM_BufAddTextEx(s, 0)
|
||||
void COM_BufAddTextEx(const char *btext, int flags);
|
||||
void COM_BufAddTextEx(const char *btext, com_flags_t flags);
|
||||
|
||||
// insert in head (before other command)
|
||||
#define COM_BufInsertText(s) COM_BufInsertTextEx(s, 0)
|
||||
void COM_BufInsertTextEx(const char *btext, int flags);
|
||||
void COM_BufInsertTextEx(const char *btext, com_flags_t flags);
|
||||
|
||||
// don't bother inserting, just do immediately
|
||||
void COM_ImmedExecute(const char *ptext);
|
||||
|
@ -89,7 +87,7 @@ void VS_Free(vsbuf_t *buf);
|
|||
void VS_Clear(vsbuf_t *buf);
|
||||
void *VS_GetSpace(vsbuf_t *buf, size_t length);
|
||||
void VS_Write(vsbuf_t *buf, const void *data, size_t length);
|
||||
void VS_WriteEx(vsbuf_t *buf, const void *data, size_t length, int flags);
|
||||
void VS_WriteEx(vsbuf_t *buf, const void *data, size_t length, com_flags_t flags);
|
||||
void VS_Print(vsbuf_t *buf, const char *data); // strcats onto the sizebuf
|
||||
|
||||
//==================
|
||||
|
|
|
@ -253,7 +253,7 @@ static int lib_comBufAddText(lua_State *L)
|
|||
plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (plr && plr != &players[consoleplayer])
|
||||
return 0;
|
||||
COM_BufAddTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE);
|
||||
COM_BufAddTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_LUA);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ static int lib_comBufInsertText(lua_State *L)
|
|||
plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (plr && plr != &players[consoleplayer])
|
||||
return 0;
|
||||
COM_BufInsertTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE);
|
||||
COM_BufInsertTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_LUA);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue