From b7d524423c23470cd11e720eeb48368c072838cb Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 7 Feb 2012 20:49:52 +0000 Subject: Rewritten all packets to use buffers instead of direct sockets, for future cSocketThreads compatibility. Moved data sending from cPacket into cSocket git-svn-id: http://mc-server.googlecode.com/svn/trunk@240 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Endianness.h | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'source/Endianness.h') diff --git a/source/Endianness.h b/source/Endianness.h index 09ae3b372..d2c6a8a0a 100644 --- a/source/Endianness.h +++ b/source/Endianness.h @@ -1,14 +1,12 @@ + #pragma once -#ifdef _WIN32 - #include -#else - #include - #include -#endif + + + // Changes endianness -inline unsigned long long HostToNetwork8( void* a_Value ) +inline unsigned long long HostToNetwork8(const void* a_Value ) { unsigned long long __HostToNetwork8; memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8 ) ); @@ -16,7 +14,11 @@ inline unsigned long long HostToNetwork8( void* a_Value ) return __HostToNetwork8; } -inline unsigned int HostToNetwork4( void* a_Value ) + + + + +inline unsigned int HostToNetwork4(const void* a_Value ) { unsigned int __HostToNetwork4; memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4 ) ); @@ -24,7 +26,11 @@ inline unsigned int HostToNetwork4( void* a_Value ) return __HostToNetwork4; } -inline double NetworkToHostDouble8( void* a_Value ) + + + + +inline double NetworkToHostDouble8(const void* a_Value ) { #define ntohll(x) ((((unsigned long long)ntohl((u_long)x)) << 32) + ntohl(x >> 32)) unsigned long long buf = 0;//(*(unsigned long long*)a_Value); @@ -35,14 +41,22 @@ inline double NetworkToHostDouble8( void* a_Value ) return x; } -inline long long NetworkToHostLong8( void* a_Value ) + + + + +inline long long NetworkToHostLong8(const void * a_Value ) { unsigned long long buf = *(unsigned long long*)a_Value; buf = ntohll(buf); return *reinterpret_cast(&buf); } -inline float NetworkToHostFloat4( void* a_Value ) + + + + +inline float NetworkToHostFloat4(const void* a_Value ) { u_long buf = *(u_long*)a_Value; buf = ntohl( buf ); @@ -50,3 +64,7 @@ inline float NetworkToHostFloat4( void* a_Value ) memcpy( &x, &buf, sizeof(float) ); return x; } + + + + -- cgit v1.2.3