X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fsector.cpp;h=96f7f34911a5169247e0ff3e5f3ed60034676e4e;hb=7bbb0ef907ebec48718560425a0147b31307f7fd;hp=063772e5344e9815f01074c356422c3cb27fee13;hpb=58bf708dc9f036b2c7d8d3edfdbfa62f0da3481a;p=supertux.git diff --git a/src/sector.cpp b/src/sector.cpp index 063772e53..96f7f3491 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -44,28 +44,17 @@ #include "statistics.h" #include "collision_grid.h" #include "collision_grid_iterator.h" +#include "object_factory.h" #include "special/collision.h" #include "math/rectangle.h" #include "math/aatriangle.h" #include "object/coin.h" #include "object/block.h" #include "object/invisible_block.h" -#include "object/platform.h" #include "object/bullet.h" #include "badguy/jumpy.h" -#include "badguy/snowball.h" -#include "badguy/bouncing_snowball.h" -#include "badguy/flame.h" -#include "badguy/flyingsnowball.h" -#include "badguy/mriceblock.h" -#include "badguy/mrbomb.h" -#include "badguy/dispenser.h" #include "badguy/spike.h" -#include "badguy/spiky.h" -#include "badguy/nolok_01.h" -#include "trigger/door.h" #include "trigger/sequence_trigger.h" -#include "trigger/secretarea_trigger.h" Sector* Sector::_current = 0; @@ -103,14 +92,10 @@ Sector::~Sector() GameObject* Sector::parse_object(const std::string& name, const lisp::Lisp& reader) { - if(name == "background") { - return new Background(reader); - } else if(name == "camera") { + if(name == "camera") { Camera* camera = new Camera(this); camera->parse(reader); return camera; - } else if(name == "tilemap") { - return new TileMap(reader); } else if(name == "particles-snow") { SnowParticleSystem* partsys = new SnowParticleSystem(); partsys->parse(reader); @@ -119,39 +104,16 @@ Sector::parse_object(const std::string& name, const lisp::Lisp& reader) CloudParticleSystem* partsys = new CloudParticleSystem(); partsys->parse(reader); return partsys; - } else if(name == "door") { - return new Door(reader); - } else if(name == "secretarea") { - return new SecretAreaTrigger(reader); - } else if(name == "sequencetrigger") { - return new SequenceTrigger(reader); - } else if(name == "platform") { - return new Platform(reader); - } else if(name == "jumpy" || name == "money") { + } else if(name == "money") { // for compatibility with old maps return new Jumpy(reader); - } else if(name == "snowball") { - return new SnowBall(reader); - } else if(name == "bouncingsnowball") { - return new BouncingSnowball(reader); - } else if(name == "flame") { - return new Flame(reader); - } else if(name == "flyingsnowball") { - return new FlyingSnowBall(reader); - } else if(name == "mriceblock") { - return new MrIceBlock(reader); - } else if(name == "mrbomb") { - return new MrBomb(reader); - } else if(name == "dispenser") { - return new Dispenser(reader); - } else if(name == "spike") { - return new Spike(reader); - } else if(name == "spiky") { - return new Spiky(reader); - } else if(name == "nolok_01") { - return new Nolok_01(reader); - } - - std::cerr << "Unknown object type '" << name << "'.\n"; + } + + try { + return create_object(name, reader); + } catch(std::exception& e) { + std::cerr << e.what() << "\n"; + } + return 0; }