summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-11-03 23:15:47 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-11-03 23:27:30 +0100
commitb7f58023d6596d96c36b904c02a81e0b52fc28f1 (patch)
tree7a10a72c7e8fa9ca99e98a913704c76fe5bfe5f9 /src/net
parent0de400f87b7ecc4bcbdbd1f3dfd552c60c5e927b (diff)
downloadmanaserv-b7f58023d6596d96c36b904c02a81e0b52fc28f1.tar.gz
manaserv-b7f58023d6596d96c36b904c02a81e0b52fc28f1.tar.bz2
manaserv-b7f58023d6596d96c36b904c02a81e0b52fc28f1.tar.xz
manaserv-b7f58023d6596d96c36b904c02a81e0b52fc28f1.zip
Renamed write{Byte,Short,Long} to writeInt{8,16,32}
Mainly for consistency with the client, and the general consensus was that these numbered versions were clearer.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/messagein.cpp12
-rw-r--r--src/net/messagein.hpp7
-rw-r--r--src/net/messageout.cpp12
-rw-r--r--src/net/messageout.hpp6
4 files changed, 19 insertions, 18 deletions
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 63fd8778..7d6de273 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -36,10 +36,10 @@ MessageIn::MessageIn(const char *data, int length):
mPos(0)
{
// Read the message ID
- mId = readShort();
+ mId = readInt16();
}
-int MessageIn::readByte()
+int MessageIn::readInt8()
{
int value = -1;
if (mPos < mLength)
@@ -51,7 +51,7 @@ int MessageIn::readByte()
return value;
}
-int MessageIn::readShort()
+int MessageIn::readInt16()
{
int value = -1;
if (mPos + 2 <= mLength)
@@ -65,7 +65,7 @@ int MessageIn::readShort()
return value;
}
-int MessageIn::readLong()
+int MessageIn::readInt32()
{
int value = -1;
if (mPos + 4 <= mLength)
@@ -87,7 +87,7 @@ double MessageIn::readDouble()
memcpy(&value, mData + mPos, sizeof(double));
mPos += sizeof(double);
#else
- int length = readByte();
+ int length = readInt8();
std::istringstream i (readString(length));
i >> value;
#endif
@@ -99,7 +99,7 @@ std::string MessageIn::readString(int length)
// Get string length
if (length < 0)
{
- length = readShort();
+ length = readInt16();
}
// Make sure the string isn't erroneous
diff --git a/src/net/messagein.hpp b/src/net/messagein.hpp
index c6e49ab5..f01c1850 100644
--- a/src/net/messagein.hpp
+++ b/src/net/messagein.hpp
@@ -44,9 +44,10 @@ class MessageIn
*/
int getLength() const { return mLength; }
- int readByte(); /**< Reads a byte. */
- int readShort(); /**< Reads a short. */
- int readLong(); /**< Reads a long. */
+ int readInt8(); /**< Reads a byte. */
+ int readInt16(); /**< Reads a short. */
+ int readInt32(); /**< Reads a long. */
+
/**
* Reads a double. HACKY and should *not* be used for client
* communication!
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index 950da5f3..c8310c55 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -49,7 +49,7 @@ MessageOut::MessageOut(int id):
mData = (char*) malloc(INITIAL_DATA_CAPACITY);
mDataSize = INITIAL_DATA_CAPACITY;
- writeShort(id);
+ writeInt16(id);
}
MessageOut::~MessageOut()
@@ -79,14 +79,14 @@ MessageOut::expand(size_t bytes)
}
}
-void MessageOut::writeByte(int value)
+void MessageOut::writeInt8(int value)
{
expand(mPos + 1);
mData[mPos] = value;
mPos += 1;
}
-void MessageOut::writeShort(int value)
+void MessageOut::writeInt16(int value)
{
expand(mPos + 2);
uint16_t t = ENET_HOST_TO_NET_16(value);
@@ -94,7 +94,7 @@ void MessageOut::writeShort(int value)
mPos += 2;
}
-void MessageOut::writeLong(int value)
+void MessageOut::writeInt32(int value)
{
expand(mPos + 4);
uint32_t t = ENET_HOST_TO_NET_32(value);
@@ -116,7 +116,7 @@ void MessageOut::writeDouble(double value)
o.precision(std::numeric_limits< double >::digits10);
o << value;
std::string str = o.str();
- writeByte(str.size());
+ writeInt8(str.size());
writeString(str, str.size());
#endif
}
@@ -138,7 +138,7 @@ MessageOut::writeString(const std::string &string, int length)
if (length < 0)
{
// Write the length at the start if not fixed
- writeShort(stringLength);
+ writeInt16(stringLength);
length = stringLength;
}
else if (length < stringLength)
diff --git a/src/net/messageout.hpp b/src/net/messageout.hpp
index 270b7963..cf3e0c73 100644
--- a/src/net/messageout.hpp
+++ b/src/net/messageout.hpp
@@ -49,11 +49,11 @@ class MessageOut
*/
void clear();
- void writeByte(int value); /**< Writes an integer on one byte. */
+ void writeInt8(int value); /**< Writes an integer on one byte. */
- void writeShort(int value); /**< Writes an integer on two bytes. */
+ void writeInt16(int value); /**< Writes an integer on two bytes. */
- void writeLong(int value); /**< Writes an integer on four bytes. */
+ void writeInt32(int value); /**< Writes an integer on four bytes. */
/**
* Writes a double. HACKY and should *not* be used for client