[Tux4kids-commits] r1139 - tuxmath/branches/lan/server
akash gangil
gangil-guest at alioth.debian.org
Fri Jul 3 23:24:04 UTC 2009
Author: gangil-guest
Date: 2009-07-03 23:24:04 +0000 (Fri, 03 Jul 2009)
New Revision: 1139
Modified:
tuxmath/branches/lan/server/server.c
Log:
server doesnt shuts down , and clients can play again
Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c 2009-07-03 17:40:58 UTC (rev 1138)
+++ tuxmath/branches/lan/server/server.c 2009-07-03 23:24:04 UTC (rev 1139)
@@ -85,8 +85,8 @@
frame++;
/* See if our existing clients are really still there. For */
/* performance reasons, we don't do this on every loop: */
- if(frame%1000 == 0)
- test_connections();
+// if(frame%1000 == 0)
+// test_connections();
/* Now we check to see if anyone is trying to connect. */
update_clients();
@@ -185,7 +185,7 @@
server_sock = NULL;
}
- SDLNet_Quit();
+
/* Clean up mathcards heap memory */
MC_EndGame();
@@ -320,11 +320,35 @@
int check_messages(void)
{
- int i = 0;
+ int i = 0,c=0;
int actives = 0;
int ready_found = 0;
char buffer[NET_BUF_LEN];
+
+
+ if(game_in_progress==1)
+ {
+ for(i=0;i<MAX_CLIENTS;i++)
+ {
+ if(client[i].sock!=NULL)
+ {
+ c=1;
+ break;
+ }
+ }
+ if(c==0)
+ {
+ printf("All the clients have been disconnected....\n");
+ cleanup_server();
+ setup_server();
+ game_in_progress=0;
+ return 0;
+ }
+ }
+
+
+
/* Check the client socket set for activity: */
actives = SDLNet_CheckSockets(client_set, 0);
// printf("in check_messages(), actives = %d\n", actives);
More information about the Tux4kids-commits
mailing list