mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-29 07:23:01 +00:00
Make dev chat commands less dangerous
(Remove /lua commands)
This commit is contained in:
parent
2841c53ffe
commit
22ac33d3f3
3 changed files with 1 additions and 34 deletions
|
@ -108,32 +108,10 @@ bool exec_dev_chat_command(char* command) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp("/lua", command) == 0) {
|
|
||||||
djui_chat_message_create("Missing parameter: [LUA]");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (str_starts_with("/lua ", command)) {
|
|
||||||
smlua_exec_str(&command[5]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp("/luaf", command) == 0) {
|
|
||||||
djui_chat_message_create("Missing parameter: [FILENAME]");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (str_starts_with("/luaf ", command)) {
|
|
||||||
smlua_exec_file(&command[6]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dev_display_chat_commands(void) {
|
void dev_display_chat_commands(void) {
|
||||||
djui_chat_message_create("/warp [LEVEL] [AREA] [ACT] - Level can be either a numeric value or a shorthand name");
|
djui_chat_message_create("/warp [LEVEL] [AREA] [ACT] - Level can be either a numeric value or a shorthand name");
|
||||||
djui_chat_message_create("/lua [LUA] - Execute Lua code from a string");
|
|
||||||
djui_chat_message_create("/luaf [FILENAME] - Execute Lua code from a file");
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -46,16 +46,7 @@ int smlua_pcall(lua_State* L, int nargs, int nresults, UNUSED int errfunc) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void smlua_exec_file(const char* path) {
|
static void smlua_exec_str(const char* str) {
|
||||||
lua_State* L = gLuaState;
|
|
||||||
if (luaL_dofile(L, path) != LUA_OK) {
|
|
||||||
LOG_LUA("Failed to load lua file '%s'.", path);
|
|
||||||
LOG_LUA("%s", smlua_to_string(L, lua_gettop(L)));
|
|
||||||
}
|
|
||||||
lua_pop(L, lua_gettop(L));
|
|
||||||
}
|
|
||||||
|
|
||||||
void smlua_exec_str(const char* str) {
|
|
||||||
lua_State* L = gLuaState;
|
lua_State* L = gLuaState;
|
||||||
if (luaL_dostring(L, str) != LUA_OK) {
|
if (luaL_dostring(L, str) != LUA_OK) {
|
||||||
LOG_LUA("Failed to load lua string.");
|
LOG_LUA("Failed to load lua string.");
|
||||||
|
|
|
@ -41,8 +41,6 @@ extern struct Mod* gLuaLastHookMod;
|
||||||
void smlua_mod_error(void);
|
void smlua_mod_error(void);
|
||||||
int smlua_error_handler(UNUSED lua_State* L);
|
int smlua_error_handler(UNUSED lua_State* L);
|
||||||
int smlua_pcall(lua_State* L, int nargs, int nresults, int errfunc);
|
int smlua_pcall(lua_State* L, int nargs, int nresults, int errfunc);
|
||||||
void smlua_exec_file(const char* path);
|
|
||||||
void smlua_exec_str(const char* str);
|
|
||||||
|
|
||||||
void smlua_init(void);
|
void smlua_init(void);
|
||||||
void smlua_update(void);
|
void smlua_update(void);
|
||||||
|
|
Loading…
Reference in a new issue