From 47c58b6b5d40807eee7bd37fa2fd5d2188a333fd Mon Sep 17 00:00:00 2001 From: Wolfgang Becker Date: Sun, 30 Aug 2009 15:41:51 +0000 Subject: [PATCH] Patchs by Matt McCutche to fix Treeboss related Bugs 469 and 504. * Tree willowisps should start at tree boss, not (0, 0) * Crash if tree boss creates root while player is dying SVN-Revision: 5911 --- src/badguy/ghosttree.cpp | 6 ++++-- src/badguy/treewillowisp.cpp | 6 ++---- src/badguy/treewillowisp.hpp | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/badguy/ghosttree.cpp b/src/badguy/ghosttree.cpp index e349f6d92..c00538ea9 100644 --- a/src/badguy/ghosttree.cpp +++ b/src/badguy/ghosttree.cpp @@ -158,8 +158,10 @@ GhostTree::active_update(float elapsed_time) if(root_timer.check()) { /* TODO indicate root with an animation */ Player* player = get_nearest_player(); - Root* root = new Root(Vector(player->get_bbox().get_left(), get_bbox().get_bottom()+ROOT_TOP_OFFSET)); - Sector::current()->add_object(root); + if (player) { + Root* root = new Root(Vector(player->get_bbox().get_left(), get_bbox().get_bottom()+ROOT_TOP_OFFSET)); + Sector::current()->add_object(root); + } } } else if (mystate == STATE_SWALLOWING) { if (suck_lantern) { diff --git a/src/badguy/treewillowisp.cpp b/src/badguy/treewillowisp.cpp index a1a63438c..f25ea5323 100644 --- a/src/badguy/treewillowisp.cpp +++ b/src/badguy/treewillowisp.cpp @@ -37,16 +37,14 @@ static const float SUCKSPEED = 25; TreeWillOWisp::TreeWillOWisp(GhostTree* tree, const Vector& pos, float radius, float speed) - : BadGuy(Vector(0, 0), "images/creatures/willowisp/willowisp.sprite", + : BadGuy(tree->get_pos() + pos, "images/creatures/willowisp/willowisp.sprite", LAYER_OBJECTS - 20), was_sucked(false), mystate(STATE_DEFAULT), tree(tree) { - treepos_delta = pos; sound_manager->preload(SOUNDFILE); this->radius = radius; this->angle = 0; this->speed = speed; - start_position = tree->get_pos() + treepos_delta; set_colgroup_active(COLGROUP_MOVING); } @@ -137,7 +135,7 @@ TreeWillOWisp::active_update(float elapsed_time) } angle = fmodf(angle + elapsed_time * speed, (float) (2*M_PI)); - Vector newpos(tree->get_pos() + treepos_delta + Vector(sin(angle) * radius, 0)); + Vector newpos(start_position + Vector(sin(angle) * radius, 0)); movement = newpos - get_pos(); float sizemod = cos(angle) * 0.8f; /* TODO: modify sprite size */ diff --git a/src/badguy/treewillowisp.hpp b/src/badguy/treewillowisp.hpp index b452e3f56..facd07a50 100644 --- a/src/badguy/treewillowisp.hpp +++ b/src/badguy/treewillowisp.hpp @@ -67,7 +67,6 @@ private: float speed; std::auto_ptr sound_source; - Vector treepos_delta; GhostTree* tree; Vector suck_target; -- 2.11.0