From: Mathnerd314 Date: Sun, 7 Mar 2010 23:44:35 +0000 (+0000) Subject: Pass player object in to BonusBlock rather than using Sector's global one. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=dcb2f4cff3c67a47729ad73a3399a8c83372e4a3;p=supertux.git Pass player object in to BonusBlock rather than using Sector's global one. SVN-Revision: 6575 --- diff --git a/src/object/bonus_block.cpp b/src/object/bonus_block.cpp index 9a4117516..2fb6bc8a7 100644 --- a/src/object/bonus_block.cpp +++ b/src/object/bonus_block.cpp @@ -114,9 +114,9 @@ BonusBlock::~BonusBlock() } void -BonusBlock::hit(Player& ) +BonusBlock::hit(Player & player) { - try_open(); + try_open(player); } HitResponse @@ -124,7 +124,7 @@ BonusBlock::collision(GameObject& other, const CollisionHit& hit){ Player* player = dynamic_cast (&other); if (player) { - if (player->does_buttjump) try_open(); + if (player->does_buttjump) try_open(*player); } BadGuy* badguy = dynamic_cast (&other); @@ -133,21 +133,21 @@ BonusBlock::collision(GameObject& other, const CollisionHit& hit){ // Badguy's bottom has to be below the top of the block // SHIFT_DELTA is required to slide over one tile gaps. if( badguy->can_break() && ( badguy->get_bbox().get_bottom() > get_bbox().get_top() + SHIFT_DELTA ) ){ - try_open(); + try_open(*player); } } Portable* portable = dynamic_cast (&other); if(portable) { MovingObject* moving = dynamic_cast (&other); if(moving->get_bbox().get_top() > get_bbox().get_bottom() - SHIFT_DELTA) { - try_open(); + try_open(*player); } } return Block::collision(other, hit); } void -BonusBlock::try_open() +BonusBlock::try_open(Player & player) { if(sprite->get_action() == "empty") { sound_manager->play("sounds/brick.wav"); @@ -156,8 +156,6 @@ BonusBlock::try_open() Sector* sector = Sector::current(); assert(sector); - assert(sector->player); - Player& player = *(sector->player); Direction direction = (player.get_bbox().get_middle().x > get_bbox().get_middle().x) ? LEFT : RIGHT; switch(contents) { diff --git a/src/object/bonus_block.hpp b/src/object/bonus_block.hpp index 98eb74780..47219293a 100644 --- a/src/object/bonus_block.hpp +++ b/src/object/bonus_block.hpp @@ -27,7 +27,7 @@ public: virtual ~BonusBlock(); HitResponse collision(GameObject& other, const CollisionHit& hit); - void try_open(); + void try_open(Player & player); enum Contents { CONTENT_COIN,