pbutton->bkgd = NULL;
}
-button_type* button_change_icon(button_type* pbutton,char* icon_file)
+void button_change_icon(button_type* pbutton,char* icon_file)
{
char filename[1024];
void button_load(button_type* pbutton,char* icon_file, char* info, SDLKey shortcut, int x, int y);
button_type* button_create(char* icon_file, char* info, SDLKey shortcut, int x, int y);
-button_type* button_change_icon(button_type* pbutton,char* icon_file);
+void button_change_icon(button_type* pbutton,char* icon_file);
void button_draw(button_type* pbutton);
void button_free(button_type* pbutton);
void button_event(button_type* pbutton, SDL_Event* event);
}
*old = *current;
-
+return 0;
}
void collision_handler()
sprintf(str, "LEVEL %d", level);
text_drawf(&blue_text, str, 0, 200, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
- sprintf(str, "%s", current_level.name);
+ sprintf(str, "%s", current_level.name.c_str());
text_drawf(&gold_text, str, 0, 224, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
sprintf(str, "TUX x %d", tux.lives);
/* --- GAME LOOP! --- */
-int gameloop(char * subset, int levelnb, int mode)
+int gameloop(const char * subset, int levelnb, int mode)
{
int fps_cnt, jump, done;
timer_type fps_timer, frame_timer;
/* Function prototypes: */
-int gameloop(char * subset, int levelnb, int mode);
+int gameloop(const char * subset, int levelnb, int mode);
void savegame(int slot);
void loadgame(int slot);
void slotinfo(char **pinfo, int slot);
{
FILE * fi;
char temp[128];
- int c, i, strl;
+ int strl;
+ unsigned int i, c;
hs_score = 100;
strcpy(hs_name, "Grandma\0");
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <iostream>
#include "globals.h"
#include "setup.h"
#include "screen.h"
#include "scene.h"
#include "lispreader.h"
+using namespace std;
+
texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2];
-void subset_init(st_subset* st_subset)
+st_subset::st_subset()
+{
+ levels = 0;
+}
+
+void st_subset::create(const std::string& subset_name)
{
- st_subset->title = NULL;
- st_subset->description = NULL;
- st_subset->name = NULL;
- st_subset->levels = 0;
+ st_level new_lev;
+ st_subset new_subset;
+ new_subset.name = subset_name;
+ new_subset.title = "Unknown Title";
+ new_subset.description = "No description so far.";
+ new_subset.save();
+ level_default(&new_lev);
+ level_save(&new_lev,subset_name.c_str(),1);
}
-void subset_parse (st_subset* st_subset, lisp_object_t* cursor)
+void st_subset::parse (lisp_object_t* cursor)
{
while(!lisp_nil_p(cursor))
{
{
if(( s = lisp_string(lisp_car(lisp_cdr(cur)))) != NULL)
{
- st_subset->title = (char*) malloc(sizeof(char)*(strlen(s)+1));
- strcpy(st_subset->title,s);
+ title = s;
}
}
else if (strcmp(lisp_symbol(lisp_car(cur)), "description") == 0)
{
if(( s = lisp_string(lisp_car(lisp_cdr(cur)))) != NULL)
{
- st_subset->description = (char*) malloc(sizeof(char)*(strlen(s)+1));
- strcpy(st_subset->description,s);
+ description = s;
}
}
}
}
}
-void subset_load(st_subset* st_subset, char *subset)
+void st_subset::load(char *subset)
{
FILE* fi;
char filename[1024];
char str[1024];
- int len,i;
+ int i;
lisp_object_t* root_obj = 0;
- st_subset->name = (char*) malloc(sizeof(char)*(strlen(subset)+1));
- strcpy(st_subset->name,subset);
+ name = subset;
snprintf(filename, 1024, "%s/levels/%s/info", st_dir, subset);
if(!faccessible(filename))
if (strcmp(lisp_symbol(cur), "level-subset") == 0)
{
- subset_parse(st_subset,lisp_cdr(root_obj));
+ parse(lisp_cdr(root_obj));
}
snprintf(str, 1024, "%s.png", filename);
if(faccessible(str))
{
- texture_load(&st_subset->image,str,IGNORE_ALPHA);
+ texture_load(&image,str,IGNORE_ALPHA);
}
else
{
snprintf(filename, 1024, "%s/images/status/level-subset-info.png", DATA_PREFIX);
- texture_load(&st_subset->image,filename,IGNORE_ALPHA);
+ texture_load(&image,filename,IGNORE_ALPHA);
}
}
break;
}
}
- st_subset->levels = --i;
+ levels = --i;
}
-void subset_save(st_subset* st_subset)
+void st_subset::save()
{
FILE* fi;
- char filename[1024];
+ string filename;
/* Save data file: */
- sprintf(filename, "/levels/%s/", st_subset->name);
+ filename = "/levels/" + name + "/";
- fcreatedir(filename);
- snprintf(filename, 1024, "%s/levels/%s/info", st_dir, st_subset->name);
- if(!fwriteable(filename))
- snprintf(filename, 1024, "%s/levels/%s/info", DATA_PREFIX, st_subset->name);
- if(fwriteable(filename))
+ fcreatedir(filename.c_str());
+ filename = string(st_dir) + "/levels/" + name + "/info";
+ if(!fwriteable(filename.c_str()))
+ filename = string(DATA_PREFIX) + "/levels/" + name + "/info";
+ if(fwriteable(filename.c_str()))
{
- fi = fopen(filename, "w");
+ fi = fopen(filename.c_str(), "w");
if (fi == NULL)
{
- perror(filename);
+ perror(filename.c_str());
}
-
+
/* Write header: */
fprintf(fi,";SuperTux-Level-Subset\n");
fprintf(fi,"(level-subset\n");
-
+
/* Save title info: */
- fprintf(fi," (title \"%s\")\n",st_subset->title);
+ fprintf(fi," (title \"%s\")\n", title.c_str());
/* Save the description: */
- fprintf(fi," (description \"%s\")\n",st_subset->description);
-
+ fprintf(fi," (description \"%s\")\n", description.c_str());
+
fprintf( fi,")");
fclose(fi);
}
}
-void subset_free(st_subset* st_subset)
+void st_subset::free()
+{
+ title.clear();
+ description.clear();
+ name.clear();
+ texture_free(&image);
+ levels = 0;
+}
+
+void level_default(st_level* plevel)
{
- free(st_subset->title);
- free(st_subset->description);
- free(st_subset->name);
- texture_free(&st_subset->image);
- st_subset->levels = 0;
+ int i,y;
+ plevel->name = "UnNamed";
+ plevel->theme = "antarctica";
+ plevel->song_title = "Mortimers_chipdisko.mod";
+ plevel->bkgd_image = "arctis.png";
+ plevel->width = 21;
+ plevel->time_left = 100;
+ plevel->gravity = 10.;
+ plevel->bkgd_red = 0;
+ plevel->bkgd_green = 0;
+ plevel->bkgd_blue = 0;
+
+ for(i = 0; i < 15; ++i)
+ {
+ plevel->tiles[i] = (unsigned int*) malloc((plevel->width+1)*sizeof(unsigned int));
+ plevel->tiles[i][plevel->width] = (unsigned int) '\0';
+ for(y = 0; y < plevel->width; ++y)
+ plevel->tiles[i][y] = (unsigned int) '.';
+ plevel->tiles[i][plevel->width] = (unsigned int) '\0';
+ }
}
/* Load data for this level: */
/* Returns -1, if the loading of the level failed. */
-int level_load(st_level* plevel, char *subset, int level)
+int level_load(st_level* plevel,const char *subset, int level)
{
char filename[1024];
int level_load(st_level* plevel, const char* filename)
{
- char str[80];
int x, y;
- char * line;
FILE * fi;
+ lisp_object_t* root_obj = 0;
fi = fopen(filename, "r");
if (fi == NULL)
{
return -1;
}
- /* Load header info: */
-
-
- /* (Level title) */
- fgets(str, 20, fi);
- strcpy(plevel->name, str);
- plevel->name[strlen(plevel->name)-1] = '\0';
-
- /* (Level theme) */
- fgets(str, 20, fi);
- strcpy(plevel->theme, str);
- plevel->theme[strlen(plevel->theme)-1] = '\0';
+ lisp_stream_t stream;
+ lisp_stream_init_file (&stream, fi);
+ root_obj = lisp_read (&stream);
-
-
- /* (Time to beat level) */
- fgets(str, 10, fi);
- plevel->time_left = atoi(str);
-
- /* (Song file for this level) */
- fgets(str, sizeof(plevel->song_title), fi);
- strcpy(plevel->song_title, str);
- plevel->song_title[strlen(plevel->song_title)-1] = '\0';
-
- /* (Level background image) */
- fgets(str, sizeof(plevel->bkgd_image), fi);
- strcpy(plevel->bkgd_image, str);
- plevel->bkgd_image[strlen(plevel->bkgd_image)-1] = '\0';
-
- /* (Level background color) */
- fgets(str, 10, fi);
- plevel->bkgd_red = atoi(str);
- fgets(str, 10, fi);
- plevel->bkgd_green= atoi(str);
- fgets(str, 10, fi);
- plevel->bkgd_blue = atoi(str);
-
- /* (Level width) */
- fgets(str, 10, fi);
- plevel->width = atoi(str);
-
- /* (Level gravity) */
- fgets(str, 10, fi);
- plevel->gravity = atof(str);
-
- /* Set the global gravity to the latest loaded level's gravity */
- gravity = plevel->gravity;
-
- /* Allocate some space for the line-reading! */
-
- line = (char *) malloc(sizeof(char) * (plevel->width + 5));
- if (line == NULL)
+ if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR)
{
- fprintf(stderr, "Couldn't allocate space to load level data!");
- fclose(fi);
- return -1;
+ printf("World: Parse Error in file %s", filename);
}
+ vector<int> vi;
- /* Load the level lines: */
+DEBUG_MSG("LLALAL");
+ if (strcmp(lisp_symbol(lisp_car(root_obj)), "level") == 0)
+ {
+ LispReader reader(lisp_cdr(root_obj));
+
+ DEBUG_MSG("TAGAF");
+ reader.read_int("width", &plevel->width);
+ reader.read_int("time", &plevel->time_left);
+ reader.read_int("bkgd_red", &plevel->bkgd_red);
+ reader.read_int("bkgd_green", &plevel->bkgd_green);
+ reader.read_int("bkgd_blue", &plevel->bkgd_blue);
+ reader.read_float("gravity", &plevel->gravity);
+ reader.read_string("name", &plevel->name);
+ reader.read_string("theme", &plevel->theme);
+ reader.read_string("music", &plevel->song_title);
+ reader.read_string("background", &plevel->bkgd_image);
+ reader.read_int_vector("tilemap", &vi);
+ }
+
+ DEBUG_MSG("LOLOL");
+
+ int i;
+ for( i = 0; i < 15; ++i)
+ plevel->tiles[i] = (unsigned int*) calloc((plevel->width +1) , sizeof(unsigned int) );
- for (y = 0; y < 15; y++)
+ i = 0;
+ int j = 0;
+ for(vector<int>::iterator it = vi.begin(); it != vi.end(); ++it, ++i)
{
- if(fgets(line, plevel->width + 5, fi) == NULL)
+
+ plevel->tiles[j][i] = (*it);
+ if(i == plevel->width)
{
- fprintf(stderr, "Level %s isn't complete!\n",plevel->name);
- free(line);
- fclose(fi);
- return -1;
+ i = 0;
+ ++j;
+ DEBUG_MSG("joa");
}
- line[strlen(line) - 1] = '\0';
- plevel->tiles[y] = (unsigned char*) strdup(line);
}
+ /* Set the global gravity to the latest loaded level's gravity */
+ gravity = plevel->gravity;
+
/* Mark the end position of this level! - Is a bit wrong here thought */
for (y = 0; y < 15; ++y)
}
}
- free(line);
fclose(fi);
return 0;
}
/* Save data for level: */
-void level_save(st_level* plevel, char * subset, int level)
+void level_save(st_level* plevel,const char * subset, int level)
{
FILE * fi;
char filename[1024];
- int y;
+ int y,i;
char str[80];
/* Save data file: */
exit(-1);
}
- fputs(plevel->name, fi);
- fputs("\n", fi);
- fputs(plevel->theme, fi);
- fputs("\n", fi);
- sprintf(str, "%d\n", plevel->time_left); /* time */
- fputs(str, fi);
- fputs(plevel->song_title, fi); /* song filename */
- fputs("\n",fi);
- fputs(plevel->bkgd_image, fi); /* background image */
- sprintf(str, "\n%d\n", plevel->bkgd_red); /* red background color */
- fputs(str, fi);
- sprintf(str, "%d\n", plevel->bkgd_green); /* green background color */
- fputs(str, fi);
- sprintf(str, "%d\n", plevel->bkgd_blue); /* blue background color */
- fputs(str, fi);
- sprintf(str, "%d\n", plevel->width); /* level width */
- fputs(str, fi);
- sprintf(str, "%2.1f\n", plevel->gravity); /* level gravity */
- fputs(str, fi);
+ /* Write header: */
+ fprintf(fi,";SuperTux-Level\n");
+ fprintf(fi,"(level\n");
+
+ fprintf(fi," (name \"%s\")\n", plevel->name.c_str());
+ fprintf(fi," (theme \"%s\")\n", plevel->theme.c_str());
+ fprintf(fi," (music \"%s\")\n", plevel->song_title.c_str());
+ fprintf(fi," (background \"%s\")\n", plevel->bkgd_image.c_str());
+ fprintf(fi," (bkgd_red %d)\n", plevel->bkgd_red);
+ fprintf(fi," (bkgd_green %d)\n", plevel->bkgd_green);
+ fprintf(fi," (bkgd_blue %d)\n", plevel->bkgd_blue);
+ fprintf(fi," (time %d)\n", plevel->time_left);
+ fprintf(fi," (width %d)\n", plevel->width);
+ fprintf(fi," (gravity %2.1f)\n", plevel->gravity);
+ fprintf(fi," (tilemap ");
+
for(y = 0; y < 15; ++y)
{
- fputs((const char*)plevel->tiles[y], fi);
- fputs("\n", fi);
+ for(i = 0; i < plevel->width; ++i)
+ fprintf(fi," %d ", plevel->tiles[y][i]);
}
+
+ fprintf( fi,")");
+ fprintf( fi,")\n");
fclose(fi);
}
for(i=0; i < 15; ++i)
free(plevel->tiles[i]);
- plevel->name[0] = '\0';
- plevel->theme[0] = '\0';
- plevel->song_title[0] = '\0';
- plevel->bkgd_image[0] = '\0';
+ plevel->name.clear();
+ plevel->theme.clear();
+ plevel->song_title.clear();
+ plevel->bkgd_image.clear();
}
/* Load graphics: */
level_load_image(&img_bkgd_tile[1][2],plevel->theme,"bkgd-12.png", USE_ALPHA);
level_load_image(&img_bkgd_tile[1][3],plevel->theme,"bkgd-13.png", USE_ALPHA);
- if(strcmp(plevel->bkgd_image,"") != 0)
+ if(!plevel->bkgd_image.empty())
{
char fname[1024];
- snprintf(fname, 1024, "%s/background/%s", st_dir, plevel->bkgd_image);
+ snprintf(fname, 1024, "%s/background/%s", st_dir, plevel->bkgd_image.c_str());
if(!faccessible(fname))
- snprintf(fname, 1024, "%s/images/background/%s", DATA_PREFIX, plevel->bkgd_image);
+ snprintf(fname, 1024, "%s/images/background/%s", DATA_PREFIX, plevel->bkgd_image.c_str());
texture_load(&img_bkgd, fname, IGNORE_ALPHA);
}
else
/* Load a level-specific graphic... */
-void level_load_image(texture_type* ptexture, char* theme, char * file, int use_alpha)
+void level_load_image(texture_type* ptexture, string theme,const char * file, int use_alpha)
{
char fname[1024];
- snprintf(fname, 1024, "%s/themes/%s/%s", st_dir, theme, file);
+ snprintf(fname, 1024, "%s/themes/%s/%s", st_dir, theme.c_str(), file);
if(!faccessible(fname))
- snprintf(fname, 1024, "%s/images/themes/%s/%s", DATA_PREFIX, theme, file);
+ snprintf(fname, 1024, "%s/images/themes/%s/%s", DATA_PREFIX, theme.c_str(), file);
texture_load(ptexture, fname, use_alpha);
}
char * song_subtitle;
song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
- strlen(plevel->song_title) + 8));
- sprintf(song_path, "%s/music/%s", DATA_PREFIX, plevel->song_title);
+ strlen(plevel->song_title.c_str()) + 8));
+ sprintf(song_path, "%s/music/%s", DATA_PREFIX, plevel->song_title.c_str());
level_song = load_song(song_path);
free(song_path);
song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
- strlen(plevel->song_title) + 8 + 5));
- song_subtitle = strdup(plevel->song_title);
+ strlen(plevel->song_title.c_str()) + 8 + 5));
+ song_subtitle = strdup(plevel->song_title.c_str());
strcpy(strstr(song_subtitle, "."), "\0");
- sprintf(song_path, "%s/music/%s-fast%s", DATA_PREFIX, song_subtitle, strstr(plevel->song_title, "."));
+ sprintf(song_path, "%s/music/%s-fast%s", DATA_PREFIX, song_subtitle, strstr(plevel->song_title.c_str(), "."));
level_song_fast = load_song(song_path);
free(song_subtitle);
free(song_path);
//
// C Interface: level
//
-// Description:
+// Description:
//
//
// Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2003
#ifndef SUPERTUX_LEVEL_H
#define SUPERTUX_LEVEL_H
+#include <string>
#include "texture.h"
#include "lispreader.h"
/* This type holds meta-information about a level-subset. */
/* It could be extended to handle manipulation of subsets. */
-typedef struct st_subset
+class st_subset
{
- char *name;
- char *title;
- char *description;
+ public:
+ st_subset();
+ static void create(const std::string& subset_name);
+ void load(char *subset);
+ void save();
+ void free();
+
+ std::string name;
+ std::string title;
+ std::string description;
texture_type image;
int levels;
- } st_subset;
+
+ private:
+ void parse(lisp_object_t* cursor);
+ };
-void subset_init(st_subset* st_subset);
-void subset_parse(st_subset* st_subset, lisp_object_t* cursor);
-void subset_load(st_subset* st_subset, char *subset);
-void subset_save(st_subset* st_subset);
-void subset_free(st_subset* st_subset);
-
#define LEVEL_NAME_MAX 20
typedef struct st_level /*It is easier to read the sources IMHO, if we don't write something like int a,b,c; */
{
- char name[LEVEL_NAME_MAX];
- char theme[100];
- char song_title[100];
- char bkgd_image[100];
- unsigned char* tiles[15];
+ std::string name;
+ std::string theme;
+ std::string song_title;
+ std::string bkgd_image;
+ unsigned int* tiles[15];
int time_left;
int bkgd_red;
int bkgd_green;
int bkgd_blue;
int width;
float gravity;
- } st_level;
-
+ }
+st_level;
+
extern texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2];
-
-int level_load(st_level* plevel, char * subset, int level);
+
+void level_default(st_level* plevel);
+int level_load(st_level* plevel, const char * subset, int level);
+void level_parse(st_level* plevel, lisp_object_t* cursor);
int level_load(st_level* plevel, const char* filename);
-void level_save(st_level* plevel, char * subset, int level);
+void level_save(st_level* plevel, const char * subset, int level);
void level_free(st_level* plevel);
void level_load_gfx(st_level* plevel);
void level_free_gfx();
-void level_load_image(texture_type* ptexture, char* theme, char * file, int use_alpha);
+void level_load_image(texture_type* ptexture, std::string theme, const char * file, int use_alpha);
void level_change(st_level* plevel, float x, float y, unsigned char c);
void level_load_song(st_level* plevel);
void level_free_song(void);
void le_showhelp();
void le_set_defaults(void);
void le_activate_bad_guys(void);
-void le_new_subset(char *subset_name);
void le_highlight_selection();
void apply_level_settings_menu();
void update_subset_settings_menu();
void save_subset_settings_menu();
-void le_update_buttons(char*);
+void le_update_buttons(const char*);
/* leveleditor internals */
static string_list_type level_subsets;
static int le_level_changed; /* if changes, ask for saving, when quiting*/
-static int pos_x, cursor_x, cursor_y, cursor_tile, fire;
+static int pos_x, cursor_x, cursor_y, fire;
static int le_level;
static st_level* le_current_level;
static st_subset le_level_subset;
default:
if(i != -1)
{
- subset_load(&le_level_subset,level_subsets.item[i-2]);
+ le_level_subset.load(level_subsets.item[i-2]);
leveleditor_menu.item[3].kind = MN_GOTO;
le_level = 1;
arrays_init();
loadshared();
- le_current_level = (st_level*) malloc(sizeof(st_level));
- if(level_load(le_current_level, le_level_subset.name, le_level) != 0)
+ le_current_level = new st_level;
+ if(level_load(le_current_level, le_level_subset.name.c_str(), le_level) != 0)
{
le_quit();
return 1;
}
- le_update_buttons(le_current_level->theme);
+ le_update_buttons(le_current_level->theme.c_str());
le_set_defaults();
level_load_gfx(le_current_level);
le_activate_bad_guys();
switch (i = menu_check(&subset_new_menu))
{
case 3:
- le_new_subset(subset_new_menu.item[2].input);
- subset_load(&le_level_subset,subset_new_menu.item[2].input);
+ st_subset::create(subset_new_menu.item[2].input);
+ le_level_subset.load(subset_new_menu.item[2].input);
leveleditor_menu.item[3].kind = MN_GOTO;
le_level = 1;
arrays_init();
loadshared();
le_current_level = (st_level*) malloc(sizeof(st_level));
- if(level_load(le_current_level, le_level_subset.name, le_level) != 0)
+ if(level_load(le_current_level, le_level_subset.name.c_str(), le_level) != 0)
{
le_quit();
return 1;
}
- le_update_buttons(le_current_level->theme);
+ le_update_buttons(le_current_level->theme.c_str());
le_set_defaults();
level_load_gfx(le_current_level);
le_activate_bad_guys();
}
else if(current_menu == &subset_settings_menu)
{
- if(strcmp(le_level_subset.title,subset_settings_menu.item[2].input) == 0 && strcmp(le_level_subset.description,subset_settings_menu.item[3].input) == 0 )
+ if(le_level_subset.title.compare(subset_settings_menu.item[2].input) == 0 && le_level_subset.description.compare(subset_settings_menu.item[3].input) == 0 )
subset_settings_menu.item[5].kind = MN_DEACTIVE;
else
subset_settings_menu.item[5].kind = MN_ACTION;
return done;
}
-void le_default_level(st_level* plevel)
-{
- int i,y;
- strcpy(plevel->name,"UnNamed");
- strcpy(plevel->theme,"antarctica");
- strcpy(plevel->song_title,"Mortimers_chipdisko.mod");
- strcpy(plevel->bkgd_image,"arctis.png");
- plevel->width = 21;
- plevel->time_left = 100;
- plevel->gravity = 10.;
- plevel->bkgd_red = 0;
- plevel->bkgd_green = 0;
- plevel->bkgd_blue = 0;
-
- for(i = 0; i < 15; ++i)
- {
- plevel->tiles[i] = (unsigned char*) malloc((plevel->width+1)*sizeof(unsigned char));
- plevel->tiles[i][plevel->width] = (unsigned char) '\0';
- for(y = 0; y < plevel->width; ++y)
- plevel->tiles[i][y] = (unsigned char) '.';
- plevel->tiles[i][plevel->width] = (unsigned char) '\0';
- }
-}
-
-void le_new_subset(char *subset_name)
-{
- st_level new_lev;
- st_subset new_subset;
- new_subset.name = (char*) malloc((strlen(subset_name)+1)*sizeof(char));
- strcpy(new_subset.name,subset_name);
- new_subset.title = (char*) malloc((strlen("Unknown Title")+1)*sizeof(char));
- strcpy(new_subset.title,"Unknown Title");
- new_subset.description = (char*) malloc((strlen("No description so far.")+1)*sizeof(char));
- strcpy(new_subset.description,"No description so far.");
- subset_save(&new_subset);
- le_default_level(&new_lev);
- level_save(&new_lev,subset_name,1);
-}
-void le_update_buttons(char *theme)
+void le_update_buttons(const char *theme)
{
int i;
char filename[1024];
int le_init()
{
- int i,j;
- char str[80];
+ int i;
char filename[1024];
SDLKey key;
string_list_type fgd_files;
done = 0;
le_frame = 0; /* support for frames in some tiles, like waves and bad guys */
le_level_changed = NO;
-
- subset_init(&le_level_subset);
-
le_current_level = NULL;
le_current_tile = '.';
le_fgd_panel.item[16].bkgd = &le_fgd_panel.item[14].icon;
le_fgd_panel.item[17].bkgd = &le_fgd_panel.item[15].icon;
- bad_files;
string_list_init(&bad_files);
string_list_add_item(&bad_files,"bsod-left-0.png");
string_list_add_item(&bad_files,"laptop-left-0.png");
char str[80];
int i;
- menu_item_change_input(&level_settings_menu.item[2], le_current_level->name);
+ menu_item_change_input(&level_settings_menu.item[2], le_current_level->name.c_str());
sprintf(str,"%d",le_current_level->width);
string_list_copy(level_settings_menu.item[3].list, dsubdirs("images/themes", "solid0.png"));
string_list_copy(level_settings_menu.item[4].list, dfiles("music/",NULL, "-fast"));
string_list_copy(level_settings_menu.item[5].list, dfiles("images/background",NULL, NULL));
string_list_add_item(level_settings_menu.item[5].list,"");
- if((i = string_list_find(level_settings_menu.item[3].list,le_current_level->theme)) != -1)
+ if((i = string_list_find(level_settings_menu.item[3].list,le_current_level->theme.c_str())) != -1)
level_settings_menu.item[3].list->active_item = i;
- if((i = string_list_find(level_settings_menu.item[4].list,le_current_level->song_title)) != -1)
+ if((i = string_list_find(level_settings_menu.item[4].list,le_current_level->song_title.c_str())) != -1)
level_settings_menu.item[4].list->active_item = i;
- if((i = string_list_find(level_settings_menu.item[5].list,le_current_level->bkgd_image)) != -1)
+ if((i = string_list_find(level_settings_menu.item[5].list,le_current_level->bkgd_image.c_str())) != -1)
level_settings_menu.item[5].list->active_item = i;
menu_item_change_input(&level_settings_menu.item[6], str);
void update_subset_settings_menu()
{
- menu_item_change_input(&subset_settings_menu.item[2], le_level_subset.title);
- menu_item_change_input(&subset_settings_menu.item[3], le_level_subset.description);
+ menu_item_change_input(&subset_settings_menu.item[2], le_level_subset.title.c_str());
+ menu_item_change_input(&subset_settings_menu.item[3], le_level_subset.description.c_str());
}
void apply_level_settings_menu()
int i,y,j;
i = NO;
- strcpy(le_current_level->name,level_settings_menu.item[2].input);
+ le_current_level->name = level_settings_menu.item[2].input;
- if(strcmp(le_current_level->bkgd_image,string_list_active(level_settings_menu.item[5].list)) != 0)
+ if(le_current_level->bkgd_image.compare(string_list_active(level_settings_menu.item[5].list)) != 0)
{
- strcpy(le_current_level->bkgd_image,string_list_active(level_settings_menu.item[5].list));
+ le_current_level->bkgd_image = string_list_active(level_settings_menu.item[5].list);
i = YES;
}
- if(strcmp(le_current_level->theme,string_list_active(level_settings_menu.item[3].list)) != 0)
+ if(le_current_level->theme.compare(string_list_active(level_settings_menu.item[3].list)) != 0)
{
- strcpy(le_current_level->theme,string_list_active(level_settings_menu.item[3].list));
- le_update_buttons(le_current_level->theme);
+ le_current_level->theme = string_list_active(level_settings_menu.item[3].list);
+ le_update_buttons(le_current_level->theme.c_str());
i = YES;
}
level_load_gfx(le_current_level);
}
- strcpy(le_current_level->song_title,string_list_active(level_settings_menu.item[4].list));
+ le_current_level->song_title = string_list_active(level_settings_menu.item[4].list);
i = le_current_level->width;
le_current_level->width = atoi(level_settings_menu.item[6].input);
le_current_level->width = 21;
for(y = 0; y < 15; ++y)
{
- le_current_level->tiles[y] = (unsigned char*) realloc(le_current_level->tiles[y],(le_current_level->width+1)*sizeof(unsigned char));
- le_current_level->tiles[y][le_current_level->width] = (unsigned char) '\0';
+ le_current_level->tiles[y] = (unsigned int*) realloc(le_current_level->tiles[y],(le_current_level->width+1)*sizeof(unsigned int));
+ le_current_level->tiles[y][le_current_level->width] = (unsigned int) '\0';
}
}
else if(le_current_level->width > i)
{
for(y = 0; y < 15; ++y)
{
- le_current_level->tiles[y] = (unsigned char*) realloc(le_current_level->tiles[y],(le_current_level->width+1)*sizeof(unsigned char));
+ le_current_level->tiles[y] = (unsigned int*) realloc(le_current_level->tiles[y],(le_current_level->width+1)*sizeof(unsigned int));
for(j = 0; j < le_current_level->width - i; ++j)
- le_current_level->tiles[y][i+j] = (unsigned char) '.';
- le_current_level->tiles[y][le_current_level->width] = (unsigned char) '\0';
+ le_current_level->tiles[y][i+j] = (unsigned int) '.';
+ le_current_level->tiles[y][le_current_level->width] = (unsigned int) '\0';
}
}
le_current_level->time_left = atoi(level_settings_menu.item[7].input);
void save_subset_settings_menu()
{
- free(le_level_subset.title);
- le_level_subset.title = (char*) malloc(sizeof(char)*(strlen(subset_settings_menu.item[2].input)+1));
- strcpy(le_level_subset.title,subset_settings_menu.item[2].input);
- free(le_level_subset.description);
- le_level_subset.description = (char*) malloc(sizeof(char)*(strlen(subset_settings_menu.item[3].input)+1));
- strcpy(le_level_subset.description,subset_settings_menu.item[3].input);
- subset_save(&le_level_subset);
+ le_level_subset.title = subset_settings_menu.item[2].input;
+ le_level_subset.description = subset_settings_menu.item[3].input;
+ le_level_subset.save();
}
void le_goto_level(int levelnb)
arrays_init();
level_free(le_current_level);
- if(level_load(le_current_level, le_level_subset.name, levelnb) != 0)
+ if(level_load(le_current_level, le_level_subset.name.c_str(), levelnb) != 0)
{
- level_load(le_current_level, le_level_subset.name, le_level);
+ level_load(le_current_level, le_level_subset.name.c_str(), le_level);
}
else
{
le_set_defaults();
- le_update_buttons(le_current_level->theme);
+ le_update_buttons(le_current_level->theme.c_str());
level_free_gfx();
level_load_gfx(le_current_level);
void le_drawlevel()
{
int y,x,i,s;
- static char str[LEVEL_NAME_MAX];
/* Draw the real background */
if(le_current_level->bkgd_image[0] != '\0')
le_testlevel();
button_event(&le_save_level_bt,&event);
if(button_get_state(&le_save_level_bt) == BN_CLICKED)
- level_save(le_current_level,le_level_subset.name,le_level);
+ level_save(le_current_level,le_level_subset.name.c_str(),le_level);
button_event(&le_next_level_bt,&event);
if(button_get_state(&le_next_level_bt) == BN_CLICKED)
{
switch(event.key.keysym.sym)
{
case SDLK_y:
- le_default_level(&new_lev);
- level_save(&new_lev,le_level_subset.name,++le_level);
+ level_default(&new_lev);
+ level_save(&new_lev,le_level_subset.name.c_str(),++le_level);
le_level_subset.levels = le_level;
le_goto_level(le_level);
d = 1;
break;
case SDLK_n:
d = 1;
+ break;
+ default:
break;
}
break;
void le_highlight_selection()
{
- int x,y,i;
int x1, x2, y1, y2;
if(selection.x1 < selection.x2)
void le_showhelp()
{
SDL_Event event;
- int i, done;
+ unsigned int i, done;
char *text[] = {
" - This is SuperTux's built-in level editor -",
"It has been designed to be light and easy to use from the start.",
int type;
int i;
lisp_object_t *pattern;
-
+ type = -1;
+
if (lisp_type(lisp_car(*obj)) != LISP_TYPE_SYMBOL)
return 0;
}
bool
+LispReader::read_char_vector (const char* name, std::vector<char>* vec)
+{
+ lisp_object_t* obj = search_for (name);
+ if (obj)
+ {
+ while(!lisp_nil_p(obj))
+ {
+ vec->push_back(*lisp_string(lisp_car(obj)));
+ obj = lisp_cdr(obj);
+ }
+ return true;
+ }
+ return false;
+}
+
+bool
LispReader::read_string (const char* name, std::string* str)
{
lisp_object_t* obj = search_for (name);
if (obj)
{
- *str = lisp_string(lisp_car(obj));
+
+ *str = lisp_string(lisp_car(obj));
return true;
}
return false;
LispReader (lisp_object_t* l);
bool read_int_vector (const char* name, std::vector<int>* vec);
+ bool read_char_vector (const char* name, std::vector<char>* vec);
bool read_string (const char* name, std::string* str);
bool read_int (const char* name, int* i);
bool read_float (const char* name, float* f);
return pnew_item;
}
-void menu_item_change_text(menu_item_type* pmenu_item, char *text)
+void menu_item_change_text(menu_item_type* pmenu_item,const char *text)
{
if(text)
{
strcpy(pmenu_item->text,text);
}
}
-void menu_item_change_input(menu_item_type* pmenu_item, char *text)
+void menu_item_change_input(menu_item_type* pmenu_item,const char *text)
{
if(text)
{
menu_item_type;
menu_item_type* menu_item_create(int kind, char *text, int init_toggle, void* target_menu);
-void menu_item_change_text(menu_item_type* pmenu_item, char *text);
-void menu_item_change_input(menu_item_type* pmenu_item, char *text);
+void menu_item_change_text(menu_item_type* pmenu_item, const char *text);
+void menu_item_change_input(menu_item_type* pmenu_item, const char *text);
typedef struct menu_type
{
return - (pphysic->start_vy - gravity* ((float)(st_get_ticks() - pphysic->start_time))/1000.);
else if(pphysic->state == PH_HA)
return - (pphysic->start_vx - pphysic->acceleration * ((float)(st_get_ticks() - pphysic->start_time))/1000.);
+ else
+ return 0;
}
float physic_get_max_distance(physic_type* pphysic)
void player_action(player_type* pplayer)
{
- int i, jumped_in_solid;
+ int jumped_in_solid;
jumped_in_solid = NO;
/* --- HANDLE TUX! --- */
if (player_on_ground(pplayer))
{
physic_init(&pplayer->vphysic);
- pplayer->jumping == NO;
+ pplayer->jumping = NO;
}
else
{
void usage(char * prog, int ret);
/* Does the given file exist and is it accessible? */
-int faccessible(char *filename)
+int faccessible(const char *filename)
{
struct stat filestat;
if (stat(filename, &filestat) == -1)
}
/* Can we write to this location? */
-int fwriteable(char *filename)
+int fwriteable(const char *filename)
{
FILE* fi;
fi = fopen(filename, "wa");
}
/* Makes sure a directory is created in either the SuperTux base directory or the SuperTux base directory.*/
-int fcreatedir(char* relative_dir)
+int fcreatedir(const char* relative_dir)
{
char path[1024];
snprintf(path, 1024, "%s/%s/", st_dir, relative_dir);
/* Get all names of sub-directories in a certain directory. */
/* Returns the number of sub-directories found. */
/* Note: The user has to free the allocated space. */
-string_list_type dsubdirs(char *rel_path, char* expected_file)
+string_list_type dsubdirs(const char *rel_path,const char* expected_file)
{
DIR *dirStructP;
struct dirent *direntp;
- int i = 0;
string_list_type sdirs;
char filename[1024];
char path[1024];
return sdirs;
}
-string_list_type dfiles(char *rel_path, char* glob, char* exception_str)
+string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str)
{
DIR *dirStructP;
struct dirent *direntp;
- int i = 0;
string_list_type sdirs;
- char filename[1024];
char path[1024];
string_list_init(&sdirs);
/* --- ABORT! --- */
-void st_abort(char * reason, char * details)
+void st_abort(const char * reason,const char * details)
{
fprintf(stderr, "\nError: %s\n%s\n\n", reason, details);
st_shutdown();
#include "sound.h"
#include "type.h"
-int faccessible(char *filename);
-int fcreatedir(char* relative_dir);
-int fwriteable(char *filename);
-string_list_type dsubdirs(char *rel_path, char* expected_file);
-string_list_type dfiles(char *rel_path, char* glob, char* exception_str);
+int faccessible(const char *filename);
+int fcreatedir(const char* relative_dir);
+int fwriteable(const char *filename);
+string_list_type dsubdirs(const char *rel_path, const char* expected_file);
+string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str);
void free_strings(char **strings, int num);
void st_directory_setup(void);
void st_general_setup(void);
void st_joystick_setup(void);
void st_shutdown(void);
void st_menu(void);
-void st_abort(char * reason, char * details);
+void st_abort( const char * reason, const char * details);
void process_options_menu(void);
void process_save_load_game_menu(int save);
void update_load_save_game_menu(menu_type* pmenu, int load);
#include "screen.h"
#include "text.h"
-void text_load(text_type* ptext, char* file, int kind, int w, int h)
+void text_load(text_type* ptext,const char* file, int kind, int w, int h)
{
- int x, y;
int mx, my;
SDL_Surface *conv;
int pixels;
SDL_FreeSurface(conv);
}
-void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update)
+void text_draw(text_type* ptext,const char* text, int x, int y, int shadowsize, int update)
{
if(text != NULL)
{
}
}
-void text_draw_chars(text_type* ptext, texture_type* pchars, char* text, int x, int y, int update)
+void text_draw_chars(text_type* ptext, texture_type* pchars,const char* text, int x, int y, int update)
{
int i,j,len;
int w, h;
}
}
-void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update)
+void text_drawf(text_type* ptext,const char* text, int x, int y, int halign, int valign, int shadowsize, int update)
{
if(text != NULL)
{
void text_free(text_type* ptext)
{
- int c;
if(ptext->kind == TEXT_TEXT)
texture_free(&ptext->chars);
else if(ptext->kind == TEXT_NUM)
/* --- ERASE TEXT: --- */
-void erasetext(text_type* ptext, char * text, int x, int y, texture_type * ptexture, int update, int shadowsize)
+void erasetext(text_type* ptext,const char * text, int x, int y, texture_type * ptexture, int update, int shadowsize)
{
SDL_Rect dest;
/* --- ERASE CENTERED TEXT: --- */
-void erasecenteredtext(text_type* ptext, char * text, int y, texture_type * ptexture, int update, int shadowsize)
+void erasecenteredtext(text_type* ptext,const char * text, int y, texture_type * ptexture, int update, int shadowsize)
{
erasetext(ptext, text, screen->w / 2 - (strlen(text) * 8), y, ptexture, update, shadowsize);
}
A_NONE
};
-void text_load(text_type* ptext, char* file, int kind, int w, int h);
-void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update);
-void text_draw_chars(text_type* ptext, texture_type* pchars, char* text, int x, int y, int update);
-void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update);
+void text_load(text_type* ptext, const char* file, int kind, int w, int h);
+void text_draw(text_type* ptext, const char* text, int x, int y, int shadowsize, int update);
+void text_draw_chars(text_type* ptext, texture_type* pchars, const char* text, int x, int y, int update);
+void text_drawf(text_type* ptext, const char* text, int x, int y, int halign, int valign, int shadowsize, int update);
void text_free(text_type* ptext);
-void erasetext(text_type* ptext, char * text, int x, int y, texture_type * surf, int update, int shadowsize);
-void erasecenteredtext(text_type* ptext, char * text, int y, texture_type * surf, int update, int shadowsize);
+void erasetext(text_type* ptext, const char * text, int x, int y, texture_type * surf, int update, int shadowsize);
+void erasecenteredtext(text_type* ptext, const char * text, int y, texture_type * surf, int update, int shadowsize);
#endif /*SUPERTUX_TEXT_H*/
#include "setup.h"
#include "texture.h"
-void (*texture_load) (texture_type* ptexture, char * file, int use_alpha);
-void (*texture_load_part) (texture_type* ptexture, char * file, int x, int y, int w, int h, int use_alpha);
+void (*texture_load) (texture_type* ptexture,const char * file, int use_alpha);
+void (*texture_load_part) (texture_type* ptexture,const char * file, int x, int y, int w, int h, int use_alpha);
void (*texture_free) (texture_type* ptexture);
void (*texture_draw) (texture_type* ptexture, float x, float y, int update);
void (*texture_draw_bg) (texture_type* ptexture, int update);
}
#ifndef NOOPENGL
-void texture_load_gl(texture_type* ptexture, char * file, int use_alpha)
+void texture_load_gl(texture_type* ptexture,const char * file, int use_alpha)
{
texture_load_sdl(ptexture,file,use_alpha);
texture_create_gl(ptexture->sdl_surface,&ptexture->gl_texture);
}
-void texture_load_part_gl(texture_type* ptexture, char * file, int x, int y, int w, int h, int use_alpha)
+void texture_load_part_gl(texture_type* ptexture,const char * file, int x, int y, int w, int h, int use_alpha)
{
texture_load_part_sdl(ptexture,file,x,y,w,h,use_alpha);
texture_create_gl(ptexture->sdl_surface,&ptexture->gl_texture);
}
#endif
-void texture_load_sdl(texture_type* ptexture, char * file, int use_alpha)
+void texture_load_sdl(texture_type* ptexture,const char * file, int use_alpha)
{
SDL_Surface * temp;
}
-void texture_load_part_sdl(texture_type* ptexture, char * file, int x, int y, int w, int h, int use_alpha)
+void texture_load_part_sdl(texture_type* ptexture,const char * file, int x, int y, int w, int h, int use_alpha)
{
SDL_Rect src;
} texture_type;
void texture_setup(void);
-extern void (*texture_load) (texture_type* ptexture, char * file, int use_alpha);
-extern void (*texture_load_part) (texture_type* ptexture, char * file, int x, int y, int w, int h, int use_alpha);
+extern void (*texture_load) (texture_type* ptexture,const char * file, int use_alpha);
+extern void (*texture_load_part) (texture_type* ptexture,const char * file, int x, int y, int w, int h, int use_alpha);
extern void (*texture_free) (texture_type* ptexture);
extern void (*texture_draw) (texture_type* ptexture, float x, float y, int update);
extern void (*texture_draw_bg) (texture_type* ptexture, int update);
extern void (*texture_draw_part) (texture_type* ptexture, float sx, float sy, float x, float y, float w, float h, int update);
-void texture_load_sdl(texture_type* ptexture, char * file, int use_alpha);
-void texture_load_part_sdl(texture_type* ptexture, char * file, int x, int y, int w, int h, int use_alpha);
+void texture_load_sdl(texture_type* ptexture,const char * file, int use_alpha);
+void texture_load_part_sdl(texture_type* ptexture,const char * file, int x, int y, int w, int h, int use_alpha);
void texture_free_sdl(texture_type* ptexture);
void texture_draw_sdl(texture_type* ptexture, float x, float y, int update);
void texture_draw_bg_sdl(texture_type* ptexture, int update);
void texture_draw_part_sdl(texture_type* ptexture,float sx, float sy, float x, float y, float w, float h, int update);
void texture_from_sdl_surface(texture_type* ptexture, SDL_Surface * sdl_surf, int use_alpha);
#ifndef NOOPENGL
-void texture_load_gl(texture_type* ptexture, char * file, int use_alpha);
-void texture_load_part_gl(texture_type* ptexture, char * file, int x, int y, int w, int h, int use_alpha);
+void texture_load_gl(texture_type* ptexture,const char * file, int use_alpha);
+void texture_load_part_gl(texture_type* ptexture,const char * file, int x, int y, int w, int h, int use_alpha);
void texture_free_gl(texture_type* ptexture);
void texture_draw_gl(texture_type* ptexture, float x, float y, int update);
void texture_draw_bg_gl(texture_type* ptexture, int update);
return (ptimer->get_ticks() - ptimer->time);
}
-int timer_fwrite(timer_type* ptimer, FILE* fi)
+void timer_fwrite(timer_type* ptimer, FILE* fi)
{
unsigned int diff_ticks;
int tick_mode;
fwrite(&tick_mode,sizeof(unsigned int),1,fi);
}
-int timer_fread(timer_type* ptimer, FILE* fi)
+void timer_fread(timer_type* ptimer, FILE* fi)
{
unsigned int diff_ticks;
int tick_mode;
======================================================================*/
int timer_get_left(timer_type* ptimer);
int timer_get_gone(timer_type* ptimer);
-int timer_fwrite(timer_type* ptimer, FILE* fi);
-int timer_fread(timer_type* ptimer, FILE* fi);
+void timer_fwrite(timer_type* ptimer, FILE* fi);
+void timer_fread(timer_type* ptimer, FILE* fi);
#endif /*SUPERTUX_TIMER_H*/
st_subset subset;
level_subsets = dsubdirs("/levels", "info");
- subset_init(&subset);
-
/* Reset menu variables */
menu_reset();
menu_set_current(&main_menu);
i = 0;
if(level_subsets.num_items != 0)
{
- subset_load(&subset,level_subsets.item[0]);
+ subset.load(level_subsets.item[0]);
while(!done)
{
texture_draw(&img_choose_subset,(screen->w - img_choose_subset.w) / 2, 0, NO_UPDATE);
if(level_subsets.num_items > 1)
{
if(i > 0)
- texture_draw(&arrow_left,(screen->w / 2) - ((strlen(subset.title)+2)*16)/2,20,NO_UPDATE);
+ texture_draw(&arrow_left,(screen->w / 2) - ((subset.title.length()+2)*16)/2,20,NO_UPDATE);
if(i < level_subsets.num_items-1)
- texture_draw(&arrow_right,(screen->w / 2) + ((strlen(subset.title))*16)/2,20,NO_UPDATE);
+ texture_draw(&arrow_right,(screen->w / 2) + ((subset.description.length())*16)/2,20,NO_UPDATE);
}
- text_drawf(&gold_text, subset.title, 0, 20, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
- text_drawf(&gold_text, subset.description, 20, -20, A_HMIDDLE, A_BOTTOM, 1, NO_UPDATE);
+ text_drawf(&gold_text, subset.title.c_str(), 0, 20, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
+ text_drawf(&gold_text, subset.description.c_str(), 20, -20, A_HMIDDLE, A_BOTTOM, 1, NO_UPDATE);
}
updatescreen();
SDL_Delay(50);
if(i > 0)
{
--i;
- subset_free(&subset);
- subset_load(&subset,level_subsets.item[i]);
+ subset.free();
+ subset.load(level_subsets.item[i]);
}
}
else if(key == SDLK_RIGHT)
if(i < level_subsets.num_items -1)
{
++i;
- subset_free(&subset);
- subset_load(&subset,level_subsets.item[i]);
+ subset.free();
+ subset.load(level_subsets.item[i]);
}
}
else if(key == SDLK_SPACE || key == SDLK_RETURN)
{
done = YES;
- quit = gameloop(subset.name,1,ST_GL_PLAY);
- subset_free(&subset);
+ quit = gameloop(subset.name.c_str(),1,ST_GL_PLAY);
+ subset.free();
}
else if(key == SDLK_ESCAPE)
{
}
fclose(fi);
}
- else
+ else
{
- string_list_add_item(&names,"Credits were not found!");
- string_list_add_item(&names,"Shame on the guy, who");
- string_list_add_item(&names,"forgot to include them");
- string_list_add_item(&names,"in your SuperTux distribution.");
+ string_list_add_item(&names,"Credits were not found!");
+ string_list_add_item(&names,"Shame on the guy, who");
+ string_list_add_item(&names,"forgot to include them");
+ string_list_add_item(&names,"in your SuperTux distribution.");
}
text_drawf(&blue_text, names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
}
}
-
-
+
+
texture_draw_part(&bkg_title, 0, 0, 0, 0, 640, 130, NO_UPDATE);
flipscreen();
return "";
}
-void string_list_add_item(string_list_type* pstring_list, char* str)
+void string_list_add_item(string_list_type* pstring_list,const char* str)
{
char *pnew_string;
pnew_string = (char*) malloc(sizeof(char)*(strlen(str)+1));
string_list_add_item(pstring_list,pstring_list_orig.item[i]);
}
-int string_list_find(string_list_type* pstring_list, char* str)
+int string_list_find(string_list_type* pstring_list,const char* str)
{
int i;
for(i = 0; i < pstring_list->num_items; ++i)
void string_list_sort(string_list_type* pstring_list)
{
int i,j,y;
- short int sorter[pstring_list->num_items];
for(j = 0; j < pstring_list->num_items; ++j)
for(i = 0; i < pstring_list->num_items-1; ++i)
void string_list_init(string_list_type* pstring_list);
char* string_list_active(string_list_type* pstring_list);
void string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig);
-int string_list_find(string_list_type* pstring_list, char* str);
+int string_list_find(string_list_type* pstring_list, const char* str);
void string_list_sort(string_list_type* pstring_list);
-void string_list_add_item(string_list_type* pstring_list, char* str);
+void string_list_add_item(string_list_type* pstring_list, const char* str);
void string_list_free(string_list_type* pstring_list);
#endif /*SUPERTUX_TYPE_H*/