[Tux4kids-commits] r283 - in tuxmath/trunk: . data/images/sprites docs src

dbruce-guest at alioth.debian.org dbruce-guest at alioth.debian.org
Thu Oct 4 01:18:24 UTC 2007


Author: dbruce-guest
Date: 2007-10-04 01:18:24 +0000 (Thu, 04 Oct 2007)
New Revision: 283

Modified:
   tuxmath/trunk/configure
   tuxmath/trunk/configure.ac
   tuxmath/trunk/data/images/sprites/Makefile.in
   tuxmath/trunk/docs/INSTALL.txt
   tuxmath/trunk/docs/changelog
   tuxmath/trunk/src/fileops.c
   tuxmath/trunk/src/highscore.c
   tuxmath/trunk/src/highscore.h
   tuxmath/trunk/src/loaders.c
   tuxmath/trunk/src/mathcards.c
   tuxmath/trunk/src/theme.c
   tuxmath/trunk/src/titlescreen.c
   tuxmath/trunk/src/titlescreen.h
Log:
fix of bug in mathcards.c


Modified: tuxmath/trunk/configure
===================================================================
--- tuxmath/trunk/configure	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/configure	2007-10-04 01:18:24 UTC (rev 283)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for Tux Of Math Command 1.5.4.
+# Generated by GNU Autoconf 2.61 for Tux Of Math Command 1.5.5.
 #
 # Report bugs to <tuxmath-devel at lists.sourceforge.net>.
 #
@@ -574,8 +574,8 @@
 # Identity of this package.
 PACKAGE_NAME='Tux Of Math Command'
 PACKAGE_TARNAME='tuxmath'
-PACKAGE_VERSION='1.5.4'
-PACKAGE_STRING='Tux Of Math Command 1.5.4'
+PACKAGE_VERSION='1.5.5'
+PACKAGE_STRING='Tux Of Math Command 1.5.5'
 PACKAGE_BUGREPORT='tuxmath-devel at lists.sourceforge.net'
 
 # Factoring default headers for most tests.
@@ -1235,7 +1235,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Tux Of Math Command 1.5.4 to adapt to many kinds of systems.
+\`configure' configures Tux Of Math Command 1.5.5 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1306,7 +1306,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Tux Of Math Command 1.5.4:";;
+     short | recursive ) echo "Configuration of Tux Of Math Command 1.5.5:";;
    esac
   cat <<\_ACEOF
 
@@ -1403,7 +1403,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Tux Of Math Command configure 1.5.4
+Tux Of Math Command configure 1.5.5
 generated by GNU Autoconf 2.61
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1417,7 +1417,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Tux Of Math Command $as_me 1.5.4, which was
+It was created by Tux Of Math Command $as_me 1.5.5, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   $ $0 $@
@@ -2282,7 +2282,7 @@
 
 # Define the identity of the package.
  PACKAGE='tuxmath'
- VERSION='1.5.4'
+ VERSION='1.5.5'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2430,7 +2430,6 @@
 
 ac_config_headers="$ac_config_headers config.h"
 
-# AM_MAINTAINER_MODE
 
 NAME_VERSION=$PACKAGE-$VERSION
 
@@ -6171,7 +6170,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Tux Of Math Command $as_me 1.5.4, which was
+This file was extended by Tux Of Math Command $as_me 1.5.5, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -6224,7 +6223,7 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-Tux Of Math Command config.status 1.5.4
+Tux Of Math Command config.status 1.5.5
 configured by $0, generated by GNU Autoconf 2.61,
   with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 

Modified: tuxmath/trunk/configure.ac
===================================================================
--- tuxmath/trunk/configure.ac	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/configure.ac	2007-10-04 01:18:24 UTC (rev 283)
@@ -1,6 +1,6 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
-AC_INIT(Tux Of Math Command, 1.5.4, tuxmath-devel at lists.sourceforge.net, tuxmath)
+AC_INIT(Tux Of Math Command, 1.5.5, tuxmath-devel at lists.sourceforge.net, tuxmath)
 
 #AC_PREREQ(2.59)
 AC_CANONICAL_HOST
@@ -9,7 +9,6 @@
 
 AM_INIT_AUTOMAKE(foreign)
 AM_CONFIG_HEADER(config.h)
-# AM_MAINTAINER_MODE
 
 NAME_VERSION=$PACKAGE-$VERSION
 

Modified: tuxmath/trunk/data/images/sprites/Makefile.in
===================================================================
--- tuxmath/trunk/data/images/sprites/Makefile.in	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/data/images/sprites/Makefile.in	2007-10-04 01:18:24 UTC (rev 283)
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.10 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -13,15 +13,11 @@
 # PARTICULAR PURPOSE.
 
 @SET_MAKE@
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-top_builddir = ../../..
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = @INSTALL@
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
 install_sh_SCRIPT = $(install_sh) -c
@@ -50,15 +46,11 @@
 DIST_SOURCES =
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
-BUILD_MINGW32_FALSE = @BUILD_MINGW32_FALSE@
-BUILD_MINGW32_TRUE = @BUILD_MINGW32_TRUE@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -73,6 +65,7 @@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 GREP = @GREP@
+INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -82,15 +75,12 @@
 LIBS = @LIBS@
 LTLIBOBJS = @LTLIBOBJS@
 MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
 NAME_VERSION = @NAME_VERSION@
 NSIS = @NSIS@
-NSI_BUILD_FALSE = @NSI_BUILD_FALSE@
-NSI_BUILD_TRUE = @NSI_BUILD_TRUE@
 NSI_DLL_DIR = @NSI_DLL_DIR@
 NSI_INSTALL_DIR = @NSI_INSTALL_DIR@
 NSI_TUXMATH_CONF_DIR = @NSI_TUXMATH_CONF_DIR@
-NSI_USE_TUXMATH_CONF_FALSE = @NSI_USE_TUXMATH_CONF_FALSE@
-NSI_USE_TUXMATH_CONF_TRUE = @NSI_USE_TUXMATH_CONF_TRUE@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -109,9 +99,11 @@
 STRIP = @STRIP@
 VERSION = @VERSION@
 WINDRES = @WINDRES@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
 ac_ct_CC = @ac_ct_CC@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
@@ -123,6 +115,7 @@
 build_cpu = @build_cpu@
 build_os = @build_os@
 build_vendor = @build_vendor@
+builddir = @builddir@
 datadir = @datadir@
 datarootdir = @datarootdir@
 docdir = @docdir@
@@ -150,12 +143,15 @@
 psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
 sysconfdir = @sysconfdir@
 target = @target@
 target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
 EXTRA_DIST = cascade0.png	\
 	cascade10.png	\
 	cascade1.png	\
@@ -291,7 +287,6 @@
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-uninstall-info-am:
 tags: TAGS
 TAGS:
 
@@ -300,22 +295,21 @@
 
 
 distdir: $(DISTFILES)
-	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
-	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
-	list='$(DISTFILES)'; for file in $$list; do \
-	  case $$file in \
-	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
-	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
-	  esac; \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
-	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
-	    dir="/$$dir"; \
-	    $(mkdir_p) "$(distdir)$$dir"; \
-	  else \
-	    dir=''; \
-	  fi; \
 	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
 	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
 	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
 	    fi; \
@@ -374,12 +368,20 @@
 
 install-data-am:
 
+install-dvi: install-dvi-am
+
 install-exec-am:
 
+install-html: install-html-am
+
 install-info: install-info-am
 
 install-man:
 
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
@@ -398,16 +400,19 @@
 
 ps-am:
 
-uninstall-am: uninstall-info-am
+uninstall-am:
 
+.MAKE: install-am install-strip
+
 .PHONY: all all-am check check-am clean clean-generic distclean \
 	distclean-generic distdir dvi dvi-am html html-am info info-am \
-	install install-am install-data install-data-am install-exec \
-	install-exec-am install-info install-info-am install-man \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
 	install-strip installcheck installcheck-am installdirs \
 	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \
-	uninstall-info-am
+	mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.

Modified: tuxmath/trunk/docs/INSTALL.txt
===================================================================
--- tuxmath/trunk/docs/INSTALL.txt	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/docs/INSTALL.txt	2007-10-04 01:18:24 UTC (rev 283)
@@ -1,7 +1,7 @@
 INSTALL.txt for "Tux, Of Math Command" (aka "Tuxmath")
-Version 1.5.2
+Version 1.5.5
 
-August 21, 2007
+October 2, 2007
 
 
 Requirements
@@ -140,36 +140,35 @@
 
         svn://svn.debian.org/tux4kids/tuxmath
 
-      If you are using a source tar.gz package (e.g. tuxmath-1.5.2-tar.gz),
+      If you are using a source tar.gz package (e.g. tuxmath-1.5.5-tar.gz),
       all you need to do is unpack the archive in a convient location and
       do a typical configure, make, and install.  In other words, the
-      tarball contains a complete "Gnu build system".  Note, however, that
+      tarball contains a complete "GNU Build System".  Note, however, that
       you will need the "-dev" files for SDL, SDL_image, SDL_mixer, and
       SDL_ttf.  You also need Gnu gettext as "msgfmt" is called during the
       installation.
  
       For example:
  
-        tar -xzf tuxmath-1.5.2-tar.gz
-        cd tuxmath-1.5.2
+        tar -xzf tuxmath-1.5.5-tar.gz
+        cd tuxmath-1.5.5
         ./configure
         make
         make install.  (you might need "su" or "sudo" for this)
  
-      If you use a subversion checkout, you will need to generate the configure
+      If you use a subversion checkout, you will need to generate the configure script.
       Tuxmath uses the Gnu Autoconf/Automake tools for development. You will need
       to run Autoconf's "autoreconf" to generate the configure script, Makefile.in's,
-      and friend, so the build process becomes:
+      and friends, so the build process becomes:
       
         autoreconf --install; ./configure; make; make install
 
       Tuxmath supports "parallel" or "vpath" builds to avoid cluttering the source
       tree with object files, so a clean way would be (starting within trunk):
 
-        autoreconf --install
-        cd ..
         mkdir build
         cd build
+        autoreconf --install ../trunk
         ../trunk/configure
         make
         make install

Modified: tuxmath/trunk/docs/changelog
===================================================================
--- tuxmath/trunk/docs/changelog	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/docs/changelog	2007-10-04 01:18:24 UTC (rev 283)
@@ -1,3 +1,14 @@
+2007.Oct.03 (svn.debian.org/tux4kids - revision 283)
+  Version 1.5.5
+  Code:
+      * One-liner bug fix in mathcards.c for rare segfaults during
+        problem list generation (thanks to Tim Holy's test program
+        for mathcards).
+      * Elimination of "evil" macros in titlescreen.h.
+
+      David Bruce <dbruce at tampabay.rr.com>
+
+
 2007.Sep.28 (svn.debian.org/tux4kids - revision 279)
   Code:
       * Completed the transition in TitleScreen to using a generic

Modified: tuxmath/trunk/src/fileops.c
===================================================================
--- tuxmath/trunk/src/fileops.c	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/src/fileops.c	2007-10-04 01:18:24 UTC (rev 283)
@@ -33,7 +33,7 @@
 #include "mathcards.h"
 #include "options.h"
 #include "highscore.h"
-//#include "titlescreen.h"
+#include "titlescreen.h"
 
 #ifndef MACOSX
 #include "../config.h"
@@ -93,10 +93,6 @@
 static int write_config_file(FILE* fp, int verbose);
 static int is_lesson_file(const struct dirent *lfdirent);
 
-/* FIXME copied this prototype here because titlescreen.h */
-/* has an 'evil macro named 'rewind' that generates a name */
-/* collision with rewind() in read_config_file():          */
-TTF_Font* LoadFont(const unsigned char* font_name, int font_size);
 
 
 /* fix HOME on windows */

Modified: tuxmath/trunk/src/highscore.c
===================================================================
--- tuxmath/trunk/src/highscore.c	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/src/highscore.c	2007-10-04 01:18:24 UTC (rev 283)
@@ -22,7 +22,7 @@
 
 typedef struct high_score_entry {
   int score;
-  char name[HIGH_SCORE_NAME_LENGTH];
+  unsigned char name[HIGH_SCORE_NAME_LENGTH];
 } high_score_entry;
 
 
@@ -734,11 +734,8 @@
     return 0;
   }
 
-/* FIXME work-around to prevent name collision until we get rid of rewind macro */
-#undef rewind
   /* make sure we start at beginning: */
   rewind(fp);
-#define rewind(SPRITE) (SPRITE)->cur = 0;
 
   /* read in a line at a time: */
   while (fgets (buf, PATH_MAX, fp))
@@ -823,14 +820,14 @@
 
 
 /* Return (pointer to) the name associated with a table entry:  */
-char* HS_Name(int diff_level, int place)
+unsigned char* HS_Name(int diff_level, int place)
 {
   /* Make sure diff_level is valid: */
   if (diff_level < 0
    || diff_level > ACE_HIGH_SCORE)
   {
     fprintf(stderr, "In HS_Score(), diff_level invalid!\n");
-    return -1;
+    return NULL;
   }
 
   /* Make sure place is valid: */
@@ -838,8 +835,8 @@
    || place >= HIGH_SCORES_SAVED)
   {
     fprintf(stderr, "In HS_Score(), place invalid!\n");
-    return -1;
+    return NULL;
   }
 
-  return &high_scores[diff_level][place].name;
+  return high_scores[diff_level][place].name;
 }

Modified: tuxmath/trunk/src/highscore.h
===================================================================
--- tuxmath/trunk/src/highscore.h	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/src/highscore.h	2007-10-04 01:18:24 UTC (rev 283)
@@ -28,5 +28,5 @@
 void write_high_scores_fp(FILE* fp);
 
 int HS_Score(int diff_level, int place);
-char* HS_Name(int diff_level, int place);
+unsigned char* HS_Name(int diff_level, int place);
 #endif

Modified: tuxmath/trunk/src/loaders.c
===================================================================
--- tuxmath/trunk/src/loaders.c	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/src/loaders.c	2007-10-04 01:18:24 UTC (rev 283)
@@ -27,6 +27,7 @@
 #include "tuxmath.h"     // for TUXMATH_DEBUG
 #include "titlescreen.h"
 #include "setup.h"  // for cleanup_on_error()
+#include "SDL_extras.h"
 
 /* FIXME Doesn't seem to work consistently on all versions of Windows */
 /* check to see if file exists, if so return true */
@@ -220,8 +221,12 @@
 	free(gfx);
 }
 
+void next_frame(sprite* s)
+{
+  if (s && s->num_frames)
+    s->cur = (s->cur + 1) % s->num_frames;
+}
 
-
 /***************************
 	LoadSound : Load a sound/music patch from a file.
 ****************************/

Modified: tuxmath/trunk/src/mathcards.c
===================================================================
--- tuxmath/trunk/src/mathcards.c	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/src/mathcards.c	2007-10-04 01:18:24 UTC (rev 283)
@@ -218,7 +218,9 @@
   
   /* clear out old lists if starting another game: (if not done already) */
   delete_list(question_list);
+  question_list = NULL;
   delete_list(wrong_quests);
+  wrong_quests = NULL;
 
   /* set up new list with pointer to top: */
   question_list = generate_list();
@@ -1909,6 +1911,9 @@
   fprintf(fp, "min_typing_num = %d\n",math_opts->min_typing_num);
   fprintf(fp, "max_typing_num = %d\n",math_opts->max_typing_num);
 
+  #ifdef MC_DEBUG
+  printf("\nLeaving MC_PrintMathOptions()\n");
+  #endif
 }
 
 
@@ -2027,9 +2032,9 @@
 /* math operations and question formats                                    */
 MC_MathQuestion* generate_list(void)
 {
-  MC_MathQuestion* top_of_list = 0;
-  MC_MathQuestion* end_of_list = 0;
-  MC_MathQuestion* tmp_ptr = 0;
+  MC_MathQuestion* top_of_list = NULL;
+  MC_MathQuestion* end_of_list = NULL;
+  MC_MathQuestion* tmp_ptr = NULL;
 
   int i, j, k;
   int length = 0;
@@ -2041,6 +2046,9 @@
  
   /* add nodes for each math operation allowed */
 
+  #ifdef MC_DEBUG
+  printf("\ngenerating addition questions\n");
+  #endif
 
   if (math_opts->addition_allowed)
   {
@@ -2108,6 +2116,10 @@
     }
   }
 
+  #ifdef MC_DEBUG
+  printf("generating subtraction questions\n");
+  #endif
+
   if (math_opts->subtraction_allowed)
   {
     for (i = math_opts->min_minuend; i <= math_opts->max_minuend; i++)
@@ -2175,6 +2187,10 @@
     }
   }
 
+  #ifdef MC_DEBUG
+  printf("generating multiplication questions\n");
+  #endif
+
   if (math_opts->multiplication_allowed)
   {
     for (i = math_opts->min_multiplier; i <= math_opts->max_multiplier; i++)
@@ -2244,6 +2260,10 @@
     }
   }
 
+  #ifdef MC_DEBUG
+  printf("generating division questions\n");
+  #endif
+
   if (math_opts->division_allowed)
   {
     for (i = math_opts->min_quotient; i <= math_opts->max_quotient; i++)
@@ -2312,6 +2332,10 @@
     }
   }
 
+  #ifdef MC_DEBUG
+  printf("generating typing practice questions\n");
+  #endif
+
   if (math_opts->typing_practice_allowed)
   {
     for (i = math_opts->min_typing_num; i <= math_opts->max_typing_num; i++)
@@ -2384,16 +2408,25 @@
 /* create a new node and return a pointer to it */
 MC_MathQuestion* create_node(int n1, int n2, int op, int ans, int f)
 {
-  MC_MathQuestion* ptr;
-  ptr = malloc(sizeof(MC_MathQuestion));
+  MC_MathQuestion* ptr = NULL;
+
+  ptr = (MC_MathQuestion*)malloc(sizeof(MC_MathQuestion));
+
+  if (!ptr)
+  {
+    fprintf(stderr, "create_node() - malloc() failed!\n");
+    return NULL;
+  }
+
   ptr->card.num1 = n1;
   ptr->card.num2 = n2;  
   ptr->card.num3 = ans;
   ptr->card.operation = op;
   ptr->card.format = f;
-  ptr->next = 0;
-  ptr->previous =0;
+  ptr->next = NULL;
+  ptr->previous = NULL;
 
+
   /* creating formula_string  and answer_string is a little more work: */
   {
     char oper_char;
@@ -2431,6 +2464,7 @@
         fprintf(stderr, "\nIn create_node(): invalid math operation\n");
         free(ptr);
         ptr = 0;
+
         return 0;
       }
     }
@@ -2469,6 +2503,8 @@
         fprintf(stderr, "\ncreate_node() - invalid question format\n");
         free(ptr);
         ptr = 0;
+
+ 
         return 0;
       }
     }

Modified: tuxmath/trunk/src/theme.c
===================================================================
--- tuxmath/trunk/src/theme.c	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/src/theme.c	2007-10-04 01:18:24 UTC (rev 283)
@@ -345,7 +345,8 @@
 			}
 
 			start = loc - (loc % 8);
-			for (i = start; i<MIN(start+8,themes); i++) {
+			for (i = start; (i < start + 8) && (i < themes); i++)
+                        {
 				titleRects[i%8].x = 160 - (titles[i]->w/2);
 				if (i == loc)
 					SDL_BlitSurface(select[loc], NULL, screen, &titleRects[i%8]);

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/src/titlescreen.c	2007-10-04 01:18:24 UTC (rev 283)
@@ -10,6 +10,7 @@
     Modified for use in tuxmath by David Bruce - 2006-2007.
     email                : <dbruce at tampabay.rr.com>
                            <tuxmath-devel at lists.sourceforge.net>
+    Also significantly enhanced by Tim Holy - 2007
 ***************************************************************************/
 
 /***************************************************************************
@@ -56,7 +57,6 @@
 int num_lessons = 0;
 
 // globals from tuxtype's globals.h defined outside of titlescreen.c (in tuxtype):
-//int show_tux4kids;
 int debugOn; //FIXME switch to TUXMATH_DEBUG
 
 
@@ -383,29 +383,17 @@
 
 
 // 1 = success, 0 = failure
-int TitleScreen_load_media( void )
+int TitleScreen_load_media(void)
 {
   char fn[PATH_MAX];
   int i;
 
-  /* --- load sounds --- */
 
 #ifdef TUXMATH_DEBUG
   fprintf(stderr, "Entering TitleScreen_load_media():\n");
 #endif
 
-/*  if (Opts_MenuSound())
-  {
-    snd_move = LoadSound("tock.wav");
-    snd_select = LoadSound("pop.wav");
-  }*/
- 
-  /* --- load graphics --- */
-
-//  titlepic = LoadImage("title/title1.png", IMG_ALPHA);
-//  bkg = LoadImage( "title/main_bkg.jpg", IMG_REGULAR );
   Tux = LoadSprite("tux/bigtux", IMG_ALPHA);
-  //font = LoadFont(menu_font, menu_font_size);
 
   SDL_ShowCursor(1);
 
@@ -435,34 +423,20 @@
   for (i = 0; i < N_SPRITES; i++)
     FreeSprite(sprite_list[i]);
   free(sprite_list);
-  sprite_list == NULL;
+  sprite_list = NULL;
 }
 
 
 
-void TitleScreen_unload_media( void ) {
+void TitleScreen_unload_media(void)
+{
+  FreeSprite(Tux);
+  Tux = NULL;
+  TitleScreen_unload_menu();
+}
 
-	/* --- unload sounds --- */
 
-/*	if (Opts_MenuSound()){
-	    Mix_FreeChunk(snd_move);
-	    Mix_FreeChunk(snd_select);
-	}*/
 
-	/* --- unload graphics --- */
-
-//	SDL_FreeSurface(titlepic);
-//	SDL_FreeSurface(bkg);
-
-//	FreeSprite(sel);
-//	FreeSprite(reg);
-
-	FreeSprite(Tux);
-
-	//TTF_CloseFont(font);
-	TitleScreen_unload_menu();
-}
-
 void NotImplemented(void)
 {
   char *s1, *s2, *s3, *s4;
@@ -479,9 +453,6 @@
 
 
 
-
-
-
 /* FIXME add some background shading to improve legibility */
 void ShowMessage(char* str1, char* str2, char* str3, char* str4)
 {
@@ -618,7 +589,7 @@
     {
       SDL_BlitSurface(Tux->frame[tux_frame - 1], NULL, screen, &Tuxdest);
 //      SDL_UpdateRect(screen, Tuxdest.x+37, Tuxdest.y+40, 70, 45);
-      SDL_UpdateRect(screen, 0, 0, 0, 0);
+      SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h);
 
     }
     /* Wait so we keep frame rate constant: */
@@ -664,29 +635,30 @@
 
   while (choice >= 0) {
     switch (choice) {
-    case 0: {
-      ret = choose_config_file();
-      break;
+      case 0: {
+        ret = choose_config_file();
+        break;
+      }
+      case 1: {
+        ret = run_arcade_menu();
+        break;
+      }
+      case 2: {
+        ret = run_custom_menu();
+        break;
+      }
+      case 3: {
+        ret = run_options_menu();
+        break;
+      }
+      case 4: {
+        return 0;
+      }
     }
-    case 1: {
-      ret = run_arcade_menu();
-      break;
-    }
-    case 2: {
-      ret = run_custom_menu();
-      break;
-    }
-    case 3: {
-      ret = run_options_menu();
-      break;
-    }
-    case 4: {
-      return 0;
-    }
-    }
     menu_opts.starting_entry = choice;
     choice = choose_menu_item(menu_text,sprites,5,menu_opts);
   }
+  return 0;
 }
 
 int run_arcade_menu(void)
@@ -913,7 +885,7 @@
 /****************************************************************/
 /* choose_menu_item: menu navigation utility function           */
 /****************************************************************/
-int choose_menu_item(const unsigned char **menu_text,sprite **menu_sprites,int n_menu_entries,menu_options menu_opts)
+int choose_menu_item(const unsigned char **menu_text, sprite **menu_sprites, int n_menu_entries, menu_options menu_opts)
 {
   // Pixel renderings of menu text choices
   SDL_Surface **menu_item_unselected = NULL;
@@ -1437,7 +1409,7 @@
 	DrawButton(&menu_button_rect[imod], 15, SEL_RGBA);
 	SDL_BlitSurface(menu_item_selected[loc], NULL, screen, &menu_text_rect[imod]);
 	if (use_sprite) {
-	  rewind(menu_sprites[loc]);  // start at beginning of animation sequence
+	  menu_sprites[loc]->cur = 0;  // start at beginning of animation sequence
 	  SDL_BlitSurface(menu_sprites[loc]->frame[menu_sprites[loc]->cur], NULL, screen, &menu_sprite_rect[imod]);
 	  SDL_UpdateRect(screen, menu_sprite_rect[imod].x, menu_sprite_rect[imod].y, menu_sprite_rect[imod].w, menu_sprite_rect[imod].h);
 	  next_frame(menu_sprites[loc]);
@@ -1493,13 +1465,10 @@
     if (Tux && tux_frame)
     {
       SDL_BlitSurface(Tux->frame[tux_frame - 1], NULL, screen, &Tuxdest);
-      SDL_UpdateRect(screen, Tuxdest.x+37, Tuxdest.y+40, 70, 45);
+      SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h);
       //SDL_UpdateRect(screen, 0, 0, 0, 0);
-
     }
 
-
-
     /* Wait so we keep frame rate constant: */
     frame_now = SDL_GetTicks();
     if (frame_now < frame_start)
@@ -1532,6 +1501,8 @@
     return loc;
 }
 
+
+
 void set_buttons_max_width(SDL_Rect *menu_button_rect,int n)
 {
   int i,max;
@@ -1727,6 +1698,8 @@
     LOG("->TransWipe(): FINISH\n");
 }
 
+
+
 /************************
 UpdateScreen : Update the screen and increment the frame num
 ***************************/

Modified: tuxmath/trunk/src/titlescreen.h
===================================================================
--- tuxmath/trunk/src/titlescreen.h	2007-10-01 03:52:48 UTC (rev 282)
+++ tuxmath/trunk/src/titlescreen.h	2007-10-04 01:18:24 UTC (rev 283)
@@ -54,13 +54,7 @@
 
 #include "tuxmath.h"
 
-/* FIXME get rid of these evil macros! */
-#define next_frame(SPRITE) if ((SPRITE)->num_frames) (SPRITE)->cur = (((SPRITE)->cur)+1) % (SPRITE)->num_frames;
-#define rewind(SPRITE) (SPRITE)->cur = 0;
 
-#define MIN(x,y) ((x) < (y) ? (x) : (y))
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-
 typedef struct {
     char lang[PATH_MAX];
     char path[PATH_MAX];
@@ -259,6 +253,7 @@
 sprite      *FlipSprite( sprite *in, int X, int Y );
 void         FreeSprite( sprite *gfx );
 Mix_Music   *LoadMusic( char *datafile );
+void next_frame(sprite* s);
 
 /* in alphabet.c (from tuxtype) */
 void LoadKeyboard( void );




More information about the Tux4kids-commits mailing list