summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/net/ea/playerhandler.cpp4
-rw-r--r--src/net/ea/protocol.cpp77
-rw-r--r--src/net/ea/protocol.h3
-rw-r--r--src/net/messageout.cpp61
-rw-r--r--src/net/messageout.h8
7 files changed, 70 insertions, 85 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f460455c..dd8be3f4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -454,7 +454,6 @@ SET(SRCS_EA
net/ea/partyhandler.h
net/ea/playerhandler.cpp
net/ea/playerhandler.h
- net/ea/protocol.cpp
net/ea/protocol.h
net/ea/skillhandler.cpp
net/ea/skillhandler.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 82f4b704..567843e3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -502,7 +502,6 @@ tmw_SOURCES += \
net/ea/partyhandler.h \
net/ea/playerhandler.cpp \
net/ea/playerhandler.h \
- net/ea/protocol.cpp \
net/ea/protocol.h \
net/ea/skillhandler.cpp \
net/ea/skillhandler.h \
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 55d54af8..4ff480d6 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -499,10 +499,8 @@ void PlayerHandler::setDirection(char direction)
void PlayerHandler::setDestination(int x, int y, int direction)
{
- char temp[4] = "";
- set_coordinates(temp, x, y, direction);
MessageOut outMsg(CMSG_PLAYER_CHANGE_DEST);
- outMsg.writeString(temp, 3);
+ outMsg.writeCoordinates(x, y, direction);
}
void PlayerHandler::changeAction(Being::Action action)
diff --git a/src/net/ea/protocol.cpp b/src/net/ea/protocol.cpp
deleted file mode 100644
index 9d9db56f..00000000
--- a/src/net/ea/protocol.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * The Mana World
- * Copyright (C) 2004 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "net/ea/protocol.h"
-
-#define LOBYTE(w) ((unsigned char)(w))
-#define HIBYTE(w) ((unsigned char)(((unsigned short)(w)) >> 8))
-
-void set_coordinates(char *data,
- unsigned short x,
- unsigned short y,
- unsigned char direction)
-{
- short temp;
- temp = x;
- temp <<= 6;
- data[0] = 0;
- data[1] = 1;
- data[2] = 2;
- data[0] = HIBYTE(temp);
- data[1] = (unsigned char)(temp);
- temp = y;
- temp <<= 4;
- data[1] |= HIBYTE(temp);
- data[2] = LOBYTE(temp);
-
- // Translate direction to eAthena format
- switch (direction)
- {
- case 1:
- direction = 0;
- break;
- case 3:
- direction = 1;
- break;
- case 2:
- direction = 2;
- break;
- case 6:
- direction = 3;
- break;
- case 4:
- direction = 4;
- break;
- case 12:
- direction = 5;
- break;
- case 8:
- direction = 6;
- break;
- case 9:
- direction = 7;
- break;
- default:
- // OOPSIE! Impossible or unknown
- direction = (unsigned char)-1;
- }
- data[2] |= direction;
-}
diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h
index c96b1734..0373dd8a 100644
--- a/src/net/ea/protocol.h
+++ b/src/net/ea/protocol.h
@@ -207,7 +207,4 @@ static const int STORAGE_OFFSET = 1;
#define CMSG_ADMIN_KICK 0x00CC
#define CMSG_ADMIN_MUTE 0x0149
-/** Encodes coords and direction in 3 bytes data */
-void set_coordinates(char *data, unsigned short x, unsigned short y, unsigned char direction);
-
#endif
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index 35e9a425..4333ac85 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -103,6 +103,67 @@ void MessageOut::writeInt32(Sint32 value)
mPos += 4;
}
+#ifdef EATHENA_SUPPORT
+
+#define LOBYTE(w) ((unsigned char)(w))
+#define HIBYTE(w) ((unsigned char)(((unsigned short)(w)) >> 8))
+
+void MessageOut::writeCoordinates(unsigned short x, unsigned short y,
+ unsigned char direction)
+{
+ char *data = mData + mPos;
+ mNetwork->mOutSize += 3;
+ mPos += 3;
+
+ short temp;
+ temp = x;
+ temp <<= 6;
+ data[0] = 0;
+ data[1] = 1;
+ data[2] = 2;
+ data[0] = HIBYTE(temp);
+ data[1] = (unsigned char) temp;
+ temp = y;
+ temp <<= 4;
+ data[1] |= HIBYTE(temp);
+ data[2] = LOBYTE(temp);
+
+ // Translate direction to eAthena format
+ switch (direction)
+ {
+ case 1:
+ direction = 0;
+ break;
+ case 3:
+ direction = 1;
+ break;
+ case 2:
+ direction = 2;
+ break;
+ case 6:
+ direction = 3;
+ break;
+ case 4:
+ direction = 4;
+ break;
+ case 12:
+ direction = 5;
+ break;
+ case 8:
+ direction = 6;
+ break;
+ case 9:
+ direction = 7;
+ break;
+ default:
+ // OOPSIE! Impossible or unknown
+ direction = (unsigned char) -1;
+ }
+ data[2] |= direction;
+}
+
+#endif // EATHENA_SUPPORT
+
void MessageOut::writeString(const std::string &string, int length)
{
int stringLength = string.length();
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 9dc31525..5027ea47 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -56,6 +56,14 @@ class MessageOut
void writeInt16(Sint16 value); /**< Writes a short. */
void writeInt32(Sint32 value); /**< Writes a long. */
+#ifdef EATHENA_SUPPORT
+ /**
+ * Encodes coordinates and direction in 3 bytes. Used by eAthena.
+ */
+ void writeCoordinates(unsigned short x, unsigned short y,
+ unsigned char direction);
+#endif
+
/**
* Writes a string. If a fixed length is not given (-1), it is stored
* as a short at the start of the string.