diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-09-13 21:33:02 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-09-13 21:33:02 +0000 |
commit | a68d11c8f32ac8795a27fe3bc27e1943ee6dc813 (patch) | |
tree | 09576a6d6bb87ce2fd2b2a1e577a4b8e9ee5d5ea | |
parent | a4ebc80ec3aa5d5b7faf51ad878d11bd4a8915e9 (diff) | |
download | mana-client-a68d11c8f32ac8795a27fe3bc27e1943ee6dc813.tar.gz mana-client-a68d11c8f32ac8795a27fe3bc27e1943ee6dc813.tar.bz2 mana-client-a68d11c8f32ac8795a27fe3bc27e1943ee6dc813.tar.xz mana-client-a68d11c8f32ac8795a27fe3bc27e1943ee6dc813.zip |
Merge createBeing and add_node.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/being.cpp | 25 | ||||
-rw-r--r-- | src/being.h | 6 | ||||
-rw-r--r-- | src/game.cpp | 27 |
4 files changed, 28 insertions, 32 deletions
@@ -4,6 +4,8 @@ 2005-09-13 Björn Steinbrink <B.Steinbrink@gmx.de> + * src/being.cpp, src/being.h, src/game.cpp: Merged createBeing and + add_node into createBeing. * src/main.cpp, src/main.h, src/gui/char_select.cpp, src/gui/login.cpp: Removed some globals. * src/main.cpp, src/main.h, src/gui/char_select.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) diff --git a/src/being.h b/src/being.h index 8d945b76..3b9e0d93 100644 --- a/src/being.h +++ b/src/being.h @@ -232,9 +232,6 @@ class Being void setPath(std::list<PATH_NODE> path); }; -/** Add a Being to the list */ -void add_node(Being *being); - /** Return a specific id Being */ Being *findNode(unsigned int id); @@ -244,6 +241,9 @@ Being *findNode(unsigned short x, unsigned short y); /** Return a being at specific coordinates with specific type*/ Being *findNode(unsigned short x, unsigned short y, Being::Type type); +/** Create a being and add it to the list of beings */ +Being *createBeing(unsigned int id, unsigned short job, Map *map); + /** Remove a Being */ void remove_node(unsigned int id); diff --git a/src/game.cpp b/src/game.cpp index bfabc528..54f900b1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -172,17 +172,6 @@ int get_elapsed_time(int start_time) } } -Being* createBeing(unsigned int id, unsigned short job, Map *map) -{ - Being *being = new Being; - - being->setId(id); - being->job = job; - being->setMap(map); - - return being; -} - /** * Create all the various globally accessible gui windows */ @@ -318,8 +307,6 @@ void do_init() player_node->setWeapon(char_info->weapon); - add_node(player_node); - remove("packet.list"); // Initialize joypad @@ -1066,7 +1053,6 @@ void do_parse() being->setHairColor(RFIFOW(28)); being->setWeapon(RFIFOW(18)); being->setMap(tiledMap); - add_node(being); } else { @@ -1120,7 +1106,6 @@ void do_parse() if (being == NULL) { being = createBeing(RFIFOL(2), RFIFOW(14), tiledMap); - add_node(being); } being->speed = RFIFOW(6); @@ -1147,7 +1132,6 @@ void do_parse() if (being == NULL) { being = createBeing(RFIFOL(2), RFIFOW(14), tiledMap); - add_node(being); } being->action = Being::STAND; @@ -1167,7 +1151,6 @@ void do_parse() if (being == NULL) { being = createBeing(RFIFOL(2), RFIFOW(14), tiledMap); - add_node(being); } being->speed = RFIFOW(6); @@ -1378,20 +1361,20 @@ void do_parse() { empty_floor_items(); + // Remove the player, so it is not deleted + beings.remove(player_node); + // Delete all beings except the local player std::list<Being *>::iterator i; for (i = beings.begin(); i != beings.end(); i++) { - if ((*i) != player_node) - { - delete (*i); - } + delete (*i); } beings.clear(); autoTarget = NULL; // Re-add the local player node - add_node(player_node); + beings.push_back(player_node); player_node->action = Being::STAND; player_node->frame = 0; |