mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2024-12-02 08:51:57 +00:00
Formatted code
This commit is contained in:
parent
5e582222cf
commit
afaf66ef40
17 changed files with 237 additions and 200 deletions
|
@ -1,4 +1,4 @@
|
||||||
astyle.exe -v --options=astyle-options.ini --exclude="libs" --recursive *.h
|
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
|
pause
|
|
@ -63,7 +63,7 @@ bool SpursEmulationAssertFailed( const char* filename, int line, const char* exp
|
||||||
#endif
|
#endif
|
||||||
#else // not _WIN32
|
#else // not _WIN32
|
||||||
// DG: POSIX support
|
// DG: POSIX support
|
||||||
raise(SIGTRAP);
|
raise( SIGTRAP );
|
||||||
// DG: end
|
// DG: end
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,7 @@ public:
|
||||||
static const int INVALID_POSITION = -1;
|
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 );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================================================================================================
|
================================================================================================
|
||||||
|
|
|
@ -698,8 +698,8 @@ ID_INLINE void idMath::SinCos( float a, float& s, float& c )
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// DG: non-MSVC version
|
// DG: non-MSVC version
|
||||||
s = sinf(a);
|
s = sinf( a );
|
||||||
c = cosf(a);
|
c = cosf( a );
|
||||||
// DG end
|
// DG end
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ bool AssertFailed( const char* file, int line, const char* expression )
|
||||||
#endif
|
#endif
|
||||||
#else // not _WIN32
|
#else // not _WIN32
|
||||||
// DG: POSIX support
|
// DG: POSIX support
|
||||||
raise(SIGTRAP);
|
raise( SIGTRAP );
|
||||||
// DG: end
|
// DG: end
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ Contains the DxtEncoder implementation for SSE2.
|
||||||
typedef uint16 word;
|
typedef uint16 word;
|
||||||
typedef uint32 dword;
|
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_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_word_mask[4] ) = { 0x0000FFFF, 0x0000FFFF, 0x0000FFFF, 0x0000FFFF };
|
||||||
ALIGN16( static dword SIMD_SSE2_dword_red_mask[4] ) = { 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF };
|
ALIGN16( static dword SIMD_SSE2_dword_red_mask[4] ) = { 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF };
|
||||||
|
|
|
@ -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 p3Z = _mm_splat_ps( p3, 2 );
|
||||||
const __m128 p3W = _mm_splat_ps( p3, 3 );
|
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; )
|
for( int i = 0; i < numVerts; )
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 p3Z = _mm_splat_ps( p3, 2 );
|
||||||
const __m128 p3W = _mm_splat_ps( p3, 3 );
|
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; )
|
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 p3Z = _mm_splat_ps( p3, 2 );
|
||||||
const __m128 p3W = _mm_splat_ps( p3, 3 );
|
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; )
|
for( int i = 0; i < numVerts; )
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,27 +49,33 @@ public:
|
||||||
void Create( const idSoundSample* leadinSample, const idSoundSample* loopingSample ) {}
|
void Create( const idSoundSample* leadinSample, const idSoundSample* loopingSample ) {}
|
||||||
|
|
||||||
// Start playing at a particular point in the buffer. Does an Update() too
|
// 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.
|
// Stop playing.
|
||||||
void Stop(){}
|
void Stop() {}
|
||||||
|
|
||||||
// Stop consuming buffers
|
// Stop consuming buffers
|
||||||
void Pause(){}
|
void Pause() {}
|
||||||
// Start consuming buffers again
|
// Start consuming buffers again
|
||||||
void UnPause(){}
|
void UnPause() {}
|
||||||
|
|
||||||
// Sends new position/volume/pitch information to the hardware
|
// Sends new position/volume/pitch information to the hardware
|
||||||
bool Update()
|
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
|
// returns the RMS levels of the most recently processed block of audio, SSF_FLICKER must have been passed to Start
|
||||||
float GetAmplitude()
|
float GetAmplitude()
|
||||||
{ return 0.0f; }
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// returns true if we can re-use this voice
|
// returns true if we can re-use this voice
|
||||||
bool CompatibleFormat( idSoundSample* s )
|
bool CompatibleFormat( idSoundSample* s )
|
||||||
{ return false; }
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 GetSampleRate() const
|
uint32 GetSampleRate() const
|
||||||
{
|
{
|
||||||
|
@ -83,27 +89,35 @@ public:
|
||||||
class idSoundHardware
|
class idSoundHardware
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
idSoundHardware(){}
|
idSoundHardware() {}
|
||||||
|
|
||||||
void Init(){}
|
void Init() {}
|
||||||
void Shutdown(){}
|
void Shutdown() {}
|
||||||
|
|
||||||
void Update(){}
|
void Update() {}
|
||||||
|
|
||||||
// FIXME: this is a bad name when having multiple sound backends... and maybe it's not even needed
|
// 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
|
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 )
|
idSoundVoice* AllocateVoice( const idSoundSample* leadinSample, const idSoundSample* loopingSample )
|
||||||
{ return NULL; }
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void FreeVoice( idSoundVoice* voice ){}
|
void FreeVoice( idSoundVoice* voice ) {}
|
||||||
|
|
||||||
int GetNumZombieVoices() const
|
int GetNumZombieVoices() const
|
||||||
{ return 0; }
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int GetNumFreeVoices() const
|
int GetNumFreeVoices() const
|
||||||
{ return 0; }
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -208,10 +222,10 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
friend class idSoundHardware_XAudio2;
|
friend class idSoundHardware_XAudio2;
|
||||||
friend class idSoundVoice_XAudio2;
|
friend class idSoundVoice_XAudio2;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool LoadWav( const idStr& name );
|
bool LoadWav( const idStr& name );
|
||||||
bool LoadAmplitude( const idStr& name );
|
bool LoadAmplitude( const idStr& name );
|
||||||
|
|
|
@ -68,7 +68,8 @@ If you have questions concerning this license or the applicable additional terms
|
||||||
Sys_Milliseconds
|
Sys_Milliseconds
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int Sys_Milliseconds() {
|
int Sys_Milliseconds()
|
||||||
|
{
|
||||||
static DWORD sys_timeBase = timeGetTime();
|
static DWORD sys_timeBase = timeGetTime();
|
||||||
return timeGetTime() - sys_timeBase;
|
return timeGetTime() - sys_timeBase;
|
||||||
}
|
}
|
||||||
|
@ -78,15 +79,17 @@ int Sys_Milliseconds() {
|
||||||
Sys_Microseconds
|
Sys_Microseconds
|
||||||
========================
|
========================
|
||||||
*/
|
*/
|
||||||
uint64 Sys_Microseconds() {
|
uint64 Sys_Microseconds()
|
||||||
|
{
|
||||||
static uint64 ticksPerMicrosecondTimes1024 = 0;
|
static uint64 ticksPerMicrosecondTimes1024 = 0;
|
||||||
|
|
||||||
if ( ticksPerMicrosecondTimes1024 == 0 ) {
|
if( ticksPerMicrosecondTimes1024 == 0 )
|
||||||
ticksPerMicrosecondTimes1024 = ( (uint64)Sys_ClockTicksPerSecond() << 10 ) / 1000000;
|
{
|
||||||
|
ticksPerMicrosecondTimes1024 = ( ( uint64 )Sys_ClockTicksPerSecond() << 10 ) / 1000000;
|
||||||
assert( ticksPerMicrosecondTimes1024 > 0 );
|
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
|
returns amount of physical memory in MB
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int Sys_GetSystemRam() {
|
int Sys_GetSystemRam()
|
||||||
|
{
|
||||||
MEMORYSTATUSEX statex;
|
MEMORYSTATUSEX statex;
|
||||||
statex.dwLength = sizeof ( statex );
|
statex.dwLength = sizeof( statex );
|
||||||
GlobalMemoryStatusEx (&statex);
|
GlobalMemoryStatusEx( &statex );
|
||||||
int physRam = statex.ullTotalPhys / ( 1024 * 1024 );
|
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
|
// 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;
|
physRam = ( physRam + 8 ) & ~15;
|
||||||
|
@ -113,13 +117,15 @@ Sys_GetDriveFreeSpace
|
||||||
returns in megabytes
|
returns in megabytes
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int Sys_GetDriveFreeSpace( const char *path ) {
|
int Sys_GetDriveFreeSpace( const char* path )
|
||||||
|
{
|
||||||
DWORDLONG lpFreeBytesAvailable;
|
DWORDLONG lpFreeBytesAvailable;
|
||||||
DWORDLONG lpTotalNumberOfBytes;
|
DWORDLONG lpTotalNumberOfBytes;
|
||||||
DWORDLONG lpTotalNumberOfFreeBytes;
|
DWORDLONG lpTotalNumberOfFreeBytes;
|
||||||
int ret = 26;
|
int ret = 26;
|
||||||
//FIXME: see why this is failing on some machines
|
//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 );
|
ret = ( double )( lpFreeBytesAvailable ) / ( 1024.0 * 1024.0 );
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -130,13 +136,15 @@ int Sys_GetDriveFreeSpace( const char *path ) {
|
||||||
Sys_GetDriveFreeSpaceInBytes
|
Sys_GetDriveFreeSpaceInBytes
|
||||||
========================
|
========================
|
||||||
*/
|
*/
|
||||||
int64 Sys_GetDriveFreeSpaceInBytes( const char * path ) {
|
int64 Sys_GetDriveFreeSpaceInBytes( const char* path )
|
||||||
|
{
|
||||||
DWORDLONG lpFreeBytesAvailable;
|
DWORDLONG lpFreeBytesAvailable;
|
||||||
DWORDLONG lpTotalNumberOfBytes;
|
DWORDLONG lpTotalNumberOfBytes;
|
||||||
DWORDLONG lpTotalNumberOfFreeBytes;
|
DWORDLONG lpTotalNumberOfFreeBytes;
|
||||||
int64 ret = 1;
|
int64 ret = 1;
|
||||||
//FIXME: see why this is failing on some machines
|
//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;
|
ret = lpFreeBytesAvailable;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -148,14 +156,16 @@ Sys_GetVideoRam
|
||||||
returns in megabytes
|
returns in megabytes
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
int Sys_GetVideoRam() {
|
int Sys_GetVideoRam()
|
||||||
|
{
|
||||||
unsigned int retSize = 64;
|
unsigned int retSize = 64;
|
||||||
|
|
||||||
// RB begin
|
// RB begin
|
||||||
#if !defined(__MINGW32__)
|
#if !defined(__MINGW32__)
|
||||||
CComPtr<IWbemLocator> spLoc = NULL;
|
CComPtr<IWbemLocator> spLoc = NULL;
|
||||||
HRESULT hr = CoCreateInstance( CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, ( LPVOID * ) &spLoc );
|
HRESULT hr = CoCreateInstance( CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator, ( LPVOID* ) &spLoc );
|
||||||
if ( hr != S_OK || spLoc == NULL ) {
|
if( hr != S_OK || spLoc == NULL )
|
||||||
|
{
|
||||||
return retSize;
|
return retSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,20 +174,23 @@ int Sys_GetVideoRam() {
|
||||||
|
|
||||||
// Connect to CIM
|
// Connect to CIM
|
||||||
hr = spLoc->ConnectServer( bstrNamespace, NULL, NULL, 0, NULL, 0, 0, &spServices );
|
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;
|
return retSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch the security level to IMPERSONATE so that provider will grant access to system-level objects.
|
// 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 );
|
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;
|
return retSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the vid controller
|
// Get the vid controller
|
||||||
CComPtr<IEnumWbemClassObject> spEnumInst = NULL;
|
CComPtr<IEnumWbemClassObject> spEnumInst = NULL;
|
||||||
hr = spServices->CreateInstanceEnum( CComBSTR( "Win32_VideoController" ), WBEM_FLAG_SHALLOW, NULL, &spEnumInst );
|
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;
|
return retSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,13 +198,16 @@ int Sys_GetVideoRam() {
|
||||||
CComPtr<IWbemClassObject> spInstance = NULL;
|
CComPtr<IWbemClassObject> spInstance = NULL;
|
||||||
hr = spEnumInst->Next( 10000, 1, &spInstance, &uNumOfInstances );
|
hr = spEnumInst->Next( 10000, 1, &spInstance, &uNumOfInstances );
|
||||||
|
|
||||||
if ( hr == S_OK && spInstance ) {
|
if( hr == S_OK && spInstance )
|
||||||
|
{
|
||||||
// Get properties from the object
|
// Get properties from the object
|
||||||
CComVariant varSize;
|
CComVariant varSize;
|
||||||
hr = spInstance->Get( CComBSTR( _T( "AdapterRAM" ) ), 0, &varSize, 0, 0 );
|
hr = spInstance->Get( CComBSTR( _T( "AdapterRAM" ) ), 0, &varSize, 0, 0 );
|
||||||
if ( hr == S_OK ) {
|
if( hr == S_OK )
|
||||||
|
{
|
||||||
retSize = varSize.intVal / ( 1024 * 1024 );
|
retSize = varSize.intVal / ( 1024 * 1024 );
|
||||||
if ( retSize == 0 ) {
|
if( retSize == 0 )
|
||||||
|
{
|
||||||
retSize = 64;
|
retSize = 64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +226,8 @@ Sys_GetCurrentMemoryStatus
|
||||||
all values are in kB except the memoryload
|
all values are in kB except the memoryload
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Sys_GetCurrentMemoryStatus( sysMemoryStats_t &stats ) {
|
void Sys_GetCurrentMemoryStatus( sysMemoryStats_t& stats )
|
||||||
|
{
|
||||||
MEMORYSTATUSEX statex = {};
|
MEMORYSTATUSEX statex = {};
|
||||||
unsigned __int64 work;
|
unsigned __int64 work;
|
||||||
|
|
||||||
|
@ -222,25 +239,25 @@ void Sys_GetCurrentMemoryStatus( sysMemoryStats_t &stats ) {
|
||||||
stats.memoryLoad = statex.dwMemoryLoad;
|
stats.memoryLoad = statex.dwMemoryLoad;
|
||||||
|
|
||||||
work = statex.ullTotalPhys >> 20;
|
work = statex.ullTotalPhys >> 20;
|
||||||
stats.totalPhysical = *(int*)&work;
|
stats.totalPhysical = *( int* )&work;
|
||||||
|
|
||||||
work = statex.ullAvailPhys >> 20;
|
work = statex.ullAvailPhys >> 20;
|
||||||
stats.availPhysical = *(int*)&work;
|
stats.availPhysical = *( int* )&work;
|
||||||
|
|
||||||
work = statex.ullAvailPageFile >> 20;
|
work = statex.ullAvailPageFile >> 20;
|
||||||
stats.availPageFile = *(int*)&work;
|
stats.availPageFile = *( int* )&work;
|
||||||
|
|
||||||
work = statex.ullTotalPageFile >> 20;
|
work = statex.ullTotalPageFile >> 20;
|
||||||
stats.totalPageFile = *(int*)&work;
|
stats.totalPageFile = *( int* )&work;
|
||||||
|
|
||||||
work = statex.ullTotalVirtual >> 20;
|
work = statex.ullTotalVirtual >> 20;
|
||||||
stats.totalVirtual = *(int*)&work;
|
stats.totalVirtual = *( int* )&work;
|
||||||
|
|
||||||
work = statex.ullAvailVirtual >> 20;
|
work = statex.ullAvailVirtual >> 20;
|
||||||
stats.availVirtual = *(int*)&work;
|
stats.availVirtual = *( int* )&work;
|
||||||
|
|
||||||
work = statex.ullAvailExtendedVirtual >> 20;
|
work = statex.ullAvailExtendedVirtual >> 20;
|
||||||
stats.availExtendedVirtual = *(int*)&work;
|
stats.availExtendedVirtual = *( int* )&work;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -248,8 +265,9 @@ void Sys_GetCurrentMemoryStatus( sysMemoryStats_t &stats ) {
|
||||||
Sys_LockMemory
|
Sys_LockMemory
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
bool Sys_LockMemory( void *ptr, int bytes ) {
|
bool Sys_LockMemory( void* ptr, int bytes )
|
||||||
return ( VirtualLock( ptr, (SIZE_T)bytes ) != FALSE );
|
{
|
||||||
|
return ( VirtualLock( ptr, ( SIZE_T )bytes ) != FALSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -257,8 +275,9 @@ bool Sys_LockMemory( void *ptr, int bytes ) {
|
||||||
Sys_UnlockMemory
|
Sys_UnlockMemory
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
bool Sys_UnlockMemory( void *ptr, int bytes ) {
|
bool Sys_UnlockMemory( void* ptr, int bytes )
|
||||||
return ( VirtualUnlock( ptr, (SIZE_T)bytes ) != FALSE );
|
{
|
||||||
|
return ( VirtualUnlock( ptr, ( SIZE_T )bytes ) != FALSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -266,7 +285,8 @@ bool Sys_UnlockMemory( void *ptr, int bytes ) {
|
||||||
Sys_SetPhysicalWorkMemory
|
Sys_SetPhysicalWorkMemory
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Sys_SetPhysicalWorkMemory( int minBytes, int maxBytes ) {
|
void Sys_SetPhysicalWorkMemory( int minBytes, int maxBytes )
|
||||||
|
{
|
||||||
::SetProcessWorkingSetSize( GetCurrentProcess(), minBytes, maxBytes );
|
::SetProcessWorkingSetSize( GetCurrentProcess(), minBytes, maxBytes );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,16 +295,19 @@ void Sys_SetPhysicalWorkMemory( int minBytes, int maxBytes ) {
|
||||||
Sys_GetCurrentUser
|
Sys_GetCurrentUser
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
char *Sys_GetCurrentUser() {
|
char* Sys_GetCurrentUser()
|
||||||
|
{
|
||||||
static char s_userName[1024];
|
static char s_userName[1024];
|
||||||
unsigned long size = sizeof( s_userName );
|
unsigned long size = sizeof( s_userName );
|
||||||
|
|
||||||
|
|
||||||
if ( !GetUserName( s_userName, &size ) ) {
|
if( !GetUserName( s_userName, &size ) )
|
||||||
|
{
|
||||||
strcpy( s_userName, "player" );
|
strcpy( s_userName, "player" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !s_userName[0] ) {
|
if( !s_userName[0] )
|
||||||
|
{
|
||||||
strcpy( s_userName, "player" );
|
strcpy( s_userName, "player" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue