Formatted code

This commit is contained in:
Robert Beckebans 2012-12-04 12:11:14 +01:00
parent 5e582222cf
commit afaf66ef40
17 changed files with 237 additions and 200 deletions

View file

@ -1,4 +1,4 @@
astyle.exe -v --options=astyle-options.ini --exclude="libs" --recursive *.h
astyle.exe -v --options=astyle-options.ini --exclude="libs" --exclude="idlib/math/Simd.cpp" --exclude="d3xp/gamesys/SysCvar.cpp" --exclude="d3xp/gamesys/Callbacks.cpp" --exclude="sys/win32/win_cpu.cpp" --exclude="sys/win32/win_main.cpp" --exclude="sys/win32/win_shared.cpp" --recursive *.cpp
astyle.exe -v --options=astyle-options.ini --exclude="libs" --exclude="idlib/math/Simd.cpp" --exclude="d3xp/gamesys/SysCvar.cpp" --exclude="d3xp/gamesys/Callbacks.cpp" --exclude="sys/win32/win_cpu.cpp" --exclude="sys/win32/win_main.cpp" --recursive *.cpp
pause

View file

@ -63,7 +63,7 @@ bool SpursEmulationAssertFailed( const char* filename, int line, const char* exp
#endif
#else // not _WIN32
// DG: POSIX support
raise(SIGTRAP);
raise( SIGTRAP );
// DG: end
#endif // _WIN32

View file

@ -401,7 +401,7 @@ public:
static const int INVALID_POSITION = -1;
};
char* va( VERIFY_FORMAT_STRING const char* fmt, ... ) ATTRIBUTE_PRINTF(1, 2);
char* va( VERIFY_FORMAT_STRING const char* fmt, ... ) ATTRIBUTE_PRINTF( 1, 2 );
/*
================================================================================================

View file

@ -698,8 +698,8 @@ ID_INLINE void idMath::SinCos( float a, float& s, float& c )
}
#else
// DG: non-MSVC version
s = sinf(a);
c = cosf(a);
s = sinf( a );
c = cosf( a );
// DG end
#endif
}

View file

@ -93,7 +93,7 @@ bool AssertFailed( const char* file, int line, const char* expression )
#endif
#else // not _WIN32
// DG: POSIX support
raise(SIGTRAP);
raise( SIGTRAP );
// DG: end
#endif // _WIN32
}

View file

@ -55,7 +55,7 @@ Contains the DxtEncoder implementation for SSE2.
typedef uint16 word;
typedef uint32 dword;
ALIGN16( static __m128i SIMD_SSE2_zero ) = _mm_set_epi32(0, 0, 0, 0);
ALIGN16( static __m128i SIMD_SSE2_zero ) = _mm_set_epi32( 0, 0, 0, 0 );
ALIGN16( static dword SIMD_SSE2_dword_byte_mask[4] ) = { 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF };
ALIGN16( static dword SIMD_SSE2_dword_word_mask[4] ) = { 0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x0000FFFF };
ALIGN16( static dword SIMD_SSE2_dword_red_mask[4] ) = { 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF };

View file

@ -131,7 +131,7 @@ static void R_ShadowVolumeCullBits( byte* cullBits, byte& totalOr, const float r
const __m128 p3Z = _mm_splat_ps( p3, 2 );
const __m128 p3W = _mm_splat_ps( p3, 3 );
__m128i vecTotalOrInt = _mm_set_epi32(0, 0, 0, 0);
__m128i vecTotalOrInt = _mm_set_epi32( 0, 0, 0, 0 );
for( int i = 0; i < numVerts; )
{

View file

@ -83,7 +83,7 @@ static void R_TracePointCullStatic( byte* cullBits, byte& totalOr, const float r
const __m128 p3Z = _mm_splat_ps( p3, 2 );
const __m128 p3W = _mm_splat_ps( p3, 3 );
__m128i vecTotalOrInt = _mm_set_epi32(0, 0, 0, 0);
__m128i vecTotalOrInt = _mm_set_epi32( 0, 0, 0, 0 );
for( int i = 0; i < numVerts; )
{
@ -218,7 +218,7 @@ static void R_TracePointCullSkinned( byte* cullBits, byte& totalOr, const float
const __m128 p3Z = _mm_splat_ps( p3, 2 );
const __m128 p3W = _mm_splat_ps( p3, 3 );
__m128i vecTotalOrInt = _mm_set_epi32(0, 0, 0, 0);
__m128i vecTotalOrInt = _mm_set_epi32( 0, 0, 0, 0 );
for( int i = 0; i < numVerts; )
{

View file

@ -49,27 +49,33 @@ public:
void Create( const idSoundSample* leadinSample, const idSoundSample* loopingSample ) {}
// Start playing at a particular point in the buffer. Does an Update() too
void Start( int offsetMS, int ssFlags ){}
void Start( int offsetMS, int ssFlags ) {}
// Stop playing.
void Stop(){}
void Stop() {}
// Stop consuming buffers
void Pause(){}
void Pause() {}
// Start consuming buffers again
void UnPause(){}
void UnPause() {}
// Sends new position/volume/pitch information to the hardware
bool Update()
{ return false; }
{
return false;
}
// returns the RMS levels of the most recently processed block of audio, SSF_FLICKER must have been passed to Start
float GetAmplitude()
{ return 0.0f; }
{
return 0.0f;
}
// returns true if we can re-use this voice
bool CompatibleFormat( idSoundSample* s )
{ return false; }
{
return false;
}
uint32 GetSampleRate() const
{
@ -83,27 +89,35 @@ public:
class idSoundHardware
{
public:
idSoundHardware(){}
idSoundHardware() {}
void Init(){}
void Shutdown(){}
void Init() {}
void Shutdown() {}
void Update(){}
void Update() {}
// FIXME: this is a bad name when having multiple sound backends... and maybe it's not even needed
void* GetIXAudio2() const // NOTE: originally this returned IXAudio2*, but that was casted to void later anyway
{ return NULL; }
{
return NULL;
}
idSoundVoice* AllocateVoice( const idSoundSample* leadinSample, const idSoundSample* loopingSample )
{ return NULL; }
{
return NULL;
}
void FreeVoice( idSoundVoice* voice ){}
void FreeVoice( idSoundVoice* voice ) {}
int GetNumZombieVoices() const
{ return 0; }
{
return 0;
}
int GetNumFreeVoices() const
{ return 0; }
{
return 0;
}
};
@ -208,10 +222,10 @@ public:
protected:
/*
/*
friend class idSoundHardware_XAudio2;
friend class idSoundVoice_XAudio2;
*/
*/
bool LoadWav( const idStr& name );
bool LoadAmplitude( const idStr& name );

View file

@ -68,7 +68,8 @@ If you have questions concerning this license or the applicable additional terms
Sys_Milliseconds
================
*/
int Sys_Milliseconds() {
int Sys_Milliseconds()
{
static DWORD sys_timeBase = timeGetTime();
return timeGetTime() - sys_timeBase;
}
@ -78,15 +79,17 @@ int Sys_Milliseconds() {
Sys_Microseconds
========================
*/
uint64 Sys_Microseconds() {
uint64 Sys_Microseconds()
{
static uint64 ticksPerMicrosecondTimes1024 = 0;
if ( ticksPerMicrosecondTimes1024 == 0 ) {
ticksPerMicrosecondTimes1024 = ( (uint64)Sys_ClockTicksPerSecond() << 10 ) / 1000000;
if( ticksPerMicrosecondTimes1024 == 0 )
{
ticksPerMicrosecondTimes1024 = ( ( uint64 )Sys_ClockTicksPerSecond() << 10 ) / 1000000;
assert( ticksPerMicrosecondTimes1024 > 0 );
}
return ((uint64)( (int64)Sys_GetClockTicks() << 10 )) / ticksPerMicrosecondTimes1024;
return ( ( uint64 )( ( int64 )Sys_GetClockTicks() << 10 ) ) / ticksPerMicrosecondTimes1024;
}
/*
@ -96,10 +99,11 @@ Sys_GetSystemRam
returns amount of physical memory in MB
================
*/
int Sys_GetSystemRam() {
int Sys_GetSystemRam()
{
MEMORYSTATUSEX statex;
statex.dwLength = sizeof ( statex );
GlobalMemoryStatusEx (&statex);
statex.dwLength = sizeof( statex );
GlobalMemoryStatusEx( &statex );
int physRam = statex.ullTotalPhys / ( 1024 * 1024 );
// HACK: For some reason, ullTotalPhys is sometimes off by a meg or two, so we round up to the nearest 16 megs
physRam = ( physRam + 8 ) & ~15;
@ -113,13 +117,15 @@ Sys_GetDriveFreeSpace
returns in megabytes
================
*/
int Sys_GetDriveFreeSpace( const char *path ) {
int Sys_GetDriveFreeSpace( const char* path )
{
DWORDLONG lpFreeBytesAvailable;
DWORDLONG lpTotalNumberOfBytes;
DWORDLONG lpTotalNumberOfFreeBytes;
int ret = 26;
//FIXME: see why this is failing on some machines
if ( ::GetDiskFreeSpaceEx( path, (PULARGE_INTEGER)&lpFreeBytesAvailable, (PULARGE_INTEGER)&lpTotalNumberOfBytes, (PULARGE_INTEGER)&lpTotalNumberOfFreeBytes ) ) {
if( ::GetDiskFreeSpaceEx( path, ( PULARGE_INTEGER )&lpFreeBytesAvailable, ( PULARGE_INTEGER )&lpTotalNumberOfBytes, ( PULARGE_INTEGER )&lpTotalNumberOfFreeBytes ) )
{
ret = ( double )( lpFreeBytesAvailable ) / ( 1024.0 * 1024.0 );
}
return ret;
@ -130,13 +136,15 @@ int Sys_GetDriveFreeSpace( const char *path ) {
Sys_GetDriveFreeSpaceInBytes
========================
*/
int64 Sys_GetDriveFreeSpaceInBytes( const char * path ) {
int64 Sys_GetDriveFreeSpaceInBytes( const char* path )
{
DWORDLONG lpFreeBytesAvailable;
DWORDLONG lpTotalNumberOfBytes;
DWORDLONG lpTotalNumberOfFreeBytes;
int64 ret = 1;
//FIXME: see why this is failing on some machines
if ( ::GetDiskFreeSpaceEx( path, (PULARGE_INTEGER)&lpFreeBytesAvailable, (PULARGE_INTEGER)&lpTotalNumberOfBytes, (PULARGE_INTEGER)&lpTotalNumberOfFreeBytes ) ) {
if( ::GetDiskFreeSpaceEx( path, ( PULARGE_INTEGER )&lpFreeBytesAvailable, ( PULARGE_INTEGER )&lpTotalNumberOfBytes, ( PULARGE_INTEGER )&lpTotalNumberOfFreeBytes ) )
{
ret = lpFreeBytesAvailable;
}
return ret;
@ -148,14 +156,16 @@ Sys_GetVideoRam
returns in megabytes
================
*/
int Sys_GetVideoRam() {
int Sys_GetVideoRam()
{
unsigned int retSize = 64;
// RB begin
#if !defined(__MINGW32__)
CComPtr<IWbemLocator> spLoc = NULL;
HRESULT hr = CoCreateInstance( CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, ( LPVOID * ) &spLoc );
if ( hr != S_OK || spLoc == NULL ) {
HRESULT hr = CoCreateInstance( CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, ( LPVOID* ) &spLoc );
if( hr != S_OK || spLoc == NULL )
{
return retSize;
}
@ -164,20 +174,23 @@ int Sys_GetVideoRam() {
// Connect to CIM
hr = spLoc->ConnectServer( bstrNamespace, NULL, NULL, 0, NULL, 0, 0, &spServices );
if ( hr != WBEM_S_NO_ERROR ) {
if( hr != WBEM_S_NO_ERROR )
{
return retSize;
}
// Switch the security level to IMPERSONATE so that provider will grant access to system-level objects.
hr = CoSetProxyBlanket( spServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
if ( hr != S_OK ) {
if( hr != S_OK )
{
return retSize;
}
// Get the vid controller
CComPtr<IEnumWbemClassObject> spEnumInst = NULL;
hr = spServices->CreateInstanceEnum( CComBSTR( "Win32_VideoController" ), WBEM_FLAG_SHALLOW, NULL, &spEnumInst );
if ( hr != WBEM_S_NO_ERROR || spEnumInst == NULL ) {
if( hr != WBEM_S_NO_ERROR || spEnumInst == NULL )
{
return retSize;
}
@ -185,13 +198,16 @@ int Sys_GetVideoRam() {
CComPtr<IWbemClassObject> spInstance = NULL;
hr = spEnumInst->Next( 10000, 1, &spInstance, &uNumOfInstances );
if ( hr == S_OK && spInstance ) {
if( hr == S_OK && spInstance )
{
// Get properties from the object
CComVariant varSize;
hr = spInstance->Get( CComBSTR( _T( "AdapterRAM" ) ), 0, &varSize, 0, 0 );
if ( hr == S_OK ) {
if( hr == S_OK )
{
retSize = varSize.intVal / ( 1024 * 1024 );
if ( retSize == 0 ) {
if( retSize == 0 )
{
retSize = 64;
}
}
@ -210,7 +226,8 @@ Sys_GetCurrentMemoryStatus
all values are in kB except the memoryload
================
*/
void Sys_GetCurrentMemoryStatus( sysMemoryStats_t &stats ) {
void Sys_GetCurrentMemoryStatus( sysMemoryStats_t& stats )
{
MEMORYSTATUSEX statex = {};
unsigned __int64 work;
@ -222,25 +239,25 @@ void Sys_GetCurrentMemoryStatus( sysMemoryStats_t &stats ) {
stats.memoryLoad = statex.dwMemoryLoad;
work = statex.ullTotalPhys >> 20;
stats.totalPhysical = *(int*)&work;
stats.totalPhysical = *( int* )&work;
work = statex.ullAvailPhys >> 20;
stats.availPhysical = *(int*)&work;
stats.availPhysical = *( int* )&work;
work = statex.ullAvailPageFile >> 20;
stats.availPageFile = *(int*)&work;
stats.availPageFile = *( int* )&work;
work = statex.ullTotalPageFile >> 20;
stats.totalPageFile = *(int*)&work;
stats.totalPageFile = *( int* )&work;
work = statex.ullTotalVirtual >> 20;
stats.totalVirtual = *(int*)&work;
stats.totalVirtual = *( int* )&work;
work = statex.ullAvailVirtual >> 20;
stats.availVirtual = *(int*)&work;
stats.availVirtual = *( int* )&work;
work = statex.ullAvailExtendedVirtual >> 20;
stats.availExtendedVirtual = *(int*)&work;
stats.availExtendedVirtual = *( int* )&work;
}
/*
@ -248,8 +265,9 @@ void Sys_GetCurrentMemoryStatus( sysMemoryStats_t &stats ) {
Sys_LockMemory
================
*/
bool Sys_LockMemory( void *ptr, int bytes ) {
return ( VirtualLock( ptr, (SIZE_T)bytes ) != FALSE );
bool Sys_LockMemory( void* ptr, int bytes )
{
return ( VirtualLock( ptr, ( SIZE_T )bytes ) != FALSE );
}
/*
@ -257,8 +275,9 @@ bool Sys_LockMemory( void *ptr, int bytes ) {
Sys_UnlockMemory
================
*/
bool Sys_UnlockMemory( void *ptr, int bytes ) {
return ( VirtualUnlock( ptr, (SIZE_T)bytes ) != FALSE );
bool Sys_UnlockMemory( void* ptr, int bytes )
{
return ( VirtualUnlock( ptr, ( SIZE_T )bytes ) != FALSE );
}
/*
@ -266,7 +285,8 @@ bool Sys_UnlockMemory( void *ptr, int bytes ) {
Sys_SetPhysicalWorkMemory
================
*/
void Sys_SetPhysicalWorkMemory( int minBytes, int maxBytes ) {
void Sys_SetPhysicalWorkMemory( int minBytes, int maxBytes )
{
::SetProcessWorkingSetSize( GetCurrentProcess(), minBytes, maxBytes );
}
@ -275,16 +295,19 @@ void Sys_SetPhysicalWorkMemory( int minBytes, int maxBytes ) {
Sys_GetCurrentUser
================
*/
char *Sys_GetCurrentUser() {
char* Sys_GetCurrentUser()
{
static char s_userName[1024];
unsigned long size = sizeof( s_userName );
if ( !GetUserName( s_userName, &size ) ) {
if( !GetUserName( s_userName, &size ) )
{
strcpy( s_userName, "player" );
}
if ( !s_userName[0] ) {
if( !s_userName[0] )
{
strcpy( s_userName, "player" );
}