Skip to content

Commit

Permalink
win32: use GlobalMemoryStatusEx() on modern platforms for Sys_LowPhys…
Browse files Browse the repository at this point in the history
…icalMemory()
  • Loading branch information
ec- committed Nov 11, 2024
1 parent a3b19a3 commit 3a5601b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions code/renderer/tr_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ static void RB_Hyperspace( void ) {

RB_SetGL2D();

if (r_teleporterFlash->integer == 0) {
c.rgba[0] = c.rgba[1] = c.rgba[2] = (backEnd.refdef.time & 0); // fade to black
if ( r_teleporterFlash->integer == 0 ) {
c.rgba[0] = c.rgba[1] = c.rgba[2] = 0; // fade to black
} else {
c.rgba[0] = c.rgba[1] = c.rgba[2] = (backEnd.refdef.time & 255); // fade to white
}
Expand Down
4 changes: 2 additions & 2 deletions code/renderer2/tr_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ static void RB_Hyperspace( void ) {
// do initialization shit
}

if (r_teleporterFlash->integer == 0) {
c = ( backEnd.refdef.time & 0 ) / 255.0f; // fade to black
if ( r_teleporterFlash->integer == 0 ) {
c = 0.0; // fade to black
} else {
c = ( backEnd.refdef.time & 255 ) / 255.0f; // fade to white
}
Expand Down
4 changes: 2 additions & 2 deletions code/renderervk/tr_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ static void RB_Hyperspace( void ) {

RB_SetGL2D();

if (r_teleporterFlash->integer == 0) {
c.rgba[0] = c.rgba[1] = c.rgba[2] = (backEnd.refdef.time & 0); // fade to black
if ( r_teleporterFlash->integer == 0 ) {
c.rgba[0] = c.rgba[1] = c.rgba[2] = 0; // fade to black
} else {
c.rgba[0] = c.rgba[1] = c.rgba[2] = (backEnd.refdef.time & 255); // fade to white
}
Expand Down
11 changes: 11 additions & 0 deletions code/win32/win_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,20 @@ Sys_LowPhysicalMemory
==================
*/
qboolean Sys_LowPhysicalMemory( void ) {
#if _MSC_VER < 1600 // MSVC 2008 and lower, assume win9x compatibility builds
MEMORYSTATUS stat;
GlobalMemoryStatus( &stat );
return (stat.dwTotalPhys <= MEM_THRESHOLD) ? qtrue : qfalse;
#else
MEMORYSTATUSEX stat;
stat.dwLength = sizeof(stat);

if ( !GlobalMemoryStatusEx( &stat ) ) {
return qfalse;
}

return (stat.ullAvailPhys <= MEM_THRESHOLD) ? qtrue : qfalse;
#endif
}


Expand Down

0 comments on commit 3a5601b

Please sign in to comment.