Caves of Qud

Caves of Qud

Recoverable Arrows
Bit of MODERROR spam during game load (mod compat)
Heyoo.

I'm getting some MODERROR spam during game load when I've got GigantismPlus (co-author) running.

MODERROR [Recoverable Arrows] - Failed creating:ProjectileDesertRifleShell: System.NullReferenceException: Object reference not set to an instance of an object at XRL.EventRegistrar.Register (XRL.IEventSource Source, System.Int32 EventID, System.Int32 Order, System.Boolean Serialize) [0x00000] in <cde1d5e5836a46da8690949494b3d578>:0 at XRL.World.Parts.RA_RecoverableProjectile.Register (XRL.World.GameObject go, XRL.IEventRegistrar registrar) [0x0002d] in C:\Program Files (x86)\Steam\steamapps\workshop\content\333640\3312620817\Scripts\RecoverableProjectile.cs:22 at XRL.World.IPart.ApplyRegistrar (XRL.World.GameObject Object, System.Boolean Active) [0x00022] in <cde1d5e5836a46da8690949494b3d578>:0 at XRL.World.GameObject.AddPartInternals (XRL.World.IPart P, System.Boolean DoRegistration, System.Boolean Initial, System.Boolean Creation) [0x00078] in <cde1d5e5836a46da8690949494b3d578>:0 at XRL.World.GameObject.AddPart (XRL.World.IPart P, System.Boolean DoRegistration, System.Boolean Creation) [0x0000a] in <cde1d5e5836a46da8690949494b3d578>:0 at XRL.World.GameObjectFactory.CreateObject (XRL.World.GameObjectBlueprint Blueprint, System.Int32 BonusModChance, System.Int32 SetModNumber, System.String AutoMod, System.Action`1[T] BeforeObjectCreated, System.Action`1[T] AfterObjectCreated, System.String Context, System.Collections.Generic.List`1[T] ProvideInventory) [0x001f0] in <cde1d5e5836a46da8690949494b3d578>:0 at XRL.World.GameObjectFactory.CreateObject (System.String ObjectBlueprint, System.Int32 BonusModChance, System.Int32 SetModNumber, System.String AutoMod, System.Action`1[T] BeforeObjectCreated, System.Action`1[T] AfterObjectCreated, System.String Context, System.Collections.Generic.List`1[T] ProvideInventory) [0x00021] in <cde1d5e5836a46da8690949494b3d578>:0

The cause is some shenanigans I'm doing during startup with the tinker recipes which seems to be triggering RA_RecoverableProjectile's Register method before The.Game has been instantiated and assigned in RecoverableProjectile.cs (per the MODERRORs, on line 22)

15 public override void Register(GameObject go, IEventRegistrar registrar) { 16 BreakChance = ParentObject.GetIntProperty("RA_BreakChance", 101); 17 18 if (BreakChance < 100) { 19 registrar.Register("ProjectileHit"); 20 } 21 22 registrar.Register(The.Game, RA_UninstallEvent.ID); 23 base.Register(go, registrar); 24 }

I've changed line 22 of the version I have downloaded to instead be
if (The.Game != null) { registrar.Register(The.Game, RA_UninstallEvent.ID); }
and it's fixed it for me.

I'm unfortunately unable to stop the startup stuff from creating all these sample objects before the The.Game is assigned to without disabling the startup stuff altogether.