]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added StoreBigShort
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 27 Dec 2009 13:11:08 +0000 (13:11 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 27 Dec 2009 13:11:08 +0000 (13:11 +0000)
added StoreLittleLong
added StoreLittleShort

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9709 d7cf8633-e32d-0410-b094-e92efae38249

common.c
common.h

index 26997319654de8e385b1e13e0335fab5be1ffcef..12a42555b96b4cbc545c6a17ef14ffe135b77ddc 100644 (file)
--- 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;
+}
+
 /*
 ============================================================================
 
index 2986045f37301738a5ba4d85fccd86a980a39501..a31e822cc5fead2764828b0b3765956eac34701b 100644 (file)
--- 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);
 //@}
 
 //============================================================================