]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Elric added BuffBigLong, BuffBigShort, BuffLittleLong, and BuffLittleShort functions...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 27 Mar 2003 08:58:07 +0000 (08:58 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 27 Mar 2003 08:58:07 +0000 (08:58 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2856 d7cf8633-e32d-0410-b094-e92efae38249

common.c
common.h

index c3ae64b09e787a1d55726b1a494bfb6787885422..cd6c392c2686733c192c889ecbbef1343f4fdbd3 100644 (file)
--- a/common.c
+++ b/common.c
@@ -123,6 +123,30 @@ float FloatNoSwap (float f)
 }
 #endif
 
+
+// Extract integers from buffers
+
+unsigned int BuffBigLong (const qbyte *buffer)
+{
+       return (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
+}
+
+unsigned short BuffBigShort (const qbyte *buffer)
+{
+       return (buffer[0] << 8) | buffer[1];
+}
+
+unsigned int BuffLittleLong (const qbyte *buffer)
+{
+       return (buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | buffer[0];
+}
+
+unsigned short BuffLittleShort (const qbyte *buffer)
+{
+       return (buffer[1] << 8) | buffer[0];
+}
+
+
 /*
 ==============================================================================
 
index 80d80e48af8477e3712348912ac85a6db88d4207..743b499ae1026c405bd565e74a8482a111829819 100644 (file)
--- a/common.h
+++ b/common.h
@@ -91,6 +91,12 @@ extern float (*BigFloat) (float l);
 extern float (*LittleFloat) (float l);
 #endif
 
+unsigned int BuffBigLong (const qbyte *buffer);
+unsigned short BuffBigShort (const qbyte *buffer);
+unsigned int BuffLittleLong (const qbyte *buffer);
+unsigned short BuffLittleShort (const qbyte *buffer);
+
+
 //============================================================================
 
 void MSG_WriteChar (sizebuf_t *sb, int c);