Skip to content

Commit

Permalink
Better handling of dev settings (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdahlblom authored Jan 27, 2024
1 parent cb01ca1 commit de16910
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/server/Scripts/DCS-INSIGHT/ServerSettings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ ServerSettings.Log_JSON = false
-- Do NOT enable unless your are firewalled.
ServerSettings.EnableLuaConsole = false

function ServerSettings:setDeveloperSettings(settings)
ServerSettings.TCP_address = settings.TCP_address
ServerSettings.TCP_port = settings.TCP_port
ServerSettings.Log_JSON = settings.Log_JSON
ServerSettings.EnableLuaConsole = settings.EnableLuaConsole
end

return ServerSettings
9 changes: 1 addition & 8 deletions src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,7 @@ end

--- Adds the lua console
function APIHandler:addLuaConsole()
Log:log_simple(0)
if CommonInsight:tryRequire("Scripts.DCS-INSIGHT.ServerSettingsDevelopment") then
local ServerSettingsDevelopment = require("Scripts.DCS-INSIGHT.ServerSettingsDevelopment")
if ServerSettingsDevelopment.EnableLuaConsole then
self.commandsTable[#self.commandsTable + 1] = LoadStringAPI:new(nil, counter())
self.apiTable[#self.apiTable + 1] = self.commandsTable[#self.commandsTable].apiInfo
end
elseif ServerSettings.EnableLuaConsole then
if ServerSettings.EnableLuaConsole then
self.commandsTable[#self.commandsTable + 1] = LoadStringAPI:new(nil, counter())
self.apiTable[#self.apiTable + 1] = self.commandsTable[#self.commandsTable].apiInfo
end
Expand Down
7 changes: 6 additions & 1 deletion src/server/Scripts/DCS-INSIGHT/lib/DCSInsight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ local Log = require("Scripts.DCS-INSIGHT.lib.common.Log")
local ServerSettings = require("Scripts.DCS-INSIGHT.ServerSettings")
local APIHandler = require("Scripts.DCS-INSIGHT.lib.APIHandler")
local APIHandler = APIHandler:new()

local CommonInsight = require("Scripts.DCS-INSIGHT.lib.common.Common")
local Listener = require("Scripts.DCS-INSIGHT.lib.Listener")

if CommonInsight:tryRequire("Scripts.DCS-INSIGHT.ServerSettingsDevelopment") then
local ServerSettingsDevelopment = require("Scripts.DCS-INSIGHT.ServerSettingsDevelopment")
ServerSettings:setDeveloperSettings(ServerSettingsDevelopment)
end

local Listener = Listener:new(ServerSettings.TCP_address, ServerSettings.TCP_port, APIHandler)
Listener:init()

Expand Down

0 comments on commit de16910

Please sign in to comment.