summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2004-09-28 09:19:56 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2004-09-28 09:19:56 +0000
commitf616a0e4736cc6f7b9b593b5579328469c3cc159 (patch)
tree99b578737778ae3b19f00dbe26964a10fb02724d /src/net
parent4e3e8d31962780b5a7fd6e7ba30d59ae34c75700 (diff)
downloadmana-client-f616a0e4736cc6f7b9b593b5579328469c3cc159.tar.gz
mana-client-f616a0e4736cc6f7b9b593b5579328469c3cc159.tar.bz2
mana-client-f616a0e4736cc6f7b9b593b5579328469c3cc159.tar.xz
mana-client-f616a0e4736cc6f7b9b593b5579328469c3cc159.zip
*** empty log message ***
Diffstat (limited to 'src/net')
-rw-r--r--src/net/protocol.cpp50
-rw-r--r--src/net/protocol.h3
2 files changed, 21 insertions, 32 deletions
diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp
index 2c33d092..d2b1ceb7 100644
--- a/src/net/protocol.cpp
+++ b/src/net/protocol.cpp
@@ -218,11 +218,11 @@ void speak(char *speech) {
WFIFOSET(len+4);
}
-/** request action */
-void action(short type, int id) {
+/** Request action */
+void action(char type, int id) {
WFIFOW(0) = net_w_value(0x0089);
WFIFOL(2) = net_l_value(id);
- WFIFOB(6) = net_l_value(type);
+ WFIFOB(6) = net_b_value(type);
WFIFOSET(7);
}
@@ -231,34 +231,22 @@ void action(short type, int id) {
void attack(unsigned short x, unsigned short y, unsigned char direction) {
int monster_id = 0;
- if(direction==2) {
- for(int j=-1;j<2;j++)
- for(int i=-1;i<1;i++) {
- monster_id = find_monster(x+i, y+j);
- if(monster_id!=0)
- action(0x07, monster_id);
- }
- } else if(direction==6) {
- for(int j=-1;j<2;j++)
- for(int i=0;i<2;i++) {
- monster_id = find_monster(x+i, y+j);
- if(monster_id!=0)
- action(0x07, monster_id);
- }
- } else if(direction==4) {
- for(int j=-1;j<1;j++)
- for(int i=-1;i<2;i++) {
- monster_id = find_monster(x+i, y+j);
- if(monster_id!=0)
- action(0x07, monster_id);
- }
- } else if(direction==0) {
- for(int j=0;j<1;j++)
- for(int i=-1;i<2;i++) {
- monster_id = find_monster(x+i, y+j);
- if(monster_id!=0)
- action(0x07, monster_id);
- }
+ if(direction==SOUTH) {
+ monster_id = find_monster(x, y+1);
+ if(monster_id!=0)
+ action(0, monster_id);
+ } else if(direction==WEST) {
+ monster_id = find_monster(x-1, y);
+ if(monster_id!=0)
+ action(0, monster_id);
+ } else if(direction==NORTH) {
+ monster_id = find_monster(x, y-1);
+ if(monster_id!=0)
+ action(0, monster_id);
+ } else if(direction==EAST) {
+ monster_id = find_monster(x+1, y);
+ if(monster_id!=0)
+ action(0, monster_id);
}
}
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 60293e4a..0a781ee2 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -53,5 +53,6 @@ void map_start();
void walk(unsigned short x, unsigned short y, unsigned char direction);
void speak(char *speech);
void attack(unsigned short x, unsigned short y, unsigned char direction);
-void action(short, int);
+void action(char type, int id);
+
#endif