diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2004-10-03 13:34:33 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2004-10-03 13:34:33 +0000 |
commit | 1c44e1f097d387fcce872f4b67c9996c050e83f9 (patch) | |
tree | 1aeefd98eb1b24f3c3901bbe25c2014d145a6daa /src/game.cpp | |
parent | 33a122be88b1d16f6a45060a0237d643877f4ae3 (diff) | |
download | mana-1c44e1f097d387fcce872f4b67c9996c050e83f9.tar.gz mana-1c44e1f097d387fcce872f4b67c9996c050e83f9.tar.bz2 mana-1c44e1f097d387fcce872f4b67c9996c050e83f9.tar.xz mana-1c44e1f097d387fcce872f4b67c9996c050e83f9.zip |
*** empty log message ***
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/game.cpp b/src/game.cpp index 5b776845..3dbd599f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -298,8 +298,9 @@ int get_packet_length(short id) { void do_parse() { unsigned short id; char *temp; - //char direction; + char direction; NODE *node = NULL; + PATH_NODE *pn; int len; // We need at least 2 bytes to identify a packet @@ -422,8 +423,22 @@ void do_parse() { add_node(node); } node->path = calculate_path(get_src_x(RFIFOP(50)),get_src_y(RFIFOP(50)),get_dest_x(RFIFOP(50)),get_dest_y(RFIFOP(50))); - if(node->path!=NULL) { - set_coordinates(node->coordinates, node->path->x, node->path->y, 0); + if(node->path!=NULL) { + direction = 0; + if(node->path->next) { + if(node->path->next->x>node->path->x && node->path->next->y>node->path->y)direction = SE; + else if(node->path->next->x<node->path->x && node->path->next->y>node->path->y)direction = SW; + else if(node->path->next->x>node->path->x && node->path->next->y<node->path->y)direction = NE; + else if(node->path->next->x<node->path->x && node->path->next->y<node->path->y)direction = NW; + else if(node->path->next->x>node->path->x)direction = EAST; + else if(node->path->next->x<node->path->x)direction = WEST; + else if(node->path->next->y>node->path->y)direction = SOUTH; + else if(node->path->next->y<node->path->y)direction = NORTH; + } + pn = node->path; + node->path = node->path->next; + free(pn); + set_coordinates(node->coordinates, node->path->x, node->path->y, direction); node->action = WALK; node->tick_time = tick_time; } |