[Tux4kids-commits] r1164 - tuxmath/branches/lan/server

akash gangil gangil-guest at alioth.debian.org
Wed Jul 8 22:58:00 UTC 2009


Author: gangil-guest
Date: 2009-07-08 22:58:00 +0000 (Wed, 08 Jul 2009)
New Revision: 1164

Modified:
   tuxmath/branches/lan/server/server.c
   tuxmath/branches/lan/server/server.h
Log:
Modifying server according to the main game

Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c	2009-07-08 22:56:51 UTC (rev 1163)
+++ tuxmath/branches/lan/server/server.c	2009-07-08 22:58:00 UTC (rev 1164)
@@ -52,6 +52,8 @@
 int player_msg(int i, char* msg);
 void broadcast_msg(char* msg);
 void throttle(int loop_msec);
+void game_msg_next_question(void);
+void game_msg_total_questions_left(int i);
 
 /* "Local globals" for server.c:   */
 TCPsocket server_sock = NULL; /* Socket descriptor for server            */
@@ -447,11 +449,29 @@
                   command,
                   &id);
 
+
+
   if(strncmp(command, "CORRECT_ANSWER", 14) == 0)
   {
     game_msg_correct_answer(i,id);
   }                            
 
+  else if(strncmp(command, "TOTAL_QUESTIONS_LEFT",strlen("TOTAL_QUESTIONS_LEFT")) == 0) /* Send Total Questions left */
+  {
+    game_msg_total_questions_left(i);
+  }
+
+
+  else if(strncmp(command, "MISSION_ACCOMPLISHED",strlen("MISSION_ACCOMPLISHED")) == 0) /* Send Total Questions left */
+  {
+    game_msg_mission_accomplished(i);
+  }
+
+  else if(strncmp(command, "NEXT_QUESTION",strlen("NEXT_QUESTION")) == 0) /* Send Next Question */
+  {
+    game_msg_next_question();
+  }
+
   else if(strncmp(command, "exit",4) == 0) /* Terminate this connection */
   {
     game_msg_exit(i);
@@ -470,6 +490,26 @@
 }
 
 
+void game_msg_total_questions_left(int i)
+{
+ int x;
+ char *ch;
+ x=MC_TotalQuestionsLeft();
+ ch=(char*)x;
+ player_msg(i,ch);
+}
+
+void game_msg_mission_accomplished(int i)
+{
+  int x;
+  char *ch;
+
+  x=MC_MissionAccomplished();
+  ch=(char*)x;
+  player_msg(i,ch);
+ 
+}
+
 void game_msg_correct_answer(int i,int id)
 {
   int n;
@@ -485,6 +525,12 @@
   //Tell mathcards so lists get updated:
   MC_AnsweredCorrectly_id(id);
 
+}
+
+void game_msg_next_question(void)
+{
+
+  int n;
   if (!MC_NextQuestion(&flash))
   { 
     /* no more questions available */
@@ -512,10 +558,8 @@
       printf("Unable to send Question\n");
     }
   } 
-
 }
 
-
 // Go through and test all the current connections, removing
 // any clients that fail to respond:
 void test_connections(void)

Modified: tuxmath/branches/lan/server/server.h
===================================================================
--- tuxmath/branches/lan/server/server.h	2009-07-08 22:56:51 UTC (rev 1163)
+++ tuxmath/branches/lan/server/server.h	2009-07-08 22:58:00 UTC (rev 1164)
@@ -30,7 +30,10 @@
 enum {
   EXIT,
   QUIT,
-  CORRECT_ANSWER
+  CORRECT_ANSWER,
+  NEXT_QUESTION,
+  TOTAL_QUESTIONS_LEFT,
+  MISSION_ACCOMPLISHED,
 };
 
 




More information about the Tux4kids-commits mailing list