Skip to content

Update mist.DBs with dynamic client slot spwaned  #98

@FullGas1

Description

@FullGas1

Hello, the last DCS update introduce a new system of dynamic client slot spwan via the airports ressources fct. This feature cause a pb in MIST, because the taken dynamic slots are not automaticaly integrated in mist.DBs. Working for a solution I have identify 2 fixes needed.

Modified lines marked by " -- MODIFY !"

1 - a pb in mist.forceAddToDB() fct to be compatible with writeDBTables() fct it would be like :

function mist.forceAddToDB(object)
-- object is static object or group.
-- call dbUpdate to get the table
local tbl = {} -- MODIFY !
tbl.data = dbUpdate(object) -- MODIFY !
if tbl then
local res = writeDBTables(tbl)
if not res then
log:warn("Failed to force add to DBs: $1", object)
end
end
-- call writeDBTables with that table.
end

2 - a pb in dbUpdate(object) fct to be compatible with calls without oType given (ex: mist.forceAddToDB()), it would be like :

local function dbUpdate(event, oType, origGroupName)
--dbLog:info('dbUpdate: $1', event)
local newTable = {}
local objType = oType
newTable.startTime = 0
if type(event) == 'string' then -- if name of an object.
local newObject
if Group.getByName(event) then
newObject = Group.getByName(event)
objType = "group" -- MODIFY !
elseif StaticObject.getByName(event) then
newObject = StaticObject.getByName(event)
objType = "static"
-- log:info('its static')
else
log:warn('$1 is not a Group or Static Object. This should not be possible. Sent category is: $2', event, objType)
return false
end
...

With this 2 fixes, it would be possible to update DBs via un simple script like (before a most integrated solution) :

function mist.updateMISTDBsForHelos(params, t) -- update helos list among taken slots
for k,v in pairs(coalition.getGroups(1,1)) do -- scan red helos taken slots grp
mist.forceAddToDB(v:getName())
end
for k,v in pairs(coalition.getGroups(2,1)) do -- scan blue helos taken slots grp
mist.forceAddToDB(v:getName())
end
timer.scheduleFunction(mist.updateMISTDBsForHelos, nil, t + 5)
end
mist.updateMISTDBsForHelos(nil, timer.getTime())

thank's

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions