CQUI-Org / cqui

Civilization 6 - Chao's Quick UI. Reduce clicks and manage your empire faster!
MIT License
317 stars 64 forks source link

Autoplay mod compatibility #498

Closed JackalWorks closed 7 years ago

JackalWorks commented 7 years ago

When running in Autoplay using the autoplay mod, there are references to the LocalPlayer which will sometimes return -1 and thus nil in certain functions. I have found two places in this mods UnitFlagManager.lua and can be fixed like this:

In UnitFlag.SetColor (around lines 508) wrap the "War Check" with

if Game.GetLocalPlayer() > -1 then
    -- War Check
    [...]
end

and in OnPlayerTurnActivated (line 1464) after local idLocalPlayer = Game.GetLocalPlayer(); insert

if idLocalPlayer < 0 then
    return
end

Edit: also line 163 and 187 should be changed to if(CQUI_ShowPaths) and (Game.GetLocalPlayer() > -1) then

chaorace commented 7 years ago

Alright, thanks for sharing! If you'd like to be properly credited for this fix, then please use the "Fork" button near the top and use the web editor to commit the changes. Finally, use the "Pull Request" button to submit your proposed changes. If that seems like altogether too much work, that's fine too, but you won't show up in the Github contributor list and it will be harder to claim credit for helping with this project as a result

JackalWorks commented 7 years ago

Credit is not a big deal, but I created a pull request anyway