[Tux4kids-commits] r22 - in tuxmath/trunk: . docs src

dbruce at alioth.debian.org dbruce at alioth.debian.org
Thu Mar 8 21:04:35 CET 2007


Author: dbruce
Date: 2006-08-22 10:26:25 +0000 (Tue, 22 Aug 2006)
New Revision: 22

Modified:
   tuxmath/trunk/Makefile
   tuxmath/trunk/docs/changelog
   tuxmath/trunk/src/mathcards.h
   tuxmath/trunk/src/setup.c
   tuxmath/trunk/src/setup.h
   tuxmath/trunk/src/tuxmath.c
   tuxmath/trunk/src/tuxmath.h
Log:
Cleaner exit when errors encountered


Modified: tuxmath/trunk/Makefile
===================================================================
--- tuxmath/trunk/Makefile	2006-08-13 19:53:36 UTC (rev 21)
+++ tuxmath/trunk/Makefile	2006-08-22 10:26:25 UTC (rev 22)
@@ -8,7 +8,7 @@
 # Modified by David Bruce
 # dbruce at tampabay.rr.com
 
-# 2001.Aug.26 - 2006.Jun.12
+# 2001.Aug.26 - 2006.Aug.22
 
 
 CFLAGS=-Wall -g $(SDL_CFLAGS) -DDATA_PREFIX=\"$(DATA_PREFIX)\" -DDEBUG \
@@ -32,7 +32,7 @@
 OWNER=$(shell if `groups root | grep root > /dev/null` ; then echo root:root ; else echo root:wheel ; fi)
 
 
-VERSION=tuxmath-0.8
+VERSION=tuxmath-0.92
 
 all:	tuxmath
 

Modified: tuxmath/trunk/docs/changelog
===================================================================
--- tuxmath/trunk/docs/changelog	2006-08-13 19:53:36 UTC (rev 21)
+++ tuxmath/trunk/docs/changelog	2006-08-22 10:26:25 UTC (rev 22)
@@ -1,5 +1,15 @@
 changelog for "tuxmath"
 
+2006.Aug.22 (https://svn.tux4kids.net/tuxmath/ - revision 20)
+  Version 0.92
+
+  Code:
+    * Patch to allow program to exit more gracefully
+      if unable to load data files - primarily, the screen 
+      resolution goes back to normal instead of staying at
+      640x480.
+      David Yoder <hobie20dude at gmail.com>
+
 2006.Aug.13 (https://svn.tux4kids.net/tuxmath/ - revision 19)
   Version 0.91
 
@@ -8,6 +18,7 @@
       caused program to crash with segmentation fault if 
       TUXMATH_DEBUG disabled (which was how it was committed).
       :^(
+      David Bruce <dbruce at tampabay.rr.com>
 
 2006.Aug.11 (https://svn.tux4kids.net/tuxmath/ - revision 18)
   Version 0.9 
@@ -38,12 +49,15 @@
       structs changed to more intuitive/descriptive ones.
   Docs:
     * Updates to README.txt and TODO.txt
+      David Bruce <dbruce at tampabay.rr.com>
 
 2006.Jun.17 (https://svn.tux4kids.net/tuxmath/ - revision 10)
   Docs:
     * Updates to README.txt and TODO.txt.
     * Version designated as 0.8 in README.txt, tuxmath.h, and Makefile.
 
+      David Bruce <dbruce at tampabay.rr.com>
+
 2006.Jun.12 (https://svn.tux4kids.net/tuxmath/ - revision 9)
   Game:
     * Command-line argument added to allow ending the game with

Modified: tuxmath/trunk/src/mathcards.h
===================================================================
--- tuxmath/trunk/src/mathcards.h	2006-08-13 19:53:36 UTC (rev 21)
+++ tuxmath/trunk/src/mathcards.h	2006-08-22 10:26:25 UTC (rev 22)
@@ -84,9 +84,9 @@
 #define MC_MATH_OPTS_INVALID -9999        /* return value for accessor functions */
                                           /* if math_opts not valid    */
 
-#define DEFAULT_PLAY_THROUGH_LIST 1       /* play until all questions in list answered */                                                 /* correctly */
-#define DEFAULT_REPEAT_WRONGS   1        /* reuse incorrectly answered questions or not */
-#define DEFAULT_COPIES_REPEATED_WRONGS 1  /* how many copies of an incorrectly answered */                                                /* question to re-insert*/
+#define DEFAULT_PLAY_THROUGH_LIST 1       /* play until all questions in list answered */                                                                               /* correctly */
+#define DEFAULT_REPEAT_WRONGS   1         /* reuse incorrectly answered questions or not */
+#define DEFAULT_COPIES_REPEATED_WRONGS 1  /* how many copies of an incorrectly answered */                                                                              /* question to re-insert*/
 #define DEFAULT_ALLOW_NEGATIVES 0
 #define DEFAULT_MAX_ANSWER 144
 #define DEFAULT_MAX_QUESTIONS 5000

Modified: tuxmath/trunk/src/setup.c
===================================================================
--- tuxmath/trunk/src/setup.c	2006-08-13 19:53:36 UTC (rev 21)
+++ tuxmath/trunk/src/setup.c	2006-08-22 10:26:25 UTC (rev 22)
@@ -194,6 +194,8 @@
 void seticon(void);
 void usage(int err, char * cmd);
 int initialize_game_options(game_option_type* opts);
+void cleanup_memory(void);
+void cleanup_options(void);
 
 /* --- Set-up function! --- */
 
@@ -218,6 +220,7 @@
   {
     printf("\nUnable to initialize game_options\n");
     fprintf(stderr, "\nUnable to initialize game_options\n");
+    cleanup_on_error();
     exit(1);
   }
 
@@ -344,6 +347,7 @@
       printf("\n");
       
 
+      cleanup_on_error();
       exit(0);
     }
     else if (strcmp(argv[i], "--copyright") == 0 ||
@@ -360,6 +364,7 @@
 	"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
 	"\n");
 
+      cleanup_on_error();
       exit(0);
     }
     else if (strcmp(argv[i], "--usage") == 0 ||
@@ -386,6 +391,7 @@
     {
       printf("Tux, of Math Command (\"tuxmath\")\n"
 	     "Version " VERSION "\n");
+      cleanup_on_error();
       exit(0);
     }
     else if (strcmp(argv[i], "--nobackground") == 0 ||
@@ -497,6 +503,7 @@
 	      "\nError: I could not initialize video!\n"
 	      "The Simple DirectMedia error that occured was:\n"
 	      "%s\n\n", SDL_GetError());
+      cleanup_on_error();
       exit(1);
     }
 
@@ -564,6 +571,7 @@
             "\nError: I could not open the display.\n"
 	    "The Simple DirectMedia error that occured was:\n"
 	    "%s\n\n", SDL_GetError());
+    cleanup_on_error();
     exit(1);
   }
 
@@ -589,6 +597,7 @@
 		"%s\n"
 		"The Simple DirectMedia error that occured was:\n"
 		"%s\n\n", image_filenames[i], SDL_GetError());
+        cleanup_on_error();
 	exit(1);
       }
 
@@ -649,6 +658,7 @@
                 "%s\n"
                 "The Simple DirectMedia error that occured was:\n"
                 "%s\n\n", sound_filenames[i], SDL_GetError());
+        cleanup_on_error();
         exit(1);
       }
       
@@ -673,6 +683,7 @@
                 "%s\n"
                 "The Simple DirectMedia error that occured was:\n"
                 "%s\n\n", music_filenames[i], SDL_GetError());
+        cleanup_on_error();
         exit(1);
       }
       
@@ -703,10 +714,27 @@
     }
 }
 
-/* free any heap memory used during game DSB */
+/* save options and free heap */
+/* use for successful exit */
 void cleanup()
 
 {
+	cleanup_options();
+	cleanup_memory();
+}
+
+/* save options and free heap */
+/* use for fail exit */
+void cleanup_on_error()
+
+{
+	cleanup_memory();
+}
+
+/* save options */
+void cleanup_options()
+
+{
   /* find $HOME and tack on file name: */
   char* home_dir;
   home_dir = malloc(sizeof(char)*PATH_MAX);
@@ -732,8 +760,13 @@
     config_file = NULL;
   }
   free(home_dir);
+}
 
+/* free any heap memory used during game DSB */
+void cleanup_memory()
 
+{
+  SDL_Quit();
   if (game_options)
     free(game_options);
   /* frees any heap used by MathCards: */

Modified: tuxmath/trunk/src/setup.h
===================================================================
--- tuxmath/trunk/src/setup.h	2006-08-13 19:53:36 UTC (rev 21)
+++ tuxmath/trunk/src/setup.h	2006-08-22 10:26:25 UTC (rev 22)
@@ -41,6 +41,7 @@
 
 void setup(int argc, char * argv[]);
 void cleanup(void);
+void cleanup_on_error(void);
 
 void print_game_options(FILE* fp, int verbose);
 #endif

Modified: tuxmath/trunk/src/tuxmath.c
===================================================================
--- tuxmath/trunk/src/tuxmath.c	2006-08-13 19:53:36 UTC (rev 21)
+++ tuxmath/trunk/src/tuxmath.c	2006-08-22 10:26:25 UTC (rev 22)
@@ -52,7 +52,6 @@
   }
   while (!done);
   
-  SDL_Quit();
   cleanup();
   return 0;
 }

Modified: tuxmath/trunk/src/tuxmath.h
===================================================================
--- tuxmath/trunk/src/tuxmath.h	2006-08-13 19:53:36 UTC (rev 21)
+++ tuxmath/trunk/src/tuxmath.h	2006-08-22 10:26:25 UTC (rev 22)
@@ -22,11 +22,10 @@
 
 //#define NOSOUND
 //#define TUXMATH_DEBUG   /* for conditional compilation of debugging output */
-#define TUXMATH_VERSION 0.9
+#define TUXMATH_VERSION 0.92
 
 /* this struct contains all options regarding general       */
 /* gameplay but not having to do with math questions per se */
-/* FIXME document what all of these options do */
 typedef struct game_option_type {
   /* general game options */
   int per_user_config;
@@ -43,7 +42,7 @@
   int slow_after_wrong;
   int starting_comets;
   int extra_comets_per_wave;
-  int max_comets;  /*FIXME not being used */
+  int max_comets;  
   /* not sure the rest of these belong in here */
   int num_cities;  /* MUST BE AN EVEN NUMBER! */
   int num_bkgds;




More information about the Tux4kids-commits mailing list