Dispensed badguys are no longer counted in level stats.
authorLMH <lmh.0013@gmail.com>
Mon, 2 Sep 2013 01:32:24 +0000 (15:32 -1000)
committerTobias Markus <tobbi@mozilla-uk.org>
Sat, 26 Oct 2013 16:45:20 +0000 (18:45 +0200)
Modified dispenser to only dispense badguys, instead of moving_objects.  Previously dispenser could be set to dispense not only objects such as rocks or other portables, but even secret areas (which obviously makes a mess if someone is foolish enough to do it in an actual level).  This change limits dispensed objects to badguys only, which also makes it trivially easy to fix the long-standing issue of dispensed badguys being counted for the badguys killed level stat.  This fix was done as well, so the badguy level stat should no longer exceed the total badguys level stat.

src/badguy/dispenser.cpp

index cb4a923..071e17d 100644 (file)
@@ -206,7 +206,7 @@ Dispenser::launch_badguy()
 
     try {
       GameObject *game_object;
-      MovingObject *moving_object;
+      BadGuy *bad_guy;
       Vector spawnpoint;
       Rectf object_bbox;
 
@@ -215,11 +215,11 @@ Dispenser::launch_badguy()
       if (game_object == NULL)
         throw std::runtime_error("Creating " + badguy + " object failed.");
 
-      moving_object = dynamic_cast<MovingObject *> (game_object);
-      if (moving_object == NULL)
-        throw std::runtime_error(badguy + " is not a moving object.");
+      bad_guy = dynamic_cast<BadGuy *> (game_object);
+      if (bad_guy == NULL)
+        throw std::runtime_error(badguy + " is not a badguy.");
 
-      object_bbox = moving_object->get_bbox ();
+      object_bbox = bad_guy->get_bbox ();
 
       if (type == "dropper") {
         spawnpoint = get_anchor_pos (get_bbox (), ANCHOR_BOTTOM);
@@ -234,9 +234,13 @@ Dispenser::launch_badguy()
       }
 
       /* Now we set the real spawn position */
-      moving_object->set_pos (spawnpoint);
+      bad_guy->set_pos (spawnpoint);
 
-      Sector::current()->add_object(moving_object);
+      /* We don't want to count dispensed badguys in level stats */
+      if(bad_guy->countMe)
+        bad_guy->countMe = false;
+
+      Sector::current()->add_object(bad_guy);
     } catch(std::exception& e) {
       log_warning << "Error dispensing badguy: " << e.what() << std::endl;
       return;