]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.h
added R_TextureHasAlpha function to check if a loaded texture has alpha
[xonotic/darkplaces.git] / common.h
index 17c2790e000df03b692f5e4e1d856ff53e0b5f70..98467fd3236745027bc53fca790f36563512321f 100644 (file)
--- a/common.h
+++ b/common.h
@@ -31,6 +31,11 @@ typedef enum {false, true}   qboolean;
 
 #include "quakeio.h"
 
+// LordHavoc: MSVC has a different name for snprintf
+#ifdef WIN32
+#define snprintf _snprintf
+#endif
+
 //============================================================================
 
 extern void *qmalloc(unsigned int size);
@@ -56,58 +61,47 @@ void SZ_Print (sizebuf_t *buf, char *data); // strcats onto the sizebuf
 
 //============================================================================
 
-typedef struct link_s
-{
-       struct link_s   *prev, *next;
-} link_t;
-
-
-void ClearLink (link_t *l);
-void RemoveLink (link_t *l);
-void InsertLinkBefore (link_t *l, link_t *before);
-void InsertLinkAfter (link_t *l, link_t *after);
-
-// (type *)STRUCT_FROM_LINK(link_t *link, type, member)
-// ent = STRUCT_FROM_LINK(link,entity_t,order)
-// FIXME: remove this mess!
-#define        STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
-
-//============================================================================
-
 #ifndef NULL
 #define NULL ((void *)0)
 #endif
 
-#define Q_MAXCHAR ((char)0x7f)
-#define Q_MAXSHORT ((short)0x7fff)
-#define Q_MAXINT       ((int)0x7fffffff)
-#define Q_MAXLONG ((int)0x7fffffff)
-#define Q_MAXFLOAT ((int)0x7fffffff)
-
-#define Q_MINCHAR ((char)0x80)
-#define Q_MINSHORT ((short)0x8000)
-#define Q_MININT       ((int)0x80000000)
-#define Q_MINLONG ((int)0x80000000)
-#define Q_MINFLOAT ((int)0x7fffffff)
-
 //============================================================================
-#ifdef WIN32
-short   ShortSwap (short l);
-int    LongSwap (int l);
+#if !defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)
+#if  defined(__i386__) || defined(__ia64__) || defined(WIN32) || (defined(__alpha__) || defined(__alpha)) || defined(__arm__) || (defined(__mips__) && defined(__MIPSEL__)) || defined(__LITTLE_ENDIAN__)
+#define ENDIAN_LITTLE
+#else
+#define ENDIAN_BIG
+#endif
+#endif
+
+short ShortSwap (short l);
+int LongSwap (int l);
 float FloatSwap (float f);
+
+#ifdef ENDIAN_LITTLE
+// little endian
 #define BigShort(l) ShortSwap(l)
 #define LittleShort(l) (l)
 #define BigLong(l) LongSwap(l)
 #define LittleLong(l) (l)
 #define BigFloat(l) FloatSwap(l)
 #define LittleFloat(l) (l)
+#elif ENDIAN_BIG
+// big endian
+#define BigShort(l) (l)
+#define LittleShort(l) ShortSwap(l)
+#define BigLong(l) (l)
+#define LittleLong(l) LongSwap(l)
+#define BigFloat(l) (l)
+#define LittleFloat(l) FloatSwap(l)
 #else
-extern short   (*BigShort) (short l);
-extern short   (*LittleShort) (short l);
-extern int     (*BigLong) (int l);
-extern int     (*LittleLong) (int l);
-extern float   (*BigFloat) (float l);
-extern float   (*LittleFloat) (float l);
+// figure it out at runtime
+extern short (*BigShort) (short l);
+extern short (*LittleShort) (short l);
+extern int (*BigLong) (int l);
+extern int (*LittleLong) (int l);
+extern float (*BigFloat) (float l);
+extern float (*LittleFloat) (float l);
 #endif
 
 //============================================================================
@@ -207,9 +201,11 @@ extern     char    com_gamedir[MAX_OSPATH];
 void COM_WriteFile (char *filename, void *data, int len);
 int COM_FOpenFile (char *filename, QFile **file, qboolean quiet, qboolean zip);
 
+// set by COM_LoadFile functions
+extern int loadsize;
 byte *COM_LoadHunkFile (char *path, qboolean quiet);
 byte *COM_LoadMallocFile (char *path, qboolean quiet);
-void COM_LoadCacheFile (char *path, struct cache_user_s *cu, qboolean quiet);
+//void COM_LoadCacheFile (char *path, struct cache_user_s *cu, qboolean quiet);
 
 byte *COM_LoadFile (char *path, int usehunk, qboolean quiet);