int CLuaFunctionDefs::GetNetworkStats ( lua_State* luaVM ) { // table getNetworkStats ( [element player] ) CPlayer* pPlayer; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pPlayer, NULL ); if ( !argStream.HasErrors () ) { NetServerPlayerID PlayerID = pPlayer ? pPlayer->GetSocket () : NetServerPlayerID (); NetStatistics stats; if ( g_pNetServer->GetNetworkStatistics ( &stats, PlayerID ) ) { lua_createtable ( luaVM, 0, 11 ); lua_pushstring ( luaVM, "bytesReceived" ); lua_pushnumber ( luaVM, static_cast <double> ( stats.bytesReceived ) ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "bytesSent" ); lua_pushnumber ( luaVM, static_cast <double> ( stats.bytesSent ) ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "packetsReceived" ); lua_pushnumber ( luaVM, stats.packetsReceived ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "packetsSent" ); lua_pushnumber ( luaVM, stats.packetsSent ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "packetlossTotal" ); lua_pushnumber ( luaVM, stats.packetlossTotal ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "packetlossLastSecond" ); lua_pushnumber ( luaVM, stats.packetlossLastSecond ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "messagesInSendBuffer" ); lua_pushnumber ( luaVM, stats.messagesInSendBuffer ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "messagesInResendBuffer" ); lua_pushnumber ( luaVM, stats.messagesInResendBuffer ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "isLimitedByCongestionControl" ); lua_pushnumber ( luaVM, stats.isLimitedByCongestionControl ? 1 : 0 ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "isLimitedByOutgoingBandwidthLimit" ); lua_pushnumber ( luaVM, stats.isLimitedByOutgoingBandwidthLimit ? 1 : 0 ); lua_settable ( luaVM, -3 ); lua_pushstring ( luaVM, "encryptionStatus" ); lua_pushnumber ( luaVM, 1 ); lua_settable ( luaVM, -3 ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
CPacket::CPacket(void) { // Init m_pSourceElement = NULL; m_Source = NetServerPlayerID(0, 0); }