From 637081ebddbcbf212cab5c82fc5fa4c199b3d4d7 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 30 Aug 2020 22:52:18 +0200 Subject: [PATCH] Ops --- Moose Development/Moose/Core/Database.lua | 2 +- Moose Development/Moose/Core/Timer.lua | 34 +++++++++++-- .../Moose/Functional/Warehouse.lua | 32 +++++++----- Moose Development/Moose/Globals.lua | 1 + Moose Development/Moose/Ops/ArmyGroup.lua | 14 +++-- Moose Development/Moose/Ops/Auftrag.lua | 17 +++++-- Moose Development/Moose/Ops/FlightGroup.lua | 25 +++++---- Moose Development/Moose/Ops/NavyGroup.lua | 31 ++++++----- Moose Development/Moose/Ops/OpsGroup.lua | 51 ++++++------------- Moose Development/Moose/Wrapper/Airbase.lua | 11 +++- 10 files changed, 128 insertions(+), 90 deletions(-) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 430542f5e..504a861b4 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -136,7 +136,7 @@ function DATABASE:New() self:_RegisterClients() self:_RegisterStatics() --self:_RegisterPlayers() - self:_RegisterAirbases() + --self:_RegisterAirbases() self.UNITS_Position = 0 diff --git a/Moose Development/Moose/Core/Timer.lua b/Moose Development/Moose/Core/Timer.lua index cbf739fa3..72fe2c19d 100644 --- a/Moose Development/Moose/Core/Timer.lua +++ b/Moose Development/Moose/Core/Timer.lua @@ -100,6 +100,12 @@ TIMER = { lid = nil, } +--- Timer ID. +_TIMERID=0 + +--- Timer data base. +_TIMERDB={} + --- TIMER class version. -- @field #string version TIMER.version="0.1.0" @@ -124,8 +130,6 @@ function TIMER:New(Function, ...) -- Inherit BASE. local self=BASE:Inherit(self, BASE:New()) --#TIMER - - self.lid="TIMER | " -- Function to call. self.func=Function @@ -136,6 +140,18 @@ function TIMER:New(Function, ...) -- Number of function calls. self.ncalls=0 + -- Increase counter + _TIMERID=_TIMERID+1 + + -- Set UID. + self.uid=_TIMERID + + -- Log id. + self.lid=string.format("TIMER UID=%d | ", self.uid) + + -- Add to DB. + _TIMERDB[self.uid]=self + return self end @@ -151,7 +167,7 @@ function TIMER:Start(Tstart, dT, Duration) local Tnow=timer.getTime() -- Start time in sec. - self.Tstart=Tstart or Tnow + self.Tstart=Tstart and Tnow+Tstart or Tnow+0.001 -- one millisecond delay if Tstart=nil -- Set time interval. self.dT=dT @@ -162,10 +178,10 @@ function TIMER:Start(Tstart, dT, Duration) end -- Call DCS timer function. - self.tid=timer.scheduleFunction(TIMER._Function, self, self.Tstart) + self.tid=timer.scheduleFunction(self._Function, self, self.Tstart) -- Set log id. - self.lid=string.format("TIMER ID=%d | ", self.tid) + self.lid=string.format("TIMER UID=%d/%d | ", self.uid, self.tid) -- Debug info. self:T(self.lid..string.format("Starting Timer in %.3f sec, dT=%s, Tstop=%s", self.Tstart-Tnow, tostring(self.dT), tostring(self.Tstop))) @@ -186,8 +202,14 @@ function TIMER:Stop(Delay) else if self.tid then + + -- Remove timer function. self:T(self.lid..string.format("Stopping timer by removing timer function after %d calls!", self.ncalls)) timer.removeFunction(self.tid) + + -- Remove DB entry. + _TIMERDB[self.uid]=nil + end end @@ -210,6 +232,8 @@ end -- @return #number Time when the function is called again or `nil` if the timer is stopped. function TIMER:_Function(time) + --self:I(self.lid.."FF calling timer _Function") + -- Call function. self.func(unpack(self.para)) diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index 605fdd94a..940251cec 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -3521,12 +3521,14 @@ function WAREHOUSE:_JobDone() --------------- -- Info on job. - local text=string.format("Warehouse %s: Job on request id=%d for warehouse %s done!\n", self.alias, request.uid, request.warehouse.alias) - text=text..string.format("- %d of %d assets delivered. Casualties %d.", ncargodelivered, ncargotot, ncargodead) - if request.ntransport>0 then - text=text..string.format("\n- %d of %d transports returned home. Casualties %d.", ntransporthome, ntransporttot, ntransportdead) + if self.verbosity>=1 then + local text=string.format("Warehouse %s: Job on request id=%d for warehouse %s done!\n", self.alias, request.uid, request.warehouse.alias) + text=text..string.format("- %d of %d assets delivered. Casualties %d.", ncargodelivered, ncargotot, ncargodead) + if request.ntransport>0 then + text=text..string.format("\n- %d of %d transports returned home. Casualties %d.", ntransporthome, ntransporttot, ntransportdead) + end + self:_InfoMessage(text, 20) end - self:_InfoMessage(text, 20) -- Mark request for deletion. table.insert(done, request) @@ -3575,13 +3577,13 @@ function WAREHOUSE:_JobDone() -- Debug text. local text=string.format("Group %s: speed=%d km/h, onground=%s , airbase=%s, spawnzone=%s ==> ishome=%s", group:GetName(), speed, tostring(onground), airbase, tostring(inspawnzone), tostring(ishome)) - self:I(self.lid..text) + self:T(self.lid..text) if ishome then -- Info message. local text=string.format("Warehouse %s: Transport group arrived back home and no cargo left for request id=%d.\nSending transport group %s back to stock.", self.alias, request.uid, group:GetName()) - self:_InfoMessage(text) + self:T(self.lid..text) -- Debug smoke. if self.Debug then @@ -4807,7 +4809,7 @@ function WAREHOUSE:onafterArrived(From, Event, To, group) end -- Move asset from pending queue into new warehouse. - env.info("FF asset arrived in wh. adding in 60 sec") + self:T(self.lid.."Asset arrived at warehouse adding in 60 sec") warehouse:__AddAsset(60, group) end @@ -4822,8 +4824,10 @@ end function WAREHOUSE:onafterDelivered(From, Event, To, request) -- Debug info - local text=string.format("Warehouse %s: All assets delivered to warehouse %s!", self.alias, request.warehouse.alias) - self:_InfoMessage(text, 5) + if self.verbosity>=1 then + local text=string.format("Warehouse %s: All assets delivered to warehouse %s!", self.alias, request.warehouse.alias) + self:_InfoMessage(text, 5) + end -- Make some noise :) if self.Debug then @@ -5163,12 +5167,12 @@ function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request) local assetitem=_asset --#WAREHOUSE.Assetitem -- Debug info. - self:I(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname))) + self:T(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname))) if assetitem.spawned then n=n+1 else - self:E(self.lid.."FF What?! This should not happen!") + self:T(self.lid.."FF What?! This should not happen!") end end @@ -8498,8 +8502,8 @@ end -- @param #number duration Message display duration in seconds. Default 20 sec. If duration is zero, no message is displayed. function WAREHOUSE:_InfoMessage(text, duration) duration=duration or 20 - if duration>0 then - MESSAGE:New(text, duration):ToCoalitionIf(self:GetCoalition(), self.Debug or self.Report) + if duration>0 and self.Debug or self.Report then + MESSAGE:New(text, duration):ToCoalition(self:GetCoalition()) end self:I(self.lid..text) end diff --git a/Moose Development/Moose/Globals.lua b/Moose Development/Moose/Globals.lua index bdde44b6d..d972cf38b 100644 --- a/Moose Development/Moose/Globals.lua +++ b/Moose Development/Moose/Globals.lua @@ -15,4 +15,5 @@ _SETTINGS:SetPlayerMenuOn() _DATABASE:_RegisterCargos() _DATABASE:_RegisterZones() +_DATABASE:_RegisterAirbases() diff --git a/Moose Development/Moose/Ops/ArmyGroup.lua b/Moose Development/Moose/Ops/ArmyGroup.lua index f5e92a8ef..f5e169e38 100644 --- a/Moose Development/Moose/Ops/ArmyGroup.lua +++ b/Moose Development/Moose/Ops/ArmyGroup.lua @@ -113,9 +113,13 @@ function ARMYGROUP:New(GroupName) self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit) -- Start the status monitoring. - self:__CheckZone(-1) - self:__Status(-2) - self:__QueueUpdate(-3) + self:__Status(-1) + + -- Start check zone timer. + self.timerCheckZone=TIMER:New(self._CheckInZones, self):Start(2, 5) + + -- Start queue update timer. + self.timerQueueUpdate=TIMER:New(self._QueueUpdate, self):Start(3, 30) return self end @@ -292,7 +296,7 @@ end -- @param #string To To state. -- @param #ARMYGROUP.Element Element The group element. function ARMYGROUP:onafterElementSpawned(From, Event, To, Element) - self:I(self.lid..string.format("Element spawned %s", Element.name)) + self:T(self.lid..string.format("Element spawned %s", Element.name)) -- Set element status. self:_UpdateStatus(Element, OPSGROUP.ElementStatus.SPAWNED) @@ -318,7 +322,7 @@ end -- @param #string Event Event. -- @param #string To To state. function ARMYGROUP:onafterSpawned(From, Event, To) - self:I(self.lid..string.format("Group spawned!")) + self:T(self.lid..string.format("Group spawned!")) if self.ai then diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index 6ce63f05a..ca8ac0159 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -429,7 +429,7 @@ AUFTRAG.TargetType={ --- AUFTRAG class version. -- @field #string version -AUFTRAG.version="0.3.1" +AUFTRAG.version="0.5.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -1801,7 +1801,7 @@ end -- @param #AUFTRAG self -- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPSGROUP object. function AUFTRAG:AddOpsGroup(OpsGroup) - self:I(self.lid..string.format("Adding Ops group %s", OpsGroup.groupname)) + self:T(self.lid..string.format("Adding Ops group %s", OpsGroup.groupname)) local groupdata={} --#AUFTRAG.GroupData groupdata.opsgroup=OpsGroup @@ -1818,7 +1818,7 @@ end -- @param #AUFTRAG self -- @param Ops.OpsGroup#OPSGROUP OpsGroup The OPSGROUP object. function AUFTRAG:DelOpsGroup(OpsGroup) - self:I(self.lid..string.format("Removing OPS group %s", OpsGroup and OpsGroup.groupname or "nil (ERROR)!")) + self:T(self.lid..string.format("Removing OPS group %s", OpsGroup and OpsGroup.groupname or "nil (ERROR)!")) if OpsGroup then @@ -2139,15 +2139,24 @@ function AUFTRAG:Evaluate() -- Mission had targets --- - -- Number of current targets is still >0 ==> Not everything was destroyed. + -- Check if failed. if self.type==AUFTRAG.Type.TROOPTRANSPORT then + -- Transported groups have to survive. if Ntargets0 then failed=true end diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index e65d72d06..2cd3fc699 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -328,11 +328,13 @@ function FLIGHTGROUP:New(group) self:_InitGroup() -- Start the status monitoring. - self:__CheckZone(-1) - self:__Status(-2) - self:__QueueUpdate(-3) - - --self.Timer=SCHEDULER:New() + self:__Status(-1) + + -- Start queue update timer. + self.timerQueueUpdate=TIMER:New(self._QueueUpdate, self):Start(2, 5) + + -- Start check zone timer. + self.timerCheckZone=TIMER:New(self._CheckInZones, self):Start(3, 10) return self end @@ -356,7 +358,7 @@ end -- @param Ops.AirWing#AIRWING airwing The AIRWING object. -- @return #FLIGHTGROUP self function FLIGHTGROUP:SetAirwing(airwing) - self:I(self.lid..string.format("Add flight to AIRWING %s", airwing.alias)) + self:T(self.lid..string.format("Add flight to AIRWING %s", airwing.alias)) self.airwing=airwing return self end @@ -2409,6 +2411,9 @@ function FLIGHTGROUP:onafterStop(From, Event, To) self:UnHandleEvent(EVENTS.Ejection) self:UnHandleEvent(EVENTS.Crash) self:UnHandleEvent(EVENTS.RemoveUnit) + + self.timerCheckZone:Stop() + self.timerQueueUpdate:Stop() self.CallScheduler:Clear() @@ -2437,7 +2442,7 @@ end -- @param Wrapper.Group#GROUP group Group object. -- @param #FLIGHTGROUP flightgroup Flight group object. function FLIGHTGROUP._ReachedHolding(group, flightgroup) - flightgroup:I(flightgroup.lid..string.format("Group reached holding point")) + flightgroup:T2(flightgroup.lid..string.format("Group reached holding point")) -- Trigger Holding event. flightgroup:__Holding(-1) @@ -2447,7 +2452,7 @@ end -- @param Wrapper.Group#GROUP group Group object. -- @param #FLIGHTGROUP flightgroup Flight group object. function FLIGHTGROUP._ClearedToLand(group, flightgroup) - flightgroup:I(flightgroup.lid..string.format("Group was cleared to land")) + flightgroup:T2(flightgroup.lid..string.format("Group was cleared to land")) -- Trigger Landing event. flightgroup:__Landing(-1) @@ -2457,7 +2462,7 @@ end -- @param Wrapper.Group#GROUP group Group object. -- @param #FLIGHTGROUP flightgroup Flight group object. function FLIGHTGROUP._FinishedRefuelling(group, flightgroup) - flightgroup:T(flightgroup.lid..string.format("Group finished refueling")) + flightgroup:T2(flightgroup.lid..string.format("Group finished refueling")) -- Trigger Holding event. flightgroup:__Refueled(-1) @@ -2633,7 +2638,7 @@ function FLIGHTGROUP:AddElementByName(unitname) local text=string.format("Adding element %s: status=%s, skill=%s, modex=%s, fuelmass=%.1f (%d), category=%d, categoryname=%s, callsign=%s, ai=%s", element.name, element.status, element.skill, element.modex, element.fuelmass, element.fuelrel*100, element.category, element.categoryname, element.callsign, tostring(element.ai)) - self:I(self.lid..text) + self:T(self.lid..text) -- Add element to table. table.insert(self.elements, element) diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 9312b19c2..a7eb20c31 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -154,10 +154,14 @@ function NAVYGROUP:New(GroupName) self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit) -- Start the status monitoring. - self:__CheckZone(-1) - self:__Status(-2) - self:__QueueUpdate(-3) - + self:__Status(-1) + + -- Start check zone timer. + self.timerCheckZone=TIMER:New(self._CheckInZones, self):Start(2, 5) + + -- Start queue update timer. + self.timerQueueUpdate=TIMER:New(self._QueueUpdate, self):Start(3, 60) + return self end @@ -505,7 +509,7 @@ end -- @param #string To To state. -- @param #NAVYGROUP.Element Element The group element. function NAVYGROUP:onafterElementSpawned(From, Event, To, Element) - self:I(self.lid..string.format("Element spawned %s", Element.name)) + self:T(self.lid..string.format("Element spawned %s", Element.name)) -- Set element status. self:_UpdateStatus(Element, OPSGROUP.ElementStatus.SPAWNED) @@ -531,7 +535,7 @@ end -- @param #string Event Event. -- @param #string To To state. function NAVYGROUP:onafterSpawned(From, Event, To) - self:I(self.lid..string.format("Group spawned!")) + self:T(self.lid..string.format("Group spawned!")) if self.ai then @@ -652,7 +656,7 @@ function NAVYGROUP:onafterUpdateRoute(From, Event, To, n, Speed, Depth) if #waypoints>1 then - self:I(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m", + self:T(self.lid..string.format("Updateing route: WP %d-->%d-->%d (#%d), Speed=%.1f knots, Depth=%d m", self.currentwp, n, #self.waypoints, #waypoints-1, UTILS.MpsToKnots(self.speed), depth)) @@ -710,7 +714,7 @@ end -- @param #string Event Event. -- @param #string To To state. function NAVYGROUP:onafterDetourReached(From, Event, To) - self:I(self.lid.."Group reached detour coordinate.") + self:T(self.lid.."Group reached detour coordinate.") end --- On after "TurnIntoWind" event. @@ -770,7 +774,8 @@ end -- @param #boolean Uturn Return to the place we came from. function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To) - env.info("FF Turn Into Wind Over!") + -- Debug message. + self:T2(self.lid.."Turn Into Wind Over!") self.intowind.Over=true self.intowind.Open=false @@ -779,10 +784,10 @@ function NAVYGROUP:onafterTurnIntoWindOver(From, Event, To) self:RemoveWaypointByID(self.intowind.waypoint.uid) if self.intowind.Uturn then - env.info("FF Turn Into Wind Over Uturn!") + self:T(self.lid.."Turn Into Wind Over ==> Uturn!") self:Detour(self.intowind.Coordinate, self:GetSpeedCruise(), 0, true) else - env.info("FF Turn Into Wind Over Next WP!") + self:T(self.lid.."FF Turn Into Wind Over ==> Next WP!") local indx=self:GetWaypointIndexNext() local speed=self:GetWaypointSpeed(indx) self:__UpdateRoute(-1, indx, speed) @@ -1041,7 +1046,7 @@ function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Up -- Check if a coordinate was given or at least a positionable. if not Coordinate:IsInstanceOf("COORDINATE") then if Coordinate:IsInstanceOf("POSITIONABLE") or Coordinate:IsInstanceOf("ZONE_BASE") then - self:I(self.lid.."WARNING: Coordinate is not a COORDINATE but a POSITIONABLE. Trying to get coordinate") + self:T(self.lid.."WARNING: Coordinate is not a COORDINATE but a POSITIONABLE. Trying to get coordinate") Coordinate=Coordinate:GetCoordinate() else self:E(self.lid.."ERROR: Coordinate is neither a COORDINATE nor any POSITIONABLE!") @@ -1070,7 +1075,7 @@ function NAVYGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Depth, Up self:_AddWaypoint(waypoint, wpnumber) -- Debug info. - self:I(self.lid..string.format("Adding NAVAL waypoint index=%d uid=%d, speed=%.1f knots. Last waypoint passed was #%d. Total waypoints #%d", wpnumber, waypoint.uid, Speed, self.currentwp, #self.waypoints)) + self:T(self.lid..string.format("Adding NAVAL waypoint index=%d uid=%d, speed=%.1f knots. Last waypoint passed was #%d. Total waypoints #%d", wpnumber, waypoint.uid, Speed, self.currentwp, #self.waypoints)) -- Update route. if Updateroute==nil or Updateroute==true then diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 1976f178b..98bf57796 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -45,6 +45,8 @@ -- @field #boolean respawning Group is being respawned. -- @field Core.Set#SET_ZONE checkzones Set of zones. -- @field Core.Set#SET_ZONE inzones Set of zones in which the group is currently in. +-- @field Core.Timer#TIMER timerCheckZone Timer for check zones. +-- @field Core.Timer#TIMER timerQueueUpdate Timer for queue updates. -- @field #boolean groupinitialized If true, group parameters were initialized. -- @field #boolean detectionOn If true, detected units of the group are analyzed. -- @field Ops.Auftrag#AUFTRAG missionpaused Paused mission. @@ -315,7 +317,6 @@ function OPSGROUP:New(Group) self:AddTransition("*", "Stop", "Stopped") -- Stop FSM. self:AddTransition("*", "Status", "*") -- Status update. - self:AddTransition("*", "QueueUpdate", "*") -- Update task and mission queues. self:AddTransition("*", "UpdateRoute", "*") -- Update route of group. Only if airborne. self:AddTransition("*", "Respawn", "*") -- Respawn group. @@ -335,7 +336,6 @@ function OPSGROUP:New(Group) self:AddTransition("*", "OutOfBombs", "*") -- Group is out of bombs. self:AddTransition("*", "OutOfMissiles", "*") -- Group is out of missiles. - self:AddTransition("*", "CheckZone", "*") -- Check if group enters/leaves a certain zone. self:AddTransition("*", "EnterZone", "*") -- Group entered a certain zone. self:AddTransition("*", "LeaveZone", "*") -- Group leaves a certain zone. @@ -1038,7 +1038,7 @@ function OPSGROUP:RemoveWaypoint(wpindex) local n=#self.waypoints -- Debug info. - self:I(self.lid..string.format("Removing waypoint index %d, current wp index %d. N %d-->%d", wpindex, self.currentwp, N, n)) + self:T(self.lid..string.format("Removing waypoint index %d, current wp index %d. N %d-->%d", wpindex, self.currentwp, N, n)) -- Waypoint was not reached yet. if wpindex > self.currentwp then @@ -1188,7 +1188,7 @@ function OPSGROUP:AddTask(task, clock, description, prio, duration) table.insert(self.taskqueue, newtask) -- Info. - self:I(self.lid..string.format("Adding SCHEDULED task %s starting at %s", newtask.description, UTILS.SecondsToClock(newtask.time, true))) + self:T(self.lid..string.format("Adding SCHEDULED task %s starting at %s", newtask.description, UTILS.SecondsToClock(newtask.time, true))) self:T3({newtask=newtask}) return newtask @@ -1475,7 +1475,7 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task) -- Debug message. local text=string.format("Task %s ID=%d execute", tostring(Task.description), Task.id) - self:I(self.lid..text) + self:T(self.lid..text) -- Cancel current task if there is any. if self.taskcurrent>0 then @@ -1585,7 +1585,7 @@ function OPSGROUP:onafterTaskCancel(From, Event, To, Task) -- Debug info. local text=string.format("Current task %s ID=%d cancelled (flag %s=%d)", Task.description, Task.id, Task.stopflag:GetName(), stopflag) - self:I(self.lid..text) + self:T(self.lid..text) -- Set stop flag. When the flag is true, the _TaskDone function is executed and calls :TaskDone() Task.stopflag:Set(1) @@ -1601,7 +1601,7 @@ function OPSGROUP:onafterTaskCancel(From, Event, To, Task) else -- Debug info. - self:I(self.lid..string.format("TaskCancel: Setting task %s ID=%d to DONE", Task.description, Task.id)) + self:T(self.lid..string.format("TaskCancel: Setting task %s ID=%d to DONE", Task.description, Task.id)) -- Call task done function. self:TaskDone(Task) @@ -1645,7 +1645,7 @@ function OPSGROUP:onafterTaskDone(From, Event, To, Task) -- Debug message. local text=string.format("Task done: %s ID=%d", Task.description, Task.id) - self:I(self.lid..text) + self:T(self.lid..text) -- No current task. if Task.id==self.taskcurrent then @@ -1703,7 +1703,7 @@ function OPSGROUP:AddMission(Mission) -- Info text. local text=string.format("Added %s mission %s starting at %s, stopping at %s", tostring(Mission.type), tostring(Mission.name), UTILS.SecondsToClock(Mission.Tstart, true), Mission.Tstop and UTILS.SecondsToClock(Mission.Tstop, true) or "INF") - self:I(self.lid..text) + self:T(self.lid..text) return self end @@ -2015,7 +2015,7 @@ function OPSGROUP:onafterMissionCancel(From, Event, To, Mission) local Task=Mission:GetGroupWaypointTask(self) -- Debug info. - self:I(self.lid..string.format("Cancel current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF"))) + self:T(self.lid..string.format("Cancel current mission %s. Task=%s", tostring(Mission.name), tostring(Task and Task.description or "WTF"))) -- Cancelling the mission is actually cancelling the current task. -- Note that two things can happen. @@ -2053,7 +2053,7 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission) -- Debug info. local text=string.format("Mission %s DONE!", Mission.name) - self:I(self.lid..text) + self:T(self.lid..text) -- Set group status. Mission:SetGroupStatus(self, AUFTRAG.GroupStatus.DONE) @@ -2196,10 +2196,9 @@ end --- On after "QueueUpdate" event. -- @param #OPSGROUP self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. -function OPSGROUP:onafterQueueUpdate(From, Event, To) +function OPSGROUP:_QueueUpdate() + + --env.info(self.lid.."FF queueupdate T="..timer.getTime()) --- -- Mission @@ -2253,10 +2252,6 @@ function OPSGROUP:onafterQueueUpdate(From, Event, To) end - -- Update queue every ~5 sec. - if not self:IsStopped() then - self:__QueueUpdate(-5) - end end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -2427,22 +2422,6 @@ function OPSGROUP:onafterLeaveZone(From, Event, To, Zone) self.inzones:Remove(zonename, true) end ---- On after "CheckZone" event. --- @param #OPSGROUP self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. -function OPSGROUP:onafterCheckZone(From, Event, To) - - if self:IsAlive()==true then - self:_CheckInZones() - end - - if not self:IsStopped() then - self:__CheckZone(-10) - end -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Internal Check Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -2451,7 +2430,7 @@ end -- @param #OPSGROUP self function OPSGROUP:_CheckInZones() - if self.checkzones then + if self.checkzones and self:IsAlive() then local Ncheck=self.checkzones:Count() local Ninside=self.inzones:Count() diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index 1c344c896..979368b0e 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -17,6 +17,7 @@ -- @field #table CategoryName Names of airbase categories. -- @field #string AirbaseName Name of the airbase. -- @field #number AirbaseID Airbase ID. +-- @field Core.Zone#ZONE AirbaseZone Circular zone around the airbase with a radius of 2500 meters. For ships this is a ZONE_UNIT object. -- @field #number category Airbase category. -- @field #table descriptors DCS descriptors. -- @field #boolean isAirdrome Airbase is an airdrome. @@ -493,8 +494,14 @@ function AIRBASE:Register(AirbaseName) self:GetCoordinate() if vec2 then - -- TODO: For ships we need a moving zone. - self.AirbaseZone=ZONE_RADIUS:New( AirbaseName, vec2, 2500 ) + if self.isShip then + local unit=UNIT:FindByName(AirbaseName) + if unit then + self.AirbaseZone=ZONE_UNIT:New(AirbaseName, unit, 2500) + end + else + self.AirbaseZone=ZONE_RADIUS:New(AirbaseName, vec2, 2500) + end else self:E(string.format("ERROR: Cound not get position Vec2 of airbase %s", AirbaseName)) end