diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-10 22:16:14 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-03-10 22:16:14 +0000 |
commit | 627d4d27d594fb7356c3d4e9f4cb45eff77c1e48 (patch) | |
tree | 8ef849bef7fd774b61057f563fc06fc1180ed8b0 /src | |
parent | 863f3f15f091378c762c0a6f8f30b8f33bb399e4 (diff) | |
download | mana-627d4d27d594fb7356c3d4e9f4cb45eff77c1e48.tar.gz mana-627d4d27d594fb7356c3d4e9f4cb45eff77c1e48.tar.bz2 mana-627d4d27d594fb7356c3d4e9f4cb45eff77c1e48.tar.xz mana-627d4d27d594fb7356c3d4e9f4cb45eff77c1e48.zip |
Fixed showing death bitmap when other players die and fixed the black hair
problem.
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 28 | ||||
-rw-r--r-- | src/being.h | 1 | ||||
-rw-r--r-- | src/game.cpp | 114 | ||||
-rw-r--r-- | src/net/protocol.h | 9 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 1 |
5 files changed, 80 insertions, 73 deletions
diff --git a/src/being.cpp b/src/being.cpp index 6e026a6b..8de5125c 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -29,10 +29,8 @@ Being *player_node = NULL; std::list<Being*> beings; PATH_NODE::PATH_NODE(unsigned short x, unsigned short y): - next(NULL) + x(x), y(y), next(NULL) { - this->x = x; - this->y = y; } void empty() { @@ -109,17 +107,19 @@ void sort() { beings.sort(BeingCompare()); } -Being::Being() { - id = 0; job = 0; - action = 0; frame = 0; - path = NULL; speech = NULL; speech_time = 0; - walk_time = 0; speed = 150; - emotion = 0; emotion_time = 0; - text_x = 0; text_y = 0; - hair_style = 1; hair_color = 1; - weapon = 0; - x = 0; y = 0; direction = 0; - speech_color = 0;//makecol(0, 0, 0); +Being::Being(): + path(NULL), + id(0), job(0), + x(0), y(0), destX(0), destY(0), direction(0), + type(0), action(0), frame(0), + speech(NULL), speech_time(0), speech_color(0), + walk_time(0), + speed(150), + emotion(0), emotion_time(0), + text_x(0), text_y(0), + hair_style(1), hair_color(1), + weapon(0) +{ } Being::~Being() { diff --git a/src/being.h b/src/being.h index 84b693da..41a2cca5 100644 --- a/src/being.h +++ b/src/being.h @@ -45,6 +45,7 @@ class Being { unsigned int id; unsigned short job; unsigned short x, y; + unsigned short destX, destY; unsigned char direction; unsigned char type; unsigned char action; diff --git a/src/game.cpp b/src/game.cpp index 4d89bd67..416e1a92 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -37,6 +37,7 @@ #include "gui/stats.h" #include "gui/ok_dialog.h" #include "resources/mapreader.h" +#include "net/protocol.h" #include <SDL.h> char map_path[480]; @@ -540,7 +541,7 @@ void do_parse() { being = new Being(); being->id = RFIFOL(2); being->speed = RFIFOW(6); - if(being->speed==0) { + if (being->speed == 0) { being->speed = 150; // Else division by 0 when calculating frame } being->job = RFIFOW(14); @@ -564,100 +565,96 @@ void do_parse() { } } break; - // Remove a being - case 0x0080: + + case SMSG_REMOVE_BEING: + // A being should be removed or has died being = find_node(RFIFOL(2)); if (being != NULL) { - if(RFIFOB(6)==1) { // Death - if(being->job>110) { + if (RFIFOB(6) == 1) { // Death + if (being->job > 110) { being->action = MONSTER_DEAD; being->frame = 0; being->walk_time = tick_time; } - //else being->action = DEAD; + else { + being->action = DEAD; + } //remove_node(RFIFOL(2)); } else remove_node(RFIFOL(2)); } break; - // Player moving - case 0x01d8: - case 0x01d9: + + case SMSG_PLAYER_UPDATE_1: + case SMSG_PLAYER_UPDATE_2: + // A message about a player, doesn't include movement. being = find_node(RFIFOL(2)); + if (being == NULL) { being = new Being(); being->id = RFIFOL(2); - being->job = RFIFOW(14); - being->x = get_x(RFIFOP(46)); - being->y = get_y(RFIFOP(46)); - being->direction = get_direction(RFIFOP(46)); add_node(being); - being->walk_time = tick_time; - being->frame = 0; - being->speed = RFIFOW(6); - being->hair_color = RFIFOW(28); - being->hair_style = RFIFOW(16); } + + being->job = RFIFOW(14); + being->x = get_x(RFIFOP(46)); + being->y = get_y(RFIFOP(46)); + being->direction = get_direction(RFIFOP(46)); + being->walk_time = tick_time; + being->frame = 0; + being->speed = RFIFOW(6); + being->hair_color = RFIFOW(28); + being->hair_style = RFIFOW(16); break; - // Monster moving - case 0x007b: - //case 0x01da: + + case SMSG_MOVE_BEING: + // A being nearby is moving being = find_node(RFIFOL(2)); - if(being == NULL) { + + if (being == NULL) { being = new Being(); + being->id = RFIFOL(2); add_node(being); } + being->action = STAND; being->x = get_src_x(RFIFOP(50)); being->y = get_src_y(RFIFOP(50)); - being->direction = 0; - being->id = RFIFOL(2); + being->destX = get_dest_x(RFIFOP(50)); + being->destY = get_dest_y(RFIFOP(50)); being->speed = RFIFOW(6); being->job = RFIFOW(14); being->weapon = RFIFOW(18); - - /*if(being->id==char_info->id) { - char plr_wpn[20]; - sprintf(plr_wpn, "7b %i %i", being->id, being->weapon); - chatBox->chat_log(plr_wpn,BY_SERVER); - }*/ being->setPath(tiledMap->findPath( - get_src_x(RFIFOP(50)), - get_src_y(RFIFOP(50)), - get_dest_x(RFIFOP(50)), - get_dest_y(RFIFOP(50)))); + being->x, being->y, + being->destX, being->destY)); break; - // Being moving - case 0x01da: + + case SMSG_MOVE_PLAYER_BEING: + // A nearby player being moves being = find_node(RFIFOL(2)); + if (being == NULL) { being = new Being(); being->id = RFIFOL(2); - being->job = RFIFOW(14); - being->x = get_src_x(RFIFOP(50)); - being->y = get_src_y(RFIFOP(50)); add_node(being); } - if (being->action != WALK) { - direction = being->direction; - being->action = WALK; - if (get_dest_x(RFIFOP(50)) > being->x) - direction = EAST; - else if (get_dest_x(RFIFOP(50)) < being->x) - direction = WEST; - else if (get_dest_y(RFIFOP(50)) > being->y) - direction = SOUTH; - else if (get_dest_y(RFIFOP(50)) < being->y) - direction = NORTH; - else being->action = STAND; - if (being->action == WALK) - being->walk_time = tick_time; - being->x = get_dest_x(RFIFOP(50)); - being->y = get_dest_y(RFIFOP(50)); - being->direction = direction; - } + + being->speed = RFIFOW(6); + being->job = RFIFOW(14); + being->x = get_src_x(RFIFOP(50)); + being->y = get_src_y(RFIFOP(50)); + being->destX = get_dest_x(RFIFOP(50)); + being->destY = get_dest_y(RFIFOP(50)); + being->hair_style = RFIFOW(16); + being->hair_color = RFIFOW(32); + + being->setPath(tiledMap->findPath( + being->x, being->y, + being->destX, being->destY)); break; + // NPC dialog case 0x00b4: npcTextDialog->addText(RFIFOP(8)); @@ -665,6 +662,7 @@ void do_parse() { npcTextDialog->setVisible(true); current_npc = RFIFOL(4); break; + // Get the items case 0x01ee: for (int loop = 0; loop < (RFIFOW(2) - 4) / 18; loop++) { @@ -1287,7 +1285,7 @@ void do_parse() { break; // Manage non implemented packets default: - //printf("%x\n",id); + log("Unhandled packet: %x\n", id); //alert(pkt_nfo,"","","","",0,0); break; } diff --git a/src/net/protocol.h b/src/net/protocol.h index 11eee3a9..b57e8d7c 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -24,6 +24,15 @@ #ifndef _TMW_PROTOCOL_H #define _TMW_PROTOCOL_H +// Packets from server to client +#define SMSG_REMOVE_BEING 0x0080 // Died, logged out, teleport, etc. +#define SMSG_MOVE_BEING 0x007b // A nearby monster moves +#define SMSG_PLAYER_UPDATE_1 0x01d8 // +#define SMSG_PLAYER_UPDATE_2 0x01d9 // +#define SMSG_MOVE_PLAYER_BEING 0x01da // A nearby player moves + + + /** Packet length by id */ short get_length(short id); diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index c5f3b837..819401ed 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -295,7 +295,6 @@ int MapReader::getProperty(xmlNodePtr node, const char* name, int def) Image *MapReader::getTileWithGid(int gid) { - std::vector<Tileset*>::iterator i; Tileset *set = getTilesetWithGid(gid); if (set) { |