Changeset 3333

Show
Ignore:
Timestamp:
11/30/08 21:49:34 (5 weeks ago)
Author:
licho
Message:
  • changes to awards and morphing to allow variable hostname
  • hopefully fixed boost crash when 16 people in game
Location:
trunk/mods/ca/LuaRules/Gadgets
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/mods/ca/LuaRules/Gadgets/awards.lua

    r3317 r3333  
    200200                end 
    201201        end 
     202 
    202203end 
    203204 
     
    437438------------------------------------------------------------------------------------- 
    438439 
     440local hostName = nil --planetwars hostname 
     441 
    439442local spGetGameFrame    = Spring.GetGameFrame 
    440443local spGetMouseState   = Spring.GetMouseState 
    441444local spSendCommands    = Spring.SendCommands 
     445 
    442446 
    443447local glPushMatrix              = gl.PushMatrix 
     
    480484local maxRow            = 8 
    481485local fontHeight        = 16 
     486 
    482487 
    483488local awardDescs =  
     
    509514        end 
    510515        spSendCommands({'endgraph 0'}) 
     516 
     517        -- planetwars init 
     518        local modOptions = Spring.GetModOptions() 
     519        if (modOptions) and modOptions.planetwars then 
     520                hostName = modOptions.planetwars.hostname 
     521        end   
    511522end 
    512523 
     
    607618                        for awardType, record in spairs(awards) do 
    608619                                awardCount = awardCount + 1 
    609                                 if not sentToPlanetWars then 
    610                                         local planetWarsData = 'award: '.. teamNames[team] ..' '.. awardType ..' '.. awardDescs[awardType] ..', '.. record 
    611                                         Spring.SendCommands("w PlanetWars Encoded mission report:".. planetWarsData) 
     620                                if not sentToPlanetWars and hostName ~= nil then 
     621                                        local planetWarsData = teamNames[team] ..' '.. awardType ..' '.. awardDescs[awardType] ..', '.. record 
     622                                        Spring.SendCommands("w "..hostName.." pwaward:".. planetWarsData) 
    612623                                        Spring.Echo(planetWarsData) 
    613624                                end 
  • trunk/mods/ca/LuaRules/Gadgets/unit_morph.lua

    r3331 r3333  
    107107local morphDefs  = {} --// make it global in Initialize() 
    108108local extraUnitMorphDefs = {} -- stores mainly planetwars morphs 
     109local hostName = nil -- planetwars hostname 
    109110local morphUnits = {} --// make it global in Initialize() 
    110111local reqDefIDs  = {} --// all possible unitDefID's, which are used as a requirement for a morph 
     
    394395  local newUnit = Spring.CreateUnit(defName, px, py, pz, 0, unitTeam) 
    395396   
    396   if (extraUnitMorphDefs[unitID] ~= nil) then  -- send planetwars deployment message 
     397  if (extraUnitMorphDefs[unitID] ~= nil and hostName ~= nil) then  -- send planetwars deployment message 
    397398        local data = unitTeam..","..defName..","..math.floor(px)..","..math.floor(pz)..",".."S" -- todo determine and apply smart orientation of the structure 
    398         Spring.SendCommands("w pwdeploy:"..data) 
     399        Spring.SendCommands("w "..hostName.." pwdeploy:"..data) 
    399400        extraUnitMorphDefs[unitID] = nil 
    400401  end 
     
    489490  end 
    490491   
    491   -- self linking 
     492  -- self linking for planetwars 
    492493  GG['morphHandler'] = {} 
    493494  GG['morphHandler'].AddExtraUnitMorph = AddExtraUnitMorph 
     495  local modOptions = Spring.GetModOptions() 
     496  if (modOptions) and modOptions.planetwars then 
     497        hostName = modOptions.planetwars.hostname 
     498  end   
     499   
    494500   
    495501  if (type(GG.UnitRanked)~="table") then GG.UnitRanked = {} end 
  • trunk/mods/ca/LuaRules/Gadgets/unit_start_boost.lua

    r3328 r3333  
    105105        for _, teamID in pairs(Spring.GetTeamList()) do 
    106106                local gaiaID = Spring.GetGaiaTeamID() 
    107                 local teamLuaAI = Spring.GetTeamLuaAI(teamID) 
     107                local teamLuaAI = nil 
     108                pcall(function() teamLuaAI = Spring.GetTeamLuaAI(teamID) end) 
    108109                if (teamID ~= gaiaID and (not teamLuaAI or teamLuaAI == "")) then 
    109110                        local metal = Spring.GetTeamResources(teamID, 'metal')