From d8dcf378861ff466f03d4ab5914d997e4bc896fe Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 14 Dec 2024 13:48:04 +0100 Subject: [PATCH] DATABASE - Fixed error that static was not returned in `DATABASE:AddStatic()` (leads to issues if a static object with the same name is spawned) - Other minor changes --- Moose Development/Moose/Core/Base.lua | 17 +++++------------ Moose Development/Moose/Core/Database.lua | 11 ++++------- Moose Development/Moose/Wrapper/Airbase.lua | 1 + Moose Development/Moose/Wrapper/Static.lua | 2 ++ 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua index 76e516799..5de2096a3 100644 --- a/Moose Development/Moose/Core/Base.lua +++ b/Moose Development/Moose/Core/Base.lua @@ -34,11 +34,12 @@ local _TraceClassMethod = {} local _ClassID = 0 ---- +--- Base class of everything -- @type BASE --- @field ClassName The name of the class. --- @field ClassID The ID number of the class. --- @field ClassNameAndID The name of the class concatenated with the ID number of the class. +-- @field #string ClassName The name of the class. +-- @field #number ClassID The ID number of the class. +-- @field #string ClassNameAndID The name of the class concatenated with the ID number of the class. +-- @field Core.Scheduler#SCHEDULER Scheduler The scheduler object. --- BASE class -- @@ -210,14 +211,6 @@ BASE._ = { Schedules = {}, --- Contains the Schedulers Active } ---- The Formation Class --- @type FORMATION --- @field Cone A cone formation. -FORMATION = { - Cone = "Cone", - Vee = "Vee", -} - --- BASE constructor. -- -- This is an example how to use the BASE:New() constructor in a new class definition when inheriting from BASE. diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 6270f1fa6..4aec2393a 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -211,10 +211,9 @@ function DATABASE:AddStatic( DCSStaticName ) if not self.STATICS[DCSStaticName] then self.STATICS[DCSStaticName] = STATIC:Register( DCSStaticName ) - return self.STATICS[DCSStaticName] end - return nil + return self.STATICS[DCSStaticName] end @@ -224,12 +223,11 @@ function DATABASE:DeleteStatic( DCSStaticName ) self.STATICS[DCSStaticName] = nil end ---- Finds a STATIC based on the StaticName. +--- Finds a STATIC based on the Static Name. -- @param #DATABASE self --- @param #string StaticName +-- @param #string StaticName Name of the static object. -- @return Wrapper.Static#STATIC The found STATIC. function DATABASE:FindStatic( StaticName ) - local StaticFound = self.STATICS[StaticName] return StaticFound end @@ -241,9 +239,8 @@ end function DATABASE:AddDynamicCargo( Name ) if not self.DYNAMICCARGO[Name] then self.DYNAMICCARGO[Name] = DYNAMICCARGO:Register(Name) - return self.DYNAMICCARGO[Name] end - return nil + return self.DYNAMICCARGO[Name] end --- Finds a DYNAMICCARGO based on the Dynamic Cargo Name. diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index 96888381a..3d40d8384 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -869,6 +869,7 @@ AIRBASE.Afghanistan = { -- * `AIRBASE.Iraq.Qayyarah_Airfield_West` Qayyarah Airfield West -- * `AIRBASE.Iraq.K1_Base` K1 Base -- +-- @field Iraq AIRBASE.Iraq = { ["Baghdad_International_Airport"] = "Baghdad International Airport", ["Sulaimaniyah_International_Airport"] = "Sulaimaniyah International Airport", diff --git a/Moose Development/Moose/Wrapper/Static.lua b/Moose Development/Moose/Wrapper/Static.lua index 557d117cc..7c2436641 100644 --- a/Moose Development/Moose/Wrapper/Static.lua +++ b/Moose Development/Moose/Wrapper/Static.lua @@ -61,6 +61,8 @@ function STATIC:Register( StaticName ) if DCSStatic then local Life0 = DCSStatic:getLife() or 1 self.Life0 = Life0 + else + self:E(string.format("Static object %s does not exist!", tostring(self.StaticName))) end return self