[Tux4kids-commits] r1465 - in tuxmath/branches/lan: intl server src

David Bruce dbruce-guest at alioth.debian.org
Thu Aug 27 23:50:30 UTC 2009


Author: dbruce-guest
Date: 2009-08-27 23:50:30 +0000 (Thu, 27 Aug 2009)
New Revision: 1465

Modified:
   tuxmath/branches/lan/intl/plural.c
   tuxmath/branches/lan/server/server.c
   tuxmath/branches/lan/src/game.c
Log:
fixed question counter in non-lan game



Modified: tuxmath/branches/lan/intl/plural.c
===================================================================
--- tuxmath/branches/lan/intl/plural.c	2009-08-27 20:47:10 UTC (rev 1464)
+++ tuxmath/branches/lan/intl/plural.c	2009-08-27 23:50:30 UTC (rev 1465)
@@ -1,24 +1,23 @@
-/* A Bison parser, made by GNU Bison 2.3a.  */
 
+/* A Bison parser, made by GNU Bison 2.4.1.  */
+
 /* Skeleton implementation for Bison's Yacc-like parsers in C
-
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   
+      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify
+   
+   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+   
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-
+   
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* As a special exception, you may create a larger work that contains
    part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@
    special exception, which will cause the skeleton and the resulting
    Bison output files to be licensed under the GNU General Public
    License without this special exception.
-
+   
    This special exception was added by the Free Software Foundation in
    version 2.2 of Bison.  */
 
@@ -47,7 +46,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "2.3a"
+#define YYBISON_VERSION "2.4.1"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -55,23 +54,30 @@
 /* Pure parsers.  */
 #define YYPURE 1
 
+/* Push parsers.  */
+#define YYPUSH 0
+
+/* Pull parsers.  */
+#define YYPULL 1
+
 /* Using locations.  */
 #define YYLSP_NEEDED 0
 
 /* Substitute the variable and function names.  */
-#define yyparse __gettextparse
-#define yylex   __gettextlex
-#define yyerror __gettexterror
-#define yylval  __gettextlval
-#define yychar  __gettextchar
-#define yydebug __gettextdebug
-#define yynerrs __gettextnerrs
+#define yyparse         __gettextparse
+#define yylex           __gettextlex
+#define yyerror         __gettexterror
+#define yylval          __gettextlval
+#define yychar          __gettextchar
+#define yydebug         __gettextdebug
+#define yynerrs         __gettextnerrs
 
 
 /* Copy the first part of user declarations.  */
-/* Line 164 of yacc.c.  */
-#line 1 "plural.y"
 
+/* Line 189 of yacc.c  */
+#line 1 "../../intl/plural.y"
+
 /* Expression parsing for plural form selection.
    Copyright (C) 2000-2001, 2003, 2005-2006 Free Software Foundation, Inc.
    Written by Ulrich Drepper <drepper at cygnus.com>, 2000.
@@ -119,6 +125,9 @@
 #define YYPARSE_PARAM	arg
 
 
+/* Line 189 of yacc.c  */
+#line 130 "../../intl/plural.c"
+
 /* Enabling traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 0
@@ -163,28 +172,31 @@
 
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef union YYSTYPE
-{/* Line 191 of yacc.c.  */
-#line 51 "plural.y"
+{
 
+/* Line 214 of yacc.c  */
+#line 51 "../../intl/plural.y"
+
   unsigned long int num;
   enum expression_operator op;
   struct expression *exp;
-}
-/* Line 191 of yacc.c.  */
-#line 175 "plural.c"
-	YYSTYPE;
+
+
+
+/* Line 214 of yacc.c  */
+#line 188 "../../intl/plural.c"
+} YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
 #endif
 
 
+/* Copy the second part of user declarations.  */
 
+/* Line 264 of yacc.c  */
+#line 57 "../../intl/plural.y"
 
-/* Copy the second part of user declarations.  */
-/* Line 221 of yacc.c.  */
-#line 57 "plural.y"
-
 /* Prototypes for local functions.  */
 static int yylex (YYSTYPE *lval, const char **pexp);
 static void yyerror (const char *str);
@@ -260,9 +272,10 @@
 }
 
 
-/* Line 221 of yacc.c.  */
-#line 265 "plural.c"
 
+/* Line 264 of yacc.c  */
+#line 278 "../../intl/plural.c"
+
 #ifdef short
 # undef short
 #endif
@@ -424,9 +437,9 @@
 /* A type that is properly aligned for any stack member.  */
 union yyalloc
 {
-  yytype_int16 yyss;
-  YYSTYPE yyvs;
-  };
+  yytype_int16 yyss_alloc;
+  YYSTYPE yyvs_alloc;
+};
 
 /* The size of the maximum gap between one aligned stack and the next.  */
 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
@@ -460,12 +473,12 @@
    elements in the stack, and YYPTR gives the new location of the
    stack.  Advance YYPTR to a properly aligned location for the next
    stack.  */
-# define YYSTACK_RELOCATE(Stack)					\
+# define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
     do									\
       {									\
 	YYSIZE_T yynewbytes;						\
-	YYCOPY (&yyptr->Stack, Stack, yysize);				\
-	Stack = &yyptr->Stack;						\
+	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
+	Stack = &yyptr->Stack_alloc;					\
 	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
 	yyptr += yynewbytes / sizeof (*yyptr);				\
       }									\
@@ -883,11 +896,11 @@
   /* The symbols being reduced.  */
   for (yyi = 0; yyi < yynrhs; yyi++)
     {
-      fprintf (stderr, "   $%d = ", yyi + 1);
+      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
 		       &(yyvsp[(yyi + 1) - (yynrhs)])
 		       		       );
-      fprintf (stderr, "\n");
+      YYFPRINTF (stderr, "\n");
     }
 }
 
@@ -1167,10 +1180,8 @@
 	break;
     }
 }
-
 
 /* Prevent warnings from -Wmissing-prototypes.  */
-
 #ifdef YYPARSE_PARAM
 #if defined __STDC__ || defined __cplusplus
 int yyparse (void *YYPARSE_PARAM);
@@ -1189,11 +1200,10 @@
 
 
 
+/*-------------------------.
+| yyparse or yypush_parse.  |
+`-------------------------*/
 
-/*----------.
-| yyparse.  |
-`----------*/
-
 #ifdef YYPARSE_PARAM
 #if (defined __STDC__ || defined __C99__FUNC__ \
      || defined __cplusplus || defined _MSC_VER)
@@ -1216,22 +1226,46 @@
 #endif
 #endif
 {
-  /* The lookahead symbol.  */
+/* The lookahead symbol.  */
 int yychar;
 
 /* The semantic value of the lookahead symbol.  */
 YYSTYPE yylval;
 
-/* Number of syntax errors so far.  */
-int yynerrs;
+    /* Number of syntax errors so far.  */
+    int yynerrs;
 
-  int yystate;
+    int yystate;
+    /* Number of tokens to shift before error messages enabled.  */
+    int yyerrstatus;
+
+    /* The stacks and their tools:
+       `yyss': related to states.
+       `yyvs': related to semantic values.
+
+       Refer to the stacks thru separate pointers, to allow yyoverflow
+       to reallocate them elsewhere.  */
+
+    /* The state stack.  */
+    yytype_int16 yyssa[YYINITDEPTH];
+    yytype_int16 *yyss;
+    yytype_int16 *yyssp;
+
+    /* The semantic value stack.  */
+    YYSTYPE yyvsa[YYINITDEPTH];
+    YYSTYPE *yyvs;
+    YYSTYPE *yyvsp;
+
+    YYSIZE_T yystacksize;
+
   int yyn;
   int yyresult;
-  /* Number of tokens to shift before error messages enabled.  */
-  int yyerrstatus;
   /* Lookahead token as an internal (translated) token number.  */
-  int yytoken = 0;
+  int yytoken;
+  /* The variables used to return semantic value and location from the
+     action routines.  */
+  YYSTYPE yyval;
+
 #if YYERROR_VERBOSE
   /* Buffer for error messages, and its allocated size.  */
   char yymsgbuf[128];
@@ -1239,51 +1273,28 @@
   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
 #endif
 
-  /* Three stacks and their tools:
-     `yyss': related to states,
-     `yyvs': related to semantic values,
-     `yyls': related to locations.
-
-     Refer to the stacks thru separate pointers, to allow yyoverflow
-     to reallocate them elsewhere.  */
-
-  /* The state stack.  */
-  yytype_int16 yyssa[YYINITDEPTH];
-  yytype_int16 *yyss = yyssa;
-  yytype_int16 *yyssp;
-
-  /* The semantic value stack.  */
-  YYSTYPE yyvsa[YYINITDEPTH];
-  YYSTYPE *yyvs = yyvsa;
-  YYSTYPE *yyvsp;
-
-
-
 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
 
-  YYSIZE_T yystacksize = YYINITDEPTH;
-
-  /* The variables used to return semantic value and location from the
-     action routines.  */
-  YYSTYPE yyval;
-
-
   /* The number of symbols on the RHS of the reduced rule.
      Keep to zero when no symbol should be popped.  */
   int yylen = 0;
 
+  yytoken = 0;
+  yyss = yyssa;
+  yyvs = yyvsa;
+  yystacksize = YYINITDEPTH;
+
   YYDPRINTF ((stderr, "Starting parse\n"));
 
   yystate = 0;
   yyerrstatus = 0;
   yynerrs = 0;
-  yychar = YYEMPTY;		/* Cause a token to be read.  */
+  yychar = YYEMPTY; /* Cause a token to be read.  */
 
   /* Initialize stack pointers.
      Waste one element of value and location stack
      so that they stay on the same level as the state stack.
      The wasted elements are never initialized.  */
-
   yyssp = yyss;
   yyvsp = yyvs;
 
@@ -1313,7 +1324,6 @@
 	YYSTYPE *yyvs1 = yyvs;
 	yytype_int16 *yyss1 = yyss;
 
-
 	/* Each stack pointer address is followed by the size of the
 	   data in use in that stack, in bytes.  This used to be a
 	   conditional around just the two extra args, but that might
@@ -1321,7 +1331,6 @@
 	yyoverflow (YY_("memory exhausted"),
 		    &yyss1, yysize * sizeof (*yyssp),
 		    &yyvs1, yysize * sizeof (*yyvsp),
-
 		    &yystacksize);
 
 	yyss = yyss1;
@@ -1344,9 +1353,8 @@
 	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
 	if (! yyptr)
 	  goto yyexhaustedlab;
-	YYSTACK_RELOCATE (yyss);
-	YYSTACK_RELOCATE (yyvs);
-
+	YYSTACK_RELOCATE (yyss_alloc, yyss);
+	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
 #  undef YYSTACK_RELOCATE
 	if (yyss1 != yyssa)
 	  YYSTACK_FREE (yyss1);
@@ -1357,7 +1365,6 @@
       yyssp = yyss + yysize - 1;
       yyvsp = yyvs + yysize - 1;
 
-
       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
 		  (unsigned long int) yystacksize));
 
@@ -1468,8 +1475,9 @@
   switch (yyn)
     {
         case 2:
-/* Line 1269 of yacc.c.  */
-#line 155 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 155 "../../intl/plural.y"
     {
 	    if ((yyvsp[(1) - (1)].exp) == NULL)
 	      YYABORT;
@@ -1478,80 +1486,90 @@
     break;
 
   case 3:
-/* Line 1269 of yacc.c.  */
-#line 163 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 163 "../../intl/plural.y"
     {
 	    (yyval.exp) = new_exp_3 (qmop, (yyvsp[(1) - (5)].exp), (yyvsp[(3) - (5)].exp), (yyvsp[(5) - (5)].exp));
 	  }
     break;
 
   case 4:
-/* Line 1269 of yacc.c.  */
-#line 167 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 167 "../../intl/plural.y"
     {
 	    (yyval.exp) = new_exp_2 (lor, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
 	  }
     break;
 
   case 5:
-/* Line 1269 of yacc.c.  */
-#line 171 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 171 "../../intl/plural.y"
     {
 	    (yyval.exp) = new_exp_2 (land, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
 	  }
     break;
 
   case 6:
-/* Line 1269 of yacc.c.  */
-#line 175 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 175 "../../intl/plural.y"
     {
 	    (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
 	  }
     break;
 
   case 7:
-/* Line 1269 of yacc.c.  */
-#line 179 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 179 "../../intl/plural.y"
     {
 	    (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
 	  }
     break;
 
   case 8:
-/* Line 1269 of yacc.c.  */
-#line 183 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 183 "../../intl/plural.y"
     {
 	    (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
 	  }
     break;
 
   case 9:
-/* Line 1269 of yacc.c.  */
-#line 187 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 187 "../../intl/plural.y"
     {
 	    (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
 	  }
     break;
 
   case 10:
-/* Line 1269 of yacc.c.  */
-#line 191 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 191 "../../intl/plural.y"
     {
 	    (yyval.exp) = new_exp_1 (lnot, (yyvsp[(2) - (2)].exp));
 	  }
     break;
 
   case 11:
-/* Line 1269 of yacc.c.  */
-#line 195 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 195 "../../intl/plural.y"
     {
 	    (yyval.exp) = new_exp_0 (var);
 	  }
     break;
 
   case 12:
-/* Line 1269 of yacc.c.  */
-#line 199 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 199 "../../intl/plural.y"
     {
 	    if (((yyval.exp) = new_exp_0 (num)) != NULL)
 	      (yyval.exp)->val.num = (yyvsp[(1) - (1)].num);
@@ -1559,16 +1577,18 @@
     break;
 
   case 13:
-/* Line 1269 of yacc.c.  */
-#line 204 "plural.y"
+
+/* Line 1455 of yacc.c  */
+#line 204 "../../intl/plural.y"
     {
 	    (yyval.exp) = (yyvsp[(2) - (3)].exp);
 	  }
     break;
 
 
-/* Line 1269 of yacc.c.  */
-#line 1572 "plural.c"
+
+/* Line 1455 of yacc.c  */
+#line 1592 "../../intl/plural.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1579,7 +1599,6 @@
 
   *++yyvsp = yyval;
 
-
   /* Now `shift' the result of the reduction.  Determine what state
      that goes to, based on the state we popped back to and the rule
      number reduced by.  */
@@ -1742,7 +1761,7 @@
   yyresult = 1;
   goto yyreturn;
 
-#ifndef yyoverflow
+#if !defined(yyoverflow) || YYERROR_VERBOSE
 /*-------------------------------------------------.
 | yyexhaustedlab -- memory exhaustion comes here.  |
 `-------------------------------------------------*/
@@ -1779,10 +1798,11 @@
 }
 
 
-/* Line 1486 of yacc.c.  */
-#line 209 "plural.y"
 
+/* Line 1675 of yacc.c  */
+#line 209 "../../intl/plural.y"
 
+
 void
 internal_function
 FREE_EXPRESSION (struct expression *exp)

Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c	2009-08-27 20:47:10 UTC (rev 1464)
+++ tuxmath/branches/lan/server/server.c	2009-08-27 23:50:30 UTC (rev 1465)
@@ -23,7 +23,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h> 
- 
+#include <sys/types.h>  
+#include <unistd.h>
+
 #include "server.h" 
 #include "../src/transtruct.h"
 #include "../src/mathcards.h"

Modified: tuxmath/branches/lan/src/game.c
===================================================================
--- tuxmath/branches/lan/src/game.c	2009-08-27 20:47:10 UTC (rev 1464)
+++ tuxmath/branches/lan/src/game.c	2009-08-27 23:50:30 UTC (rev 1465)
@@ -235,11 +235,9 @@
 //  Uint32 last_time, now_time;
   char buf[NET_BUF_LEN];
   char command[NET_BUF_LEN];
-#define TUXMATH_DEBUG
-#ifdef TUXMATH_DEBUG
-  fprintf(stderr, "Entering game():\n");
-#endif
 
+  tmdprintf("Entering game():\n");
+
   //see if the option matches the actual screen
   if (Opts_GetGlobalOpt(FULLSCREEN) == !(screen->flags & SDL_FULLSCREEN) )
   {
@@ -264,12 +262,6 @@
     return GAME_OVER_OTHER;
   }
  
-  /* Start out with our "comets" empty: */
-  {
-    int i;
-    for(i = 0; i < TEST_COMETS; i ++)
-      erase_flashcard(&(comets_questions[i]));
-  }
 
 
   /* --- MAIN GAME LOOP: --- */
@@ -539,7 +531,7 @@
 int add_quest_recvd(char* buf)
 {
   MC_FlashCard* fc = find_comet_by_id(-1);
-
+  // if fc = NULL means no empty slot for question
   if(!fc || !buf)
   {
     printf("NULL fc or buf\n");
@@ -555,6 +547,7 @@
   return 1;
 }
 
+
 int remove_quest_recvd(char* buf)
 {
   int id = 0;
@@ -569,7 +562,7 @@
     return 0;
 
   id = atoi(p);
-  if(id == 0)  // The question_id can never be zero, and will falsely match empty comets
+  if(id < 1)  // The question_id can never be negative or zero
     return 0;
 
   fc = find_comet_by_id(id);
@@ -582,6 +575,7 @@
   return 1;
 }
 
+
 /* Print the current questions and the number of remaining questions: */
 void print_current_quests(void)
 {
@@ -674,9 +668,9 @@
 
   else if(strncmp(command,"TOTAL_QUESTIONS",strlen("TOTAL_QUESTIONS"))==0)
   {
-    sscanf(buf,"%*s %d",&total_questions_left);
+    sscanf(buf,"%*s %d", &total_questions_left);
     if(!total_questions_left)
-    game_over_other=1;
+      game_over_other=1;
   }
 
   else if(strncmp(command,"GAME_OVER_WON",strlen("GAME_OVER_WON"))==0)
@@ -687,6 +681,8 @@
      with a warning until they get implemented - DSB             */
 }
 
+
+
 /* 
 Set one to four lines of text to display at the game's start. Eventually
 this should stylishly fade out over the first few moments of the game.
@@ -733,7 +729,7 @@
 
   if(!Opts_LanMode())
   {
-    printf("Calling MC_StartGame()\n");
+    tmdprintf("Calling MC_StartGame()\n");
     if (!MC_StartGame())
     {
       fprintf(stderr, "\nMC_StartGame() failed!");
@@ -741,43 +737,55 @@
     }
   }
 
+  /* Start out with our "comets" empty: */
+  {
+    int i;
+    for(i = 0; i < TEST_COMETS; i ++)
+      erase_flashcard(&(comets_questions[i]));
+  }
+
   /* Allocate memory */
   comets = NULL;  // set in case allocation fails partway through
   cities = NULL;
   penguins = NULL;
   steam = NULL;
   comets = (comet_type *) malloc(MAX_MAX_COMETS * sizeof(comet_type));
-  if (comets == NULL) {
+  if (comets == NULL)
+  {
     printf("Allocation of comets failed");
     return 0;
   }
-  else {
+  else 
+  {
     for (i = 0; i < MAX_MAX_COMETS; ++i)
-      {
+    {
       comets[i].flashcard = MC_AllocateFlashcard();
       if (!MC_FlashCardGood(&comets[i].flashcard) ) 
-        {
+      {
         //something's wrong
         printf("Allocation of flashcard %d failed\n", i);
         for (; i >= 0; --i) //free anything we've already gotten
           MC_FreeFlashcard(&comets[i].flashcard);
         return 0;
-        }
       }
+    }
   }
   
   cities = (city_type *) malloc(NUM_CITIES * sizeof(city_type));
-  if (cities == NULL) {
+  if (cities == NULL)
+  {
     printf("Allocation of cities failed");
     return 0;
   }
   penguins = (penguin_type *) malloc(NUM_CITIES * sizeof(penguin_type));
-  if (penguins == NULL) {
+  if (penguins == NULL)
+  {
     printf("Allocation of penguins failed");
     return 0;
   }
   steam = (steam_type *) malloc(NUM_CITIES * sizeof(steam_type));
-  if (steam == NULL) {
+  if (steam == NULL)
+  {
     printf("Allocation of steam failed");
     return 0;
   }
@@ -804,6 +812,7 @@
   slowdown = 0;
   score = 0;
   demo_countdown = 2000;
+  total_questions_left = 0;
   level_start_wait = LEVEL_START_WAIT_START;
   neg_answer_picked = 0;
 
@@ -842,7 +851,8 @@
   igloo_vertical_offset = images[IMG_CITY_BLUE]->h - images[IMG_IGLOO_INTACT]->h;
 
   /* Create and position the penguins and steam */
-  for (i = 0; i < NUM_CITIES; i++) {
+  for (i = 0; i < NUM_CITIES; i++)
+  {
     penguins[i].status = PENGUIN_HAPPY;
     penguins[i].counter = 0;
     penguins[i].x = cities[i].x;
@@ -852,7 +862,8 @@
     steam[i].counter = 0;
   }
 
-  if (Opts_BonusCometInterval()) {
+  if (Opts_BonusCometInterval())
+  {
     bonus_comet_counter = Opts_BonusCometInterval() + 1;
     tmdprintf("\nInitializing with bonus_comet_counter = %d\n",bonus_comet_counter);
   }
@@ -900,7 +911,6 @@
 #ifdef HAVE_LIBSDL_NET  
   LAN_Cleanup();
 #endif
-  
 
   /* Free background: */
   if (bkgd != NULL)
@@ -931,13 +941,10 @@
   }
 #endif
 
+  tmdprintf("Leaving game():\n");
+}
 
-#ifdef TUXMATH_DEBUG
-  fprintf(stderr, "Leaving game():\n");
-#endif
 
-}
-
 void game_handle_help(void)
 {
   const int left_edge = 140;
@@ -1054,39 +1061,51 @@
 
   help_add_comet("56 / 8 = ?", "7");
   comets[0].y = 2*(screen->h)/3;   // start it low down
+
   while (comets[0].alive && !(quit_help = help_renderframe_exit()));
+
   if (quit_help)
     return;
   frame_start = frame;
+
   while ((frame-frame_start < 3*FPS) && !(quit_help = help_renderframe_exit()));
+
   if (quit_help)
     return;
 
   help_controls.laser_enabled = 1;
-  game_set_message(&s1,_("You can fix the igloos"),left_edge,100);
-  game_set_message(&s2,_("by stopping bonus comets."),left_edge,135);
+  game_set_message(&s1,_("You can fix the igloos"), left_edge,100);
+  game_set_message(&s2,_("by stopping bonus comets."), left_edge,135);
   help_add_comet("2 + 2 = ?", "4");
   comets[0].bonus = 1;
   frame_start = frame;
+
   while (comets[0].alive && (frame-frame_start < 50) && !(quit_help = help_renderframe_exit()));
+
   if (quit_help)
     return;
   if (comets[0].alive)
     speed = 0;
   game_set_message(&s3,_("Zap it now!"),left_edge,225);
+
   while (comets[0].alive && !(quit_help = help_renderframe_exit()));
+
   if (quit_help)
     return;
   game_set_message(&s1,_("Great job!"),left_edge,100);
   game_clear_message(&s2);
   game_clear_message(&s3);
   frame_start = frame;
+
   while ((frame-frame_start < 2*FPS) && !(quit_help = help_renderframe_exit()));
+
   if (quit_help)
     return;
   check_extra_life();
   frame_start = frame;
+
   while ((frame-frame_start < 10*FPS) && !(quit_help = help_renderframe_exit()));
+
   if (quit_help)
     return;
 
@@ -1097,6 +1116,7 @@
   game_set_message(&s4,_("Do it now, and then play!"),left_edge,225);
 
   help_controls.x_is_blinking = 1;
+
   while (!help_renderframe_exit());
 }
 
@@ -1184,10 +1204,11 @@
 
 void game_write_message(const game_message *msg)
 {
-  SDL_Surface *surf;
+  SDL_Surface* surf;
   SDL_Rect rect;
 
-  if (strlen(msg->message) > 0) {
+  if (strlen(msg->message) > 0)
+  {
     surf = BlackOutline( _(msg->message), DEFAULT_HELP_FONT_SIZE, &white);
     rect.w = surf->w;
     rect.h = surf->h;
@@ -3295,7 +3316,11 @@
   SDL_BlitSurface(images[comet_img], NULL, screen, &dest);
 
   /* draw number of remaining questions: */
-  questions_left = total_questions_left;
+  if(Opts_LanMode())
+    questions_left = total_questions_left;
+  else
+    questions_left = MC_TotalQuestionsLeft();
+
   sprintf(str, "%.4d", questions_left);
   draw_numbers(str, nums_x, 0);
 }




More information about the Tux4kids-commits mailing list