ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/loop.C
(Generate patch)

Comparing deliantra/server/socket/loop.C (file contents):
Revision 1.12 by root, Thu Dec 14 01:12:35 2006 UTC vs.
Revision 1.13 by root, Thu Dec 14 02:37:37 2006 UTC

65 * before player joins, and those happen after the player has joined. 65 * before player joins, and those happen after the player has joined.
66 * As such, we have function types that might be called, so 66 * As such, we have function types that might be called, so
67 * we end up having 2 tables. 67 * we end up having 2 tables.
68 */ 68 */
69 69
70typedef void (*func_uint8_int_ns) (char *, int, NewSocket *); 70typedef void (*func_uint8_int_ns) (char *, int, client_socket *);
71 71
72struct NsCmdMapping 72struct NsCmdMapping
73{ 73{
74 const char *cmdname; 74 const char *cmdname;
75 func_uint8_int_ns cmdproc; 75 func_uint8_int_ns cmdproc;
132 * RequestInfo is sort of a meta command. There is some specific 132 * RequestInfo is sort of a meta command. There is some specific
133 * request of information, but we call other functions to provide 133 * request of information, but we call other functions to provide
134 * that information. 134 * that information.
135 */ 135 */
136void 136void
137RequestInfo (char *buf, int len, NewSocket * ns) 137RequestInfo (char *buf, int len, client_socket * ns)
138{ 138{
139 char *params = NULL, *cp; 139 char *params = NULL, *cp;
140 140
141 /* No match */ 141 /* No match */
142 char bigbuf[MAX_BUF]; 142 char bigbuf[MAX_BUF];
181 * with this socket, null if no player (one of the init_sockets for just 181 * with this socket, null if no player (one of the init_sockets for just
182 * starting a connection) 182 * starting a connection)
183 */ 183 */
184 184
185void 185void
186HandleClient (NewSocket *ns, player *pl) 186HandleClient (client_socket *ns, player *pl)
187{ 187{
188 /* Loop through this - maybe we have several complete packets here. */ 188 /* Loop through this - maybe we have several complete packets here. */
189 // limit to a few commands only, though, as to not monopolise the server 189 // limit to a few commands only, though, as to not monopolise the server
190 for (int repeat = 16; repeat--;) 190 for (int repeat = 16; repeat--;)
191 { 191 {
424 LOG (llevDebug, "doeric_server: New Connection\n"); 424 LOG (llevDebug, "doeric_server: New Connection\n");
425#endif 425#endif
426 /* If this is the case, all sockets currently in used */ 426 /* If this is the case, all sockets currently in used */
427 if (socket_info.allocated_sockets <= socket_info.nconns) 427 if (socket_info.allocated_sockets <= socket_info.nconns)
428 { 428 {
429 init_sockets = (NewSocket *) realloc (init_sockets, sizeof (NewSocket) * (socket_info.nconns + 1)); 429 init_sockets = (client_socket *) realloc (init_sockets, sizeof (client_socket) * (socket_info.nconns + 1));
430 if (!init_sockets) 430 if (!init_sockets)
431 fatal (OUT_OF_MEMORY); 431 fatal (OUT_OF_MEMORY);
432 newsocknum = socket_info.allocated_sockets; 432 newsocknum = socket_info.allocated_sockets;
433 socket_info.allocated_sockets++; 433 socket_info.allocated_sockets++;
434 init_sockets[newsocknum].faces_sent_len = nrofpixmaps; 434 init_sockets[newsocknum].faces_sent_len = nrofpixmaps;
455 LOG (llevError, "accept failed: %s\n", strerror (errno)); 455 LOG (llevError, "accept failed: %s\n", strerror (errno));
456 else 456 else
457 { 457 {
458 char buf[MAX_BUF]; 458 char buf[MAX_BUF];
459 long ip; 459 long ip;
460 NewSocket *ns; 460 client_socket *ns;
461 461
462 ns = &init_sockets[newsocknum]; 462 ns = &init_sockets[newsocknum];
463 463
464 ip = ntohl (addr.sin_addr.s_addr); 464 ip = ntohl (addr.sin_addr.s_addr);
465 sprintf (buf, "%ld.%ld.%ld.%ld", (ip >> 24) & 255, (ip >> 16) & 255, (ip >> 8) & 255, ip & 255); 465 sprintf (buf, "%ld.%ld.%ld.%ld", (ip >> 24) & 255, (ip >> 16) & 255, (ip >> 8) & 255, ip & 255);
470 close (init_sockets[newsocknum].fd); 470 close (init_sockets[newsocknum].fd);
471 init_sockets[newsocknum].fd = -1; 471 init_sockets[newsocknum].fd = -1;
472 } 472 }
473 else 473 else
474 { 474 {
475 InitConnection (ns, buf); 475 ns->init (buf);
476 socket_info.nconns++; 476 socket_info.nconns++;
477 } 477 }
478 } 478 }
479 } 479 }
480 480

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines