[Tux4kids-commits] [SCM] tuxhistory - Educational history game branch, master, updated. 24180ed3492a26ad320d5306a4cd07f8e49f441f
julio (none)
julio at julio-desktop.
Sun Jun 27 07:30:53 UTC 2010
The following commit has been merged in the master branch:
commit 24180ed3492a26ad320d5306a4cd07f8e49f441f
Author: julio <julio at julio-desktop.(none)>
Date: Sun Jun 27 02:30:03 2010 -0500
get_terrain_enum() is ready and all commpiling errors are fixed.
diff --git a/src/globals.h b/src/globals.h
index 4a3c178..6fb3ff5 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -114,10 +114,10 @@ extern const int debug_all;
/* MAX definition for the map handling...*/
-#define MAX_X_TILDES
-#define MAX_Y_TILDES
+#define MAX_X_TILDES 100
+#define MAX_Y_TILDES 100
-#define MAX_OBJECTS
+#define MAX_OBJECTS 100
/* These values are hard-coded and used 'as is' by the program */
/* (i.e. these behaviors require recompilation to change) */
@@ -147,7 +147,26 @@ extern const int debug_all;
#define PIXEL_BITS 32
+enum {
+ CADET_HIGH_SCORE,
+ SCOUT_HIGH_SCORE,
+ RANGER_HIGH_SCORE,
+ ACE_HIGH_SCORE,
+ COMMANDO_HIGH_SCORE,
+ NUM_MATH_COMMAND_LEVELS
+};
+
+enum {
+ FACTORS_HIGH_SCORE = NUM_MATH_COMMAND_LEVELS,
+ FRACTIONS_HIGH_SCORE,
+ NUM_HIGH_SCORE_LEVELS
+};
-#define NAME_BUF_SIZE 200
+#define NAME_BUF_SIZE 200
+/* data for 'Training Academy' lessons: */
+extern char **lesson_list_titles;
+extern char **lesson_list_filenames;
+extern int* lesson_list_goldstars;
+extern int num_lessons;
#endif
diff --git a/src/map.c b/src/map.c
index 0977a85..1475bb0 100644
--- a/src/map.c
+++ b/src/map.c
@@ -12,6 +12,7 @@
*/
#include "tuxhistory.h"
+#include "fileops.h"
#include<ctype.h>
#include<mxml.h>
@@ -23,6 +24,8 @@ void str_upper(char *string);
int map_xml(FILE *fp)
{
+ int value;
+ int x,y;
char *text;
mxml_node_t *tree;
mxml_node_t *node;
@@ -31,6 +34,9 @@ int map_xml(FILE *fp)
tree = mxmlLoadFile(NULL, fp, MXML_TEXT_CALLBACK);
+ x = 0;
+ y = 0;
+
for(inode = mxmlFindElement(tree, tree, "row",
NULL, NULL, MXML_DESCEND);
inode != NULL;
@@ -45,12 +51,28 @@ int map_xml(FILE *fp)
{
node = mxmlFindElement(jnode, jnode, "terrain",
NULL, NULL, MXML_DESCEND);
+
+ value = get_terrain_enum(node->child->value.text.string);
+ if(value != -1)
+ {
+ map[x][y].terrain = value;
+ }
+
printf("%s",node->child->value.text.string);
node = mxmlFindElement(jnode, jnode, "height",
NULL, NULL, MXML_DESCEND);
+
printf("%d",node->child->value.integer);
+
+ if(node->child->value.integer >= 0)
+ {
+ map[x][y].height = node->child->value.integer;
+ }
+
+ y++;
}
+ x++;
printf("\n");
}
@@ -66,14 +88,40 @@ int map_xml(FILE *fp)
fclose(fp);
}
+// Returns the enum value for each terrain type. If the terrain
+// type don't exists it returns -1
+
int get_terrain_enum(char *terrain_string)
{
- if(strcmp(terrain, "GRASSLAND"))
- {
- return 1;
- }
+ if(strcmp(terrain_string, "HIGHSEA"))
+ return HIGHSEA;
+ else if(strcmp(terrain_string, "TUNDRA"))
+ return TUNDRA;
+ else if(strcmp(terrain_string, "SWAMP"))
+ return SWAMP;
+ else if(strcmp(terrain_string, "UNEXPLORED"))
+ return UNEXPLORED;
+ else if(strcmp(terrain_string, "DESERT"))
+ return DESERT;
+ else if(strcmp(terrain_string, "GRASSLAND"))
+ return GRASSLAND;
+ else if(strcmp(terrain_string, "ARCTIC"))
+ return ARCTIC;
+ else if(strcmp(terrain_string, "OCEAN"))
+ return OCEAN;
+ else if(strcmp(terrain_string, "MARSH"))
+ return MARSH;
+ else if(strcmp(terrain_string, "SAVANNAH"))
+ return SAVANNAH;
+ else if(strcmp(terrain_string, "PLAINS"))
+ return PLAINS;
+ else if(strcmp(terrain_string, "PRAIRIE"))
+ return PRAIRIE;
+ else
+ return -1;
}
+// TODO: Segfault error still in this function!
void str_upper(char *string)
{
char c;
diff --git a/src/menu.c b/src/menu.c
index cac850f..ee39196 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -297,12 +297,8 @@ int handle_activity(int act, int param)
case RUN_ARCADE:
game();
break;
- case RUN_HALL_OF_FAME:
- DisplayHighScores(CADET_HIGH_SCORE);
- break;
case RUN_HELP:
- game();
break;
case RUN_DEMO:
diff --git a/src/setup.c b/src/setup.c
index fdc34b1..d057968 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -41,6 +41,7 @@
#include "options.h"
#include "tuxhistory.h"
+#include "globals.h"
#include "setup.h"
#include "fileops.h"
#include "loaders.h"
@@ -67,7 +68,7 @@ int win_res_y = 480;
int fs_res_x = 0;
int fs_res_y = 0;
-th_map **map; //The map array.
+th_map **map = NULL; //The map array.
th_obj* object = NULL;
@@ -656,7 +657,7 @@ void cleanup_on_error(void)
/* need to check all pointers before freeing them, */
/* and set them to NULL after freeing them, so we */
/* avoid segfaults at exit from double free() */
-void [MAX_X_TILDES]cleanup_memory(void)
+void cleanup_memory(void)
{
int i;
int frequency,channels,n_timesopened;
--
tuxhistory - Educational history game
More information about the Tux4kids-commits
mailing list