Skip to content

Commit

Permalink
Merge branch 'master' of github.com:diasurgical/devilution into hellfire
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Apr 6, 2020
2 parents 160dd3f + 7b70770 commit cc0f92d
Show file tree
Hide file tree
Showing 37 changed files with 358 additions and 654 deletions.
70 changes: 34 additions & 36 deletions Source/appfat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,31 @@ void TriggerBreak()
LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc)
{
if (pExc->ExceptionRecord == NULL) {
return 0;
return EXCEPTION_CONTINUE_SEARCH;
}
if (pExc->ExceptionRecord->ExceptionCode != EXCEPTION_BREAKPOINT) {
return 0;
return EXCEPTION_CONTINUE_SEARCH;
}

if (((BYTE *)pExc->ContextRecord->Eip)[0] == 0xCC) { // int 3
pExc->ContextRecord->Eip++;
}

return -1;
return EXCEPTION_CONTINUE_EXECUTION;
}
#endif

char *GetErrorStr(DWORD error_code)
{
DWORD upper_code;
int size;
char *chr;

upper_code = (error_code >> 16) & 0x1FFF;
if (upper_code == 0x0878) {
TraceErrorDS(error_code, sz_error_buf, 256);
} else if (upper_code == 0x0876) {
TraceErrorDD(error_code, sz_error_buf, 256);
} else if (!SErrGetErrorStr(error_code, sz_error_buf, 256)
&& !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, 0x400, sz_error_buf, 0x100, NULL)) {
if (HRESULT_FACILITY(error_code) == _FACDS) {
TraceErrorDS(error_code, sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0]));
} else if (HRESULT_FACILITY(error_code) == _FACDD) {
TraceErrorDD(error_code, sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0]));
} else if (!SErrGetErrorStr(error_code, sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0]))
&& !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0]), NULL)) {
wsprintf(sz_error_buf, "unknown error 0x%08x", error_code);
}

Expand Down Expand Up @@ -394,7 +392,7 @@ void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars)
break;
default: {
const char szUnknown[] = "DDERR unknown 0x%x";
/// ASSERT: assert(dwMaxChars >= sizeof(szUnknown) + 10);
assert(dwMaxChars >= sizeof(szUnknown) + 10);
sprintf(pszBuffer, szUnknown, hError);
return;
}
Expand Down Expand Up @@ -455,7 +453,7 @@ void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars)
break;
default: {
const char szUnknown[] = "DSERR unknown 0x%x";
/// ASSERT: assert(dwMaxChars >= sizeof(szUnknown) + 10);
assert(dwMaxChars >= sizeof(szUnknown) + 10);
sprintf(pszBuffer, szUnknown, hError);
return;
}
Expand Down Expand Up @@ -559,7 +557,7 @@ void center_window(HWND hDlg)
{
LONG w, h;
int screenW, screenH;
struct tagRECT Rect;
tagRECT Rect;
HDC hdc;

GetWindowRect(hDlg, &Rect);
Expand All @@ -575,6 +573,26 @@ void center_window(HWND hDlg)
}
}

static BOOL CALLBACK FuncDlg(HWND hDlg, UINT uMsg,WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
TextDlg(hDlg, (char *)lParam);
break;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK) {
EndDialog(hDlg, TRUE);
} else if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hDlg, FALSE);
}
break;
default:
return FALSE;
}

return TRUE;
}

void ErrDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr)
{
char *size;
Expand All @@ -593,27 +611,7 @@ void ErrDlg(int template_id, DWORD error_code, char *log_file_path, int log_line
app_fatal(NULL);
}

BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM text)
{
switch (uMsg) {
case WM_INITDIALOG:
TextDlg(hDlg, (char *)text);
break;
case WM_COMMAND:
if (wParam == 1) {
EndDialog(hDlg, 1);
} else if (wParam == 2) {
EndDialog(hDlg, 0);
}
break;
default:
return FALSE;
}

return TRUE;
}

void TextDlg(HWND hDlg, char *text)
static void TextDlg(HWND hDlg, char *text)
{
center_window(hDlg);

Expand Down Expand Up @@ -669,7 +667,7 @@ BOOL InsertCDDlg()

ShowCursor(FALSE);

return nResult == 1;
return nResult == IDOK;
}

void DirErrorDlg(char *error)
Expand Down
1 change: 0 additions & 1 deletion Source/appfat.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ void DDErrMsg(DWORD error_code, int log_line_nr, char *log_file_path);
void DSErrMsg(DWORD error_code, int log_line_nr, char *log_file_path);
void center_window(HWND hDlg);
void ErrDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr);
BOOL __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM text);
void TextDlg(HWND hDlg, char *text);
void ErrOkDlg(int template_id, DWORD error_code, char *log_file_path, int log_line_nr);
void FileErrDlg(const char *error);
Expand Down
18 changes: 3 additions & 15 deletions Source/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static BOOL CaptureHdr(HANDLE hFile, short width, short height)
static BOOL CapturePal(HANDLE hFile, PALETTEENTRY *palette)
{
DWORD NumberOfBytesWritten;
BYTE pcx_palette[769];
BYTE pcx_palette[1 + 256 * 3];
int i;

pcx_palette[0] = 12;
Expand All @@ -45,7 +45,7 @@ static BOOL CapturePal(HANDLE hFile, PALETTEENTRY *palette)
pcx_palette[1 + 3 * i + 2] = palette[i].peBlue;
}

return WriteFile(hFile, pcx_palette, 769, &NumberOfBytesWritten, 0) && NumberOfBytesWritten == 769;
return WriteFile(hFile, pcx_palette, sizeof(pcx_palette), &NumberOfBytesWritten, NULL) && NumberOfBytesWritten == sizeof(pcx_palette);
}

static BYTE *CaptureEnc(BYTE *src, BYTE *dst, int width)
Expand Down Expand Up @@ -93,7 +93,7 @@ static BOOL CapturePix(HANDLE hFile, WORD width, WORD height, WORD stride, BYTE
pBufferEnd = CaptureEnc(pixels, pBuffer, width);
pixels += stride;
writeSize = pBufferEnd - pBuffer;
if (!(WriteFile(hFile, pBuffer, writeSize, &lpNumBytes, 0) && lpNumBytes == writeSize)) {
if (!(WriteFile(hFile, pBuffer, writeSize, &lpNumBytes, NULL) && lpNumBytes == writeSize)) {
return FALSE;
}
}
Expand Down Expand Up @@ -141,11 +141,7 @@ static void RedPalette(PALETTEENTRY *pal)
red[i].peFlags = 0;
}

#ifdef __cplusplus
lpDDPalette->SetEntries(0, 0, 256, red);
#else
lpDDPalette->lpVtbl->SetEntries(lpDDPalette, 0, 0, 256, red);
#endif
}

void CaptureScreen()
Expand All @@ -158,11 +154,7 @@ void CaptureScreen()
hObject = CaptureFile(FileName);
if (hObject != INVALID_HANDLE_VALUE) {
DrawAndBlit();
#ifdef __cplusplus
lpDDPalette->GetEntries(0, 0, 256, palette);
#else
lpDDPalette->lpVtbl->GetEntries(lpDDPalette, 0, 0, 256, palette);
#endif
RedPalette(palette);

lock_buf(2);
Expand All @@ -180,10 +172,6 @@ void CaptureScreen()
DeleteFile(FileName);

Sleep(300);
#ifdef __cplusplus
lpDDPalette->SetEntries(0, 0, 256, palette);
#else
lpDDPalette->lpVtbl->SetEntries(lpDDPalette, 0, 0, 256, palette);
#endif
}
}
Loading

0 comments on commit cc0f92d

Please sign in to comment.