summaryrefslogtreecommitdiff
path: root/src/server.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-23 21:38:56 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-23 21:38:56 +0000
commitaec5ba5ca31f3d7c895beb658a93c353b2b8d5c1 (patch)
tree068d2a3ad5e5bf290acf2d73b87e170bc9962069 /src/server.c
parent20ecf36f401adad01cc5ff67e411c596a8b523d5 (diff)
- 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 <code>" ) nespravny pikaz, veriza, timeout git-svn-id: http://opensvn.csie.org/tuxanci_ng@33 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/server.c')
-rw-r--r--src/server.c40
1 files changed, 30 insertions, 10 deletions
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;
}