@@ -135,14 +135,12 @@ namespace cage
135135 {
136136 InitializerSockets ()
137137 {
138+ SteamNetworkingSockets_SetServiceThreadInitCallback (+[]() { currentThreadName (" steam sockets" ); });
139+ SteamNetworkingErrMsg msg;
140+ if (!GameNetworkingSockets_Init (nullptr , msg))
138141 {
139- SteamNetworkingSockets_SetServiceThreadInitCallback (+[]() { currentThreadName (" steam sockets" ); });
140- SteamNetworkingErrMsg msg;
141- if (!GameNetworkingSockets_Init (nullptr , msg))
142- {
143- CAGE_LOG_THROW (msg);
144- CAGE_THROW_ERROR (Exception, " failed to initialize steam sockets networking library" );
145- }
142+ CAGE_LOG_THROW (msg);
143+ CAGE_THROW_ERROR (Exception, " failed to initialize steam sockets networking library" );
146144 }
147145 }
148146 ~InitializerSockets () { GameNetworkingSockets_Kill (); }
@@ -156,6 +154,11 @@ namespace cage
156154 sockets = SteamNetworkingSockets ();
157155 utils = SteamNetworkingUtils ();
158156 }
157+ if (!sockets || !utils)
158+ {
159+ CAGE_LOG (SeverityEnum::Note, " steamsocks" , Stringizer () + " sockets: " + sockets + " , utils: " + utils);
160+ CAGE_THROW_ERROR (Exception, " steam sockets api pointer is invalid" );
161+ }
159162 CAGE_ASSERT (sockets);
160163 CAGE_ASSERT (utils);
161164
@@ -164,8 +167,12 @@ namespace cage
164167 InitializerConfiguration ()
165168 {
166169 utils->SetDebugOutputFunction ((ESteamNetworkingSocketsDebugOutputType)(sint32)confDebugLogLevel, &debugOutputHandler);
167- utils->SetGlobalConfigValueFloat (k_ESteamNetworkingConfig_FakePacketLoss_Send, confSimulatedPacketLoss * 100 );
168- utils->SetGlobalConfigValueInt32 (k_ESteamNetworkingConfig_FakePacketLag_Send, (sint32)confSimulatedPacketDelay);
170+ const float packetLoss = confSimulatedPacketLoss * 100 ;
171+ const sint32 packetDelay = (sint32)confSimulatedPacketDelay;
172+ if (packetLoss != 0 || packetDelay != 0 )
173+ CAGE_LOG (SeverityEnum::Warning, " steamsocks" , Stringizer () + " setting packet loss: " + packetLoss + " %, packet delay: " + packetDelay + " ms" );
174+ utils->SetGlobalConfigValueFloat (k_ESteamNetworkingConfig_FakePacketLoss_Send, packetLoss);
175+ utils->SetGlobalConfigValueInt32 (k_ESteamNetworkingConfig_FakePacketLag_Send, packetDelay);
169176 utils->SetGlobalConfigValueInt32 (k_ESteamNetworkingConfig_IPLocalHost_AllowWithoutAuth, 1 );
170177 }
171178 };
0 commit comments