- Cleanups
authorTobias Gläßer <tobi.web@gmx.de>
Tue, 27 Jul 2004 19:31:39 +0000 (19:31 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Tue, 27 Jul 2004 19:31:39 +0000 (19:31 +0000)
- Got rid of string_list_type (caution! Bugs with the replacement solutions are likely to happen, that will be fixed)

SVN-Revision: 1640

15 files changed:
lib/app/globals.cpp
lib/app/globals.h
lib/app/setup.cpp
lib/app/setup.h
lib/gui/menu.cpp
lib/gui/menu.h
lib/special/stringlist.cpp [deleted file]
lib/special/stringlist.h [deleted file]
lib/utils/configfile.cpp
src/gameloop.cpp
src/level_subset.cpp
src/leveleditor.cpp
src/leveleditor.h
src/title.cpp
src/worldmap.cpp

index 251fc29..e731b29 100644 (file)
@@ -50,7 +50,6 @@ bool use_joystick;
 bool use_fullscreen;
 bool debug_mode;
 bool show_fps;
-float game_speed = 1.0f;
 
 int joystick_num = 0;
 char* level_startup_file = 0;
index 6f727b7..6de62d6 100644 (file)
@@ -74,7 +74,6 @@ namespace SuperTux
   extern char* st_dir;
   extern char* st_save_dir;
   
-  extern float game_speed;
   extern SDL_Joystick * js;
 
   int wait_for_event(SDL_Event& event,unsigned int min_delay = 0, unsigned int max_delay = 0, bool empty_events = false);
index 1a56682..22a23a6 100644 (file)
@@ -119,15 +119,14 @@ int FileSystem::fcreatedir(const char* 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 FileSystem::dsubdirs(const char *rel_path,const  char* expected_file)
+std::set<std::string> FileSystem::dsubdirs(const char *rel_path,const  char* expected_file)
 {
   DIR *dirStructP;
   struct dirent *direntp;
-  string_list_type sdirs;
+  std::set<std::string> sdirs;
   char filename[1024];
   char path[1024];
 
-  string_list_init(&sdirs);
   sprintf(path,"%s/%s",st_dir,rel_path);
   if((dirStructP = opendir(path)) != NULL)
     {
@@ -147,7 +146,7 @@ string_list_type FileSystem::dsubdirs(const char *rel_path,const  char* expected
                     continue;
                 }
 
-              string_list_add_item(&sdirs,direntp->d_name);
+             sdirs.insert(direntp->d_name);
             }
         }
       closedir(dirStructP);
@@ -180,7 +179,7 @@ string_list_type FileSystem::dsubdirs(const char *rel_path,const  char* expected
                     }
                 }
 
-              string_list_add_item(&sdirs,direntp->d_name);
+             sdirs.insert(direntp->d_name);
             }
         }
       closedir(dirStructP);
@@ -189,14 +188,13 @@ string_list_type FileSystem::dsubdirs(const char *rel_path,const  char* expected
   return sdirs;
 }
 
-string_list_type FileSystem::dfiles(const char *rel_path, const  char* glob, const  char* exception_str)
+std::set<std::string> FileSystem::dfiles(const char *rel_path, const  char* glob, const  char* exception_str)
 {
   DIR *dirStructP;
   struct dirent *direntp;
-  string_list_type sdirs;
+  std::set<std::string> sdirs;
   char path[1024];
 
-  string_list_init(&sdirs);
   sprintf(path,"%s/%s",st_dir,rel_path);
   if((dirStructP = opendir(path)) != NULL)
     {
@@ -218,7 +216,7 @@ string_list_type FileSystem::dfiles(const char *rel_path, const  char* glob, con
                 if(strstr(direntp->d_name,glob) == NULL)
                   continue;
 
-              string_list_add_item(&sdirs,direntp->d_name);
+             sdirs.insert(direntp->d_name);
             }
         }
       closedir(dirStructP);
@@ -245,7 +243,7 @@ string_list_type FileSystem::dfiles(const char *rel_path, const  char* glob, con
                 if(strstr(direntp->d_name,glob) == NULL)
                   continue;
 
-              string_list_add_item(&sdirs,direntp->d_name);
+             sdirs.insert(direntp->d_name);
             }
         }
       closedir(dirStructP);
@@ -844,9 +842,9 @@ void usage(char * prog, int ret)
   exit(ret);
 }
 
-std::vector<std::string> FileSystem::read_directory(const std::string& pathname)
+std::set<std::string> FileSystem::read_directory(const std::string& pathname)
 {
-  std::vector<std::string> dirnames;
+  std::set<std::string> dirnames;
   
   DIR* dir = opendir(pathname.c_str());
   if (dir)
@@ -855,7 +853,7 @@ std::vector<std::string> FileSystem::read_directory(const std::string& pathname)
       
       while((direntp = readdir(dir)))
         {
-          dirnames.push_back(direntp->d_name);
+          dirnames.insert(direntp->d_name);
         }
       
       closedir(dir);
index 2eebb38..4c91464 100644 (file)
@@ -21,6 +21,7 @@
 #define SUPERTUX_SETUP_H
 
 #include <vector>
+#include <set>
 #include <string>
 #include "../gui/menu.h"
 #include "../special/base.h"
@@ -33,9 +34,9 @@ struct FileSystem
     static int faccessible(const char *filename);
     static int fcreatedir(const char* relative_dir);
     static int fwriteable(const char *filename);
-    static std::vector<std::string> read_directory(const std::string& pathname);
-    static string_list_type dsubdirs(const char *rel_path, const char* expected_file);
-    static string_list_type dfiles(const char *rel_path, const char* glob, const char* exception_str);
+    static std::set<std::string> read_directory(const std::string& pathname);
+    static std::set<std::string> dsubdirs(const char *rel_path, const char* expected_file);
+    static std::set<std::string> dfiles(const char *rel_path, const char* glob, const char* exception_str);
   };
 
 /// All you need to get an application up and running
index 5e899a8..7e273d6 100644 (file)
@@ -171,16 +171,10 @@ MenuItem::create(MenuItemKind kind_, const char *text_, int init_toggle_, Menu*
   pnew_item->input = (char*) malloc(sizeof(char));
   pnew_item->input[0] = '\0';
 
-  if(kind_ == MN_STRINGSELECT)
-    {
-      pnew_item->list = (string_list_type*) malloc(sizeof(string_list_type));
-      string_list_init(pnew_item->list);
-    }
-  else
-    pnew_item->list = NULL;
-
   pnew_item->id = id;
   pnew_item->int_p = int_p_;
+  
+  pnew_item->list.second = 0;
 
   pnew_item->input_flickering = false;
   pnew_item->input_flickering_timer.init(true);
@@ -306,7 +300,7 @@ Menu::~Menu()
         {
           free(item[i].text);
           free(item[i].input);
-          string_list_free(item[i].list);
+          item[i].list.first.clear();
         }
     }
 }
@@ -379,23 +373,23 @@ Menu::action()
 
         case MENU_ACTION_LEFT:
           if(item[active_item].kind == MN_STRINGSELECT
-              && item[active_item].list->num_items != 0)
+              && item[active_item].list.first.size() != 0)
             {
-              if(item[active_item].list->active_item > 0)
-                --item[active_item].list->active_item;
+              if(item[active_item].list.second != item[active_item].list.first.begin())
+                --item[active_item].list.second;
               else
-                item[active_item].list->active_item = item[active_item].list->num_items-1;
+                item[active_item].list.second = item[active_item].list.first.end();
             }
           break;
 
         case MENU_ACTION_RIGHT:
           if(item[active_item].kind == MN_STRINGSELECT
-              && item[active_item].list->num_items != 0)
+              && item[active_item].list.first.size() != 0)
             {
-              if(item[active_item].list->active_item < item[active_item].list->num_items-1)
-                ++item[active_item].list->active_item;
+              if(item[active_item].list.second != item[active_item].list.first.end())
+                ++item[active_item].list.second;
               else
-                item[active_item].list->active_item = 0;
+                item[active_item].list.second = item[active_item].list.first.begin();
             }
           break;
 
@@ -526,9 +520,10 @@ Menu::draw_item(DrawingContext& context,
   int shadow_size = 2;
   int text_width  = int(text_font->get_text_width(pitem.text));
   int input_width = int(text_font->get_text_width(pitem.input) + 10);
-  int list_width  =
-    int(text_font->get_text_width(string_list_active(pitem.list)));
-
+  int list_width = 0;
+  if(pitem.list.second != 0)
+  list_width = int(text_font->get_text_width((*pitem.list.second)));
+  
   if (arrange_left)
     x_pos += 24 - menu_width/2 + (text_width + input_width + list_width)/2;
 
@@ -637,7 +632,7 @@ Menu::draw_item(DrawingContext& context,
           Vector(list_pos_2, 18),
           Color(0,0,0,128), LAYER_GUI - 5);
 
-        context.draw_text_center(text_font, string_list_active(pitem.list),
+        context.draw_text_center(text_font, (*pitem.list.second),
                                  Vector(text_pos, y_pos - int(text_font->get_height()/2)),
                                  LAYER_GUI);
         context.draw_text_center(text_font, pitem.text,
@@ -693,7 +688,7 @@ int Menu::get_width() const
     int menu_width = 0;
     for(unsigned int i = 0; i < item.size(); ++i)
       {
-        int w = strlen(item[i].text) + (item[i].input ? strlen(item[i].input) + 1 : 0) + strlen(string_list_active(item[i].list));
+        int w = strlen(item[i].text) + (item[i].input ? strlen(item[i].input) + 1 : 0); //+ ((item[i].list.second != item[i].list.first.end()) ? (strlen((*(item[i].list.second)).c_str())) : 0);
         if( w > menu_width )
           {
             menu_width = w;
@@ -714,8 +709,9 @@ int Menu::get_height() const
 void
 Menu::draw(DrawingContext& context)
 {
+
   int menu_height = get_height();
-  int menu_width  = get_width();
+  int menu_width = get_width();  
 
   /* Draw a transparent background */
   context.draw_filled_rect(
index 31ad4f9..f4a3943 100644 (file)
@@ -21,6 +21,9 @@
 #define SUPERTUX_MENU_H
 
 #include <vector>
+#include <set>
+#include <string>
+#include <utility>
 
 #include "SDL.h"
 
@@ -28,7 +31,6 @@
 #include "../video/font.h"
 #include "../special/timer.h"
 #include "../special/base.h"
-#include "../special/stringlist.h"
 #include "../gui/mousecursor.h"
 
 namespace SuperTux
@@ -68,7 +70,7 @@ namespace SuperTux
       char *input;
       int *int_p;   // used for setting keys (can be used for more stuff...)
       int id;   // item id
-      string_list_type* list;
+      std::pair<std::set<std::string>, std::set<std::string>::iterator> list;
       Menu* target_menu;
 
       void change_text (const char *text);
diff --git a/lib/special/stringlist.cpp b/lib/special/stringlist.cpp
deleted file mode 100644 (file)
index a9f73cc..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-//  $Id$
-// 
-//  SuperTux
-//  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-// 
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-//  02111-1307, USA.
-
-#include "string.h"
-#include "stdlib.h"
-#include "../special/stringlist.h"
-
-using namespace SuperTux;
-
-void SuperTux::string_list_init(string_list_type* pstring_list)
-{
-  pstring_list->num_items = 0;
-  pstring_list->active_item = -1;
-  pstring_list->item = NULL;
-}
-
-char* SuperTux::string_list_active(string_list_type* pstring_list)
-{
-  if(pstring_list == NULL)
-    return "";
-
-  if(pstring_list->active_item != -1)
-    return pstring_list->item[pstring_list->active_item];
-  else
-    return "";
-}
-
-void SuperTux::string_list_add_item(string_list_type* pstring_list,const  char* str)
-{
-  char *pnew_string;
-  pnew_string = (char*) malloc(sizeof(char)*(strlen(str)+1));
-  strcpy(pnew_string,str);
-  ++pstring_list->num_items;
-  pstring_list->item = (char**) realloc(pstring_list->item,sizeof(char**)*pstring_list->num_items);
-  pstring_list->item[pstring_list->num_items-1] = pnew_string;
-  if(pstring_list->active_item == -1)
-    pstring_list->active_item = 0;
-}
-
-void SuperTux::string_list_copy(string_list_type* pstring_list, string_list_type pstring_list_orig)
-{
-  int i;
-  string_list_free(pstring_list);
-  for(i = 0; i < pstring_list_orig.num_items; ++i)
-    string_list_add_item(pstring_list,pstring_list_orig.item[i]);
-}
-
-int SuperTux::string_list_find(string_list_type* pstring_list,const  char* str)
-{
-  int i;
-  for(i = 0; i < pstring_list->num_items; ++i)
-    {
-      if(strcmp(pstring_list->item[i],str) == 0)
-        {
-          return i;
-        }
-    }
-  return -1;
-}
-
-void SuperTux::string_list_sort(string_list_type* pstring_list)
-{
-  int i,j,y;
-
-  for(j = 0; j < pstring_list->num_items; ++j)
-    for(i = 0; i < pstring_list->num_items-1; ++i)
-      {
-
-        y = strcmp(pstring_list->item[i],pstring_list->item[i+1]);
-        if(y == 0)
-          {
-            continue;
-          }
-        else if(y < 0)
-          {
-            continue;
-          }
-        else if(y > 0)
-          {
-            char* char_pointer;
-            char_pointer = pstring_list->item[i];
-            pstring_list->item[i] = pstring_list->item[i+1];
-            pstring_list->item[i+1] = char_pointer;
-            continue;
-          }
-
-      }
-
-}
-
-void SuperTux::string_list_free(string_list_type* pstring_list)
-{
-  if(pstring_list != NULL)
-    {
-      int i;
-      for(i=0; i < pstring_list->num_items; ++i)
-        free(pstring_list->item[i]);
-      free(pstring_list->item);
-      pstring_list->item = NULL;
-      pstring_list->num_items = 0;
-      pstring_list->active_item = -1;
-    }
-}
-
diff --git a/lib/special/stringlist.h b/lib/special/stringlist.h
deleted file mode 100644 (file)
index 436758b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-//  $Id$
-//
-//  SuperTux
-//  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-//  02111-1307, USA.
-
-#ifndef SUPERTUX_STRINGLIST_H
-#define SUPERTUX_STRINGLIST_H
-
-namespace SuperTux
-  {
-
-  struct string_list_type
-    {
-      int num_items;
-      int active_item;
-      char **item;
-    };
-
-  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, const char* str);
-  void  string_list_sort(string_list_type* pstring_list);
-  void  string_list_add_item(string_list_type* pstring_list, const char* str);
-  void  string_list_free(string_list_type* pstring_list);
-
-} //namespace SuperTux
-
-#endif /*SUPERTUX_STRINGLIST_H*/
-
index 387a5e8..31a3502 100644 (file)
@@ -103,7 +103,7 @@ void Config::load()
   if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR)
     return;
 
-  if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-config") != 0)
+  if (strcmp(lisp_symbol(lisp_car(root_obj)), (package_symbol_name+"-config").c_str()) != 0)
     return;
 
   LispReader reader(lisp_cdr(root_obj));
@@ -148,7 +148,7 @@ void Config::save ()
 
   if(config)
     {
-      fprintf(config, "(supertux-config\n");
+      fprintf(config, ("("+package_symbol_name+"-config\n").c_str());
       fprintf(config, "\t;; the following options can be set to #t or #f:\n");
       fprintf(config, "\t(fullscreen %s)\n", use_fullscreen ? "#t" : "#f");
       fprintf(config, "\t(sound      %s)\n", SoundManager::get()->sound_enabled()      ? "#t" : "#f");
index d04a952..4d7c4dd 100644 (file)
@@ -77,6 +77,9 @@ GameSession::GameSession(const std::string& levelname_, int mode, bool flip_leve
 
   context = new DrawingContext();
 
+  if(debug_mode)
+    flip_level = true;
+
   restart_level();
 }
 
index 39bc622..5d4e24f 100644 (file)
@@ -19,8 +19,6 @@
 //  02111-1307, USA.
 
 #include <assert.h>
-#include <unistd.h>
-
 #include "app/setup.h"
 #include "level.h"
 #include "app/globals.h"
@@ -103,7 +101,7 @@ void LevelSubset::load(const char* subset)
   if (levels.empty())
     { // Level info file doesn't define any levels, so read the
       // directory to see what we can find
-      std::vector<std::string> files;
+      std::set<std::string> files;
   
       snprintf(filename, 1024, "%s/levels/%s/", st_dir, subset);
       if(access(filename, R_OK) == 0)
@@ -116,7 +114,7 @@ void LevelSubset::load(const char* subset)
           files = FileSystem::read_directory(filename);
         }
   
-      for(std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i)
+      for(std::set<std::string>::iterator i = files.begin(); i != files.end(); ++i)
         {
           if (has_suffix(*i, ".stl"))
             levels.push_back(*i);
index 15b2d57..2dab421 100644 (file)
@@ -330,7 +330,7 @@ int LevelEditor::run(char* filename)
         default:
           if(i >= 1)
           {
-            if(load_level_subset(level_subsets.item[i-1]))
+            if(load_level_subset(subset_load_menu->item[i+1].text))
               return 1;
           }
           break;
@@ -395,7 +395,7 @@ int LevelEditor::run(char* filename)
   return done;
 }
 
-int LevelEditor::load_level_subset(char *filename)
+int LevelEditor::load_level_subset(const char *filename)
 {
   le_level_subset->load(filename);
   leveleditor_menu->get_item_by_id(MNID_SUBSETSETTINGS).kind = MN_GOTO;
@@ -411,7 +411,7 @@ int LevelEditor::load_level_subset(char *filename)
 
 void LevelEditor::init_menus()
 {
-  int i;
+  int i = 0;
 
   leveleditor_menu = new Menu();
   subset_load_menu = new Menu();
@@ -435,9 +435,9 @@ void LevelEditor::init_menus()
   subset_load_menu->additem(MN_LABEL, "Load Level Subset", 0, 0);
   subset_load_menu->additem(MN_HL, "", 0, 0);
 
-  for(i = 0; i < level_subsets.num_items; ++i)
+  for(std::set<std::string>::iterator it = level_subsets.begin(); it != level_subsets.end(); ++it)
   {
-    subset_load_menu->additem(MN_ACTION,level_subsets.item[i],0,0, i+1);
+    subset_load_menu->additem(MN_ACTION,(*it),0,0, i+1);
   }
   subset_load_menu->additem(MN_HL,"",0,0);
   subset_load_menu->additem(MN_BACK,"Back",0,0);
@@ -539,22 +539,22 @@ void LevelEditor::init_menus()
 void LevelEditor::update_level_settings_menu()
 {
   char str[80];
-  int i;
+  std::set<std::string>::iterator it;
 
   level_settings_menu->get_item_by_id(MNID_NAME).change_input(le_level->name.c_str());
   level_settings_menu->get_item_by_id(MNID_AUTHOR).change_input(le_level->author.c_str());
 
-  string_list_copy(level_settings_menu->get_item_by_id(MNID_SONG).list, FileSystem::dfiles("music/",NULL, "-fast"));
-  string_list_copy(level_settings_menu->get_item_by_id(MNID_BGIMG).list, FileSystem::dfiles("images/background",NULL, NULL));
-  string_list_add_item(level_settings_menu->get_item_by_id(MNID_BGIMG).list,"");
-  string_list_add_item(level_settings_menu->get_item_by_id(MNID_PARTICLE).list,"");
-  string_list_add_item(level_settings_menu->get_item_by_id(MNID_PARTICLE).list,"snow");
-  string_list_add_item(level_settings_menu->get_item_by_id(MNID_PARTICLE).list,"clouds");
-
-  if((i = string_list_find(level_settings_menu->get_item_by_id(MNID_SONG).list,le_level->get_sector("main")->song_title.c_str())) != -1)
-    level_settings_menu->get_item_by_id(MNID_SONG).list->active_item = i;
-  if((i = string_list_find(level_settings_menu->get_item_by_id(MNID_BGIMG).list,le_level->get_sector("main")->background->get_image().c_str())) != -1)
-    level_settings_menu->get_item_by_id(MNID_BGIMG).list->active_item = i;
+  level_settings_menu->get_item_by_id(MNID_SONG).list.first = FileSystem::dfiles("music/",NULL, "-fast");
+  level_settings_menu->get_item_by_id(MNID_BGIMG).list.first = FileSystem::dfiles("images/background",NULL, NULL);
+  level_settings_menu->get_item_by_id(MNID_BGIMG).list.first.insert("");
+  level_settings_menu->get_item_by_id(MNID_PARTICLE).list.first.insert("");
+  level_settings_menu->get_item_by_id(MNID_PARTICLE).list.first.insert("snow");
+  level_settings_menu->get_item_by_id(MNID_PARTICLE).list.first.insert("clouds");
+
+  if((it = level_settings_menu->get_item_by_id(MNID_SONG).list.first.find(le_level->get_sector("main")->song_title)) != level_settings_menu->get_item_by_id(MNID_SONG).list.first.end())
+    level_settings_menu->get_item_by_id(MNID_SONG).list.second = it;
+  if((it = level_settings_menu->get_item_by_id(MNID_BGIMG).list.first.find(le_level->get_sector("main")->background->get_image())) != level_settings_menu->get_item_by_id(MNID_BGIMG).list.first.end())
+    level_settings_menu->get_item_by_id(MNID_BGIMG).list.second = it;
 /*  if((i = string_list_find(level_settings_menu->get_item_by_id(MNID_PARTICLE).list,le_level->get_sector("main")->particlesystem.c_str())) != -1)
     level_settings_menu->get_item_by_id(MNID_PARTICLE).list->active_item = i;*/
 
@@ -597,9 +597,9 @@ void LevelEditor::apply_level_settings_menu()
   le_level->name = level_settings_menu->get_item_by_id(MNID_NAME).input;
   le_level->author = level_settings_menu->get_item_by_id(MNID_AUTHOR).input;
 
-  if(le_level->get_sector("main")->background->get_image().compare(string_list_active(level_settings_menu->get_item_by_id(MNID_BGIMG).list)) != 0)
+  if(le_level->get_sector("main")->background->get_image().compare((*level_settings_menu->get_item_by_id(MNID_BGIMG).list.second)) != 0)
   {
-    le_level->get_sector("main")->background->set_image(string_list_active(level_settings_menu->get_item_by_id(MNID_BGIMG).list), atoi(level_settings_menu->get_item_by_id(MNID_BGSPEED).input));
+    le_level->get_sector("main")->background->set_image((*level_settings_menu->get_item_by_id(MNID_BGIMG).list.second), atoi(level_settings_menu->get_item_by_id(MNID_BGSPEED).input));
     i = true;
   }
 
@@ -613,7 +613,7 @@ void LevelEditor::apply_level_settings_menu()
     le_level->load_gfx();
   }*/
 
-  le_level->get_sector("main")->song_title = string_list_active(level_settings_menu->get_item_by_id(MNID_SONG).list);
+  le_level->get_sector("main")->song_title = (*level_settings_menu->get_item_by_id(MNID_SONG).list.second);
 
   le_level->get_sector("main")->solids->resize(
       atoi(level_settings_menu->get_item_by_id(MNID_LENGTH).input),
@@ -950,10 +950,10 @@ void LevelEditor::change_object_properties(GameObject *pobj)
     object_properties_menu->additem(MN_STRINGSELECT,"Kind",0,0,1);
     for(int i = 0; i < NUM_BadGuyKinds; ++i)
     {
-      string_list_add_item(object_properties_menu->get_item_by_id(1).list,
-          badguykind_to_string(static_cast<BadGuyKind>(i)).c_str());
+      object_properties_menu->get_item_by_id(1).list.first.insert(
+          badguykind_to_string(static_cast<BadGuyKind>(i)));
       if(pbad->kind == i)
-        object_properties_menu->get_item_by_id(1).list->active_item = i;
+        object_properties_menu->get_item_by_id(1).list.second = object_properties_menu->get_item_by_id(1).list.first.find(badguykind_to_string(static_cast<BadGuyKind>(i)));
     }
     object_properties_menu->additem(MN_TOGGLE,"StayOnPlatform",pbad->stay_on_platform,0,2);
   }
@@ -984,7 +984,7 @@ void LevelEditor::change_object_properties(GameObject *pobj)
       BadGuy* pbad = dynamic_cast<BadGuy*>(pobj);
       if(pbad != 0) {
         BadGuy* pbad = dynamic_cast<BadGuy*>(pobj);
-        pbad->kind =  badguykind_from_string(string_list_active(object_properties_menu->get_item_by_id(1).list));
+        pbad->kind =  badguykind_from_string((*object_properties_menu->get_item_by_id(1).list.second));
         pbad->stay_on_platform = object_properties_menu->get_item_by_id(2).toggled;
       }
       loop = false;
index c51411b..a63f78b 100644 (file)
@@ -94,7 +94,7 @@ void unload_level();
 /* own declerations */
 /* crutial ones (main loop) */
 void init_menus();
-int load_level_subset(char *filename);
+int load_level_subset(const char *filename);
 void drawlevel(DrawingContext& context);
 void drawinterface(DrawingContext& context);
 void change(float x, float y, int tm, unsigned int c);
@@ -142,7 +142,7 @@ enum SelectionMode { CURSOR, SQUARE, NONE };
 
 // variables
 /* leveleditor internals */
-string_list_type level_subsets;
+std::set<std::string> level_subsets;
 bool le_level_changed;  /* if changes, ask for saving, when quiting*/
 bool show_minimap;
 bool show_selections;
index ddb0c01..dd720b2 100644 (file)
@@ -74,7 +74,7 @@ static GameSession* titlesession;
 static std::vector<LevelSubset*> contrib_subsets;
 static LevelSubset* current_contrib_subset = 0;
 
-static string_list_type worldmap_list;
+static std::set<std::string> worldmap_list;
 
 static LevelEditor* leveleditor;
 
@@ -102,34 +102,39 @@ void free_contrib_menu()
 
 void generate_contrib_menu()
 {
+  
   /** Generating contrib levels list by making use of Level Subset */
-  string_list_type level_subsets = FileSystem::dsubdirs("/levels", "info");
+  std::set<std::string> level_subsets = FileSystem::dsubdirs("/levels", "info");
 
   free_contrib_menu();
 
   contrib_menu->additem(MN_LABEL,_("Contrib Levels"),0,0);
   contrib_menu->additem(MN_HL,"",0,0);
-
-  for (int i = 0; i < level_subsets.num_items; ++i)
+  
+  int i = 0;
+  for (std::set<std::string>::iterator it = level_subsets.begin(); it != level_subsets.end(); ++it)
     {
       LevelSubset* subset = new LevelSubset();
-      subset->load(level_subsets.item[i]);
+      subset->load((*it).c_str());
       contrib_menu->additem(MN_GOTO, subset->title.c_str(), i,
-          contrib_subset_menu, i);
+          contrib_subset_menu);
       contrib_subsets.push_back(subset);
+      ++i;
     }
 
-  for(int i = 0; i < worldmap_list.num_items; i++)
+  i = 0;
+  for(std::set<std::string>::iterator it = worldmap_list.begin(); it != worldmap_list.end(); ++it)
     {
     WorldMapNS::WorldMap worldmap;
-    worldmap.loadmap(worldmap_list.item[i]);
-    contrib_menu->additem(MN_ACTION, worldmap.get_world_title(),0,0, i + level_subsets.num_items);
+    worldmap.loadmap((*it).c_str());
+    contrib_menu->additem(MN_ACTION, worldmap.get_world_title(),0,0, i + level_subsets.size());
+    ++i;
     }
 
   contrib_menu->additem(MN_HL,"",0,0);
   contrib_menu->additem(MN_BACK,_("Back"),0,0);
 
-  string_list_free(&level_subsets);
+  level_subsets.clear();
 }
 
 void check_levels_contrib_menu()
@@ -180,10 +185,13 @@ void check_levels_contrib_menu()
       titlesession->set_current();
       }
     }
-  else if(index < worldmap_list.num_items + (int)contrib_subsets.size())
+  else if((unsigned)index < worldmap_list.size() + (int)contrib_subsets.size())
     {
     WorldMapNS::WorldMap worldmap;
-    worldmap.loadmap(worldmap_list.item[index - contrib_subsets.size()]);
+    std::set<std::string>::iterator it = worldmap_list.begin();
+    for(int i = index - contrib_subsets.size(); i > 0; --i)
+    ++it;
+    worldmap.loadmap((*it));
     worldmap.display();
 
     Menu::set_current(main_menu);
@@ -309,10 +317,11 @@ void title(void)
           if (event.type == SDL_QUIT)
             Menu::set_current(0);
         }
-
+  
       /* Draw the background: */
       draw_demo(frame_ratio);
-     
+      
+      
       if (Menu::current() == main_menu)
         context.draw_surface(logo, Vector(screen->w/2 - logo->w/2, 30),
             LAYER_FOREGROUND1+1);
@@ -330,7 +339,7 @@ void title(void)
         {
           menu->draw(context);
           menu->action();
-        
+         
           if(menu == main_menu)
             {
               switch (main_menu->check())
@@ -417,12 +426,13 @@ void title(void)
   /* Free surfaces: */
 
   free_contrib_menu();
-  string_list_free(&worldmap_list);
+  worldmap_list.clear();
   delete titlesession;
   delete bkg_title;
   delete logo;
   delete img_choose_subset;
 }
 
+
 // EOF //
 
index d309771..7f87ad4 100644 (file)
@@ -437,7 +437,7 @@ WorldMap::load_map()
                       reader.read_int("x", level.x);
                       reader.read_int("y", level.y);
                       level.auto_path = true;
-                      reader.read_bool("auto-path", &level.auto_path);
+                      reader.read_bool("auto-path", level.auto_path);
                       level.swap_x = level.swap_y = -1;
                       reader.read_int("swap-x", level.swap_x);
                       reader.read_int("swap-y", level.swap_y);