From c72ef4a8c30770b0ce4378817d0d0b094f0a7b2b Mon Sep 17 00:00:00 2001 From: abstrct Date: Sun, 18 Jan 2026 10:16:20 -0500 Subject: [PATCH] Fixed bug in new cmd ship creation --- x/structs/keeper/fleet_cache.go | 2 +- x/structs/keeper/struct_cache.go | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/x/structs/keeper/fleet_cache.go b/x/structs/keeper/fleet_cache.go index 73f866c..6aeb833 100644 --- a/x/structs/keeper/fleet_cache.go +++ b/x/structs/keeper/fleet_cache.go @@ -545,7 +545,7 @@ func (cache *FleetCache) MigrateToNewPlanet(destination *PlanetCache) { cache.FleetLoaded = true // Build an Initial Command Ship - structure := cache.K.InitialCommandShipStruct(cache.Ctx, cache.GetOwner()) + structure := cache.K.InitialCommandShipStruct(cache.Ctx, cache) // TODO Not a huge fan that this is committed separately // Could change cache.commit() to comment the command struct too // but that would need SetCommandStruct to accept the StructCache instead of Struct. diff --git a/x/structs/keeper/struct_cache.go b/x/structs/keeper/struct_cache.go index 380ed66..b991a3f 100644 --- a/x/structs/keeper/struct_cache.go +++ b/x/structs/keeper/struct_cache.go @@ -111,23 +111,25 @@ func (k *Keeper) GetStructCacheFromId(ctx context.Context, structId string) (Str } -func (k *Keeper) InitialCommandShipStruct(ctx context.Context, owner *PlayerCache) (StructCache) { +func (k *Keeper) InitialCommandShipStruct(ctx context.Context, fleet *FleetCache) (StructCache) { structType, _ := k.GetStructType(ctx, types.CommandStructTypeId) - structure := types.CreateBaseStruct(&structType, owner.GetPrimaryAddress(), owner.GetPlayerId(), structType.Category, types.Ambit_space) + structure := types.CreateBaseStruct(&structType, fleet.GetOwner().GetPrimaryAddress(), fleet.GetOwner().GetPlayerId(), structType.Category, types.Ambit_space) structure = k.AppendStruct(ctx, structure) - owner.BuildQuantityIncrement(structType.GetId()) + fleet.GetOwner().BuildQuantityIncrement(structType.GetId()) var structStatus types.StructState - if owner.CanSupportLoadAddition(structType.GetPassiveDraw()) { - owner.StructsLoadIncrement(structType.GetPassiveDraw()) + if fleet.GetOwner().CanSupportLoadAddition(structType.GetPassiveDraw()) { + fleet.GetOwner().StructsLoadIncrement(structType.GetPassiveDraw()) structStatus = types.StructState(types.StructStateMaterialized | types.StructStateBuilt | types.StructStateOnline) } else { structStatus = types.StructState(types.StructStateMaterialized | types.StructStateBuilt ) } + structure.LocationId = fleet.GetFleetId() + // Start to put the pieces together structCache := StructCache{ StructId: structure.Id, @@ -140,10 +142,10 @@ func (k *Keeper) InitialCommandShipStruct(ctx context.Context, owner *PlayerCach StructureChanged: false, StructureLoaded: true, - Owner: owner, + Owner: fleet.GetOwner(), OwnerLoaded: true, - Fleet: owner.GetFleet(), + Fleet: fleet, FleetLoaded: true, // Include the health value