summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-07-31 18:24:18 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-07-31 18:24:18 +0000
commit6e6c1d4b25e7c833b68da0a2aba6861879e08881 (patch)
treef569bb4704c5b32c658b560d56dde8aa12f81b64
parentb01c9a0e4dd2c606c043ec9beb8a33f26bef7bf8 (diff)
downloadmanaserv-6e6c1d4b25e7c833b68da0a2aba6861879e08881.tar.gz
manaserv-6e6c1d4b25e7c833b68da0a2aba6861879e08881.tar.bz2
manaserv-6e6c1d4b25e7c833b68da0a2aba6861879e08881.tar.xz
manaserv-6e6c1d4b25e7c833b68da0a2aba6861879e08881.zip
Fixed registering for the test client (send version as integer) and corrected
the off by one packed size.
-rw-r--r--ChangeLog5
-rw-r--r--src/client.cpp6
-rw-r--r--src/messagein.cpp9
-rw-r--r--src/netcomputer.cpp3
4 files changed, 13 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index b59946f6..72ba27d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-31 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/client.cpp, src/netcomputer.cpp: Fixed registering (send version
+ as integer) and corrected the off by one packed size.
+
2006-07-27 Eugenio Favalli <elvenprogrammer@gmail.com>
* tmwserv.cbp, tmwserv.dev: Updated project files.
diff --git a/src/client.cpp b/src/client.cpp
index 6685949f..82548c89 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -121,7 +121,7 @@ int main(int argc, char *argv[])
// Register
msg.writeShort(PAMSG_REGISTER);
// We send the client version
- msg.writeString(PACKAGE_VERSION);
+ msg.writeLong(0);
std::cout << "Account name: ";
std::cin >> line;
msg.writeString(line);
@@ -336,8 +336,7 @@ int main(int argc, char *argv[])
// Send prepared message
if (!exit && connected) {
ENetPacket *packet = enet_packet_create(
- msg.getData(),
- msg.getDataSize() + 1,
+ msg.getData(), msg.getDataSize(),
ENET_PACKET_FLAG_RELIABLE);
// Send the packet to the peer over channel id 0.
enet_peer_send(msgDestination == 0 ? peerAccount : peerGame, 0, packet);
@@ -640,7 +639,6 @@ void parsePacket(char *data, int recvLength) {
<< "---------------" << std::endl;
std::cout << int(charNumber) << " character(s) in the account."
<< std::endl;
- char charID;
for (unsigned int i = 0; i < charNumber; i++) {
std::cout << int(i) << ". "
<< msg.readString() << ":" << std::endl;
diff --git a/src/messagein.cpp b/src/messagein.cpp
index f5ae44db..54d74809 100644
--- a/src/messagein.cpp
+++ b/src/messagein.cpp
@@ -97,16 +97,17 @@ std::string MessageIn::readString(int length)
length = readShort();
}
- // Make sure the string isn't erroneus
+ // Make sure the string isn't erroneous
if (length < 0 || mPos + length > mPacket->length) {
mPos = mPacket->length + 1;
return "";
}
// Read the string
- char const *stringBeg = mPacket->data + mPos,
- *stringEnd = (char const *)memchr(stringBeg, '\0', length);
- std::string readString(stringBeg, stringEnd ? stringEnd - stringBeg : length);
+ char const *stringBeg = mPacket->data + mPos;
+ char const *stringEnd = (char const *)memchr(stringBeg, '\0', length);
+ std::string readString(stringBeg,
+ stringEnd ? stringEnd - stringBeg : length);
mPos += length;
return readString;
}
diff --git a/src/netcomputer.cpp b/src/netcomputer.cpp
index 2a8ecc22..dc692916 100644
--- a/src/netcomputer.cpp
+++ b/src/netcomputer.cpp
@@ -43,8 +43,7 @@ void NetComputer::disconnect(const std::string &reason)
void NetComputer::send(const Packet *p)
{
// Create a reliable packet.
- ENetPacket *packet = enet_packet_create(p->data,
- p->length + 1,
+ ENetPacket *packet = enet_packet_create(p->data, p->length,
ENET_PACKET_FLAG_RELIABLE);
// Send the packet to the peer over channel id 0.