From aec5ba5ca31f3d7c895beb658a93c353b2b8d5c1 Mon Sep 17 00:00:00 2001 From: oroborus Date: Sun, 23 Mar 2008 21:38:56 +0000 Subject: - zobratie zbrani/bonusov prebieha na server, a server tuto informaciu posiela clientom - server checkuje, ci ma client spravnu verziu - clientovy, ktory sa neprihlasil do hry prikazom hello, neposiela stavy aku su end, alebo deltux - oprava malej chyby v textfiled - posladna aktivita serveru/clienta zistuje druha strana na zaklade kazdeho prijateho packetu, nie iba podla packetu ping - server posile clientovy pakcety "error " ) nespravny pikaz, veriza, timeout git-svn-id: http://opensvn.csie.org/tuxanci_ng@33 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/server.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'src/server.c') diff --git a/src/server.c b/src/server.c index 98fc96c..1df2338 100644 --- a/src/server.c +++ b/src/server.c @@ -261,7 +261,7 @@ void sendAllClientBut(char *msg, client_t *p) { thisClient = (client_t *) listClient->list[i]; - if( thisClient != p ) + if( thisClient->tux != NULL && thisClient != p ) { sendClient(thisClient, msg); } @@ -390,22 +390,42 @@ static void eventClientBuffer(client_t *client) while( getBufferLine(client->buffer, line, STR_PROTO_SIZE) >= 0 ) { #ifdef DEBUG_SERVER_RECV - printf("recv client msg->%s", line); + printf("recv client msg->%s", line); #endif - if( strncmp(line, "hello", 5) == 0 )proto_recv_hello_server(client, line); +#if defined SUPPORT_NET_UNIX_UDP || defined SUPPORT_NET_SDL_UDP + client->lastPing = getMyTime(); +#endif + if( strncmp(line, "hello", 5) == 0 ) + { + proto_recv_hello_server(client, line); + continue; + } + if( strncmp(line, "status", 6) == 0 )proto_recv_status_server(client, line); if( client->tux != NULL ) { - if( strncmp(line, "event", 5) == 0 )proto_recv_event_server(client, line); - if( strncmp(line, "ping", 4) == 0 )proto_recv_ping_server(client, line); - if( strncmp(line, "end", 3) == 0 )proto_recv_end_server(client, line); + if( strncmp(line, "event", 5) == 0 ) + { + proto_recv_event_server(client, line); + continue; + } + + if( strncmp(line, "ping", 4) == 0 ) + { + proto_recv_ping_server(client, line); + continue; + } + + if( strncmp(line, "end", 3) == 0 ) + { + proto_recv_end_server(client, line); + continue; + } } -#if defined SUPPORT_NET_UNIX_UDP || defined SUPPORT_NET_SDL_UDP - client->lastPing = getMyTime(); -#endif + proto_send_error_server(PROTO_SEND_ONE, client, PROTO_ERROR_CODE_BAD_COMMAND); } } @@ -496,7 +516,7 @@ static void delZombieCLient() if( currentTime - thisClient->lastPing > SERVER_TIMEOUT ) { - printf("client ping timeout\n"); + proto_send_error_server(PROTO_SEND_ONE, thisClient, PROTO_ERROR_CODE_TIMEOUT); thisClient->status = NET_STATUS_ZOMBIE; } -- cgit v1.2.3