From 2ca6168f475b6c4ed7d0d800cfdf03293155e438 Mon Sep 17 00:00:00 2001 From: Jason du Plessis <33880363+TheChosenOn3@users.noreply.github.com> Date: Thu, 6 Oct 2022 05:27:07 +0000 Subject: [PATCH] #ZONE * Fixed ZONE_RADIUS Not being added to _Database (#1798) * #ZONE * Fixed ZONE_RADIUS Not being added to _Database Bugfix for #1797. ZONE_RADIUS was not being registered within the _Database table, thus for CTLD, the Zone could not be found for moving units to ZONE_RADIUS zones. Because other Zone types inherit ZONE_RADIUS, I've added a RegisterZone parameter that is default to true, and modified the inheritance of the other Zone types to register the zone in the _Database depending if the zone does not get registered in that zone type. * #ZONE * Updated ZONE_RADIUS RegisterZone to DoNotRegisterZone Changed RegisterZone to DoNotRegisterZone and updated the different zone types values for RegisterZone. Suggested by Applevangelist. Co-authored-by: Jason du Plessis --- Moose Development/Moose/Core/Zone.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 296dbb3ba..d19725683 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -631,8 +631,9 @@ ZONE_RADIUS = { -- @param #string ZoneName Name of the zone. -- @param DCS#Vec2 Vec2 The location of the zone. -- @param DCS#Distance Radius The radius of the zone. +-- @param DCS#Boolean DoNotRegisterZone Determins if the Zone should not be registered in the _Database Table. Default=false -- @return #ZONE_RADIUS self -function ZONE_RADIUS:New( ZoneName, Vec2, Radius ) +function ZONE_RADIUS:New( ZoneName, Vec2, Radius, DoNotRegisterZone ) -- Inherit ZONE_BASE. local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) ) -- #ZONE_RADIUS @@ -641,6 +642,10 @@ function ZONE_RADIUS:New( ZoneName, Vec2, Radius ) self.Radius = Radius self.Vec2 = Vec2 + if not DoNotRegisterZone then + _EVENTDISPATCHER:CreateEventNewZone(self) + end + --self.Coordinate=COORDINATE:NewFromVec2(Vec2) return self @@ -1538,7 +1543,7 @@ function ZONE:New( ZoneName ) end -- Create a new ZONE_RADIUS. - local self=BASE:Inherit( self, ZONE_RADIUS:New(ZoneName, {x=Zone.point.x, y=Zone.point.z}, Zone.radius)) + local self=BASE:Inherit( self, ZONE_RADIUS:New(ZoneName, {x=Zone.point.x, y=Zone.point.z}, Zone.radius, true)) self:F(ZoneName) -- Color of zone. @@ -1605,7 +1610,7 @@ function ZONE_UNIT:New( ZoneName, ZoneUNIT, Radius, Offset) self.relative_to_unit = Offset.relative_to_unit or false end - local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, ZoneUNIT:GetVec2(), Radius ) ) + local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, ZoneUNIT:GetVec2(), Radius, true ) ) self:F( { ZoneName, ZoneUNIT:GetVec2(), Radius } ) @@ -1721,7 +1726,7 @@ ZONE_GROUP = { -- @param DCS#Distance Radius The radius of the zone. -- @return #ZONE_GROUP self function ZONE_GROUP:New( ZoneName, ZoneGROUP, Radius ) - local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, ZoneGROUP:GetVec2(), Radius ) ) + local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, ZoneGROUP:GetVec2(), Radius, true ) ) self:F( { ZoneName, ZoneGROUP:GetVec2(), Radius } ) self._.ZoneGROUP = ZoneGROUP @@ -2321,7 +2326,7 @@ function ZONE_POLYGON_BASE:Boundary(Coalition, Color, Radius, Alpha, Segments, C for Segment = 0, Segments do local PointX = self._.Polygon[i].x + ( Segment * DeltaX / Segments ) local PointY = self._.Polygon[i].y + ( Segment * DeltaY / Segments ) - ZONE_RADIUS:New( "Zone", {x = PointX, y = PointY}, Radius ):DrawZone(Coalition, Color, 1, Color, Alpha, nil, true) + ZONE_RADIUS:New( "Zone", {x = PointX, y = PointY}, Radius, true ):DrawZone(Coalition, Color, 1, Color, Alpha, nil, false) end end j = i @@ -2948,7 +2953,7 @@ do -- ZONE_AIRBASE local Airbase = AIRBASE:FindByName( AirbaseName ) - local self = BASE:Inherit( self, ZONE_RADIUS:New( AirbaseName, Airbase:GetVec2(), Radius ) ) + local self = BASE:Inherit( self, ZONE_RADIUS:New( AirbaseName, Airbase:GetVec2(), Radius, true ) ) self._.ZoneAirbase = Airbase self._.ZoneVec2Cache = self._.ZoneAirbase:GetVec2()