From: LMH Date: Mon, 2 Sep 2013 01:32:24 +0000 (-1000) Subject: Dispensed badguys are no longer counted in level stats. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5298befc8e2a9c1d4536f8c5e3f2f5dbdda6ab15;p=supertux.git Dispensed badguys are no longer counted in level stats. 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. --- diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index cb4a923fa..071e17dcc 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -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 (game_object); - if (moving_object == NULL) - throw std::runtime_error(badguy + " is not a moving object."); + bad_guy = dynamic_cast (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;