Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 54 additions & 52 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 = 121
mist.build = 122

-- forward declaration of log shorthand
local log
Expand Down Expand Up @@ -97,57 +97,6 @@ do -- the main scope
mist.DBs.missionData.countries = {}
end

mist.DBs.zonesByName = {}
mist.DBs.zonesByNum = {}


if env.mission.triggers and env.mission.triggers.zones then
for zone_ind, zone_data in pairs(env.mission.triggers.zones) do
if type(zone_data) == 'table' then
local zone = mist.utils.deepCopy(zone_data)
--log:warn(zone)
zone.point = {} -- point is used by SSE
zone.point.x = zone_data.x
zone.point.y = land.getHeight({x = zone_data.x, y = zone_data.y})
zone.point.z = zone_data.y
zone.properties = {}
if zone_data.properties then
for propInd, prop in pairs(zone_data.properties) do
if prop.value and tostring(prop.value) ~= "" then
zone.properties[prop.key] = prop.value
end
end
end
if zone.verticies then -- trust but verify
local r = 0
for i = 1, #zone.verticies do
local dist = mist.utils.get2DDist(zone.point, zone.verticies[i])
if dist > r then
r = mist.utils.deepCopy(dist)
end
end
zone.radius = r

end
if zone.linkUnit then
local uRef = mist.DBs.unitsByName[zone.linkUnit]
if zone.verticies then
local offset = {}
for i = 1, #zone.verticies do
table.insert(offset, {dist = mist.utils.get2DDist(uRef.point, zone.verticies[i]), heading = mist.getHeadingPoints(uRef.point, zone.verticies[i]) + uRef.heading})
end
zone.offset = offset
else
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
end
end

mist.DBs.zonesByName[zone_data.name] = zone
mist.DBs.zonesByNum[#mist.DBs.zonesByNum + 1] = mist.utils.deepCopy(zone) --[[deepcopy so that the zone in zones_by_name and the zone in
zones_by_num se are different objects.. don't want them linked.]]
end
end
end

mist.DBs.drawingByName = {}
mist.DBs.drawingIndexed = {}
Expand Down Expand Up @@ -842,6 +791,59 @@ do -- the main scope
end
end

mist.DBs.zonesByName = {}
mist.DBs.zonesByNum = {}

if env.mission.triggers and env.mission.triggers.zones then
for zone_ind, zone_data in pairs(env.mission.triggers.zones) do
if type(zone_data) == 'table' then
local zone = mist.utils.deepCopy(zone_data)
--log:warn(zone)
zone.point = {} -- point is used by SSE
zone.point.x = zone_data.x
zone.point.y = land.getHeight({x = zone_data.x, y = zone_data.y})
zone.point.z = zone_data.y
zone.properties = {}
if zone_data.properties then
for propInd, prop in pairs(zone_data.properties) do
if prop.value and tostring(prop.value) ~= "" then
zone.properties[prop.key] = prop.value
end
end
end
if zone.verticies then -- trust but verify
local r = 0
for i = 1, #zone.verticies do
local dist = mist.utils.get2DDist(zone.point, zone.verticies[i])
if dist > r then
r = mist.utils.deepCopy(dist)
end
end
zone.radius = r

end
if zone.linkUnit then
local uRef = mist.DBs.unitsByName[zone.linkUnit]
if uRef then
if zone.verticies then
local offset = {}
for i = 1, #zone.verticies do
table.insert(offset, {dist = mist.utils.get2DDist(uRef.point, zone.verticies[i]), heading = mist.getHeadingPoints(uRef.point, zone.verticies[i]) + uRef.heading})
end
zone.offset = offset
else
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
end
end
end

mist.DBs.zonesByName[zone_data.name] = zone
mist.DBs.zonesByNum[#mist.DBs.zonesByNum + 1] = mist.utils.deepCopy(zone) --[[deepcopy so that the zone in zones_by_name and the zone in
zones_by_num se are different objects.. don't want them linked.]]
end
end
end

--DynDBs
mist.DBs.MEunits = mist.utils.deepCopy(mist.DBs.units)
mist.DBs.MEunitsByName = mist.utils.deepCopy(mist.DBs.unitsByName)
Expand Down
106 changes: 54 additions & 52 deletions mist_4_5_121.lua → mist_4_5_122.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 = 121
mist.build = 122

-- forward declaration of log shorthand
local log
Expand Down Expand Up @@ -97,57 +97,6 @@ do -- the main scope
mist.DBs.missionData.countries = {}
end

mist.DBs.zonesByName = {}
mist.DBs.zonesByNum = {}


if env.mission.triggers and env.mission.triggers.zones then
for zone_ind, zone_data in pairs(env.mission.triggers.zones) do
if type(zone_data) == 'table' then
local zone = mist.utils.deepCopy(zone_data)
--log:warn(zone)
zone.point = {} -- point is used by SSE
zone.point.x = zone_data.x
zone.point.y = land.getHeight({x = zone_data.x, y = zone_data.y})
zone.point.z = zone_data.y
zone.properties = {}
if zone_data.properties then
for propInd, prop in pairs(zone_data.properties) do
if prop.value and tostring(prop.value) ~= "" then
zone.properties[prop.key] = prop.value
end
end
end
if zone.verticies then -- trust but verify
local r = 0
for i = 1, #zone.verticies do
local dist = mist.utils.get2DDist(zone.point, zone.verticies[i])
if dist > r then
r = mist.utils.deepCopy(dist)
end
end
zone.radius = r

end
if zone.linkUnit then
local uRef = mist.DBs.unitsByName[zone.linkUnit]
if zone.verticies then
local offset = {}
for i = 1, #zone.verticies do
table.insert(offset, {dist = mist.utils.get2DDist(uRef.point, zone.verticies[i]), heading = mist.getHeadingPoints(uRef.point, zone.verticies[i]) + uRef.heading})
end
zone.offset = offset
else
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
end
end

mist.DBs.zonesByName[zone_data.name] = zone
mist.DBs.zonesByNum[#mist.DBs.zonesByNum + 1] = mist.utils.deepCopy(zone) --[[deepcopy so that the zone in zones_by_name and the zone in
zones_by_num se are different objects.. don't want them linked.]]
end
end
end

mist.DBs.drawingByName = {}
mist.DBs.drawingIndexed = {}
Expand Down Expand Up @@ -842,6 +791,59 @@ do -- the main scope
end
end

mist.DBs.zonesByName = {}
mist.DBs.zonesByNum = {}

if env.mission.triggers and env.mission.triggers.zones then
for zone_ind, zone_data in pairs(env.mission.triggers.zones) do
if type(zone_data) == 'table' then
local zone = mist.utils.deepCopy(zone_data)
--log:warn(zone)
zone.point = {} -- point is used by SSE
zone.point.x = zone_data.x
zone.point.y = land.getHeight({x = zone_data.x, y = zone_data.y})
zone.point.z = zone_data.y
zone.properties = {}
if zone_data.properties then
for propInd, prop in pairs(zone_data.properties) do
if prop.value and tostring(prop.value) ~= "" then
zone.properties[prop.key] = prop.value
end
end
end
if zone.verticies then -- trust but verify
local r = 0
for i = 1, #zone.verticies do
local dist = mist.utils.get2DDist(zone.point, zone.verticies[i])
if dist > r then
r = mist.utils.deepCopy(dist)
end
end
zone.radius = r

end
if zone.linkUnit then
local uRef = mist.DBs.unitsByName[zone.linkUnit]
if uRef then
if zone.verticies then
local offset = {}
for i = 1, #zone.verticies do
table.insert(offset, {dist = mist.utils.get2DDist(uRef.point, zone.verticies[i]), heading = mist.getHeadingPoints(uRef.point, zone.verticies[i]) + uRef.heading})
end
zone.offset = offset
else
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
end
end
end

mist.DBs.zonesByName[zone_data.name] = zone
mist.DBs.zonesByNum[#mist.DBs.zonesByNum + 1] = mist.utils.deepCopy(zone) --[[deepcopy so that the zone in zones_by_name and the zone in
zones_by_num se are different objects.. don't want them linked.]]
end
end
end

--DynDBs
mist.DBs.MEunits = mist.utils.deepCopy(mist.DBs.units)
mist.DBs.MEunitsByName = mist.utils.deepCopy(mist.DBs.unitsByName)
Expand Down