git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6072
837edb03-e0f3-0310-88ca-
d4d4e8b29345
#include <version.h>
#include <algorithm>
#include <version.h>
#include <algorithm>
#include <physfs.h>
#include <sstream>
#include <stdexcept>
#include <physfs.h>
#include <sstream>
#include <stdexcept>
if(!addons_lisp) throw std::runtime_error("Downloaded file is not an Add-on list");
lisp::ListIterator iter(addons_lisp);
if(!addons_lisp) throw std::runtime_error("Downloaded file is not an Add-on list");
lisp::ListIterator iter(addons_lisp);
const std::string& token = iter.item();
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;
}
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++) {
// 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 (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;
}
} catch(std::exception& e) {
std::stringstream msg;
#include "supertux/tile_set.hpp"
#include "supertux/tile_set.hpp"
#include <stdexcept>
#include <sstream>
#include <stdexcept>
#include <sstream>
lisp::ListIterator iter(tiles_lisp);
while(iter.next()) {
if(iter.item() == "tile") {
lisp::ListIterator iter(tiles_lisp);
while(iter.next()) {
if(iter.item() == "tile") {
- Tile* tile = new Tile(this);
+ std::auto_ptr<Tile> tile(new Tile(this));
uint32_t id = tile->parse(*(iter.lisp()));
if(id >= tiles.size())
uint32_t id = tile->parse(*(iter.lisp()));
if(id >= tiles.size())
if(tiles[id] != 0) {
log_warning << "Tile with ID " << id << " redefined" << std::endl;
if(tiles[id] != 0) {
log_warning << "Tile with ID " << id << " redefined" << std::endl;
+ tiles[id] = tile.release();
}
} else if(iter.item() == "tilegroup") {
/* tilegroups are only interesting for the editor */
}
} else if(iter.item() == "tilegroup") {
/* tilegroups are only interesting for the editor */
int x = 32*(i % width);
int y = 32*(i / width);
int x = 32*(i % width);
int y = 32*(i / width);
- Tile* tile = new Tile(this, images, Rect(x, y, x + 32, y + 32),
- (has_attributes ? attributes[i] : 0), (has_datas ? datas[i] : 0), animfps);
+ std::auto_ptr<Tile> tile(new Tile(this, images, Rect(x, y, x + 32, y + 32),
+ (has_attributes ? attributes[i] : 0), (has_datas ? datas[i] : 0), animfps));
if (tiles[ids[i]] == 0) {
if (tiles[ids[i]] == 0) {
+ tiles[ids[i]] = tile.release();
} else {
log_warning << "Tile with ID " << ids[i] << " redefined" << std::endl;
} else {
log_warning << "Tile with ID " << ids[i] << " redefined" << std::endl;
}
}
} else if(iter.item() == "properties") {
}
}
} else if(iter.item() == "properties") {