Browse Source

Autoformat some base files

pull/25/head
Anders Jenbo 8 years ago
parent
commit
a08bfa22c0
  1. 85
      defs.h
  2. 2
      structs.h
  3. 35
      types.h

85
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<class T> uint64 __PAIR__(uint32 high, T low) { return (((uint64)high) <
// rotate left
template<class T> 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<class T> 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<class T, class U> 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

2
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)();
};

35
types.h

@ -7,17 +7,17 @@
#include "resource.h"
#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
#include <ddraw.h>
#include <dsound.h>
#include <io.h>
#include <math.h>
#include <time.h>
#include <mmsystem.h>
#include <process.h>
#include <shlobj.h>
#include <shellapi.h>
#include <shlobj.h>
#include <stdio.h>
#include <time.h>
#include <windows.h>
#ifdef __GNUC__
#include <ctype.h>
@ -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"

Loading…
Cancel
Save