// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
-
#include <config.h>
#include "bomb.hpp"
start_position = pos;
bbox.set_pos(pos);
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("bomb");
+ sprite = sprite_manager->create("images/creatures/mr_bomb/bomb.sprite");
state = 0;
timer.start(TICKINGTIME);
this->dir = dir;
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
-
#include <config.h>
#include "bouncing_snowball.hpp"
reader.get("x", start_position.x);
reader.get("y", start_position.y);
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("bouncingsnowball");
+ sprite = sprite_manager->create("images/creatures/bouncing_snowball/bouncing_snowball.sprite");
set_direction = false;
}
start_position.x = pos_x;
start_position.y = pos_y;
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("bouncingsnowball");
+ sprite = sprite_manager->create("images/creatures/bouncing_snowball/bouncing_snowball.sprite");
set_direction = true;
initial_direction = d;
}
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
-
#include <config.h>
#include "dispenser.hpp"
reader.get("cycle", cycle);
reader.get("badguy", badguy);
bbox.set_size(32, 32);
- sprite = sprite_manager->create("dispenser");
+ sprite = sprite_manager->create("images/creatures/dispenser/dispenser.sprite");
if (badguy == "mrrocket") {
sprite->set_action(dir == LEFT ? "working-left" : "working-right");
}
reader.get("x", start_position.x);
reader.get("y", start_position.y);
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("fish");
+ sprite = sprite_manager->create("images/creatures/fish/fish.sprite");
physic.enable_gravity(true);
}
start_position.x = pos_x;
start_position.y = pos_y;
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("fish");
+ sprite = sprite_manager->create("images/creatures/fish/fish.sprite");
physic.enable_gravity(true);
}
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
-
#include <config.h>
#include "flame.hpp"
bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
start_position.y + sin(angle) * radius));
bbox.set_size(32, 32);
- sprite = sprite_manager->create("flame");
+ sprite = sprite_manager->create("images/creatures/flame.sprite");
countMe = false;
}
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
-
#include <config.h>
+
#include <stdio.h>
#include "flyingsnowball.hpp"
reader.get("x", start_position.x);
reader.get("y", start_position.y);
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("flyingsnowball");
+ sprite = sprite_manager->create("images/creatures/flying_snowball/flying_snowball.sprite");
physic.enable_gravity(false);
}
start_position.x = pos_x;
start_position.y = pos_y;
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("flyingsnowball");
+ sprite = sprite_manager->create("images/creatures/flying_snowball/flying_snowball.sprite");
physic.enable_gravity(false);
}
reader.get("x", start_position.x);
reader.get("y", start_position.y);
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("jumpy");
+ sprite = sprite_manager->create("images/creatures/jumpy/jumpy.sprite");
}
void
reader.get("x", start_position.x);
start_position.y = 0; //place above visible area
bbox.set_size(63.8, 63.8);
- sprite = sprite_manager->create("kugelblitz");
+ sprite = sprite_manager->create("images/creatures/kugelblitz/kugelblitz.sprite");
sprite->set_action("falling");
physic.enable_gravity(false);
}
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
-
#include <config.h>
#include "mrbomb.hpp"
reader.get("x", start_position.x);
reader.get("y", start_position.y);
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("mrbomb");
+ sprite = sprite_manager->create("images/creatures/mr_bomb/mr_bomb.sprite");
set_direction = false;
}
start_position.x = pos_x;
start_position.y = pos_y;
bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("mrbomb");
+ sprite = sprite_manager->create("images/creatures/mr_bomb/mr_bomb.sprite");
set_direction = true;
initial_direction = d;
}
#include "file_system.hpp"
#include <string>
+#include <vector>
+#include <iostream>
+#include <sstream>
namespace FileSystem
{
return filename.substr(p, filename.size()-p);
}
+std::string normalize(const std::string& filename)
+{
+ std::vector<std::string> path_stack;
+
+ const char* p = filename.c_str();
+
+ while(true) {
+ while(*p == '/') {
+ p++;
+ continue;
+ }
+
+ const char* pstart = p;
+ while(*p != '/' && *p != 0) {
+ ++p;
+ }
+
+ size_t len = p - pstart;
+ if(len == 0)
+ break;
+
+ std::string pathelem(pstart, p-pstart);
+ if(pathelem == ".")
+ continue;
+
+ if(pathelem == "..") {
+ if(path_stack.empty()) {
+ std::cout << "Invalid '..' in path '" << filename << "'.\n";
+ // push it into the result path so that the users sees his error...
+ path_stack.push_back(pathelem);
+ } else {
+ path_stack.pop_back();
+ }
+ } else {
+ path_stack.push_back(pathelem);
+ }
+ }
+
+ // construct path
+ std::ostringstream result;
+ for(std::vector<std::string>::iterator i = path_stack.begin();
+ i != path_stack.end(); ++i) {
+ result << '/' << *i;
+ }
+ if(path_stack.empty())
+ result << '/';
+
+ return result.str();
+}
+
}
{
std::string dirname(const std::string& filename);
std::string basename(const std::string& filename);
+ /**
+ * normalize filename so that "blup/bla/blo/../../bar" will become
+ * "blup/bar"
+ */
+ std::string normalize(const std::string& filename);
}
#endif
while(tile->id >= tiles.size()) {
tiles.push_back(0);
}
+ if(tiles[tile->id] != 0) {
+ std::cout << "Warning: Tile with ID " << tile->id << " redefined\n";
+ }
tiles[tile->id] = tile;
} else if(iter.item() == "tilegroup") {
TileGroup tilegroup;
#include "physfs/physfs_sdl.hpp"
#include "image_texture.hpp"
#include "glutil.hpp"
+#include "file_system.hpp"
TextureManager* texture_manager = NULL;
}
ImageTexture*
-TextureManager::get(const std::string& filename)
+TextureManager::get(const std::string& _filename)
{
+ std::string filename = FileSystem::normalize(_filename);
ImageTextures::iterator i = image_textures.find(filename);
ImageTexture* texture = NULL;