summaryrefslogtreecommitdiffstats
path: root/src/core/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/common.h')
-rw-r--r--src/core/common.h81
1 files changed, 48 insertions, 33 deletions
diff --git a/src/core/common.h b/src/core/common.h
index 50002ab5..155b5dba 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -89,10 +89,8 @@ typedef ptrdiff_t ssize_t;
#include "config.h"
-#ifdef PED_SKIN
#include <rphanim.h>
#include <rpskin.h>
-#endif
#ifdef __GNUC__
#define TYPEALIGN(n) __attribute__ ((aligned (n)))
@@ -121,43 +119,17 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#include "skeleton.h"
#include "Draw.h"
-#if defined(USE_PROPER_SCALING)
- #ifdef FORCE_PC_SCALING
- #define DEFAULT_SCREEN_WIDTH (640)
- #define DEFAULT_SCREEN_HEIGHT (448)
- #else
- #define DEFAULT_SCREEN_WIDTH (640)
- #define DEFAULT_SCREEN_HEIGHT (480)
- #endif
-#elif defined(GTA_PS2)
- #define DEFAULT_SCREEN_WIDTH (640)
- #define DEFAULT_SCREEN_HEIGHT (480)
-#else //elif defined(GTA_PC)
- #define DEFAULT_SCREEN_WIDTH (640)
- #define DEFAULT_SCREEN_HEIGHT (448)
-#endif
-
+#define DEFAULT_SCREEN_WIDTH (640)
+#define DEFAULT_SCREEN_HEIGHT (448)
+#define DEFAULT_SCREEN_HEIGHT_PAL (512)
+#define DEFAULT_SCREEN_HEIGHT_NTSC (448)
#define DEFAULT_ASPECT_RATIO (4.0f/3.0f)
#define DEFAULT_VIEWWINDOW (0.7f)
// game uses maximumWidth/Height, but this probably won't work
// with RW windowed mode
-#ifdef GTA_PS2
- #ifdef GTA_PAL
- #define SCREEN_WIDTH ((float)640)
- #define SCREEN_HEIGHT ((float)512)
- #else
- #define SCREEN_WIDTH ((float)640)
- #define SCREEN_HEIGHT ((float)448)
- #endif
-#else
-#define SCREEN_WIDTH ((float)RsGlobal.width)
+#define SCREEN_WIDTH ((float)RsGlobal.width)
#define SCREEN_HEIGHT ((float)RsGlobal.height)
-#endif
-
-#define SCREEN_HEIGHT_PAL (512)
-#define SCREEN_HEIGHT_NTSC (448)
-
#define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio())
#define SCREEN_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetScaledFOV() * 0.5f)))
@@ -248,12 +220,15 @@ public:
#if (defined(_MSC_VER))
extern int strcasecmp(const char *str1, const char *str2);
+extern int strncasecmp(const char *str1, const char *str2, size_t len);
#endif
extern wchar *AllocUnicode(const char*src);
#define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v))
+#define clamp2(v, center, radius) ((v) < (center) ? Max(v, center - radius) : Min(v, center + radius))
+
inline float sq(float x) { return x*x; }
#define SQR(x) ((x) * (x))
@@ -448,6 +423,15 @@ inline void SkipSaveBuf(uint8 *&buf, int32 skip)
#endif
}
+inline void SkipSaveBuf(uint8*& buf, uint32 &length, int32 skip)
+{
+ buf += skip;
+ length += skip;
+#ifdef VALIDATE_SAVE_SIZE
+ _saveBufCount += skip;
+#endif
+}
+
template<typename T>
inline const T ReadSaveBuf(uint8 *&buf)
{
@@ -457,6 +441,14 @@ inline const T ReadSaveBuf(uint8 *&buf)
}
template<typename T>
+inline const T ReadSaveBuf(uint8 *&buf, uint32 &length)
+{
+ T &value = *(T*)buf;
+ SkipSaveBuf(buf, length, sizeof(T));
+ return value;
+}
+
+template<typename T>
inline T *WriteSaveBuf(uint8 *&buf, const T &value)
{
T *p = (T*)buf;
@@ -465,6 +457,15 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value)
return p;
}
+template<typename T>
+inline T *WriteSaveBuf(uint8 *&buf, uint32 &length, const T &value)
+{
+ T *p = (T*)buf;
+ *p = value;
+ SkipSaveBuf(buf, length, sizeof(T));
+ return p;
+}
+
#define SAVE_HEADER_SIZE (4*sizeof(char)+sizeof(uint32))
@@ -475,6 +476,13 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value)
WriteSaveBuf(buf, d);\
WriteSaveBuf<uint32>(buf, size);
+#define WriteSaveHeaderWithLength(buf,len,a,b,c,d,size) \
+ WriteSaveBuf(buf, len, a);\
+ WriteSaveBuf(buf, len, b);\
+ WriteSaveBuf(buf, len, c);\
+ WriteSaveBuf(buf, len, d);\
+ WriteSaveBuf<uint32>(buf, len, size);
+
#define CheckSaveHeader(buf,a,b,c,d,size)\
assert(ReadSaveBuf<char>(buf) == a);\
assert(ReadSaveBuf<char>(buf) == b);\
@@ -482,5 +490,12 @@ inline T *WriteSaveBuf(uint8 *&buf, const T &value)
assert(ReadSaveBuf<char>(buf) == d);\
assert(ReadSaveBuf<uint32>(buf) == size);
+#define CheckSaveHeaderWithLength(buf,len,a,b,c,d,size)\
+ assert(ReadSaveBuf<char>(buf,len) == a);\
+ assert(ReadSaveBuf<char>(buf,len) == b);\
+ assert(ReadSaveBuf<char>(buf,len) == c);\
+ assert(ReadSaveBuf<char>(buf,len) == d);\
+ assert(ReadSaveBuf<uint32>(buf,len) == size);
+
void cprintf(char*, ...);