• Welcome to Valhalla Legends Archive.
 

Starcraft 100% CPU

Started by Grok, February 21, 2003, 10:35 AM

Previous topic - Next topic

Grok

Skywing authorized me to post this on NNTP, so I'm copying here for anyone interested.  This was in reply to someone wanting to know how to make starcraft not use 100% CPU.

Updated version:

This is From [vL]Skywing himself:
-----------------------------
"The Starcraft GUI thread doesn't use any wait functions in it's
message loop, which means it uses as much CPU time as the OS will give
it.  My fix was adding a call to a wait function in the message loop,
so the thread would only use processor time when it needed to."

// This is my C version of the problematic message handling function
in Storm.dll for
// SDlgDialog windows.
BOOL __fastcall SDlgDialogProcessMessage(HWND hSDlg)
{
      MSG msg;

      if(!PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) {
            __asm {
                  call Storm_Ordinal_00cb // I just used __asm call so that
I wouldn't
                  call Storm_Ordinal_00dc // have to use typedefs and
function pointers.
            }
            return FALSE;
      }

      if(msg.message == WM_QUIT) {
            PostQuitMessage(msg.wParam);
            return TRUE;
      }

      // ESI = hWnd
      if(hSDlg && IsDialogMessageA(hSDlg, &msg)) // No real accelerators
are used!  Instead,
            return TRUE; // IsDialogMessageA is used with child control
captions (i.e. &V)
      // ESP+04 = msg
      TranslateMessage(&msg);
      DispatchMessage(&msg);

      return TRUE;
}

while(!GetProp(hDlg, "SDlg_EndDialog"))
SDlgDialogProcessMessage(hDlg);

pileofcrap(cantlogin)@sch

#1
what exactly are we looking at here?

Banana fanna fo fanna

#2
Nice, so do we just add this to the DefWndProc hook?

Yoni

#3
??? No, the code above is Skywing's translation of the bad code by Blizzard. You shouldn't use it.

Banana fanna fo fanna

#4
Thought so.