View Issue Details

IDProjectCategoryLast Update
0021564AI War 2Crash/ExceptionSep 5, 2019 12:29 pm
ReporterBadgerBadger Assigned ToChris_McElligottPark  
Status resolvedResolutionfixed 
Product Version0.886 Zombie Homebodies 
Fixed in Version0.887 Ending Scenes 
Summary0021564: Problems with reconquest seeding
Description9/3/2019 8:18:03 PM Hit debugCode 30 exception System.Exception: guardPostBag is null for Brand
  at Arcen.AIW2.External.AIDefensePlacer_Default.StartReconquestDefenseSeeding (Arcen.AIW2.Core.ArcenSimContext Context, Arcen.AIW2.Core.Planet ThisPlanet, Arcen.AIW2.Core.Faction faction) [0x000f4] in <5880ab743172483c94406afdb82c323d>:0 in StartReconquestDefenseSeeding
9/3/2019 8:25:28 PM

The code is
                    debugCode = 30;
                    PlanetFaction pFaction = ThisPlanet.GetPlanetFactionForFaction( faction );
                    ArcenRandomDrawBag<GameEntityTypeData> guardPostBag = null;
                    if ( pFaction.ShipGroup_GuardPosts != null )
                        guardPostBag = pFaction.ShipGroup_GuardPosts.DrawBag;
...
                    if ( guardPostBag == null )
                    {
                        //Having an empty guardPostBag is okay, but I don't believe it should be null
                        //if it is okay to be null then we can just change the below
                        //if ( guardPostBag.GetHasItems() ) to include a check for guardPostBag != null
                        throw new Exception("guardPostBag is null for " + ThisPlanet.Name);
                    }

My understanding is that the guardPostBag is set in
        #region DefinePlanetFactionDefenseTypesIfNeeded
        public static void DefinePlanetFactionDefenseTypesIfNeeded( ArcenSimContext Context, Planet ThisPlanet, Faction faction )
...
            if ( pFaction.ShipGroup_GuardPosts == null )
            {
                if ( ThisPlanet.PopulationType == PlanetPopulationType.AIHomeworld )
                    pFaction.ShipGroup_GuardPosts = reinforcementBudgetItem.DireGuardPostAIShipGroup.DrawBag.PickRandomItemAndReplace( Context.RandomToUse );
                if ( pFaction.ShipGroup_GuardPosts == null || !pFaction.ShipGroup_GuardPosts.DrawBag.GetHasItems() )
                    pFaction.ShipGroup_GuardPosts = reinforcementBudgetItem.GuardPostAIShipGroup.DrawBag.PickRandomItemAndReplace( Context.RandomToUse );
            }
TagsNo tags attached.

Activities

Chris_McElligottPark

Sep 5, 2019 12:29 pm

administrator   ~0052859

Thanks!

* Some extra code has been put in place to make it so that if for some reason during reconquest of a planet there are no guard post types already assigned to the planet, the AI can now figure out AI types.
** Most likely the reason this was happening before is that it wasn't an AI planet at the start of the game, and so it belatedly needed to find the guard post and/or guardian types.
** At the moment this is completely untested, but it should work.

Issue History

Date Modified Username Field Change
Sep 3, 2019 10:29 pm BadgerBadger New Issue
Sep 5, 2019 12:29 pm Chris_McElligottPark Assigned To => Chris_McElligottPark
Sep 5, 2019 12:29 pm Chris_McElligottPark Status new => resolved
Sep 5, 2019 12:29 pm Chris_McElligottPark Resolution open => fixed
Sep 5, 2019 12:29 pm Chris_McElligottPark Fixed in Version => 0.887 Ending Scenes
Sep 5, 2019 12:29 pm Chris_McElligottPark Note Added: 0052859