V4.1 Release

Commits for v4.1 to be sent to release branch
This commit is contained in:
mrSkortch 2016-01-11 03:48:47 -07:00
parent 9bfeca1495
commit 69190060e5
5 changed files with 108 additions and 21 deletions

Binary file not shown.

View File

@ -14,8 +14,8 @@ mist = {}
-- don't change these -- don't change these
mist.majorVersion = 4 mist.majorVersion = 4
mist.minorVersion = 0 mist.minorVersion = 1
mist.build = 60 mist.build = 61
-------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------
-- the main area -- the main area
@ -1011,7 +1011,8 @@ function mist.utils.vecToWP(vec)
return newWP return newWP
end end
function mist.utils.unitToWP(unit) function mist.utils.unitToWP(pUnit)
local unit = mist.utils.deepCopy(pUnit)
if type(unit) == 'string' then if type(unit) == 'string' then
if Unit.getByName(unit) then if Unit.getByName(unit) then
unit = Unit.getByName(unit) unit = Unit.getByName(unit)

View File

@ -14,8 +14,8 @@ mist = {}
-- don't change these -- don't change these
mist.majorVersion = 4 mist.majorVersion = 4
mist.minorVersion = 0 mist.minorVersion = 1
mist.build = 57 mist.build = 61
-------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------
-- the main area -- the main area
@ -241,7 +241,7 @@ do
end end
end end
end end
--mist.debug.writeData(mist.utils.serialize,{'msg', newTable}, timer.getAbsTime() ..'Group.lua')
newTable['timeAdded'] = timer.getAbsTime() -- only on the dynGroupsAdded table. For other reference, see start time newTable['timeAdded'] = timer.getAbsTime() -- only on the dynGroupsAdded table. For other reference, see start time
--mist.debug.dumpDBs() --mist.debug.dumpDBs()
--end --end
@ -254,6 +254,7 @@ do
local function checkSpawnedEvents() local function checkSpawnedEvents()
if #tempSpawnedUnits > 0 then if #tempSpawnedUnits > 0 then
local groupsToAdd = {} local groupsToAdd = {}
local added = false
local ltemp = tempSpawnedUnits local ltemp = tempSpawnedUnits
local ltable = table local ltable = table
@ -265,7 +266,7 @@ do
local spawnedObj = ltemp[x] local spawnedObj = ltemp[x]
if spawnedObj and spawnedObj:isExist() then if spawnedObj and spawnedObj:isExist() then
local found = false local found = false
for index, name in pairs(groupsToAdd) do for name, val in pairs(groupsToAdd) do
if spawnedObj:getCategory() == 1 then -- normal groups if spawnedObj:getCategory() == 1 then -- normal groups
if mist.stringMatch(spawnedObj:getGroup():getName(), name) == true then if mist.stringMatch(spawnedObj:getGroup():getName(), name) == true then
found = true found = true
@ -280,26 +281,37 @@ do
end end
-- for some reason cargo objects are returning as category == 6. -- for some reason cargo objects are returning as category == 6.
if found == false then if found == false then
added = true
if spawnedObj:getCategory() == 1 then -- normal groups if spawnedObj:getCategory() == 1 then -- normal groups
groupsToAdd[#groupsToAdd + 1] = spawnedObj:getGroup():getName() groupsToAdd[spawnedObj:getGroup():getName()] = true
elseif spawnedObj:getCategory() == 3 or spawnedObj:getCategory() == 6 then -- static objects elseif spawnedObj:getCategory() == 3 or spawnedObj:getCategory() == 6 then -- static objects
groupsToAdd[#groupsToAdd + 1] = spawnedObj:getName() groupsToAdd[spawnedObj:getName()] = true
end end
end end
end end
table.remove(ltemp, x) table.remove(ltemp, x)
if x%updatesPerRun == 0 then if x%updatesPerRun == 0 then
coroutine.yield() coroutine.yield()
end end
end end
if added == true then
if #groupsToAdd > 0 then for groupName, val in pairs(groupsToAdd) do
for groupId, groupName in pairs(groupsToAdd) do local dataChanged = false
if not mist.DBs.groupsByName[groupName] or mist.DBs.groupsByName[groupName] and mist.DBs.groupsByName[groupName].startTime + 10 < timer.getAbsTime() then if mist.DBs.groupsByName[groupName] then
for _index, data in pairs(mist.DBs.groupsByName[groupName]) do
if data.unitName ~= spawnedObj:getName() and data.unitId ~= spawnedObj:getID() and data.type ~= spawnedObj:getTypeName() then
dataChanged = true
break
end
end
if dataChanged == false then
groupsToAdd[groupName] = false
end
end
if groupsToAdd[groupName] == true or not mist.DBs.groupsByName[groupName] then
writeGroups[#writeGroups + 1] = dbUpdate(groupName) writeGroups[#writeGroups + 1] = dbUpdate(groupName)
end end
end end
@ -309,6 +321,7 @@ do
local function updateDBTables() local function updateDBTables()
local i = 0 local i = 0
for index, newTable in pairs(writeGroups) do for index, newTable in pairs(writeGroups) do
i = i + 1 i = i + 1
@ -548,7 +561,7 @@ do
if newObj.clone or not newObj.name then if newObj.clone or not newObj.name then
mistDynAddIndex = mistDynAddIndex + 1 mistDynAddIndex = mistDynAddIndex + 1
newObj.name = (newCountry .. ' static ' .. mistDynAddIndex) newObj.name = (country.name[newCountry] .. ' static ' .. mistDynAddIndex)
end end
if not newObj.dead then if not newObj.dead then
@ -591,6 +604,7 @@ do
-- validate data -- validate data
for countryId, countryName in pairs(country.name) do for countryId, countryName in pairs(country.name) do
if type(cntry) == 'string' then if type(cntry) == 'string' then
cntry = cntry:gsub("%s+", "_")
if tostring(countryName) == string.upper(cntry) then if tostring(countryName) == string.upper(cntry) then
newCountry = countryName newCountry = countryName
end end
@ -649,7 +663,7 @@ do
end end
if newGroup.clone and mist.DBs.groupsByName[newGroup.name] or not newGroup.name then if newGroup.clone and mist.DBs.groupsByName[newGroup.name] or not newGroup.name then
newGroup['name'] = tostring(tostring(cntry) .. tostring(typeName) .. mistDynAddIndex) newGroup['name'] = tostring(tostring(country.name[cntry]) .. tostring(typeName) .. mistDynAddIndex)
end end
if not newGroup.hidden then if not newGroup.hidden then
@ -921,7 +935,9 @@ end
function mist.utils.makeVec3(Vec2, y) function mist.utils.makeVec3(Vec2, y)
if not Vec2.z then if not Vec2.z then
if not y then if Vec2.alt and not y then
y = Vec2.alt
elseif not y then
y = 0 y = 0
end end
return {x = Vec2.x, y = y, z = Vec2.y} return {x = Vec2.x, y = y, z = Vec2.y}
@ -961,7 +977,9 @@ end
-- gets heading-error corrected direction from point along vector vec. -- gets heading-error corrected direction from point along vector vec.
function mist.utils.getDir(vec, point) function mist.utils.getDir(vec, point)
local dir = math.atan2(vec.z, vec.x) local dir = math.atan2(vec.z, vec.x)
dir = dir + mist.getNorthCorrection(point) if point then
dir = dir + mist.getNorthCorrection(point)
end
if dir < 0 then if dir < 0 then
dir = dir + 2*math.pi -- put dir in range of 0 to 2*pi dir = dir + 2*math.pi -- put dir in range of 0 to 2*pi
end end
@ -980,7 +998,35 @@ function mist.utils.get3DDist(point1, point2)
return mist.vec.mag({x = point1.x - point2.x, y = point1.y - point2.y, z = point1.z - point2.z}) return mist.vec.mag({x = point1.x - point2.x, y = point1.y - point2.y, z = point1.z - point2.z})
end end
function mist.utils.vecToWP(vec)
local newWP = {}
newWP.x = vec.x
newWP.y = vec.y
if vec.z then
newWP.alt = vec.y
newWP.y = vec.z
else
newWP.alt = land.getHeight({x = vec.x, y = vec.y})
end
return newWP
end
function mist.utils.unitToWP(pUnit)
local unit = mist.utils.deepCopy(pUnit)
if type(unit) == 'string' then
if Unit.getByName(unit) then
unit = Unit.getByName(unit)
end
end
if unit:isExist() == true then
local new = mist.utils.vecToWP(unit:getPosition().p)
new.speed = mist.vec.mag(unit:getVelocity())
new.alt_type = "BARO"
return new
end
return false
end
@ -1010,6 +1056,15 @@ mist.utils.round = function(num, idp)
return math.floor(num * mult + 0.5) / mult return math.floor(num * mult + 0.5) / mult
end end
mist.utils.roundTbl = function(tbl, idp)
for id, val in pairs(tbl) do
if type(val) == 'number' then
tbl[id] = mist.utils.round(val, idp)
end
end
return tbl
end
-- porting in Slmod's dostring -- porting in Slmod's dostring
mist.utils.dostring = function(s) mist.utils.dostring = function(s)
local f, err = loadstring(s) local f, err = loadstring(s)
@ -1526,7 +1581,8 @@ mist.tostringBR = function(az, dist, alt, metric)
return s return s
end end
mist.getNorthCorrection = function(point) --gets the correction needed for true north mist.getNorthCorrection = function(gPoint) --gets the correction needed for true north
local point = mist.utils.deepCopy(gPoint)
if not point.z then --Vec2; convert to Vec3 if not point.z then --Vec2; convert to Vec3
point.z = point.y point.z = point.y
point.y = 0 point.y = 0
@ -3414,6 +3470,21 @@ mist.flagFunc.group_alive_more_than = function(vars)
end end
end end
mist.getAvgPoint = function(points)
local avgX, avgY, avgZ, totNum = 0, 0, 0, 0
for i = 1, #points do
local nPoint = mist.utils.makeVec3(points[i])
if nPoint.z then
avgX = avgX + nPoint.x
avgY = avgY + nPoint.y
avgZ = avgZ + nPoint.z
totNum = totNum + 1
end
end
if totNum ~= 0 then
return {x = avgX/totNum, y = avgY/totNum, z = avgZ/totNum}
end
end
--Gets the average position of a group of units (by name) --Gets the average position of a group of units (by name)

Binary file not shown.

View File

@ -1,3 +1,18 @@
v61 - 4.1 release
-Fixed locality issue with unitToWP
v60
-Fixed issue with country names in the editor not matching enum country
name values. For example "Best Korea" could not match with "BEST_KOREA".
Thanks lukrop of this fix
-Fixed locality issue with mist.getNorthCorrection
-Added function mist.utils.unitToWP
-added function mist.utils.vecToWP
Both of these functions deal with creating a WP table from the passed
values. unitToWP also returns a speed variable based on the current
velocity of the unit
v59 v59
-removed the new 3rd variable from mist.utils.getDir and just made the 2nd variable optional instead -removed the new 3rd variable from mist.utils.getDir and just made the 2nd variable optional instead
-Added check to DB update functions to only update if data from the group has changed from what is currently in the DB. This fixes an issue I had where some data was lost if you spawned a group normally after mission start and then used a respawn, clone, or teleport function on said group -Added check to DB update functions to only update if data from the group has changed from what is currently in the DB. This fixes an issue I had where some data was lost if you spawned a group normally after mission start and then used a respawn, clone, or teleport function on said group