SpriteData::Action::~Action()
{
- for(std::vector<Surface*>::iterator i = surfaces.begin();
- i != surfaces.end(); ++i)
- delete *i;
}
SpriteData::SpriteData(const Reader& lisp, const std::string& basedir) :
std::string mirror_action;
lisp.get("mirror-action", mirror_action);
if(!mirror_action.empty()) {
- Action* act_tmp = get_action(mirror_action);
+ const Action* act_tmp = get_action(mirror_action);
if(act_tmp == NULL) {
throw std::runtime_error("Could not mirror action. Action not found.\n"
"Mirror actions must be defined after the real one!");
float max_w = 0;
float max_h = 0;
for(int i = 0; static_cast<unsigned int>(i) < act_tmp->surfaces.size(); i++) {
- Surface* surface = new Surface(*(act_tmp->surfaces[i]));
+ SurfacePtr surface = act_tmp->surfaces[i]->clone();
surface->hflip();
max_w = std::max(max_w, (float) surface->get_width());
max_h = std::max(max_h, (float) surface->get_height());
float max_w = 0;
float max_h = 0;
for(std::vector<std::string>::size_type i = 0; i < images.size(); i++) {
- Surface* surface = new Surface(basedir + images[i]);
+ SurfacePtr surface = Surface::create(basedir + images[i]);
max_w = std::max(max_w, (float) surface->get_width());
max_h = std::max(max_h, (float) surface->get_height());
action->surfaces.push_back(surface);
actions[action->name] = action;
}
-SpriteData::Action*
-SpriteData::get_action(std::string act)
+const SpriteData::Action*
+SpriteData::get_action(const std::string& act)
{
Actions::iterator i = actions.find(act);
if(i == actions.end()) {