diff --git a/.gitignore b/.gitignore index f91ff2b91..84b95b5f4 100644 --- a/.gitignore +++ b/.gitignore @@ -214,3 +214,6 @@ pip-log.txt #Mr Developer .mr.developer.cfg +*.gss +*._gs +*.gsl diff --git a/Database.lua b/Database.lua index 5074afe4f..6daf4c2e7 100644 --- a/Database.lua +++ b/Database.lua @@ -301,46 +301,50 @@ trace.f( self.ClassName, UnitData ) if UnitData:isExist() then local UnitName = UnitData:getName() - local GroupName = Unit.getGroup(UnitData):getName() - local PlayerName = UnitData:getPlayerName() + local GroupData = UnitData:getGroup() - trace.i(self.ClassName, "Player : " .. PlayerName .. " Unit : " .. UnitName .. " Group : " .. GroupName ) + if GroupData and GroupData:isExist() then + local GroupName = GroupData:getName() + local PlayerName = UnitData:getPlayerName() - if self.Players[PlayerName] == nil then -- I believe this is the place where a Player gets a life in a mission when he enters a unit ... - self.Players[PlayerName] = {} - self.Players[PlayerName].Hit = {} - self.Players[PlayerName].Kill = {} - self.Players[PlayerName].Mission = {} - - -- for CategoryID, CategoryName in pairs( DATABASECategory ) do - -- self.Players[PlayerName].Hit[CategoryID] = {} - -- self.Players[PlayerName].Kill[CategoryID] = {} - -- end - self.Players[PlayerName].HitPlayers = {} - self.Players[PlayerName].HitUnits = {} - self.Players[PlayerName].Penalty = 0 - self.Players[PlayerName].PenaltyCoalition = 0 - end + trace.i(self.ClassName, "Player : " .. PlayerName .. " Unit : " .. UnitName .. " Group : " .. GroupName ) - if not self.Players[PlayerName].UnitCoalition then - self.Players[PlayerName].UnitCoalition = Unit.getGroup(UnitData):getCoalition() - else - if self.Players[PlayerName].UnitCoalition ~= Unit.getGroup(UnitData):getCoalition() then - self.Players[PlayerName].Penalty = self.Players[PlayerName].Penalty + 50 - self.Players[PlayerName].PenaltyCoalition = self.Players[PlayerName].PenaltyCoalition + 1 - MESSAGE:New( "Player '" .. PlayerName .. "' changed coalition from " .. DATABASECoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. DATABASECoalition[Unit.getGroup(UnitData):getCoalition()] .. - "(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). 50 Penalty points added.", - "Game Status: Penalty", 20, "/PENALTYCOALITION" .. PlayerName ):ToAll() - self:ScoreAdd( PlayerName, "COALITION_PENALTY", 1, -50, self.Players[PlayerName].UnitName, DATABASECoalition[self.Players[PlayerName].UnitCoalition], DATABASECategory[self.Players[PlayerName].UnitCategory], self.Players[PlayerName].UnitType, - UnitName, DATABASECategory[Unit.getGroup(UnitData):getCoalition()], DATABASECategory[Unit.getGroup(UnitData):getCategory()], UnitData:getTypeName() ) + if self.Players[PlayerName] == nil then -- I believe this is the place where a Player gets a life in a mission when he enters a unit ... + self.Players[PlayerName] = {} + self.Players[PlayerName].Hit = {} + self.Players[PlayerName].Kill = {} + self.Players[PlayerName].Mission = {} + + -- for CategoryID, CategoryName in pairs( DATABASECategory ) do + -- self.Players[PlayerName].Hit[CategoryID] = {} + -- self.Players[PlayerName].Kill[CategoryID] = {} + -- end + self.Players[PlayerName].HitPlayers = {} + self.Players[PlayerName].HitUnits = {} + self.Players[PlayerName].Penalty = 0 + self.Players[PlayerName].PenaltyCoalition = 0 end - end - self.Players[PlayerName].UnitName = UnitName - self.Players[PlayerName].GroupName = GroupName - self.Players[PlayerName].UnitCoalition = Unit.getGroup(UnitData):getCoalition() - self.Players[PlayerName].UnitCategory = Unit.getGroup(UnitData):getCategory() - self.Players[PlayerName].UnitType = UnitData:getTypeName() + if not self.Players[PlayerName].UnitCoalition then + self.Players[PlayerName].UnitCoalition = Unit.getGroup(UnitData):getCoalition() + else + if self.Players[PlayerName].UnitCoalition ~= Unit.getGroup(UnitData):getCoalition() then + self.Players[PlayerName].Penalty = self.Players[PlayerName].Penalty + 50 + self.Players[PlayerName].PenaltyCoalition = self.Players[PlayerName].PenaltyCoalition + 1 + MESSAGE:New( "Player '" .. PlayerName .. "' changed coalition from " .. DATABASECoalition[self.Players[PlayerName].UnitCoalition] .. " to " .. DATABASECoalition[Unit.getGroup(UnitData):getCoalition()] .. + "(changed " .. self.Players[PlayerName].PenaltyCoalition .. " times the coalition). 50 Penalty points added.", + "Game Status: Penalty", 20, "/PENALTYCOALITION" .. PlayerName ):ToAll() + self:ScoreAdd( PlayerName, "COALITION_PENALTY", 1, -50, self.Players[PlayerName].UnitName, DATABASECoalition[self.Players[PlayerName].UnitCoalition], DATABASECategory[self.Players[PlayerName].UnitCategory], self.Players[PlayerName].UnitType, + UnitName, DATABASECategory[Unit.getGroup(UnitData):getCoalition()], DATABASECategory[Unit.getGroup(UnitData):getCategory()], UnitData:getTypeName() ) + end + end + self.Players[PlayerName].UnitName = UnitName + self.Players[PlayerName].GroupName = GroupName + + self.Players[PlayerName].UnitCoalition = Unit.getGroup(UnitData):getCoalition() + self.Players[PlayerName].UnitCategory = Unit.getGroup(UnitData):getCategory() + self.Players[PlayerName].UnitType = UnitData:getTypeName() + end end end diff --git a/Message.lua b/Message.lua index 74146cc05..7a9ea75a3 100644 --- a/Message.lua +++ b/Message.lua @@ -187,21 +187,21 @@ function MESSAGEQUEUE:_DisplayMessages() end -- Now check if the Client also has messages that belong to the Coalition of the Client... - for CoalitionSideID, CoalitionSideData in pairs( self.CoalitionSides ) do - for MessageID, MessageData in pairs( CoalitionSideData.Messages ) do - local CoalitionGroup = Group.getByName( ClientGroupName ) - if CoalitionGroup and CoalitionGroup:getCoalition() == CoalitionSideID then - if MessageData.MessageCoalition == false then - trigger.action.outTextForGroup( Group.getByName(ClientGroupName):getID(), MessageData.MessageCategory .. '\n' .. MessageData.MessageText:gsub("\n$",""):gsub("\n$",""), MessageData.MessageDuration ) - MessageData.MessageCoalition = true - end - end - local MessageTimeLeft = ( MessageData.MessageTime + MessageData.MessageDuration ) - timer.getTime() - if MessageTimeLeft <= 0 then - MessageData = nil - end - end - end + -- for CoalitionSideID, CoalitionSideData in pairs( self.CoalitionSides ) do + -- for MessageID, MessageData in pairs( CoalitionSideData.Messages ) do + -- local CoalitionGroup = Group.getByName( ClientGroupName ) + -- if CoalitionGroup and CoalitionGroup:getCoalition() == CoalitionSideID then + -- if MessageData.MessageCoalition == false then + -- trigger.action.outTextForGroup( Group.getByName(ClientGroupName):getID(), MessageData.MessageCategory .. '\n' .. MessageData.MessageText:gsub("\n$",""):gsub("\n$",""), MessageData.MessageDuration ) + -- MessageData.MessageCoalition = true + -- end + -- end + -- local MessageTimeLeft = ( MessageData.MessageTime + MessageData.MessageDuration ) - timer.getTime() + -- if MessageTimeLeft <= 0 then + -- MessageData = nil + -- end + -- end + -- end end end