[Tux4kids-commits] r1211 - tuxmath/branches/lan/src

akash gangil gangil-guest at alioth.debian.org
Wed Jul 15 10:56:19 UTC 2009


Author: gangil-guest
Date: 2009-07-15 10:56:17 +0000 (Wed, 15 Jul 2009)
New Revision: 1211

Modified:
   tuxmath/branches/lan/src/game.c
   tuxmath/branches/lan/src/network.c
   tuxmath/branches/lan/src/network.h
   tuxmath/branches/lan/src/titlescreen.c
Log:
total_questions_left  in game.c taken care of

Modified: tuxmath/branches/lan/src/game.c
===================================================================
--- tuxmath/branches/lan/src/game.c	2009-07-15 03:44:28 UTC (rev 1210)
+++ tuxmath/branches/lan/src/game.c	2009-07-15 10:56:17 UTC (rev 1211)
@@ -17,7 +17,7 @@
   Revised by David Bruce, Tim Holy and others
   2005-2007
 */
-#define DEFAULT_PORT 4779
+
 #define TUXMATH_DEBUG
 /* put this first so we get <config.h> and <gettext.h> immediately: */
 #include "tuxmath.h"
@@ -83,6 +83,7 @@
 static int gameover_counter;
 static int game_status;
 static int user_quit_received;
+static int total_questions_left;
 static int paused;
 static int wave;
 static int score;
@@ -553,8 +554,10 @@
     }   
   }
 
-  else if(strncmp(command,"GAME_OVER_OTHER",strlen("GAME_OVER_OTHER"))==0)
+  else if(strncmp(command,"TOTAL_QUESTIONS",strlen("TOTAL_QUESTIONS"))==0)
   {
+    sscanf(buf,"%*s %d",&total_questions_left);
+   if(!total_questions_left)
     game_over_other=1;
   }
 
@@ -986,7 +989,7 @@
   game_handle_user_events();
   game_handle_answer();
   game_handle_tux();
-  game_handle_comets(NULL,NULL);
+  game_handle_comets();
   game_handle_cities();
   game_handle_penguins();
   game_handle_steam();
@@ -2682,7 +2685,7 @@
 //      /* no more questions available - cannot create comet.  */
 //      return 0;
 //     }
-
+   LAN_NextQuestion(); // Let it be for now until we think of something else
    /* FIXME what we really need here is the capability within network.c to queue  */
    /* any questions that have been received from the server in check_messages(),  */
    /* and a function that gives us the next question in the local queue if there  */
@@ -3119,7 +3122,7 @@
   SDL_BlitSurface(images[comet_img], NULL, screen, &dest);
 
   /* draw number of remaining questions: */
-  questions_left = MC_TotalQuestionsLeft();
+  questions_left = total_questions_left;
   sprintf(str, "%.4d", questions_left);
   draw_numbers(str, nums_x, 0);
 }

Modified: tuxmath/branches/lan/src/network.c
===================================================================
--- tuxmath/branches/lan/src/network.c	2009-07-15 03:44:28 UTC (rev 1210)
+++ tuxmath/branches/lan/src/network.c	2009-07-15 10:56:17 UTC (rev 1211)
@@ -139,23 +139,14 @@
 
 
 
-int say_to_server(char* statement)
+int LAN_NextQuestion(void)
 {
-  char buffer[NET_BUF_LEN];
+  char buf[NET_BUF_LEN];
 
-  if(!statement)
-    return 0;
-
-  snprintf(buffer, NET_BUF_LEN, 
+  snprintf(buf, NET_BUF_LEN, 
                   "%s\n",
-                  statement);
-  if (SDLNet_TCP_Send(sd, (void *)buffer, NET_BUF_LEN) < NET_BUF_LEN)
-  {
-    fprintf(stderr, "SDLNet_TCP_Send: %s\n", SDLNet_GetError());
-    return 0;
-  }
-
-  return 1;
+                  "NEXT_QUESTION");
+  return say_to_server(buf);
 }
 
 
@@ -351,41 +342,25 @@
   return 1;
 }
 
+/*private to network.c functions*/
 
-
-
-/*This mainly is a network version of all the MathCards Functions
-  MC_* that have integer as their return value*/
-/* Looks to me like it just sends "statement".  Again, when we send a  */
-/* message, we can't assume when we are going to get a reply.          */
-int evaluate(char statement[20])
+int say_to_server(char* statement)
 {
-  int ans,x;
-  char command[NET_BUF_LEN];
-  int len;
   char buffer[NET_BUF_LEN];
-  char buf[NET_BUF_LEN];
 
-   snprintf(buffer, NET_BUF_LEN, 
+  if(!statement)
+    return 0;
+
+  snprintf(buffer, NET_BUF_LEN, 
                   "%s\n",
                   statement);
-   len = strlen(buffer) + 1;
-   if (SDLNet_TCP_Send(sd, (void *)buffer, NET_BUF_LEN) < NET_BUF_LEN)
-   {
-     fprintf(stderr, "SDLNet_TCP_Send: %s\n", SDLNet_GetError());
-     exit(EXIT_FAILURE);
-   }
-  
-//   x = SDLNet_TCP_Recv(sd, buf, NET_BUF_LEN);
-//  if( x <= 0)
-//  {
-//    fprintf(stderr, "In play_game(), SDLNet_TCP_Recv() failed!\n");
-//    exit(EXIT_FAILURE);
-//  }
-//  player_msg_recvd(buf,command);
-//  ans=atoi(command);
+  if (SDLNet_TCP_Send(sd, (void *)buffer, NET_BUF_LEN) < NET_BUF_LEN)
+  {
+    fprintf(stderr, "SDLNet_TCP_Send: %s\n", SDLNet_GetError());
+    return 0;
+  }
 
-  return 0;
+  return 1;
 }
 
 
@@ -393,3 +368,4 @@
 
 
 
+

Modified: tuxmath/branches/lan/src/network.h
===================================================================
--- tuxmath/branches/lan/src/network.h	2009-07-15 03:44:28 UTC (rev 1210)
+++ tuxmath/branches/lan/src/network.h	2009-07-15 10:56:17 UTC (rev 1211)
@@ -28,6 +28,7 @@
 /* Network replacement functions for mathcards "API": */
 /* These functions are how the client tells things to the server: */
 int LAN_StartGame(void);
+int LAN_NextQuestion(void);
 int LAN_AnsweredCorrectly(MC_FlashCard* fc);
 int LAN_NotAnsweredCorrectly(MC_FlashCard* fc);
 /* This is how the client receives messages from the server: */

Modified: tuxmath/branches/lan/src/titlescreen.c
===================================================================
--- tuxmath/branches/lan/src/titlescreen.c	2009-07-15 03:44:28 UTC (rev 1210)
+++ tuxmath/branches/lan/src/titlescreen.c	2009-07-15 10:56:17 UTC (rev 1211)
@@ -886,12 +886,10 @@
     if(mode == 1)
    { NameEntry(host, _("Enter the name"),
                        _("(of the Host)"));
-    NameEntry(port, _("Enter the port number"),
+    NameEntry(port, _("Enter you name"),
                        _(""));
     
 
-   // lan_client_set_parameter(HOST, host);
-   // lan_client_set_parameter(PORT, port);
    //  if((lan_client_connect(host,port))==0)
    b=Standby(_("No Host...=("),_("Press Esc to go back"),host,port);
    if(b==7)




More information about the Tux4kids-commits mailing list