@@ -42,9 +42,9 @@ func (cache *FleetCache) ID() string {
4242}
4343
4444func (cache * FleetCache ) LoadFleet () (found bool ) {
45- cache .Fleet , found = cache .CC .k .GetFleet (cache .CC .ctx , cache .FleetId )
45+ cache .Fleet , cache . FleetLoaded = cache .CC .k .GetFleet (cache .CC .ctx , cache .FleetId )
4646
47- if (! found ) {
47+ if (! cache . FleetLoaded ) {
4848 fleet := types .CreateEmptyFleet ()
4949 // Set the ID of the appended value
5050 fleet .Id = cache .FleetId
@@ -53,15 +53,13 @@ func (cache *FleetCache) LoadFleet() (found bool) {
5353 player , _ := cache .CC .GetPlayer (cache .PlayerId )
5454 player .SetFleetId (cache .FleetId )
5555
56- structure := cache .CC .InitialCommandShipStruct (cache .PlayerId , cache .FleetId )
57- cache .SetCommandStruct (structure .GetStructId ())
58-
5956 cache .Fleet = fleet
6057 cache .Changed = true
58+ cache .FleetLoaded = true
59+ structure := cache .CC .InitialCommandShipStruct (cache )
60+ cache .SetCommandStruct (structure .GetStructId ())
6161 }
6262
63- cache .FleetLoaded = true
64-
6563 return cache .FleetLoaded
6664}
6765
@@ -261,7 +259,7 @@ func (cache *FleetCache) PeaceDeal() (){
261259
262260func (cache * FleetCache ) BuildInitiateReadiness (structure * types.Struct , structType * StructTypeCache , ambit types.Ambit , ambitSlot uint64 ) (error ) {
263261 if structure .GetOwner () != cache .GetOwnerId () {
264- return types .NewStructOwnershipError (structure .GetStructId () , cache .GetOwnerId (), structure .GetOwner ()).WithLocation ("fleet" , cache .GetFleetId ())
262+ return types .NewStructOwnershipError (structure .Id , cache .GetOwnerId (), structure .GetOwner ()).WithLocation ("fleet" , cache .GetFleetId ())
265263 }
266264
267265 if cache .IsAway () {
@@ -280,17 +278,17 @@ func (cache *FleetCache) BuildInitiateReadiness(structure *types.Struct, structT
280278 }
281279
282280 if (structType .GetStructType ().Category != types .ObjectType_fleet ) {
283- return types .NewStructLocationError (structType .GetId (), ambit .String (), "outside_planet" )
281+ return types .NewStructLocationError (structType .ID (), ambit .String (), "outside_planet" )
284282 }
285283
286284 // Check that the Struct can exist in the specified ambit
287- if types .Ambit_flag [ambit ]& structType .PossibleAmbit == 0 {
288- return types .NewStructLocationError (structType .GetId (), ambit .String (), "invalid_ambit" )
285+ if types .Ambit_flag [ambit ]& structType .GetStructType (). PossibleAmbit == 0 {
286+ return types .NewStructLocationError (structType .ID (), ambit .String (), "invalid_ambit" )
289287 }
290288
291289 if structType .GetStructType ().Type == types .CommandStruct {
292290 if cache .HasCommandStruct () {
293- return types .NewStructBuildError (structType .GetId (), "fleet" , cache .GetFleetId (), "command_exists" )
291+ return types .NewStructBuildError (structType .ID (), "fleet" , cache .GetFleetId (), "command_exists" )
294292 }
295293
296294 } else {
@@ -312,14 +310,14 @@ func (cache *FleetCache) BuildInitiateReadiness(structure *types.Struct, structT
312310 slots = cache .GetFleet ().SpaceSlots
313311 slot = cache .GetFleet ().Space [ambitSlot ]
314312 default :
315- return types .NewStructBuildError (structType .GetId (), "fleet" , cache .GetFleetId (), "invalid_ambit" ).WithAmbit (ambit .String ())
313+ return types .NewStructBuildError (structType .ID (), "fleet" , cache .GetFleetId (), "invalid_ambit" ).WithAmbit (ambit .String ())
316314 }
317315
318316 if (ambitSlot >= slots ) {
319- return types .NewStructBuildError (structType .GetId (), "fleet" , cache .GetFleetId (), "slot_unavailable" ).WithSlot (ambitSlot )
317+ return types .NewStructBuildError (structType .ID (), "fleet" , cache .GetFleetId (), "slot_unavailable" ).WithSlot (ambitSlot )
320318 }
321319 if (slot != "" ) {
322- return types .NewStructBuildError (structType .GetId (), "fleet" , cache .GetFleetId (), "slot_occupied" ).WithSlot (ambitSlot ).WithExistingStruct (slot )
320+ return types .NewStructBuildError (structType .ID (), "fleet" , cache .GetFleetId (), "slot_occupied" ).WithSlot (ambitSlot ).WithExistingStruct (slot )
323321 }
324322 }
325323 return nil
@@ -333,12 +331,12 @@ func (cache *FleetCache) MoveReadiness(structure *StructCache, ambit types.Ambit
333331 }
334332
335333 if (structure .GetStructType ().Category != types .ObjectType_fleet ) {
336- return types .NewStructLocationError (structure .GetStructType (). GetId (), ambit .String (), "outside_planet" )
334+ return types .NewStructLocationError (structure .GetTypeId (), ambit .String (), "outside_planet" )
337335 }
338336
339337 // Check that the Struct can exist in the specified ambit
340338 if types .Ambit_flag [ambit ]& structure .GetStructType ().PossibleAmbit == 0 {
341- return types .NewStructLocationError (structure .GetStructType (). GetId (), ambit .String (), "invalid_ambit" )
339+ return types .NewStructLocationError (structure .GetTypeId (), ambit .String (), "invalid_ambit" )
342340 }
343341
344342 if structure .GetStructType ().Type != types .CommandStruct {
@@ -360,14 +358,14 @@ func (cache *FleetCache) MoveReadiness(structure *StructCache, ambit types.Ambit
360358 slots = cache .GetFleet ().SpaceSlots
361359 slot = cache .GetFleet ().Space [ambitSlot ]
362360 default :
363- return types .NewStructBuildError (structure .GetStructType (). GetId (), "fleet" , cache .GetFleetId (), "invalid_ambit" ).WithAmbit (ambit .String ())
361+ return types .NewStructBuildError (structure .GetTypeId (), "fleet" , cache .GetFleetId (), "invalid_ambit" ).WithAmbit (ambit .String ())
364362 }
365363
366364 if (ambitSlot >= slots ) {
367- return types .NewStructBuildError (structure .GetStructType (). GetId (), "fleet" , cache .GetFleetId (), "slot_unavailable" ).WithSlot (ambitSlot )
365+ return types .NewStructBuildError (structure .GetTypeId (), "fleet" , cache .GetFleetId (), "slot_unavailable" ).WithSlot (ambitSlot )
368366 }
369367 if (slot != "" ) {
370- return types .NewStructBuildError (structure .GetStructType (). GetId (), "fleet" , cache .GetFleetId (), "slot_occupied" ).WithSlot (ambitSlot ).WithExistingStruct (slot )
368+ return types .NewStructBuildError (structure .GetTypeId (), "fleet" , cache .GetFleetId (), "slot_occupied" ).WithSlot (ambitSlot ).WithExistingStruct (slot )
371369 }
372370 }
373371 return nil
0 commit comments