From: Rene S. <sa...@us...> - 2005-12-27 21:02:42
|
Update of /cvsroot/jake2/jake2/src/jake2/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7724/src/jake2/sys Modified Files: NET.java Log Message: code cleanups and beautification Index: NET.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/sys/NET.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NET.java 26 Jun 2005 09:17:33 -0000 1.8 --- NET.java 27 Dec 2005 21:02:31 -0000 1.9 *************** *** 46,50 **** private final static int MAX_LOOPBACK = 4; ! // local loopback adress private static netadr_t net_local_adr = new netadr_t(); --- 46,50 ---- private final static int MAX_LOOPBACK = 4; ! /** Local loopback adress. */ private static netadr_t net_local_adr = new netadr_t(); *************** *** 78,85 **** private static DatagramSocket[] ip_sockets = { null, null }; ! /* ! * CompareAdr ! * ! * Compares with the port */ public static boolean CompareAdr(netadr_t a, netadr_t b) { --- 78,83 ---- private static DatagramSocket[] ip_sockets = { null, null }; ! /** ! * Compares ip address and port. */ public static boolean CompareAdr(netadr_t a, netadr_t b) { *************** *** 88,95 **** } ! /* ! * CompareBaseAdr ! * ! * Compares without the port */ public static boolean CompareBaseAdr(netadr_t a, netadr_t b) { --- 86,91 ---- } ! /** ! * Compares ip address without the port. */ public static boolean CompareBaseAdr(netadr_t a, netadr_t b) { *************** *** 107,114 **** } ! /* ! * AdrToString ! * ! * IP address with the port */ public static String AdrToString(netadr_t a) { --- 103,108 ---- } ! /** ! * Returns a string holding ip address and port like "ip0.ip1.ip2.ip3:port". */ public static String AdrToString(netadr_t a) { *************** *** 121,128 **** } ! /* ! * BaseAdrToString ! * ! * IP address without the port */ public static String BaseAdrToString(netadr_t a) { --- 115,120 ---- } ! /** ! * Returns IP address without the port as string. */ public static String BaseAdrToString(netadr_t a) { *************** *** 134,139 **** } ! /* ! * StringToAdr */ public static boolean StringToAdr(String s, netadr_t a) { --- 126,131 ---- } ! /** ! * Creates an netadr_t from an string. */ public static boolean StringToAdr(String s, netadr_t a) { *************** *** 156,161 **** } ! /* ! * IsLocalAddress */ public static boolean IsLocalAddress(netadr_t adr) { --- 148,153 ---- } ! /** ! * Seems to return true, if the address is is on 127.0.0.1. */ public static boolean IsLocalAddress(netadr_t adr) { *************** *** 171,174 **** --- 163,169 ---- */ + /** + * Gets a packet from internal loopback. + */ public static boolean GetLoopPacket(int sock, netadr_t net_from, sizebuf_t net_message) { *************** *** 193,198 **** } ! /* ! * SendLoopPacket */ public static void SendLoopPacket(int sock, int length, byte[] data, --- 188,193 ---- } ! /** ! * Sends a packet via internal loopback. */ public static void SendLoopPacket(int sock, int length, byte[] data, *************** *** 211,216 **** } ! /* ! * GetPacket */ public static boolean GetPacket(int sock, netadr_t net_from, --- 206,211 ---- } ! /** ! * Gets a packet from a network channel */ public static boolean GetPacket(int sock, netadr_t net_from, *************** *** 256,261 **** } ! /* ! * SendPacket */ public static void SendPacket(int sock, int length, byte[] data, netadr_t to) { --- 251,256 ---- } ! /** ! * Sends a Packet. */ public static void SendPacket(int sock, int length, byte[] data, netadr_t to) { *************** *** 274,289 **** try { ! SocketAddress dstSocket = new InetSocketAddress( ! to.getInetAddress(), to.port); ip_channels[sock].send(ByteBuffer.wrap(data, 0, length), dstSocket); } catch (Exception e) { ! Com ! .Println("NET_SendPacket ERROR: " + e + " to " ! + AdrToString(to)); } } ! /* ! * OpenIP */ public static void OpenIP() { --- 269,281 ---- try { ! SocketAddress dstSocket = new InetSocketAddress(to.getInetAddress(), to.port); ip_channels[sock].send(ByteBuffer.wrap(data, 0, length), dstSocket); } catch (Exception e) { ! Com.Println("NET_SendPacket ERROR: " + e + " to " + AdrToString(to)); } } ! /** ! * OpenIP, creates the network sockets. */ public static void OpenIP() { *************** *** 302,309 **** } ! /* ! * Config ! * ! * A single player game will only use the loopback code */ public static void Config(boolean multiplayer) { --- 294,299 ---- } ! /** ! * Config multi or singlepalyer - A single player game will only use the loopback code. */ public static void Config(boolean multiplayer) { *************** *** 322,326 **** } ! /* * Init */ --- 312,316 ---- } ! /** * Init */ *************** *** 364,369 **** } ! /* ! * Shutdown */ public static void Shutdown() { --- 354,359 ---- } ! /** ! * Shutdown - closes the sockets */ public static void Shutdown() { *************** *** 372,376 **** } ! // sleeps msec or until net socket is ready public static void Sleep(int msec) { if (ip_sockets[Defines.NS_SERVER] == null --- 362,366 ---- } ! /** Sleeps msec or until net socket is ready. */ public static void Sleep(int msec) { if (ip_sockets[Defines.NS_SERVER] == null *************** *** 387,401 **** // this should wait up to 100ms until a packet /* ! * struct timeval timeout; fd_set fdset; extern cvar_t *dedicated; * extern qboolean stdin_active; * * if (!ip_sockets[NS_SERVER] || (dedicated && !dedicated.value)) ! * return; // we're not a server, just run full speed * ! * FD_ZERO(&fdset); if (stdin_active) FD_SET(0, &fdset); // stdin is ! * processed too FD_SET(ip_sockets[NS_SERVER], &fdset); // network ! * socket timeout.tv_sec = msec/1000; timeout.tv_usec = ! * (msec%1000)*1000; select(ip_sockets[NS_SERVER]+1, &fdset, NULL, NULL, ! * &timeout); */ } --- 377,399 ---- // this should wait up to 100ms until a packet /* ! * struct timeval timeout; ! * fd_set fdset; ! * extern cvar_t *dedicated; * extern qboolean stdin_active; * * if (!ip_sockets[NS_SERVER] || (dedicated && !dedicated.value)) ! * return; // we're not a server, just run full speed * ! * FD_ZERO(&fdset); ! * ! * if (stdin_active) ! * FD_SET(0, &fdset); // stdin is processed too ! * ! * FD_SET(ip_sockets[NS_SERVER], &fdset); // network socket ! * ! * timeout.tv_sec = msec/1000; ! * timeout.tv_usec = (msec%1000)*1000; ! * ! * select(ip_sockets[NS_SERVER]+1, &fdset, NULL, NULL, &timeout); */ } |