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

David Bruce dbruce-guest at alioth.debian.org
Wed Aug 5 14:11:27 UTC 2009


Author: dbruce-guest
Date: 2009-08-05 14:11:27 +0000 (Wed, 05 Aug 2009)
New Revision: 1367

Modified:
   tuxmath/branches/lan/server/server.c
   tuxmath/branches/lan/src/mathcards.c
   tuxmath/branches/lan/src/mathcards.h
Log:
rearranged MC_NotAnsweredCorrectly to fix (or at least avoid) bug with question reinsertion

Modified: tuxmath/branches/lan/server/server.c
===================================================================
--- tuxmath/branches/lan/server/server.c	2009-08-05 12:02:13 UTC (rev 1366)
+++ tuxmath/branches/lan/server/server.c	2009-08-05 14:11:27 UTC (rev 1367)
@@ -625,11 +625,6 @@
     client[i].game_ready = 1;
     //This will call start_game() if all the other clients are ready:
     check_game_clients();
-//    snprintf(buf, NET_BUF_LEN, 
-//                  "%s",
-//                  "Success");
-//    x = SDLNet_TCP_Send(client[i].sock, buf, NET_BUF_LEN);
-        
   }
   else if(strncmp(buffer, "SET_NAME", strlen("SET_NAME")) == 0)
   {

Modified: tuxmath/branches/lan/src/mathcards.c
===================================================================
--- tuxmath/branches/lan/src/mathcards.c	2009-08-05 12:02:13 UTC (rev 1366)
+++ tuxmath/branches/lan/src/mathcards.c	2009-08-05 14:11:27 UTC (rev 1367)
@@ -691,26 +691,6 @@
   printf("\nMatching question is:");
   print_card(quest->card);
   #endif
-
-  //We found a matching question, now we take it out of the 
-  //"active_quests" list and either put it back into the 
-  //main question list in a random location, or delete it:
-  active_quests = remove_node(active_quests, quest);
-  questions_pending--;  //the length of the 'active_quests' list
-
-  answered_wrong++;
-
-  /* add question to wrong_quests list: */
-  if (!already_in_list(wrong_quests, quest)) /* avoid duplicates */
-  {
-    mcdprintf("\nAdding to wrong_quests list");
-    wrong_quests = append_node(wrong_quests, quest);
-  }
-  else /* avoid memory leak */
-  {
-    free(quest);
-  }
-
   /* if desired, put question back in list so student sees it again */
   if (math_opts->iopts[REPEAT_WRONGS])
   {
@@ -720,6 +700,11 @@
 
     mcdprintf("\nAdding %d copies to question_list:", math_opts->iopts[COPIES_REPEATED_WRONGS]);
 
+#ifdef MC_DEBUG
+    printf("\nCard to be added is:");
+    print_card(*fc);
+#endif
+
     /* can put in more than one copy (to drive the point home!) */
     for (i = 0; i < math_opts->iopts[COPIES_REPEATED_WRONGS]; i++)
     {
@@ -735,11 +720,37 @@
   else
   {
     mcdprintf("\nNot repeating wrong answers\n");
-
     /* not repeating questions so list gets shorter:      */
     unanswered--;
   }
 
+  //Take the question out of the active_quests list and add it to
+  //the wrong_quests list, unless an identical question is already
+  //in the wrong_quests list:
+  active_quests = remove_node(active_quests, quest);
+  questions_pending--;  //the length of the 'active_quests' list
+  answered_wrong++;
+
+  /* add question to wrong_quests list: */
+  if (!already_in_list(wrong_quests, quest)) /* avoid duplicates */
+  {
+    mcdprintf("\nAdding to wrong_quests list");
+    wrong_quests = append_node(wrong_quests, quest);
+  }
+  else /* avoid memory leak */
+  {
+#ifdef MC_DEBUG
+    printf("\nBefore free() *fc is:");
+    print_card(*fc);
+#endif
+    free_node(quest);
+#ifdef MC_DEBUG
+    printf("\n After free() *fc is:");
+    print_card(*fc);
+#endif
+  }
+
+
   #ifdef MC_DEBUG
   print_counters();
   printf("\nLeaving MC_NotAnswered_Correctly()\n");

Modified: tuxmath/branches/lan/src/mathcards.h
===================================================================
--- tuxmath/branches/lan/src/mathcards.h	2009-08-05 12:02:13 UTC (rev 1366)
+++ tuxmath/branches/lan/src/mathcards.h	2009-08-05 14:11:27 UTC (rev 1367)
@@ -17,7 +17,7 @@
 
 #include "transtruct.h"
 
-//#define MC_DEBUG
+#define MC_DEBUG
 #ifdef MC_DEBUG
 #define mcdprintf(...) printf(__VA_ARGS__)
 #else




More information about the Tux4kids-commits mailing list