Closed Demolish50 closed 5 years ago
Can you elaborate more? The builtby shouldnt effect the ownedby ?
Every block you build, even armor blocks have a builtby node that contains the playerid of the player who built it. It's how the in game block limit system keeps track of who built what blocks.
It seems you are only transferring functional computer blocks when doing a ship trade.
Here is a cubeblock that is an armor block
`
Agreed. Not changing the BuiltBy is dangerous.
Sample code for changing it is located here. https://github.com/midspace/Space-Engineers-Admin-script-mod/blob/master/midspace%20admin%20helper/Data/Scripts/midspace.adminscripts/Messages/Sync/MessageSyncGridChange.cs#L242
also not sure if related just had a crash after using sell ship buyship and bal:
2017-03-26 16:17:21.123 - Thread: 1 -> Exception occured: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.KeyCollection.Enumerator.MoveNext() at Sandbox.Game.Entities.Cube.MyCubeGridOwnershipManager.RecalculateOwners() at Sandbox.Game.Entities.MyCubeGrid.DoLazyUpdates() at Sandbox.Game.Entities.MyCubeGrid.UpdateAfterSimulation() at Sandbox.Game.Entities.MyEntities.<UpdateAfterSimulation>b__d(MyEntity x) at VRage.Collections.MyDistributedUpdater
2.Iterate(Action`1 p)
at Sandbox.Game.Entities.MyEntities.UpdateAfterSimulation()
at Sandbox.Game.World.MySector.UpdateAfterSimulation()
at Sandbox.Game.World.MySession.UpdateComponents()
at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime)
at Sandbox.MySandboxGame.Update()
at Sandbox.Engine.Platform.Game.UpdateInternal()
at Sandbox.Engine.Platform.Game.RunSingleFrame()
at Sandbox.Engine.Platform.FixedLoop.<>cDisplayClass1.
So looks like we need to change https://github.com/jpcsupplies/Economy_mod/blob/master/Economy/Data/Scripts/Economy.scripts/Messages/MessageShipSale.cs#L248 to also do ((MyCubeGrid)grid).TransferBlocksBuiltByID(identity.IdentityId, selectedPlayer.IdentityId);
Since non owned blocks also have a built by, we also need to rework the code that skips over armor blocks etc, and change that too.. ?
I am going to post a recommendation on the Frontier Economy page recommending in the short term that admins disable the remote removal of owned blocks option. Is that an option admin mod can access? Shared hosting servers may struggle to access an option they can only touch in XML.
Can some explain to me what the loop starting here does? https://github.com/jpcsupplies/Economy_mod/blob/master/Economy/Data/Scripts/Economy.scripts/Messages/MessageShipSale.cs#L254
Because as far as I understand, ownership was changed at L250. There are lots of calls to fetch the block definition using GetObjectBuilder(), which is a very costly operation, and then nothing uses the definition.
@temar96
your right i dont see a purpose in those 2 lines, it may have been used for something earlier on in the coding
the loop changes ownership of the individual blocks that have ownership but the blockDefintion variable doesnt seem to be used
So far testers seem to indicate other than a brief client residue which goes away when they reconnect the issue seems to resolved by your last commit.
Could you elaborate on what client residue
is?
when ownership changes, the local client still see's it as not changed.. so its like "residual" traces of the prior ownership. If they reconnect both client and server see the new owner fine.
AFAIK this is now all working correctly
Ship trading needs to also change the builtby attribute. If you don't, when someone removes their owned block it removed all the blocks on the ship that was traded.