public static void SV_ReadPackets( ) { Int32 i; client_t cl; var qport = 0; while (NET.GetPacket(Defines.NS_SERVER, Globals.net_from, Globals.net_message)) { if ((Globals.net_message.data[0] == -1) && (Globals.net_message.data[1] == -1) && (Globals.net_message.data[2] == -1) && (Globals.net_message.data[3] == -1)) { SV_ConnectionlessPacket(); continue; } MSG.BeginReading(Globals.net_message); MSG.ReadLong(Globals.net_message); MSG.ReadLong(Globals.net_message); qport = MSG.ReadShort(Globals.net_message) & 0xffff; for (i = 0; i < SV_MAIN.maxclients.value; i++) { cl = SV_INIT.svs.clients[i]; if (cl.state == Defines.cs_free) { continue; } if (!NET.CompareBaseAdr(Globals.net_from, cl.netchan.remote_address)) { continue; } if (cl.netchan.qport != qport) { continue; } if (cl.netchan.remote_address.port != Globals.net_from.port) { Com.Printf("SV_ReadPackets: fixing up a translated port\\n"); cl.netchan.remote_address.port = Globals.net_from.port; } if (Netchan.Process(cl.netchan, Globals.net_message)) { if (cl.state != Defines.cs_zombie) { cl.lastmessage = SV_INIT.svs.realtime; SV_USER.SV_ExecuteClientMessage(cl); } } break; } if (i != SV_MAIN.maxclients.value) { continue; } } }
/** * Reads packets from the network or loopback. */ public static void SV_ReadPackets() { int i; client_t cl; var qport = 0; while (NET.GetPacket(Defines.NS_SERVER, Globals.net_from, Globals.net_message)) { // check for connectionless packet (0xffffffff) first if (Globals.net_message.data[0] == 255 && Globals.net_message.data[1] == 255 && Globals.net_message.data[2] == 255 && Globals.net_message.data[3] == 255) { SV_MAIN.SV_ConnectionlessPacket(); continue; } // read the qport out of the message so we can fix up // stupid address translating routers MSG.BeginReading(Globals.net_message); MSG.ReadLong(Globals.net_message); // sequence number MSG.ReadLong(Globals.net_message); // sequence number qport = MSG.ReadShort(Globals.net_message) & 0xffff; // check for packets from connected clients for (i = 0; i < SV_MAIN.maxclients.value; i++) { cl = SV_INIT.svs.clients[i]; if (cl.state == Defines.cs_free) { continue; } if (!NET.CompareBaseAdr(Globals.net_from, cl.netchan.remote_address)) { continue; } if (cl.netchan.qport != qport) { continue; } if (cl.netchan.remote_address.port != Globals.net_from.port) { Com.Printf("SV_ReadPackets: fixing up a translated port\n"); cl.netchan.remote_address.port = Globals.net_from.port; } if (Netchan.Process(cl.netchan, Globals.net_message)) { // this is a valid, sequenced packet, so process it if (cl.state != Defines.cs_zombie) { cl.lastmessage = SV_INIT.svs.realtime; // don't timeout SV_USER.SV_ExecuteClientMessage(cl); } } break; } if (i != SV_MAIN.maxclients.value) { continue; } } }