@@ -34,7 +34,7 @@ public partial class CoveServer
34
34
public string LobbyCode = new string ( Enumerable . Range ( 0 , 5 ) . Select ( _ => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" [ new Random ( ) . Next ( 36 ) ] ) . ToArray ( ) ) ;
35
35
public bool codeOnly = true ;
36
36
public bool ageRestricted = false ;
37
-
37
+
38
38
public string joinMessage = "This is a Cove dedicated server!\n Please report any issues to the github (xr0.xyz/cove)" ;
39
39
public bool displayJoinMessage = true ;
40
40
@@ -66,7 +66,10 @@ public partial class CoveServer
66
66
public void Init ( )
67
67
{
68
68
cbThread = new ( runSteamworksUpdate ) ;
69
+ cbThread . Name = "Steamworks Callback Thread" ;
70
+
69
71
networkThread = new ( RunNetwork ) ;
72
+ networkThread . Name = "Network Thread" ;
70
73
71
74
Console . WriteLine ( "Loading world!" ) ;
72
75
string worldFile = $ "{ AppDomain . CurrentDomain . BaseDirectory } worlds/main_zone.tscn";
@@ -207,7 +210,7 @@ public void Init()
207
210
// like 10 minutes of delay within 30 seconds
208
211
networkThread . IsBackground = true ;
209
212
networkThread . Start ( ) ;
210
-
213
+
211
214
bool LogServices = false ;
212
215
ILoggerFactory loggerFactory = LoggerFactory . Create ( builder =>
213
216
{
@@ -367,13 +370,17 @@ private bool getBoolFromString(string str)
367
370
void runSteamworksUpdate ( )
368
371
{
369
372
while ( true )
373
+ {
374
+ Thread . Sleep ( 25 ) ;
370
375
SteamAPI . RunCallbacks ( ) ;
376
+ }
371
377
}
372
378
373
379
void RunNetwork ( )
374
380
{
375
381
while ( true )
376
382
{
383
+ bool didWork = false ;
377
384
try
378
385
{
379
386
for ( int i = 0 ; i < 6 ; i ++ )
@@ -382,6 +389,7 @@ void RunNetwork()
382
389
// we are going to check if there are any incoming net packets!
383
390
if ( SteamNetworking . IsP2PPacketAvailable ( out packetSize , nChannel : i ) )
384
391
{
392
+ didWork = true ;
385
393
byte [ ] packet = new byte [ packetSize ] ;
386
394
uint bytesRead = 0 ;
387
395
CSteamID sender ;
@@ -397,10 +405,13 @@ void RunNetwork()
397
405
{
398
406
if ( ! showErrorMessages )
399
407
return ;
400
-
408
+
401
409
Console . WriteLine ( "-- Error responding to packet! --" ) ;
402
410
Console . WriteLine ( e . ToString ( ) ) ;
403
411
}
412
+
413
+ if ( ! didWork )
414
+ Thread . Sleep ( 10 ) ;
404
415
}
405
416
}
406
417
0 commit comments