Fixed a Segmentation Fault when mr_iceblock was kicked into a brick containing coins...
[supertux.git] / src / object / comet_particle_system.cpp
index 679ebf0..b9b4754 100644 (file)
@@ -1,5 +1,5 @@
 //  SuperTux
-//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmail.com>
 //
 //  This program is free software: you can redistribute it and/or modify
 //  it under the terms of the GNU General Public License as published by
@@ -32,12 +32,12 @@ CometParticleSystem::CometParticleSystem()
   size_t cometcount = 2;
   for(size_t i=0; i<cometcount; ++i) {
     CometParticle* particle = new CometParticle;
-    particle->pos.x = systemRandom.rand(int(virtual_width));
-    particle->pos.y = systemRandom.rand(int(virtual_height));
-    int cometsize = systemRandom.rand(2);
-    particle->texture = cometimages[cometsize].get();
+    particle->pos.x = graphicsRandom.rand(int(virtual_width));
+    particle->pos.y = graphicsRandom.rand(int(virtual_height));
+    int cometsize = graphicsRandom.rand(2);
+    particle->texture = cometimages[cometsize];
     do {
-      particle->speed = (cometsize+1)*30 + systemRandom.randf(3.6);
+      particle->speed = (cometsize+1)*30 + graphicsRandom.randf(3.6);
     } while(particle->speed < 1);
     particle->speed *= 10; // gravity
 
@@ -48,7 +48,7 @@ CometParticleSystem::CometParticleSystem()
 void
 CometParticleSystem::parse(const Reader& reader)
 {
-  reader.get("z-pos", z_pos);
+  z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1);
 }
 
 CometParticleSystem::~CometParticleSystem()
@@ -73,7 +73,7 @@ void CometParticleSystem::update(float elapsed_time)
       if ((particle->pos.y <= SCREEN_HEIGHT + abs_y) && (col >= 1)) {
         Sector::current()->add_object(new Bomb(particle->pos, LEFT));
       }
-      int new_x = systemRandom.rand(int(virtual_width)) + int(abs_x);
+      int new_x = graphicsRandom.rand(int(virtual_width)) + int(abs_x);
       int new_y = 0;
       //FIXME: Don't move particles over solid tiles
       particle->pos.x = new_x;