Closed HaoTNN closed 9 years ago
This is great, so glad to have it. I haven't looked into it in detail yet; on the whole implementation looks good, but here's a couple notes I had so far:
stream.WriteByte(Convert.ToByte(true))
, add the addBoolean
and getBoolean
methods to Extensions/ByteConverterExtension
, so you can do stream writing for booleans in the same way as other native data types, i.e. stream.addLong((long)Grid.GetPosition().X)
.canDisplayPositionTo(IMyCubeGrid grid, long playerID)
in Utility
, create an extension method on grids like canDisplayPositionTo(this IMyCubeGrid grid, long playerID)
in Extensions/GridExtensions
. Since this method doesn't rely on any other GC logic and is really a simple relationship between Grids and Players, that's a good place to define it. Let's reserve Utility for things that we can't find any more appropriate place for.Sound ok?
Alright cool, I made the changes as you suggested. Do you want me to squash these commits down?
Big whoops on the tab indents. Didn't realize VS was converting my tabs to spaces, heh.
As discussed:
And we should be good to go!
/gc fleet is rewritten to send data to client now instead of just a dialog, which should allow for the implementation of /gc fleet disown. The problem right now with disown is that the current ModAPI doesn't have a changeOwner() method to change the owner of a block, so we can't really disown a player's grid. I've looked through the Space Engineers' source code and mostly figured out what method to expose so I'll throw up a PR on that and see if we can get that changeOwner() functionality.
Regardless, I've included most of the code for /gc fleet disown. Just need to uncomment a few lines when ModAPI supports block.changeOwner().
As for how /gc fleet is rewritten: instead of sending a dialog, the server now sends the client data about their fleet and the client stores it. The client will then build a string and call a dialog to display their fleet information. FleetResponse handles the serialization; it works pretty much the same as SettingsResponse. The data that's being sent can be found in the struct GridData in GridEnforcer.
/gc fleet also shows the player their grid coordinates, given that the player is the owner of the main cockpit OR the owner of the main cockpit is part of the player's faction. If the grid doesn't have a main cockpit, the coordinates won't show up.
Let me know if you want anything changed.