From: <dil...@us...> - 2015-01-26 20:51:10
|
Revision: 7877 http://sourceforge.net/p/freeorion/code/7877 Author: dilvish-fo Date: 2015-01-26 20:51:01 +0000 (Mon, 26 Jan 2015) Log Message: ----------- fix for AI error if potential invasion target planets had been destroyed Modified Paths: -------------- trunk/FreeOrion/default/AI/InvasionAI.py Modified: trunk/FreeOrion/default/AI/InvasionAI.py =================================================================== --- trunk/FreeOrion/default/AI/InvasionAI.py 2015-01-26 20:11:03 UTC (rev 7876) +++ trunk/FreeOrion/default/AI/InvasionAI.py 2015-01-26 20:51:01 UTC (rev 7877) @@ -236,14 +236,19 @@ if not system: continue planet_industries = {} - for pid2 in system.planetIDs: + system_planets = [pid2 for pid2 in system.planetIDs] + if planetID not in system_planets: + # planet or system apparently has most likely been destroyed + planetValues[planetID] = [0, 0] + continue + for pid2 in system_planets: planet2 = universe.getPlanet(pid2) specName2 = (planet2 and planet2.speciesName) or "" species2 = fo.getSpecies(specName2) if species2 and species2.canProduceShips: planet_industries[pid2] = planet2.currentMeterValue(fo.meterType.industry) + 0.1 # to prevent divide-by-zero industry_ratio = planet_industries[planetID] / max(planet_industries.values()) - for pid2 in system.planetIDs: + for pid2 in system_planets: if pid2 == planetID: continue planet2 = universe.getPlanet(pid2) |