summaryrefslogtreecommitdiff
path: root/src/network/core/udp.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-02-01 22:30:35 +0000
committerrubidium <rubidium@openttd.org>2007-02-01 22:30:35 +0000
commit99f860e68615b011b959ac9edb45660a0396dc1b (patch)
treed1732ff5833da9103bce694429be7bf8317b2f50 /src/network/core/udp.cpp
parent15980fc023c9fffa1af1ab71a446d0154d7962ca (diff)
downloadopenttd-99f860e68615b011b959ac9edb45660a0396dc1b.tar.xz
(svn r8521) -Codechange: initial step in converting Packet to a class; make and use constructors and functions related to the reading/saving the packet size.
Diffstat (limited to 'src/network/core/udp.cpp')
-rw-r--r--src/network/core/udp.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index 2c975215b..865b2ad3a 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -92,7 +92,7 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, const struct sockaddr_in *re
{
int res;
- NetworkSend_FillPacketSize(p);
+ p->PrepareToSend();
/* Send the buffer */
res = sendto(this->sock, (const char*)p->buffer, p->size, 0, (struct sockaddr *)recv, sizeof(*recv));
@@ -109,7 +109,7 @@ void NetworkUDPSocketHandler::ReceivePackets()
struct sockaddr_in client_addr;
socklen_t client_len;
int nbytes;
- Packet p;
+ Packet p(this);
int packet_len;
if (!this->IsConnected()) return;
@@ -122,7 +122,7 @@ void NetworkUDPSocketHandler::ReceivePackets()
/* We got some bytes for the base header of the packet. */
if (nbytes > 2) {
- NetworkRecv_ReadPacketSize(&p);
+ p.PrepareToRead();
/* If the size does not match the packet must be corrupted.
* Otherwise it will be marked as corrupted later on. */
@@ -133,10 +133,6 @@ void NetworkUDPSocketHandler::ReceivePackets()
return;
}
- /* Put the position on the right place */
- p.pos = 2;
- p.next = NULL;
-
/* Handle the packet */
this->HandleUDPPacket(&p, &client_addr);
}