Use the endian swapping functions provided by SDL.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3201 4a71c877-e1ca-e34f-864e-861f7616d084
master
Freddie Witherden 2007-12-27 19:29:53 +00:00
parent 31940330ab
commit 6a338c71ce
1 changed files with 9 additions and 17 deletions

View File

@ -27,15 +27,7 @@
#include "lib/framework/strnlen1.h"
#include <string.h>
#ifdef WZ_OS_WIN
# include <winsock.h>
#else
# include <arpa/inet.h>
#ifdef WZ_OS_MAC
# undef MIN
# undef MAX
#endif
#endif
#include <SDL_endian.h>
#include "../framework/frame.h"
#include "netplay.h"
@ -156,11 +148,11 @@ BOOL NETint16_t(int16_t *ip)
// Convert the integer into the network byte order (big endian)
if (NETgetPacketDir() == PACKET_ENCODE)
{
*store = htons(*ip);
*store = SDL_SwapBE16(*ip);
}
else if (NETgetPacketDir() == PACKET_DECODE)
{
*ip = ntohs(*store);
*ip = SDL_SwapBE16(*store);
}
// Increment the size of the message
@ -182,11 +174,11 @@ BOOL NETuint16_t(uint16_t *ip)
// Convert the integer into the network byte order (big endian)
if (NETgetPacketDir() == PACKET_ENCODE)
{
*store = htons(*ip);
*store = SDL_SwapBE16(*ip);
}
else if (NETgetPacketDir() == PACKET_DECODE)
{
*ip = ntohs(*store);
*ip = SDL_SwapBE16(*store);
}
// Increment the size of the message
@ -208,11 +200,11 @@ BOOL NETint32_t(int32_t *ip)
// Convert the integer into the network byte order (big endian)
if (NETgetPacketDir() == PACKET_ENCODE)
{
*store = htonl(*ip);
*store = SDL_SwapBE32(*ip);
}
else if (NETgetPacketDir() == PACKET_DECODE)
{
*ip = ntohl(*store);
*ip = SDL_SwapBE32(*store);
}
// Increment the size of the message
@ -234,11 +226,11 @@ BOOL NETuint32_t(uint32_t *ip)
// Convert the integer into the network byte order (big endian)
if (NETgetPacketDir() == PACKET_ENCODE)
{
*store = htonl(*ip);
*store = SDL_SwapBE32(*ip);
}
else if (NETgetPacketDir() == PACKET_DECODE)
{
*ip = ntohl(*store);
*ip = SDL_SwapBE32(*store);
}
// Increment the size of the message