Made trampolines less likely to interfere with level design:
[supertux.git] / src / main.cpp
index c082224..1eadf1a 100644 (file)
@@ -86,7 +86,7 @@ static void init_physfs(const char* argv0)
 
   // Initialize physfs (this is a slightly modified version of
   // PHYSFS_setSaneConfig
-  const char* application = PACKAGE_NAME;
+  const char* application = "supertux2"; //instead of PACKAGE_NAME so we can coexist with MS1
   const char* userdir = PHYSFS_getUserDir();
   const char* dirsep = PHYSFS_getDirSeparator();
   char* writedir = new char[strlen(userdir) + strlen(application) + 2];
@@ -445,7 +445,6 @@ int main(int argc, char** argv)
     
   try {
     Console::instance = new Console();
-//  srand(time(0));            // this breaks repeatability in random numbers
     init_physfs(argv[0]);
     init_sdl();
     
@@ -476,15 +475,20 @@ int main(int argc, char** argv)
       std::string dir = FileSystem::dirname(config->start_level);
       PHYSFS_addToSearchPath(dir.c_str(), true);
 
-      init_rand();        // play_demo sets seed, record_demo uses it
-
       if(config->start_level.size() > 4 &&
-              config->start_level.compare(config->start_level.size() - 5, 4, ".stwm") == 0) {
-          main_loop->push_screen(new WorldMapNS::WorldMap(config->start_level));
+              config->start_level.compare(config->start_level.size() - 5, 5, ".stwm") == 0) {
+          init_rand();
+          main_loop->push_screen(new WorldMapNS::WorldMap(
+                      FileSystem::basename(config->start_level)));
       } else {
+        init_rand();//If level uses random eg. for
+        // rain particles before we do this:
         std::auto_ptr<GameSession> session (
                 new GameSession(FileSystem::basename(config->start_level)));
         
+        config->random_seed =session->get_demo_random_seed(config->start_demo);
+        init_rand();//initialise generator with seed from session
+
         if(config->start_demo != "")
           session->play_demo(config->start_demo);
 
@@ -497,6 +501,7 @@ int main(int argc, char** argv)
       main_loop->push_screen(new TitleScreen());
     }
 
+    //init_rand(); PAK: this call might subsume the above 3, but I'm chicken!
     main_loop->run();
 
   } catch(std::exception& e) {