Minor bug fix for dynAdd functions with regard to new countries in the
simulator
This commit is contained in:
mrSkortch 2015-10-03 19:45:00 -06:00
parent 6c2b091e94
commit ee76538575
2 changed files with 22 additions and 13 deletions

View File

@ -15,7 +15,7 @@ mist = {}
-- don't change these -- don't change these
mist.majorVersion = 4 mist.majorVersion = 4
mist.minorVersion = 0 mist.minorVersion = 0
mist.build = 55 mist.build = 56
-------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------
-- the main area -- the main area
@ -492,6 +492,7 @@ do
newObj.name = staticObj.name newObj.name = staticObj.name
newObj.dead = staticObj.dead newObj.dead = staticObj.dead
newObj.country = staticObj.country newObj.country = staticObj.country
newObj.countryId = staticObj.countryId
newObj.clone = staticObj.clone newObj.clone = staticObj.clone
newObj.shape_name = staticObj.shape_name newObj.shape_name = staticObj.shape_name
newObj.canCargo = staticObj.canCargo newObj.canCargo = staticObj.canCargo
@ -508,21 +509,22 @@ do
newObj.name = staticObj.units[1].name newObj.name = staticObj.units[1].name
newObj.dead = staticObj.units[1].dead newObj.dead = staticObj.units[1].dead
newObj.country = staticObj.units[1].country newObj.country = staticObj.units[1].country
newObj.countryId = staticObj.units[1].countryId
newObj.shape_name = staticObj.units[1].shape_name newObj.shape_name = staticObj.units[1].shape_name
newObj.canCargo = staticObj.units[1].canCargo newObj.canCargo = staticObj.units[1].canCargo
newObj.mass = staticObj.units[1].mass newObj.mass = staticObj.units[1].mass
newObj.categoryStatic = staticObj.units[1].categoryStatic newObj.categoryStatic = staticObj.units[1].categoryStatic
end end
newObj.country = staticObj.country
if not newObj.country then if not newObj.country then
return false return false
end end
local newCountry local newCountry = newObj.country
for countryName, countryId in pairs(country.id) do if newObj.countryId then
newCountry = newObj.countryId
end
for countryId, countryName in pairs(country.name) do
if type(newObj.country) == 'string' then if type(newObj.country) == 'string' then
if tostring(countryName) == string.upper(newObj.country) then if tostring(countryName) == string.upper(newObj.country) then
newCountry = countryName newCountry = countryName
@ -577,12 +579,17 @@ do
-- --
--env.info('dynAdd')
--mist.debug.writeData(mist.utils.serialize,{'msg', newGroup}, 'newGroupOrig.lua')
local cntry = newGroup.country local cntry = newGroup.country
if newGroup.countryId then
cntry = newGroup.countryId
end
local groupType = newGroup.category local groupType = newGroup.category
local newCountry = '' local newCountry = ''
-- validate data -- validate data
for countryName, countryId in pairs(country.id) do for countryId, countryName in pairs(country.name) do
if type(cntry) == 'string' then if type(cntry) == 'string' then
if tostring(countryName) == string.upper(cntry) then if tostring(countryName) == string.upper(cntry) then
newCountry = countryName newCountry = countryName
@ -616,7 +623,6 @@ do
newCat = 'AIRPLANE' newCat = 'AIRPLANE'
end end
end end
local typeName local typeName
if newCat == 'GROUND_UNIT' then if newCat == 'GROUND_UNIT' then
typeName = ' gnd ' typeName = ' gnd '
@ -629,7 +635,6 @@ do
elseif newCat == 'BUILDING' then elseif newCat == 'BUILDING' then
typeName = ' bld ' typeName = ' bld '
end end
if newGroup.clone or not newGroup.groupId then if newGroup.clone or not newGroup.groupId then
mistDynAddIndex = mistDynAddIndex + 1 mistDynAddIndex = mistDynAddIndex + 1
mistGpId = mistGpId + 1 mistGpId = mistGpId + 1
@ -662,8 +667,9 @@ do
newGroup.start_time = 0 newGroup.start_time = 0
end end
end end
for unitIndex, unitData in pairs(newGroup.units) do
for unitIndex, unitData in pairs(newGroup.units) do
local originalName = newGroup.units[unitIndex].unitName or newGroup.units[unitIndex].name local originalName = newGroup.units[unitIndex].unitName or newGroup.units[unitIndex].name
if newGroup.clone or not unitData.unitId then if newGroup.clone or not unitData.unitId then
mistUnitId = mistUnitId + 1 mistUnitId = mistUnitId + 1
@ -720,7 +726,6 @@ do
mistAddedObjects[#mistAddedObjects + 1] = mist.utils.deepCopy(newGroup.units[unitIndex]) mistAddedObjects[#mistAddedObjects + 1] = mist.utils.deepCopy(newGroup.units[unitIndex])
end end
mistAddedGroups[#mistAddedGroups + 1] = mist.utils.deepCopy(newGroup) mistAddedGroups[#mistAddedGroups + 1] = mist.utils.deepCopy(newGroup)
if newGroup.route and not newGroup.route.points then if newGroup.route and not newGroup.route.points then
if not newGroup.route.points and newGroup.route[1] then if not newGroup.route.points and newGroup.route[1] then
local copyRoute = newGroup.route local copyRoute = newGroup.route
@ -5279,7 +5284,6 @@ mist.teleportToPoint = function(vars) -- main teleport function that all of tele
if string.lower(newGroupData.category) == 'static' then if string.lower(newGroupData.category) == 'static' then
return mist.dynAddStatic(newGroupData) return mist.dynAddStatic(newGroupData)
end end
return mist.dynAdd(newGroupData) return mist.dynAdd(newGroupData)
end end

View File

@ -1,3 +1,8 @@
v56
-fixed bug with dynAdd and dynAddStatic not recognizing new countries in dcs 1.5
v55
- Release v4
v54 v54
-added a check when adding unitTypes for messages to figure out the correct in-game unit name for a given unit. For example the Mi-8 helicopter is always displayed as 'Mi-8MTV2', however its actual in game name is 'Mi-8MT', this feature allows for you to list 'Mi-8MTV2', 'Mi-8MTV', or 'Mi-8' to get messages sent to the Mi-8. Shortcut also works for the relevant aircraft 'Mig-21', 'Mig-15', 'FW-190', and 'Bf-109'. -added a check when adding unitTypes for messages to figure out the correct in-game unit name for a given unit. For example the Mi-8 helicopter is always displayed as 'Mi-8MTV2', however its actual in game name is 'Mi-8MT', this feature allows for you to list 'Mi-8MTV2', 'Mi-8MTV', or 'Mi-8' to get messages sent to the Mi-8. Shortcut also works for the relevant aircraft 'Mig-21', 'Mig-15', 'FW-190', and 'Bf-109'.