use kick inside manage player window#2798
use kick inside manage player window#2798IntegratedQuantum merged 11 commits intoPixelGuys:masterfrom
Conversation
| if (main.server.world != null) { | ||
| list.add(Button.initText(.{0, 0}, 128, "Invite Player", gui.openWindowCallback("invite"))); | ||
| } | ||
| list.add(Button.initText(.{0, 0}, 128, "Manage Players", gui.openWindowCallback("manage_players"))); |
There was a problem hiding this comment.
Maybe we should call it just players, since not everyone will be allowed to manage them.
As for the invite screen: I think it should stay accessible from this inventory directly, since it is not so obvious that you would get there from manage players.
|
|
||
| const old = main.settings.showIdWithName; | ||
| main.settings.showIdWithName = true; | ||
| defer main.settings.showIdWithName = old; |
There was a problem hiding this comment.
This is a hack, I don't like it. Instead you could just create a separate formatting function and call it with an Io.Writer.
There was a problem hiding this comment.
I have not found the right writer I should use... but I have found this alt method from the WriterGate PR.
| row.add(Label.init(.{0, 0}, 200, connection.user.?.name, .left)); | ||
| row.add(Button.initText(.{0, 0}, 100, "Kick", .initWithPtr(kick, connection))); | ||
| } else { | ||
| const ip = std.fmt.allocPrint(main.stackAllocator.allocator, "{f}", .{connection.remoteAddress}) catch unreachable; |
There was a problem hiding this comment.
Incomplete connections should also be observable and cancelable by the server owner.
There was a problem hiding this comment.
I brought it back. This had the same problem with the zero length name being skipped. but I now skip the the player himself. So it also now has the "no other player" info when needed.
There was a problem hiding this comment.
I hope I understood the isConnected check here is the right one. I don't know what I could else check (I am not that knowledgeable on the network code
Co-authored-by: IntegratedQuantum <43880493+IntegratedQuantum@users.noreply.github.com>
| userList[i].increaseRefCount(); | ||
| if (userList[i].id == main.game.Player.id and connection.isConnected()) continue; | ||
| const row = HorizontalList.init(); | ||
| if (connection.isConnected()) { |
There was a problem hiding this comment.
This is a lower level state, the connection is connected when it has done the initial connection handshake and is ready to transmit game data (like the player name).
You can use the handShakeState to check the progress of the game handshake where it exchanges the name.
There was a problem hiding this comment.
done. now it only shows the ip if the handshake is below the userData state. Also applied your suggestions with the function names
| if (userList[i].id == main.game.Player.id and connection.isConnected()) continue; | ||
| const row = HorizontalList.init(); | ||
| if (connection.isConnected()) { | ||
| if (@intFromEnum(connection.handShakeState.load(.monotonic)) >= @intFromEnum(main.network.Connection.HandShakeState.userData)) { |
There was a problem hiding this comment.
Should be >, since the protocol sets the value before actually processing the data.
Furthermore since it's unclear how this will change with the ECS (the entity might get created in a later step of the handshake), and generally avoid problems on future changes, I'd suggest to just check if the handshake is complete.
IntegratedQuantum
left a comment
There was a problem hiding this comment.
Yay, I can finally kick the host
Closes #2724
Changes:
One difference between the windows is still that the player opening the window is not shown for the client-side only version, while for the client-server version the player is in the list.
I would be ok with both versions that's why I take the question to the reviewers.