Renamed namespaces to all lowercase
[supertux.git] / src / supertux / sector.cpp
index 52d345f..717c121 100644 (file)
 #include "lisp/list_iterator.hpp"
 #include "math/aatriangle.hpp"
 #include "object/background.hpp"
+#include "object/bonus_block.hpp"
+#include "object/brick.hpp"
 #include "object/bullet.hpp"
 #include "object/camera.hpp"
+#include "object/cloud_particle_system.hpp"
 #include "object/coin.hpp"
+#include "object/comet_particle_system.hpp"
 #include "object/display_effect.hpp"
+#include "object/ghost_particle_system.hpp"
 #include "object/gradient.hpp"
 #include "object/invisible_block.hpp"
 #include "object/particlesystem.hpp"
 #include "object/player.hpp"
 #include "object/portable.hpp"
 #include "object/pulsing_light.hpp"
+#include "object/rain_particle_system.hpp"
 #include "object/smoke_cloud.hpp"
+#include "object/snow_particle_system.hpp"
 #include "object/text_object.hpp"
 #include "object/tilemap.hpp"
-#include "physfs/physfs_stream.hpp"
+#include "physfs/ifile_stream.hpp"
 #include "scripting/squirrel_util.hpp"
 #include "supertux/collision.hpp"
 #include "supertux/constants.hpp"
+#include "supertux/globals.hpp"
 #include "supertux/level.hpp"
-#include "supertux/main.hpp"
 #include "supertux/object_factory.hpp"
 #include "supertux/spawn_point.hpp"
 #include "supertux/tile.hpp"
@@ -57,10 +64,22 @@ bool Sector::draw_solids_only = false;
 
 Sector::Sector(Level* parent) :
   level(parent), 
+  name(),
+  bullets(),
+  init_script(),
+  gameobjects_new(),
   currentmusic(LEVEL_MUSIC),
+  sector_table(),
+  scripts(),
   ambient_light( 1.0f, 1.0f, 1.0f, 1.0f ), 
+  gameobjects(),
+  moving_objects(),
+  spawnpoints(),
+  portables(),
+  music(),
   gravity(10.0), 
   player(0), 
+  solid_tilemaps(),
   camera(0), 
   effect(0)
 {
@@ -71,25 +90,25 @@ Sector::Sector(Level* parent) :
   sound_manager->preload("sounds/shoot.wav");
 
   // create a new squirrel table for the sector
-  using namespace Scripting;
+  using namespace scripting;
 
   sq_collectgarbage(global_vm);
 
   sq_newtable(global_vm);
   sq_pushroottable(global_vm);
   if(SQ_FAILED(sq_setdelegate(global_vm, -2)))
-    throw Scripting::SquirrelError(global_vm, "Couldn't set sector_table delegate");
+    throw scripting::SquirrelError(global_vm, "Couldn't set sector_table delegate");
 
   sq_resetobject(&sector_table);
   if(SQ_FAILED(sq_getstackobj(global_vm, -1, &sector_table)))
-    throw Scripting::SquirrelError(global_vm, "Couldn't get sector table");
+    throw scripting::SquirrelError(global_vm, "Couldn't get sector table");
   sq_addref(global_vm, &sector_table);
   sq_pop(global_vm, 1);
 }
 
 Sector::~Sector()
 {
-  using namespace Scripting;
+  using namespace scripting;
 
   deactivate();
 
@@ -151,15 +170,14 @@ Sector::parse_object(const std::string& name, const Reader& reader)
     return partsys;
   } else if(name == "money") { // for compatibility with old maps
     return new Jumpy(reader);
+  } else {
+    try {
+      return create_object(name, reader);
+    } catch(std::exception& e) {
+      log_warning << e.what() << "" << std::endl;
+      return 0;
+    }
   }
-
-  try {
-    return create_object(name, reader);
-  } catch(std::exception& e) {
-    log_warning << e.what() << "" << std::endl;
-  }
-
-  return 0;
 }
 
 void
@@ -176,7 +194,7 @@ Sector::parse(const Reader& sector)
     } else if(token == "music") {
       iter.value()->get(music);
     } else if(token == "spawnpoint") {
-      SpawnPoint* sp = new SpawnPoint(iter.lisp());
+      SpawnPoint* sp = new SpawnPoint(*iter.lisp());
       spawnpoints.push_back(sp);
     } else if(token == "init-script") {
       iter.value()->get(init_script);
@@ -447,7 +465,7 @@ Sector::fix_old_tiles()
 HSQUIRRELVM
 Sector::run_script(std::istream& in, const std::string& sourcename)
 {
-  using namespace Scripting;
+  using namespace scripting;
 
   // garbage collect thread list
   for(ScriptList::iterator i = scripts.begin();
@@ -537,12 +555,12 @@ Sector::activate(const Vector& player_pos)
     _current = this;
 
     // register sectortable as sector in scripting
-    HSQUIRRELVM vm = Scripting::global_vm;
+    HSQUIRRELVM vm = scripting::global_vm;
     sq_pushroottable(vm);
     sq_pushstring(vm, "sector", -1);
     sq_pushobject(vm, sector_table);
     if(SQ_FAILED(sq_createslot(vm, -3)))
-      throw Scripting::SquirrelError(vm, "Couldn't set sector in roottable");
+      throw scripting::SquirrelError(vm, "Couldn't set sector in roottable");
     sq_pop(vm, 1);
 
     for(GameObjects::iterator i = gameobjects.begin();
@@ -598,11 +616,11 @@ Sector::deactivate()
     return;
 
   // remove sector entry from global vm
-  HSQUIRRELVM vm = Scripting::global_vm;
+  HSQUIRRELVM vm = scripting::global_vm;
   sq_pushroottable(vm);
   sq_pushstring(vm, "sector", -1);
   if(SQ_FAILED(sq_deleteslot(vm, -2, SQFalse)))
-    throw Scripting::SquirrelError(vm, "Couldn't unset sector in roottable");
+    throw scripting::SquirrelError(vm, "Couldn't unset sector in roottable");
   sq_pop(vm, 1);
 
   for(GameObjects::iterator i = gameobjects.begin();
@@ -750,7 +768,7 @@ Sector::try_expose(GameObject* object)
 {
   ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
   if(interface != NULL) {
-    HSQUIRRELVM vm = Scripting::global_vm;
+    HSQUIRRELVM vm = scripting::global_vm;
     sq_pushobject(vm, sector_table);
     interface->expose(vm, -1);
     sq_pop(vm, 1);
@@ -760,9 +778,9 @@ Sector::try_expose(GameObject* object)
 void
 Sector::try_expose_me()
 {
-  HSQUIRRELVM vm = Scripting::global_vm;
+  HSQUIRRELVM vm = scripting::global_vm;
   sq_pushobject(vm, sector_table);
-  Scripting::SSector* interface = static_cast<Scripting::SSector*> (this);
+  scripting::SSector* interface = static_cast<scripting::SSector*> (this);
   expose_object(vm, -1, interface, "settings", false);
   sq_pop(vm, 1);
 }
@@ -793,7 +811,7 @@ Sector::try_unexpose(GameObject* object)
 {
   ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
   if(interface != NULL) {
-    HSQUIRRELVM vm = Scripting::global_vm;
+    HSQUIRRELVM vm = scripting::global_vm;
     SQInteger oldtop = sq_gettop(vm);
     sq_pushobject(vm, sector_table);
     try {
@@ -808,11 +826,11 @@ Sector::try_unexpose(GameObject* object)
 void
 Sector::try_unexpose_me()
 {
-  HSQUIRRELVM vm = Scripting::global_vm;
+  HSQUIRRELVM vm = scripting::global_vm;
   SQInteger oldtop = sq_gettop(vm);
   sq_pushobject(vm, sector_table);
   try {
-    Scripting::unexpose_object(vm, -1, "settings");
+    scripting::unexpose_object(vm, -1, "settings");
   } catch(std::exception& e) {
     log_warning << "Couldn't unregister object: " << e.what() << std::endl;
   }