[Supertux-Commit] r5484 - in trunk/supertux: data/levels/test data/levels/world2 src src/worldmap

sik0fewl at millhouse.dreamhost.com sik0fewl at millhouse.dreamhost.com
Fri May 16 08:42:06 PDT 2008


Author: sik0fewl
Date: 2008-05-16 08:42:02 -0700 (Fri, 16 May 2008)
New Revision: 5484

Modified:
   trunk/supertux/data/levels/test/intro.stl
   trunk/supertux/data/levels/test/intro2.stl
   trunk/supertux/data/levels/test/keydoors.stl
   trunk/supertux/data/levels/test/snowslope.stl
   trunk/supertux/data/levels/test/transition.stl
   trunk/supertux/data/levels/world2/Crumbling_Path.stl
   trunk/supertux/data/levels/world2/airkey.stl
   trunk/supertux/data/levels/world2/builder.stl
   trunk/supertux/data/levels/world2/christophB.stl
   trunk/supertux/data/levels/world2/detour.stl
   trunk/supertux/data/levels/world2/fish.stl
   trunk/supertux/data/levels/world2/key1.stl
   trunk/supertux/data/levels/world2/key2.stl
   trunk/supertux/data/levels/world2/key3.stl
   trunk/supertux/data/levels/world2/key4.stl
   trunk/supertux/data/levels/world2/key5.stl
   trunk/supertux/data/levels/world2/leaves.stl
   trunk/supertux/data/levels/world2/level1.stl
   trunk/supertux/data/levels/world2/level2.stl
   trunk/supertux/data/levels/world2/trees.stl
   trunk/supertux/data/levels/world2/underconstruction.stl
   trunk/supertux/data/levels/world2/updown.stl
   trunk/supertux/data/levels/world2/village.stl
   trunk/supertux/data/levels/world2/worldmap.stwm
   trunk/supertux/src/level.cpp
   trunk/supertux/src/level.hpp
   trunk/supertux/src/sector.cpp
   trunk/supertux/src/worldmap/worldmap.cpp
Log:
#318: Automatically run default.nut for each level/sector and worldmap. We may want to consider moving world.nut functionality into default.nut.

Modified: trunk/supertux/data/levels/test/intro.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/test/intro2.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/test/keydoors.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/test/snowslope.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/test/transition.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/Crumbling_Path.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/airkey.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/builder.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/christophB.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/detour.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/fish.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/key1.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/key2.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/key3.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/key4.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/key5.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/leaves.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/level1.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/level2.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/trees.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/underconstruction.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/updown.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/village.stl
===================================================================
(Contents removed)

Modified: trunk/supertux/data/levels/world2/worldmap.stwm
===================================================================
(Contents removed)

Modified: trunk/supertux/src/level.cpp
===================================================================
--- trunk/supertux/src/level.cpp	2008-05-16 01:54:30 UTC (rev 5483)
+++ trunk/supertux/src/level.cpp	2008-05-16 15:42:02 UTC (rev 5484)
@@ -67,6 +67,7 @@
 Level::load(const std::string& filepath)
 {
   try {
+    filename = filepath;
     lisp::Parser parser;
     const lisp::Lisp* root = parser.parse(filepath);
 

Modified: trunk/supertux/src/level.hpp
===================================================================
--- trunk/supertux/src/level.hpp	2008-05-16 01:54:30 UTC (rev 5483)
+++ trunk/supertux/src/level.hpp	2008-05-16 15:42:02 UTC (rev 5484)
@@ -46,6 +46,7 @@
   std::string author;
   std::string contact;
   std::string license;
+  std::string filename;
   std::string on_menukey_script;
   Sectors     sectors;
   Statistics  stats;

Modified: trunk/supertux/src/sector.cpp
===================================================================
--- trunk/supertux/src/sector.cpp	2008-05-16 01:54:30 UTC (rev 5483)
+++ trunk/supertux/src/sector.cpp	2008-05-16 15:42:02 UTC (rev 5484)
@@ -44,6 +44,8 @@
 #include "lisp/writer.hpp"
 #include "lisp/list_iterator.hpp"
 #include "tile.hpp"
+#include "file_system.hpp"
+#include "physfs/physfs_stream.hpp"
 #include "audio/sound_manager.hpp"
 #include "game_session.hpp"
 #include "resources.hpp"
@@ -611,6 +613,18 @@
   camera->reset(player->get_pos());
   update_game_objects();
 
+  //Run default.nut just before init script
+  //Check to see if it's in a levelset (info file)
+  std::string basedir = FileSystem::dirname(get_level()->filename);
+  if(PHYSFS_exists((basedir + "/info").c_str())) {
+    try {
+      IFileStream in(basedir + "/default.nut");
+      run_script(in, std::string("Sector(") + name + ") - default.nut");
+    } catch(std::exception& ) {
+      // doesn't exist or erroneous; do nothing
+    }
+  }
+
   // Run init script
   if(init_script != "") {
     std::istringstream in(init_script);

Modified: trunk/supertux/src/worldmap/worldmap.cpp
===================================================================
--- trunk/supertux/src/worldmap/worldmap.cpp	2008-05-16 01:54:30 UTC (rev 5483)
+++ trunk/supertux/src/worldmap/worldmap.cpp	2008-05-16 15:42:02 UTC (rev 5484)
@@ -54,6 +54,7 @@
 #include "main.hpp"
 #include "spawn_point.hpp"
 #include "file_system.hpp"
+#include "physfs/physfs_stream.hpp"
 #include "tile_manager.hpp"
 #include "tile_set.hpp"
 #include "gui/menu.hpp"
@@ -939,6 +940,15 @@
     throw SquirrelError(global_vm, "Couldn't set worldmap in roottable");
   sq_pop(global_vm, 1);
 
+  //Run default.nut just before init script
+  try {
+    IFileStream in(levels_path + "/default.nut");
+    run_script(in, "WorldMap::default.nut");
+  } catch(std::exception& ) {
+    // doesn't exist or erroneous; do nothing
+  }
+
+
   if(init_script != "") {
     std::istringstream in(init_script);
     run_script(in, "WorldMap::init");




More information about the Supertux-Commit mailing list