Browse Source

Merge pull request #1293 from AJenbo/init.cpp

Init.cpp
pull/189/head^2
Robin Eklind 7 years ago committed by GitHub
parent
commit
971a25d7a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 77
      Source/init.cpp
  2. 4
      Source/items.cpp

77
Source/init.cpp

@ -109,28 +109,25 @@ void init_run_office(char *dir)
void init_disable_screensaver(BOOLEAN disable)
{
BOOLEAN v1; // al
char Data[16]; // [esp+4h] [ebp-20h]
DWORD Type; // [esp+14h] [ebp-10h]
DWORD cbData; // [esp+18h] [ebp-Ch]
HKEY phkResult; // [esp+1Ch] [ebp-8h]
BOOLEAN v6; // [esp+20h] [ebp-4h]
BOOLEAN enabled;
char Data[16];
DWORD Type, cbData;
HKEY phkResult;
// BUGFIX: this is probably the worst possible way to do this. Alternatives: ExtEscape() with SETPOWERMANAGEMENT,
// SystemParametersInfo() with SPI_SETSCREENSAVEACTIVE/SPI_SETPOWEROFFACTIVE/SPI_SETLOWPOWERACTIVE
v6 = disable;
if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ | KEY_WRITE, (PHKEY)&phkResult)) {
if (v6) {
if (disable) {
cbData = 16;
if (!RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData))
screensaver_enabled_prev = Data[0] != '0';
v1 = 0;
enabled = FALSE;
} else {
v1 = screensaver_enabled_prev;
enabled = screensaver_enabled_prev;
}
Data[1] = 0;
Data[0] = (v1 != 0) + '0';
Data[0] = enabled ? '1' : '0';
RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2u);
RegCloseKey(phkResult);
}
@ -180,30 +177,29 @@ void init_create_window(int nCmdShow)
void init_kill_mom_parent()
{
HWND v0; // eax
HWND handle;
v0 = init_find_mom_parent();
if (v0) {
PostMessage(v0, WM_CLOSE, 0, 0);
handle = init_find_mom_parent();
if (handle) {
PostMessage(handle, WM_CLOSE, 0, 0);
killed_mom_parent = TRUE;
}
}
HWND init_find_mom_parent()
{
HWND i; // eax
HWND v1; // esi
char ClassName[256]; // [esp+4h] [ebp-100h]
HWND i, handle;
char ClassName[256];
for (i = GetForegroundWindow();; i = GetWindow(v1, GW_HWNDNEXT)) {
v1 = i;
for (i = GetForegroundWindow();; i = GetWindow(handle, GW_HWNDNEXT)) {
handle = i;
if (!i)
break;
GetClassName(i, ClassName, 255);
if (!_strcmpi(ClassName, "MOM Parent"))
break;
}
return v1;
return handle;
}
void init_await_mom_parent_exit()
@ -310,7 +306,7 @@ HANDLE init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags
char *init_strip_trailing_slash(char *path)
{
char *result; // eax
char *result;
result = strrchr(path, '\\');
if (result) {
@ -354,20 +350,18 @@ BOOL init_read_test_file(char *pszPath, char *pszArchive, int flags, HANDLE *phA
void init_get_file_info()
{
int v0; // eax
DWORD v1; // edi
void *v2; // ebx
unsigned int uBytes; // [esp+8h] [ebp-Ch]
DWORD dwHandle; // [esp+Ch] [ebp-8h]
VS_FIXEDFILEINFO *lpBuffer; // [esp+10h] [ebp-4h]
DWORD dwLen;
void *pBlock;
unsigned int uBytes;
DWORD dwHandle;
VS_FIXEDFILEINFO *lpBuffer;
if (GetModuleFileName(ghInst, diablo_exe_path, sizeof(diablo_exe_path))) {
v0 = GetFileVersionInfoSize(diablo_exe_path, &dwHandle);
v1 = v0;
if (v0) {
v2 = DiabloAllocPtr(v0);
if (GetFileVersionInfo(diablo_exe_path, 0, v1, v2)) {
if (VerQueryValue(v2, "\\", (LPVOID *)&lpBuffer, &uBytes))
dwLen = GetFileVersionInfoSize(diablo_exe_path, &dwHandle);
if (dwLen) {
pBlock = DiabloAllocPtr(dwLen);
if (GetFileVersionInfo(diablo_exe_path, 0, dwLen, pBlock)) {
if (VerQueryValue(pBlock, "\\", (LPVOID *)&lpBuffer, &uBytes))
sprintf(
gszVersionNumber,
"version %d.%d.%d.%d",
@ -376,7 +370,7 @@ void init_get_file_info()
lpBuffer->dwProductVersionLS >> 16,
lpBuffer->dwProductVersionLS & 0xFFFF);
}
mem_free_dbg(v2);
mem_free_dbg(pBlock);
}
}
}
@ -416,7 +410,7 @@ LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
void init_activate_window(HWND hWnd, BOOL bActive)
{
LONG dwNewLong; // eax
LONG dwNewLong;
gbActive = bActive;
UiAppActivate(bActive);
@ -437,18 +431,17 @@ void init_activate_window(HWND hWnd, BOOL bActive)
LRESULT __stdcall WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
LRESULT result; // eax
LRESULT result;
if (CurrentProc)
result = CurrentProc(hWnd, Msg, wParam, lParam);
else
result = MainWndProc(hWnd, Msg, wParam, lParam);
return result;
return CurrentProc(hWnd, Msg, wParam, lParam);
return MainWndProc(hWnd, Msg, wParam, lParam);
}
WNDPROC SetWindowProc(WNDPROC NewProc)
{
WNDPROC OldProc; // eax
WNDPROC OldProc;
OldProc = CurrentProc;
CurrentProc = NewProc;

4
Source/items.cpp

@ -1650,7 +1650,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
pre = random(23, 4);
post = random(23, 3);
if (pre && !post) {
if (pre != 0 && post == 0) {
if (random(23, 2))
post = 1;
else
@ -1692,7 +1692,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
goe = PL_Prefix[preidx].PLGOE;
}
}
if (post) {
if (post != 0) {
nl = 0;
for (j = 0; PL_Suffix[j].PLPower != -1; j++) {
if (PL_Suffix[j].PLIType & flgs

Loading…
Cancel
Save