Companions uninteractable if they have no abilities

Issue #1012 resolved
Armithaig created an issue

When attempting to interact with a companion with no abilities this exception will be thrown.

Exception at TwiddleObject: System.NullReferenceException: Object reference not set to an instance of an object
  at XRL.World.GameObject.HandleOwnerGetInventoryActionsEvent (XRL.World.OwnerGetInventoryActionsEvent E) [0x00000] in <filename unknown>:0 
  at XRL.World.GameObject.HandleEvent[OwnerGetInventoryActionsEvent] (XRL.World.OwnerGetInventoryActionsEvent E) [0x00000] in <filename unknown>:0 
  at XRL.World.OwnerGetInventoryActionsEvent.Send (XRL.World.GameObject Actor, XRL.World.GameObject Object, System.Collections.Generic.Dictionary`2 Actions) [0x00000] in <filename unknown>:0 
  at Qud.API.EquipmentAPI.TwiddleObject (XRL.World.GameObject Owner, XRL.World.GameObject GO, System.Boolean& Done, Boolean Distant) [0x00000] in <filename unknown>:0 

This is because the last option, CompanionAbilityUse, will call ActivatedAbilities.GetAbilityCount().

ActivatedAbilities only creates the counted AbilityByGuid dictionary when the creature receives an ability, no ability = NullReferenceException.

Confirmed through Harmony (thank you Brian!).

Comments (6)

  1. chaos

    No, that isn't why. If it were, the trace would be going into GetAbilityCount(). Unable to reproduce, but took steps to mitigate the few remaining possible scenarios that could lead to it. Hopefully fixed in 200.81. If it recurs, replication steps from a new game would be helpful.

  2. Armithaig reporter
    • changed status to open

    Hell I felt dumb there for a second, but’m 99% sure GetAbilityCount() would get inlined by the compiler and that’s why the trace doesn’t go there.

    This also lined up with another issue’d had with GetAbilityByCommand() for the same reasons, no dictionary & no null-check.

    Repro: Start new game with beguile or proselytize → wish for a snapjaw scavenger → make it a companion → Ctrl+Space to interact.

  3. chaos

    Ahh, k, inlining would do it. Hopefully that is it because I did correct GetAbilityCount() anyway, so that'd be fixed in 200.81.

  4. Log in to comment