summaryrefslogtreecommitdiff
path: root/src/tools/asm/cmdlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/asm/cmdlib.c')
-rw-r--r--src/tools/asm/cmdlib.c113
1 files changed, 17 insertions, 96 deletions
diff --git a/src/tools/asm/cmdlib.c b/src/tools/asm/cmdlib.c
index 69ce3ff..63ba79e 100644
--- a/src/tools/asm/cmdlib.c
+++ b/src/tools/asm/cmdlib.c
@@ -1,7 +1,7 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
-Copyright (C) 2000-2006 Tim Angus
+Copyright (C) 2000-2013 Darklegion Development
This file is part of Tremulous.
@@ -64,7 +64,7 @@ char *ex_argv[MAX_EX_ARGC];
void ExpandWildcards( int *argc, char ***argv )
{
struct _finddata_t fileinfo;
- int handle;
+ intptr_t handle;
int i;
char filename[1024];
char filebase[1024];
@@ -186,7 +186,7 @@ void _printf( const char *format, ... ) {
vsprintf (text, format, argptr);
va_end (argptr);
- printf(text);
+ printf("%s", text);
#ifdef WIN32
if (!lookedForServer) {
@@ -397,10 +397,12 @@ void Q_getwd (char *out)
int i = 0;
#ifdef WIN32
- _getcwd (out, 256);
+ if (_getcwd (out, 256) == NULL)
+ strcpy(out, "."); /* shrug */
strcat (out, "\\");
#else
- getcwd (out, 256);
+ if (getcwd (out, 256) == NULL)
+ strcpy(out, "."); /* shrug */
strcat (out, "/");
#endif
@@ -976,13 +978,7 @@ int ParseNum (const char *str)
============================================================================
*/
-#ifdef _SGI_SOURCE
-#define __BIG_ENDIAN__
-#endif
-
-#ifdef __BIG_ENDIAN__
-
-short LittleShort (short l)
+short ShortSwap (short l)
{
byte b1,b2;
@@ -992,13 +988,7 @@ short LittleShort (short l)
return (b1<<8) + b2;
}
-short BigShort (short l)
-{
- return l;
-}
-
-
-int LittleLong (int l)
+int LongSwap (int l)
{
byte b1,b2,b3,b4;
@@ -1010,89 +1000,20 @@ int LittleLong (int l)
return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
}
-int BigLong (int l)
-{
- return l;
-}
-
-
-float LittleFloat (float l)
-{
- union {byte b[4]; float f;} in, out;
-
- in.f = l;
- out.b[0] = in.b[3];
- out.b[1] = in.b[2];
- out.b[2] = in.b[1];
- out.b[3] = in.b[0];
-
- return out.f;
-}
-
-float BigFloat (float l)
-{
- return l;
-}
-
-
-#else
-
-
-short BigShort (short l)
-{
- byte b1,b2;
-
- b1 = l&255;
- b2 = (l>>8)&255;
-
- return (b1<<8) + b2;
-}
-
-short LittleShort (short l)
-{
- return l;
-}
+typedef union {
+ float f;
+ unsigned int i;
+} _FloatByteUnion;
+float FloatSwap (const float *f) {
+ _FloatByteUnion out;
-int BigLong (int l)
-{
- byte b1,b2,b3,b4;
+ out.f = *f;
+ out.i = LongSwap(out.i);
- b1 = l&255;
- b2 = (l>>8)&255;
- b3 = (l>>16)&255;
- b4 = (l>>24)&255;
-
- return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
-}
-
-int LittleLong (int l)
-{
- return l;
-}
-
-float BigFloat (float l)
-{
- union {byte b[4]; float f;} in, out;
-
- in.f = l;
- out.b[0] = in.b[3];
- out.b[1] = in.b[2];
- out.b[2] = in.b[1];
- out.b[3] = in.b[0];
-
return out.f;
}
-float LittleFloat (float l)
-{
- return l;
-}
-
-
-#endif
-
-
//=======================================================