Refactoring of building scripts

This commit is contained in:
Pax1601
2024-01-03 17:48:38 +01:00
parent 8024db9579
commit 4e7c8ef856
92 changed files with 17403 additions and 284876 deletions

View File

@@ -0,0 +1,63 @@
local version = '{{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}}'
local lfs = require("lfs")
Olympus = {}
Olympus.OlympusDLL = nil
Olympus.DLLsloaded = false
Olympus.OlympusModPath = lfs.writedir().."Mods\\Services\\Olympus\\bin\\"
log.write('Olympus.HOOKS.LUA', log.INFO,'Executing OlympusHook.lua')
function Olympus.loadDLLs()
-- Add the .dll paths
package.cpath = package.cpath..';'..Olympus.OlympusModPath..'?.dll;'
local status
log.write('Olympus.HOOKS.LUA', log.INFO, 'Loading olympus.dll from ['..Olympus.OlympusModPath..']')
status, Olympus.OlympusDLL = pcall(require, 'olympus')
if status then
log.write('Olympus.HOOKS.LUA', log.INFO, 'olympus.dll loaded successfully')
return true
else
log.write('Olympus.HOOKS.LUA', log.ERROR, 'Error loading olympus.dll: '..Olympus.OlympusDLL)
return false
end
end
do
if isOlympusModuleInitialized~=true then
local OlympusName = 'Olympus ' .. version .. ' C++ module';
Olympus.loadDLLs();
-- Register callbacks
local OlympusCallbacks = {}
function OlympusCallbacks.onSimulationStart()
log.write('Olympus.HOOKS.LUA', log.INFO,OlympusName..' onSimulationStart')
if DCS.isServer() then
Olympus.DLLsloaded = Olympus.loadDLLs()
if Olympus.DLLsloaded then
Olympus.OlympusDLL.onSimulationStart()
log.write('Olympus.HOOKS.LUA', log.INFO, OlympusName..' successfully loaded.')
else
log.write('Olympus.HOOKS.LUA', log.ERROR, 'Failed to load '..OlympusName)
end
end
end
function OlympusCallbacks.onSimulationFrame()
if DCS.isServer() and Olympus.DLLsloaded then
Olympus.OlympusDLL.onSimulationFrame()
end
end
function OlympusCallbacks.onSimulationStop()
if DCS.isServer() and Olympus.DLLsloaded then
Olympus.OlympusDLL.onSimulationStop()
end
end
DCS.setUserCallbacks(OlympusCallbacks)
log.write('Olympus.HOOKS.LUA', log.INFO, OlympusName..' callbacks registered correctly.')
isOlympusModuleInitialized=true;
end
end