Make curl a required dependency, compilation fails without it
[supertux.git] / src / supertux / menu / contrib_menu.cpp
index d4ae767..8bbc717 100644 (file)
@@ -19,6 +19,7 @@
 #include <physfs.h>
 #include <sstream>
 
+#include "gui/menu_item.hpp"
 #include "gui/menu_manager.hpp"
 #include "supertux/game_manager.hpp"
 #include "supertux/gameconfig.hpp"
 ContribMenu::ContribMenu() :
   m_contrib_worlds()
 {
-  /** Generating contrib levels list by making use of Level Subset  */
+  // Generating contrib levels list by making use of Level Subset
   std::vector<std::string> level_worlds;
-  char** files = PHYSFS_enumerateFiles("levels/");
-  for(const char* const* filename = files; *filename != 0; ++filename) {
-    std::string filepath = std::string("levels/") + *filename;
+
+  std::unique_ptr<char*, decltype(&PHYSFS_freeList)>
+    files(PHYSFS_enumerateFiles("levels"),
+          PHYSFS_freeList);
+  for(const char* const* filename = files.get(); *filename != 0; ++filename)
+  {
+    std::string filepath = FileSystem::join("levels", *filename);
     if(PHYSFS_isDirectory(filepath.c_str()))
+    {
       level_worlds.push_back(filepath);
+    }
   }
-  PHYSFS_freeList(files);
 
   add_label(_("Contrib Levels"));
   add_hl();
@@ -134,9 +140,9 @@ ContribMenu::~ContribMenu()
 }
 
 void
-ContribMenu::check_menu()
+ContribMenu::menu_action(MenuItem* item)
 {
-  int index = check();
+  int index = item->id;
   if (index != -1)
   {
     // reload the World so that we have something that we can safely