From a68d11c8f32ac8795a27fe3bc27e1943ee6dc813 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Tue, 13 Sep 2005 21:33:02 +0000 Subject: Merge createBeing and add_node. --- src/being.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/being.cpp') diff --git a/src/being.cpp b/src/being.cpp index a0b9a88c..579ad54f 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -53,8 +53,14 @@ PATH_NODE::PATH_NODE(unsigned short x, unsigned short y): { } -void add_node(Being *being) +Being* createBeing(unsigned int id, unsigned short job, Map *map) { + Being *being = new Being; + + being->setId(id); + being->job = job; + being->setMap(map); + beings.push_back(being); // If the being is a player, request the name @@ -64,20 +70,25 @@ void add_node(Being *being) WFIFOSET(6); } // If the being is a monster then load the monsterset - else if (being->job >= 1002 && monsterset.find( - being->job - 1002) == monsterset.end()) { + else if (being->job >= 1002 && + monsterset.find(being->job - 1002) == monsterset.end()) + { std::stringstream filename; + filename << "graphics/sprites/monster" << (being->job - 1002) << ".png"; logger->log("%s",filename.str().c_str()); - ResourceManager *resman = ResourceManager::getInstance(); - Image *monsterbitmap = resman->getImage(filename.str()); + + Image *monsterbitmap = + ResourceManager::getInstance()->getImage(filename.str()); + if (!monsterbitmap) { logger->error("Unable to load monster.png"); - } - else { + } else { monsterset[being->job - 1002] = new Spriteset(monsterbitmap, 60, 60); } } + + return being; } void remove_node(unsigned int id) -- cgit v1.2.3-70-g09d2