diff --git a/defs.h b/defs.h index 31c2944a6..2df790fad 100644 --- a/defs.h +++ b/defs.h @@ -174,14 +174,13 @@ typedef ull uint64; #else inline void *qmemcpy(void *dst, const void *src, size_t cnt) { - char *out = (char *)dst; - const char *in = (const char *)src; - while ( cnt > 0 ) - { - *out++ = *in++; - --cnt; - } - return dst; + char *out = (char *)dst; + const char *in = (const char *)src; + while (cnt > 0) { + *out++ = *in++; + --cnt; + } + return dst; } #endif @@ -196,25 +195,22 @@ template uint64 __PAIR__(uint32 high, T low) { return (((uint64)high) < // rotate left template T __ROL__(T value, int count) { - const uint nbits = sizeof(T) * 8; - - if ( count > 0 ) - { - count %= nbits; - T high = value >> (nbits - count); - if ( T(-1) < 0 ) // signed value - high &= ~((T(-1) << count)); - value <<= count; - value |= high; - } - else - { - count = -count % nbits; - T low = value << (nbits - count); - value >>= count; - value |= low; - } - return value; + const uint nbits = sizeof(T) * 8; + + if (count > 0) { + count %= nbits; + T high = value >> (nbits - count); + if (T(-1) < 0) // signed value + high &= ~((T(-1) << count)); + value <<= count; + value |= high; + } else { + count = -count % nbits; + T low = value << (nbits - count); + value >>= count; + value |= low; + } + return value; } inline uint16 __ROR2__(uint16 value, int count) { return __ROL__((uint16)value, -count); } @@ -223,30 +219,27 @@ inline uint32 __ROR4__(uint32 value, int count) { return __ROL__((uint32)value, // sign flag template int8 __SETS__(T x) { - if ( sizeof(T) == 1 ) - return int8(x) < 0; - if ( sizeof(T) == 2 ) - return int16(x) < 0; - if ( sizeof(T) == 4 ) - return int32(x) < 0; - return int64(x) < 0; + if (sizeof(T) == 1) + return int8(x) < 0; + if (sizeof(T) == 2) + return int16(x) < 0; + if (sizeof(T) == 4) + return int32(x) < 0; + return int64(x) < 0; } // overflow flag of subtraction (x-y) template int8 __OFSUB__(T x, U y) { - if ( sizeof(T) < sizeof(U) ) - { - U x2 = x; - int8 sx = __SETS__(x2); - return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y)); - } - else - { - T y2 = y; - int8 sx = __SETS__(x); - return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x-y2)); - } + if (sizeof(T) < sizeof(U)) { + U x2 = x; + int8 sx = __SETS__(x2); + return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2 - y)); + } else { + T y2 = y; + int8 sx = __SETS__(x); + return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x - y2)); + } } #endif diff --git a/structs.h b/structs.h index 6219228e7..25ff83d9f 100644 --- a/structs.h +++ b/structs.h @@ -1297,7 +1297,7 @@ struct _SNETUIDATA { char *, DWORD, /* character name will be copied here */ char *, DWORD, /* character "description" will be copied here (used to advertise games) */ BOOL * /* new character? - unsure about this */ - ); + ); void(__cdecl *changenamecallback)(); }; diff --git a/types.h b/types.h index ebf72d336..d5cb4f4f4 100644 --- a/types.h +++ b/types.h @@ -7,17 +7,17 @@ #include "resource.h" -#include -#include -#include #include #include #include #include -#include +#include #include -#include #include +#include +#include +#include +#include #ifdef __GNUC__ #include @@ -25,24 +25,24 @@ // tell Visual C++ to shut the hell up #ifdef _MSC_VER -#pragma warning (disable : 4309) // truncation of constant value -#pragma warning (disable : 4305) // truncation of int -#pragma warning (disable : 4018) // signed/unsigned mismatch -#pragma warning (disable : 4700) // used without having been initialized -#pragma warning (disable : 4804) // unsafe use of type 'bool' in operation -#pragma warning (disable : 4805) // unsafe bool mix -#pragma warning (disable : 4244) // conversion loss -#pragma warning (disable : 4800) // bool perf -#pragma warning (disable : 4146) // negative unsigned +#pragma warning(disable : 4309) // truncation of constant value +#pragma warning(disable : 4305) // truncation of int +#pragma warning(disable : 4018) // signed/unsigned mismatch +#pragma warning(disable : 4700) // used without having been initialized +#pragma warning(disable : 4804) // unsafe use of type 'bool' in operation +#pragma warning(disable : 4805) // unsafe bool mix +#pragma warning(disable : 4244) // conversion loss +#pragma warning(disable : 4800) // bool perf +#pragma warning(disable : 4146) // negative unsigned #endif #include "defs.h" #include "enums.h" #include "structs.h" -#include "DiabloUI/diabloui.h" -#include "3rdParty/Storm/Source/storm.h" #include "3rdParty/PKWare/pkware.h" +#include "3rdParty/Storm/Source/storm.h" +#include "DiabloUI/diabloui.h" // If defined, use copy protection [Default -> Defined] //#define COPYPROT @@ -57,9 +57,8 @@ // Will be replaced with [rep movsd] if optimization is used #define FAST_MEMCPY - /* temp macro for asm XLAT */ -#define ASM_XLAT(eax,ebx) eax = (eax & 0xFFFFFF00) + LOBYTE(ebx[LOBYTE(eax)]) +#define ASM_XLAT(eax, ebx) eax = (eax & 0xFFFFFF00) + LOBYTE(ebx[LOBYTE(eax)]) // header files #include "Source/appfat.h"