[Tux4kids-commits] [SCM] tuxhistory - Educational history game branch, master, updated. 3ab44c3e1c83a63ee5b16a5afaf44f5383e57406
julio (none)
julio at julio-desktop.
Wed Jun 23 21:00:06 UTC 2010
The following commit has been merged in the master branch:
commit 3ab44c3e1c83a63ee5b16a5afaf44f5383e57406
Author: julio <julio at julio-desktop.(none)>
Date: Wed Jun 23 15:59:36 2010 -0500
New load_map() function...
diff --git a/src/loaders.c b/src/loaders.c
index ae15134..3edf064 100644
--- a/src/loaders.c
+++ b/src/loaders.c
@@ -47,7 +47,7 @@ void fit_in_rectangle(int* width, int* height, int max_width, int max
SDL_Surface* set_format(SDL_Surface* img, int mode);
sprite* load_sprite(const char* name, int mode, int w, int h, bool proportional);
-
+FILE* load_map(const char* file_name);
/* check to see if file exists, if so return true */
// int checkFile( const char *file ) {
@@ -654,3 +654,33 @@ Mix_Music* LoadMusic(char *datafile )
return tempMusic;
}
+/* load_map: Load map from a XML datafile */
+FILE* load_map(const char* name)
+{
+ FILE *fp = NULL;
+ char fn[PATH_MAX];
+ int fn_len;
+ int i;
+
+ if(NULL == fp)
+ {
+ DEBUGMSG(debug_loaders, "load_image(): file_name is NULL, exiting.\n");
+ return NULL;
+ }
+
+
+ /* check if map file is present */
+ sprintf(fn, "%s/maps/%s.map", DATA_PREFIX, name);
+ fn_len = strlen(fn);
+
+ if(strcmp(fn + fn_len - 4, ".map"))
+ {
+ DEBUGMSG(debug_loaders, "load_map(): %s is not an TuxHistory XML Map file\n", fn);
+ return NULL;
+ }
+
+ fp = fopen(fn, "r");
+
+ return fp;
+}
+
--
tuxhistory - Educational history game
More information about the Tux4kids-commits
mailing list