@@ -32,6 +32,8 @@ class Program
3232
3333 static bool isServerIpv4 = true ;
3434
35+ static byte [ ] [ ] lastPacketMessage ;
36+
3537 static void Main ( string [ ] args )
3638 {
3739 var nonInteractive = false ;
@@ -93,7 +95,7 @@ static void Main(string[] args)
9395
9496 private static void NetcodeServer ( )
9597 {
96- NetcodeLibrary . SetLogLevel ( NetcodeLogLevel . Debug ) ;
98+ NetcodeLibrary . SetLogLevel ( NetcodeLogLevel . Info ) ;
9799
98100 double time = 0f ;
99101 double deltaTime = 1.0 / 60.0 ;
@@ -103,23 +105,23 @@ private static void NetcodeServer()
103105 0x1122334455667788L ,
104106 _privateKey ,
105107 0 ) ;
106-
107- byte [ ] packetData = null ;
108-
108+
109109 server . Start ( NetcodeLibrary . GetMaxClients ( ) ) ;
110110
111+ lastPacketMessage = new byte [ NetcodeLibrary . GetMaxClients ( ) ] [ ] ;
112+
111113 while ( running )
112114 {
113115 server . Update ( time ) ;
114116
115117 for ( var clientIndex = 0 ; clientIndex < NetcodeLibrary . GetMaxClients ( ) ; clientIndex ++ )
116118 {
117- if ( server . ClientConnected ( clientIndex ) && packetData != null )
119+ if ( server . ClientConnected ( clientIndex ) && lastPacketMessage [ clientIndex ] != null )
118120 {
119- server . SendPacket ( clientIndex , packetData ) ;
121+ server . SendPacket ( clientIndex , lastPacketMessage [ clientIndex ] ) ;
122+ lastPacketMessage [ clientIndex ] = null ;
120123 }
121124 }
122- packetData = null ;
123125
124126 for ( var clientIndex = 0 ; clientIndex < NetcodeLibrary . GetMaxClients ( ) ; clientIndex ++ )
125127 {
@@ -130,8 +132,8 @@ private static void NetcodeServer()
130132 {
131133 break ;
132134 }
133-
134- packetData = packet ;
135+
136+ lastPacketMessage [ clientIndex ] = packet ;
135137 }
136138 }
137139
0 commit comments