Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kissmp-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct Config {
pub show_in_server_list: bool,
pub upnp_enabled: bool,
pub server_identifier: String,
pub unsafe_debug_library: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub mods: Option<Vec<String>>,
}
Expand All @@ -30,6 +31,7 @@ impl Default for Config {
show_in_server_list: false,
upnp_enabled: false,
server_identifier: rand_string(),
unsafe_debug_library: false,
mods: None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion kissmp-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub struct Server {

impl Server {
pub fn from_config(config: config::Config) -> Self {
let (lua, receiver) = lua::setup_lua();
let (lua, receiver) = lua::setup_lua(config.unsafe_debug_library);
let (watcher_tx, watcher_rx) = std::sync::mpsc::channel();
let lua_watcher =
notify::Watcher::new(watcher_tx, std::time::Duration::from_secs(2)).unwrap();
Expand Down
10 changes: 8 additions & 2 deletions kissmp-server/src/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,14 @@ pub struct MpscChannelSender(mpsc::Sender<LuaCommand>);

impl rlua::UserData for MpscChannelSender {}

pub fn setup_lua() -> (rlua::Lua, mpsc::Receiver<LuaCommand>) {
let lua = rlua::Lua::new();
pub fn setup_lua(debug_lib: bool) -> (rlua::Lua, mpsc::Receiver<LuaCommand>) {
let lua;
if debug_lib {
unsafe { lua = rlua::Lua::unsafe_new_with(rlua::StdLib::all()); };
} else {
lua = rlua::Lua::new();
}

let (tx, rx) = mpsc::channel();
lua.context(|lua_ctx| {
let globals = lua_ctx.globals();
Expand Down