Added configuration file to set address and port

This commit is contained in:
Pax1601
2023-03-26 11:04:17 +02:00
parent 0f2d9feba5
commit 25d0f031d5
17 changed files with 110 additions and 288 deletions

View File

@@ -1,40 +0,0 @@
local version = 'v0.1.0-alpha'
Olympus = {}
Olympus.OlympusDLL = nil
Olympus.cppRESTDLL = nil
Olympus.DLLsloaded = false
Olympus.OlympusModPath = os.getenv('DCSOLYMPUS_PATH')..'\\bin\\'
log.write('Olympus.EXPORT.LUA', log.INFO, 'Executing OlympusExport.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';
isOlympusModuleInitialized=true;
Olympus.DLLsloaded = Olympus.loadDLLs()
if Olympus.DLLsloaded then
log.write('Olympus.EXPORT.LUA', log.INFO, OlympusName..' successfully loaded.')
else
log.write('Olympus.EXPORT.LUA', log.ERROR, 'Failed to load '..OlympusName)
end
else
log.write('Olympus.EXPORT.LUA', log.INFO, 'olympus.dll already initialized')
end
end

View File

@@ -1,4 +1,4 @@
local version = 'v0.1.0-alpha'
local version = 'v0.1.1-alpha'
Olympus = {}
Olympus.OlympusDLL = nil

View File

@@ -1,135 +0,0 @@
local version = 'v0.1.0-alpha'
Olympus = {}
Olympus.groupIndex = 0
Olympus.groupStep = 40
function Olympus.notify(message, displayFor)
trigger.action.outText(message, displayFor)
end
function Olympus.setMissionData(arg, time)
local missionData = {}
-- Bullseye data
local bullseyes = {}
for i = 0, 2 do
local bullseyeVec3 = coalition.getMainRefPoint(i)
local bullseyeLatitude, bullseyeLongitude, bullseyeAltitude = coord.LOtoLL(bullseyeVec3)
bullseyes[i] = {}
bullseyes[i]["latitude"] = bullseyeLatitude
bullseyes[i]["longitude"] = bullseyeLongitude
end
-- Units tactical data
local unitsData = {}
local startIndex = Olympus.groupIndex
local endIndex = startIndex + Olympus.groupStep
local index = 0
for groupName, gp in pairs(mist.DBs.groupsByName) do
index = index + 1
if index > startIndex then
if groupName ~= nil then
local group = Group.getByName(groupName)
if group ~= nil then
local controller = group:getController()
for index, unit in pairs(group:getUnits()) do
local table = {}
table["targets"] = {}
table["targets"]["visual"] = controller:getDetectedTargets(1)
table["targets"]["radar"] = controller:getDetectedTargets(4)
table["targets"]["rwr"] = controller:getDetectedTargets(16)
table["targets"]["other"] = controller:getDetectedTargets(2, 8, 32)
table["hasTask"] = controller:hasTask()
table["ammo"] = unit:getAmmo()
table["fuel"] = unit:getFuel()
table["life"] = unit:getLife() / unit:getLife0()
unitsData[unit:getObjectID()] = table
end
end
end
end
if index >= endIndex then
break
end
end
if index ~= endIndex then
Olympus.groupIndex = 0
else
Olympus.groupIndex = endIndex
end
-- Airbases data
local base = world.getAirbases()
local airbases = {}
for i = 1, #base do
local info = {}
local latitude, longitude, altitude = coord.LOtoLL(Airbase.getPoint(base[i]))
info["callsign"] = Airbase.getCallsign(base[i])
local coalitionID = Airbase.getCoalition(base[i])
if coalitionID == 0 then
info["coalition"] = "neutral"
elseif coalitionID == 1 then
info["coalition"] = "red"
else
info["coalition"] = "blue"
end
info["latitude"] = latitude
info["longitude"] = longitude
if Airbase.getUnit(base[i]) then
info["unitId"] = Airbase.getUnit(base[i]):getID()
end
airbases[i] = info
end
local mission = {}
mission.theatre = env.mission.theatre
-- Assemble missionData table
missionData["bullseyes"] = bullseyes
missionData["unitsData"] = unitsData
missionData["airbases"] = airbases
missionData["mission"] = mission
local command = "Olympus.missionData = " .. Olympus.serializeTable(missionData) .. "\n" .. "Olympus.OlympusDLL.setMissionData()"
net.dostring_in("export", command)
return time + 1
end
function Olympus.serializeTable(val, name, skipnewlines, depth)
skipnewlines = skipnewlines or false
depth = depth or 0
local tmp = string.rep(" ", depth)
if name then
if type(name) == "number" then
tmp = tmp .. "[" .. name .. "]" .. " = "
else
tmp = tmp .. name .. " = "
end
end
if type(val) == "table" then
tmp = tmp .. "{" .. (not skipnewlines and "\n" or "")
for k, v in pairs(val) do
tmp = tmp .. Olympus.serializeTable(v, k, skipnewlines, depth + 1) .. "," .. (not skipnewlines and "\n" or "")
end
tmp = tmp .. string.rep(" ", depth) .. "}"
elseif type(val) == "number" then
tmp = tmp .. tostring(val)
elseif type(val) == "string" then
tmp = tmp .. string.format("%q", val)
elseif type(val) == "boolean" then
tmp = tmp .. (val and "true" or "false")
else
tmp = tmp .. "\"[inserializeable datatype:" .. type(val) .. "]\""
end
return tmp
end
timer.scheduleFunction(Olympus.setMissionData, {}, timer.getTime() + 1)
Olympus.notify("OlympusMission " .. version .. " script loaded correctly", 10)

Binary file not shown.

View File

@@ -1,42 +0,0 @@
import shutil
import sys
START_STRING = "-- Olympus START\n"
END_STRING = "-- Olympus END\n"
EXPORT_STRING = "local Olympuslfs=require('lfs');dofile(Olympuslfs.writedir()..'Scripts/OlympusExport.lua')\n"
def main(flag):
if flag == "-i":
try:
with open("Export.lua", "r") as f:
shutil.copyfile("Export.lua", "Export.lua.bak")
lines = f.readlines()
if START_STRING in lines:
return
except FileNotFoundError:
print('File does not exist')
with open("Export.lua", "a") as f:
f.writelines(["\n", START_STRING, EXPORT_STRING, END_STRING, "\n"])
elif flag == "-u":
try:
with open("Export.lua", "r") as f:
shutil.copyfile("Export.lua", "Export.lua.bak")
lines = f.readlines()
except FileNotFoundError:
print('File does not exist')
with open("Export.lua", "w") as f:
block = False
for line in lines:
if line == START_STRING:
block = True
if not block:
f.write(line)
if line == END_STRING:
block = False
if __name__ == "__main__":
main(sys.argv[1])

View File

@@ -1,44 +0,0 @@
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(
['OlympusPatcher.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='OlympusPatcher',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)