mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Flexible Dedicated Hosting Options
* Fixed minor errors on the original LUA scripting * Refactored code to be self-contained to a function * Changed the search logic to use an environment variable first, then fallback into other search options
This commit is contained in:
parent
84beb2dfe5
commit
cab5825b72
@ -39,46 +39,54 @@ write_state = function()
|
|||||||
-- messageAll("Done writing DCS Liberation state.")
|
-- messageAll("Done writing DCS Liberation state.")
|
||||||
end
|
end
|
||||||
|
|
||||||
debriefing_file_location = nil
|
|
||||||
if dcsLiberation then
|
local function discoverDebriefingFilePath()
|
||||||
debriefing_file_location = dcsLiberation.installPath
|
local function insertFileName(directoryOrFilePath, overrideFileName)
|
||||||
end
|
if overrideFileName then
|
||||||
if debriefing_file_location then
|
logger:info("Using LIBERATION_EXPORT_STAMPED_STATE to locate the state.json")
|
||||||
logger:info("Using DCS Liberation install folder for state.json")
|
return directoryOrFilePath .. os.time() .. "-state.json"
|
||||||
else
|
end
|
||||||
|
|
||||||
|
local filename = "state.json"
|
||||||
|
if not (directoryOrFilePath:sub(-#filename) == filename) then
|
||||||
|
return directoryOrFilePath .. filename
|
||||||
|
end
|
||||||
|
|
||||||
|
return directoryOrFilePath
|
||||||
|
end
|
||||||
|
|
||||||
|
-- establish a search pattern into the following modes
|
||||||
|
-- 1. Environment variable mode, to support dedicated server hosting
|
||||||
|
-- 2. Embedded DCS Liberation Generation, to support locally hosted single player
|
||||||
|
-- 3. Retain the classic TEMP directory logic
|
||||||
|
|
||||||
if os then
|
if os then
|
||||||
debriefing_file_location = os.getenv("LIBERATION_EXPORT_DIR")
|
local exportDirectory = os.getenv("LIBERATION_EXPORT_DIR")
|
||||||
if debriefing_file_location then debriefing_file_location = debriefing_file_location .. "\\" end
|
|
||||||
end
|
if exportDirectory then
|
||||||
if debriefing_file_location then
|
logger:info("Using LIBERATION_EXPORT_DIR to locate the state.json")
|
||||||
logger:info("Using LIBERATION_EXPORT_DIR environment variable for state.json")
|
local useCurrentStamping = os.getenv("LIBERATION_EXPORT_STAMPED_STATE")
|
||||||
else
|
exportDirectory = exportDirectory .. "\\"
|
||||||
if os then
|
return insertFileName(exportDirectory, useCurrentStamping)
|
||||||
debriefing_file_location = os.getenv("TEMP")
|
|
||||||
if debriefing_file_location then debriefing_file_location = debriefing_file_location .. "\\" end
|
|
||||||
end
|
|
||||||
if debriefing_file_location then
|
|
||||||
logger:info("Using TEMP environment variable for state.json")
|
|
||||||
else
|
|
||||||
if lfs then
|
|
||||||
debriefing_file_location = lfs.writedir()
|
|
||||||
end
|
|
||||||
if debriefing_file_location then
|
|
||||||
logger:info("Using DCS working directory for state.json")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if debriefing_file_location then
|
if dcsLiberation then
|
||||||
local filename = "state.json"
|
logger:info("Using DCS Liberation install folder for state.json")
|
||||||
if not debriefing_file_location:sub(-#filename) == filename then
|
return insertFileName(dcsLiberation.installPath)
|
||||||
debriefing_file_location = debriefing_file_location .. filename
|
end
|
||||||
|
|
||||||
|
if lfs then
|
||||||
|
logger:info("Using DCS working directory for state.json")
|
||||||
|
return insertFileName(lfs.writedir())
|
||||||
end
|
end
|
||||||
logger:info(string.format("DCS Liberation state will be written as json to [[%s]]",debriefing_file_location))
|
|
||||||
else
|
|
||||||
logger:error("No usable storage path for state.json")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
debriefing_file_location = discoverDebriefingFilePath()
|
||||||
|
logger:info(string.format("DCS Liberation state will be written as json to [[%s]]",debriefing_file_location))
|
||||||
|
|
||||||
|
|
||||||
write_state_error_handling = function()
|
write_state_error_handling = function()
|
||||||
if pcall(write_state) then
|
if pcall(write_state) then
|
||||||
-- messageAll("Written DCS Liberation state to "..debriefing_file_location)
|
-- messageAll("Written DCS Liberation state to "..debriefing_file_location)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user