From 2f02c4041c250d70053a297dd59a0b218072f9a5 Mon Sep 17 00:00:00 2001 From: mrSkortch Date: Wed, 17 Jun 2015 22:08:10 -0600 Subject: [PATCH] v51 Fixed issue with message system Added check for message systems to not send messages to combined arms if CA slots are not in a mission. --- mist.lua | 43 ++++++++++++++++++++------- mistv3_7_48.lua => mistv3_7_51.lua | 47 +++++++++++++++++++++--------- rev changelog.txt | 7 +++++ 3 files changed, 73 insertions(+), 24 deletions(-) rename mistv3_7_48.lua => mistv3_7_51.lua (99%) diff --git a/mist.lua b/mist.lua index ae88027..bb474f8 100644 --- a/mist.lua +++ b/mist.lua @@ -8,7 +8,7 @@ mist = {} -- don't change these mist.majorVersion = 3 mist.minorVersion = 7 -mist.build = 50 +mist.build = 51 @@ -4003,6 +4003,26 @@ do local displayActive = false local displayFuncId = 0 + local caSlots = false + + for index, value in pairs(env.mission.groundControl) do + if type(value) == 'table' then + for roleName, roleVal in pairs(value) do + for rIndex, rVal in pairs(roleVal) do + if rIndex == 'red' or rIndex == 'blue' then + if env.mission.groundControl[index][roleName][rIndex] > 0 then + caSlots = true + break + end + end + end + end + elseif type(value) == 'boolean' and value == true then + caSlots = true + break + end + end + local function mistdisplayV4() local activeClients = {} @@ -4079,12 +4099,13 @@ do end ------- new display - - if msgTableText['RED'] then - trigger.action.outTextForCoalition(coalition.side.RED, table.concat(msgTableText['RED'].text), msgTableText['RED'].displayTime) - end - if msgTableText['BLUE'] then - trigger.action.outTextForCoalition(coalition.side.BLUE, table.concat(msgTableText['BLUE'].text), msgTableText['BLUE'].displayTime) + if caSlots == true then + if msgTableText['RED'] then + trigger.action.outTextForCoalition(coalition.side.RED, table.concat(msgTableText['RED'].text), msgTableText['RED'].displayTime) + end + if msgTableText['BLUE'] then + trigger.action.outTextForCoalition(coalition.side.BLUE, table.concat(msgTableText['BLUE'].text), msgTableText['BLUE'].displayTime) + end end for index, msgData in pairs(msgTableText) do @@ -4176,8 +4197,8 @@ do if type(listData) == 'string' then listData = string.lower(listData) end - if forIndex == 'coa' and (listData == string.lower(clientData.coalition) or listData == 'all') or forIndex == 'countries' and string.lower(clientData.country) == listData or forIndex == 'units' and string.lower(clientData.unitName) == listData then -- - newMsgFor = msgSpamFilter(newMsgFor, clientId) -- so units dont get the same message twice if complex rules are given + if (forIndex == 'coa' and (listData == string.lower(clientData.coalition) or listData == 'all')) or (forIndex == 'countries' and string.lower(clientData.country) == listData) or (forIndex == 'units' and string.lower(clientData.unitName) == listData) then -- + newMsgFor = msgSpamFilter(newMsgFor, clientData.groupId) -- so units dont get the same message twice if complex rules are given --table.insert(newMsgFor, clientId) elseif forIndex == 'unittypes' then for typeId, typeData in pairs(listData) do @@ -4187,7 +4208,7 @@ do if string.lower(list) == string.lower(clientDataVal) or list == 'all' then if typeData == clientData.type then found = true - newMsgFor = msgSpamFilter(newMsgFor, clientId) -- sends info oto other function to see if client is already recieving the current message. + newMsgFor = msgSpamFilter(newMsgFor, clientData.groupId) -- sends info oto other function to see if client is already recieving the current message. --table.insert(newMsgFor, clientId) end end @@ -4241,7 +4262,7 @@ do messageID = messageID + 1 new.messageID = messageID - --mist.debug.writeData(mist.utils.serialize,{'msg', new}, 'newMsg.txt') + --mist.debug.writeData(mist.utils.serialize,{'msg', new}, 'newMsg.lua') messageList[#messageList + 1] = new diff --git a/mistv3_7_48.lua b/mistv3_7_51.lua similarity index 99% rename from mistv3_7_48.lua rename to mistv3_7_51.lua index b9656a2..bb474f8 100644 --- a/mistv3_7_48.lua +++ b/mistv3_7_51.lua @@ -8,7 +8,7 @@ mist = {} -- don't change these mist.majorVersion = 3 mist.minorVersion = 7 -mist.build = 48 +mist.build = 51 @@ -3186,7 +3186,7 @@ stopFlag if stopflag == -1 or (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then - if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true then + if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true and #Group.getByName(groupName):getUnits() > 0 then if trigger.misc.getUserFlag(flag) == 0 then trigger.action.setUserFlag(flag, true) end @@ -3223,7 +3223,7 @@ mist.flagFunc.group_dead = function(vars) if stopflag == -1 or (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then - if Group.getByName(groupName) and Group.getByName(groupName):isExist() == false or not Group.getByName(groupName) then + if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then if trigger.misc.getUserFlag(flag) == 0 then trigger.action.setUserFlag(flag, true) end @@ -4003,6 +4003,26 @@ do local displayActive = false local displayFuncId = 0 + local caSlots = false + + for index, value in pairs(env.mission.groundControl) do + if type(value) == 'table' then + for roleName, roleVal in pairs(value) do + for rIndex, rVal in pairs(roleVal) do + if rIndex == 'red' or rIndex == 'blue' then + if env.mission.groundControl[index][roleName][rIndex] > 0 then + caSlots = true + break + end + end + end + end + elseif type(value) == 'boolean' and value == true then + caSlots = true + break + end + end + local function mistdisplayV4() local activeClients = {} @@ -4079,12 +4099,13 @@ do end ------- new display - - if msgTableText['RED'] then - trigger.action.outTextForCoalition(coalition.side.RED, table.concat(msgTableText['RED'].text), msgTableText['RED'].displayTime) - end - if msgTableText['BLUE'] then - trigger.action.outTextForCoalition(coalition.side.BLUE, table.concat(msgTableText['BLUE'].text), msgTableText['BLUE'].displayTime) + if caSlots == true then + if msgTableText['RED'] then + trigger.action.outTextForCoalition(coalition.side.RED, table.concat(msgTableText['RED'].text), msgTableText['RED'].displayTime) + end + if msgTableText['BLUE'] then + trigger.action.outTextForCoalition(coalition.side.BLUE, table.concat(msgTableText['BLUE'].text), msgTableText['BLUE'].displayTime) + end end for index, msgData in pairs(msgTableText) do @@ -4176,8 +4197,8 @@ do if type(listData) == 'string' then listData = string.lower(listData) end - if forIndex == 'coa' and (listData == string.lower(clientData.coalition) or listData == 'all') or forIndex == 'countries' and string.lower(clientData.country) == listData or forIndex == 'units' and string.lower(clientData.unitName) == listData then -- - newMsgFor = msgSpamFilter(newMsgFor, clientId) -- so units dont get the same message twice if complex rules are given + if (forIndex == 'coa' and (listData == string.lower(clientData.coalition) or listData == 'all')) or (forIndex == 'countries' and string.lower(clientData.country) == listData) or (forIndex == 'units' and string.lower(clientData.unitName) == listData) then -- + newMsgFor = msgSpamFilter(newMsgFor, clientData.groupId) -- so units dont get the same message twice if complex rules are given --table.insert(newMsgFor, clientId) elseif forIndex == 'unittypes' then for typeId, typeData in pairs(listData) do @@ -4187,7 +4208,7 @@ do if string.lower(list) == string.lower(clientDataVal) or list == 'all' then if typeData == clientData.type then found = true - newMsgFor = msgSpamFilter(newMsgFor, clientId) -- sends info oto other function to see if client is already recieving the current message. + newMsgFor = msgSpamFilter(newMsgFor, clientData.groupId) -- sends info oto other function to see if client is already recieving the current message. --table.insert(newMsgFor, clientId) end end @@ -4241,7 +4262,7 @@ do messageID = messageID + 1 new.messageID = messageID - --mist.debug.writeData(mist.utils.serialize,{'msg', new}, 'newMsg.txt') + --mist.debug.writeData(mist.utils.serialize,{'msg', new}, 'newMsg.lua') messageList[#messageList + 1] = new diff --git a/rev changelog.txt b/rev changelog.txt index afc8b3b..47f2d52 100644 --- a/rev changelog.txt +++ b/rev changelog.txt @@ -1,3 +1,10 @@ +v51 +-Fixed bug with message system +-Added a check to the message system so combined arms messages wont be sent if CA slots are not in a mission. + +v50 +-something got deleted from v49 so this fixed it. + v49 -fixed flagFuncs.group_dead and group_alive issue caused via a DCS bug.