Skip to content

Commit

Permalink
Fixed getCategory checks
Browse files Browse the repository at this point in the history
Fixed getCategory calls for Object.getCategory()
  • Loading branch information
mrSkortch committed Nov 17, 2023
1 parent ab55753 commit e6bdd50
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions mist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mist = {}
-- don't change these
mist.majorVersion = 4
mist.minorVersion = 5
mist.build = 119
mist.build = 120

-- forward declaration of log shorthand
local log
Expand Down Expand Up @@ -998,7 +998,7 @@ do -- the main scope
if #unitOneRef > 0 and unitOneRef[1] and type(unitOneRef[1]) == 'table' then
newTable.countryId = tonumber(unitOneRef[1]:getCountry())
newTable.coalitionId = tonumber(unitOneRef[1]:getCoalition())
newTable.category = tonumber(newObject:getCategory())
newTable.category = tonumber(Object.getCategory(newObject))
else
log:warn('getUnits failed to return on $1 ; Built Data: $2.', event, newTable)
return false
Expand Down Expand Up @@ -1115,7 +1115,7 @@ do -- the main scope
newTable.units[1].country = newTable.country
newTable.units[1].coalitionId = newTable.coalitionId
newTable.units[1].coalition = newTable.coalition
if newObject:getCategory() == 6 and newObject:getCargoDisplayName() then
if Object.getCategory(newObject) == 6 and newObject:getCargoDisplayName() then
local mass = newObject:getCargoDisplayName()
mass = string.gsub(mass, ' ', '')
mass = string.gsub(mass, 'kg', '')
Expand Down Expand Up @@ -3422,7 +3422,7 @@ function mist.getUnitsInPolygon(unit_names, polyZone, max_alt)
local inZoneUnits = {}
for i =1, #units do
local lUnit = units[i]
local lCat = lUnit:getCategory()
local lCat = Object.getCategory(lUnit)
if lUnit:isExist() == true and ((lCat == 1 and lUnit:isActive()) or lCat ~= 1) and mist.pointInPolygon(lUnit:getPosition().p, polyZone, max_alt) then
inZoneUnits[#inZoneUnits + 1] = lUnit
end
Expand Down Expand Up @@ -3468,7 +3468,7 @@ function mist.getUnitsInZones(unit_names, zone_names, zone_type)
for units_ind = 1, #units do
local lUnit = units[units_ind]
local unit_pos = lUnit:getPosition().p
local lCat = lUnit:getCategory()
local lCat = Object.getCategory(lUnit)
for zones_ind = 1, #zones do
if zone_type == 'sphere' then --add land height value for sphere zone type
local alt = land.getHeight({x = zones[zones_ind].x, y = zones[zones_ind].z})
Expand Down Expand Up @@ -3531,7 +3531,7 @@ function mist.getUnitsInMovingZones(unit_names, zone_unit_names, radius, zone_ty

for units_ind = 1, #units do
local lUnit = units[units_ind]
local lCat = lUnit:getCategory()
local lCat = Object.getCategory(lUnit)
local unit_pos = lUnit:getPosition().p
for zone_units_ind = 1, #zone_units do

Expand Down Expand Up @@ -3559,7 +3559,7 @@ function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
-- get the positions all in one step, saves execution time.
for unitset1_ind = 1, #unitset1 do
local unit1 = Unit.getByName(unitset1[unitset1_ind])
local lCat = unit1:getCategory()
local lCat = Object.getCategory(unit1)
if unit1 and ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit:isExist() == true then
unit_info1[#unit_info1 + 1] = {}
unit_info1[#unit_info1].unit = unit1
Expand All @@ -3569,7 +3569,7 @@ function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)

for unitset2_ind = 1, #unitset2 do
local unit2 = Unit.getByName(unitset2[unitset2_ind])
local lCat = unit2:getCategory()
local lCat = Object.getCategory(unit2)
if unit2 and ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit:isExist() == true then
unit_info2[#unit_info2 + 1] = {}
unit_info2[#unit_info2].unit = unit2
Expand Down
16 changes: 8 additions & 8 deletions mist_4_5_119.lua → mist_4_5_120.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mist = {}
-- don't change these
mist.majorVersion = 4
mist.minorVersion = 5
mist.build = 119
mist.build = 120

-- forward declaration of log shorthand
local log
Expand Down Expand Up @@ -998,7 +998,7 @@ do -- the main scope
if #unitOneRef > 0 and unitOneRef[1] and type(unitOneRef[1]) == 'table' then
newTable.countryId = tonumber(unitOneRef[1]:getCountry())
newTable.coalitionId = tonumber(unitOneRef[1]:getCoalition())
newTable.category = tonumber(newObject:getCategory())
newTable.category = tonumber(Object.getCategory(newObject))
else
log:warn('getUnits failed to return on $1 ; Built Data: $2.', event, newTable)
return false
Expand Down Expand Up @@ -1115,7 +1115,7 @@ do -- the main scope
newTable.units[1].country = newTable.country
newTable.units[1].coalitionId = newTable.coalitionId
newTable.units[1].coalition = newTable.coalition
if newObject:getCategory() == 6 and newObject:getCargoDisplayName() then
if Object.getCategory(newObject) == 6 and newObject:getCargoDisplayName() then
local mass = newObject:getCargoDisplayName()
mass = string.gsub(mass, ' ', '')
mass = string.gsub(mass, 'kg', '')
Expand Down Expand Up @@ -3422,7 +3422,7 @@ function mist.getUnitsInPolygon(unit_names, polyZone, max_alt)
local inZoneUnits = {}
for i =1, #units do
local lUnit = units[i]
local lCat = lUnit:getCategory()
local lCat = Object.getCategory(lUnit)
if lUnit:isExist() == true and ((lCat == 1 and lUnit:isActive()) or lCat ~= 1) and mist.pointInPolygon(lUnit:getPosition().p, polyZone, max_alt) then
inZoneUnits[#inZoneUnits + 1] = lUnit
end
Expand Down Expand Up @@ -3468,7 +3468,7 @@ function mist.getUnitsInZones(unit_names, zone_names, zone_type)
for units_ind = 1, #units do
local lUnit = units[units_ind]
local unit_pos = lUnit:getPosition().p
local lCat = lUnit:getCategory()
local lCat = Object.getCategory(lUnit)
for zones_ind = 1, #zones do
if zone_type == 'sphere' then --add land height value for sphere zone type
local alt = land.getHeight({x = zones[zones_ind].x, y = zones[zones_ind].z})
Expand Down Expand Up @@ -3531,7 +3531,7 @@ function mist.getUnitsInMovingZones(unit_names, zone_unit_names, radius, zone_ty

for units_ind = 1, #units do
local lUnit = units[units_ind]
local lCat = lUnit:getCategory()
local lCat = Object.getCategory(lUnit)
local unit_pos = lUnit:getPosition().p
for zone_units_ind = 1, #zone_units do

Expand Down Expand Up @@ -3559,7 +3559,7 @@ function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
-- get the positions all in one step, saves execution time.
for unitset1_ind = 1, #unitset1 do
local unit1 = Unit.getByName(unitset1[unitset1_ind])
local lCat = unit1:getCategory()
local lCat = Object.getCategory(unit1)
if unit1 and ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit:isExist() == true then
unit_info1[#unit_info1 + 1] = {}
unit_info1[#unit_info1].unit = unit1
Expand All @@ -3569,7 +3569,7 @@ function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)

for unitset2_ind = 1, #unitset2 do
local unit2 = Unit.getByName(unitset2[unitset2_ind])
local lCat = unit2:getCategory()
local lCat = Object.getCategory(unit2)
if unit2 and ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit:isExist() == true then
unit_info2[#unit_info2 + 1] = {}
unit_info2[#unit_info2].unit = unit2
Expand Down

0 comments on commit e6bdd50

Please sign in to comment.