diff --git a/.gitignore b/.gitignore index d61a18fe..d5cccbae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ build +mohaa-re +out Makefile.local *.swp *tags diff --git a/code/client/cl_ui.cpp b/code/client/cl_ui.cpp index da4749fb..e45cff08 100644 --- a/code/client/cl_ui.cpp +++ b/code/client/cl_ui.cpp @@ -29,9 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cl_ui.h" -#if _MSC_VER -#include -#endif +#include typedef struct { float fadetime; @@ -5443,7 +5441,7 @@ UI_BeginLoadResource ==================== */ void UI_BeginLoadResource( void ) { - uint64_t time = __rdtsc(); + clock_t time = clock(); startCountHigh = time >> 32; startCountLow = time; diff --git a/code/qcommon/memory.c b/code/qcommon/memory.c index 6bab20c0..cd269e0d 100644 --- a/code/qcommon/memory.c +++ b/code/qcommon/memory.c @@ -114,7 +114,7 @@ void Z_Free( void *ptr ) block->prev = block; block->next = block; -#if !defined(_DEBUG) && !defined(WIN32) +#if !defined(_DEBUG) || !defined(WIN32) // free the block free( block ); #else @@ -172,7 +172,7 @@ void *Z_TagMalloc( size_t size, int tag ) #endif size = PAD( size, sizeof( intptr_t ) ); // align to 32/64 bit boundary -#if !defined(_DEBUG) && !defined(WIN32) +#if !defined(_DEBUG) || !defined(WIN32) block = ( memblock_t * )malloc( size ); #else block = HeapAlloc(GetProcessHeap(), 0, size); diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h index c1b5830c..67dadafa 100644 --- a/code/qcommon/q_platform.h +++ b/code/qcommon/q_platform.h @@ -346,6 +346,8 @@ short ShortSwapPtr(const void* l); int LongSwapPtr(const void* l); short ShortNoSwapPtr(const void* l); int LongNoSwapPtr(const void* l); +float FloatSwapPtr(const void* l); +float FloatNoSwapPtr(const void* l); #if defined( Q3_BIG_ENDIAN ) && defined( Q3_LITTLE_ENDIAN ) #error "Endianness defined as both big and little" @@ -354,11 +356,16 @@ int LongNoSwapPtr(const void* l); #define CopyLittleShort(dest, src) CopyShortSwap(dest, src) #define CopyLittleLong(dest, src) CopyLongSwap(dest, src) +// +// Those Little*Ptr are used to avoid alignment problems +// + #define LittleShort(x) ShortSwap(x) #define LittleLong(x) LongSwap(x) #define LittleFloat(x) FloatSwap(&x) #define LittleShortPtr(x) ShortSwapPtr(&x) #define LittleLongPtr(x) LongSwapPtr(&x) +#define LittleFloatPtr(x) FloatSwapPtr(&x) #define BigShort #define BigLong @@ -376,6 +383,7 @@ int LongNoSwapPtr(const void* l); #define LittleFloat #define LittleShortPtr(x) ShortNoSwapPtr(&x) #define LittleLongPtr(x) LongNoSwapPtr(&x) +#define LittleFloatPtr(x) FloatNoSwapPtr(&x) #define BigShort(x) ShortSwap(x) #define BigLong(x) LongSwap(x) diff --git a/code/qcommon/q_shared.c b/code/qcommon/q_shared.c index e4411080..6be454a6 100644 --- a/code/qcommon/q_shared.c +++ b/code/qcommon/q_shared.c @@ -1552,6 +1552,20 @@ int LongNoSwapPtr(const void* l) return out; } +float FloatSwapPtr(const void* l) +{ + float out; + CopyLittleLong((int*)&out, l); + return out; +} + +float FloatNoSwapPtr(const void* l) +{ + float out; + Com_Memcpy(&out, l, sizeof(float)); + return out; +} + void Swap_Init(void) { // Endianness is now computed at compile time diff --git a/code/tiki/tiki_skel.cpp b/code/tiki/tiki_skel.cpp index 460df5a2..9a9b9af1 100644 --- a/code/tiki/tiki_skel.cpp +++ b/code/tiki/tiki_skel.cpp @@ -371,11 +371,11 @@ void TIKI_CacheFileSkel( skelHeader_t *pHeader, skelcache_t *cache, int length ) iOffset += sizeof(skelWeight_t) * numWeights; iOffset += sizeof(skeletorVertex_t); - skelVert->normal[0] = LittleFloat(pVert->normal[0]); - skelVert->normal[1] = LittleFloat(pVert->normal[1]); - skelVert->normal[2] = LittleFloat(pVert->normal[2]); - skelVert->texCoords[0] = LittleFloat(pVert->texCoords[0]); - skelVert->texCoords[1] = LittleFloat(pVert->texCoords[1]); + skelVert->normal[0] = LittleFloatPtr(pVert->normal[0]); + skelVert->normal[1] = LittleFloatPtr(pVert->normal[1]); + skelVert->normal[2] = LittleFloatPtr(pVert->normal[2]); + skelVert->texCoords[0] = LittleFloatPtr(pVert->texCoords[0]); + skelVert->texCoords[1] = LittleFloatPtr(pVert->texCoords[1]); skelVert->numWeights = numWeights; skelVert->numMorphs = numMorphs; @@ -385,20 +385,20 @@ void TIKI_CacheFileSkel( skelHeader_t *pHeader, skelcache_t *cache, int length ) for (k = 0; k < pVert->numMorphs; k++, pMorph++, skelMorph++) { skelMorph->morphIndex = pMorph->morphIndex; - skelMorph->offset[0] = LittleFloat(pMorph->offset[0]); - skelMorph->offset[1] = LittleFloat(pMorph->offset[1]); - skelMorph->offset[2] = LittleFloat(pMorph->offset[2]); + skelMorph->offset[0] = LittleFloatPtr(pMorph->offset[0]); + skelMorph->offset[1] = LittleFloatPtr(pMorph->offset[1]); + skelMorph->offset[2] = LittleFloatPtr(pMorph->offset[2]); } skelWeight_t* pWeight = (skelWeight_t * )((byte*)pMorph); skelWeight_t* skelWeight = (skelWeight_t*)((byte*)skelMorph); for (k = 0; k < pVert->numWeights; k++, skelWeight++, pWeight++) { - skelWeight->boneIndex = LittleLong(pWeight->boneIndex); - skelWeight->boneWeight = LittleLong(pWeight->boneWeight); - skelWeight->offset[0] = LittleFloat(pWeight->offset[0]); - skelWeight->offset[1] = LittleFloat(pWeight->offset[1]); - skelWeight->offset[2] = LittleFloat(pWeight->offset[2]); + skelWeight->boneIndex = LittleLongPtr(pWeight->boneIndex); + skelWeight->boneWeight = LittleLongPtr(pWeight->boneWeight); + skelWeight->offset[0] = LittleFloatPtr(pWeight->offset[0]); + skelWeight->offset[1] = LittleFloatPtr(pWeight->offset[1]); + skelWeight->offset[2] = LittleFloatPtr(pWeight->offset[2]); } pVert = (skeletorVertex_t*)((byte*)pVert + iOffset); diff --git a/code/unix/linux_glimp.c b/code/unix/linux_glimp.c index 33d57a28..f0b16198 100644 --- a/code/unix/linux_glimp.c +++ b/code/unix/linux_glimp.c @@ -69,7 +69,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#define WINDOW_CLASS_NAME "Quake III: Arena" +#define WINDOW_CLASS_NAME PRODUCT_NAME_FULL typedef enum { diff --git a/code/unix/unix_main.c b/code/unix/unix_main.c index 335d6a3a..5b0df2cb 100644 --- a/code/unix/unix_main.c +++ b/code/unix/unix_main.c @@ -981,7 +981,7 @@ void* Sys_GetCGameAPI(void* parms) const char* gamedir; const char* homepath; const char* fn; - const char* gamename = "cgame" ARCH_STRING DLL_EXT; + const char* gamename = "cgame" ARCH_STRING DLL_SUFFIX DLL_EXT; if (cgame_library) Com_Error(ERR_FATAL, "Sys_GetCGameAPI without calling Sys_UnloadCGame"); @@ -1098,7 +1098,10 @@ void *Sys_LoadDll( const char *name, char *fqpath , snprintf (fname, sizeof(fname), "%smips.so", name); #elif defined __x86_64__ snprintf(fname, sizeof(fname), "%sx86_64.so", name); -#else +#elif defined __arm__ + snprintf(fname, sizeof(fname), "%sarm.so", name); +#elif defined __aarch64__ + snprintf(fname, sizeof(fname), "%saarch64.so", name); #error Unknown arch #endif