From: havoc Date: Sun, 27 Dec 2009 13:11:08 +0000 (+0000) Subject: added StoreBigShort X-Git-Tag: xonotic-v0.1.0preview~939 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;ds=sidebyside;h=7e999b95f1f73a8d12668256a1979e011355a3ae;p=xonotic%2Fdarkplaces.git added StoreBigShort added StoreLittleLong added StoreLittleShort git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9709 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/common.c b/common.c index 26997319..12a42555 100644 --- a/common.c +++ b/common.c @@ -104,6 +104,26 @@ void StoreBigLong (unsigned char *buffer, unsigned int i) buffer[3] = i & 0xFF; } +void StoreBigShort (unsigned char *buffer, unsigned short i) +{ + buffer[0] = (i >> 8) & 0xFF; + buffer[1] = i & 0xFF; +} + +void StoreLittleLong (unsigned char *buffer, unsigned int i) +{ + buffer[0] = i & 0xFF; + buffer[1] = (i >> 8) & 0xFF; + buffer[2] = (i >> 16) & 0xFF; + buffer[3] = (i >> 24) & 0xFF; +} + +void StoreLittleShort (unsigned char *buffer, unsigned short i) +{ + buffer[0] = i & 0xFF; + buffer[1] = (i >> 8) & 0xFF; +} + /* ============================================================================ diff --git a/common.h b/common.h index 2986045f..a31e822c 100644 --- a/common.h +++ b/common.h @@ -103,6 +103,15 @@ short BuffLittleShort (const unsigned char *buffer); /// Encode a big endian 32bit int to the given \p buffer void StoreBigLong (unsigned char *buffer, unsigned int i); + +/// Encode a big endian 16bit int to the given \p buffer +void StoreBigShort (unsigned char *buffer, unsigned short i); + +/// Encode a little endian 32bit int to the given \p buffer +void StoreLittleLong (unsigned char *buffer, unsigned int i); + +/// Encode a little endian 16bit int to the given \p buffer +void StoreLittleShort (unsigned char *buffer, unsigned short i); //@} //============================================================================