From 89aa08829eab164dc0ae7afd4806f4e736275a4a Mon Sep 17 00:00:00 2001 From: Applevangelist <72444570+Applevangelist@users.noreply.github.com> Date: Wed, 20 Jan 2021 11:05:14 +0100 Subject: [PATCH 1/3] Update ATIS.lua Fix time to be negative if early AM when using time to ZULU or time to GMT difference --- Moose Development/Moose/Ops/ATIS.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index 29b2918b2..688b743b7 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -1318,6 +1318,10 @@ function ATIS:onafterBroadcast(From, Event, To) time=time-UTILS.GMTToLocalTimeDifference()*60*60 end + if time < 0 then + time = 24*60*60 - time --avoid negative time around midnight + end + local clock=UTILS.SecondsToClock(time) local zulu=UTILS.Split(clock, ":") local ZULU=string.format("%s%s", zulu[1], zulu[2]) From a6ff84c09a1d2715f7549c6354c16547dd5b2e0a Mon Sep 17 00:00:00 2001 From: Applevangelist <72444570+Applevangelist@users.noreply.github.com> Date: Thu, 21 Jan 2021 15:34:50 +0100 Subject: [PATCH 2/3] ATIS.lua update time calculation over midnight (logic error) Actually line 1322 + time here, sind it's negative ... :) --- Moose Development/Moose/Ops/ATIS.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index 688b743b7..044963a28 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -1319,7 +1319,7 @@ function ATIS:onafterBroadcast(From, Event, To) end if time < 0 then - time = 24*60*60 - time --avoid negative time around midnight + time = 24*60*60 + time --avoid negative time around midnight end local clock=UTILS.SecondsToClock(time) From e9f92d225033d5cd6ee45a63660307fdc166bcd9 Mon Sep 17 00:00:00 2001 From: Applevangelist <72444570+Applevangelist@users.noreply.github.com> Date: Fri, 22 Jan 2021 18:34:05 +0100 Subject: [PATCH 3/3] Update Set.lua Break loop after x tries --- Moose Development/Moose/Core/Set.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 41261abcc..87bcf9e4a 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -5411,10 +5411,12 @@ do -- SET_ZONE --- Get a random zone from the set. -- @param #SET_ZONE self + -- @param #number margin Number of tries to find a zone -- @return Core.Zone#ZONE_BASE The random Zone. -- @return #nil if no zone in the collection. - function SET_ZONE:GetRandomZone() - + function SET_ZONE:GetRandomZone(margin) + + local margin = margin or 100 if self:Count() ~= 0 then local Index = self.Index @@ -5423,9 +5425,11 @@ do -- SET_ZONE -- Loop until a zone has been found. -- The :GetZoneMaybe() call will evaluate the probability for the zone to be selected. -- If the zone is not selected, then nil is returned by :GetZoneMaybe() and the loop continues! - while not ZoneFound do + local counter = 0 + while (not ZoneFound) or (counter < margin) do local ZoneRandom = math.random( 1, #Index ) ZoneFound = self.Set[Index[ZoneRandom]]:GetZoneMaybe() + counter = counter + 1 end return ZoneFound