Make it compile with 4.6.1.
[supertux.git] / src / addon / addon_manager.cpp
index 4b54a2d..562096c 100644 (file)
@@ -20,6 +20,7 @@
 #include <version.h>
 
 #include <algorithm>
+#include <memory>
 #include <physfs.h>
 #include <sstream>
 #include <stdexcept>
@@ -28,7 +29,6 @@
 #ifdef HAVE_LIBCURL
 #  include <curl/curl.h>
 #  include <curl/easy.h>
-#  include <curl/types.h>
 #endif
 
 #include "addon/addon.hpp"
@@ -104,7 +104,7 @@ AddonManager::check_online()
 #ifdef HAVE_LIBCURL
   char error_buffer[CURL_ERROR_SIZE+1];
 
-  const char* baseUrl = "http://supertux.berlios.de/addons/index.nfo";
+  const char* baseUrl = "http://supertux.lethargik.org/addons/index.nfo";
   std::string addoninfos = "";
 
   CURL *curl_handle;
@@ -135,39 +135,41 @@ AddonManager::check_online()
     if(!addons_lisp) throw std::runtime_error("Downloaded file is not an Add-on list");
 
     lisp::ListIterator iter(addons_lisp);
-    while(iter.next()) {
+    while(iter.next()) 
+    {
       const std::string& token = iter.item();
-      if(token != "supertux-addoninfo") {
+      if(token != "supertux-addoninfo") 
+      {
         log_warning << "Unknown token '" << token << "' in Add-on list" << std::endl;
         continue;
       }
-      Addon* addon_ptr = new Addon();
-      Addon& addon = *addon_ptr;
-      addon.parse(*(iter.lisp()));
-      addon.installed = false;
-      addon.loaded = false;
+      std::auto_ptr<Addon> addon(new Addon());
+      addon->parse(*(iter.lisp()));
+      addon->installed = false;
+      addon->loaded = false;
 
       // make sure the list of known Add-ons does not already contain this one 
       bool exists = false;
       for (std::vector<Addon*>::const_iterator i = addons.begin(); i != addons.end(); i++) {
-        if (**i == addon) {
+        if (**i == *addon) {
           exists = true; 
           break; 
         }
-      } 
-      if (exists) {
-        delete addon_ptr;
-        continue;
       }
 
-      // make sure the Add-on's file name does not contain weird characters
-      if (addon.suggested_filename.find_first_not_of("match.quiz-proxy_gwenblvdjfks0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != std::string::npos) {
-        log_warning << "Add-on \"" << addon.title << "\" contains unsafe file name. Skipping." << std::endl;
-        delete addon_ptr;
-        continue;
+      if (exists) 
+      {
+        // do nothing
+      }
+      else if (addon->suggested_filename.find_first_not_of("match.quiz-proxy_gwenblvdjfks0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != std::string::npos) 
+      {
+        // make sure the Add-on's file name does not contain weird characters
+        log_warning << "Add-on \"" << addon->title << "\" contains unsafe file name. Skipping." << std::endl;
+      }
+      else
+      {
+        addons.push_back(addon.release());
       }
-
-      addons.push_back(addon_ptr);
     }
   } catch(std::exception& e) {
     std::stringstream msg;