@@ -39,7 +39,7 @@ public class Game : GameWindow
3939 public const double TickRate = 1.0 / TicksPerSecond ;
4040 public const int HandshakeRate = TicksPerSecond ;
4141 public const int MaxTimeWithoutHandshake = TicksPerSecond * 5 ;
42- public const bool EnableCursorGrab = false ;
42+ public const bool EnableCursorGrab = true ;
4343 public const bool OpenGlDebugging = SharedConstants . Debug ; // Only enable this if your drivers support OpenGL 4.3+
4444
4545 public static double TimeElapsed => GLFW . GetTime ( ) ;
@@ -237,24 +237,23 @@ protected override void OnUpdateFrame(FrameEventArgs args)
237237 }
238238 Profiler . Pop ( ) ;
239239
240- if ( PacketHandler is not null )
240+ if ( PacketHandler is null ) continue ;
241+
242+ if ( Ticks > PacketHandler . TimeSinceLastHandshake
243+ && Ticks - PacketHandler . TimeSinceLastHandshake > MaxTimeWithoutHandshake )
241244 {
242- if ( Ticks > PacketHandler . TimeSinceLastHandshake
243- && Ticks - PacketHandler . TimeSinceLastHandshake > MaxTimeWithoutHandshake )
244- {
245- PacketHandler . HandlePacket ( new SDisconnect ( "Timed out" ) ) ;
246- }
247- else
248- {
249- if ( Ticks % HandshakeRate == 0 )
250- PacketHandler . Server . SendPacket ( CHandshake . Instance ) ;
245+ PacketHandler . HandlePacket ( new SDisconnect ( "Timed out" ) ) ;
246+ }
247+ else
248+ {
249+ if ( Ticks % HandshakeRate == 0 )
250+ PacketHandler . Server . SendPacket ( CHandshake . Instance ) ;
251251
252- if ( Player is not null )
253- PacketHandler . Server . SendPacket ( new CUpdatePosition ( Player ) ) ;
252+ if ( Player is not null )
253+ PacketHandler . Server . SendPacket ( new CUpdatePosition ( Player ) ) ;
254254
255- while ( PacketHandler . Server . PendingPackets . TryDequeue ( out IPacket ? packet ) )
256- PacketHandler . HandlePacket ( packet ) ;
257- }
255+ while ( PacketHandler . Server . PendingPackets . TryDequeue ( out IPacket ? packet ) )
256+ PacketHandler . HandlePacket ( packet ) ;
258257 }
259258 }
260259
@@ -474,11 +473,9 @@ public void ExitWorld()
474473 if ( World is null )
475474 return ;
476475
477- if ( Player is not null )
478- {
476+ if ( Player is not null && ! World . Remote )
479477 World . SaveHandler . SaveData ( "player" , ( CompoundItem ) Player . Serialize ( ) ) ;
480- Player = null ;
481- }
478+ Player = null ;
482479
483480 World . Close ( ) ;
484481 World = null ;
0 commit comments