1
0
Fork 0

Add files via upload

pull/1/head
galaxyhaxz 2018-06-06 21:25:54 -05:00 committed by GitHub
parent 41bfbdbfcf
commit dde68ff89e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
100 changed files with 88250 additions and 0 deletions

820
Source/appfat.cpp Normal file
View File

@ -0,0 +1,820 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int appfat_terminated = 0; // weak
char sz_error_buf[256];
int terminating; // weak
int cleanup_thread_id; // weak
char empty_string;
void __cdecl appfat_cpp_init()
{
appfat_terminated = 0x7F800000;
}
struct j_appfat_cpp_init
{
j_appfat_cpp_init()
{
appfat_cpp_init();
}
} _j_appfat_cpp_init;
/*
bool __cdecl appfat_cpp_free(void *a1)
{
bool result; // al
if ( a1 )
result = SMemFree(a1, "delete", -1, 0);
return result;
}
*/
//----- (0040102A) --------------------------------------------------------
char *__fastcall GetErr(int error_code)
{
int v1; // edi
unsigned int v2; // eax
signed int v4; // eax
_BYTE *i; // ecx
v1 = error_code;
v2 = ((unsigned int)error_code >> 16) & 0x1FFF;
if ( v2 == 0x0878 )
{
GetDSErr(error_code, sz_error_buf, 256);
}
else if ( v2 == 0x0876 )
{
GetDDErr(error_code, sz_error_buf, 256);
}
else
{
if ( !SErrGetErrorStr(error_code, sz_error_buf, 256) && !FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, v1, 0x400u, sz_error_buf, 0x100u, NULL) )
wsprintfA(sz_error_buf, "unknown error 0x%08x", v1);
}
v4 = strlen(sz_error_buf);
for ( i = (unsigned char *)&appfat_terminated + v4 + 3; v4 > 0; *i = 0 )
{
--v4;
if ( *--i != '\r' && *i != '\n' )
break;
}
return sz_error_buf;
}
// 4B7930: using guessed type int appfat_terminated;
//----- (004010CE) --------------------------------------------------------
void __fastcall GetDDErr(int error_code, char *error_buf, int error_buf_len)
{
const char *v3; // eax
char v4[4]; // [esp+0h] [ebp-14h]
if ( error_code > DDERR_SURFACEBUSY )
{
if ( error_code > DDERR_NOPALETTEHW )
{
if ( error_code > DDERR_CANTPAGELOCK )
{
switch ( error_code )
{
case DDERR_CANTPAGEUNLOCK:
v3 = "DDERR_CANTPAGEUNLOCK";
goto LABEL_182;
case DDERR_NOTPAGELOCKED:
v3 = "DDERR_NOTPAGELOCKED";
goto LABEL_182;
case DD_OK:
v3 = "DD_OK";
goto LABEL_182;
}
}
else
{
if ( error_code == DDERR_CANTPAGELOCK )
{
v3 = "DDERR_CANTPAGELOCK";
goto LABEL_182;
}
switch ( error_code )
{
case DDERR_BLTFASTCANTCLIP:
v3 = "DDERR_BLTFASTCANTCLIP";
goto LABEL_182;
case DDERR_NOBLTHW:
v3 = "DDERR_NOBLTHW";
goto LABEL_182;
case DDERR_NODDROPSHW:
v3 = "DDERR_NODDROPSHW";
goto LABEL_182;
case DDERR_OVERLAYNOTVISIBLE:
v3 = "DDERR_OVERLAYNOTVISIBLE";
goto LABEL_182;
case DDERR_NOOVERLAYDEST:
v3 = "DDERR_NOOVERLAYDEST";
goto LABEL_182;
case DDERR_INVALIDPOSITION:
v3 = "DDERR_INVALIDPOSITION";
goto LABEL_182;
case DDERR_NOTAOVERLAYSURFACE:
v3 = "DDERR_NOTAOVERLAYSURFACE";
goto LABEL_182;
case DDERR_EXCLUSIVEMODEALREADYSET:
v3 = "DDERR_EXCLUSIVEMODEALREADYSET";
goto LABEL_182;
case DDERR_NOTFLIPPABLE:
v3 = "DDERR_NOTFLIPPABLE";
goto LABEL_182;
case DDERR_CANTDUPLICATE:
v3 = "DDERR_CANTDUPLICATE";
goto LABEL_182;
case DDERR_NOTLOCKED:
v3 = "DDERR_NOTLOCKED";
goto LABEL_182;
case DDERR_CANTCREATEDC:
v3 = "DDERR_CANTCREATEDC";
goto LABEL_182;
case DDERR_NODC:
v3 = "DDERR_NODC";
goto LABEL_182;
case DDERR_WRONGMODE:
v3 = "DDERR_WRONGMODE";
goto LABEL_182;
case DDERR_IMPLICITLYCREATED:
v3 = "DDERR_IMPLICITLYCREATED";
goto LABEL_182;
case DDERR_NOTPALETTIZED:
v3 = "DDERR_NOTPALETTIZED";
goto LABEL_182;
case DDERR_NOMIPMAPHW:
v3 = "DDERR_NOMIPMAPHW";
goto LABEL_182;
case DDERR_INVALIDSURFACETYPE:
v3 = "DDERR_INVALIDSURFACETYPE";
goto LABEL_182;
case DDERR_DCALREADYCREATED:
v3 = "DDERR_DCALREADYCREATED";
goto LABEL_182;
default:
goto LABEL_178;
}
}
}
else
{
if ( error_code == DDERR_NOPALETTEHW )
{
v3 = "DDERR_NOPALETTEHW";
goto LABEL_182;
}
if ( error_code > DDERR_INVALIDDIRECTDRAWGUID )
{
switch ( error_code )
{
case DDERR_DIRECTDRAWALREADYCREATED:
v3 = "DDERR_DIRECTDRAWALREADYCREATED";
goto LABEL_182;
case DDERR_NODIRECTDRAWHW:
v3 = "DDERR_NODIRECTDRAWHW";
goto LABEL_182;
case DDERR_PRIMARYSURFACEALREADYEXISTS:
v3 = "DDERR_PRIMARYSURFACEALREADYEXISTS";
goto LABEL_182;
case DDERR_NOEMULATION:
v3 = "DDERR_NOEMULATION";
goto LABEL_182;
case DDERR_REGIONTOOSMALL:
v3 = "DDERR_REGIONTOOSMALL";
goto LABEL_182;
case DDERR_CLIPPERISUSINGHWND:
v3 = "DDERR_CLIPPERISUSINGHWND";
goto LABEL_182;
case DDERR_NOCLIPPERATTACHED:
v3 = "DDERR_NOCLIPPERATTACHED";
goto LABEL_182;
case DDERR_NOHWND:
v3 = "DDERR_NOHWND";
goto LABEL_182;
case DDERR_HWNDSUBCLASSED:
v3 = "DDERR_HWNDSUBCLASSED";
goto LABEL_182;
case DDERR_HWNDALREADYSET:
v3 = "DDERR_HWNDALREADYSET";
goto LABEL_182;
case DDERR_NOPALETTEATTACHED:
v3 = "DDERR_NOPALETTEATTACHED";
goto LABEL_182;
default:
goto LABEL_178;
}
}
else
{
if ( error_code == DDERR_INVALIDDIRECTDRAWGUID )
{
v3 = "DDERR_INVALIDDIRECTDRAWGUID";
goto LABEL_182;
}
if ( error_code > DDERR_TOOBIGWIDTH )
{
switch ( error_code )
{
case DDERR_UNSUPPORTEDFORMAT:
v3 = "DDERR_UNSUPPORTEDFORMAT";
goto LABEL_182;
case DDERR_UNSUPPORTEDMASK:
v3 = "DDERR_UNSUPPORTEDMASK";
goto LABEL_182;
case DDERR_VERTICALBLANKINPROGRESS:
v3 = "DDERR_VERTICALBLANKINPROGRESS";
goto LABEL_182;
case DDERR_WASSTILLDRAWING:
v3 = "DDERR_WASSTILLDRAWING";
goto LABEL_182;
case DDERR_XALIGN:
v3 = "DDERR_XALIGN";
goto LABEL_182;
}
}
else
{
switch ( error_code )
{
case DDERR_TOOBIGWIDTH:
v3 = "DDERR_TOOBIGWIDTH";
goto LABEL_182;
case DDERR_CANTLOCKSURFACE:
v3 = "DDERR_CANTLOCKSURFACE";
goto LABEL_182;
case DDERR_SURFACEISOBSCURED:
v3 = "DDERR_SURFACEISOBSCURED";
goto LABEL_182;
case DDERR_SURFACELOST:
v3 = "DDERR_SURFACELOST";
goto LABEL_182;
case DDERR_SURFACENOTATTACHED:
v3 = "DDERR_SURFACENOTATTACHED";
goto LABEL_182;
case DDERR_TOOBIGHEIGHT:
v3 = "DDERR_TOOBIGHEIGHT";
goto LABEL_182;
case DDERR_TOOBIGSIZE:
v3 = "DDERR_TOOBIGSIZE";
goto LABEL_182;
}
}
}
}
goto LABEL_178;
}
if ( error_code == DDERR_SURFACEBUSY )
{
v3 = "DDERR_SURFACEBUSY";
goto LABEL_182;
}
if ( error_code > DDERR_NOCOLORKEYHW )
{
if ( error_code > DDERR_NOTEXTUREHW )
{
if ( error_code > DDERR_OVERLAYCANTCLIP )
{
switch ( error_code )
{
case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
v3 = "DDERR_OVERLAYCOLORKEYONLYONEACTIVE";
goto LABEL_182;
case DDERR_PALETTEBUSY:
v3 = "DDERR_PALETTEBUSY";
goto LABEL_182;
case DDERR_COLORKEYNOTSET:
v3 = "DDERR_COLORKEYNOTSET";
goto LABEL_182;
case DDERR_SURFACEALREADYATTACHED:
v3 = "DDERR_SURFACEALREADYATTACHED";
goto LABEL_182;
case DDERR_SURFACEALREADYDEPENDENT:
v3 = "DDERR_SURFACEALREADYDEPENDENT";
goto LABEL_182;
}
}
else
{
switch ( error_code )
{
case DDERR_OVERLAYCANTCLIP:
v3 = "DDERR_OVERLAYCANTCLIP";
goto LABEL_182;
case DDERR_NOVSYNCHW:
v3 = "DDERR_NOVSYNCHW";
goto LABEL_182;
case DDERR_NOZBUFFERHW:
v3 = "DDERR_NOZBUFFERHW";
goto LABEL_182;
case DDERR_NOZOVERLAYHW:
v3 = "DDERR_NOZOVERLAYHW";
goto LABEL_182;
case DDERR_OUTOFCAPS:
v3 = "DDERR_OUTOFCAPS";
goto LABEL_182;
case DDERR_OUTOFVIDEOMEMORY:
v3 = "DDERR_OUTOFVIDEOMEMORY";
goto LABEL_182;
}
}
}
else
{
if ( error_code == DDERR_NOTEXTUREHW )
{
v3 = "DDERR_NOTEXTUREHW";
goto LABEL_182;
}
if ( error_code > DDERR_NORASTEROPHW )
{
switch ( error_code )
{
case DDERR_NOROTATIONHW:
v3 = "DDERR_NOROTATIONHW";
goto LABEL_182;
case DDERR_NOSTRETCHHW:
v3 = "DDERR_NOSTRETCHHW";
goto LABEL_182;
case DDERR_NOT4BITCOLOR:
v3 = "DDERR_NOT4BITCOLOR";
goto LABEL_182;
case DDERR_NOT4BITCOLORINDEX:
v3 = "DDERR_NOT4BITCOLORINDEX";
goto LABEL_182;
case DDERR_NOT8BITCOLOR:
v3 = "DDERR_NOT8BITCOLOR";
goto LABEL_182;
}
}
else
{
switch ( error_code )
{
case DDERR_NORASTEROPHW:
v3 = "DDERR_NORASTEROPHW";
goto LABEL_182;
case DDERR_NOEXCLUSIVEMODE:
v3 = "DDERR_NOEXCLUSIVEMODE";
goto LABEL_182;
case DDERR_NOFLIPHW:
v3 = "DDERR_NOFLIPHW";
goto LABEL_182;
case DDERR_NOGDI:
v3 = "DDERR_NOGDI";
goto LABEL_182;
case DDERR_NOMIRRORHW:
v3 = "DDERR_NOMIRRORHW";
goto LABEL_182;
case DDERR_NOTFOUND:
v3 = "DDERR_NOTFOUND";
goto LABEL_182;
case DDERR_NOOVERLAYHW:
v3 = "DDERR_NOOVERLAYHW";
goto LABEL_182;
}
}
}
goto LABEL_178;
}
if ( error_code == DDERR_NOCOLORKEYHW )
{
v3 = "DDERR_NOCOLORKEYHW";
goto LABEL_182;
}
if ( error_code > DDERR_INVALIDCLIPLIST )
{
if ( error_code > DDERR_NO3D )
{
switch ( error_code )
{
case DDERR_NOALPHAHW:
v3 = "DDERR_NOALPHAHW";
goto LABEL_182;
case DDERR_NOCLIPLIST:
v3 = "DDERR_NOCLIPLIST";
goto LABEL_182;
case DDERR_NOCOLORCONVHW:
v3 = "DDERR_NOCOLORCONVHW";
goto LABEL_182;
case DDERR_NOCOOPERATIVELEVELSET:
v3 = "DDERR_NOCOOPERATIVELEVELSET";
goto LABEL_182;
case DDERR_NOCOLORKEY:
v3 = "DDERR_NOCOLORKEY";
goto LABEL_182;
}
}
else
{
switch ( error_code )
{
case DDERR_NO3D:
v3 = "DDERR_NO3D";
goto LABEL_182;
case DDERR_INVALIDMODE:
v3 = "DDERR_INVALIDMODE";
goto LABEL_182;
case DDERR_INVALIDOBJECT:
v3 = "DDERR_INVALIDOBJECT";
goto LABEL_182;
case DDERR_INVALIDPIXELFORMAT:
v3 = "DDERR_INVALIDPIXELFORMAT";
goto LABEL_182;
case DDERR_INVALIDRECT:
v3 = "DDERR_INVALIDRECT";
goto LABEL_182;
case DDERR_LOCKEDSURFACES:
v3 = "DDERR_LOCKEDSURFACES";
goto LABEL_182;
}
}
goto LABEL_178;
}
if ( error_code == DDERR_INVALIDCLIPLIST )
{
v3 = "DDERR_INVALIDCLIPLIST";
goto LABEL_182;
}
if ( error_code > DDERR_CANNOTDETACHSURFACE )
{
switch ( error_code )
{
case DDERR_CURRENTLYNOTAVAIL:
v3 = "DDERR_CURRENTLYNOTAVAIL";
goto LABEL_182;
case DDERR_EXCEPTION:
v3 = "DDERR_EXCEPTION";
goto LABEL_182;
case DDERR_HEIGHTALIGN:
v3 = "DDERR_HEIGHTALIGN";
goto LABEL_182;
case DDERR_INCOMPATIBLEPRIMARY:
v3 = "DDERR_INCOMPATIBLEPRIMARY";
goto LABEL_182;
case DDERR_INVALIDCAPS:
v3 = "DDERR_INVALIDCAPS";
goto LABEL_182;
}
goto LABEL_178;
}
switch ( error_code )
{
case DDERR_CANNOTDETACHSURFACE:
v3 = "DDERR_CANNOTDETACHSURFACE";
goto LABEL_182;
case DDERR_UNSUPPORTED:
v3 = "DDERR_UNSUPPORTED";
goto LABEL_182;
case DDERR_GENERIC:
v3 = "DDERR_GENERIC";
goto LABEL_182;
case DDERR_OUTOFMEMORY:
v3 = "DDERR_OUTOFMEMORY";
goto LABEL_182;
case DDERR_INVALIDPARAMS:
v3 = "DDERR_INVALIDPARAMS";
goto LABEL_182;
case DDERR_ALREADYINITIALIZED:
v3 = "DDERR_ALREADYINITIALIZED";
goto LABEL_182;
}
if ( error_code != DDERR_CANNOTATTACHSURFACE )
{
LABEL_178:
strcpy(v4, "DDERR unknown 0x%x");
sprintf(error_buf, v4, error_code);
return;
}
v3 = "DDERR_CANNOTATTACHSURFACE";
LABEL_182:
strncpy(error_buf, v3, error_buf_len);
}
//----- (00401831) --------------------------------------------------------
void __fastcall GetDSErr(int error_code, char *error_buf, int error_buf_len)
{
const char *v3; // eax
char v4[4]; // [esp+0h] [ebp-14h]
if ( error_code > DSERR_INVALIDCALL )
{
switch ( error_code )
{
case DSERR_PRIOLEVELNEEDED:
v3 = "DSERR_PRIOLEVELNEEDED";
goto LABEL_29;
case DSERR_BADFORMAT:
v3 = "DSERR_BADFORMAT";
goto LABEL_29;
case DSERR_NODRIVER:
v3 = "DSERR_NODRIVER";
goto LABEL_29;
case DSERR_ALREADYINITIALIZED:
v3 = "DSERR_ALREADYINITIALIZED";
goto LABEL_29;
case DSERR_BUFFERLOST:
v3 = "DSERR_BUFFERLOST";
goto LABEL_29;
case DS_OK:
v3 = "DS_OK";
goto LABEL_29;
}
goto LABEL_22;
}
switch ( error_code )
{
case DSERR_INVALIDCALL:
v3 = "DSERR_INVALIDCALL";
goto LABEL_29;
case E_NOINTERFACE:
v3 = "E_NOINTERFACE";
goto LABEL_29;
case DSERR_NOAGGREGATION:
v3 = "DSERR_NOAGGREGATION";
goto LABEL_29;
case DSERR_OUTOFMEMORY:
v3 = "DSERR_OUTOFMEMORY";
goto LABEL_29;
case DSERR_INVALIDPARAM:
v3 = "DSERR_INVALIDPARAM";
goto LABEL_29;
case DSERR_ALLOCATED:
v3 = "DSERR_ALLOCATED";
goto LABEL_29;
}
if ( error_code != DSERR_CONTROLUNAVAIL )
{
LABEL_22:
strcpy(v4, "DSERR unknown 0x%x");
sprintf(error_buf, v4, error_code);
return;
}
v3 = "DSERR_CONTROLUNAVAIL";
LABEL_29:
strncpy(error_buf, v3, error_buf_len);
}
//----- (0040193A) --------------------------------------------------------
char *__cdecl GetLastErr()
{
int v0; // eax
v0 = GetLastError();
return GetErr(v0);
}
//----- (00401947) --------------------------------------------------------
void TermMsg(char *pszFmt, ...)
{
va_list arglist; // [esp+8h] [ebp+8h]
va_start(arglist, pszFmt);
FreeDlg();
if ( pszFmt )
MsgBox(pszFmt, arglist);
init_cleanup(0);
exit(1);
}
//----- (00401975) --------------------------------------------------------
void __fastcall MsgBox(char *pszFmt, va_list va)
{
char Text[256]; // [esp+0h] [ebp-100h]
wvsprintfA(Text, pszFmt, va);
if ( ghMainWnd )
SetWindowPos(ghMainWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
MessageBoxA(ghMainWnd, Text, "ERROR", MB_TASKMODAL|MB_ICONHAND);
}
//----- (004019C7) --------------------------------------------------------
void __cdecl FreeDlg()
{
if ( terminating && cleanup_thread_id != GetCurrentThreadId() )
Sleep(20000u);
terminating = 1;
cleanup_thread_id = GetCurrentThreadId();
dx_cleanup();
if ( (unsigned char)gbMaxPlayers > 1u )
{
if ( SNetLeaveGame(3) )
Sleep(2000u);
}
SNetDestroy();
ShowCursor(1);
}
// 4B7A34: using guessed type int terminating;
// 4B7A38: using guessed type int cleanup_thread_id;
// 679660: using guessed type char gbMaxPlayers;
//----- (00401A30) --------------------------------------------------------
void DrawDlg(char *pszFmt, ...)
{
char text[256]; // [esp+0h] [ebp-100h]
va_list arglist; // [esp+10Ch] [ebp+Ch]
va_start(arglist, pszFmt);
wvsprintfA(text, pszFmt, arglist);
SDrawMessageBox(text, "Diablo", MB_TASKMODAL|MB_ICONEXCLAMATION);
}
//----- (00401A65) --------------------------------------------------------
void __fastcall DDErrDlg(int error_code, int log_line_nr, char *log_file_path)
{
int v3; // esi
char *v4; // eax
v3 = log_line_nr;
if ( error_code )
{
v4 = GetErr(error_code);
TermMsg("Direct draw error (%s:%d)\n%s", log_file_path, v3, v4);
}
}
//----- (00401A88) --------------------------------------------------------
void __fastcall DSErrDlg(int error_code, int log_line_nr, char *log_file_path)
{
int v3; // esi
char *v4; // eax
v3 = log_line_nr;
if ( error_code )
{
v4 = GetErr(error_code);
TermMsg("Direct sound error (%s:%d)\n%s", log_file_path, v3, v4);
}
}
//----- (00401AAB) --------------------------------------------------------
void __fastcall CenterDlg(HWND hDlg)
{
LONG v1; // esi
LONG v2; // edi
int v3; // ebx
char *v4; // eax
struct tagRECT Rect; // [esp+Ch] [ebp-1Ch]
int v6; // [esp+1Ch] [ebp-Ch]
HDC hdc; // [esp+20h] [ebp-8h]
HWND hWnd; // [esp+24h] [ebp-4h]
hWnd = hDlg;
GetWindowRect(hDlg, &Rect);
v1 = Rect.right - Rect.left;
v2 = Rect.bottom - Rect.top;
hdc = GetDC(hWnd);
v6 = GetDeviceCaps(hdc, HORZRES);
v3 = GetDeviceCaps(hdc, VERTRES);
ReleaseDC(hWnd, hdc);
if ( !SetWindowPos(hWnd, HWND_TOP, (v6 - v1) / 2, (v3 - v2) / 2, 0, 0, SWP_NOZORDER|SWP_NOSIZE) )
{
v4 = GetLastErr();
TermMsg("center_window: %s", v4);
}
}
//----- (00401B3D) --------------------------------------------------------
void __fastcall TermDlg(int template_id, int error_code, char *log_file_path, int log_line_nr)
{
int v4; // ebx
int v5; // edi
char *v6; // esi
char *v7; // eax
char *v8; // eax
LPARAM dwInitParam[128]; // [esp+Ch] [ebp-200h]
v4 = error_code;
v5 = template_id;
FreeDlg();
v6 = log_file_path;
v7 = strrchr(log_file_path, '\\');
if ( v7 )
v6 = v7 + 1;
v8 = GetErr(v4);
wsprintfA((LPSTR)dwInitParam, "%s\nat: %s line %d", v8, v6, log_line_nr);
if ( DialogBoxParamA(ghInst, (LPCSTR)(unsigned short)v5, ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam) == -1 )
TermMsg("ErrDlg: %d", v5);
TermMsg(0);
}
//----- (00401BCA) --------------------------------------------------------
bool __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text)
{
if ( uMsg == WM_INITDIALOG )
{
TextDlg(hDlg, text);
}
else
{
if ( uMsg != WM_COMMAND )
return 0;
if ( (_WORD)wParam == 1 )
{
EndDialog(hDlg, 1);
}
else if ( (_WORD)wParam == 2 )
{
EndDialog(hDlg, 0);
}
}
return 1;
}
//----- (00401C0F) --------------------------------------------------------
void __fastcall TextDlg(HWND hDlg, char *text)
{
char *v2; // esi
HWND v3; // edi
v2 = text;
v3 = hDlg;
CenterDlg(hDlg);
if ( v2 )
SetDlgItemTextA(v3, 1000, v2);
}
//----- (00401C2E) --------------------------------------------------------
void __fastcall ErrDlg(template_id template_id, int error_code, char *log_file_path, int log_line_nr)
{
char *v4; // esi
int v5; // edi
unsigned short v6; // bx
char *v7; // eax
char *v8; // eax
LPARAM dwInitParam[128]; // [esp+Ch] [ebp-200h]
v4 = log_file_path;
v5 = error_code;
v6 = template_id;
v7 = strrchr(log_file_path, '\\');
if ( v7 )
v4 = v7 + 1;
v8 = GetErr(v5);
wsprintfA((LPSTR)dwInitParam, "%s\nat: %s line %d", v8, v4, log_line_nr);
DialogBoxParamA(ghInst, (LPCSTR)v6, ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam);
}
//----- (00401C9C) --------------------------------------------------------
void __fastcall FileErrDlg(char *error)
{
char *v1; // esi
v1 = error;
FreeDlg();
if ( !v1 )
v1 = &empty_string;
if ( DialogBoxParamA(ghInst, (LPCSTR)0x6A, ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1 )
TermMsg("FileErrDlg");
TermMsg(0);
}
//----- (00401CE1) --------------------------------------------------------
void __fastcall DiskFreeDlg(char *error)
{
char *v1; // esi
v1 = error;
FreeDlg();
if ( DialogBoxParamA(ghInst, (LPCSTR)0x6E, ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1 )
TermMsg("DiskFreeDlg");
TermMsg(0);
}
//----- (00401D1D) --------------------------------------------------------
bool __cdecl InsertCDDlg()
{
INT_PTR v0; // edi
ShowCursor(1);
v0 = DialogBoxParamA(ghInst, (LPCSTR)0x70, ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)&empty_string);
if ( v0 == -1 )
TermMsg("InsertCDDlg");
ShowCursor(0);
return v0 == 1;
}
//----- (00401D68) --------------------------------------------------------
void __fastcall DirErrDlg(char *error)
{
char *v1; // esi
v1 = error;
FreeDlg();
if ( DialogBoxParamA(ghInst, (LPCSTR)0x72, ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)v1) == -1 )
TermMsg("DirErrorDlg");
TermMsg(0);
}

37
Source/appfat.h Normal file
View File

@ -0,0 +1,37 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//appfat
extern int appfat_terminated; // weak
extern char sz_error_buf[256];
extern int terminating; // weak
extern int cleanup_thread_id; // weak
extern char empty_string;
char *__fastcall GetErr(int error_code);
void __fastcall GetDDErr(int error_code, char *error_buf, int error_buf_len);
void __fastcall GetDSErr(int error_code, char *error_buf, int error_buf_len);
char *__cdecl GetLastErr();
void TermMsg(char *pszFmt, ...);
void __fastcall MsgBox(char *pszFmt, va_list va);
void __cdecl FreeDlg();
void DrawDlg(char *pszFmt, ...);
void __fastcall DDErrDlg(int error_code, int log_line_nr, char *log_file_path);
void __fastcall DSErrDlg(int error_code, int log_line_nr, char *log_file_path);
void __fastcall CenterDlg(HWND hDlg);
void __fastcall TermDlg(int template_id, int error_code, char *log_file_path, int log_line_nr);
bool __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text);
void __fastcall TextDlg(HWND hDlg, char *text);
void __fastcall ErrDlg(template_id template_id, int error_code, char *log_file_path, int log_line_nr);
void __fastcall FileErrDlg(char *error);
void __fastcall DiskFreeDlg(char *error);
bool __cdecl InsertCDDlg();
void __fastcall DirErrDlg(char *error);

993
Source/automap.cpp Normal file
View File

@ -0,0 +1,993 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
short automaptype[512];
int AMdword_4B7E40; // weak
int AMdword_4B7E44; // weak
bool automapflag; // idb
char AMbyte_4B7E4C[32];
char automapview[40][40];
int AutoMapScale; // idb
int AutoMapXOfs; // weak
int AutoMapYOfs; // weak
int AutoMapPosBits; // weak
int AutoMapXPos; // weak
int AutoMapYPos; // weak
int AMPlayerX; // weak
int AMPlayerY; // weak
//----- (00401DA4) --------------------------------------------------------
void __cdecl InitAutomapOnce()
{
automapflag = 0;
AutoMapScale = 50;
AutoMapPosBits = 32;
AutoMapXPos = 16;
AutoMapYPos = 8;
AMPlayerX = 4;
AMPlayerY = 2;
}
// 4B84B8: using guessed type int AutoMapPosBits;
// 4B84BC: using guessed type int AutoMapXPos;
// 4B84C0: using guessed type int AutoMapYPos;
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;
//----- (00401DE8) --------------------------------------------------------
void __cdecl InitAutomap()
{
signed int v0; // edi
signed int v1; // ecx
int v2; // esi
char v3; // al
int v4; // esi
char v5; // al
char *v6; // ecx
unsigned char *v7; // eax
int v8; // ecx
unsigned char *v9; // edx
unsigned int i; // esi
unsigned char v11; // bl
_BYTE *v12; // edx
signed int v13; // ecx
_BYTE *v14; // eax
signed int v15; // edx
int size; // [esp+Ch] [ebp-4h]
v0 = 50;
v1 = 0;
do
{
v2 = (v0 << 6) / 100;
v3 = 2 * (320 / v2);
v4 = 320 % v2;
v5 = v3 + 1;
AMbyte_4B7E4C[v1] = v5;
if ( v4 )
AMbyte_4B7E4C[v1] = v5 + 1;
if ( v4 >= 32 * v0 / 100 )
++AMbyte_4B7E4C[v1];
v0 += 5;
++v1;
}
while ( v1 < 31 );
memset(automaptype, 0, 0x400u);
switch ( leveltype )
{
case DTYPE_CATHEDRAL:
v6 = "Levels\\L1Data\\L1.AMP";
break;
case DTYPE_CATACOMBS:
v6 = "Levels\\L2Data\\L2.AMP";
break;
case DTYPE_CAVES:
v6 = "Levels\\L3Data\\L3.AMP";
break;
case DTYPE_HELL:
v6 = "Levels\\L4Data\\L4.AMP";
break;
default:
return;
}
v7 = LoadFileInMem(v6, &size);
size = (unsigned int)size >> 1;
v9 = v7;
for ( i = 1; i <= size; ++i )
{
v11 = *v9;
v12 = v9 + 1;
_LOWORD(v0) = v11;
_LOBYTE(v8) = *v12;
v9 = v12 + 1;
_LOWORD(v8) = (unsigned char)v8;
v8 = v0 + (v8 << 8);
automaptype[i] = v8;
}
mem_free_dbg(v7);
memset(automapview, 0, 0x640u);
v13 = 0;
do
{
v14 = (unsigned char *)dFlags + v13;
v15 = 112;
do
{
*v14 &= 0x7Fu;
v14 += 112;
--v15;
}
while ( v15 );
++v13;
}
while ( v13 < 112 );
}
// 5BB1ED: using guessed type char leveltype;
//----- (00401EF4) --------------------------------------------------------
void __cdecl StartAutomap()
{
AutoMapXOfs = 0;
AutoMapYOfs = 0;
automapflag = 1;
}
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;
//----- (00401F0D) --------------------------------------------------------
void __cdecl AutomapUp()
{
--AutoMapXOfs;
--AutoMapYOfs;
}
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;
//----- (00401F1A) --------------------------------------------------------
void __cdecl AutomapDown()
{
++AutoMapXOfs;
++AutoMapYOfs;
}
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;
//----- (00401F27) --------------------------------------------------------
void __cdecl AutomapLeft()
{
--AutoMapXOfs;
++AutoMapYOfs;
}
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;
//----- (00401F34) --------------------------------------------------------
void __cdecl AutomapRight()
{
++AutoMapXOfs;
--AutoMapYOfs;
}
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;
//----- (00401F41) --------------------------------------------------------
void __cdecl AutomapZoomIn()
{
if ( AutoMapScale < 200 )
{
AutoMapScale += 5;
AutoMapPosBits = (AutoMapScale << 6) / 100;
AutoMapXPos = AutoMapPosBits >> 1;
AutoMapYPos = AutoMapPosBits >> 2;
AMPlayerX = AutoMapPosBits >> 3;
AMPlayerY = AutoMapPosBits >> 4;
}
}
// 4B84B8: using guessed type int AutoMapPosBits;
// 4B84BC: using guessed type int AutoMapXPos;
// 4B84C0: using guessed type int AutoMapYPos;
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;
//----- (00401F80) --------------------------------------------------------
void __cdecl AutomapZoomOut()
{
if ( AutoMapScale > 50 )
{
AutoMapScale -= 5;
AutoMapPosBits = (AutoMapScale << 6) / 100;
AutoMapXPos = AutoMapPosBits >> 1;
AutoMapYPos = AutoMapPosBits >> 2;
AMPlayerX = AutoMapPosBits >> 3;
AMPlayerY = AutoMapPosBits >> 4;
}
}
// 4B84B8: using guessed type int AutoMapPosBits;
// 4B84BC: using guessed type int AutoMapXPos;
// 4B84C0: using guessed type int AutoMapYPos;
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;
//----- (00401FBD) --------------------------------------------------------
void __cdecl DrawAutomap()
{
int v0; // eax
int v1; // ecx
int v2; // edx
int v3; // edx
int v4; // ecx
int v5; // eax
int v6; // esi
int v7; // edx
int v8; // edx
int v9; // esi
int v10; // ebx
int v11; // edi
int v12; // esi
int v13; // edi
int v14; // esi
int v15; // ebp
short v16; // ax
int v17; // ebp
short v18; // ax
int v19; // [esp+0h] [ebp-18h]
int screen_x; // [esp+4h] [ebp-14h]
int screen_xa; // [esp+4h] [ebp-14h]
int v22; // [esp+8h] [ebp-10h]
int ty; // [esp+Ch] [ebp-Ch]
int tya; // [esp+Ch] [ebp-Ch]
int v25; // [esp+10h] [ebp-8h]
int screen_y; // [esp+14h] [ebp-4h]
if ( leveltype )
{
screen_buf_end = (int)gpBuffer->row[352].col_unused_1;
v0 = AutoMapXOfs;
v1 = (ViewX - 16) >> 1;
v2 = AutoMapXOfs + v1;
if ( AutoMapXOfs + v1 < 0 )
{
do
{
++v0;
++v2;
}
while ( v2 < 0 );
AutoMapXOfs = v0;
}
v3 = v0 + v1;
if ( v0 + v1 >= 40 )
{
do
{
--v0;
--v3;
}
while ( v3 >= 40 );
AutoMapXOfs = v0;
}
v4 = v0 + v1;
AMdword_4B7E40 = v4;
v5 = AutoMapYOfs;
v6 = (ViewY - 16) >> 1;
v7 = AutoMapYOfs + v6;
if ( AutoMapYOfs + v6 < 0 )
{
do
{
++v5;
++v7;
}
while ( v7 < 0 );
AutoMapYOfs = v5;
}
v8 = v5 + v6;
if ( v5 + v6 >= 40 )
{
do
{
--v5;
--v8;
}
while ( v8 >= 40 );
AutoMapYOfs = v5;
}
v9 = v5 + v6;
AMdword_4B7E44 = v9;
v10 = AMbyte_4B7E4C[(AutoMapScale - 50) / 5];
if ( ScrollInfo._sxoff + ScrollInfo._syoff )
++v10;
v22 = v4 - v10;
v19 = v9 - 1;
if ( v10 & 1 )
{
v11 = 384 - AutoMapPosBits * ((v10 - 1) >> 1);
v12 = 336 - AutoMapXPos * ((v10 + 1) >> 1);
}
else
{
v11 = AutoMapXPos - AutoMapPosBits * (v10 >> 1) + 384;
v12 = 336 - AutoMapXPos * (v10 >> 1) - AutoMapYPos;
}
if ( ViewX & 1 )
{
v11 -= AutoMapYPos;
v12 -= AMPlayerX;
}
if ( ViewY & 1 )
{
v11 += AutoMapYPos;
v12 -= AMPlayerX;
}
v13 = (AutoMapScale * ScrollInfo._sxoff / 100 >> 1) + v11;
v14 = (AutoMapScale * ScrollInfo._syoff / 100 >> 1) + v12;
if ( invflag || sbookflag )
v13 -= 160;
if ( chrflag || questlog )
v13 += 160;
if ( v10 + 1 >= 0 )
{
v25 = v10 + 2;
do
{
v15 = 0;
screen_x = v13;
if ( v10 > 0 )
{
ty = v19;
do
{
v16 = GetAutomapType(v22 + v15, ty, 1);
if ( v16 )
DrawAutomapType(screen_x, v14, v16);
screen_x += AutoMapPosBits;
++v15;
--ty;
}
while ( v15 < v10 );
}
++v19;
screen_xa = 0;
v17 = v13 - AutoMapXPos;
screen_y = v14 + AutoMapYPos;
if ( v10 >= 0 )
{
tya = v19;
do
{
v18 = GetAutomapType(v22 + screen_xa, tya, 1);
if ( v18 )
DrawAutomapType(v17, screen_y, v18);
v17 += AutoMapPosBits;
++screen_xa;
--tya;
}
while ( screen_xa <= v10 );
}
++v22;
v14 += AutoMapXPos;
--v25;
}
while ( v25 );
}
DrawAutomapPlr();
DrawAutomapGame();
}
else
{
DrawAutomapGame();
}
}
// 4B7E40: using guessed type int AMdword_4B7E40;
// 4B7E44: using guessed type int AMdword_4B7E44;
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;
// 4B84B8: using guessed type int AutoMapPosBits;
// 4B84BC: using guessed type int AutoMapXPos;
// 4B84C0: using guessed type int AutoMapYPos;
// 4B84C4: using guessed type int AMPlayerX;
// 4B8968: using guessed type int sbookflag;
// 5BB1ED: using guessed type char leveltype;
// 69BD04: using guessed type int questlog;
// 69CF0C: using guessed type int screen_buf_end;
//----- (00402233) --------------------------------------------------------
void __fastcall DrawAutomapType(int screen_x, int screen_y, short automap_type)
{
short v3; // al
int v4; // ebx
int v5; // edi
int a3; // ST2C_4
int a1; // ST28_4
int a2; // ST24_4
int v9; // edx
int v10; // ST28_4
int v11; // ST2C_4
int v12; // ST24_4
int v13; // ST2C_4
int v14; // ST28_4
int v15; // ST24_4
int v16; // ST28_4
int v17; // ST24_4
int v18; // ST2C_4
int v19; // ST2C_4
int v20; // ST28_4
int v21; // ST24_4
int v22; // ST28_4
int v23; // ST2C_4
int v24; // ST24_4
int v25; // ST28_4
int v26; // ST24_4
int v27; // ST2C_4
int v28; // [esp-Ch] [ebp-34h]
int v29; // [esp-8h] [ebp-30h]
signed int v30; // [esp+Ch] [ebp-1Ch]
signed int v31; // [esp+10h] [ebp-18h]
signed int v32; // [esp+14h] [ebp-14h]
char v33; // [esp+27h] [ebp-1h]
int automap_typea; // [esp+30h] [ebp+8h]
int automap_typeb; // [esp+30h] [ebp+8h]
int automap_typec; // [esp+30h] [ebp+8h]
int automap_typed; // [esp+30h] [ebp+8h]
int automap_typee; // [esp+30h] [ebp+8h]
int automap_typef; // [esp+30h] [ebp+8h]
int automap_typeg; // [esp+30h] [ebp+8h]
v3 = automap_type;
v4 = screen_x;
v5 = screen_y;
v33 = _HIBYTE(automap_type);
if ( automap_type & 0x4000 )
{
ENG_set_pixel(screen_x, screen_y, 200);
ENG_set_pixel(v4 - AMPlayerX, v5 - AMPlayerY, 200);
ENG_set_pixel(v4 - AMPlayerX, AMPlayerY + v5, 200);
ENG_set_pixel(AMPlayerX + v4, v5 - AMPlayerY, 200);
ENG_set_pixel(AMPlayerX + v4, AMPlayerY + v5, 200);
ENG_set_pixel(v4 - AutoMapYPos, v5, 200);
ENG_set_pixel(AutoMapYPos + v4, v5, 200);
ENG_set_pixel(v4, v5 - AMPlayerX, 200);
ENG_set_pixel(v4, AMPlayerX + v5, 200);
ENG_set_pixel(v4 + AMPlayerX - AutoMapXPos, AMPlayerY + v5, 200);
ENG_set_pixel(v4 + AutoMapXPos - AMPlayerX, AMPlayerY + v5, 200);
ENG_set_pixel(v4 - AutoMapYPos, AMPlayerX + v5, 200);
ENG_set_pixel(AutoMapYPos + v4, AMPlayerX + v5, 200);
ENG_set_pixel(v4 - AMPlayerX, v5 + AutoMapYPos - AMPlayerY, 200);
ENG_set_pixel(AMPlayerX + v4, v5 + AutoMapYPos - AMPlayerY, 200);
ENG_set_pixel(v4, AutoMapYPos + v5, 200);
v3 = automap_type;
}
if ( automap_type < 0 )
{
engine_draw_automap_pixels(v4 - AMPlayerX, v5 - AMPlayerX - AMPlayerY, v4 + AMPlayerX + AutoMapYPos, AMPlayerY + v5, 144);
engine_draw_automap_pixels(v4 - AutoMapYPos, v5 - AMPlayerX, AutoMapYPos + v4, AMPlayerX + v5, 144);
engine_draw_automap_pixels(v4 - AutoMapYPos - AMPlayerX, v5 - AMPlayerY, AMPlayerX + v4, v5 + AMPlayerX + AMPlayerY, 144);
engine_draw_automap_pixels(v4 - AutoMapXPos, v5, v4, v5 + AutoMapYPos, 144);
v3 = automap_type;
}
v31 = 0;
v30 = 0;
v32 = 0;
switch ( v3 & 0xF )
{
case 1:
a3 = v4 - AutoMapYPos + AutoMapXPos;
a1 = v4 - AutoMapYPos;
a2 = v5 - AutoMapYPos;
automap_typea = v5 - AMPlayerX;
engine_draw_automap_pixels(v4, v5 - AutoMapYPos, v4 - AutoMapYPos, v5 - AMPlayerX, 200);
engine_draw_automap_pixels(v4, a2, a3, automap_typea, 200);
engine_draw_automap_pixels(v4, v5, a1, automap_typea, 200);
v9 = v5;
v29 = automap_typea;
v28 = a3;
goto LABEL_36;
case 2:
case 5:
goto LABEL_8;
case 3:
case 6:
goto LABEL_17;
case 4:
v31 = 1;
goto LABEL_8;
case 7:
goto LABEL_25;
case 8:
v30 = 1;
LABEL_8:
if ( automap_type & 0x100 )
{
v10 = v4 - AutoMapXPos;
v11 = v4 - AutoMapYPos;
v12 = v5 - AutoMapYPos;
automap_typeb = v5 - AMPlayerX;
engine_draw_automap_pixels(v4, v5 - AutoMapYPos, v4 - AMPlayerX, v5 - AutoMapYPos + AMPlayerY, 200);
engine_draw_automap_pixels(v10, v5, v10 + AMPlayerX, v5 - AMPlayerY, 200);
engine_draw_automap_pixels(v11, v12, v10, automap_typeb, 144);
engine_draw_automap_pixels(v11, v12, v4, automap_typeb, 144);
engine_draw_automap_pixels(v11, v5, v10, automap_typeb, 144);
engine_draw_automap_pixels(v11, v5, v4, automap_typeb, 144);
}
if ( v33 & 0x10 )
{
engine_draw_automap_pixels(v4 - AutoMapYPos, v5 - AMPlayerX, v4 - AutoMapXPos, v5, 200);
v33 |= 4u;
}
if ( v33 & 4 )
{
v13 = v4 - AutoMapYPos + AutoMapXPos;
v14 = v4 - AutoMapYPos;
v15 = v5 - AutoMapYPos;
automap_typec = v5 - AMPlayerX;
engine_draw_automap_pixels(v4, v5 - AutoMapYPos, v4 - AutoMapYPos, v5 - AMPlayerX, 200);
engine_draw_automap_pixels(v4, v15, v13, automap_typec, 200);
engine_draw_automap_pixels(v4, v5, v14, automap_typec, 200);
engine_draw_automap_pixels(v4, v5, v13, automap_typec, 200);
}
if ( !(v33 & 0x15) )
engine_draw_automap_pixels(v4, v5 - AutoMapYPos, v4 - AutoMapXPos, v5, 200);
if ( v31 )
goto LABEL_17;
goto LABEL_25;
case 9:
v32 = 1;
LABEL_17:
if ( v33 & 2 )
{
v16 = AutoMapYPos + v4;
v17 = v5 - AutoMapYPos;
v18 = v4 + AutoMapXPos;
automap_typed = v5 - AMPlayerX;
engine_draw_automap_pixels(v4, v5 - AutoMapYPos, v4 + AMPlayerX, v5 - AutoMapYPos + AMPlayerY, 200);
engine_draw_automap_pixels(v18, v5, v18 - AMPlayerX, v5 - AMPlayerY, 200);
engine_draw_automap_pixels(v16, v17, v4, automap_typed, 144);
engine_draw_automap_pixels(v16, v17, v18, automap_typed, 144);
engine_draw_automap_pixels(v16, v5, v4, automap_typed, 144);
engine_draw_automap_pixels(v16, v5, v18, automap_typed, 144);
}
if ( v33 & 0x20 )
{
engine_draw_automap_pixels(AutoMapYPos + v4, v5 - AMPlayerX, v4 + AutoMapXPos, v5, 200);
v33 |= 8u;
}
if ( v33 & 8 )
{
v19 = v4 - AutoMapYPos + AutoMapXPos;
v20 = v4 - AutoMapYPos;
v21 = v5 - AutoMapYPos;
automap_typee = v5 - AMPlayerX;
engine_draw_automap_pixels(v4, v5 - AutoMapYPos, v4 - AutoMapYPos, v5 - AMPlayerX, 200);
engine_draw_automap_pixels(v4, v21, v19, automap_typee, 200);
engine_draw_automap_pixels(v4, v5, v20, automap_typee, 200);
engine_draw_automap_pixels(v4, v5, v19, automap_typee, 200);
}
if ( !(v33 & 0x2A) )
engine_draw_automap_pixels(v4, v5 - AutoMapYPos, v4 + AutoMapXPos, v5, 200);
LABEL_25:
if ( v30 )
goto LABEL_26;
goto LABEL_32;
case 0xA:
goto LABEL_26;
case 0xB:
goto LABEL_33;
case 0xC:
v32 = 1;
LABEL_26:
if ( v33 & 1 )
{
v22 = v4 - AutoMapXPos;
v23 = v4 - AutoMapYPos;
v24 = AutoMapYPos + v5;
automap_typef = AMPlayerX + v5;
engine_draw_automap_pixels(v4, AutoMapYPos + v5, v4 - AMPlayerX, AutoMapYPos + v5 - AMPlayerY, 200);
engine_draw_automap_pixels(v22, v5, v22 + AMPlayerX, v5 + AMPlayerY, 200);
engine_draw_automap_pixels(v23, v24, v22, automap_typef, 144);
engine_draw_automap_pixels(v23, v24, v4, automap_typef, 144);
engine_draw_automap_pixels(v23, v5, v22, automap_typef, 144);
engine_draw_automap_pixels(v23, v5, v4, automap_typef, 144);
}
else
{
engine_draw_automap_pixels(v4, AutoMapYPos + v5, v4 - AutoMapXPos, v5, 200);
}
LABEL_32:
if ( v32 )
{
LABEL_33:
if ( v33 & 2 )
{
v25 = AutoMapYPos + v4;
v26 = AutoMapYPos + v5;
v27 = v4 + AutoMapXPos;
automap_typeg = AMPlayerX + v5;
engine_draw_automap_pixels(v4, AutoMapYPos + v5, v4 + AMPlayerX, AutoMapYPos + v5 - AMPlayerY, 200);
engine_draw_automap_pixels(v27, v5, v27 - AMPlayerX, v5 + AMPlayerY, 200);
engine_draw_automap_pixels(v25, v26, v4, automap_typeg, 144);
engine_draw_automap_pixels(v25, v26, v27, automap_typeg, 144);
engine_draw_automap_pixels(v25, v5, v4, automap_typeg, 144);
engine_draw_automap_pixels(v25, v5, v27, automap_typeg, 144);
}
else
{
v29 = v5;
v28 = v4 + AutoMapXPos;
v9 = AutoMapYPos + v5;
LABEL_36:
engine_draw_automap_pixels(v4, v9, v28, v29, 200);
}
}
break;
default:
return;
}
}
// 4B84BC: using guessed type int AutoMapXPos;
// 4B84C0: using guessed type int AutoMapYPos;
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;
//----- (004029A8) --------------------------------------------------------
void __cdecl DrawAutomapPlr()
{
int v0; // ebx
int v1; // eax
int v2; // ecx
int v3; // esi
int v4; // edi
int v5; // edx
int v6; // ecx
int v7; // eax
int v8; // ecx
int v9; // [esp-Ch] [ebp-20h]
int v10; // [esp-8h] [ebp-1Ch]
int v11; // [esp+Ch] [ebp-8h]
int v12; // [esp+10h] [ebp-4h]
v0 = myplr;
if ( plr[myplr]._pmode == PM_WALK3 )
{
v1 = plr[v0]._px;
v2 = plr[v0]._py;
if ( plr[v0]._pdir == 2 )
++v1;
else
++v2;
}
else
{
v1 = plr[v0].WorldX;
v2 = plr[v0].WorldY;
}
v11 = v1 - 2 * AutoMapXOfs - ViewX;
v12 = v2 - 2 * AutoMapYOfs - ViewY;
v3 = (AutoMapScale * ScrollInfo._sxoff / 100 >> 1)
+ (AutoMapScale * plr[v0]._pxoff / 100 >> 1)
+ AutoMapYPos * (v11 - v12)
+ 384;
if ( invflag || sbookflag )
v3 = (AutoMapScale * ScrollInfo._sxoff / 100 >> 1)
+ (AutoMapScale * plr[v0]._pxoff / 100 >> 1)
+ AutoMapYPos * (v11 - v12)
+ 224;
if ( chrflag || questlog )
v3 += 160;
v4 = AMPlayerX * (v12 + v11)
+ (AutoMapScale * ScrollInfo._syoff / 100 >> 1)
+ (AutoMapScale * plr[v0]._pyoff / 100 >> 1)
+ 336
- AMPlayerX;
switch ( plr[v0]._pdir )
{
case DIR_S:
engine_draw_automap_pixels(v3, v4, v3, v4 + AutoMapYPos, 153);
engine_draw_automap_pixels(v3, AutoMapYPos + v4, v3 + AMPlayerY, v4 + AMPlayerX, 153);
v10 = v4 + AMPlayerX;
v9 = v3 - AMPlayerY;
v5 = AutoMapYPos + v4;
goto LABEL_19;
case DIR_SW:
engine_draw_automap_pixels(
v3,
AMPlayerX * (v12 + v11)
+ (AutoMapScale * ScrollInfo._syoff / 100 >> 1)
+ (AutoMapScale * plr[v0]._pyoff / 100 >> 1)
+ 336
- AMPlayerX,
v3 - AutoMapYPos,
AMPlayerX * (v12 + v11)
+ (AutoMapScale * ScrollInfo._syoff / 100 >> 1)
+ (AutoMapScale * plr[v0]._pyoff / 100 >> 1)
+ 336,
153);
engine_draw_automap_pixels(v3 - AutoMapYPos, AMPlayerX + v4, v3 - AMPlayerY - AMPlayerX, v4, 153);
v7 = AMPlayerX;
v8 = v3;
v5 = AMPlayerX + v4;
v10 = AMPlayerX + v4;
goto LABEL_23;
case DIR_W:
engine_draw_automap_pixels(v3, v4, v3 - AutoMapYPos, v4, 153);
engine_draw_automap_pixels(v3 - AutoMapYPos, v4, v3 - AMPlayerX, v4 - AMPlayerY, 153);
v5 = v4;
v10 = v4 + AMPlayerY;
v9 = v3 - AMPlayerX;
goto LABEL_24;
case DIR_NW:
engine_draw_automap_pixels(v3, v4, v3 - AutoMapYPos, v4 - AMPlayerX, 153);
engine_draw_automap_pixels(v3 - AutoMapYPos, v4 - AMPlayerX, v3 - AMPlayerX, v4 - AMPlayerX, 153);
v7 = AMPlayerX;
v8 = v3 - AMPlayerY;
v10 = v4;
v5 = v4 - AMPlayerX;
LABEL_23:
v9 = v8 - v7;
LABEL_24:
v6 = v3 - AutoMapYPos;
goto LABEL_25;
case DIR_N:
engine_draw_automap_pixels(v3, v4, v3, v4 - AutoMapYPos, 153);
engine_draw_automap_pixels(v3, v4 - AutoMapYPos, v3 - AMPlayerY, v4 - AMPlayerX, 153);
v10 = v4 - AMPlayerX;
v5 = v4 - AutoMapYPos;
v9 = v3 + AMPlayerY;
LABEL_19:
v6 = v3;
goto LABEL_25;
case DIR_NE:
engine_draw_automap_pixels(v3, v4, v3 + AutoMapYPos, v4 - AMPlayerX, 153);
engine_draw_automap_pixels(AutoMapYPos + v3, v4 - AMPlayerX, v3 + AMPlayerX, v4 - AMPlayerX, 153);
v10 = v4;
v9 = v3 + AMPlayerX + AMPlayerY;
v5 = v4 - AMPlayerX;
goto LABEL_17;
case DIR_E:
engine_draw_automap_pixels(v3, v4, v3 + AutoMapYPos, v4, 153);
engine_draw_automap_pixels(AutoMapYPos + v3, v4, v3 + AMPlayerX, v4 - AMPlayerY, 153);
engine_draw_automap_pixels(AutoMapYPos + v3, v4, v3 + AMPlayerX, v4 + AMPlayerY, 153);
break;
case DIR_SE:
engine_draw_automap_pixels(
v3,
AMPlayerX * (v12 + v11)
+ (AutoMapScale * ScrollInfo._syoff / 100 >> 1)
+ (AutoMapScale * plr[v0]._pyoff / 100 >> 1)
+ 336
- AMPlayerX,
v3 + AutoMapYPos,
AMPlayerX * (v12 + v11)
+ (AutoMapScale * ScrollInfo._syoff / 100 >> 1)
+ (AutoMapScale * plr[v0]._pyoff / 100 >> 1)
+ 336,
153);
engine_draw_automap_pixels(AutoMapYPos + v3, AMPlayerX + v4, v3 + AMPlayerX + AMPlayerY, v4, 153);
v5 = AMPlayerX + v4;
v10 = AMPlayerX + v4;
v9 = v3 + AMPlayerX;
LABEL_17:
v6 = AutoMapYPos + v3;
LABEL_25:
engine_draw_automap_pixels(v6, v5, v9, v10, 153);
break;
default:
return;
}
}
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;
// 4B84C0: using guessed type int AutoMapYPos;
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;
// 4B8968: using guessed type int sbookflag;
// 69BD04: using guessed type int questlog;
//----- (00402D83) --------------------------------------------------------
short __fastcall GetAutomapType(int tx, int ty, bool view)
{
int v3; // edi
int v4; // esi
int v6; // eax
short v7; // bp
v3 = ty;
v4 = tx;
if ( view )
{
if ( tx == -1 && ty >= 0 && ty < 40 && automapview[0][ty] )
{
tx = 0;
return ~GetAutomapType(tx, ty, 0) & 0x4000;
}
if ( ty == -1 )
{
if ( tx < 0 )
return 0;
if ( tx < 40 && automapview[tx][0] )
{
ty = 0;
return ~GetAutomapType(tx, ty, 0) & 0x4000;
}
}
}
if ( tx < 0 )
return 0;
if ( tx >= 40 )
return 0;
if ( ty < 0 )
return 0;
if ( ty >= 40 )
return 0;
v6 = ty + 40 * tx;
if ( !automapview[0][v6] && view )
return 0;
v7 = automaptype[(unsigned char)dungeon[0][v6]];
if ( v7 == 7 && ((unsigned short)GetAutomapType(tx - 1, ty, 0) >> 8) & 8 )
{
if ( ((unsigned short)GetAutomapType(v4, v3 - 1, 0) >> 8) & 4 )
v7 = 1;
}
return v7;
}
//----- (00402E4A) --------------------------------------------------------
void __cdecl DrawAutomapGame()
{
int v0; // esi
char *v1; // eax
char *v2; // eax
char v3[256]; // [esp+4h] [ebp-100h]
v0 = 20;
if ( (unsigned char)gbMaxPlayers > 1u )
{
v1 = strcpy(v3, "game: ");
strcat(v1, szPlayerName);
PrintGameStr(8, 20, v3, 3);
v0 = 35;
if ( szPlayerDescript[0] )
{
v2 = strcpy(v3, "password: ");
strcat(v2, szPlayerDescript);
PrintGameStr(8, 35, v3, 3);
v0 = 50;
}
}
if ( setlevel )
{
PrintGameStr(8, v0, quest_level_names[(unsigned char)setlvlnum], 3);
}
else if ( currlevel )
{
sprintf(v3, "Level: %i", currlevel);
PrintGameStr(8, v0, v3, 3);
}
}
// 5CCB10: using guessed type char setlvlnum;
// 5CF31D: using guessed type char setlevel;
// 679660: using guessed type char gbMaxPlayers;
//----- (00402F27) --------------------------------------------------------
void __fastcall SetAutomapView(int x, int y)
{
signed int v2; // esi
signed int v3; // edi
int v4; // ebx
short v5; // ax
short v6; // cx
int v7; // eax
int v8; // eax
int v9; // eax
int v10; // eax
short v11; // ax
int v12; // edi
v2 = (x - 16) >> 1;
v3 = (y - 16) >> 1;
if ( v2 < 0 || v2 >= 40 || v3 < 0 || v3 >= 40 )
return;
v4 = v3 + 40 * v2;
automapview[0][v4] = 1;
v5 = GetAutomapType((x - 16) >> 1, (y - 16) >> 1, 0);
v6 = v5 & 0x4000;
v7 = (v5 & 0xF) - 2;
if ( !v7 )
{
if ( v6 )
{
LABEL_19:
if ( GetAutomapType(v2, v3 + 1, 0) == 0x4007 )
automapview[0][v4 + 1] = 1;
return;
}
goto LABEL_35;
}
v8 = v7 - 1;
if ( !v8 )
{
if ( v6 )
{
v11 = GetAutomapType(v2 + 1, v3, 0);
LABEL_32:
if ( v11 == 0x4007 )
automapview[1][v4] = 1;
return;
}
LABEL_14:
if ( GetAutomapType(v2, v3 - 1, 0) & 0x4000 )
automapview[0][v4 - 1] = 1; // AMbyte_4B7E4C[v4 + 31] = 1;
return;
}
v9 = v8 - 1;
if ( v9 )
{
v10 = v9 - 1;
if ( v10 )
{
if ( v10 != 1 )
return;
if ( v6 )
{
if ( GetAutomapType(v2 - 1, v3, 0) & 0x4000 )
automapview[-1][v4] = 1; // *((_BYTE *)&AMdword_4B7E44 + v4) = 1;
LABEL_13:
v11 = GetAutomapType(v2 + 1, v3, 0);
goto LABEL_32;
}
goto LABEL_14;
}
if ( v6 )
{
if ( GetAutomapType(v2, v3 - 1, 0) & 0x4000 )
automapview[0][v4 - 1] = 1; // AMbyte_4B7E4C[v4 + 31] = 1;
goto LABEL_19;
}
LABEL_35:
if ( GetAutomapType(v2 - 1, v3, 0) & 0x4000 )
automapview[-1][v4] = 1; // *((_BYTE *)&AMdword_4B7E44 + v4) = 1;
return;
}
if ( v6 )
{
if ( GetAutomapType(v2, v3 + 1, 0) == 0x4007 )
automapview[0][v4 + 1] = 1;
goto LABEL_13;
}
if ( GetAutomapType(v2 - 1, v3, 0) & 0x4000 )
automapview[-1][v4] = 1; // *((_BYTE *)&AMdword_4B7E44 + v4) = 1;
v12 = v3 - 1;
if ( GetAutomapType(v2, v12, 0) & 0x4000 )
automapview[0][v4 - 1] = 1; // AMbyte_4B7E4C[v4 + 31] = 1;
if ( GetAutomapType(v2 - 1, v12, 0) & 0x4000 )
automapview[-1][v4 - 1] = 1; /* *((_BYTE *)&AMdword_4B7E40 + v4 + 3) = 1; fix */
}
// 4B7E40: using guessed type int AMdword_4B7E40;
// 4B7E44: using guessed type int AMdword_4B7E44;
//----- (004030DD) --------------------------------------------------------
void __cdecl AutomapZoomReset()
{
AutoMapXOfs = 0;
AutoMapYOfs = 0;
AutoMapPosBits = (AutoMapScale << 6) / 100;
AutoMapXPos = AutoMapPosBits >> 1;
AutoMapYPos = AutoMapPosBits >> 2;
AMPlayerX = AutoMapPosBits >> 3;
AMPlayerY = AutoMapPosBits >> 4;
}
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;
// 4B84B8: using guessed type int AutoMapPosBits;
// 4B84BC: using guessed type int AutoMapXPos;
// 4B84C0: using guessed type int AutoMapYPos;
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;

43
Source/automap.h Normal file
View File

@ -0,0 +1,43 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//automap
extern short automaptype[512];
extern int AMdword_4B7E40; // weak
extern int AMdword_4B7E44; // weak
extern bool automapflag; // idb
extern char AMbyte_4B7E4C[32];
extern char automapview[40][40];
extern int AutoMapScale; // idb
extern int AutoMapXOfs; // weak
extern int AutoMapYOfs; // weak
extern int AutoMapPosBits; // weak
extern int AutoMapXPos; // weak
extern int AutoMapYPos; // weak
extern int AMPlayerX; // weak
extern int AMPlayerY; // weak
void __cdecl InitAutomapOnce();
void __cdecl InitAutomap();
void __cdecl StartAutomap();
void __cdecl AutomapUp();
void __cdecl AutomapDown();
void __cdecl AutomapLeft();
void __cdecl AutomapRight();
void __cdecl AutomapZoomIn();
void __cdecl AutomapZoomOut();
void __cdecl DrawAutomap();
void __fastcall DrawAutomapType(int screen_x, int screen_y, short automap_type);
void __cdecl DrawAutomapPlr();
short __fastcall GetAutomapType(int tx, int ty, bool view);
void __cdecl DrawAutomapGame();
void __fastcall SetAutomapView(int x, int y);
void __cdecl AutomapZoomReset();

219
Source/capture.cpp Normal file
View File

@ -0,0 +1,219 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
//----- (0040311B) --------------------------------------------------------
void __cdecl CaptureScreen()
{
int v4; // edi
PALETTEENTRY palette[256]; // [esp+0h] [ebp-508h]
char FileName[260]; // [esp+400h] [ebp-108h]
HANDLE hObject; // [esp+504h] [ebp-4h]
hObject = CaptureFile(FileName);
if ( hObject != (HANDLE)-1 )
{
DrawAndBlit();
IDirectDrawPalette_GetEntries(lpDDPalette, 0, 0, 256, palette);
RedPalette(palette);
dx_lock_mutex();
v4 = CaptureHdr(hObject, 640, 480);
if ( v4 )
{
v4 = CapturePix(hObject, 640, 480, 768, gpBuffer->row[0].pixels);
if ( v4 )
{
v4 = CapturePal(hObject, palette);
}
}
dx_unlock_mutex();
CloseHandle(hObject);
if ( !v4 )
DeleteFileA(FileName);
Sleep(300);
IDirectDrawPalette_SetEntries(lpDDPalette, 0, 0, 256, palette);
}
}
// 40311B: could not find valid save-restore pair for ebx
// 40311B: could not find valid save-restore pair for edi
// 40311B: could not find valid save-restore pair for esi
//----- (00403204) --------------------------------------------------------
bool __fastcall CaptureHdr(HANDLE hFile, short width, int height)
{
short v3; // si
HANDLE v4; // ebx
PCXHeader Buffer; // [esp+Ch] [ebp-84h]
DWORD lpNumBytes; // [esp+8Ch] [ebp-4h]
v3 = width;
v4 = hFile;
memset(&Buffer, 0, 0x80u);
Buffer.xmax = v3 - 1;
Buffer.vertRes = height;
Buffer.manufacturer = 10;
Buffer.version = 5;
Buffer.encoding = 1;
Buffer.bitsPerPixel = 8;
Buffer.ymax = height - 1;
Buffer.horzRes = v3;
Buffer.numColorPlanes = 1;
Buffer.bytesPerScanLine = v3;
return WriteFile(v4, &Buffer, 0x80u, &lpNumBytes, NULL) && lpNumBytes == 128;
}
//----- (00403294) --------------------------------------------------------
bool __fastcall CapturePal(HANDLE hFile, PALETTEENTRY *palette)
{
BYTE *v2; // eax
char *v3; // esi
signed int v4; // edx
char Buffer[772]; // [esp+8h] [ebp-308h]
DWORD lpNumBytes; // [esp+30Ch] [ebp-4h]
v2 = &palette->peBlue;
Buffer[0] = 12;
v3 = &Buffer[2];
v4 = 256;
do
{
*(v3 - 1) = *(v2 - 2);
*v3 = *(v2 - 1);
v3[1] = *v2;
v2 += 4;
v3 += 3;
--v4;
}
while ( v4 );
return WriteFile(hFile, Buffer, 0x301u, &lpNumBytes, 0) && lpNumBytes == 769;
}
//----- (004032FD) --------------------------------------------------------
bool __fastcall CapturePix(HANDLE hFile, short width, short height, short stride, char *pixels)
{
int v5; // esi
char *v6; // edi
char *v7; // eax
int v8; // ebx
DWORD lpNumBytes; // [esp+Ch] [ebp-8h]
HANDLE hFilea; // [esp+10h] [ebp-4h]
v5 = (unsigned short)width;
hFilea = hFile;
v6 = (char *)DiabloAllocPtr(2 * (unsigned short)width);
do
{
if ( !height )
{
mem_free_dbg(v6);
return 1;
}
*(_DWORD *)&height = height + 0xFFFF;
v7 = CaptureEnc(pixels, v6, v5);
pixels += (unsigned short)stride;
v8 = v7 - v6;
}
while ( WriteFile(hFilea, v6, v7 - v6, &lpNumBytes, 0) && lpNumBytes == v8 );
return 0;
}
//----- (0040336A) --------------------------------------------------------
char *__fastcall CaptureEnc(char *src, char *dst, int width)
{
int v3; // esi
char v4; // bl
signed int v5; // eax
v3 = width;
do
{
v4 = *src++;
v5 = 1;
--v3;
if ( v4 == *src )
{
do
{
if ( v5 >= 63 )
break;
if ( !v3 )
break;
++v5;
--v3;
++src;
}
while ( v4 == *src );
if ( v5 > 1 )
goto LABEL_13;
}
if ( (unsigned char)v4 > 0xBFu )
LABEL_13:
*dst++ = v5 | 0xC0;
*dst++ = v4;
}
while ( v3 );
return dst;
}
//----- (004033A8) --------------------------------------------------------
HANDLE __fastcall CaptureFile(char *dst_path)
{
char *v1; // edi
__int32 v2; // esi
int v3; // eax
int v5; // [esp-4h] [ebp-18Ch]
struct _finddata_t v6; // [esp+Ch] [ebp-17Ch]
char v7[100]; // [esp+124h] [ebp-64h]
v1 = dst_path;
memset(v7, 0, 0x64u);
v2 = _findfirst("screen??.PCX", &v6);
if ( v2 != -1 )
{
do
{
if ( isdigit(v6.name[6]) )
{
if ( isdigit(v6.name[7]) )
v7[10 * v6.name[6] - 528 + v6.name[7]] = 1;
}
}
while ( !_findnext(v2, &v6) );
}
v3 = 0;
while ( v7[v3] )
{
if ( ++v3 >= 100 )
return (HANDLE)-1;
}
v5 = v3;
sprintf(v1, "screen%02d.PCX", v3);
return CreateFileA(v1, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
}
// 4033A8: using guessed type char var_64[100];
//----- (00403470) --------------------------------------------------------
void __fastcall RedPalette(PALETTEENTRY *pal)
{
int i; // eax
PALETTEENTRY red[256]; // [esp+Ch] [ebp-400h]
for(i = 0; i < 256; i++)
{
red[i].peRed = pal[i].peRed;
red[i].peGreen = 0;
red[i].peBlue = 0;
red[i].peFlags = 0;
}
IDirectDrawPalette_SetEntries(lpDDPalette, 0, 0, 256, red);
}

18
Source/capture.h Normal file
View File

@ -0,0 +1,18 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
void __cdecl CaptureScreen();
bool __fastcall CaptureHdr(HANDLE hFile, short width, int height);
bool __fastcall CapturePal(HANDLE hFile, PALETTEENTRY *palette);
bool __fastcall CapturePix(HANDLE hFile, short width, short height, short stride, char *pixels);
char *__fastcall CaptureEnc(char *src, char *dst, int width);
HANDLE __fastcall CaptureFile(char *dst_path);
void __fastcall RedPalette(PALETTEENTRY *pal);

199
Source/codec.cpp Normal file
View File

@ -0,0 +1,199 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
//----- (004034D9) --------------------------------------------------------
int __fastcall codec_decode(void *pbSrcDst, int size, char *pszPassword)
{
unsigned int v3; // ebx
char *v4; // esi
int v5; // ebx
signed int v7; // ecx
int v8; // esi
char v9[128]; // [esp+8h] [ebp-98h]
char dst[20]; // [esp+88h] [ebp-18h]
int v11; // [esp+9Ch] [ebp-4h]
char *passworda; // [esp+A8h] [ebp+8h]
v3 = size;
v4 = (char *)pbSrcDst;
codec_init_key(0, pszPassword);
if ( v3 <= 8 )
return 0;
v5 = v3 - 8;
v11 = v5;
if ( v5 & 0x3F )
return 0;
passworda = (char *)v5;
if ( v5 )
{
do
{
memcpy(v9, v4, 0x40u);
SHA1Result(0, dst);
v7 = 0;
do
{
v9[v7] ^= dst[v7 % 20];
++v7;
}
while ( v7 < 64 );
SHA1Calculate(0, v9, 0);
memset(dst, 0, 0x14u);
memcpy(v4, v9, 0x40u);
v4 += 64;
passworda -= 64;
}
while ( passworda );
v5 = v11;
}
memset(v9, 0, 0x80u);
if ( !v4[4] )
{
SHA1Result(0, dst);
if ( *(_DWORD *)v4 == *(_DWORD *)dst )
{
v8 = v5 + (unsigned char)v4[5] - 64;
goto LABEL_14;
}
memset(dst, 0, 0x14u);
}
v8 = 0;
LABEL_14:
SHA1Clear();
return v8;
}
// 4034D9: using guessed type char var_98[128];
//----- (004035DB) --------------------------------------------------------
void __fastcall codec_init_key(int unused, char *pszPassword)
{
char *v2; // edi
char *v3; // esi
int v4; // eax
signed int v5; // ecx
char v6; // dl
unsigned int v7; // ecx
signed int v8; // esi
char v9[136]; // [esp+Ch] [ebp-E0h]
char v10[64]; // [esp+94h] [ebp-58h]
char dst[20]; // [esp+D4h] [ebp-18h]
int v12; // [esp+E8h] [ebp-4h]
v2 = pszPassword;
srand(0x7058u);
v3 = v9;
v12 = 136;
do
{
*v3++ = rand();
--v12;
}
while ( v12 );
v4 = 0;
v5 = 0;
do
{
if ( !v2[v4] )
v4 = 0;
v6 = v2[v4++];
v10[v5++] = v6;
}
while ( v5 < 64 );
SHA1Reset(0);
SHA1Calculate(0, v10, dst);
SHA1Clear();
v7 = 0;
do
{
v9[v7] ^= dst[(signed int)v7 % 20];
++v7;
}
while ( v7 < 0x88 );
memset(v10, 0, 0x40u);
memset(dst, 0, 0x14u);
v8 = 0;
do
{
SHA1Reset(v8);
SHA1Calculate(v8++, &v9[72], 0);
}
while ( v8 < 3 );
memset(v9, 0, 0x88u);
}
// 4035DB: using guessed type char var_E0[72];
// 4035DB: using guessed type char var_58[64];
// 4035DB: using guessed type char dst[20];
//----- (004036AC) --------------------------------------------------------
int __fastcall codec_get_encoded_len(int dwSrcBytes)
{
if ( dwSrcBytes & 0x3F )
dwSrcBytes += 64 - (dwSrcBytes & 0x3F);
return dwSrcBytes + 8;
}
//----- (004036BE) --------------------------------------------------------
void __fastcall codec_encode(void *pbSrcDst, int size, int size_64, char *pszPassword)
{
char *v4; // esi
char v5; // bl
size_t v6; // edi
signed int v7; // ecx
char v9[128]; // [esp+8h] [ebp-ACh]
char v10[20]; // [esp+88h] [ebp-2Ch]
char dst[20]; // [esp+9Ch] [ebp-18h]
size_t v12; // [esp+B0h] [ebp-4h]
v4 = (char *)pbSrcDst;
v12 = size;
if ( size_64 != codec_get_encoded_len(size) )
TermMsg("Invalid encode parameters");
codec_init_key(1, pszPassword);
v5 = 0;
if ( v12 )
{
do
{
v6 = v12;
if ( v12 >= 0x40 )
v6 = 64;
memcpy(v9, v4, v6);
if ( v6 < 0x40 )
memset(&v9[v6], 0, 64 - v6);
SHA1Result(0, dst);
SHA1Calculate(0, v9, 0);
v7 = 0;
do
{
v9[v7] ^= dst[v7 % 20];
++v7;
}
while ( v7 < 64 );
memset(dst, 0, 0x14u);
memcpy(v4, v9, 0x40u);
v4 += 64;
v12 -= v6;
}
while ( v12 );
v5 = v6;
}
memset(v9, 0, 0x80u);
SHA1Result(0, v10);
v4[4] = 0;
*((_WORD *)v4 + 3) = 0;
*(_DWORD *)v4 = *(_DWORD *)v10;
v4[5] = v5;
SHA1Clear();
}
// 4036BE: using guessed type char var_AC[128];
// 4036BE: using guessed type char dst[20];

15
Source/codec.h Normal file
View File

@ -0,0 +1,15 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
int __fastcall codec_decode(void *pbSrcDst, int size, char *pszPassword);
void __fastcall codec_init_key(int unused, char *pszPassword);
int __fastcall codec_get_encoded_len(int dwSrcBytes);
void __fastcall codec_encode(void *pbSrcDst, int size, int size_64, char *pszPassword);

3503
Source/control.cpp Normal file

File diff suppressed because it is too large Load Diff

147
Source/control.h Normal file
View File

@ -0,0 +1,147 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//control
extern char sgbNextTalkSave; // weak
extern char sgbTalkSavePos; // weak
extern void *pDurIcons;
extern void *pChrButtons;
extern int drawhpflag; // idb
extern int dropGoldFlag; // weak
extern int panbtn[8];
extern int chrbtn[4];
extern void *pMultiBtns;
extern void *pPanelButtons;
extern void *pChrPanel;
extern int lvlbtndown; // weak
extern char sgszTalkSave[8][80];
extern int dropGoldValue; // idb
extern int drawmanaflag; // idb
extern int chrbtnactive; // weak
extern char sgszTalkMsg[80];
extern void *pPanelText;
extern int frame_4B8800; // idb
extern void *pLifeBuff;
extern void *pBtmBuff;
extern void *pTalkBtns;
extern int pstrjust[4];
extern int pnumlines; // idb
extern int pinfoflag; // weak
extern int talkbtndown[3];
extern int pSpell; // weak
extern void *pManaBuff;
extern int infoclr; // weak
extern int sgbPlrTalkTbl; // weak // should be char [4]
extern void *pGBoxBuff;
extern void *pSBkBtnCel;
extern char tempstr[260];
extern int sbooktab; // weak
extern int pSplType; // weak
extern int frame; // idb
extern int initialDropGoldIndex; // idb
extern int talkflag; // weak
extern void *pSBkIconCels;
extern int sbookflag; // weak
extern int chrflag;
extern int drawbtnflag; // idb
extern void *pSpellBkCel;
extern char infostr[260];
extern int numpanbtns; // weak
extern void *pStatusPanel;
extern char panelstr[256];
extern int panelflag; // weak
extern char byte_4B8B88[256];
extern int initialDropGoldValue; // idb
extern void *pSpellCels;
extern int panbtndown; // weak
extern void *pTalkPanel; // idb
extern int spselflag; // weak
void __fastcall DrawSpellCel(int xp, int yp, char *Trans, int nCel, int w);
void __fastcall SetSpellTrans(char t);
void __cdecl DrawSpell();
void __cdecl DrawSpellList();
void __cdecl SetSpell();
void __fastcall SetSpeedSpell(int slot);
void __fastcall ToggleSpell(int slot);
void __fastcall CPrintString(int No, unsigned char pszStr, int Just);
void __fastcall AddPanelString(char *str, int just);
void __cdecl ClearPanel();
void __fastcall DrawPanelBox(int x, int y, int w, int h, int sx, int sy);
void __cdecl InitPanelStr();
void __fastcall SetFlaskHeight(char *buf, int min, int max, int c, int r);
void __fastcall DrawFlask(void *a1, int a2, int a3, void *a4, int a5, int a6);
void __cdecl DrawLifeFlask();
void __cdecl UpdateLifeFlask();
void __cdecl DrawManaFlask();
void __cdecl control_update_life_mana();
void __cdecl UpdateManaFlask();
void __cdecl InitControlPan();
void __cdecl ClearCtrlPan();
void __cdecl DrawCtrlPan();
void __cdecl DoSpeedBook();
void __cdecl DoPanBtn();
void __fastcall control_set_button_down(int btn_id);
void __cdecl control_check_btn_press();
void __cdecl DoAutoMap();
void __cdecl CheckPanelInfo();
void __cdecl CheckBtnUp();
void __cdecl FreeControlPan();
int __fastcall control_WriteStringToBuffer(char *str);
void __cdecl DrawInfoBox();
void __fastcall control_print_info_str(int y, char *str, bool center, int lines);
void __fastcall PrintGameStr(int x, int y, char *str, int color);
void __cdecl DrawChr();
void __fastcall ADD_PlrStringXY(int x, int y, int width, char *pszStr, char col);
void __fastcall MY_PlrStringXY(int x, int y, int width, char *pszStr, char col, int base);
void __cdecl CheckLvlBtn();
void __cdecl ReleaseLvlBtn();
void __cdecl DrawLevelUpIcon();
void __cdecl CheckChrBtns();
void __cdecl ReleaseChrBtns();
void __cdecl DrawDurIcon();
int __fastcall DrawDurIcon4Item(ItemStruct *pItem, int x, int c);
void __cdecl RedBack();
int __fastcall GetSBookTrans(int ii, unsigned char townok);
void __cdecl DrawSpellBook();
void __fastcall PrintSBookStr(int x, int y, bool cjustflag, char *pszStr, int bright);
void __cdecl CheckSBook();
char *__fastcall get_pieces_str(int nGold);
void __fastcall DrawGoldSplit(int amount);
void __fastcall control_drop_gold(int vkey);
void __fastcall control_remove_gold(int pnum, int gold_index);
void __fastcall control_set_gold_curs(int pnum);
void __cdecl DrawTalkPan();
char *__fastcall control_print_talk_msg(char *msg, int x, int y, int *a4, int just);
int __cdecl control_check_talk_btn();
void __cdecl control_release_talk_btn();
void __cdecl control_reset_talk_msg();
void __cdecl control_type_message();
void __cdecl control_reset_talk();
int __fastcall control_talk_last_key(int a1);
int __fastcall control_presskeys(int a1);
void __cdecl control_press_enter();
void __fastcall control_up_down(char a1);
/* data */
extern unsigned char fontframe[127];
extern unsigned char fontkern[68];
extern int lineoffset[25];
extern unsigned char fontidx[256];
/* rdata */
extern unsigned char SpellITbl[37];
extern int PanBtnPos[8][5];
extern char *PanBtnHotKey[8];
extern char *PanBtnStr[8];
extern RECT32 attribute_inc_rects[4];
extern int SpellPages[6][7];

1310
Source/cursor.cpp Normal file

File diff suppressed because it is too large Load Diff

42
Source/cursor.h Normal file
View File

@ -0,0 +1,42 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//cursor
extern int cursH; // weak
extern int icursH28; // idb
extern int cursW; // idb
extern int pcursmonst; // idb
extern int icursW28; // idb
extern void *pCursCels;
extern int icursH; // weak
extern char pcursinvitem; // weak
extern int icursW; // weak
extern char pcursitem; // weak
extern char pcursobj; // weak
extern char pcursplr; // weak
extern int cursmx;
extern int cursmy;
extern int dword_4B8CCC; // weak
extern int pcurs; // idb
void __cdecl InitCursor();
void __cdecl FreeCursor();
void __fastcall SetICursor(int i);
void __fastcall SetCursor(int i);
void __fastcall NewCursor(int i);
void __cdecl InitLevelCursor();
void __cdecl CheckTown();
void __cdecl CheckRportal();
void __cdecl CheckCursMove();
/* data */
extern int InvItemWidth[180];
extern int InvItemHeight[180];

161
Source/dead.cpp Normal file
View File

@ -0,0 +1,161 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int spurtndx; // weak
DeadStruct dead[31];
int stonendx;
//----- (004084A6) --------------------------------------------------------
void __cdecl InitDead()
{
int v0; // ebx
int *v1; // edx
int *v2; // eax
int v3; // ecx
int v4; // edx
int v5; // eax
int v6; // edx
int v7; // esi
int *v8; // eax
int v9; // edx
CMonster *v10; // ecx
char *v11; // edi
int *v12; // ebx
int mtypes[200]; // [esp+Ch] [ebp-330h]
int *v14; // [esp+32Ch] [ebp-10h]
int *v15; // [esp+330h] [ebp-Ch]
int v16; // [esp+334h] [ebp-8h]
int v17; // [esp+338h] [ebp-4h]
memset(mtypes, 0, sizeof(mtypes));
v0 = 0;
if ( nummtypes > 0 )
{
v1 = &dead[0]._deadFrame;
v2 = &Monsters[0].Anims[4].Rate;
v17 = nummtypes;
do
{
v15 = &mtypes[*((unsigned char *)v2 - 216)];
if ( !*v15 )
{
qmemcpy(v1 - 8, v2 - 8, 0x20u);
v3 = *v2;
*((_BYTE *)v1 + 12) = 0;
*v1 = v3;
v1[1] = v2[21];
v1[2] = v2[22];
*((_BYTE *)v2 + 101) = ++v0;
v1 += 12;
*v15 = v0;
}
v2 += 82;
--v17;
}
while ( v17 );
}
v16 = 0;
v4 = v0;
memset(&dead[v0], misfiledata[16].mAnimCel[0], 8u);
_LOBYTE(dead[v4]._deadtrans) = 0;
dead[v4]._deadFrame = 8;
v5 = misfiledata[18].mAnimCel[0];
dead[v4].field_24 = 128;
dead[v4].field_28 = 32;
v6 = v0 + 1;
spurtndx = v0 + 1;
memset(&dead[v6], v5, 8u);
_LOBYTE(dead[v6]._deadtrans) = 0;
stonendx = v0 + 2;
v7 = nummonsters;
dead[v6]._deadFrame = 12;
dead[v6].field_24 = 128;
dead[v6].field_28 = 32;
v17 = v0 + 2;
if ( v7 > 0 )
{
v8 = &dead[v0 + 2]._deadFrame;
do
{
v9 = monstactive[v16];
if ( monster[v9]._uniqtype )
{
v10 = monster[v9].MType;
v11 = (char *)(v8 - 8);
v15 = (int *)8;
v14 = &v10->Anims[4].Frames[1];
do
{
v12 = v14;
++v14;
*(_DWORD *)v11 = *v12;
v11 += 4;
v15 = (int *)((char *)v15 - 1);
}
while ( v15 );
*v8 = v10->Anims[4].Rate;
v8[1] = v10->flags_1;
v8[2] = v10->flags_2;
*((_BYTE *)v8 + 12) = monster[v9]._uniqtrans + 4;
monster[v9]._udeadval = ++v17;
v8 += 12;
}
++v16;
}
while ( v16 < v7 );
}
}
// 4B8CD8: using guessed type int spurtndx;
//----- (0040865C) --------------------------------------------------------
void __fastcall AddDead(int dx, int dy, char dv, int ddir)
{
dDead[dx][dy] = (dv & 0x1F) + 32 * ddir;
}
//----- (0040867D) --------------------------------------------------------
void __cdecl SetDead()
{
int v0; // eax
int v1; // esi
int v2; // ebp
char (*v3)[112]; // ebx
int v4; // edi
int i; // [esp+0h] [ebp-4h]
v0 = 0;
for ( i = 0; i < nummonsters; ++i )
{
v1 = monstactive[v0];
if ( monster[v1]._uniqtype )
{
v2 = 0;
v3 = dDead;
do
{
v4 = 0;
do
{
if ( ((*v3)[v4] & 0x1F) == monster[v1]._udeadval )
ChangeLightXY((unsigned char)monster[v1].mlid, v2, v4);
++v4;
}
while ( v4 < 112 );
++v3;
++v2;
}
while ( (signed int)v3 < (signed int)&dDead[112][0] );
}
v0 = i + 1;
}
}

19
Source/dead.h Normal file
View File

@ -0,0 +1,19 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//dead
extern int spurtndx; // weak
extern DeadStruct dead[31];
extern int stonendx;
void __cdecl InitDead();
void __fastcall AddDead(int dx, int dy, char dv, int ddir);
void __cdecl SetDead();

225
Source/debug.cpp Normal file
View File

@ -0,0 +1,225 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
void *pSquareCel;
char dMonsDbg[17][112][112];
char dFlagDbg[17][112][112];
//----- (004086F4) --------------------------------------------------------
void __cdecl LoadDebugGFX()
{
if ( visiondebug )
pSquareCel = LoadFileInMem("Data\\Square.CEL", 0);
}
// 525720: using guessed type int visiondebug;
//----- (0040870F) --------------------------------------------------------
void __cdecl FreeDebugGFX()
{
void *v0; // ecx
v0 = pSquareCel;
pSquareCel = 0;
mem_free_dbg(v0);
}
//----- (00408721) --------------------------------------------------------
void __cdecl CheckDungeonClear()
{
int i;
int j;
for(i = 0; i < 112; i++)
{
for(j = 0; j < 112; j++)
{
if ( dMonster[i][j] )
TermMsg("Monsters not cleared");
if ( dPlayer[i][j] )
TermMsg("Players not cleared");
dMonsDbg[currlevel][i][j] = dFlags[i][j] & 2;
dFlagDbg[currlevel][i][j] = dFlags[i][j] & 8;
}
}
}
#ifdef _DEBUG
void __cdecl GiveGoldCheat()
{
int i; // esi
int ni; // ebp
for(i = 0; i < 40; i++)
{
if ( !plr[myplr].InvGrid[i] )
{
ni = plr[myplr]._pNumInv++;
SetPlrHandItem(&plr[myplr].InvList[ni], IDI_GOLD);
GetPlrHandSeed(&plr[myplr].InvList[ni]);
plr[myplr].InvList[ni]._ivalue = 5000;
plr[myplr].InvList[ni]._iCurs = 6;
plr[myplr]._pGold += 5000;
plr[myplr].InvGrid[i] = plr[myplr]._pNumInv;
}
}
}
void __cdecl StoresCheat()
{
int i; // eax
numpremium = 0;
for(i = 0; i < 6; i++)
premiumitem[i]._itype = -1;
SpawnPremium(30);
for(i = 0; i < 20; i++)
witchitem[i]._itype = -1;
SpawnWitch(30);
}
void __cdecl TakeGoldCheat()
{
int i; // esi
char ig; // cl
for(i = 0; i < 40; i++)
{
ig = plr[myplr].InvGrid[i];
if ( ig > 0 && plr[myplr].InvList[ig - 1]._itype == ITYPE_GOLD )
RemoveInvItem(myplr, ig - 1);
}
for(i = 0; i < 8; i++)
{
if ( plr[myplr].SpdList[i]._itype == ITYPE_GOLD )
plr[myplr].SpdList[i]._itype = -1;
}
plr[myplr]._pGold = 0;
}
void __cdecl MaxSpellsCheat()
{
int i; // ebp
for(i = 1; i < 37; i++)
{
if ( spelldata[i].sBookLvl != -1 )
{
*(_QWORD *)plr[myplr]._pMemSpells |= 1i64 << (i - 1);
plr[myplr]._pSplLvl[i] = 10;
}
}
}
void __fastcall PrintDebugPlayer(bool bNextPlayer)
{
char dstr[128]; // [esp+Ch] [ebp-80h]
if ( bNextPlayer )
dbgplr = ((_BYTE)dbgplr + 1) & 3;
sprintf(dstr, "Plr %i : Active = %i", dbgplr, plr[dbgplr].plractive);
NetSendCmdString(1 << myplr, dstr);
if ( plr[dbgplr].plractive )
{
sprintf(dstr, " Plr %i is %s", dbgplr, plr[dbgplr]._pName);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " Lvl = %i : Change = %i", plr[dbgplr].plrlevel, plr[dbgplr]._pLvlChanging);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " x = %i, y = %i : tx = %i, ty = %i", plr[dbgplr].WorldX, plr[dbgplr].WorldY, plr[dbgplr]._ptargx, plr[dbgplr]._ptargy);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " mode = %i : daction = %i : walk[0] = %i", plr[dbgplr]._pmode, plr[dbgplr].destAction, plr[dbgplr].walkpath[0]);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " inv = %i : hp = %i", plr[dbgplr]._pInvincible, plr[dbgplr]._pHitPoints);
NetSendCmdString(1 << myplr, dstr);
}
}
void __cdecl PrintDebugQuest()
{
char dstr[128]; // [esp+0h] [ebp-80h]
sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", dbgqst, quests[dbgqst]._qactive, quests[dbgqst]._qvar1);
NetSendCmdString(1 << myplr, dstr);
if ( ++dbgqst == 16 )
dbgqst = 0;
}
void __fastcall PrintDebugMonster(int m)
{
bool bActive; // ecx
int i; // eax
char dstr[128]; // [esp+Ch] [ebp-80h]
sprintf(dstr, "Monster %i = %s", m, monster[m].mName);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, "X = %i, Y = %i", monster[m]._mx, monster[m]._my);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, "Enemy = %i, HP = %i", monster[m]._menemy, monster[m]._mhitpoints);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, "Mode = %i, Var1 = %i", monster[m]._mmode, monster[m]._mVar1);
NetSendCmdString(1 << myplr, dstr);
bActive = 0;
for(i = 0; i < nummonsters; i++)
{
if ( monstactive[i] == m )
bActive = 1;
}
sprintf(dstr, "Active List = %i, Squelch = %i", bActive, monster[m]._msquelch);
NetSendCmdString(1 << myplr, dstr);
}
void __cdecl GetDebugMonster()
{
int v0; // ecx
int v1; // eax
v0 = pcursmonst;
if ( pcursmonst == -1 )
{
v1 = dMonster[cursmx][cursmy];
if ( v1 )
{
v0 = v1 - 1;
if ( v1 <= 0 )
v0 = -1 - v1;
}
else
{
v0 = dbgmon;
}
}
PrintDebugMonster(v0);
}
void __cdecl NextDebugMonster()
{
char dstr[128]; // [esp+0h] [ebp-80h]
if ( dbgmon++ == 200 )
dbgmon = 0;
sprintf(dstr, "Current debug monster = %i", dbgmon);
NetSendCmdString(1 << myplr, dstr);
}
#endif

30
Source/debug.h Normal file
View File

@ -0,0 +1,30 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//debug
extern void *pSquareCel;
extern char dMonsDbg[17][112][112];
extern char dFlagDbg[17][112][112];
void __cdecl LoadDebugGFX();
void __cdecl FreeDebugGFX();
void __cdecl CheckDungeonClear();
#ifdef _DEBUG
void __cdecl GiveGoldCheat();
void __cdecl StoresCheat();
void __cdecl TakeGoldCheat();
void __cdecl MaxSpellsCheat();
void __fastcall PrintDebugPlayer(bool bNextPlayer);
void __cdecl PrintDebugQuest();
void __fastcall PrintDebugMonster(int m);
void __cdecl GetDebugMonster();
void __cdecl NextDebugMonster();
#endif

2331
Source/diablo.cpp Normal file

File diff suppressed because it is too large Load Diff

107
Source/diablo.h Normal file
View File

@ -0,0 +1,107 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//diablo
extern int diablo_cpp_init_value; // weak
extern HWND ghMainWnd;
extern int glMid1Seed[17];
extern int glMid2Seed[17];
extern int gnLevelTypeTbl[17];
extern int MouseY; // idb
extern int MouseX; // idb
extern bool gbGameLoopStartup; // idb
extern int glSeedTbl[17];
extern int gbRunGame; // weak
extern int glMid3Seed[17];
extern int gbRunGameResult; // weak
extern int zoomflag; // weak
extern int gbProcessPlayers; // weak
extern int glEndSeed[17];
extern int dword_5256E8; // weak
extern HINSTANCE ghInst; // idb
extern int DebugMonsters[10];
extern char cineflag; // weak
extern int drawpanflag; // weak
extern int visiondebug; // weak
extern int scrollflag; /* unused */
extern int light4flag; // weak
extern int leveldebug; // weak
extern int monstdebug; // weak
extern int trigdebug; /* unused */
extern int setseed; // weak
extern int debugmonsttypes; // weak
extern int PauseMode; // weak
extern int sgnTimeoutCurs;
extern char sgbMouseDown; // weak
extern int color_cycle_timer; // weak
void __cdecl diablo_cpp_init();
void __cdecl FreeGameMem();
int __fastcall diablo_init_menu(int a1, int bSinglePlayer);
void __fastcall run_game_loop(int uMsg);
void __fastcall start_game(int uMsg);
void __cdecl free_game();
bool __cdecl diablo_get_not_running();
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
void __fastcall diablo_parse_flags(char *args);
void __cdecl diablo_init_screen();
HWND __fastcall diablo_find_window(LPCSTR lpClassName);
void __fastcall diablo_reload_process(HMODULE hModule);
int __cdecl PressEscKey();
LRESULT __stdcall DisableInputWndProc(HWND hWnd, int uMsg, int wParam, int lParam);
int __stdcall GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
bool __fastcall LeftMouseDown(int a1);
bool __cdecl TryIconCurs();
void __cdecl LeftMouseUp();
void __cdecl RightMouseDown();
void __fastcall j_gmenu_on_mouse_move(LPARAM lParam);
bool __fastcall PressSysKey(int wParam);
void __fastcall diablo_hotkey_msg(int dwMsg);
void __fastcall ReleaseKey(int vkey);
void __fastcall PressKey(int vkey);
void __cdecl diablo_pause_game();
void __fastcall PressChar(int vkey);
void __cdecl LoadLvlGFX();
void __cdecl LoadAllGFX();
void __fastcall CreateLevel(int lvldir);
void __fastcall LoadGameLevel(bool firstflag, int lvldir);
void __fastcall game_loop(bool startup);
void __cdecl game_logic();
void __fastcall timeout_cursor(bool timeout);
void __cdecl diablo_color_cyc_logic();
/* data */
extern int diablo_inf; // weak
/* rdata */
extern int fullscreen; // weak
#ifdef _DEBUG
extern int showintrodebug;
extern int questdebug;
extern int debug_mode_key_s;
extern int debug_mode_key_w;
extern int debug_mode_key_inverted_v;
extern int debug_mode_dollar_sign;
extern int debug_mode_key_d;
extern int debug_mode_key_i;
extern int dbgplr;
extern int dbgqst;
extern int dbgmon;
extern int frameflag;
extern int frameend;
extern int framerate;
extern int framestart;
#endif
extern int FriendlyMode; // weak
extern char *spszMsgTbl[4]; // weak
extern char *spszMsgKeyTbl[4]; // weak

110
Source/doom.cpp Normal file
View File

@ -0,0 +1,110 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int doom_quest_time; // weak
int doom_stars_drawn; // weak
void *pDoomCel;
int doomflag; // weak
int DoomQuestState; // idb
//----- (0040ACAD) --------------------------------------------------------
int __cdecl doom_get_frame_from_time()
{
int result; // eax
if ( DoomQuestState == 36001 )
result = 31;
else
result = DoomQuestState / 1200;
return result;
}
//----- (0040ACC6) --------------------------------------------------------
void __cdecl doom_alloc_cel()
{
pDoomCel = DiabloAllocPtr(229376);
}
//----- (0040ACD6) --------------------------------------------------------
void __cdecl doom_cleanup()
{
void *v0; // ecx
v0 = pDoomCel;
pDoomCel = 0;
mem_free_dbg(v0);
}
//----- (0040ACE8) --------------------------------------------------------
void __cdecl doom_load_graphics()
{
if ( doom_quest_time == 31 )
{
strcpy(tempstr, "Items\\Map\\MapZDoom.CEL");
}
else if ( doom_quest_time >= 10 )
{
sprintf(tempstr, "Items\\Map\\MapZ00%i.CEL", doom_quest_time);
}
else
{
sprintf(tempstr, "Items\\Map\\MapZ000%i.CEL", doom_quest_time);
}
LoadFileWithMem(tempstr, pDoomCel);
}
// 525750: using guessed type int doom_quest_time;
//----- (0040AD34) --------------------------------------------------------
void __cdecl doom_init()
{
int v0; // eax
doomflag = 1;
doom_alloc_cel();
v0 = -(doom_get_frame_from_time() != 31);
_LOBYTE(v0) = v0 & 0xE1;
doom_quest_time = v0 + 31;
doom_load_graphics();
}
// 525750: using guessed type int doom_quest_time;
// 52575C: using guessed type int doomflag;
//----- (0040AD5E) --------------------------------------------------------
void __cdecl doom_close()
{
if ( doomflag )
{
doomflag = 0;
doom_cleanup();
}
}
// 52575C: using guessed type int doomflag;
//----- (0040AD74) --------------------------------------------------------
void __cdecl doom_draw()
{
if ( doomflag )
{
if ( doom_quest_time != 31 && ++doom_stars_drawn >= 5 )
{
doom_stars_drawn = 0;
if ( ++doom_quest_time > doom_get_frame_from_time() )
doom_quest_time = 0;
doom_load_graphics();
}
CelDecodeOnly(64, 511, pDoomCel, 1, 640);
}
}
// 525750: using guessed type int doom_quest_time;
// 525754: using guessed type int doom_stars_drawn;
// 52575C: using guessed type int doomflag;

25
Source/doom.h Normal file
View File

@ -0,0 +1,25 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//doom
extern int doom_quest_time; // weak
extern int doom_stars_drawn; // weak
extern void *pDoomCel;
extern int doomflag; // weak
extern int DoomQuestState; // idb
int __cdecl doom_get_frame_from_time();
void __cdecl doom_alloc_cel();
void __cdecl doom_cleanup();
void __cdecl doom_load_graphics();
void __cdecl doom_init();
void __cdecl doom_close();
void __cdecl doom_draw();

2981
Source/drlg_l1.cpp Normal file

File diff suppressed because it is too large Load Diff

74
Source/drlg_l1.h Normal file
View File

@ -0,0 +1,74 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//drlg_l1
extern char L5dungeon[80][80];
extern char mydflags[40][40];
extern int setloadflag; // weak
extern int HR1;
extern int HR2;
extern int HR3;
extern int VR1;
extern int VR2;
extern int VR3;
extern void *pSetPiece; // idb
void __cdecl DRLG_Init_Globals();
void __fastcall LoadL1Dungeon(char *sFileName, int vx, int vy);
void __cdecl DRLG_L1Floor();
void __cdecl DRLG_L1Pass3();
void __cdecl DRLG_InitL1Vals();
void __fastcall LoadPreL1Dungeon(char *sFileName, int vx, int vy);
void __fastcall CreateL5Dungeon(int rseed, int entry);
void __cdecl DRLG_LoadL1SP();
void __cdecl DRLG_FreeL1SP();
void __fastcall DRLG_L5(int entry);
void __fastcall DRLG_PlaceDoor(int x, int y);
void __cdecl DRLG_L1Shadows();
int __fastcall DRLG_PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int noquad, int ldir);
void __cdecl InitL5Dungeon();
void __cdecl L5ClearFlags();
void __cdecl L5firstRoom();
void __fastcall L5drawRoom(int x, int y, int w, int h);
void __fastcall L5roomGen(int x, int y, int w, int h, bool dir);
bool __fastcall L5checkRoom(int x, int y, int width, int height);
int __cdecl L5GetArea();
void __cdecl L5makeDungeon();
void __cdecl L5makeDmt();
void __cdecl L5AddWall();
int __fastcall L5HWallOk(int i, int j);
int __fastcall L5VWallOk(int i, int j);
void __fastcall L5HorizWall(int i, int j, char p, int dx);
void __fastcall L5VertWall(int i, int j, char p, int dy);
void __cdecl L5tileFix();
void __cdecl DRLG_L5Subs();
void __cdecl L5FillChambers();
void __fastcall DRLG_L5GChamber(int sx, int sy, bool topflag, bool bottomflag, bool leftflag, bool rightflag);
void __fastcall DRLG_L5GHall(int x1, int y1, int x2, int y2);
void __fastcall DRLG_L5SetRoom(int rx1, int ry1);
void __cdecl DRLG_L5FloodTVal();
void __fastcall DRLG_L5FTVR(int i, int j, int x, int y, int d);
void __cdecl DRLG_L5TransFix();
void __cdecl DRLG_L5DirtFix();
void __cdecl DRLG_L5CornerFix();
/* data */
extern ShadowStruct SPATS[37];
extern unsigned char BSTYPES[206];
extern unsigned char L5BTYPES[206];
extern unsigned char STAIRSUP[];
extern unsigned char L5STAIRSUP[];
extern unsigned char STAIRSDOWN[];
extern unsigned char LAMPS[];
extern unsigned char PWATERIN[];
/* rdata */
extern unsigned char L5ConvTbl[16];

3416
Source/drlg_l2.cpp Normal file

File diff suppressed because it is too large Load Diff

179
Source/drlg_l2.h Normal file
View File

@ -0,0 +1,179 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//drlg_l2
extern int nSx1;
extern int nSx2; // weak
extern int nSy1;
extern int nSy2; // weak
extern int nRoomCnt;
extern char predungeon[40][40];
extern ROOMNODE RoomList[81];
extern HALLNODE *pHallList;
void __cdecl InitDungeon();
void __cdecl L2LockoutFix();
void __cdecl L2DoorFix();
void __fastcall LoadL2Dungeon(char *sFileName, int vx, int vy);
void __cdecl DRLG_L2Pass3();
void __fastcall LoadPreL2Dungeon(char *sFileName, int vx, int vy);
void __fastcall CreateL2Dungeon(int rseed, int entry);
void __cdecl DRLG_LoadL2SP();
void __cdecl DRLG_FreeL2SP();
void __fastcall DRLG_L2(int entry);
bool __fastcall DRLG_L2PlaceMiniSet(char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int ldir);
void __fastcall DRLG_L2PlaceRndSet(char *miniset, int rndper);
void __cdecl DRLG_L2Subs();
void __cdecl DRLG_L2Shadows();
void __fastcall DRLG_L2SetRoom(int rx1, int ry1);
void __cdecl L2TileFix();
bool __cdecl CreateDungeon();
void __fastcall CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, int ForceHW, int nH, int nW);
void __fastcall DefineRoom(int nX1, int nY1, int nX2, int nY2, int ForceHW);
void __fastcall AddHall(int nX1, int nY1, int nX2, int nY2, int nHd);
void __fastcall GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd);
void __fastcall ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd);
void __fastcall CreateDoorType(int nX, int nY);
void __fastcall PlaceHallExt(int nX, int nY);
void __fastcall DoPatternCheck(int i, int j);
bool __cdecl DL2_FillVoids();
bool __fastcall DL2_Cont(bool x1f, bool y1f, bool x2f, bool y2f);
int __cdecl DL2_NumNoChar();
void __fastcall DL2_DrawRoom(int x1, int y1, int x2, int y2);
void __fastcall DL2_KnockWalls(int x1, int y1, int x2, int y2);
void __cdecl DRLG_L2FloodTVal();
void __fastcall DRLG_L2FTVR(int i, int j, int x, int y, int d);
void __cdecl DRLG_L2TransFix();
void __cdecl L2DirtFix();
void __cdecl DRLG_InitL2Vals();
/* rdata */
extern int Area_Min; // weak
extern int Room_Max; // weak
extern int Room_Min; // weak
extern int Dir_Xadd[5];
extern int Dir_Yadd[5];
extern ShadowStruct SPATSL2[2];
//short word_48489A;
extern unsigned char BTYPESL2[161];
extern unsigned char BSTYPESL2[161];
extern unsigned char VARCH1[];
extern unsigned char VARCH2[];
extern unsigned char VARCH3[];
extern unsigned char VARCH4[];
extern unsigned char VARCH5[];
extern unsigned char VARCH6[];
extern unsigned char VARCH7[];
extern unsigned char VARCH8[];
extern unsigned char VARCH9[];
extern unsigned char VARCH10[];
extern unsigned char VARCH11[];
extern unsigned char VARCH12[];
extern unsigned char VARCH13[];
extern unsigned char VARCH14[];
extern unsigned char VARCH15[];
extern unsigned char VARCH16[];
extern unsigned char VARCH17[];
extern unsigned char VARCH18[];
extern unsigned char VARCH19[];
extern unsigned char VARCH20[];
extern unsigned char VARCH21[];
extern unsigned char VARCH22[];
extern unsigned char VARCH23[];
extern unsigned char VARCH24[];
extern unsigned char VARCH25[];
extern unsigned char VARCH26[];
extern unsigned char VARCH27[];
extern unsigned char VARCH28[];
extern unsigned char VARCH29[];
extern unsigned char VARCH30[];
extern unsigned char VARCH31[];
extern unsigned char VARCH32[];
extern unsigned char VARCH33[];
extern unsigned char VARCH34[];
extern unsigned char VARCH35[];
extern unsigned char VARCH36[];
extern unsigned char VARCH37[];
extern unsigned char VARCH38[];
extern unsigned char VARCH39[];
extern unsigned char VARCH40[];
extern unsigned char HARCH1[];
extern unsigned char HARCH2[];
extern unsigned char HARCH3[];
extern unsigned char HARCH4[];
extern unsigned char HARCH5[];
extern unsigned char HARCH6[];
extern unsigned char HARCH7[];
extern unsigned char HARCH8[];
extern unsigned char HARCH9[];
extern unsigned char HARCH10[];
extern unsigned char HARCH11[];
extern unsigned char HARCH12[];
extern unsigned char HARCH13[];
extern unsigned char HARCH14[];
extern unsigned char HARCH15[];
extern unsigned char HARCH16[];
extern unsigned char HARCH17[];
extern unsigned char HARCH18[];
extern unsigned char HARCH19[];
extern unsigned char HARCH20[];
extern unsigned char HARCH21[];
extern unsigned char HARCH22[];
extern unsigned char HARCH23[];
extern unsigned char HARCH24[];
extern unsigned char HARCH25[];
extern unsigned char HARCH26[];
extern unsigned char HARCH27[];
extern unsigned char HARCH28[];
extern unsigned char HARCH29[];
extern unsigned char HARCH30[];
extern unsigned char HARCH31[];
extern unsigned char HARCH32[];
extern unsigned char HARCH33[];
extern unsigned char HARCH34[];
extern unsigned char HARCH35[];
extern unsigned char HARCH36[];
extern unsigned char HARCH37[];
extern unsigned char HARCH38[];
extern unsigned char HARCH39[];
extern unsigned char HARCH40[];
extern unsigned char USTAIRS[];
extern unsigned char DSTAIRS[];
extern unsigned char WARPSTAIRS[];
extern unsigned char CRUSHCOL[];
extern unsigned char BIG1[];
extern unsigned char BIG2[];
extern unsigned char BIG3[];
extern unsigned char BIG4[];
extern unsigned char BIG5[];
extern unsigned char BIG6[];
extern unsigned char BIG7[];
extern unsigned char BIG8[];
extern unsigned char BIG9[];
extern unsigned char BIG10[];
extern unsigned char RUINS1[];
extern unsigned char RUINS2[];
extern unsigned char RUINS3[];
extern unsigned char RUINS4[];
extern unsigned char RUINS5[];
extern unsigned char RUINS6[];
extern unsigned char RUINS7[];
extern unsigned char PANCREAS1[];
extern unsigned char PANCREAS2[];
extern unsigned char CTRDOOR1[];
extern unsigned char CTRDOOR2[];
extern unsigned char CTRDOOR3[];
extern unsigned char CTRDOOR4[];
extern unsigned char CTRDOOR5[];
extern unsigned char CTRDOOR6[];
extern unsigned char CTRDOOR7[];
extern unsigned char CTRDOOR8[];
extern int Patterns[100][10];

3044
Source/drlg_l3.cpp Normal file

File diff suppressed because it is too large Load Diff

93
Source/drlg_l3.h Normal file
View File

@ -0,0 +1,93 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//drlg_l3
extern char lavapool; // weak
extern int abyssx; // weak
extern int lockoutcnt; // weak
extern char lockout[40][40];
void __cdecl AddFenceDoors();
void __cdecl FenceDoorFix();
int __cdecl DRLG_L3Anvil();
void __cdecl FixL3Warp();
void __cdecl FixL3HallofHeroes();
void __fastcall DRLG_L3LockRec(int x, int y);
bool __cdecl DRLG_L3Lockout();
void __fastcall CreateL3Dungeon(int rseed, int entry);
void __fastcall DRLG_L3(int entry);
void __cdecl InitL3Dungeon();
int __fastcall DRLG_L3FillRoom(int x1, int y1, int x2, int y2);
void __fastcall DRLG_L3CreateBlock(int x, int y, int obs, int dir);
void __fastcall DRLG_L3FloorArea(int x1, int y1, int x2, int y2);
void __cdecl DRLG_L3FillDiags();
void __cdecl DRLG_L3FillSingles();
void __cdecl DRLG_L3FillStraights();
void __cdecl DRLG_L3Edges();
int __cdecl DRLG_L3GetFloorArea();
void __cdecl DRLG_L3MakeMegas();
void __cdecl DRLG_L3River();
void __cdecl DRLG_L3Pool();
int __fastcall DRLG_L3SpawnEdge(int x, int y, int *totarea);
int __fastcall DRLG_L3Spawn(int x, int y, int *totarea);
void __cdecl DRLG_L3PoolFix();
int __fastcall DRLG_L3PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, bool setview, int ldir);
void __fastcall DRLG_L3PlaceRndSet(unsigned char *miniset, int rndper);
void __cdecl DRLG_L3Wood();
bool __fastcall WoodVertU(int i, int y);
bool __fastcall WoodVertD(int i, int y);
bool __fastcall WoodHorizL(int x, int j);
bool __fastcall WoodHorizR(int x, int j);
void __cdecl DRLG_L3Pass3();
void __fastcall LoadL3Dungeon(char *sFileName, int vx, int vy);
void __fastcall LoadPreL3Dungeon(char *sFileName, int vx, int vy);
/* data */
extern unsigned char L3ConvTbl[16];
extern unsigned char L3UP[20];
extern unsigned char L3DOWN[20];
extern unsigned char L3HOLDWARP[20];
extern unsigned char L3TITE1[34];
extern unsigned char L3TITE2[34];
extern unsigned char L3TITE3[34];
extern unsigned char L3TITE6[42];
extern unsigned char L3TITE7[42];
extern unsigned char L3TITE8[20];
extern unsigned char L3TITE9[20];
extern unsigned char L3TITE10[20];
extern unsigned char L3TITE11[20];
extern unsigned char L3TITE12[6];
extern unsigned char L3TITE13[6];
extern unsigned char L3CREV1[6];
extern unsigned char L3CREV2[6];
extern unsigned char L3CREV3[6];
extern unsigned char L3CREV4[6];
extern unsigned char L3CREV5[6];
extern unsigned char L3CREV6[6];
extern unsigned char L3CREV7[6];
extern unsigned char L3CREV8[6];
extern unsigned char L3CREV9[6];
extern unsigned char L3CREV10[6];
extern unsigned char L3CREV11[6];
extern unsigned char L3ISLE1[14];
extern unsigned char L3ISLE2[14];
extern unsigned char L3ISLE3[14];
extern unsigned char L3ISLE4[14];
extern unsigned char L3ISLE5[10];
extern unsigned char L3XTRA1[4];
extern unsigned char L3XTRA2[4];
extern unsigned char L3XTRA3[4];
extern unsigned char L3XTRA4[4];
extern unsigned char L3XTRA5[4];
extern unsigned char L3ANVIL[244];
extern unsigned char L3SpawnTbl1[15]; /* local spawntable? */
extern unsigned char L3SpawnTbl2[15]; /* local spawntable? */
extern unsigned char L3PoolSub[15]; /* local poolsub? */

3424
Source/drlg_l4.cpp Normal file

File diff suppressed because it is too large Load Diff

75
Source/drlg_l4.h Normal file
View File

@ -0,0 +1,75 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//drlg_l4
extern int diabquad1x; // weak
extern int diabquad1y; // weak
extern int diabquad3x; // idb
extern int diabquad3y; // idb
extern int diabquad2x; // idb
extern int diabquad2y; // idb
extern int diabquad4x; // idb
extern int diabquad4y; // idb
extern int hallok[20];
extern int l4holdx; // weak
extern int l4holdy; // weak
extern int SP4x1; // idb
extern int SP4x2; // weak
extern int SP4y1; // idb
extern int SP4y2; // weak
extern char L4dungeon[80][80];
extern char dung[20][20];
//int dword_52A4DC; // weak
void __cdecl DRLG_LoadL4SP();
void __cdecl DRLG_FreeL4SP();
void __fastcall DRLG_L4SetSPRoom(int rx1, int ry1);
void __cdecl L4SaveQuads();
void __fastcall DRLG_L4SetRoom(unsigned char *pSetPiece, int rx1, int ry1);
void __fastcall DRLG_LoadDiabQuads(bool preflag);
bool __fastcall IsDURWall(char d);
bool __fastcall IsDLLWall(char dd);
void __cdecl L4FixRim();
void __cdecl DRLG_L4GeneralFix();
void __fastcall CreateL4Dungeon(int rseed, int entry);
void __fastcall DRLG_L4(int entry);
void __cdecl DRLG_L4Shadows();
void __cdecl InitL4Dungeon();
void __cdecl L4makeDmt();
void __cdecl L4AddWall();
int __fastcall L4HWallOk(int i, int j);
int __fastcall L4VWallOk(int i, int j);
void __fastcall L4HorizWall(int i, int j, int dx);
void __fastcall L4VertWall(int i, int j, int dy);
void __cdecl L4tileFix();
void __cdecl DRLG_L4Subs();
void __cdecl L4makeDungeon();
void __cdecl uShape();
int __cdecl GetArea();
void __cdecl L4firstRoom();
void __fastcall L4drawRoom(int x, int y, int width, int height);
void __fastcall L4roomGen(int x, int y, int w, int h, int dir);
bool __fastcall L4checkRoom(int x, int y, int width, int height);
bool __fastcall DRLG_L4PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, int setview, int ldir);
void __cdecl DRLG_L4FloodTVal();
void __fastcall DRLG_L4FTVR(int i, int j, int x, int y, int d);
void __cdecl DRLG_L4TransFix();
void __cdecl DRLG_L4Corners();
void __cdecl DRLG_L4Pass3();
/* data */
extern unsigned char L4ConvTbl[16];
extern unsigned char L4USTAIRS[42];
extern unsigned char L4TWARP[42];
extern unsigned char L4DSTAIRS[52];
extern unsigned char L4PENTA[52];
extern unsigned char L4PENTA2[52];
extern unsigned char L4BTYPES[140];

221
Source/dthread.cpp Normal file
View File

@ -0,0 +1,221 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int dthread_cpp_init_value; // weak
static CRITICAL_SECTION sgMemCrit; // idb
unsigned int glpDThreadId; // idb
TMegaPkt *sgpInfoHead; /* may not be right struct */
char byte_52A508; // weak
HANDLE sghWorkToDoEvent; // idb
int dthread_inf = 0x7F800000; // weak
/* rdata */
static HANDLE sghThread = (HANDLE)0xFFFFFFFF; // idb
//----- (0041509D) --------------------------------------------------------
struct dthread_cpp_init_1
{
dthread_cpp_init_1()
{
dthread_cpp_init_value = dthread_inf;
}
} _dthread_cpp_init_1;
// 47A460: using guessed type int dthread_inf;
// 52A4E0: using guessed type int dthread_cpp_init_value;
//----- (004150A8) --------------------------------------------------------
struct dthread_cpp_init_2
{
dthread_cpp_init_2()
{
dthread_init_mutex();
dthread_cleanup_mutex_atexit();
}
} _dthread_cpp_init_2;
//----- (004150B2) --------------------------------------------------------
void __cdecl dthread_init_mutex()
{
InitializeCriticalSection(&sgMemCrit);
}
//----- (004150BE) --------------------------------------------------------
void __cdecl dthread_cleanup_mutex_atexit()
{
atexit(dthread_cleanup_mutex);
}
//----- (004150CA) --------------------------------------------------------
void __cdecl dthread_cleanup_mutex()
{
DeleteCriticalSection(&sgMemCrit);
}
//----- (004150D6) --------------------------------------------------------
void __fastcall dthread_remove_player(int pnum)
{
int v1; // edi
TMegaPkt *i; // eax
v1 = pnum;
EnterCriticalSection(&sgMemCrit);
for ( i = sgpInfoHead; i; i = i->pNext )
{
if ( i->dwSpaceLeft == v1 )
i->dwSpaceLeft = 4;
}
LeaveCriticalSection(&sgMemCrit);
}
//----- (00415109) --------------------------------------------------------
void __fastcall dthread_send_delta(int pnum, int cmd, void *pbSrc, int dwLen)
{
char v4; // bl
TMegaPkt *v5; // eax
TMegaPkt *v6; // esi
TMegaPkt *v7; // eax
TMegaPkt **v8; // ecx
int v9; // [esp+4h] [ebp-4h]
v4 = cmd;
v9 = pnum;
if ( gbMaxPlayers != 1 )
{
v5 = (TMegaPkt *)DiabloAllocPtr(dwLen + 20);
v6 = v5;
v5->pNext = 0;
v5->dwSpaceLeft = v9;
v5->data[0] = v4;
*(_DWORD *)&v5->data[4] = dwLen;
memcpy(&v5->data[8], pbSrc, dwLen);
EnterCriticalSection(&sgMemCrit);
v7 = sgpInfoHead;
v8 = &sgpInfoHead;
while ( v7 )
{
v8 = &v7->pNext;
v7 = v7->pNext;
}
*v8 = v6;
SetEvent(sghWorkToDoEvent);
LeaveCriticalSection(&sgMemCrit);
}
}
// 679660: using guessed type char gbMaxPlayers;
//----- (00415186) --------------------------------------------------------
void __cdecl dthread_start()
{
char *v0; // eax
char *v1; // eax
if ( gbMaxPlayers != 1 )
{
sghWorkToDoEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
if ( !sghWorkToDoEvent )
{
v0 = GetLastErr();
TermMsg("dthread:1\n%s", v0);
}
byte_52A508 = 1;
sghThread = (HANDLE)_beginthreadex(NULL, 0, dthread_handler, NULL, 0, &glpDThreadId);
if ( sghThread == (HANDLE)-1 )
{
v1 = GetLastErr();
TermMsg("dthread2:\n%s", v1);
}
}
}
// 52A508: using guessed type char byte_52A508;
// 679660: using guessed type char gbMaxPlayers;
//----- (004151F3) --------------------------------------------------------
unsigned int __stdcall dthread_handler(void *a1)
{
char *v1; // eax
TMegaPkt *v2; // esi
int v3; // ecx
unsigned int v4; // edi
while ( byte_52A508 )
{
if ( !sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, 0xFFFFFFFF) == -1 )
{
v1 = GetLastErr();
TermMsg("dthread4:\n%s", v1);
}
EnterCriticalSection(&sgMemCrit);
v2 = sgpInfoHead;
if ( sgpInfoHead )
sgpInfoHead = sgpInfoHead->pNext;
else
ResetEvent(sghWorkToDoEvent);
LeaveCriticalSection(&sgMemCrit);
if ( v2 )
{
v3 = v2->dwSpaceLeft;
if ( v3 != 4 )
multi_send_zero_packet(v3, v2->data[0], &v2->data[8], *(_DWORD *)&v2->data[4]);
v4 = 1000 * *(_DWORD *)&v2->data[4] / (unsigned int)gdwDeltaBytesSec;
if ( v4 >= 1 )
v4 = 1;
mem_free_dbg(v2);
if ( v4 )
Sleep(v4);
}
}
return 0;
}
// 52A508: using guessed type char byte_52A508;
// 679730: using guessed type int gdwDeltaBytesSec;
//----- (004152C0) --------------------------------------------------------
void __cdecl dthread_cleanup()
{
char *v0; // eax
TMegaPkt *v1; // eax
TMegaPkt *v2; // esi
if ( sghWorkToDoEvent )
{
byte_52A508 = 0;
SetEvent(sghWorkToDoEvent);
if ( sghThread != (HANDLE)-1 && glpDThreadId != GetCurrentThreadId() )
{
if ( WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1 )
{
v0 = GetLastErr();
TermMsg("dthread3:\n(%s)", v0);
}
CloseHandle(sghThread);
sghThread = (HANDLE)-1;
}
CloseHandle(sghWorkToDoEvent);
v1 = sgpInfoHead;
sghWorkToDoEvent = 0;
if ( sgpInfoHead )
{
do
{
v2 = v1->pNext;
sgpInfoHead = 0;
mem_free_dbg(v1);
v1 = v2;
sgpInfoHead = v2;
}
while ( v2 );
}
}
}
// 52A508: using guessed type char byte_52A508;

31
Source/dthread.h Normal file
View File

@ -0,0 +1,31 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//dthread
extern int dthread_cpp_init_value; // weak
extern unsigned int glpDThreadId; // idb
extern TMegaPkt *sgpInfoHead; /* may not be right struct */
extern char byte_52A508; // weak
extern HANDLE sghWorkToDoEvent; // idb
void __cdecl dthread_cpp_init_1();
void __cdecl dthread_cpp_init_2();
void __cdecl dthread_init_mutex();
void __cdecl dthread_cleanup_mutex_atexit();
void __cdecl dthread_cleanup_mutex();
void __fastcall dthread_remove_player(int pnum);
void __fastcall dthread_send_delta(int pnum, int cmd, void *pbSrc, int dwLen);
void __cdecl dthread_start();
unsigned int __stdcall dthread_handler(void *a1);
void __cdecl dthread_cleanup();
/* data */
extern int dthread_inf; // weak

320
Source/dx.cpp Normal file
View File

@ -0,0 +1,320 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
void *sgpBackBuf;
int dx_cpp_init_value; // weak
IDirectDraw *lpDDInterface;
IDirectDrawPalette *lpDDPalette; // idb
int sgdwLockCount;
Screen *gpBuffer;
IDirectDrawSurface *lpDDSBackBuf;
IDirectDrawSurface *lpDDSPrimary;
static CRITICAL_SECTION sgMemCrit;
char gbBackBuf; // weak
char gbEmulate; // weak
HMODULE ghDiabMod; // idb
int dx_inf = 0x7F800000; // weak
//----- (00415367) --------------------------------------------------------
struct dx_cpp_init_1
{
dx_cpp_init_1()
{
dx_cpp_init_value = dx_inf;
}
} _dx_cpp_init_1;
// 47A464: using guessed type int dx_inf;
// 52A514: using guessed type int dx_cpp_init_value;
//----- (00415372) --------------------------------------------------------
struct dx_cpp_init_2
{
dx_cpp_init_2()
{
dx_init_mutex();
dx_cleanup_mutex_atexit();
}
} _dx_cpp_init_2;
//----- (0041537C) --------------------------------------------------------
void __cdecl dx_init_mutex()
{
InitializeCriticalSection(&sgMemCrit);
}
//----- (00415388) --------------------------------------------------------
void __cdecl dx_cleanup_mutex_atexit()
{
atexit(dx_cleanup_mutex);
}
//----- (00415394) --------------------------------------------------------
void __cdecl dx_cleanup_mutex()
{
DeleteCriticalSection(&sgMemCrit);
}
//----- (004153A0) --------------------------------------------------------
void __fastcall dx_init(HWND hWnd)
{
HWND v1; // esi
GUID *v2; // ecx
int v3; // eax
int v4; // eax
//int v5; // ecx
int v6; // edi
int v7; // eax
int v8; // eax
HWND hWnda; // [esp+1Ch] [ebp-4h]
v1 = hWnd;
hWnda = hWnd;
SetFocus(hWnd);
ShowWindow(v1, SW_SHOWNORMAL);
v2 = NULL;
if ( gbEmulate )
v2 = (GUID *)DDCREATE_EMULATIONONLY;
v3 = dx_DirectDrawCreate(v2, &lpDDInterface, NULL);
if ( v3 )
TermDlg(104, v3, "C:\\Src\\Diablo\\Source\\dx.cpp", 149);
fullscreen = 1;
v4 = IDirectDraw_SetCooperativeLevel(lpDDInterface, v1, DDSCL_EXCLUSIVE|DDSCL_ALLOWREBOOT|DDSCL_FULLSCREEN);
if ( v4 == DDERR_EXCLUSIVEMODEALREADYSET )
{
MI_Dummy(0); // v5
}
else if ( v4 )
{
TermDlg(104, v4, "C:\\Src\\Diablo\\Source\\dx.cpp", 170);
}
if ( IDirectDraw_SetDisplayMode(lpDDInterface, 640, 480, 8) )
{
v6 = GetSystemMetrics(SM_CXSCREEN);
v7 = GetSystemMetrics(SM_CYSCREEN);
v8 = IDirectDraw_SetDisplayMode(lpDDInterface, v6, v7, 8);
if ( v8 )
TermDlg(104, v8, "C:\\Src\\Diablo\\Source\\dx.cpp", 183);
}
dx_create_primary_surface();
palette_init();
GdiSetBatchLimit(1);
dx_create_back_buffer();
SDrawManualInitialize(hWnda, lpDDInterface, lpDDSPrimary, 0, 0, lpDDSBackBuf, lpDDPalette, 0);
}
// 484364: using guessed type int fullscreen;
// 52A549: using guessed type char gbEmulate;
//----- (004154B5) --------------------------------------------------------
void __cdecl dx_create_back_buffer()
{
int v0; // eax
int v1; // eax
int v2; // eax
int v3; // eax
DDSURFACEDESC v4; // [esp+Ch] [ebp-70h]
DDSCAPS v5; // [esp+78h] [ebp-4h]
v0 = IDirectDrawSurface_GetCaps(lpDDSPrimary, &v5);
if ( v0 )
DDErrDlg(v0, 59, "C:\\Src\\Diablo\\Source\\dx.cpp");
if ( !gbBackBuf )
{
v4.dwSize = 108;
v1 = IDirectDrawSurface_Lock(lpDDSPrimary, NULL, &v4, DDLOCK_WRITEONLY|DDLOCK_WAIT, NULL);
if ( !v1 )
{
IDirectDrawSurface_Unlock(lpDDSPrimary, NULL);
sgpBackBuf = DiabloAllocPtr(0x7B000);
return;
}
if ( v1 != DDERR_CANTLOCKSURFACE )
TermDlg(104, v1, "C:\\Src\\Diablo\\Source\\dx.cpp", 81);
}
memset(&v4, 0, 0x6Cu);
v4.dwWidth = 768;
v4.lPitch = 768;
v4.dwSize = 108;
v4.dwFlags = DDSD_PIXELFORMAT|DDSD_PITCH|DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS;
v4.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY|DDSCAPS_OFFSCREENPLAIN;
v4.dwHeight = 656;
v4.ddpfPixelFormat.dwSize = 32;
v2 = IDirectDrawSurface_GetPixelFormat(lpDDSPrimary, &v4.ddpfPixelFormat);
if ( v2 )
TermDlg(104, v2, "C:\\Src\\Diablo\\Source\\dx.cpp", 94);
v3 = IDirectDraw_CreateSurface(lpDDInterface, &v4, &lpDDSBackBuf, NULL);
if ( v3 )
TermDlg(104, v3, "C:\\Src\\Diablo\\Source\\dx.cpp", 96);
}
// 52A548: using guessed type char gbBackBuf;
//----- (004155C2) --------------------------------------------------------
void __cdecl dx_create_primary_surface()
{
int v0; // eax
DDSURFACEDESC v1; // [esp+0h] [ebp-6Ch]
memset(&v1, 0, 0x6Cu);
v1.dwSize = 108;
v1.dwFlags = DDSD_CAPS;
v1.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
v0 = IDirectDraw_CreateSurface(lpDDInterface, &v1, &lpDDSPrimary, NULL);
if ( v0 )
TermDlg(104, v0, "C:\\Src\\Diablo\\Source\\dx.cpp", 109);
}
//----- (0041561A) --------------------------------------------------------
HRESULT __fastcall dx_DirectDrawCreate(GUID *guid, IDirectDraw **DD, void *unknown)
{
IDirectDraw **v3; // ebp
int v4; // eax
FARPROC v5; // ebx
int v6; // eax
GUID *v8; // [esp+10h] [ebp-4h]
v3 = DD;
v8 = guid;
if ( !ghDiabMod )
{
ghDiabMod = LoadLibraryA("ddraw.dll");
if ( !ghDiabMod )
{
v4 = GetLastError();
TermDlg(107, v4, "C:\\Src\\Diablo\\Source\\dx.cpp", 122);
}
}
v5 = GetProcAddress(ghDiabMod, "DirectDrawCreate");
if ( !v5 )
{
v6 = GetLastError();
TermDlg(107, v6, "C:\\Src\\Diablo\\Source\\dx.cpp", 127);
}
return ((int (__stdcall *)(GUID *, IDirectDraw **, void *))v5)(v8, v3, unknown);
}
//----- (0041569A) --------------------------------------------------------
void __cdecl dx_lock_mutex()
{
Screen *v0; // eax
int v1; // eax
DDSURFACEDESC v2; // [esp+0h] [ebp-6Ch]
EnterCriticalSection(&sgMemCrit);
v0 = (Screen *)sgpBackBuf;
if ( sgpBackBuf )
goto LABEL_8;
if ( lpDDSBackBuf )
{
if ( sgdwLockCount )
goto LABEL_9;
v2.dwSize = 108;
v1 = IDirectDrawSurface_Lock(lpDDSBackBuf, NULL, &v2, DDLOCK_WAIT, NULL);
if ( v1 )
DDErrDlg(v1, 235, "C:\\Src\\Diablo\\Source\\dx.cpp");
v0 = (Screen *)v2.lpSurface;
screen_buf_end += (int)v2.lpSurface;
LABEL_8:
gpBuffer = v0;
goto LABEL_9;
}
Sleep(20000);
TermMsg("lock_buf_priv");
LABEL_9:
++sgdwLockCount;
}
// 69CF0C: using guessed type int screen_buf_end;
//----- (00415725) --------------------------------------------------------
void __cdecl dx_unlock_mutex()
{
Screen *v0; // eax
int v1; // eax
if ( !sgdwLockCount )
TermMsg("draw main unlock error");
if ( !gpBuffer )
TermMsg("draw consistency error");
if ( !--sgdwLockCount )
{
v0 = gpBuffer;
gpBuffer = 0;
screen_buf_end -= (signed int)v0;
if ( !sgpBackBuf )
{
v1 = IDirectDrawSurface_Unlock(lpDDSBackBuf, NULL);
if ( v1 )
DDErrDlg(v1, 273, "C:\\Src\\Diablo\\Source\\dx.cpp");
}
}
LeaveCriticalSection(&sgMemCrit);
}
// 69CF0C: using guessed type int screen_buf_end;
//----- (004157A0) --------------------------------------------------------
void __cdecl dx_cleanup()
{
void *v0; // ecx
if ( ghMainWnd )
ShowWindow(ghMainWnd, SW_HIDE);
SDrawDestroy();
EnterCriticalSection(&sgMemCrit);
if ( sgpBackBuf )
{
v0 = sgpBackBuf;
sgpBackBuf = 0;
mem_free_dbg(v0);
}
else if ( lpDDSBackBuf )
{
IDirectDrawSurface_Release(lpDDSBackBuf);
lpDDSBackBuf = 0;
}
sgdwLockCount = 0;
gpBuffer = 0;
LeaveCriticalSection(&sgMemCrit);
if ( lpDDSPrimary )
{
IDirectDrawSurface_Release(lpDDSPrimary);
lpDDSPrimary = 0;
}
if ( lpDDPalette )
{
IDirectDrawPalette_Release(lpDDPalette);
lpDDPalette = 0;
}
if ( lpDDInterface )
{
IDirectDraw_Release(lpDDInterface);
lpDDInterface = 0;
}
}
//----- (00415848) --------------------------------------------------------
void __cdecl dx_reinit()
{
int v0; // esi
EnterCriticalSection(&sgMemCrit);
ClearCursor();
v0 = sgdwLockCount;
while ( sgdwLockCount )
dx_unlock_mutex();
dx_cleanup();
drawpanflag = 255;
dx_init(ghMainWnd);
for ( ; v0; --v0 )
dx_lock_mutex();
LeaveCriticalSection(&sgMemCrit);
}
// 52571C: using guessed type int drawpanflag;

44
Source/dx.h Normal file
View File

@ -0,0 +1,44 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//dx
extern void *sgpBackBuf;
extern int dx_cpp_init_value; // weak
extern IDirectDraw *lpDDInterface;
extern IDirectDrawPalette *lpDDPalette; // idb
extern int sgdwLockCount;
extern Screen *gpBuffer;
extern IDirectDrawSurface *lpDDSBackBuf;
extern IDirectDrawSurface *lpDDSPrimary;
extern char gbBackBuf; // weak
extern char gbEmulate; // weak
extern HMODULE ghDiabMod; // idb
void __cdecl dx_cpp_init_1();
void __cdecl dx_cpp_init_2();
void __cdecl dx_init_mutex();
void __cdecl dx_cleanup_mutex_atexit();
void __cdecl dx_cleanup_mutex();
void __fastcall dx_init(HWND hWnd);
void __cdecl dx_create_back_buffer();
void __cdecl dx_create_primary_surface();
HRESULT __fastcall dx_DirectDrawCreate(GUID *guid, IDirectDraw **DD, void *unknown);
void __cdecl j_dx_lock_mutex();
void __cdecl dx_lock_mutex();
void __cdecl j_dx_unlock_mutex();
void __cdecl dx_unlock_mutex();
void __cdecl dx_cleanup();
void __cdecl dx_reinit();
void __cdecl j_dx_reinit();
/* data */
extern int dx_inf; // weak

1444
Source/effects.cpp Normal file

File diff suppressed because it is too large Load Diff

47
Source/effects.h Normal file
View File

@ -0,0 +1,47 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//effects
extern int effects_cpp_init_value; // weak
extern int sfxdelay; // weak
extern int sfxdnum;
extern void *sfx_stream;
extern TSFX *sfx_data_cur;
void __cdecl effects_cpp_init();
bool __fastcall effect_is_playing(int nSFX);
void __cdecl sfx_stop();
void __fastcall InitMonsterSND(int monst);
void __cdecl FreeEffects();
void __fastcall PlayEffect(int i, int mode);
int __fastcall calc_snd_position(int x, int y, int *plVolume, int *plPan);
void __fastcall PlaySFX(int psfx);
void __fastcall PlaySFX_priv(TSFX *pSFX, char loc, int x, int y);
void __fastcall stream_play(TSFX *pSFX, int lVolume, int lPan);
int __fastcall RndSFX(int psfx);
void __fastcall PlaySfxLoc(int psfx, int x, int y);
void __cdecl FreeMonsterSnd();
void __cdecl sound_stop();
void __cdecl sound_update();
void __cdecl effects_cleanup_sfx();
void __cdecl stream_update();
void __fastcall priv_sound_init(int bLoadMask);
void __cdecl sound_init();
void __stdcall effects_play_sound(char *snd_file);
/* data */
extern int effects_inf; // weak
extern char monster_action_sounds[]; // idb
/* rdata */
extern TSFX sgSFX[858];

225
Source/encrypt.cpp Normal file
View File

@ -0,0 +1,225 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int encrypt_table[1280];
//----- (00415F43) --------------------------------------------------------
void __fastcall encrypt_decrypt_block(void *block, int size, int key) // DecryptMPQBlock
{
unsigned int v3; // edx
int v4; // eax
unsigned int v5; // edi
unsigned int v6; // edx
int v7; // eax
int v8; // esi
v3 = (unsigned int)size >> 2;
v4 = 0xEEEEEEEE;
if ( v3 )
{
v5 = v3;
v6 = key;
do
{
v7 = encrypt_table[(unsigned char)v6 + 1024] + v4;
*(_DWORD *)block ^= v7 + v6;
v8 = *(_DWORD *)block;
block = (char *)block + 4;
v4 = 33 * v7 + v8 + 3;
v6 = ((~v6 << 21) + 0x11111111) | (v6 >> 11);
--v5;
}
while ( v5 );
}
}
//----- (00415F8F) --------------------------------------------------------
void __fastcall encrypt_encrypt_block(void *block, int size, int key) // EncryptMPQBlock
{
unsigned int v3; // edx
int v4; // eax
unsigned int v5; // edi
unsigned int v6; // edx
int v7; // eax
int v8; // ebx
v3 = (unsigned int)size >> 2;
v4 = 0xEEEEEEEE;
if ( v3 )
{
v5 = v3;
v6 = key;
do
{
v7 = encrypt_table[(unsigned char)v6 + 1024] + v4;
v8 = *(_DWORD *)block ^ (v7 + v6);
v4 = 33 * v7 + *(_DWORD *)block + 3;
*(_DWORD *)block = v8;
block = (char *)block + 4;
v6 = ((~v6 << 21) + 0x11111111) | (v6 >> 11);
--v5;
}
while ( v5 );
}
}
//----- (00415FDF) --------------------------------------------------------
int __fastcall encrypt_hash(char *s, int type) // HashStringSlash
{
int v2; // ebp
char *v3; // ebx
signed int v4; // esi
int v5; // edi
int v6; // ST00_4
char v7; // al
v2 = type;
v3 = s;
v4 = 0x7FED7FED;
v5 = 0xEEEEEEEE;
while ( v3 && *v3 )
{
v6 = *v3++;
v7 = toupper(v6);
v4 = (v5 + v4) ^ encrypt_table[v7 + (v2 << 8)];
v5 = v7 + 33 * v5 + v4 + 3;
}
return v4;
}
//----- (0041602E) --------------------------------------------------------
void __cdecl encrypt_init_lookup_table() // InitScratchSpace
{
unsigned int v0; // eax
int *v1; // edi
unsigned int v2; // eax
int v3; // ecx
signed int v4; // [esp+Ch] [ebp-8h]
int *v5; // [esp+10h] [ebp-4h]
v0 = 0x100001;
v5 = encrypt_table;
do
{
v1 = v5;
v4 = 5;
do
{
v2 = (125 * v0 + 3) % 0x2AAAAB;
v3 = (unsigned short)v2 << 16;
v0 = (125 * v2 + 3) % 0x2AAAAB;
*v1 = (unsigned short)v0 | v3;
v1 += 256;
--v4;
}
while ( v4 );
++v5;
}
while ( (signed int)v5 < (signed int)&encrypt_table[256] );
}
//----- (0041609D) --------------------------------------------------------
int __fastcall encrypt_compress(void *buf, int size) // MPQCompress_PKWare
{
unsigned char *v2; // ebx
unsigned char *v3; // esi
int v4; // ecx
unsigned char *v5; // edi
TDataInfo param; // [esp+Ch] [ebp-20h]
unsigned int type; // [esp+20h] [ebp-Ch]
unsigned int dsize; // [esp+24h] [ebp-8h]
char *ptr; // [esp+28h] [ebp-4h]
v2 = (unsigned char *)buf;
v3 = (unsigned char *)size;
ptr = (char *)DiabloAllocPtr(CMP_BUFFER_SIZE); // 36312
v4 = 2 * (_DWORD)v3;
if ( (unsigned int)(2 * (_DWORD)v3) < 0x2000 )
v4 = 0x2000;
v5 = (unsigned char *)DiabloAllocPtr(v4);
param.pbInBuffEnd = 0;
param.pbOutBuffEnd = 0;
type = 0;
param.pbInBuff = v2;
param.pbOutBuff = v5;
param.pbSize = v3;
dsize = 4096;
implode(
encrypt_pkware_read,
encrypt_pkware_write,
ptr,
&param,
&type,
&dsize);
if ( param.pbOutBuffEnd < v3 )
{
memcpy(v2, v5, (size_t)param.pbOutBuffEnd);
v3 = param.pbOutBuffEnd;
}
mem_free_dbg(ptr);
mem_free_dbg(v5);
return (int)v3;
}
//----- (00416133) --------------------------------------------------------
unsigned int __cdecl encrypt_pkware_read(char *buf, unsigned int *size, void *param) // ReadPKWare
{
TDataInfo * pInfo = (TDataInfo *)param;
int v3; // edi
unsigned char *v4; // ecx
v3 = *size;
v4 = pInfo->pbInBuffEnd;
if ( *size >= (unsigned int)(pInfo->pbSize - v4) )
v3 = pInfo->pbSize - v4;
memcpy(buf, &v4[(unsigned int)pInfo->pbInBuff], v3);
pInfo->pbInBuffEnd += v3;
return v3;
}
//----- (00416167) --------------------------------------------------------
void __cdecl encrypt_pkware_write(char *buf, unsigned int *size, void *param) // WritePKWare
{
TDataInfo * pInfo = (TDataInfo *)param;
memcpy(&pInfo->pbOutBuffEnd[(unsigned int)pInfo->pbOutBuff], buf, *size);
pInfo->pbOutBuffEnd += *size;
}
//----- (0041618E) --------------------------------------------------------
void __fastcall encrypt_decompress(void *param, int recv_size, int dwMaxBytes) // MPQDecompress_PKWare
{
unsigned char *v3; // edi
unsigned char *v4; // ebx
unsigned char *v5; // esi
TDataInfo info; // [esp+Ch] [ebp-18h]
char *ptr; // [esp+20h] [ebp-4h]
v3 = (unsigned char *)param;
v4 = (unsigned char *)recv_size;
ptr = (char *)DiabloAllocPtr(CMP_BUFFER_SIZE); // 36312
v5 = (unsigned char *)DiabloAllocPtr(dwMaxBytes);
info.pbInBuffEnd = 0;
info.pbOutBuffEnd = 0;
info.pbInBuff = v3;
info.pbOutBuff = v5;
info.pbSize = v4;
explode(
encrypt_pkware_read,
encrypt_pkware_write,
ptr,
&info);
memcpy(v3, v5, (size_t)info.pbOutBuffEnd);
mem_free_dbg(ptr);
mem_free_dbg(v5);
}

23
Source/encrypt.h Normal file
View File

@ -0,0 +1,23 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//encrypt
extern int encrypt_table[1280];
//int encrypt_52B564[257];
void __fastcall encrypt_decrypt_block(void *block, int size, int key);
void __fastcall encrypt_encrypt_block(void *block, int size, int key);
int __fastcall encrypt_hash(char *s, int type);
void __cdecl encrypt_init_lookup_table();
int __fastcall encrypt_compress(void *buf, int size);
unsigned int __cdecl encrypt_pkware_read(char *buf, unsigned int *size, void *param);
void __cdecl encrypt_pkware_write(char *buf, unsigned int *size, void *param);
void __fastcall encrypt_decompress(void *param, int recv_size, int dwMaxBytes);

3019
Source/engine.cpp Normal file

File diff suppressed because it is too large Load Diff

84
Source/engine.h Normal file
View File

@ -0,0 +1,84 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//offset 0
//pCelBuff->pFrameTable[0]
//engine
extern int engine_cpp_init_value; // weak
extern char byte_52B96C; // automap pixel color 8-bit (palette entry)
extern int dword_52B970; // bool flip - if y < x
extern int orgseed; // weak
extern int sgnWidth;
extern int sglGameSeed; // weak
extern int SeedCount; // weak
extern int dword_52B99C; // bool valid - if x/y are in bounds
void __cdecl engine_cpp_init_1();
void __fastcall CelDrawDatOnly(char *pDecodeTo, char *pRLEBytes, int dwRLESize, int dwRLEWdt);
void __fastcall CelDecodeOnly(int screen_x, int screen_y, void *pCelBuff, int frame, int frame_width);
void __fastcall CelDecDatOnly(char *pBuff, char *pCelBuff, int frame, int frame_width);
void __fastcall CelDrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction);
void __fastcall CelDecodeHdrOnly(char *pBuff, char *pCelBuff, int frame, int frame_width, int always_0, int direction);
void __fastcall CelDecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall CelDecDatLightEntry(int a1, char *a2, char *a3, char *v6);
void __fastcall CelDecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall CelDecodeLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width);
void __fastcall CelDecodeHdrLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction);
void __fastcall CelDecodeHdrLightTrans(char *pBuff, char *pCelBuff, int frame, int frame_width, int always_0, int direction);
void __fastcall CelDrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1);
void __fastcall Cel2DecDatOnly(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall Cel2DrawHdrOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction);
void __fastcall Cel2DecodeHdrOnly(char *pBuff, char *pCelBuff, int frame, int frame_width, int a5, int direction);
void __fastcall Cel2DecDatLightOnly(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall Cel2DecDatLightEntry(int a1, int a2);
void __fastcall Cel2DecDatLightTrans(char *pDecodeTo, char *pRLEBytes, int frame_content_size, int frame_width);
void __fastcall Cel2DecodeHdrLight(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction);
void __fastcall Cel2DecodeLightTrans(char *dst_buf, char *pCelBuff, int frame, int frame_width, int a5, int direction);
void __fastcall Cel2DrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1);
void __fastcall CelDecodeRect(char *pBuff, int always_0, int dst_height, int dst_width, char *pCelBuff, int frame, int frame_width);
void __fastcall CelDecodeClr(char colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction);
void __fastcall CelDrawHdrClrHL(char colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction);
void __fastcall ENG_set_pixel(int screen_x, int screen_y, char pixel);
void __fastcall engine_draw_pixel(int x, int y);
void __fastcall engine_draw_automap_pixels(int x1, int y1, int x2, int y2, char a5);
int __fastcall GetDirection(int x1, int y1, int x2, int y2);
void __fastcall SetRndSeed(int s);
int __cdecl GetRndSeed();
int __fastcall random(int idx, int v);
void __cdecl engine_cpp_init_2();
void __cdecl mem_init_mutex();
void __cdecl mem_atexit_mutex();
void __cdecl mem_free_mutex();
void *__fastcall DiabloAllocPtr(int dwBytes);
void __fastcall mem_free_dbg(void *ptr);
unsigned char *__fastcall LoadFileInMem(char *pszName, int *pdwFileLen);
void __fastcall LoadFileWithMem(char *pszName, void *buf);
void __fastcall Cl2ApplyTrans(char *p, char *ttbl, int last_frame);
void __fastcall Cl2DecodeFrm1(int x, int y, char *pCelBuff, int nCel, int width, int dir1, int dir2);
void __fastcall Cl2DecDatFrm1(char *buffer, char *frame_content, int a3, int width);
void __fastcall Cl2DecodeFrm2(char colour, int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a7, int a8);
void __fastcall Cl2DecDatFrm2(char *buffer, char *a2, int a3, int a4, char a5);
void __fastcall Cl2DecodeFrm3(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7, char a8);
void __fastcall Cl2DecDatLightTbl1(char *a1, char *a2, int a3, int a4, char *unused_lindex);
void __fastcall Cl2DecodeLightTbl(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7);
void __fastcall Cl2DecodeFrm4(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7);
void __fastcall Cl2DecDatFrm4(char *buffer, char *a2, int a3, int frame_width);
void __fastcall Cl2DecodeClrHL(char colour, int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a7, int a8);
void __fastcall Cl2DecDatClrHL(char *dst_buf, char *frame_content, int a3, int frame_width, char colour);
void __fastcall Cl2DecodeFrm5(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7, char a8);
void __fastcall Cl2DecDatLightTbl2(char *dst_buf, char *a2, int a3, int frame_width, char *a5);
void __fastcall Cl2DecodeFrm6(int screen_x, int screen_y, char *pCelBuff, int nCel, int frame_width, int a6, int a7);
void __fastcall PlayInGameMovie(char *pszMovie);
/* data */
extern int engine_inf; // weak

227
Source/error.cpp Normal file
View File

@ -0,0 +1,227 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
char msgtable[80];
char msgdelay; // weak
char msgflag; // weak
char msgcnt; // weak
char *MsgStrings[44] =
{
&empty_string,
"No automap available in town",
"No multiplayer functions in demo",
"Direct Sound Creation Failed",
"Not available in shareware version",
"Not enough space to save",
"No Pause in town",
"Copying to a hard disk is recommended",
"Multiplayer sync problem",
"No pause in multiplayer",
"Loading...",
"Saving...",
"Some are weakened as one grows strong",
"New strength is forged through destruction",
"Those who defend seldom attack",
"The sword of justice is swift and sharp",
"While the spirit is vigilant the body thrives",
"The powers of mana refocused renews",
"Time cannot diminish the power of steel",
"Magic is not always what it seems to be",
"What once was opened now is closed",
"Intensity comes at the cost of wisdom",
"Arcane power brings destruction",
"That which cannot be held cannot be harmed",
"Crimson and Azure become as the sun",
"Knowledge and wisdom at the cost of self",
"Drink and be refreshed",
"Wherever you go, there you are",
"Energy comes at the cost of wisdom",
"Riches abound when least expected",
"Where avarice fails, patience gains reward",
"Blessed by a benevolent companion!",
"The hands of men may be guided by fate",
"Strength is bolstered by heavenly faith",
"The essence of life flows from within",
"The way is made clear when viewed from above",
"Salvation comes at the cost of wisdom",
"Mysteries are revealed in the light of reason",
"Those who are last may yet be first",
"Generosity brings its own rewards",
"You must be at least level 8 to use this.",
"You must be at least level 13 to use this.",
"You must be at least level 17 to use this.",
"Arcane knowledge gained!"
};
//----- (0041804E) --------------------------------------------------------
void __fastcall InitDiabloMsg(char e)
{
int i; // edx
bool v2; // sf
unsigned char v3; // of
i = 0;
if ( msgcnt <= 0 )
{
LABEL_4:
v3 = __OFSUB__(msgcnt, 80);
v2 = (char)(msgcnt - 80) < 0;
msgtable[msgcnt] = e;
if ( v2 ^ v3 )
++msgcnt;
msgdelay = 70;
msgflag = msgtable[0];
}
else
{
while ( msgtable[i] != e )
{
if ( ++i >= msgcnt )
goto LABEL_4;
}
}
}
// 52B9F0: using guessed type char msgdelay;
// 52B9F1: using guessed type char msgflag;
// 52B9F2: using guessed type char msgcnt;
//----- (0041808F) --------------------------------------------------------
void __cdecl ClrDiabloMsg()
{
msgflag = 0;
msgcnt = 0;
memset(msgtable, 0, sizeof(msgtable));
}
// 52B9F1: using guessed type char msgflag;
// 52B9F2: using guessed type char msgcnt;
//----- (004180AA) --------------------------------------------------------
void __cdecl DrawDiabloMsg()
{
int v0; // esi
signed int v1; // edi
char *v2; // edi
signed int v3; // edx
signed int v4; // ecx
int v5; // edi
signed int v6; // ecx
_BYTE *v7; // edi
int v8; // edi
signed int v9; // ebx
signed int v10; // eax
signed int v11; // ecx
int v12; // esi
signed int v13; // esi
unsigned char v14; // bl
bool v15; // zf
signed int v16; // [esp+Ch] [ebp-8h]
signed int v17; // [esp+Ch] [ebp-8h]
signed int screen_x; // [esp+10h] [ebp-4h]
CelDecodeOnly(165, 318, pSTextSlidCels, 1, 12);
CelDecodeOnly(591, 318, pSTextSlidCels, 4, 12);
CelDecodeOnly(165, 366, pSTextSlidCels, 2, 12);
CelDecodeOnly(591, 366, pSTextSlidCels, 3, 12);
screen_x = 173;
v16 = 35;
do
{
CelDecodeOnly(screen_x, 318, pSTextSlidCels, 5, 12);
CelDecodeOnly(screen_x, 366, pSTextSlidCels, 7, 12);
screen_x += 12;
--v16;
}
while ( v16 );
v0 = 330;
v1 = 3;
do
{
CelDecodeOnly(165, v0, pSTextSlidCels, 6, 12);
CelDecodeOnly(591, v0, pSTextSlidCels, 8, 12);
v0 += 12;
--v1;
}
while ( v1 );
v2 = &gpBuffer->row[203].pixels[104];
v3 = 27;
do
{
v4 = 216;
do
{
*v2 = 0;
v2 += 2;
--v4;
}
while ( v4 );
v5 = (int)(v2 - 1200);
v6 = 216;
do
{
v7 = (_BYTE *)(v5 + 1);
*v7 = 0;
v5 = (int)(v7 + 1);
--v6;
}
while ( v6 );
v2 = (char *)(v5 - 1200);
--v3;
}
while ( v3 );
strcpy(tempstr, MsgStrings[msgflag]);
v8 = screen_y_times_768[342] + 165;
v9 = strlen(tempstr);
v10 = 0;
v11 = 0;
v17 = v9;
if ( v9 <= 0 )
goto LABEL_27;
do
{
v12 = (unsigned char)tempstr[v11++];
v10 += fontkern[fontframe[fontidx[v12]]] + 1;
}
while ( v11 < v9 );
if ( v10 < 442 )
LABEL_27:
v8 += (442 - v10) >> 1;
v13 = 0;
if ( v9 > 0 )
{
do
{
v14 = fontframe[fontidx[(unsigned char)tempstr[v13]]];
if ( v14 )
CPrintString(v8, v14, 3);
++v13;
v8 += fontkern[v14] + 1;
}
while ( v13 < v17 );
}
v15 = msgdelay == 0;
if ( msgdelay > 0 )
v15 = --msgdelay == 0;
if ( v15 )
{
v15 = msgcnt-- == 1;
msgdelay = 70;
if ( v15 )
msgflag = 0;
else
msgflag = msgtable[msgcnt];
}
}
// 52B9F0: using guessed type char msgdelay;
// 52B9F1: using guessed type char msgflag;
// 52B9F2: using guessed type char msgcnt;

23
Source/error.h Normal file
View File

@ -0,0 +1,23 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//error
extern char msgtable[80];
extern char msgdelay; // weak
extern char msgflag; // weak
extern char msgcnt; // weak
void __fastcall InitDiabloMsg(char e);
void __cdecl ClrDiabloMsg();
void __cdecl DrawDiabloMsg();
/* data */
extern char *MsgStrings[44];

384
Source/fault.cpp Normal file
View File

@ -0,0 +1,384 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter; // idb
//----- (004182AD) --------------------------------------------------------
struct exception_cpp_init
{
exception_cpp_init()
{
exception_install_filter();
j_exception_init_filter();
}
} _exception_cpp_init;
//----- (004182B7) --------------------------------------------------------
void __cdecl exception_install_filter()
{
exception_set_filter();
}
//----- (004182C1) --------------------------------------------------------
void __cdecl j_exception_init_filter()
{
atexit(exception_init_filter);
}
//----- (004182CD) --------------------------------------------------------
void __cdecl exception_init_filter()
{
exception_set_filter_ptr();
}
//----- (004182D7) --------------------------------------------------------
LONG __stdcall TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
{
PEXCEPTION_RECORD v1; // esi
char *v2; // eax
PCONTEXT v3; // esi
LONG result; // eax
CHAR v5[260]; // [esp+Ch] [ebp-210h]
char String1[260]; // [esp+110h] [ebp-10Ch]
int a5; // [esp+214h] [ebp-8h]
int a4; // [esp+218h] [ebp-4h]
log_dump_computer_info();
v1 = ExceptionInfo->ExceptionRecord;
v2 = exception_get_error_type(ExceptionInfo->ExceptionRecord->ExceptionCode, v5, 0x104u);
log_printf("Exception code: %08X %s\r\n", v1->ExceptionCode, v2);
exception_unknown_module(v1->ExceptionAddress, String1, 260, (int)&a4, (int)&a5);
log_printf("Fault address:\t%08X %02X:%08X %s\r\n", v1->ExceptionAddress, a4, a5, String1);
v3 = ExceptionInfo->ContextRecord;
log_printf("\r\nRegisters:\r\n");
log_printf(
"EAX:%08X\r\nEBX:%08X\r\nECX:%08X\r\nEDX:%08X\r\nESI:%08X\r\nEDI:%08X\r\n",
v3->Eax,
v3->Ebx,
v3->Ecx,
v3->Edx,
v3->Esi,
v3->Edi);
log_printf("CS:EIP:%04X:%08X\r\n", v3->SegCs, v3->Eip);
log_printf("SS:ESP:%04X:%08X EBP:%08X\r\n", v3->SegSs, v3->Esp, v3->Ebp);
log_printf("DS:%04X ES:%04X FS:%04X GS:%04X\r\n", v3->SegDs, v3->SegEs, v3->SegFs, v3->SegGs);
log_printf("Flags:%08X\r\n", v3->EFlags);
exception_call_stack((void *)v3->Eip, (LPVOID)v3->Ebp);
log_printf("Stack bytes:\r\n");
exception_hex_format((char *)v3->Esp, 0);
log_printf("Code bytes:\r\n");
exception_hex_format((char *)v3->Eip, 16);
log_printf("\r\n");
log_flush(1);
if ( lpTopLevelExceptionFilter )
result = lpTopLevelExceptionFilter(ExceptionInfo);
else
result = 0;
return result;
}
//----- (00418455) --------------------------------------------------------
void __fastcall exception_hex_format(char *a1, char a2)
{
unsigned int v2; // ebp
char *v3; // edi
UINT_PTR v4; // ebx
unsigned int v5; // esi
char *v6; // eax
int v7; // ST04_4
UINT_PTR v8; // esi
unsigned char v9; // al
v2 = a2;
v3 = a1;
if ( a2 )
{
do
{
v4 = 16;
if ( v2 < 0x10 )
v4 = v2;
if ( IsBadReadPtr(v3, v4) )
break;
log_printf("0x%08x: ");
v5 = 0;
do
{
v6 = "%02x ";
if ( v5 >= v4 )
v6 = " ";
v7 = (unsigned char)v3[v5];
log_printf(v6);
if ( (v5 & 3) == 3 )
log_printf(" ");
++v5;
}
while ( v5 < 0x10 );
v8 = 0;
if ( v4 )
{
do
{
if ( isprint((unsigned char)v3[v8]) )
v9 = v3[v8];
else
v9 = 46;
log_printf("%c", v9);
++v8;
}
while ( v8 < v4 );
}
log_printf("\r\n");
v3 += v4;
v2 -= v4;
}
while ( v2 );
}
log_printf("\r\n");
}
//----- (00418518) --------------------------------------------------------
void __fastcall exception_unknown_module(LPCVOID lpAddress, LPSTR lpString1, int iMaxLength, int a4, int a5)
{
int v6; // eax
char *v7; // eax
unsigned int v8; // edi
unsigned int v9; // esi
char *v10; // eax
int v11; // edx
unsigned int v12; // ecx
struct _MEMORY_BASIC_INFORMATION Buffer; // [esp+Ch] [ebp-24h]
LPSTR lpFilename; // [esp+28h] [ebp-8h]
HMODULE hModule; // [esp+2Ch] [ebp-4h]
unsigned int iMaxLengtha; // [esp+38h] [ebp+8h]
lpFilename = lpString1;
lstrcpynA(lpString1, "*unknown*", iMaxLength);
*(_DWORD *)a4 = 0;
*(_DWORD *)a5 = 0;
if ( VirtualQuery(lpAddress, &Buffer, 0x1Cu) )
{
hModule = (HMODULE)Buffer.AllocationBase;
if ( !Buffer.AllocationBase )
hModule = GetModuleHandleA(0);
if ( GetModuleFileNameA(hModule, lpFilename, iMaxLength) )
{
if ( hModule )
{
if ( *(_WORD *)hModule == 'ZM' )
{
v6 = *((_DWORD *)hModule + 15);
if ( v6 )
{
v7 = (char *)hModule + v6;
if ( *(_DWORD *)v7 == 'EP' )
{
v8 = *((unsigned __int16 *)v7 + 3);
iMaxLengtha = 0;
v9 = (_BYTE *)lpAddress - (_BYTE *)hModule;
if ( *((_WORD *)v7 + 3) )
{
v10 = &v7[*((unsigned __int16 *)v7 + 10) + 40];
while ( 1 )
{
v11 = *(_DWORD *)v10;
v12 = *((_DWORD *)v10 - 1);
if ( *(_DWORD *)v10 <= *((_DWORD *)v10 - 2) )
v11 = *((_DWORD *)v10 - 2);
if ( v9 >= v12 && v9 <= v12 + v11 )
break;
++iMaxLengtha;
v10 += 40;
if ( iMaxLengtha >= v8 )
return;
}
*(_DWORD *)a4 = iMaxLengtha + 1;
*(_DWORD *)a5 = v9 - v12;
}
}
}
}
}
}
else
{
lstrcpynA(lpFilename, "*unknown*", iMaxLength);
}
}
}
//----- (004185FF) --------------------------------------------------------
void __fastcall exception_call_stack(void *a1, LPVOID lp)
{
_DWORD *v2; // ebx
void *v3; // edi
_DWORD *v4; // eax
char String1[260]; // [esp+Ch] [ebp-10Ch]
int a5; // [esp+110h] [ebp-8h]
int a4; // [esp+114h] [ebp-4h]
v2 = (unsigned int *)lp;
v3 = a1;
log_printf("Call stack:\r\nAddress Frame Logical addr Module\r\n");
do
{
exception_unknown_module(v3, String1, 260, (int)&a4, (int)&a5);
log_printf("%08X %08X %04X:%08X %s\r\n", v3, v2, a4, a5, String1);
if ( IsBadWritePtr(v2, 8u) )
break;
v3 = (void *)v2[1];
v4 = v2;
v2 = (_DWORD *)*v2;
if ( (unsigned char)v2 & 3 )
break;
}
while ( v2 > v4 && !IsBadWritePtr(v2, 8u) );
log_printf("\r\n");
}
//----- (00418688) --------------------------------------------------------
char *__fastcall exception_get_error_type(DWORD dwMessageId, LPSTR lpString1, DWORD nSize)
{
CHAR *v3; // esi
const CHAR *v4; // eax
CHAR *v5; // ST10_4
DWORD v6; // ST08_4
HMODULE v7; // eax
v3 = lpString1;
if ( dwMessageId > EXCEPTION_FLT_DENORMAL_OPERAND )
{
if ( dwMessageId <= EXCEPTION_STACK_OVERFLOW )
{
if ( dwMessageId == EXCEPTION_STACK_OVERFLOW )
{
v4 = "STACK_OVERFLOW";
goto LABEL_42;
}
switch ( dwMessageId )
{
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
v4 = "FLT_DIVIDE_BY_ZERO";
goto LABEL_42;
case EXCEPTION_FLT_INEXACT_RESULT:
v4 = "FLT_INEXACT_RESULT";
goto LABEL_42;
case EXCEPTION_FLT_INVALID_OPERATION:
v4 = "FLT_INVALID_OPERATION";
goto LABEL_42;
case EXCEPTION_FLT_OVERFLOW:
v4 = "FLT_OVERFLOW";
goto LABEL_42;
case EXCEPTION_FLT_STACK_CHECK:
v4 = "FLT_STACK_CHECK";
goto LABEL_42;
case EXCEPTION_FLT_UNDERFLOW:
v4 = "FLT_UNDERFLOW";
goto LABEL_42;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
v4 = "INT_DIVIDE_BY_ZERO";
goto LABEL_42;
case EXCEPTION_INT_OVERFLOW:
v4 = "INT_OVERFLOW";
goto LABEL_42;
case EXCEPTION_PRIV_INSTRUCTION:
v4 = "PRIV_INSTRUCTION";
goto LABEL_42;
default:
break;
}
}
}
else
{
if ( dwMessageId == EXCEPTION_FLT_DENORMAL_OPERAND )
{
v4 = "FLT_DENORMAL_OPERAND";
goto LABEL_42;
}
if ( dwMessageId > EXCEPTION_IN_PAGE_ERROR )
{
switch ( dwMessageId )
{
case EXCEPTION_INVALID_HANDLE:
v4 = "INVALID_HANDLE";
goto LABEL_42;
case EXCEPTION_ILLEGAL_INSTRUCTION:
v4 = "ILLEGAL_INSTRUCTION";
goto LABEL_42;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
v4 = "NONCONTINUABLE_EXCEPTION";
goto LABEL_42;
case EXCEPTION_INVALID_DISPOSITION:
v4 = "INVALID_DISPOSITION";
goto LABEL_42;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
v4 = "ARRAY_BOUNDS_EXCEEDED";
goto LABEL_42;
}
}
else
{
switch ( dwMessageId )
{
case EXCEPTION_IN_PAGE_ERROR:
v4 = "IN_PAGE_ERROR";
goto LABEL_42;
case EXCEPTION_GUARD_PAGE:
v4 = "GUARD_PAGE";
goto LABEL_42;
case EXCEPTION_DATATYPE_MISALIGNMENT:
v4 = "DATATYPE_MISALIGNMENT";
goto LABEL_42;
case EXCEPTION_BREAKPOINT:
v4 = "BREAKPOINT";
goto LABEL_42;
case EXCEPTION_SINGLE_STEP:
v4 = "SINGLE_STEP";
goto LABEL_42;
case EXCEPTION_ACCESS_VIOLATION:
v4 = "ACCESS_VIOLATION";
LABEL_42:
lstrcpynA(v3, v4, nSize);
return v3;
}
}
}
v5 = lpString1;
v6 = dwMessageId;
v7 = GetModuleHandleA("NTDLL.DLL");
if ( !FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE|FORMAT_MESSAGE_IGNORE_INSERTS, v7, v6, 0, v5, nSize, NULL) )
{
v4 = "*unknown*";
goto LABEL_42;
}
return v3;
}
//----- (0041883C) --------------------------------------------------------
void __fastcall exception_set_filter()
{
lpTopLevelExceptionFilter = SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)TopLevelExceptionFilter);
}
//----- (00418853) --------------------------------------------------------
LPTOP_LEVEL_EXCEPTION_FILTER __cdecl exception_set_filter_ptr()
{
return SetUnhandledExceptionFilter(lpTopLevelExceptionFilter);
}
//----- (00418860) --------------------------------------------------------
LPTOP_LEVEL_EXCEPTION_FILTER __cdecl exception_get_filter()
{
return lpTopLevelExceptionFilter;
}

27
Source/fault.h Normal file
View File

@ -0,0 +1,27 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//fault
//int dword_52B9F4;
extern LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter; // idb
void __cdecl exception_cpp_init();
void __cdecl exception_install_filter();
void __cdecl j_exception_init_filter();
void __cdecl exception_init_filter();
LONG __stdcall TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo);
void __fastcall exception_hex_format(char *a1, char a2);
void __fastcall exception_unknown_module(LPCVOID lpAddress, LPSTR lpString1, int iMaxLength, int a4, int a5);
void __fastcall exception_call_stack(void *a1, LPVOID lp);
char *__fastcall exception_get_error_type(DWORD dwMessageId, LPSTR lpString1, DWORD nSize);
void __fastcall exception_set_filter();
LPTOP_LEVEL_EXCEPTION_FILTER __cdecl exception_set_filter_ptr();
LPTOP_LEVEL_EXCEPTION_FILTER __cdecl exception_get_filter();

358
Source/gamemenu.cpp Normal file
View File

@ -0,0 +1,358 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
TMenuItem sgSingleMenu[6] =
{
{ 0x80000000, "Save Game", &gamemenu_save_game },
{ 0x80000000, "Options", &gamemenu_options },
{ 0x80000000, "New Game", &gamemenu_new_game },
{ 0x80000000, "Load Game", &gamemenu_load_game },
{ 0x80000000, "Quit Diablo", &gamemenu_quit_game },
{ 0x80000000, NULL, NULL }
};
TMenuItem sgMultiMenu[5] =
{
{ 0x80000000, "Options", &gamemenu_options },
{ 0x80000000, "New Game", &gamemenu_new_game },
{ 0x80000000, "Restart In Town", &gamemenu_restart_town },
{ 0x80000000, "Quit Diablo", &gamemenu_quit_game },
{ 0x80000000, NULL, NULL }
};
TMenuItem sgOptionMenu[6] =
{
{ 0xC0000000, NULL, (void (__cdecl *)(void))&gamemenu_music_volume },
{ 0xC0000000, NULL, (void (__cdecl *)(void))&gamemenu_sound_volume },
{ 0xC0000000, "Gamma", (void (__cdecl *)(void))&gamemenu_gamma },
{ 0x80000000, NULL, &gamemenu_color_cycling },
{ 0x80000000, "Previous Menu", &gamemenu_previous },
{ 0x80000000, NULL, NULL }
};
char *music_toggle_names[] = { "Music", "Music Disabled" };
char *sound_toggle_names[] = { "Sound", "Sound Disabled" };
char *color_cycling_toggle_names[] = { "Color Cycling Off", "Color Cycling On" };
//----- (00418866) --------------------------------------------------------
void __cdecl gamemenu_previous()
{
void (__cdecl *v0)(); // edx
TMenuItem *v1; // ecx
if ( gbMaxPlayers == 1 )
{
v0 = gamemenu_enable_single;
v1 = sgSingleMenu;
}
else
{
v0 = gamemenu_enable_multi;
v1 = sgMultiMenu;
}
gmenu_call_proc(v1, v0);
PressEscKey();
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0041888F) --------------------------------------------------------
void __cdecl gamemenu_enable_single()
{
bool v0; // dl
gmenu_enable(&sgSingleMenu[3], gbValidSaveFile);
v0 = 0;
if ( plr[myplr]._pmode != PM_DEATH && !deathflag )
v0 = 1;
gmenu_enable(sgSingleMenu, v0);
}
//----- (004188C8) --------------------------------------------------------
void __cdecl gamemenu_enable_multi()
{
gmenu_enable(&sgMultiMenu[2], deathflag);
}
//----- (004188D8) --------------------------------------------------------
void __cdecl gamemenu_off()
{
gmenu_call_proc(0, 0);
}
//----- (004188E1) --------------------------------------------------------
void __cdecl gamemenu_handle_previous()
{
if ( gmenu_exception() )
gamemenu_off();
else
gamemenu_previous();
}
//----- (004188F9) --------------------------------------------------------
void __cdecl gamemenu_new_game()
{
int i; // eax
for(i = 0; i < 4; i++)
{
plr[i]._pmode = PM_QUIT;
plr[i]._pInvincible = 1;
}
deathflag = 0;
drawpanflag = 255;
scrollrt_draw_game_screen(1);
gbRunGame = 0;
gamemenu_off();
}
// 525650: using guessed type int gbRunGame;
// 52571C: using guessed type int drawpanflag;
//----- (0041893B) --------------------------------------------------------
void __cdecl gamemenu_quit_game()
{
gamemenu_new_game();
gbRunGameResult = 0;
}
// 525698: using guessed type int gbRunGameResult;
//----- (00418948) --------------------------------------------------------
void __cdecl gamemenu_load_game()
{
LRESULT (__stdcall *saveProc)(HWND, UINT, WPARAM, LPARAM); // edi
saveProc = SetWindowProc(DisableInputWndProc);
gamemenu_off();
SetCursor(0);
InitDiabloMsg(10);
drawpanflag = 255;
DrawAndBlit();
LoadGame(0);
ClrDiabloMsg();
PaletteFadeOut(8);
deathflag = 0;
drawpanflag = 255;
DrawAndBlit();
PaletteFadeIn(8);
SetCursor(CURSOR_HAND);
interface_msg_pump();
SetWindowProc(saveProc);
}
// 52571C: using guessed type int drawpanflag;
//----- (004189BE) --------------------------------------------------------
void __cdecl gamemenu_save_game()
{
LRESULT (__stdcall *saveProc)(HWND, UINT, WPARAM, LPARAM); // edi
if ( pcurs == CURSOR_HAND )
{
if ( plr[myplr]._pmode == PM_DEATH || deathflag )
{
gamemenu_off();
}
else
{
saveProc = SetWindowProc(DisableInputWndProc);
SetCursor(0);
gamemenu_off();
InitDiabloMsg(11);
drawpanflag = 255;
DrawAndBlit();
SaveGame();
ClrDiabloMsg();
drawpanflag = 255;
SetCursor(CURSOR_HAND);
interface_msg_pump();
SetWindowProc(saveProc);
}
}
}
// 52571C: using guessed type int drawpanflag;
//----- (00418A42) --------------------------------------------------------
void __cdecl gamemenu_restart_town()
{
NetSendCmd(1u, CMD_RETOWN);
}
//----- (00418A4C) --------------------------------------------------------
void __cdecl gamemenu_options()
{
gamemenu_get_music();
gamemenu_get_sound();
gamemenu_get_gamma();
gamemenu_get_color_cycling();
gmenu_call_proc(sgOptionMenu, 0);
}
//----- (00418A6C) --------------------------------------------------------
void __cdecl gamemenu_get_music()
{
gamemenu_sound_music_toggle(music_toggle_names, sgOptionMenu, sound_get_or_set_music_volume(1));
}
//----- (00418A85) --------------------------------------------------------
void __fastcall gamemenu_sound_music_toggle(char **names, TMenuItem *menu_item, int gamma)
{
if ( gbSndInited )
{
menu_item->dwFlags |= 0xC0000000;
menu_item->pszStr = *names;
gmenu_slider_3(menu_item, 17);
gmenu_slider_1(menu_item, -1600, 0, gamma);
}
else
{
menu_item->dwFlags &= 0x3F000000;
menu_item->pszStr = names[1];
}
}
//----- (00418AC6) --------------------------------------------------------
void __cdecl gamemenu_get_sound()
{
gamemenu_sound_music_toggle(sound_toggle_names, &sgOptionMenu[1], sound_get_or_set_sound_volume(1));
}
//----- (00418ADF) --------------------------------------------------------
void __cdecl gamemenu_get_color_cycling()
{
sgOptionMenu[3].pszStr = color_cycling_toggle_names[palette_get_colour_cycling()];
}
//----- (00418AF4) --------------------------------------------------------
void __cdecl gamemenu_get_gamma()
{
gmenu_slider_3(&sgOptionMenu[2], 15);
gmenu_slider_1(&sgOptionMenu[2], 30, 100, palette_update_gamma(0));
}
//----- (00418B1A) --------------------------------------------------------
void __fastcall gamemenu_music_volume(int a1)
{
int v1; // esi
if ( a1 )
{
if ( gbMusicOn )
{
gbMusicOn = 0;
music_stop();
sound_get_or_set_music_volume(-1600);
goto LABEL_11;
}
gbMusicOn = 1;
sound_get_or_set_music_volume(0);
LABEL_10:
music_start((unsigned char)leveltype);
goto LABEL_11;
}
v1 = gamemenu_slider_music_sound(sgOptionMenu);
sound_get_or_set_music_volume(v1);
if ( v1 != -1600 )
{
if ( gbMusicOn )
goto LABEL_11;
gbMusicOn = 1;
goto LABEL_10;
}
if ( gbMusicOn )
{
gbMusicOn = 0;
music_stop();
}
LABEL_11:
gamemenu_get_music();
}
// 4A22D4: using guessed type char gbMusicOn;
// 5BB1ED: using guessed type char leveltype;
//----- (00418BA3) --------------------------------------------------------
int __fastcall gamemenu_slider_music_sound(TMenuItem *menu_item)
{
return gmenu_slider_get(menu_item, -1600, 0);
}
//----- (00418BB0) --------------------------------------------------------
void __fastcall gamemenu_sound_volume(int a1)
{
int v1; // ecx
int v2; // esi
if ( a1 )
{
if ( gbSoundOn )
{
gbSoundOn = 0;
FreeMonsterSnd();
v1 = -1600;
}
else
{
gbSoundOn = 1;
v1 = 0;
}
sound_get_or_set_sound_volume(v1);
}
else
{
v2 = gamemenu_slider_music_sound(&sgOptionMenu[1]);
sound_get_or_set_sound_volume(v2);
if ( v2 == -1600 )
{
if ( gbSoundOn )
{
gbSoundOn = 0;
FreeMonsterSnd();
}
}
else if ( !gbSoundOn )
{
gbSoundOn = 1;
}
}
PlaySFX(IS_TITLEMOV);
gamemenu_get_sound();
}
// 4A22D5: using guessed type char gbSoundOn;
//----- (00418C30) --------------------------------------------------------
void __fastcall gamemenu_gamma(int a1)
{
int v1; // eax
int v2; // eax
if ( a1 )
{
v1 = -(palette_update_gamma(0) != 30);
_LOBYTE(v1) = v1 & 0xBA;
v2 = v1 + 100;
}
else
{
v2 = gamemenu_slider_gamma();
}
palette_update_gamma(v2);
gamemenu_get_gamma();
}
//----- (00418C5A) --------------------------------------------------------
int __cdecl gamemenu_slider_gamma()
{
return gmenu_slider_get(&sgOptionMenu[2], 30, 100);
}
//----- (00418C6A) --------------------------------------------------------
void __cdecl gamemenu_color_cycling()
{
palette_set_color_cycling(palette_get_colour_cycling() == 0);
sgOptionMenu[3].pszStr = color_cycling_toggle_names[palette_get_colour_cycling() & 1];
}

41
Source/gamemenu.h Normal file
View File

@ -0,0 +1,41 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
void __cdecl gamemenu_previous();
void __cdecl gamemenu_enable_single();
void __cdecl gamemenu_enable_multi();
void __cdecl gamemenu_off();
void __cdecl gamemenu_handle_previous();
void __cdecl gamemenu_new_game();
void __cdecl gamemenu_quit_game();
void __cdecl gamemenu_load_game();
void __cdecl gamemenu_save_game();
void __cdecl gamemenu_restart_town();
void __cdecl gamemenu_options();
void __cdecl gamemenu_get_music();
void __fastcall gamemenu_sound_music_toggle(char **names, TMenuItem *menu_item, int gamma);
void __cdecl gamemenu_get_sound();
void __cdecl gamemenu_get_color_cycling();
void __cdecl gamemenu_get_gamma();
void __fastcall gamemenu_music_volume(int a1);
int __fastcall gamemenu_slider_music_sound(TMenuItem *menu_item);
void __fastcall gamemenu_sound_volume(int a1);
void __fastcall gamemenu_gamma(int a1);
int __cdecl gamemenu_slider_gamma();
void __cdecl gamemenu_color_cycling();
/* rdata */
extern TMenuItem sgSingleMenu[6];
extern TMenuItem sgMultiMenu[5];
extern TMenuItem sgOptionMenu[6];
extern char *music_toggle_names[];
extern char *sound_toggle_names[];
extern char *color_cycling_toggle_names[];

1482
Source/gendung.cpp Normal file

File diff suppressed because it is too large Load Diff

101
Source/gendung.h Normal file
View File

@ -0,0 +1,101 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//gendung
extern short level_frame_types[2048];
extern int themeCount;
extern char nTransTable[2049];
//int dword_52D204;
extern int dMonster[112][112];
extern char dungeon[40][40];
extern char dObject[112][112];
extern void *pSpeedCels;
extern int nlevel_frames; // weak
extern char pdungeon[40][40];
extern char dDead[112][112];
extern short dpiece_defs_map_1[16][112][112];
extern char dTransVal2[112][112];
extern char TransVal; // weak
extern int dword_5A5594;
extern char dflags[40][40];
extern int dPiece[112][112];
extern char dTransVal[112][112];
extern int setloadflag_2; // weak
extern Tile tile_defs[1024];
extern void *pMegaTiles;
extern DPiece dpiece_defs[2];
extern int gnDifficulty; // idb
extern char block_lvid[2049];
//char byte_5B78EB;
extern char dung_map[112][112];
extern char nTrapTable[2049];
extern char leveltype; // weak
extern unsigned char currlevel; // idb
extern char TransList[256];
extern char nSolidTable[2049];
extern int level_frame_count[2049];
extern ScrollStruct ScrollInfo;
extern void *pDungeonCels;
extern int speed_cel_frame_num_from_light_index_frame_num[16][128];
extern THEME_LOC themeLoc[50];
extern char dPlayer[112][112];
extern int dword_5C2FF8; // weak
extern int dword_5C2FFC; // weak
extern int scr_pix_width; // weak
extern int scr_pix_height; // weak
extern char dArch[112][112];
extern char nBlockTable[2049];
extern void *level_special_cel;
extern char dFlags[112][112];
extern char dItem[112][112];
extern char setlvlnum; // weak
extern int level_frame_sizes[2048];
extern char nMissileTable[2049];
extern char *pSetPiece_2;
extern char setlvltype; // weak
extern char setlevel; // weak
extern int LvlViewY; // weak
extern int LvlViewX; // weak
extern int dmaxx; // weak
extern int dmaxy; // weak
extern int setpc_h; // weak
extern int setpc_w; // weak
extern int setpc_x; // idb
extern int ViewX; // idb
extern int ViewY; // idb
extern int setpc_y; // idb
extern char dMissile[112][112];
extern int dminx; // weak
extern int dminy; // weak
extern short dpiece_defs_map_2[16][112][112];
void __cdecl FillSolidBlockTbls();
void __cdecl gendung_418D91();
void __fastcall gendung_4191BF(int frames);
void __fastcall gendung_4191FB(int a1, int a2);
int __fastcall gendung_get_dpiece_num_from_coord(int x, int y);
void __cdecl gendung_4192C2();
void __cdecl SetDungeonMicros();
void __cdecl DRLG_InitTrans();
void __fastcall DRLG_MRectTrans(int x1, int y1, int x2, int y2);
void __fastcall DRLG_RectTrans(int x1, int y1, int x2, int y2);
void __fastcall DRLG_CopyTrans(int sx, int sy, int dx, int dy);
void __fastcall DRLG_ListTrans(int num, unsigned char *List);
void __fastcall DRLG_AreaTrans(int num, unsigned char *List);
void __cdecl DRLG_InitSetPC();
void __cdecl DRLG_SetPC();
void __fastcall Make_SetPC(int x, int y, int w, int h);
bool __fastcall DRLG_WillThemeRoomFit(int floor, int x, int y, int minSize, int maxSize, int *width, int *height);
void __fastcall DRLG_CreateThemeRoom(int themeIndex);
void __fastcall DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, int rndSize);
void __cdecl DRLG_HoldThemeRooms();
bool __fastcall SkipThemeRoom(int x, int y);
void __cdecl InitLevels();

538
Source/gmenu.cpp Normal file
View File

@ -0,0 +1,538 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
void *optbar_cel;
bool byte_634464; // weak
void *PentSpin_cel;
TMenuItem *sgpCurrItem;
void *BigTGold_cel;
int dword_634474; // weak
char byte_634478; // weak
void (__cdecl *dword_63447C)();
TMenuItem *dword_634480; // idb
void *option_cel;
void *sgpLogo;
int dword_63448C; // weak
unsigned char lfontframe[127] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 37, 49, 38, 0, 39, 40, 47,
42, 43, 41, 45, 52, 44, 53, 55, 36, 27,
28, 29, 30, 31, 32, 33, 34, 35, 51, 50,
0, 46, 0, 54, 0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 42, 0, 43, 0, 0, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 20, 0, 21, 0
};
unsigned char lfontkern[56] =
{
18, 33, 21, 26, 28, 19, 19, 26, 25, 11,
12, 25, 19, 34, 28, 32, 20, 32, 28, 20,
28, 36, 35, 46, 33, 33, 24, 11, 23, 22,
22, 21, 22, 21, 21, 21, 32, 10, 20, 36,
31, 17, 13, 12, 13, 18, 16, 11, 20, 21,
11, 10, 12, 11, 21, 23
};
//----- (00419E8B) --------------------------------------------------------
void __cdecl gmenu_draw_pause()
{
if ( currlevel )
RedBack();
if ( !dword_634480 )
{
light_table_index = 0;
gmenu_print_text(316, 336, "Pause");
}
}
// 69BEF8: using guessed type int light_table_index;
//----- (00419EBE) --------------------------------------------------------
void __fastcall gmenu_print_text(int x, int y, char *pszStr)
{
char *v3; // edi
int v4; // ebp
int v5; // esi
unsigned char i; // al
unsigned char v7; // bl
v3 = pszStr;
v4 = y;
v5 = x;
for ( i = *pszStr; *v3; i = *v3 )
{
++v3;
v7 = lfontframe[fontidx[i]];
if ( v7 )
CelDecodeLightOnly(v5, v4, (char *)BigTGold_cel, v7, 46);
v5 += lfontkern[v7] + 2;
}
}
//----- (00419F17) --------------------------------------------------------
void __cdecl FreeGMenu()
{
void *v0; // ecx
void *v1; // ecx
void *v2; // ecx
void *v3; // ecx
void *v4; // ecx
v0 = sgpLogo;
sgpLogo = 0;
mem_free_dbg(v0);
v1 = BigTGold_cel;
BigTGold_cel = 0;
mem_free_dbg(v1);
v2 = PentSpin_cel;
PentSpin_cel = 0;
mem_free_dbg(v2);
v3 = option_cel;
option_cel = 0;
mem_free_dbg(v3);
v4 = optbar_cel;
optbar_cel = 0;
mem_free_dbg(v4);
}
//----- (00419F70) --------------------------------------------------------
void __cdecl gmenu_init_menu()
{
byte_634478 = 1;
dword_634480 = 0;
sgpCurrItem = 0;
dword_63447C = 0;
dword_63448C = 0;
byte_634464 = 0;
sgpLogo = LoadFileInMem("Data\\Diabsmal.CEL", 0);
BigTGold_cel = LoadFileInMem("Data\\BigTGold.CEL", 0);
PentSpin_cel = LoadFileInMem("Data\\PentSpin.CEL", 0);
option_cel = LoadFileInMem("Data\\option.CEL", 0);
optbar_cel = LoadFileInMem("Data\\optbar.CEL", 0);
}
// 634464: using guessed type char byte_634464;
// 634478: using guessed type char byte_634478;
// 63448C: using guessed type int dword_63448C;
//----- (00419FE8) --------------------------------------------------------
bool __cdecl gmenu_exception()
{
return dword_634480 != 0;
}
//----- (00419FF4) --------------------------------------------------------
void __fastcall gmenu_call_proc(TMenuItem *pItem, void (__cdecl *gmFunc)())
{
TMenuItem *v2; // eax
int v3; // ecx
void (__cdecl **v4)(); // edx
PauseMode = 0;
byte_634464 = 0;
v2 = pItem;
dword_63447C = gmFunc;
dword_634480 = pItem;
if ( gmFunc )
{
gmFunc();
v2 = dword_634480;
}
v3 = 0;
dword_63448C = 0;
if ( v2 )
{
v4 = &v2->fnMenu;
while ( *v4 )
{
++v3;
v4 += 3;
dword_63448C = v3;
}
}
sgpCurrItem = &v2[v3 - 1];
gmenu_up_down(1);
}
// 525740: using guessed type int PauseMode;
// 634464: using guessed type char byte_634464;
// 63448C: using guessed type int dword_63448C;
//----- (0041A04E) --------------------------------------------------------
void __fastcall gmenu_up_down(int a1)
{
TMenuItem *v1; // eax
int v2; // edi
v1 = sgpCurrItem;
if ( sgpCurrItem )
{
byte_634464 = 0;
v2 = dword_63448C;
while ( v2 )
{
--v2;
if ( a1 )
{
++v1;
sgpCurrItem = v1;
if ( v1->fnMenu )
goto LABEL_10;
v1 = dword_634480;
}
else
{
if ( v1 == dword_634480 )
v1 = &dword_634480[dword_63448C];
--v1;
}
sgpCurrItem = v1;
LABEL_10:
if ( v1->dwFlags < 0 )
{
if ( v2 )
PlaySFX(IS_TITLEMOV);
return;
}
}
}
}
// 634464: using guessed type char byte_634464;
// 63448C: using guessed type int dword_63448C;
//----- (0041A0B6) --------------------------------------------------------
void __cdecl gmenu_draw()
{
int v0; // edi
TMenuItem *i; // esi
DWORD v2; // eax
if ( dword_634480 )
{
if ( dword_63447C )
dword_63447C();
CelDecodeOnly(236, 262, sgpLogo, 1, 296);
v0 = 320;
for ( i = dword_634480; i->fnMenu; v0 += 45 )
{
gmenu_draw_menu_item(i, v0);
++i;
}
v2 = GetTickCount();
if ( (signed int)(v2 - dword_634474) > 25 )
{
if ( ++byte_634478 == 9 )
byte_634478 = 1;
dword_634474 = v2;
}
}
}
// 634474: using guessed type int dword_634474;
// 634478: using guessed type char byte_634478;
//----- (0041A145) --------------------------------------------------------
void __fastcall gmenu_draw_menu_item(TMenuItem *pItem, int a2)
{
int v2; // edi
TMenuItem *v3; // ebx
unsigned int v4; // eax
unsigned int v5; // ebp
int v6; // esi
unsigned int v7; // ecx
unsigned int v8; // eax
int v9; // ecx
unsigned int v10; // ebp
int v11; // esi
int v12; // eax
int v13; // edi
unsigned int v14; // [esp+10h] [ebp-4h]
v2 = a2;
v3 = pItem;
v4 = gmenu_get_lfont(pItem);
v5 = v4;
v14 = v4;
if ( v3->dwFlags & 0x40000000 )
{
v6 = (v4 >> 1) + 80;
CelDecodeOnly(v6, v2 - 10, optbar_cel, 1, 287);
v7 = ((unsigned int)v3->dwFlags >> 12) & 0xFFF;
if ( v7 < 2 )
v7 = 2;
v8 = ((v3->dwFlags & 0xFFFu) << 8) / v7;
v9 = (v5 >> 1) + 82;
v10 = v8;
gmenu_clear_buffer(v9, v2 - 12, v8 + 13, 28);
CelDecodeOnly(v6 + v10 + 2, v2 - 12, option_cel, 1, 27);
v5 = v14;
}
v11 = 384 - (v5 >> 1);
v12 = -(v3->dwFlags < 0);
_LOBYTE(v12) = v12 & 0xF1;
light_table_index = v12 + 15;
gmenu_print_text(384 - (v5 >> 1), v2, v3->pszStr);
if ( v3 == sgpCurrItem )
{
v13 = v2 + 1;
CelDecodeOnly(v11 - 54, v13, PentSpin_cel, (unsigned char)byte_634478, 48);
CelDecodeOnly(v11 + v5 + 4, v13, PentSpin_cel, (unsigned char)byte_634478, 48);
}
}
// 634478: using guessed type char byte_634478;
// 69BEF8: using guessed type int light_table_index;
//----- (0041A239) --------------------------------------------------------
void __fastcall gmenu_clear_buffer(int x, int y, int width, int height)
{
int v4; // edi
char *i; // esi
v4 = height;
for ( i = (char *)gpBuffer + screen_y_times_768[y] + x; v4; --v4 )
{
memset(i, 205, width);
i -= 768;
}
}
//----- (0041A272) --------------------------------------------------------
int __fastcall gmenu_get_lfont(TMenuItem *pItem)
{
char *v2; // eax
int i; // edx
unsigned char v4; // cl
if ( pItem->dwFlags & 0x40000000 )
return 490;
v2 = pItem->pszStr;
for ( i = 0; ; i += lfontkern[lfontframe[fontidx[v4]]] + 2 )
{
v4 = *v2;
if ( !*v2 )
break;
++v2;
}
return i - 2;
}
//----- (0041A2AE) --------------------------------------------------------
int __fastcall gmenu_presskeys(int a1)
{
int v1; // ecx
int v2; // ecx
if ( !dword_634480 )
return 0;
switch ( a1 )
{
case VK_RETURN:
if ( sgpCurrItem->dwFlags < 0 )
{
PlaySFX(IS_TITLEMOV);
((void (__fastcall *)(signed int))sgpCurrItem->fnMenu)(1);
}
return 1;
case VK_ESCAPE:
PlaySFX(IS_TITLEMOV);
gmenu_call_proc(0, 0);
return 1;
case VK_SPACE:
return 0;
case VK_LEFT:
v2 = 0;
goto LABEL_12;
case VK_UP:
v1 = 0;
goto LABEL_10;
case VK_RIGHT:
v2 = 1;
LABEL_12:
gmenu_left_right(v2);
return 1;
case VK_DOWN:
v1 = 1;
LABEL_10:
gmenu_up_down(v1);
break;
}
return 1;
}
//----- (0041A32A) --------------------------------------------------------
void __fastcall gmenu_left_right(int a1)
{
int v1; // edx
int v2; // eax
int v3; // eax
v1 = sgpCurrItem->dwFlags;
if ( sgpCurrItem->dwFlags & 0x40000000 )
{
v2 = sgpCurrItem->dwFlags & 0xFFF;
if ( a1 )
{
if ( v2 == ((v1 >> 12) & 0xFFF) )
return;
v3 = v2 + 1;
}
else
{
if ( !(v1 & 0xFFF) )
return;
v3 = v2 - 1;
}
_LOWORD(v1) = v1 & 0xF000;
sgpCurrItem->dwFlags = v1;
sgpCurrItem->dwFlags |= v3;
((void (__fastcall *)(_DWORD))sgpCurrItem->fnMenu)(0);
}
}
//----- (0041A37A) --------------------------------------------------------
int __fastcall gmenu_on_mouse_move(LPARAM lParam)
{
int v2; // edx
int a1; // [esp+0h] [ebp-4h]
a1 = lParam;
if ( !byte_634464 )
return 0;
gmenu_valid_mouse_pos(&a1);
v2 = a1 * ((sgpCurrItem->dwFlags >> 12) & 0xFFF) % 256;
a1 = a1 * ((sgpCurrItem->dwFlags >> 12) & 0xFFF) / 256;
_LOWORD(sgpCurrItem->dwFlags) &= 0xF000u;
sgpCurrItem->dwFlags |= a1;
((void (__fastcall *)(_DWORD, int))sgpCurrItem->fnMenu)(0, v2);
return 1;
}
// 41A37A: could not find valid save-restore pair for esi
// 634464: using guessed type char byte_634464;
//----- (0041A3D2) --------------------------------------------------------
bool __fastcall gmenu_valid_mouse_pos(int *plOffset)
{
*plOffset = 282;
if ( MouseX < 282 )
{
*plOffset = 0;
return 0;
}
if ( MouseX > 538 )
{
*plOffset = 256;
return 0;
}
*plOffset = MouseX - 282;
return 1;
}
//----- (0041A401) --------------------------------------------------------
int __fastcall gmenu_left_mouse(int a1)
{
int result; // eax
unsigned int v2; // eax
unsigned int v3; // eax
TMenuItem *v4; // esi
unsigned int v5; // eax
//LPARAM v6; // ecx
int a1a; // [esp+4h] [ebp-4h]
if ( a1 )
{
if ( !dword_634480 || MouseY >= 352 )
return 0;
if ( MouseY - 117 >= 0 )
{
v2 = (MouseY - 117) / 45;
if ( v2 < dword_63448C )
{
v3 = v2;
v4 = &dword_634480[v3];
if ( v4->dwFlags < 0 )
{
v5 = (unsigned int)gmenu_get_lfont(&dword_634480[v3]) >> 1;
if ( MouseX >= 320 - v5 && MouseX <= v5 + 320 )
{
sgpCurrItem = v4;
PlaySFX(IS_TITLEMOV);
if ( v4->dwFlags & 0x40000000 )
{
byte_634464 = gmenu_valid_mouse_pos(&a1a);
gmenu_on_mouse_move(a1); /* v6 */
}
else
{
((void (__fastcall *)(signed int))sgpCurrItem->fnMenu)(1);
}
}
}
}
}
}
else
{
result = 0;
if ( !byte_634464 )
return result;
byte_634464 = 0;
}
return 1;
}
// 634464: using guessed type char byte_634464;
// 63448C: using guessed type int dword_63448C;
//----- (0041A4B8) --------------------------------------------------------
void __fastcall gmenu_enable(TMenuItem *pMenuItem, bool enable)
{
if ( enable )
pMenuItem->dwFlags |= 0x80000000;
else
pMenuItem->dwFlags &= 0x7F000000;
}
//----- (0041A4C6) --------------------------------------------------------
void __fastcall gmenu_slider_1(TMenuItem *pItem, int min, int max, int gamma)
{
int v4; // esi
int v5; // eax
v4 = pItem->dwFlags;
v5 = (pItem->dwFlags >> 12) & 0xFFF;
if ( v5 < 2 )
v5 = 2;
_LOWORD(v4) = v4 & 0xF000;
pItem->dwFlags = v4 | (v5 * (gamma - min) + (max - min - 1) / 2) / (max - min);
}
//----- (0041A508) --------------------------------------------------------
int __fastcall gmenu_slider_get(TMenuItem *pItem, int min, int max)
{
int v3; // eax
int v4; // ecx
v3 = (pItem->dwFlags >> 12) & 0xFFF;
v4 = pItem->dwFlags & 0xFFF;
if ( v3 < 2 )
v3 = 2;
return min + (v4 * (max - min) + (v3 - 1) / 2) / v3;
}
//----- (0041A545) --------------------------------------------------------
void __fastcall gmenu_slider_3(TMenuItem *pItem, int dwTicks)
{
pItem->dwFlags ^= (pItem->dwFlags ^ (dwTicks << 12)) & 0xFFF000;
}

50
Source/gmenu.h Normal file
View File

@ -0,0 +1,50 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//gmenu
extern void *optbar_cel;
extern bool byte_634464; // weak
extern void *PentSpin_cel;
extern TMenuItem *sgpCurrItem;
extern void *BigTGold_cel;
extern int dword_634474; // weak
extern char byte_634478; // weak
extern void (__cdecl *dword_63447C)();
extern TMenuItem *dword_634480; // idb
extern void *option_cel;
extern void *sgpLogo;
extern int dword_63448C; // weak
void __cdecl gmenu_draw_pause();
void __fastcall gmenu_print_text(int x, int y, char *pszStr);
void __cdecl FreeGMenu();
void __cdecl gmenu_init_menu();
bool __cdecl gmenu_exception();
void __fastcall gmenu_call_proc(TMenuItem *pItem, void (__cdecl *gmFunc)());
void __fastcall gmenu_up_down(int a1);
void __cdecl gmenu_draw();
void __fastcall gmenu_draw_menu_item(TMenuItem *pItem, int a2);
void __fastcall gmenu_clear_buffer(int x, int y, int width, int height);
int __fastcall gmenu_get_lfont(TMenuItem *pItem);
int __fastcall gmenu_presskeys(int a1);
void __fastcall gmenu_left_right(int a1);
int __fastcall gmenu_on_mouse_move(LPARAM lParam);
bool __fastcall gmenu_valid_mouse_pos(int *plOffset);
int __fastcall gmenu_left_mouse(int a1);
void __fastcall gmenu_enable(TMenuItem *pMenuItem, bool enable);
void __fastcall gmenu_slider_1(TMenuItem *pItem, int min, int max, int gamma);
int __fastcall gmenu_slider_get(TMenuItem *pItem, int min, int max);
void __fastcall gmenu_slider_3(TMenuItem *pItem, int dwTicks);
/* data */
extern unsigned char lfontframe[127];
extern unsigned char lfontkern[56];

285
Source/help.cpp Normal file
View File

@ -0,0 +1,285 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int help_select_line; // weak
int dword_634494; // weak
int helpflag;
int displayinghelp[22]; /* check, does nothing? */
int HelpTop; // weak
char gszHelpText[] =
{
"$Keyboard Shortcuts:|"
"F1: Open Help Screen|"
"Esc: Display Main Menu|"
"Tab: Display Auto-map|"
"Space: Hide all info screens|"
"S: Open Speedbook|"
"B: Open Spellbook|"
"I: Open Inventory screen|"
"C: Open Character screen|"
"Q: Open Quest log|"
"F: Reduce screen brightness|"
"G: Increase screen brightness|"
"Z: Zoom Game Screen|"
"+ / -: Zoom Automap|"
"1 - 8: Use Belt item|"
"F5, F6, F7, F8: Set hot key for skill or spell|"
"Shift + Left Click: Attack without moving|"
"|"
"$Movement:|"
"If you hold the mouse button down while moving, the character "
"will continue to move in that direction.|"
"|"
"$Combat:|"
"Holding down the shift key and then left-clicking allows the "
"character to attack without moving.|"
"|"
"$Auto-map:|"
"To access the auto-map, click the 'MAP' button on the "
"Information Bar or press 'TAB' on the keyboard. Zooming in and "
"out of the map is done with the + and - keys. Scrolling the map "
"uses the arrow keys.|"
"|"
"$Picking up Objects:|"
"Useable items that are small in size, such as potions or scrolls, "
"are automatically placed in your 'belt' located at the top of "
"the Interface bar . When an item is placed in the belt, a small "
"number appears in that box. Items may be used by either pressing "
"the corresponding number or right-clicking on the item.|"
"|"
"$Gold|"
"You can select a specific amount of gold to drop by right "
"clicking on a pile of gold in your inventory.|"
"|"
"$Skills & Spells:|"
"You can access your list of skills and spells by left-clicking on "
"the 'SPELLS' button in the interface bar. Memorized spells and "
"those available through staffs are listed here. Left-clicking on "
"the spell you wish to cast will ready the spell. A readied spell "
"may be cast by simply right-clicking in the play area.|"
"|"
"$Using the Speedbook for Spells|"
"Left-clicking on the 'readied spell' button will open the 'Speedbook' "
"which allows you to select a skill or spell for immediate use. "
"To use a readied skill or spell, simply right-click in the main play "
"area.|"
"|"
"$Setting Spell Hotkeys|"
"You can assign up to four Hot Keys for skills, spells or scrolls. "
"Start by opening the 'speedbook' as described in the section above. "
"Press the F5, F6, F7 or F8 keys after highlighting the spell you "
"wish to assign.|"
"|"
"$Spell Books|"
"Reading more than one book increases your knowledge of that "
"spell, allowing you to cast the spell more effectively.|"
"&"
};
//----- (0041A553) --------------------------------------------------------
void __cdecl InitHelp()
{
helpflag = 0;
dword_634494 = 0;
displayinghelp[0] = 0;
}
// 634494: using guessed type int dword_634494;
//----- (0041A565) --------------------------------------------------------
void __cdecl DrawHelp()
{
int v0; // edi
const char *v1; // esi
int v2; // edx
signed int v3; // ecx
char v4; // al
unsigned char v5; // al
_BYTE *i; // eax
int v7; // eax
signed int v8; // edx
char v9; // cl
unsigned char v10; // cl
text_color color; // [esp+Ch] [ebp-8h]
int help_line_nr; // [esp+10h] [ebp-4h]
signed int help_line_nra; // [esp+10h] [ebp-4h]
DrawSTextHelp();
DrawQTextBack();
PrintSString(0, 2, 1u, "Diablo Help", COL_GOLD, 0);
DrawSLine(5);
v0 = help_select_line;
v1 = gszHelpText;
if ( help_select_line > 0 )
{
help_line_nr = help_select_line;
do
{
v2 = 0;
v3 = 0;
while ( !*v1 )
++v1;
if ( *v1 == '$' )
++v1;
v4 = *v1;
if ( *v1 != '&' )
{
if ( v4 == ('|') )
goto LABEL_47;
while ( v3 < 577 )
{
if ( !v4 )
{
do
++v1;
while ( !*v1 );
}
v5 = *v1;
tempstr[v2++] = *v1++;
v3 += fontkern[fontframe[fontidx[v5]]] + 1;
v4 = *v1;
if ( *v1 == ('|') )
{
if ( v3 < 577 )
goto LABEL_18;
break;
}
}
for ( i = (unsigned char *)&tempstr[v2]-1; *i != ' '; --i )
--v1;
LABEL_18:
if ( *v1 == ('|') )
LABEL_47:
++v1;
}
--help_line_nr;
}
while ( help_line_nr );
}
help_line_nra = 7;
do
{
v7 = 0;
v8 = 0;
while ( !*v1 )
++v1;
if ( *v1 == '$' )
{
++v1;
_LOBYTE(color) = COL_RED;
}
else
{
_LOBYTE(color) = COL_WHITE;
}
v9 = *v1;
if ( *v1 == '&' )
{
HelpTop = v0;
}
else
{
if ( v9 == ('|') )
goto LABEL_48;
while ( v8 < 577 )
{
if ( !v9 )
{
do
++v1;
while ( !*v1 );
}
v10 = *v1;
tempstr[v7++] = *v1++;
v8 += fontkern[fontframe[fontidx[v10]]] + 1;
v9 = *v1;
if ( *v1 == ('|') )
{
if ( v8 < 577 )
goto LABEL_39;
break;
}
}
while ( tempstr[--v7] != ' ' )
--v1;
LABEL_39:
if ( v7 )
{
tempstr[v7] = 0;
DrawHelpLine(0, help_line_nra, tempstr, color);
v0 = help_select_line;
}
if ( *v1 == ('|') )
LABEL_48:
++v1;
}
++help_line_nra;
}
while ( help_line_nra < 22 );
PrintSString(0, 23, 1u, "Press ESC to end or the arrow keys to scroll.", COL_GOLD, 0);
}
// 634490: using guessed type int help_select_line;
// 634960: using guessed type int HelpTop;
//----- (0041A6FA) --------------------------------------------------------
void __fastcall DrawHelpLine(int always_0, int help_line_nr, char *text, text_color color)
{
signed int v4; // ebx
int v5; // edi
unsigned char i; // al
unsigned char v7; // al
int v8; // esi
v4 = 0;
v5 = screen_y_times_768[SStringY[help_line_nr] + 204] + always_0 + 96;
for ( i = *text; *text; i = *text )
{
++text;
v7 = fontframe[fontidx[i]];
v8 = v7;
v4 += fontkern[v7] + 1;
if ( v7 )
{
if ( v4 <= 577 )
CPrintString(v5, v7, color);
}
v5 += fontkern[v8] + 1;
}
}
//----- (0041A773) --------------------------------------------------------
void __cdecl DisplayHelp()
{
help_select_line = 0;
helpflag = 1;
HelpTop = 5000;
}
// 634490: using guessed type int help_select_line;
// 634960: using guessed type int HelpTop;
//----- (0041A78F) --------------------------------------------------------
void __cdecl HelpScrollUp()
{
if ( help_select_line > 0 )
--help_select_line;
}
// 634490: using guessed type int help_select_line;
//----- (0041A79F) --------------------------------------------------------
void __cdecl HelpScrollDown()
{
if ( help_select_line < HelpTop )
++help_select_line;
}
// 634490: using guessed type int help_select_line;
// 634960: using guessed type int HelpTop;

27
Source/help.h Normal file
View File

@ -0,0 +1,27 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//help
extern int help_select_line; // weak
extern int dword_634494; // weak
extern int helpflag;
extern int displayinghelp[22];
extern int HelpTop; // weak
void __cdecl InitHelp();
void __cdecl DrawHelp();
void __fastcall DrawHelpLine(int always_0, int help_line_nr, char *text, text_color color);
void __cdecl DisplayHelp();
void __cdecl HelpScrollUp();
void __cdecl HelpScrollDown();
/* data */
extern char gszHelpText[];

553
Source/init.cpp Normal file
View File

@ -0,0 +1,553 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
_SNETVERSIONDATA fileinfo;
int init_cpp_init_value; // weak
int window_activated; // weak
char diablo_exe_path[260];
void *unused_mpq;
char patch_rt_mpq_path[260];
LRESULT (__stdcall *CurrentProc)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void *diabdat_mpq;
char diabdat_mpq_path[260];
void *patch_rt_mpq;
int killed_mom_parent; // weak
bool screensaver_enabled_prev;
int init_inf = 0x7F800000; // weak
/* rdata */
char gszVersionNumber[260] = "internal version unknown";
char gszProductName[260] = "Diablo v1.09";
//----- (0041A7B8) --------------------------------------------------------
struct init_cpp_init
{
init_cpp_init()
{
init_cpp_init_value = init_inf;
}
} _init_cpp_init;
// 47AE20: using guessed type int init_inf;
// 63497C: using guessed type int init_cpp_init_value;
//----- (0041A7C3) --------------------------------------------------------
void __fastcall init_cleanup(bool show_cursor)
{
int v1; // edi
v1 = show_cursor;
pfile_flush_W();
init_disable_screensaver(0);
init_run_office_from_start_menu();
if ( diabdat_mpq )
{
SFileCloseArchive(diabdat_mpq);
diabdat_mpq = 0;
}
if ( patch_rt_mpq )
{
SFileCloseArchive(patch_rt_mpq);
patch_rt_mpq = 0;
}
if ( unused_mpq )
{
SFileCloseArchive(unused_mpq);
unused_mpq = 0;
}
UiDestroy();
effects_cleanup_sfx();
sound_cleanup();
NetClose();
dx_cleanup();
MI_Dummy(v1);
StormDestroy();
if ( v1 )
ShowCursor(1);
}
//----- (0041A84C) --------------------------------------------------------
void __cdecl init_run_office_from_start_menu()
{
HWND v0; // eax
char pszPath[256]; // [esp+0h] [ebp-104h]
LPITEMIDLIST ppidl; // [esp+100h] [ebp-4h]
if ( killed_mom_parent )
{
*pszPath = empty_string;
killed_mom_parent = 0;
memset(pszPath + 1, 0, sizeof(pszPath) - 1);
// *(_WORD *)&pszPath[253] = 0;
//pszPath[255] = 0;
ppidl = 0;
v0 = GetDesktopWindow();
if ( !SHGetSpecialFolderLocation(v0, CSIDL_STARTMENU, &ppidl) )
{
SHGetPathFromIDListA(ppidl, pszPath);
init_run_office(pszPath);
}
}
}
// 634CA0: using guessed type int killed_mom_parent;
//----- (0041A8B9) --------------------------------------------------------
void __fastcall init_run_office(char *dir)
{
char *v1; // esi
HANDLE v2; // ebx
bool v3; // zf
HWND v4; // eax
char Directory[260]; // [esp+8h] [ebp-348h]
char FileName[260]; // [esp+10Ch] [ebp-244h]
struct _WIN32_FIND_DATAA FindFileData; // [esp+210h] [ebp-140h]
v1 = dir;
strcpy(FileName, dir);
if ( FileName[0] && Directory[strlen(FileName) + 259] == '\\' )
strcat(FileName, "*");
else
strcat(FileName, "\\*");
v2 = FindFirstFileA(FileName, &FindFileData);
if ( v2 != (HANDLE)-1 )
{
do
{
if ( FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
if ( strcmp(FindFileData.cFileName, ".") && strcmp(FindFileData.cFileName, "..") )
{
*Directory = empty_string;
memset(Directory + 1, 0, sizeof(Directory) - 1);
v3 = *v1 == 0;
// *(_WORD *)&Directory[257] = 0;
//Directory[259] = 0;
if ( v3 || v1[strlen(v1) - 1] != '\\' )
sprintf(Directory, "%s\\%s\\", v1, FindFileData.cFileName);
else
sprintf(Directory, "%s%s\\", v1, FindFileData.cFileName);
init_run_office(Directory);
}
}
else if ( !_strcmpi(FindFileData.cFileName, "Microsoft Office Shortcut Bar.lnk") )
{
v4 = GetDesktopWindow();
ShellExecuteA(v4, "open", FindFileData.cFileName, &empty_string, v1, SW_SHOWNORMAL);
}
}
while ( FindNextFileA(v2, &FindFileData) );
FindClose(v2);
}
}
//----- (0041AA2C) --------------------------------------------------------
void __fastcall init_disable_screensaver(bool disable)
{
bool v1; // al
BYTE Data; // [esp+4h] [ebp-20h]
char v3; // [esp+5h] [ebp-1Fh]
DWORD Type; // [esp+14h] [ebp-10h]
DWORD cbData; // [esp+18h] [ebp-Ch]
HKEY phkResult; // [esp+1Ch] [ebp-8h]
bool v7; // [esp+20h] [ebp-4h]
v7 = disable;
if ( !RegOpenKeyExA(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ|KEY_WRITE, &phkResult) )
{
if ( v7 )
{
cbData = 16;
if ( !RegQueryValueExA(phkResult, "ScreenSaveActive", 0, &Type, &Data, &cbData) )
screensaver_enabled_prev = Data != '0';
v1 = 0;
}
else
{
v1 = screensaver_enabled_prev;
}
v3 = 0;
Data = (v1 != 0) + '0';
RegSetValueExA(phkResult, "ScreenSaveActive", 0, REG_SZ, &Data, 2u);
RegCloseKey(phkResult);
}
}
//----- (0041AAC5) --------------------------------------------------------
void __cdecl init_create_window()
{
int nHeight; // eax
HWND hWnd; // esi
WNDCLASSEXA wcex; // [esp+8h] [ebp-34h]
int nWidth; // [esp+38h] [ebp-4h]
init_kill_mom_parent();
pfile_init_save_directory();
memset(&wcex, 0, sizeof(wcex));
wcex.cbSize = sizeof(wcex);
wcex.style = CS_HREDRAW|CS_VREDRAW;
wcex.lpfnWndProc = init_redraw_window;
wcex.hInstance = ghInst;
wcex.hIcon = LoadIconA(ghInst, (LPCSTR)0x65);
wcex.hCursor = LoadCursorA(0, (LPCSTR)0x7F00);
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = "DIABLO";
wcex.lpszClassName = "DIABLO";
wcex.hIconSm = (HICON)LoadImageA(ghInst, (LPCSTR)0x65, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
if ( !RegisterClassExA(&wcex) )
TermMsg("Unable to register window class");
if ( GetSystemMetrics(SM_CXSCREEN) >= 640 )
nWidth = GetSystemMetrics(SM_CXSCREEN);
else
nWidth = 640;
if ( GetSystemMetrics(SM_CYSCREEN) >= 480 )
nHeight = GetSystemMetrics(SM_CYSCREEN);
else
nHeight = 480;
hWnd = CreateWindowExA(0, "DIABLO", "DIABLO", WS_POPUP, 0, 0, nWidth, nHeight, NULL, NULL, ghInst, NULL);
if ( !hWnd )
TermMsg("Unable to create main window");
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
init_await_mom_parent_exit();
dx_init(hWnd);
BlackPalette();
snd_init(hWnd);
init_archives();
init_disable_screensaver(1);
}
//----- (0041AC00) --------------------------------------------------------
void __cdecl init_kill_mom_parent()
{
HWND v0; // eax
v0 = init_find_mom_parent();
if ( v0 )
{
PostMessageA(v0, WM_CLOSE, 0, 0);
killed_mom_parent = 1;
}
}
// 634CA0: using guessed type int killed_mom_parent;
//----- (0041AC21) --------------------------------------------------------
HWND __cdecl init_find_mom_parent()
{
HWND i; // eax
HWND v1; // esi
char ClassName[256]; // [esp+4h] [ebp-100h]
for ( i = GetForegroundWindow(); ; i = GetWindow(v1, GW_HWNDNEXT) )
{
v1 = i;
if ( !i )
break;
GetClassNameA(i, ClassName, 255);
if ( !_strcmpi(ClassName, "MOM Parent") )
break;
}
return v1;
}
//----- (0041AC71) --------------------------------------------------------
void __cdecl init_await_mom_parent_exit()
{
DWORD v0; // edi
v0 = GetTickCount();
do
{
if ( !init_find_mom_parent() )
break;
Sleep(250);
}
while ( GetTickCount() - v0 <= 4000 );
}
//----- (0041ACA1) --------------------------------------------------------
void __cdecl init_archives()
{
void *a1; // [esp+8h] [ebp-8h]
#ifdef COPYPROT
int v1; // [esp+Ch] [ebp-4h]
#endif
fileinfo.size = 20;
fileinfo.versionstring = gszVersionNumber;
fileinfo.executablefile = diablo_exe_path;
fileinfo.originalarchivefile = diabdat_mpq_path;
fileinfo.patcharchivefile = patch_rt_mpq_path;
init_get_file_info();
#ifdef COPYPROT
while ( 1 )
{
#endif
diabdat_mpq = init_test_access(diabdat_mpq_path, "\\diabdat.mpq", "DiabloCD", 1000, 1);
#ifdef COPYPROT
if ( diabdat_mpq )
break;
UiCopyProtError((int)&v1);
if ( v1 == COPYPROT_CANCEL )
FileErrDlg("diabdat.mpq");
}
#endif
if ( !WOpenFile("ui_art\\title.pcx", &a1, 1) )
FileErrDlg("Main program archive: diabdat.mpq");
WCloseFile(a1);
patch_rt_mpq = init_test_access(patch_rt_mpq_path, "\\patch_rt.mpq", "DiabloInstall", 2000, 0);
}
//----- (0041AD72) --------------------------------------------------------
void *__fastcall init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags, bool on_cd)
{
char *v5; // esi
char *v7; // eax
char Filename[260]; // [esp+Ch] [ebp-314h]
char Buffer[260]; // [esp+110h] [ebp-210h]
char v15[260]; // [esp+214h] [ebp-10Ch]
char *mpq_namea; // [esp+318h] [ebp-8h]
void *archive; // [esp+31Ch] [ebp-4h]
mpq_namea = mpq_name;
v5 = mpq_path;
if ( !GetCurrentDirectoryA(0x104u, Buffer) )
TermMsg("Can't get program path");
init_strip_trailing_slash(Buffer);
if ( !SFileSetBasePath(Buffer) )
TermMsg("SFileSetBasePath");
if ( !GetModuleFileNameA(ghInst, Filename, 0x104u) )
TermMsg("Can't get program name");
v7 = strrchr(Filename, '\\');
if ( v7 )
*v7 = 0;
init_strip_trailing_slash(Filename);
strcpy(v5, Buffer);
strcat(v5, mpq_namea);
#ifdef COPYPROT
if ( SFileOpenArchive(v5, flags, on_cd, &archive) )
#else
if ( SFileOpenArchive(v5, flags, 0, &archive) )
#endif
return archive;
if ( strcmp(Filename, Buffer) )
{
strcpy(v5, Filename);
strcat(v5, mpq_namea);
#ifdef COPYPROT
if ( SFileOpenArchive(v5, flags, on_cd, &archive) )
#else
if ( SFileOpenArchive(v5, flags, 0, &archive) )
#endif
return archive;
}
v15[0] = 0;
if ( reg_loc )
{
if ( SRegLoadString("Archives", (const char *)reg_loc, 0, v15, 260) )
{
init_strip_trailing_slash(v15);
strcpy(v5, v15);
strcat(v5, mpq_namea);
#ifdef COPYPROT
if ( SFileOpenArchive(v5, flags, on_cd, &archive) )
#else
if ( SFileOpenArchive(v5, flags, 0, &archive) )
#endif
return archive;
}
}
if ( on_cd && init_read_test_file(v15, mpq_namea, flags, &archive) )
{
strcpy(v5, v15);
return archive;
}
return 0;
}
//----- (0041AF22) --------------------------------------------------------
char *__fastcall init_strip_trailing_slash(char *path)
{
char *result; // eax
result = strrchr(path, '\\');
if ( result )
{
if ( !result[1] )
*result = 0;
}
return result;
}
//----- (0041AF3A) --------------------------------------------------------
int __fastcall init_read_test_file(char *mpq_path, char *mpq_name, int flags, void **archive)
{
char *v4; // edi
DWORD v5; // eax
const char *v7; // ebx
const char *v8; // esi
char Buffer[260]; // [esp+Ch] [ebp-108h]
char *mpq_patha; // [esp+110h] [ebp-4h]
v4 = mpq_name;
mpq_patha = mpq_path;
v5 = GetLogicalDriveStringsA(0x104u, Buffer);
if ( !v5 || v5 > 0x104 )
return 0;
while ( *v4 == '\\' )
++v4;
v7 = Buffer;
if ( !Buffer[0] )
return 0;
while ( 1 )
{
v8 = v7;
v7 += strlen(v7) + 1;
if ( GetDriveTypeA(v8) == DRIVE_CDROM )
{
strcpy(mpq_patha, v8);
strcat(mpq_patha, v4);
if ( SFileOpenArchive(mpq_patha, flags, 1, archive) )
break;
}
if ( !*v7 )
return 0;
}
return 1;
}
//----- (0041AFCE) --------------------------------------------------------
void __cdecl 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]
if ( GetModuleFileNameA(ghInst, diablo_exe_path, 0x104u) )
{
v0 = GetFileVersionInfoSizeA(diablo_exe_path, &dwHandle);
v1 = v0;
if ( v0 )
{
v2 = DiabloAllocPtr(v0);
if ( GetFileVersionInfoA(diablo_exe_path, 0, v1, v2) )
{
if ( VerQueryValueA(v2, "\\", (LPVOID *)&lpBuffer, &uBytes) )
sprintf(
gszVersionNumber,
"version %d.%d.%d.%d",
lpBuffer->dwProductVersionMS >> 16,
lpBuffer->dwProductVersionMS & 0xFFFF,
lpBuffer->dwProductVersionLS >> 16,
lpBuffer->dwProductVersionLS & 0xFFFF);
}
mem_free_dbg(v2);
}
}
}
//----- (0041B06C) --------------------------------------------------------
LRESULT __stdcall init_palette(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
if ( Msg > WM_ERASEBKGND )
{
if ( Msg == WM_ACTIVATEAPP )
{
init_activate_window(hWnd, wParam);
}
else
{
if ( Msg == WM_QUERYNEWPALETTE )
{
SDrawRealizePalette();
return 1;
}
if ( Msg == WM_PALETTECHANGED && (HWND)wParam != hWnd )
SDrawRealizePalette();
}
}
else
{
switch ( Msg )
{
case WM_ERASEBKGND:
return 0;
case WM_CREATE:
ghMainWnd = hWnd;
break;
case WM_DESTROY:
init_cleanup(1);
ghMainWnd = 0;
PostQuitMessage(0);
break;
case WM_PAINT:
drawpanflag = 255;
break;
case WM_CLOSE:
return 0;
}
}
return DefWindowProcA(hWnd, Msg, wParam, lParam);
}
// 52571C: using guessed type int drawpanflag;
//----- (0041B105) --------------------------------------------------------
void __fastcall init_activate_window(HWND hWnd, bool activated)
{
LONG dwNewLong; // eax
window_activated = activated;
UiAppActivate(activated);
dwNewLong = GetWindowLongA(hWnd, GWL_STYLE);
if ( window_activated && fullscreen )
dwNewLong &= ~WS_SYSMENU;
else
dwNewLong |= WS_SYSMENU;
SetWindowLongA(hWnd, GWL_STYLE, dwNewLong);
if ( window_activated )
{
drawpanflag = 255;
ResetPal();
}
}
// 484364: using guessed type int fullscreen;
// 52571C: using guessed type int drawpanflag;
// 634980: using guessed type int window_activated;
//----- (0041B15F) --------------------------------------------------------
LRESULT __stdcall init_redraw_window(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
LRESULT result; // eax
if ( CurrentProc )
result = CurrentProc(hWnd, Msg, wParam, lParam);
else
result = init_palette(hWnd, Msg, wParam, lParam);
return result;
}
//----- (0041B184) --------------------------------------------------------
LRESULT (__stdcall *__fastcall SetWindowProc(void *func))(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT (__stdcall *result)(HWND, UINT, WPARAM, LPARAM); // eax
result = CurrentProc;
CurrentProc = (LRESULT (__stdcall *)(HWND, UINT, WPARAM, LPARAM))func;
return result;
}

51
Source/init.h Normal file
View File

@ -0,0 +1,51 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//init
extern _SNETVERSIONDATA fileinfo;
extern int init_cpp_init_value; // weak
extern int window_activated; // weak
extern char diablo_exe_path[260];
extern void *unused_mpq;
extern char patch_rt_mpq_path[260];
extern LRESULT (__stdcall *CurrentProc)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern void *diabdat_mpq;
extern char diabdat_mpq_path[260];
extern void *patch_rt_mpq;
extern int killed_mom_parent; // weak
extern bool screensaver_enabled_prev;
void __cdecl init_cpp_init();
void __fastcall init_cleanup(bool show_cursor);
void __cdecl init_run_office_from_start_menu();
void __fastcall init_run_office(char *dir);
void __fastcall init_disable_screensaver(bool disable);
void __cdecl init_create_window();
void __cdecl init_kill_mom_parent();
HWND __cdecl init_find_mom_parent();
void __cdecl init_await_mom_parent_exit();
void __cdecl init_archives();
void *__fastcall init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags, bool on_cd);
char *__fastcall init_strip_trailing_slash(char *path);
int __fastcall init_read_test_file(char *mpq_path, char *mpq_name, int flags, void **archive);
void __cdecl init_get_file_info();
LRESULT __stdcall init_palette(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
void __fastcall init_activate_window(HWND hWnd, bool activated);
LRESULT __stdcall init_redraw_window(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
LRESULT (__stdcall *__fastcall SetWindowProc(void *func))(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
/* data */
extern int init_inf; // weak
/* rdata */
extern char gszVersionNumber[260];
extern char gszProductName[260];

400
Source/interfac.cpp Normal file
View File

@ -0,0 +1,400 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
void *sgpBackCel;
float interfac_cpp_init_value;
int sgdwProgress;
int progress_id; // idb
int interfac_inf = 0x7F800000; // weak
unsigned char progress_bar_colours[3] = { 138u, 43u, 254u };
POINT32 progress_bar_screen_pos[3] = { { 53, 37 }, { 53, 421 }, { 53, 37 } };
//----- (0041B195) --------------------------------------------------------
struct interfac_cpp_init
{
interfac_cpp_init()
{
interfac_cpp_init_value = interfac_inf;
}
} _interfac_cpp_init;
// 47AE40: using guessed type int interfac_inf;
//----- (0041B1A0) --------------------------------------------------------
void __cdecl interface_msg_pump()
{
MSG Msg; // [esp+8h] [ebp-1Ch]
while ( PeekMessageA(&Msg, NULL, 0, 0, PM_REMOVE) )
{
if ( Msg.message != WM_QUIT )
{
TranslateMessage(&Msg);
DispatchMessageA(&Msg);
}
}
}
//----- (0041B1DF) --------------------------------------------------------
bool __cdecl IncProgress()
{
interface_msg_pump();
sgdwProgress += 15;
if ( (unsigned int)sgdwProgress > 0x216 )
sgdwProgress = 534;
if ( sgpBackCel )
DrawCutscene();
return (unsigned int)sgdwProgress >= 0x216;
}
//----- (0041B218) --------------------------------------------------------
void __cdecl DrawCutscene()
{
unsigned int v0; // esi
dx_lock_mutex();
CelDecodeOnly(64, 639, sgpBackCel, 1, 640);
v0 = 0;
if ( sgdwProgress )
{
do
DrawProgress(
progress_bar_screen_pos[progress_id].x + v0++ + 64,
progress_bar_screen_pos[progress_id].y + 160,
progress_id);
while ( v0 < sgdwProgress );
}
dx_unlock_mutex();
drawpanflag = 255;
scrollrt_draw_game_screen(0);
}
// 52571C: using guessed type int drawpanflag;
//----- (0041B28D) --------------------------------------------------------
void __fastcall DrawProgress(int screen_x, int screen_y, int progress_id)
{
_BYTE *v3; // eax
signed int v4; // ecx
v3 = (unsigned char *)gpBuffer + screen_y_times_768[screen_y] + screen_x;
v4 = 22;
do
{
*v3 = progress_bar_colours[progress_id];
v3 += 768;
--v4;
}
while ( v4 );
}
//----- (0041B2B6) --------------------------------------------------------
void __fastcall ShowProgress(int uMsg)
{
LRESULT (__stdcall *saveProc)(HWND, UINT, WPARAM, LPARAM); // edi
bool v3; // cl
int v4; // eax
int v5; // edx
signed int v7; // [esp-4h] [ebp-10h]
gbSomebodyWonGameKludge = 0;
plrmsg_delay(1);
saveProc = SetWindowProc(DisableInputWndProc);
interface_msg_pump();
ClearScreenBuffer();
scrollrt_draw_game_screen(1);
InitCutscene(uMsg);
BlackPalette();
DrawCutscene();
PaletteFadeIn(8);
IncProgress();
stream_update();
IncProgress();
switch ( uMsg )
{
case WM_DIABNEXTLVL:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
v4 = ++currlevel;
goto LABEL_38;
case WM_DIABPREVLVL:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
IncProgress();
FreeGameMem();
leveltype = gnLevelTypeTbl[--currlevel];
IncProgress();
v5 = 1;
goto LABEL_33;
case WM_DIABRTNLVL:
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
setlevel = 0;
FreeGameMem();
IncProgress();
GetReturnLvlPos();
v7 = 3;
goto LABEL_32;
case WM_DIABSETLVL:
SetReturnLvlPos();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
setlevel = 1;
leveltype = setlvltype;
FreeGameMem();
IncProgress();
v7 = 2;
goto LABEL_32;
case WM_DIABWARPLVL:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
GetPortalLevel();
IncProgress();
v7 = 5;
goto LABEL_32;
case WM_DIABTOWNWARP:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
IncProgress();
v7 = 6;
goto LABEL_32;
case WM_DIABTWARPUP:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
IncProgress();
v7 = 7;
LABEL_32:
v5 = v7;
LABEL_33:
v3 = 0;
goto LABEL_40;
case WM_DIABRETOWN:
IncProgress();
if ( gbMaxPlayers == 1 )
SaveLevel();
else
DeltaSaveLevel();
FreeGameMem();
currlevel = plr[myplr].plrlevel;
v4 = currlevel;
LABEL_38:
leveltype = gnLevelTypeTbl[v4];
IncProgress();
v3 = 0;
goto LABEL_39;
case WM_DIABNEWGAME:
IncProgress();
FreeGameMem();
IncProgress();
pfile_remove_temp_files();
v3 = 1;
LABEL_39:
v5 = 0;
LABEL_40:
LoadGameLevel(v3, v5);
goto LABEL_41;
case WM_DIABLOADGAME:
IncProgress();
LoadGame(1);
LABEL_41:
IncProgress();
break;
default:
break;
}
PaletteFadeOut(8);
FreeInterface();
SetWindowProc(saveProc);
NetSendCmdLocParam1(1u, CMD_PLAYER_JOINLEVEL, plr[myplr].WorldX, plr[myplr].WorldY, plr[myplr].plrlevel);
plrmsg_delay(0);
ResetPal();
if ( gbSomebodyWonGameKludge && plr[myplr].plrlevel == 16 )
PrepDoEnding();
gbSomebodyWonGameKludge = 0;
}
// 5BB1ED: using guessed type char leveltype;
// 5CF31C: using guessed type char setlvltype;
// 5CF31D: using guessed type char setlevel;
// 6761B8: using guessed type char gbSomebodyWonGameKludge;
// 679660: using guessed type char gbMaxPlayers;
//----- (0041B5F5) --------------------------------------------------------
void __cdecl FreeInterface()
{
void *v0; // ecx
v0 = sgpBackCel;
sgpBackCel = 0;
mem_free_dbg(v0);
}
//----- (0041B607) --------------------------------------------------------
void __fastcall InitCutscene(int interface_mode)
{
int v1; // eax
int v2; // eax
int v3; // eax
int v4; // eax
unsigned char *v5; // eax
char *v6; // ecx
int *v7; // eax
int v8; // eax
int v9; // eax
int v10; // eax
int v11; // eax
int v12; // eax
int v13; // eax
int v14; // eax
switch ( interface_mode )
{
case WM_DIABNEXTLVL:
v1 = gnLevelTypeTbl[currlevel];
if ( !v1 )
goto LABEL_31;
v2 = v1 - 1;
if ( !v2 )
goto LABEL_10;
v3 = v2 - 1;
if ( !v3 )
goto LABEL_9;
v4 = v3 - 1;
if ( !v4 )
goto LABEL_29;
if ( v4 != 1 )
goto LABEL_10;
if ( currlevel < 0xFu )
goto LABEL_28;
v5 = LoadFileInMem("Gendata\\Cutgate.CEL", 0);
v6 = "Gendata\\Cutgate.pal";
goto LABEL_30;
case WM_DIABPREVLVL:
v7 = &gnLevelTypeTbl[currlevel];
if ( !*(v7 - 1) )
goto LABEL_31;
v8 = *v7;
if ( !v8 )
goto LABEL_31;
v9 = v8 - 1;
if ( !v9 )
goto LABEL_10;
v10 = v9 - 1;
if ( !v10 )
{
LABEL_9:
sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0);
LoadPalette("Gendata\\Cut2.pal");
progress_id = 2;
goto LABEL_33;
}
v11 = v10 - 1;
if ( !v11 )
goto LABEL_29;
if ( v11 == 1 )
goto LABEL_28;
LABEL_10:
sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0);
LoadPalette("Gendata\\Cutl1d.pal");
progress_id = 0;
goto LABEL_33;
case WM_DIABRTNLVL:
case WM_DIABSETLVL:
if ( setlvlnum == SL_BONECHAMB )
goto LABEL_21;
if ( setlvlnum != SL_VILEBETRAYER )
goto LABEL_10;
v5 = LoadFileInMem("Gendata\\Cutportr.CEL", 0);
v6 = "Gendata\\Cutportr.pal";
goto LABEL_30;
case WM_DIABWARPLVL:
v5 = LoadFileInMem("Gendata\\Cutportl.CEL", 0);
v6 = "Gendata\\Cutportl.pal";
goto LABEL_30;
case WM_DIABTOWNWARP:
case WM_DIABTWARPUP:
v12 = gnLevelTypeTbl[plr[myplr].plrlevel];
if ( !v12 )
goto LABEL_31;
v13 = v12 - 2;
if ( !v13 )
{
LABEL_21:
sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0);
LoadPalette("Gendata\\Cut2.pal");
progress_id = SL_BONECHAMB;
goto LABEL_33;
}
v14 = v13 - 1;
if ( v14 )
{
if ( v14 != 1 )
goto LABEL_33;
LABEL_28:
v5 = LoadFileInMem("Gendata\\Cut4.CEL", 0);
v6 = "Gendata\\Cut4.pal";
}
else
{
LABEL_29:
v5 = LoadFileInMem("Gendata\\Cut3.CEL", 0);
v6 = "Gendata\\Cut3.pal";
}
LABEL_30:
sgpBackCel = v5;
LoadPalette(v6);
progress_id = 1;
LABEL_33:
sgdwProgress = 0;
return;
case WM_DIABRETOWN:
LABEL_31:
v5 = LoadFileInMem("Gendata\\Cuttt.CEL", 0);
v6 = "Gendata\\Cuttt.pal";
goto LABEL_30;
case WM_DIABNEWGAME:
case WM_DIABLOADGAME:
v5 = LoadFileInMem("Gendata\\Cutstart.CEL", 0);
v6 = "Gendata\\Cutstart.pal";
goto LABEL_30;
default:
TermMsg("Unknown progress mode");
goto LABEL_33;
}
}
// 5CCB10: using guessed type char setlvlnum;

31
Source/interfac.h Normal file
View File

@ -0,0 +1,31 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//interfac
extern void *sgpBackCel;
extern float interfac_cpp_init_value;
extern int sgdwProgress;
extern int progress_id; // idb
void __cdecl interfac_cpp_init();
void __cdecl interface_msg_pump();
bool __cdecl IncProgress();
void __cdecl DrawCutscene();
void __fastcall DrawProgress(int screen_x, int screen_y, int progress_id);
void __fastcall ShowProgress(int uMsg);
void __cdecl FreeInterface();
void __fastcall InitCutscene(int interface_mode);
/* data */
extern int interfac_inf; // weak
extern unsigned char progress_bar_colours[3];
extern POINT32 progress_bar_screen_pos[3];

3376
Source/inv.cpp Normal file

File diff suppressed because it is too large Load Diff

65
Source/inv.h Normal file
View File

@ -0,0 +1,65 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//inv
extern int invflag;
extern void *pInvCels;
extern int drawsbarflag; // idb
extern int sgdwLastTime; // check name
void __cdecl FreeInvGFX();
void __cdecl InitInv();
void __fastcall InvDrawSlotBack(int X, int Y, int W, int H);
void __cdecl DrawInv();
void __cdecl DrawInvBelt();
int __fastcall AutoPlace(int pnum, int ii, int sx, int sy, int saveflag);
int __fastcall SpecialAutoPlace(int pnum, int ii, int sx, int sy, int saveflag);
int __fastcall GoldAutoPlace(int pnum);
int __fastcall WeaponAutoPlace(int pnum);
int __fastcall SwapItem(ItemStruct *a, ItemStruct *b);
void __fastcall CheckInvPaste(int pnum, int mx, int my);
void __fastcall CheckInvSwap(int pnum, int bLoc, int idx, int wCI, int seed, int bId);
void __fastcall CheckInvCut(int pnum, int mx, int my);
void __fastcall inv_update_rem_item(int pnum, int iv);
void __fastcall RemoveInvItem(int pnum, int iv);
void __fastcall RemoveSpdBarItem(int pnum, int iv);
void __cdecl CheckInvItem();
void __cdecl CheckInvScrn();
void __fastcall CheckItemStats(int pnum);
void __fastcall CheckBookLevel(int pnum);
void __fastcall CheckQuestItem(int pnum);
void __fastcall InvGetItem(int pnum, int ii);
void __fastcall AutoGetItem(int pnum, int ii);
int __fastcall FindGetItem(int indx, unsigned short ci, int iseed);
void __fastcall SyncGetItem(int x, int y, int idx, unsigned short ci, int iseed);
int __fastcall CanPut(int i, int j);
int __cdecl TryInvPut();
void __fastcall DrawInvMsg(char *msg);
int __fastcall InvPutItem(int pnum, int x, int y);
int __fastcall SyncPutItem(int pnum, int x, int y, int idx, int icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, unsigned int ibuff);
int __cdecl CheckInvHLight();
void __fastcall RemoveScroll(int pnum);
bool __cdecl UseScroll();
void __fastcall UseStaffCharge(int pnum);
bool __cdecl UseStaff();
void __cdecl StartGoldDrop();
int __fastcall UseInvItem(int pnum, int cii);
void __cdecl DoTelekinesis();
int __fastcall CalculateGold(int pnum);
int __cdecl DropItemBeforeTrig();
/* data */
extern InvXY InvRect[73];
/* rdata */
extern int AP2x2Tbl[10]; // weak

5803
Source/items.cpp Normal file

File diff suppressed because it is too large Load Diff

153
Source/items.h Normal file
View File

@ -0,0 +1,153 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//items
extern int itemactive[127];
extern int uitemflag;
extern int itemavail[127];
extern ItemStruct curruitem;
extern ItemGetRecordStruct itemrecord[127];
extern ItemStruct item[128];
extern char itemhold[3][3];
extern char byte_641234[28]; /* check if part of above */
extern int Item2Frm[35];
extern int UniqueItemFlag[128];
extern int numitems;
extern int gnNumGetRecords;
void __cdecl InitItemGFX();
bool __fastcall ItemPlace(int x, int y);
void __cdecl AddInitItems();
void __cdecl InitItems();
void __fastcall CalcPlrItemVals(int p, bool Loadgfx);
void __fastcall CalcPlrScrolls(int p);
void __fastcall CalcPlrStaff(int pnum);
void __fastcall CalcSelfItems(int pnum);
void __fastcall CalcPlrItemMin(int pnum);
bool __fastcall ItemMinStats(PlayerStruct *p, ItemStruct *x);
void __fastcall CalcPlrBookVals(int p);
void __fastcall CalcPlrInv(int p, bool Loadgfx);
void __fastcall SetPlrHandItem(ItemStruct *h, int idata);
void __fastcall GetPlrHandSeed(ItemStruct *h);
void __fastcall GetGoldSeed(int pnum, ItemStruct *h);
void __fastcall SetPlrHandSeed(ItemStruct *h, int iseed);
void __fastcall SetPlrHandGoldCurs(ItemStruct *h);
void __fastcall CreatePlrItems(int p);
bool __fastcall ItemSpaceOk(int i, int j);
bool __fastcall GetItemSpace(int x, int y, char inum);
void __fastcall GetSuperItemSpace(int x, int y, char inum);
void __fastcall GetSuperItemLoc(int x, int y, int *xx, int *yy);
void __fastcall CalcItemValue(int i);
void __fastcall GetBookSpell(int i, int lvl);
void __fastcall GetStaffPower(int i, int lvl, int bs, unsigned char onlygood);
void __fastcall GetStaffSpell(int i, int lvl, unsigned char onlygood);
void __fastcall GetItemAttrs(int i, int idata, int lvl);
int __fastcall RndPL(int param1, int param2);
int __fastcall PLVal(int pv, int p1, int p2, int minv, int maxv);
void __fastcall SaveItemPower(int i, int power, int param1, int param2, int minval, int maxval, int multval);
void __fastcall GetItemPower(int i, int minlvl, int maxlvl, int flgs, int onlygood);
void __fastcall GetItemBonus(int i, int idata, int minlvl, int maxlvl, int onlygood);
void __fastcall SetupItem(int i);
int __fastcall RndItem(int m);
int __fastcall RndUItem(int m);
int __cdecl RndAllItems();
int __fastcall RndTypeItems(int itype, int imid);
int __fastcall CheckUnique(int i, int lvl, int uper, bool recreate);
void __fastcall GetUniqueItem(int i, int uid);
void __fastcall SpawnUnique(int uid, int x, int y);
void __fastcall ItemRndDur(int ii);
void __fastcall SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood, int recreate, int pregen);
void __fastcall SpawnItem(int m, int x, int y, unsigned char sendmsg);
void __fastcall CreateItem(int uid, int x, int y);
void __fastcall CreateRndItem(int x, int y, unsigned char onlygood, unsigned char sendmsg, int delta);
void __fastcall SetupAllUseful(int ii, int iseed, int lvl);
void __fastcall CreateRndUseful(int pnum, int x, int y, unsigned char sendmsg);
void __fastcall CreateTypeItem(int x, int y, unsigned char onlygood, int itype, int imisc, int sendmsg, int delta);
void __fastcall RecreateItem(int ii, int idx, unsigned short ic, int iseed, int ivalue);
void __fastcall RecreateEar(int ii, unsigned short ic, int iseed, unsigned char Id, int dur, int mdur, int ch, int mch, int ivalue, int ibuff);
void __fastcall SpawnQuestItem(int itemid, int x, int y, int randarea, int selflag);
void __cdecl SpawnRock();
void __fastcall RespawnItem(int i, bool FlipFlag);
void __fastcall DeleteItem(int ii, int i);
void __cdecl ItemDoppel();
void __cdecl ProcessItems();
void __cdecl FreeItemGFX();
void __fastcall GetItemFrm(int i);
void __fastcall GetItemStr(int i);
void __fastcall CheckIdentify(int pnum, int cii);
void __fastcall DoRepair(int pnum, int cii);
void __fastcall RepairItem(ItemStruct *i, int lvl);
void __fastcall DoRecharge(int pnum, int cii);
void __fastcall RechargeItem(ItemStruct *i, int r);
void __fastcall PrintItemOil(char IDidx);
void __fastcall PrintItemPower(char plidx, ItemStruct *x);
void __cdecl DrawUBack();
void __fastcall PrintUString(int x, int y, int cjustflag, char *str, int col);
void __fastcall DrawULine(int y);
void __cdecl DrawUniqueInfo();
void __fastcall PrintItemMisc(ItemStruct *x);
void __fastcall PrintItemDetails(ItemStruct *x);
void __fastcall PrintItemDur(ItemStruct *x);
void __fastcall UseItem(int p, int Mid, int spl);
bool __fastcall StoreStatOk(ItemStruct *h);
bool __fastcall SmithItemOk(int i);
int __fastcall RndSmithItem(int lvl);
void __fastcall BubbleSwapItem(ItemStruct *a, ItemStruct *b);
void __cdecl SortSmith();
void __fastcall SpawnSmith(int lvl);
bool __fastcall PremiumItemOk(int i);
int __fastcall RndPremiumItem(int minlvl, int maxlvl);
void __fastcall SpawnOnePremium(int i, int plvl);
void __fastcall SpawnPremium(int lvl);
bool __fastcall WitchItemOk(int i);
int __fastcall RndWitchItem(int lvl);
void __cdecl SortWitch();
void __fastcall WitchBookLevel(int ii);
void __fastcall SpawnWitch(int lvl);
int __fastcall RndBoyItem(int lvl);
void __fastcall SpawnBoy(int lvl);
bool __fastcall HealerItemOk(int i);
int __fastcall RndHealerItem(int lvl);
void __cdecl SortHealer();
void __fastcall SpawnHealer(int lvl);
void __cdecl SpawnStoreGold();
void __fastcall RecreateSmithItem(int ii, int idx, int plvl, int iseed);
void __fastcall RecreatePremiumItem(int ii, int idx, int lvl, int iseed);
void __fastcall RecreateBoyItem(int ii, int idx, int lvl, int iseed);
void __fastcall RecreateWitchItem(int ii, int idx, int lvl, int iseed);
void __fastcall RecreateHealerItem(int ii, int idx, int lvl, int iseed);
void __fastcall RecreateTownItem(int ii, int idx, unsigned short icreateinfo, int iseed, int ivalue);
void __cdecl RecalcStoreStats();
int __cdecl ItemNoFlippy();
void __fastcall CreateSpellBook(int x, int y, int ispell, bool sendmsg, int delta);
void __fastcall CreateMagicItem(int x, int y, int imisc, int icurs, int sendmsg, int delta);
bool __fastcall GetItemRecord(int dwSeed, int CI, int indx);
void __fastcall NextItemRecord(int i);
void __fastcall SetItemRecord(int dwSeed, int CI, int indx);
void __fastcall PutItemRecord(int seed, int ci, int index);
/* data */
extern PLStruct PL_Prefix[84];
extern PLStruct PL_Suffix[96];
extern UItemStruct UniqueItemList[91];
/* rdata */
extern ItemDataStruct AllItemsList[157];
extern unsigned char ItemCAnimTbl[169];
extern char *ItemDropStrs[35];
extern unsigned char ItemAnimLs[35];
extern int ItemDropSnds[35];
extern int ItemInvSnds[35];
extern int idoppely; // weak
extern int premiumlvladd[6];

1787
Source/lighting.cpp Normal file

File diff suppressed because it is too large Load Diff

58
Source/lighting.h Normal file
View File

@ -0,0 +1,58 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//lighting
extern LightListStruct VisionList[32];
extern char lightactive[32];
extern LightListStruct LightList[32];
extern int numlights;
extern char dung_map_radius[2048]; /* char [16][128] */
extern int dovision; // weak
extern int numvision;
extern char lightmax; // weak
extern int dolighting; // weak
extern char dung_map_rgba[16384]; /* int [64][64] short [64][128] char [64][256] */
extern int visionid;
extern char *pLightTbl; /* todo: struct? */
extern int lightflag; // weak
void __fastcall SetLightFX(int *x, int *y, short *s_r, short *s_g, int *s_b, int *d_r, int *d_g, int *d_b);
void __fastcall DoLighting(int nXPos, int nYPos, int nRadius, int Lnum);
void __fastcall DoUnLight(int nXPos, int nYPos, int nRadius);
void __fastcall DoUnVision(int nXPos, int nYPos, int nRadius);
void __fastcall DoVision(int nXPos, int nYPos, int nRadius, unsigned char doautomap, int visible);
void __cdecl FreeLightTable();
void __cdecl InitLightTable();
void __cdecl MakeLightTable();
void __cdecl InitLightMax();
void __cdecl InitLighting();
int __fastcall AddLight(int x, int y, int r);
void __fastcall AddUnLight(int i);
void __fastcall ChangeLightRadius(int i, int r);
void __fastcall ChangeLightXY(int i, int x, int y);
void __fastcall ChangeLightOff(int i, int x, int y);
void __fastcall ChangeLight(int i, int x, int y, int r);
void __cdecl ProcessLightList();
void __cdecl SavePreLighting();
void __cdecl InitVision();
int __fastcall AddVision(int x, int y, int r, bool mine);
void __fastcall ChangeVisionRadius(int id, int r);
void __fastcall ChangeVisionXY(int id, int x, int y);
void __cdecl ProcessVisionList();
void __cdecl lighting_color_cycling();
/* rdata */
extern CircleCoord CrawlTable;
extern void *pCrawlTable[19];
extern unsigned char vCrawlTable[23][30];
extern unsigned char byte_49463C[18][18];
extern unsigned char RadiusAdj[23];

1306
Source/loadsave.cpp Normal file

File diff suppressed because it is too large Load Diff

46
Source/loadsave.h Normal file
View File

@ -0,0 +1,46 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//loadsave
extern void *tbuff;
void __fastcall LoadGame(bool firstflag);
char __cdecl BLoad();
int __cdecl ILoad();
int __cdecl ILoad_2();
bool __cdecl OLoad();
void __fastcall LoadPlayer(int i);
void __fastcall LoadMonster(int i);
void __fastcall LoadMissile(int i);
void __fastcall LoadObject(int i);
void __fastcall LoadItem(int i);
void __fastcall LoadPremium(int i);
void __fastcall LoadQuest(int i);
void __fastcall LoadLighting(int i);
void __fastcall LoadVision(int i);
void __fastcall LoadPortal(int i);
void __cdecl SaveGame();
void __fastcall BSave(char v);
void __fastcall ISave(int v);
void __fastcall ISave_2(int v);
void __fastcall OSave(unsigned char v);
void __fastcall SavePlayer(int i);
void __fastcall SaveMonster(int i);
void __fastcall SaveMissile(int i);
void __fastcall SaveObject(int i);
void __fastcall SaveItem(int i);
void __fastcall SavePremium(int i);
void __fastcall SaveQuest(int i);
void __fastcall SaveLighting(int i);
void __fastcall SaveVision(int i);
void __fastcall SavePortal(int i);
void __cdecl SaveLevel();
void __cdecl LoadLevel();

248
Source/logging.cpp Normal file
View File

@ -0,0 +1,248 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int log_cpp_init_value; // weak
static CRITICAL_SECTION sgMemCrit;
CHAR FileName[260]; // idb
char log_buffer[388];
LPCVOID lpAddress; // idb
DWORD nNumberOfBytesToWrite; // idb
int log_inf = 0x7F800000; // weak
/* rdata */
int log_not_created = 1; // weak
HANDLE log_file = (HANDLE)0xFFFFFFFF; // idb
//----- (004279F7) --------------------------------------------------------
struct log_cpp_init_1
{
log_cpp_init_1()
{
log_cpp_init_value = log_inf;
}
} _log_cpp_init_1;
// 47F070: using guessed type int log_inf;
// 646A30: using guessed type int log_cpp_init_value;
//----- (00427A02) --------------------------------------------------------
struct log_cpp_init_2
{
log_cpp_init_2()
{
log_init_mutex();
j_log_cleanup_mutex();
}
} _log_cpp_init_2;
//----- (00427A0C) --------------------------------------------------------
void __cdecl log_init_mutex()
{
InitializeCriticalSection(&sgMemCrit);
}
//----- (00427A18) --------------------------------------------------------
void __cdecl j_log_cleanup_mutex()
{
atexit(log_cleanup_mutex);
}
//----- (00427A24) --------------------------------------------------------
void __cdecl log_cleanup_mutex()
{
DeleteCriticalSection(&sgMemCrit);
}
//----- (00427A30) --------------------------------------------------------
void __cdecl log_flush(bool force_close)
{
void *v1; // eax
DWORD NumberOfBytesWritten; // [esp+8h] [ebp-4h]
EnterCriticalSection(&sgMemCrit);
if ( nNumberOfBytesToWrite )
{
if ( log_file == (HANDLE)-1 )
{
v1 = log_create();
log_file = v1;
if ( v1 == (void *)-1 )
{
nNumberOfBytesToWrite = 0;
return;
}
SetFilePointer(v1, 0, NULL, FILE_END);
}
WriteFile(log_file, lpAddress, nNumberOfBytesToWrite, &NumberOfBytesWritten, 0);
nNumberOfBytesToWrite = 0;
}
if ( force_close && log_file != (HANDLE)-1 )
{
CloseHandle(log_file);
log_file = (HANDLE)-1;
}
LeaveCriticalSection(&sgMemCrit);
}
//----- (00427AC2) --------------------------------------------------------
void *__cdecl log_create()
{
char *v0; // eax
void *v1; // ebx
HANDLE v2; // eax
char *v3; // edx
char Filename[260]; // [esp+Ch] [ebp-15Ch]
VS_FIXEDFILEINFO file_info; // [esp+110h] [ebp-58h]
char Buffer[32]; // [esp+144h] [ebp-24h]
DWORD pcbBuffer; // [esp+164h] [ebp-4h]
if ( log_not_created )
{
if ( GetModuleFileNameA(0, Filename, 0x104u) && (v0 = strrchr(Filename, '\\')) != 0 )
v0[1] = 0;
else
Filename[0] = 0;
pcbBuffer = 32;
if ( !GetUserNameA(Buffer, &pcbBuffer) )
Buffer[0] = 0;
log_get_version(&file_info);
_snprintf(
FileName,
0x104u,
"%s%s%02u%02u%02u.ERR",
Filename,
Buffer,
_LOWORD(file_info.dwProductVersionMS),
file_info.dwProductVersionLS >> 16,
_LOWORD(file_info.dwProductVersionLS));
}
v1 = (void *)-1;
for ( pcbBuffer = log_not_created == 0; (signed int)pcbBuffer < 2; ++pcbBuffer )
{
v2 = CreateFileA(FileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
v1 = v2;
if ( v2 != (HANDLE)-1 )
{
if ( GetFileSize(v2, 0) > 0x10000 )
SetEndOfFile(v1);
break;
}
v3 = strrchr(FileName, '\\');
if ( !v3 )
v3 = FileName;
strcpy(Filename, "c:\\");
memset(&Filename[4], 0, 0x100u);
strcat(Filename, v3);
strcpy(FileName, Filename);
}
log_not_created = 0;
return v1;
}
// 4947D4: using guessed type int log_not_created;
//----- (00427C18) --------------------------------------------------------
void __fastcall log_get_version(VS_FIXEDFILEINFO *file_info)
{
DWORD v1; // eax
DWORD v2; // esi
void *v3; // ebx
unsigned int v4; // eax
char Filename[260]; // [esp+8h] [ebp-114h]
DWORD dwHandle; // [esp+10Ch] [ebp-10h]
LPVOID lpBuffer; // [esp+110h] [ebp-Ch]
unsigned int puLen; // [esp+114h] [ebp-8h]
void *v9; // [esp+118h] [ebp-4h]
v9 = file_info;
memset(file_info, 0, 0x34u);
if ( GetModuleFileNameA(0, Filename, 0x104u) )
{
v1 = GetFileVersionInfoSizeA(Filename, &dwHandle);
v2 = v1;
if ( v1 )
{
v3 = VirtualAlloc(0, v1, 0x1000u, 4u);
if ( GetFileVersionInfoA(Filename, 0, v2, v3) && VerQueryValueA(v3, "\\", &lpBuffer, &puLen) )
{
v4 = puLen;
if ( puLen >= 0x34 )
v4 = 52;
memcpy(v9, lpBuffer, v4);
}
VirtualFree(v3, 0, 0x8000u);
}
}
}
//----- (00427CC9) --------------------------------------------------------
void log_printf(char *pszFmt, ...)
{
size_t v1; // edi
char *v2; // eax
char v3[512]; // [esp+Ch] [ebp-200h]
va_list va; // [esp+218h] [ebp+Ch]
va_start(va, pszFmt);
EnterCriticalSection(&sgMemCrit);
_vsnprintf(v3, 0x200u, pszFmt, va);
v3[511] = 0;
v1 = strlen(v3);
if ( v1 + nNumberOfBytesToWrite > 0x1000 )
log_flush(0);
v2 = (char *)lpAddress;
if ( lpAddress
|| (v2 = (char *)VirtualAlloc((LPVOID)lpAddress, 0x1000u, 0x1000u, 4u),
nNumberOfBytesToWrite = 0,
(lpAddress = v2) != 0) )
{
memcpy(&v2[nNumberOfBytesToWrite], v3, v1);
nNumberOfBytesToWrite += v1;
}
LeaveCriticalSection(&sgMemCrit);
}
//----- (00427D75) --------------------------------------------------------
void __cdecl log_dump_computer_info()
{
char Buffer[64]; // [esp+0h] [ebp-88h]
VS_FIXEDFILEINFO file_info; // [esp+40h] [ebp-48h]
struct _SYSTEMTIME SystemTime; // [esp+74h] [ebp-14h]
DWORD pcbBuffer; // [esp+84h] [ebp-4h]
GetLocalTime(&SystemTime);
pcbBuffer = 64;
if ( !GetUserNameA(Buffer, &pcbBuffer) )
Buffer[0] = 0;
log_get_version(&file_info);
log_printf(
"\r\n"
"------------------------------------------------------\r\n"
"PROGRAM VERSION: %d.%d.%d.%d\r\n"
"COMPUTER NAME: %s\r\n"
"TIME: %02u/%02u/%02u %02u:%02u:%02u\r\n"
"INFO: %s\r\n"
"\r\n",
file_info.dwProductVersionMS >> 16,
_LOWORD(file_info.dwProductVersionMS),
file_info.dwProductVersionLS >> 16,
_LOWORD(file_info.dwProductVersionLS),
Buffer,
SystemTime.wMonth,
SystemTime.wDay,
SystemTime.wYear % 100,
SystemTime.wHour,
SystemTime.wMinute,
SystemTime.wSecond,
log_buffer);
}

37
Source/logging.h Normal file
View File

@ -0,0 +1,37 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//logging
extern int log_cpp_init_value; // weak
extern CHAR FileName[260]; // idb
extern char log_buffer[388];
extern LPCVOID lpAddress; // idb
extern DWORD nNumberOfBytesToWrite; // idb
void __cdecl log_cpp_init_1();
void __cdecl log_cpp_init_2();
void __cdecl log_init_mutex();
void __cdecl j_log_cleanup_mutex();
void __cdecl log_cleanup_mutex();
void __cdecl log_flush(bool force_close);
void *__cdecl log_create(); // should be HANDLE
void __fastcall log_get_version(VS_FIXEDFILEINFO *file_info);
void log_printf(char *pszFmt, ...); // LogMessage
void __cdecl log_dump_computer_info();
/* data */
extern int log_inf; // weak
/* rdata */
extern int log_not_created; // weak
extern HANDLE log_file; // idb

206
Source/mainmenu.cpp Normal file
View File

@ -0,0 +1,206 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int mainmenu_cpp_init_value; // weak
char chr_name_str[16];
int mainmenu_inf = 0x7F800000; // weak
/* rdata */
int menu_music_track_id = 5; // idb
//----- (00427E13) --------------------------------------------------------
struct mainmenu_cpp_init
{
mainmenu_cpp_init()
{
mainmenu_cpp_init_value = mainmenu_inf;
}
} _mainmenu_cpp_init;
// 47F074: using guessed type int mainmenu_inf;
// 646CE0: using guessed type int mainmenu_cpp_init_value;
//----- (00427E1E) --------------------------------------------------------
void __cdecl mainmenu_refresh_music()
{
int v0; // eax
music_start(menu_music_track_id);
v0 = menu_music_track_id;
do
{
if ( ++v0 == 6 )
v0 = 0;
}
while ( !v0 || v0 == 1 );
menu_music_track_id = v0;
}
//----- (00427E45) --------------------------------------------------------
void __stdcall mainmenu_create_hero(char *a1, char *a2)
{
// char *v2; // [esp-14h] [ebp-14h]
if ( UiValidPlayerName(a1) ) /* v2 */
pfile_create_save_file(a1, a2);
}
//----- (00427E62) --------------------------------------------------------
int __stdcall mainmenu_select_hero_dialog(int u1, int u2, int u3, int u4, int mode, char *cname, int clen, char *cdesc, int cdlen, int *multi) /* fix args */
{
int v10; // eax
int a6; // [esp+8h] [ebp-8h]
int a5; // [esp+Ch] [ebp-4h]
a6 = 1;
a5 = 0;
if ( gbMaxPlayers == 1 )
{
if ( !UiSelHeroSingDialog(
pfile_ui_set_hero_infos,
pfile_ui_save_create,
pfile_delete_save,
pfile_ui_set_class_stats,
&a5,
chr_name_str,
&gnDifficulty) )
TermMsg("Unable to display SelHeroSing");
if ( a5 == 2 )
{
dword_5256E8 = 1;
goto LABEL_6;
}
dword_5256E8 = 0;
}
else if ( !UiSelHeroMultDialog(
pfile_ui_set_hero_infos,
pfile_ui_save_create,
pfile_delete_save,
pfile_ui_set_class_stats,
&a5,
&a6,
chr_name_str) )
{
TermMsg("Can't load multiplayer dialog");
}
if ( a5 == 4 )
{
SErrSetLastError(1223);
return 0;
}
LABEL_6:
pfile_create_player_description(cdesc, cdlen);
if ( multi )
{
if ( mode == 'BNET' )
v10 = a6 || !plr[myplr].pBattleNet;
else
v10 = a6;
*multi = v10;
}
if ( cname )
{
if ( clen )
SStrCopy(cname, chr_name_str, clen);
}
return 1;
}
// 5256E8: using guessed type int dword_5256E8;
// 679660: using guessed type char gbMaxPlayers;
//----- (00427F76) --------------------------------------------------------
void __fastcall mainmenu_action(int option)
{
int v1; // eax
int a2; // [esp+0h] [ebp-4h]
a2 = option;
mainmenu_refresh_music();
do
{
while ( 1 )
{
a2 = 0;
if ( !UiMainMenuDialog("Diablo v1.09", &a2, effects_play_sound, 30) )
TermMsg("Unable to display mainmenu");
if ( a2 == 1 )
break;
switch ( a2 )
{
case MAINMENU_MULTIPLAYER:
v1 = mainmenu_multi_player();
goto LABEL_15;
case MAINMENU_REPLAY_INTRO:
goto LABEL_10;
case MAINMENU_SHOW_CREDITS:
UiCreditsDialog(16);
break;
case MAINMENU_EXIT_DIABLO:
goto LABEL_16;
case MAINMENU_ATTRACT_MODE:
LABEL_10:
if ( window_activated )
mainmenu_play_intro();
break;
}
}
v1 = mainmenu_single_player();
LABEL_15:
;
}
while ( v1 );
LABEL_16:
music_stop();
}
// 634980: using guessed type int window_activated;
//----- (00427FEC) --------------------------------------------------------
int __cdecl mainmenu_single_player()
{
gbMaxPlayers = 1;
return mainmenu_init_menu(1);
}
// 679660: using guessed type char gbMaxPlayers;
//----- (00427FFA) --------------------------------------------------------
int __fastcall mainmenu_init_menu(int a1)
{
int v1; // esi
int v3; // esi
v1 = a1;
if ( a1 == 4 )
return 1;
music_stop();
v3 = diablo_init_menu(v1 != 2, v1 != 3);
if ( v3 )
mainmenu_refresh_music();
return v3;
}
//----- (00428030) --------------------------------------------------------
int __cdecl mainmenu_multi_player()
{
gbMaxPlayers = 4;
return mainmenu_init_menu(3);
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0042803F) --------------------------------------------------------
void __cdecl mainmenu_play_intro()
{
music_stop();
play_movie("gendata\\diablo1.smk", 1);
mainmenu_refresh_music();
}

32
Source/mainmenu.h Normal file
View File

@ -0,0 +1,32 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//mainmenu
extern int mainmenu_cpp_init_value; // weak
extern char chr_name_str[16];
void __cdecl mainmenu_cpp_init();
void __cdecl mainmenu_refresh_music();
void __stdcall mainmenu_create_hero(char *, char *);
int __stdcall mainmenu_select_hero_dialog(int u1, int u2, int u3, int u4, int mode, char *cname, int clen, char *cdesc, int cdlen, int *multi);
void __fastcall mainmenu_action(int option);
int __cdecl mainmenu_single_player();
int __fastcall mainmenu_init_menu(int a1);
int __cdecl mainmenu_multi_player();
void __cdecl mainmenu_play_intro();
/* data */
extern int mainmenu_inf; // weak
/* rdata */
extern int menu_music_track_id; // idb

339
Source/minitext.cpp Normal file
View File

@ -0,0 +1,339 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int qtexty; // weak
char *qtextptr;
int qtextSpd; // weak
char qtextflag; // weak
int scrolltexty; // weak
int sgLastScroll; // weak
void *pMedTextCels;
void *pTextBoxCels;
unsigned char mfontframe[127] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 37, 49, 38, 0, 39, 40, 47,
42, 43, 41, 45, 52, 44, 53, 55, 36, 27,
28, 29, 30, 31, 32, 33, 34, 35, 51, 50,
48, 46, 49, 54, 0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 42, 0, 43, 0, 0, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 48, 0, 49, 0
};
unsigned char mfontkern[56] =
{
5, 15, 10, 13, 14, 10, 9, 13, 11, 5,
5, 11, 10, 16, 13, 16, 10, 15, 12, 10,
14, 17, 17, 22, 17, 16, 11, 5, 11, 11,
11, 10, 11, 11, 11, 11, 15, 5, 10, 18,
15, 8, 6, 6, 7, 10, 9, 6, 10, 10,
5, 5, 5, 5, 11, 12
};
/* rdata */
int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 };
//----- (00428056) --------------------------------------------------------
void __cdecl FreeQuestText()
{
void *v0; // ecx
void *v1; // ecx
v0 = pMedTextCels;
pMedTextCels = 0;
mem_free_dbg(v0);
v1 = pTextBoxCels;
pTextBoxCels = 0;
mem_free_dbg(v1);
}
//----- (0042807A) --------------------------------------------------------
void __cdecl InitQuestText()
{
unsigned char *v0; // eax
pMedTextCels = LoadFileInMem("Data\\MedTextS.CEL", 0);
v0 = LoadFileInMem("Data\\TextBox.CEL", 0);
qtextflag = 0;
pTextBoxCels = v0;
}
// 646D00: using guessed type char qtextflag;
//----- (004280A4) --------------------------------------------------------
void __fastcall InitQTextMsg(int m)
{
if ( alltext[m].scrlltxt )
{
questlog = 0;
qtextptr = alltext[m].txtstr;
qtextflag = 1;
qtexty = 500;
sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1]; /* double check offset */
scrolltexty = sgLastScroll;
qtextSpd = GetTickCount();
}
PlaySFX(alltext[m].sfxnr);
}
// 646CF4: using guessed type int qtexty;
// 646CFC: using guessed type int qtextSpd;
// 646D00: using guessed type char qtextflag;
// 646D04: using guessed type int scrolltexty;
// 646D08: using guessed type int sgLastScroll;
// 69BD04: using guessed type int questlog;
//----- (00428104) --------------------------------------------------------
void __cdecl DrawQTextBack()
{
char *v0; // edi
signed int v1; // edx
signed int v2; // ecx
int v3; // edi
signed int v4; // ecx
_BYTE *v5; // edi
signed int v6; // ecx
CelDecodeOnly(88, 487, pTextBoxCels, 1, 591);
v0 = &gpBuffer->row[324].pixels[27];
v1 = 148;
do
{
v2 = 292;
do
{
*v0 = 0;
v0 += 2;
--v2;
}
while ( v2 );
*v0 = 0;
v3 = (int)(v0 - 1352);
v4 = 292;
do
{
v5 = (_BYTE *)(v3 + 1);
*v5 = 0;
v3 = (int)(v5 + 1);
--v4;
}
while ( v4 );
v0 = (char *)(v3 - 1352);
--v1;
}
while ( v1 );
v6 = 292;
do
{
*v0 = 0;
v0 += 2;
--v6;
}
while ( v6 );
*v0 = 0;
}
//----- (00428160) --------------------------------------------------------
void __fastcall PrintQTextChr(int screen_x, int screen_y, char *cel_buf, int frame)
{
char *v4; // ebx
char *v5; // esi
char *v6; // edi
int v7; // ebx
signed int v8; // edx
unsigned int v9; // eax
unsigned int v10; // ecx
char v11; // cf
unsigned int v12; // ecx
char *v13; // [esp+14h] [ebp-8h]
char *v14; // [esp+18h] [ebp-4h]
v13 = (char *)gpBuffer + screen_y_times_768[209];
v14 = (char *)gpBuffer + screen_y_times_768[469];
v4 = &cel_buf[4 * frame];
v5 = &cel_buf[*(_DWORD *)v4];
v6 = (char *)gpBuffer + screen_y_times_768[screen_y] + screen_x;
v7 = (int)&v5[*((_DWORD *)v4 + 1) - *(_DWORD *)v4];
do
{
v8 = 22;
do
{
while ( 1 )
{
v9 = (unsigned char)*v5++;
if ( (v9 & 0x80u) == 0 )
break;
_LOBYTE(v9) = -(char)v9;
v6 += v9;
v8 -= v9;
if ( !v8 )
goto LABEL_15;
}
v8 -= v9;
if ( v6 < v13 || v6 > v14 )
{
v5 += v9;
v6 += v9;
}
else
{
v10 = v9 >> 1;
if ( !(v9 & 1) || (*v6 = *v5, ++v5, ++v6, v10) )
{
v11 = v10 & 1;
v12 = v9 >> 2;
if ( !v11 || (*(_WORD *)v6 = *(_WORD *)v5, v5 += 2, v6 += 2, v12) )
{
qmemcpy(v6, v5, 4 * v12);
v5 += 4 * v12;
v6 += 4 * v12;
}
}
}
}
while ( v8 );
LABEL_15:
v6 -= 790;
}
while ( (char *)v7 != v5 );
}
//----- (00428202) --------------------------------------------------------
void __cdecl DrawQText()
{
char *v0; // edi
signed int v1; // edx
int v2; // ecx
char *i; // esi
unsigned char v4; // al
unsigned char v5; // al
char v6; // dl
char *v7; // eax
unsigned char v8; // al
char *v9; // esi
unsigned char v10; // bl
DWORD v11; // eax
char qstr[128]; // [esp+8h] [ebp-90h]
char *v13; // [esp+88h] [ebp-10h]
int v14; // [esp+8Ch] [ebp-Ch]
int screen_y; // [esp+90h] [ebp-8h]
int screen_x; // [esp+94h] [ebp-4h]
DrawQTextBack();
v0 = qtextptr;
screen_x = 112;
v13 = 0;
screen_y = qtexty;
v14 = 0;
do
{
v1 = 0;
v2 = 0;
for ( i = v0; *i != 10; ++v2 )
{
if ( *i == 124 || v1 >= 543 )
break;
v4 = *i++;
v5 = fontidx[v4];
if ( v5 )
{
qstr[v2] = v5;
v1 += mfontkern[mfontframe[v5]] + 2;
}
else
{
--v2;
}
}
v6 = *i;
v7 = &qstr[v2];
qstr[v2] = 0;
if ( v6 == 124 )
{
*v7 = 0;
v14 = 1;
}
else if ( v6 != 10 )
{
while ( *v7 != 32 && v2 > 0 )
{
*v7 = 0;
v7 = &qstr[--v2];
}
}
v8 = qstr[0];
if ( qstr[0] )
{
v9 = qstr;
do
{
++v0;
v10 = mfontframe[fontidx[v8]];
if ( *v0 == 10 )
++v0;
if ( v10 )
PrintQTextChr(screen_x, screen_y, (char *)pMedTextCels, v10);
++v9;
screen_x += mfontkern[v10] + 2;
v8 = *v9;
}
while ( *v9 );
}
if ( !v13 )
v13 = v0;
screen_y += 38;
screen_x = 112;
if ( screen_y > 501 )
v14 = 1;
}
while ( !v14 );
v11 = GetTickCount();
while ( 1 )
{
if ( sgLastScroll <= 0 )
{
qtexty = qtexty + sgLastScroll - 1;
goto LABEL_33;
}
if ( --scrolltexty )
{
--qtexty;
LABEL_33:
if ( scrolltexty )
goto LABEL_35;
}
scrolltexty = sgLastScroll;
LABEL_35:
if ( qtexty <= 209 )
break;
qtextSpd += 50;
if ( v11 - qtextSpd >= 0x7FFFFFFF )
return;
}
qtexty += 38;
qtextptr = v13;
if ( *v13 == 124 )
qtextflag = 0;
}
// 646CF4: using guessed type int qtexty;
// 646CFC: using guessed type int qtextSpd;
// 646D00: using guessed type char qtextflag;
// 646D04: using guessed type int scrolltexty;
// 646D08: using guessed type int sgLastScroll;
// 428202: using guessed type char qstr[128];

36
Source/minitext.h Normal file
View File

@ -0,0 +1,36 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//minitext
extern int qtexty; // weak
extern char *qtextptr;
extern int qtextSpd; // weak
extern char qtextflag; // weak
extern int scrolltexty; // weak
extern int sgLastScroll; // weak
extern void *pMedTextCels;
extern void *pTextBoxCels;
void __cdecl FreeQuestText();
void __cdecl InitQuestText();
void __fastcall InitQTextMsg(int m);
void __cdecl DrawQTextBack();
void __fastcall PrintQTextChr(int screen_x, int screen_y, char *cel_buf, int frame);
void __cdecl DrawQText();
/* data */
extern unsigned char mfontframe[127];
extern unsigned char mfontkern[56];
/* rdata */
extern int qscroll_spd_tbl[9];

7712
Source/missiles.cpp Normal file

File diff suppressed because it is too large Load Diff

161
Source/missiles.h Normal file
View File

@ -0,0 +1,161 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//missile
extern int missileactive[125];
extern int missileavail[125];
extern MissileStruct missile[125];
extern int nummissiles; // idb
extern int ManashieldFlag;
extern unk_missile_struct misflagstruct_unknown[125];
extern int MissilePreFlag; // weak
// int END_unkmis_126; // weak
void __fastcall GetDamageAmt(int i, int *mind, int *maxd);
int __fastcall CheckBlock(int fx, int fy, int tx, int ty);
int __fastcall FindClosest(int sx, int sy, int rad);
int __fastcall GetSpellLevel(int id, int sn);
int __fastcall GetDirection8(int x1, int y1, int x2, int y2);
int __fastcall GetDirection16(int x1, int y1, int x2, int y2);
void __fastcall DeleteMissile(int mi, int i);
void __fastcall GetMissileVel(int i, int sx, int sy, int dx, int dy, int v);
void __fastcall PutMissile(int i);
void __fastcall GetMissilePos(int i);
void __fastcall MoveMissilePos(int i);
bool __fastcall MonsterTrapHit(int m, int mindam, int maxdam, int dist, int t, int shift);
bool __fastcall MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist, int t, int shift);
bool __fastcall PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, int shift, int earflag);
bool __fastcall Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist, int mtype, int shift);
void __fastcall CheckMissileCol(int i, int mindam, int maxdam, bool shift, int mx, int my, int nodel);
void __fastcall SetMissAnim(int mi, int animtype);
void __fastcall SetMissDir(int mi, int dir);
void __fastcall LoadMissileGFX(int mi);
void __cdecl InitMissileGFX();
void __fastcall FreeMissileGFX(int mi);
void __cdecl FreeMissiles();
void __cdecl FreeMissiles2();
void __cdecl InitMissiles();
void __fastcall AddLArrow(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddArrow(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall GetVileMissPos(int mi, int dx, int dy);
void __fastcall AddRndTeleport(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFirebolt(int mi, int sx, int sy, int dx, int dy, int midir, int micaster, int id, int dam);
void __fastcall AddMagmaball(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall miss_null_33(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddTeleport(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddLightball(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFirewall(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFireball(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddLightctrl(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddLightning(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddMisexp(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddWeapexp(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
bool __fastcall CheckIfTrig(int x, int y);
void __fastcall AddTown(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFlash(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFlash2(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddManashield(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFiremove(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddGuardian(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddChain(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall miss_null_11(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall miss_null_12(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall miss_null_13(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddRhino(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall miss_null_32(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFlare(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddAcid(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall miss_null_1D(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddAcidpud(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddStone(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddGolem(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddEtherealize(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall miss_null_1F(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall miss_null_23(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddBoom(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddHeal(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddHealOther(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddElement(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddIdentify(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFirewallC(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddInfra(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddWave(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddNova(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddRepair(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddRecharge(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddDisarm(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddApoca(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFlame(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddFlamec(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddCbolt(int mi, int sx, int sy, int dx, int dy, int midir, int micaster, int id, int dam);
void __fastcall AddHbolt(int mi, int sx, int sy, int dx, int dy, int midir, int micaster, int id, int dam);
void __fastcall AddResurrect(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddResurrectBeam(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddTelekinesis(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddBoneSpirit(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddRportal(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
void __fastcall AddDiabApoca(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam);
int __fastcall AddMissile(int sx, int sy, int v1, int v2, int midir, int mitype, int micaster, int id, int v3, int spllvl);
int __fastcall Sentfire(int i, int sx, int sy);
void __fastcall MI_Dummy(int i);
void __fastcall MI_Golem(int i);
void __fastcall MI_SetManashield(int i);
void __fastcall MI_LArrow(int i);
void __fastcall MI_Arrow(int i);
void __fastcall MI_Firebolt(int i);
void __fastcall MI_Lightball(int i);
void __fastcall mi_null_33(int i);
void __fastcall MI_Acidpud(int i);
void __fastcall MI_Firewall(int i);
void __fastcall MI_Fireball(int i);
void __fastcall MI_Lightctrl(int i);
void __fastcall MI_Lightning(int i);
void __fastcall MI_Town(int i);
void __fastcall MI_Flash(int i);
void __fastcall MI_Flash2(int i);
void __fastcall MI_Manashield(int i);
void __fastcall MI_Etherealize(int i);
void __fastcall MI_Firemove(int i);
void __fastcall MI_Guardian(int i);
void __fastcall MI_Chain(int i);
void __fastcall mi_null_11(int i);
void __fastcall MI_Weapexp(int i);
void __fastcall MI_Misexp(int i);
void __fastcall MI_Acidsplat(int i);
void __fastcall MI_Teleport(int i);
void __fastcall MI_Stone(int i);
void __fastcall MI_Boom(int i);
void __fastcall MI_Rhino(int i);
void __fastcall mi_null_32(int i);
void __fastcall MI_FirewallC(int i);
void __fastcall MI_Infra(int i);
void __fastcall MI_Apoca(int i);
void __fastcall MI_Wave(int i);
void __fastcall MI_Nova(int i);
void __fastcall MI_Blodboil(int i);
void __fastcall MI_Flame(int i);
void __fastcall MI_Flamec(int i);
void __fastcall MI_Cbolt(int i);
void __fastcall MI_Hbolt(int i);
void __fastcall MI_Element(int i);
void __fastcall MI_Bonespirit(int i);
void __fastcall MI_ResurrectBeam(int i);
void __fastcall MI_Rportal(int i);
void __cdecl ProcessMissiles();
void __cdecl missiles_process_charge();
void __fastcall ClearMissileSpot(int mi);
/* rdata */
extern MissileData missiledata[68];
extern MisFileData misfiledata[47];
extern int XDirAdd[8];
extern int YDirAdd[8];

9375
Source/monster.cpp Normal file

File diff suppressed because it is too large Load Diff

201
Source/monster.h Normal file
View File

@ -0,0 +1,201 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//monster
extern int MissileFileFlag; // weak
extern int monster_cpp_init_value; // weak
extern int monstkills[200];
extern int monstactive[200];
extern int nummonsters;
extern int sgbSaveSoundOn; // weak
extern MonsterStruct monster[200];
extern int totalmonsters; // weak
extern CMonster Monsters[16];
// int END_Monsters_17; // weak
extern int monstimgtot; // weak
extern int uniquetrans;
extern int nummtypes;
void __cdecl monster_cpp_init();
void __fastcall InitMonsterTRN(int monst, int special);
void __cdecl InitLevelMonsters();
int __fastcall AddMonsterType(int type, int placeflag);
void __cdecl GetLevelMTypes();
void __fastcall InitMonsterGFX(int monst);
void __fastcall ClearMVars(int i);
void __fastcall InitMonster(int i, int rd, int mtype, int x, int y);
void __cdecl ClrAllMonsters();
bool __fastcall MonstPlace(int xp, int yp);
void __fastcall PlaceMonster(int i, int mtype, int x, int y);
void __fastcall PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize);
void __cdecl PlaceQuestMonsters();
void __fastcall PlaceGroup(int mtype, int num, unsigned char leaderf, int leader);
void __cdecl LoadDiabMonsts();
void __cdecl InitMonsters();
void __cdecl PlaceUniques();
void __fastcall SetMapMonsters(char *pMap, int startx, int starty);
void __fastcall DeleteMonster(int i);
int __fastcall AddMonster(int x, int y, int dir, int mtype, int InMap);
void __fastcall NewMonsterAnim(int i, AnimStruct *anim, int md);
bool __fastcall M_Ranged(int i);
bool __fastcall M_Talker(int i);
void __fastcall M_Enemy(int i);
int __fastcall M_GetDir(int i);
void __fastcall M_CheckEFlag(int i);
void __fastcall M_StartStand(int i, int md);
void __fastcall M_StartDelay(int i, int len);
void __fastcall M_StartSpStand(int i, int md);
void __fastcall M_StartWalk(int i, int xvel, int yvel, int xadd, int yadd, int EndDir);
void __fastcall M_StartWalk2(int i, int xvel, int yvel, int a4, int a5, int a6, int a7, int EndDir);
void __fastcall M_StartWalk3(int i, int xvel, int yvel, int a4, int a5, int a6, int a7, int a8, int a9, int EndDir);
void __fastcall M_StartAttack(int i);
void __fastcall M_StartRAttack(int i, int missile_type, int dam);
void __fastcall M_StartRSpAttack(int i, int missile_type, int dam);
void __fastcall M_StartSpAttack(int i);
void __fastcall M_StartEat(int i);
void __fastcall M_ClearSquares(int i);
void __fastcall M_GetKnockback(int i);
void __fastcall M_StartHit(int i, int pnum, int dam);
void __fastcall M_DiabloDeath(int i, unsigned char sendmsg);
void __fastcall M2MStartHit(int mid, int i, int dam);
void __fastcall MonstStartKill(int i, int pnum, unsigned char sendmsg);
void __fastcall M2MStartKill(int i, int mid);
void __fastcall M_StartKill(int i, int pnum);
void __fastcall M_SyncStartKill(int i, int x, int y, int pnum);
void __fastcall M_StartFadein(int i, int md, unsigned char backwards);
void __fastcall M_StartFadeout(int i, int md, unsigned char backwards);
void __fastcall M_StartHeal(int i);
void __fastcall M_ChangeLightOffset(int monst);
int __fastcall M_DoStand(int i);
int __fastcall M_DoWalk(int i);
int __fastcall M_DoWalk2(int i);
int __fastcall M_DoWalk3(int i);
void __fastcall M_TryM2MHit(int i, int mid, int hper, int mind, int maxd);
void __fastcall M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam);
int __fastcall M_DoAttack(int i);
int __fastcall M_DoRAttack(int i);
int __fastcall M_DoRSpAttack(int i);
int __fastcall M_DoSAttack(int i);
int __fastcall M_DoFadein(int i);
int __fastcall M_DoFadeout(int i);
int __fastcall M_DoHeal(int i);
int __fastcall M_DoTalk(int i);
void __fastcall M_Teleport(int i);
int __fastcall M_DoGotHit(int i);
void __fastcall M_UpdateLeader(int i);
void __cdecl DoEnding();
void __cdecl PrepDoEnding();
int __fastcall M_DoDeath(int i);
int __fastcall M_DoSpStand(int i);
int __fastcall M_DoDelay(int i);
int __fastcall M_DoStone(int i);
void __fastcall M_WalkDir(int i, int md);
void __fastcall GroupUnity(int i);
bool __fastcall M_CallWalk(int i, int md);
bool __fastcall M_PathWalk(int i);
bool __fastcall M_CallWalk2(int i, int md);
bool __fastcall M_DumbWalk(int i, int md);
bool __fastcall M_RoundWalk(int i, int md, int *dir);
void __fastcall MAI_Zombie(int i);
void __fastcall MAI_SkelSd(int i);
bool __fastcall MAI_Path(int i);
void __fastcall MAI_Snake(int i);
void __fastcall MAI_Bat(int i);
void __fastcall MAI_SkelBow(int i);
void __fastcall MAI_Fat(int i);
void __fastcall MAI_Sneak(int i);
void __fastcall MAI_Fireman(int i);
void __fastcall MAI_Fallen(int i);
void __fastcall MAI_Cleaver(int i);
void __fastcall MAI_Round(int i, unsigned char special);
void __fastcall MAI_GoatMc(int i);
void __fastcall MAI_Ranged(int i, int missile_type, unsigned char special);
void __fastcall MAI_GoatBow(int i);
void __fastcall MAI_Succ(int i);
void __fastcall MAI_AcidUniq(int i);
void __fastcall MAI_Scav(int i);
void __fastcall MAI_Garg(int i);
void __fastcall MAI_RoundRanged(int i, int missile_type, unsigned char checkdoors, int dam, int lessmissiles);
void __fastcall MAI_Magma(int i);
void __fastcall MAI_Storm(int i);
void __fastcall MAI_Acid(int i);
void __fastcall MAI_Diablo(int i);
void __fastcall MAI_RR2(int i, int mistype, int dam);
void __fastcall MAI_Mega(int i);
void __fastcall MAI_Golum(int i);
void __fastcall MAI_SkelKing(int i);
void __fastcall MAI_Rhino(int i);
void __fastcall MAI_Counselor(int i);
void __fastcall MAI_Garbud(int i);
void __fastcall MAI_Zhar(int i);
void __fastcall MAI_SnotSpil(int i);
void __fastcall MAI_Lazurus(int i);
void __fastcall MAI_Lazhelp(int i);
void __fastcall MAI_Lachdanan(int i);
void __fastcall MAI_Warlord(int i);
void __cdecl DeleteMonsterList();
void __cdecl ProcessMonsters();
void __cdecl FreeMonsters();
bool __fastcall DirOK(int i, int mdir);
bool __fastcall PosOkMissile(int x, int y);
bool __fastcall CheckNoSolid(int x, int y);
bool __fastcall LineClearF(bool (__fastcall *Clear)(int, int), int x1, int y1, int x2, int y2);
bool __fastcall LineClear(int x1, int y1, int x2, int y2);
bool __fastcall LineClearF1(bool (__fastcall *Clear)(int, int, int), int monst, int x1, int y1, int x2, int y2);
void __fastcall SyncMonsterAnim(int i);
void __fastcall M_FallenFear(int x, int y);
void __fastcall PrintMonstHistory(int mt);
void __cdecl PrintUniqueHistory();
void __fastcall MissToMonst(int i, int x, int y);
bool __fastcall PosOkMonst(int i, int x, int y);
bool __fastcall PosOkMonst2(int i, int x, int y);
bool __fastcall PosOkMonst3(int i, int x, int y);
bool __fastcall IsSkel(int mt);
bool __fastcall IsGoat(int mt);
int __fastcall M_SpawnSkel(int x, int y, int dir);
void __fastcall ActivateSpawn(int i, int x, int y, int dir);
bool __fastcall SpawnSkeleton(int ii, int x, int y);
int __cdecl PreSpawnSkeleton();
void __fastcall TalktoMonster(int i);
void __fastcall SpawnGolum(int i, int x, int y, int mi);
bool __fastcall CanTalkToMonst(int m);
bool __fastcall CheckMonsterHit(int m, bool *ret);
int __fastcall encode_enemy(int m);
void __fastcall decode_enemy(int m, int enemy);
/* data */
extern int monster_inf; // weak
extern char plr2monst[9];
extern unsigned char counsmiss[4];
/* rdata */
extern MonsterData monsterdata[112];
extern char MonstConvTbl[128];
extern unsigned char MonstAvailTbl[112];
extern UniqMonstStruct UniqMonst[98];
extern int MWVel[24][3];
extern char animletter[7];
extern int left[8];
extern int right[8];
extern int opposite[8];
extern int offset_x[8];
extern int offset_y[8];
/* unused */
extern int rnd5[4];
extern int rnd10[4];
extern int rnd20[4];
extern int rnd60[4];
//
extern void (__fastcall *AiProc[])(int i);

103
Source/movie.cpp Normal file
View File

@ -0,0 +1,103 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int movie_cpp_init_value; // weak
char movie_playing; // weak
int loop_movie; // weak
int movie_inf = 0x7F800000; // weak
//----- (0043AD38) --------------------------------------------------------
struct movie_cpp_init
{
movie_cpp_init()
{
movie_cpp_init_value = movie_inf;
}
} _movie_cpp_init;
// 47F144: using guessed type int movie_inf;
// 659AF4: using guessed type int movie_cpp_init_value;
//----- (0043AD43) --------------------------------------------------------
void __fastcall play_movie(char *pszMovie, bool user_can_close)
{
char *v2; // esi
LRESULT (__stdcall *saveProc)(HWND, UINT, WPARAM, LPARAM); // edi
//int v4; // eax
MSG Msg; // [esp+8h] [ebp-24h]
BOOL v6; // [esp+24h] [ebp-8h]
void *video_stream; // [esp+28h] [ebp-4h]
v6 = user_can_close;
v2 = pszMovie;
if ( window_activated )
{
saveProc = SetWindowProc(MovieWndProc);
InvalidateRect(ghMainWnd, 0, 0);
UpdateWindow(ghMainWnd);
movie_playing = 1;
sound_disable_music(1);
sfx_stop();
effects_play_sound("Sfx\\Misc\\blank.wav");
SVidPlayBegin(v2, 0, 0, 0, 0, loop_movie != 0 ? 0x100C0808 : 0x10280808, &video_stream);
if ( video_stream )
{
do
{
if ( !window_activated || v6 && !movie_playing )
break;
while ( PeekMessageA(&Msg, NULL, 0, 0, PM_REMOVE) )
{
if ( Msg.message != WM_QUIT )
{
TranslateMessage(&Msg);
DispatchMessageA(&Msg);
}
}
//_LOBYTE(v4) = SVidPlayContinue();
if ( !SVidPlayContinue() )
break;
}
while ( video_stream );
if ( video_stream )
SVidPlayEnd(video_stream);
}
SetWindowProc(saveProc);
sound_disable_music(0);
}
}
// 634980: using guessed type int window_activated;
// 659AF8: using guessed type int movie_playing;
// 659AFC: using guessed type int loop_movie;
//----- (0043AE3E) --------------------------------------------------------
LRESULT __stdcall MovieWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
if ( Msg == WM_KEYFIRST || Msg == WM_CHAR )
{
LABEL_6:
movie_playing = 0;
return init_palette(hWnd, Msg, wParam, lParam);
}
if ( Msg != WM_SYSCOMMAND )
{
if ( Msg != WM_LBUTTONDOWN && Msg != WM_RBUTTONDOWN )
return init_palette(hWnd, Msg, wParam, lParam);
goto LABEL_6;
}
if ( wParam != SC_CLOSE )
return init_palette(hWnd, Msg, wParam, lParam);
movie_playing = 0;
return 0;
}
// 659AF8: using guessed type int movie_playing;

23
Source/movie.h Normal file
View File

@ -0,0 +1,23 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//movie
extern int movie_cpp_init_value; // weak
extern char movie_playing; // weak
extern int loop_movie; // weak
void __cdecl movie_cpp_init();
void __fastcall play_movie(char *pszMovie, bool user_can_close);
LRESULT __stdcall MovieWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
/* data */
extern int movie_inf; // weak

838
Source/mpqapi.cpp Normal file
View File

@ -0,0 +1,838 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int mpqapi_cpp_init_value; // weak
int sgdwMpqOffset; // idb
char mpq_buf[4096];
_HASHENTRY *sgpHashTbl;
bool save_archive_modified; // weak
_BLOCKENTRY *sgpBlockTbl;
bool save_archive_open; // weak
int mpqapi_inf = 0x7F800000; // weak
/* rdata */
HANDLE sghArchive = (HANDLE)0xFFFFFFFF; // idb
//----- (0043AE95) --------------------------------------------------------
struct mpqapi_cpp_init
{
mpqapi_cpp_init()
{
mpqapi_cpp_init_value = mpqapi_inf;
}
} _mpqapi_cpp_init;
// 47F148: using guessed type int mpqapi_inf;
// 659B00: using guessed type int mpqapi_cpp_init_value;
//----- (0043AEA0) --------------------------------------------------------
bool __fastcall mpqapi_set_hidden(char *pszArchive, bool hidden)
{
char *v2; // edi
BOOL v3; // esi
DWORD v4; // eax
bool result; // al
DWORD v6; // esi
v2 = pszArchive;
v3 = hidden;
v4 = GetFileAttributesA(pszArchive);
if ( v4 == -1 )
return GetLastError() == ERROR_FILE_NOT_FOUND;
v6 = v3 != 0 ? FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN : 0;
if ( v4 == v6 )
result = 1;
else
result = SetFileAttributesA(v2, v6);
return result;
}
//----- (0043AEDC) --------------------------------------------------------
void __fastcall mpqapi_store_creation_time(char *pszArchive, int dwChar)
{
int v2; // esi
char *v3; // ebx
HANDLE v4; // eax
int v5; // esi
struct _WIN32_FIND_DATAA FindFileData; // [esp+8h] [ebp-1E0h]
char dst[160]; // [esp+148h] [ebp-A0h]
v2 = dwChar;
v3 = pszArchive;
if ( gbMaxPlayers != 1 )
{
mpqapi_reg_load_modification_time(dst, 160);
v4 = FindFirstFileA(v3, &FindFileData);
if ( v4 != (HANDLE)-1 )
{
FindClose(v4);
v5 = 16 * v2;
*(_DWORD *)&dst[v5] = FindFileData.ftCreationTime.dwLowDateTime;
*(_DWORD *)&dst[v5 + 4] = FindFileData.ftCreationTime.dwHighDateTime;
mpqapi_reg_store_modification_time(dst, 160);
}
}
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0043AF4F) --------------------------------------------------------
bool __fastcall mpqapi_reg_load_modification_time(char *dst, int size)
{
unsigned int v2; // esi
char *v3; // edi
unsigned int v6; // esi
char *v7; // ecx
int nbytes_read; // [esp+8h] [ebp-4h]
v2 = size;
v3 = dst;
memset(dst, 0, size);
if ( !SRegLoadData("Diablo", "Video Player ", 0, (unsigned char *)v3, v2, (unsigned long *)&nbytes_read) || nbytes_read != v2 )
return 0;
if ( v2 >= 8 )
{
v6 = v2 >> 3;
do
{
v7 = v3;
v3 += 8;
mpqapi_xor_buf(v7);
--v6;
}
while ( v6 );
}
return 1;
}
//----- (0043AFA5) --------------------------------------------------------
void __fastcall mpqapi_xor_buf(char *pbData)
{
signed int v1; // eax
char *v2; // esi
signed int v3; // edi
v1 = 0xF0761AB;
v2 = pbData;
v3 = 8;
do
{
*v2 ^= v1;
++v2;
v1 = _rotl(v1, 1);
--v3;
}
while ( v3 );
}
//----- (0043AFC4) --------------------------------------------------------
bool __fastcall mpqapi_reg_store_modification_time(char *pbData, int dwLen)
{
int v2; // ebx
char *v3; // ebp
char *v4; // edi
unsigned int v5; // esi
char *v6; // ecx
v2 = dwLen;
v3 = pbData;
v4 = pbData;
if ( (unsigned int)dwLen >= 8 )
{
v5 = (unsigned int)dwLen >> 3;
do
{
v6 = v4;
v4 += 8;
mpqapi_xor_buf(v6);
--v5;
}
while ( v5 );
}
return SRegSaveData("Diablo", "Video Player ", 0, (unsigned char *)v3, v2);
}
//----- (0043B002) --------------------------------------------------------
void __fastcall mpqapi_remove_hash_entry(char *pszName)
{
int v1; // eax
_HASHENTRY *v2; // ecx
_BLOCKENTRY *v3; // eax
int v4; // esi
int v5; // edi
v1 = mpqapi_get_hash_index_of_path(pszName);
if ( v1 != -1 )
{
v2 = &sgpHashTbl[v1];
v3 = &sgpBlockTbl[v2->block];
v2->block = -2;
v4 = v3->offset;
v5 = v3->sizealloc;
memset(v3, 0, 0x10u);
mpqapi_alloc_block(v4, v5);
save_archive_modified = 1;
}
}
// 65AB0C: using guessed type int save_archive_modified;
//----- (0043B054) --------------------------------------------------------
void __fastcall mpqapi_alloc_block(int block_offset, int block_size)
{
int v2; // esi
int v3; // edi
_BLOCKENTRY *v4; // eax
signed int v5; // edx
signed int v6; // ecx
int v7; // ecx
bool v8; // zf
_BLOCKENTRY *v9; // eax
v2 = block_size;
v3 = block_offset;
LABEL_2:
v4 = sgpBlockTbl;
v5 = 2048;
while ( 1 )
{
v6 = v5--;
if ( !v6 )
break;
v7 = v4->offset;
if ( v4->offset && !v4->flags && !v4->sizefile )
{
if ( v7 + v4->sizealloc == v3 )
{
v3 = v4->offset;
LABEL_11:
v2 += v4->sizealloc;
memset(v4, 0, 0x10u);
goto LABEL_2;
}
if ( v3 + v2 == v7 )
goto LABEL_11;
}
++v4;
}
v8 = v3 + v2 == sgdwMpqOffset;
if ( v3 + v2 > sgdwMpqOffset )
{
TermMsg("MPQ free list error");
v8 = v3 + v2 == sgdwMpqOffset;
}
if ( v8 )
{
sgdwMpqOffset = v3;
}
else
{
v9 = mpqapi_new_block(0);
v9->offset = v3;
v9->sizealloc = v2;
v9->sizefile = 0;
v9->flags = 0;
}
}
//----- (0043B0E4) --------------------------------------------------------
_BLOCKENTRY *__fastcall mpqapi_new_block(int *block_index)
{
_BLOCKENTRY *result; // eax
unsigned int v2; // edx
result = sgpBlockTbl;
v2 = 0;
while ( result->offset || result->sizealloc || result->flags || result->sizefile )
{
++v2;
++result;
if ( v2 >= 0x800 )
{
TermMsg("Out of free block entries");
return 0;
}
}
if ( block_index )
*block_index = v2;
return result;
}
//----- (0043B123) --------------------------------------------------------
int __fastcall mpqapi_get_hash_index_of_path(char *pszName) // FetchHandle
{
char *v1; // esi
int v2; // ST00_4
int v3; // edi
short v4; // ax
v1 = pszName;
v2 = encrypt_hash(pszName, 2); // MPQ_HASH_NAME_B
v3 = encrypt_hash(v1, 1); // MPQ_HASH_NAME_A
v4 = encrypt_hash(v1, 0); // MPQ_HASH_TABLE_INDEX
return mpqapi_get_hash_index(v4, v3, v2, 0);
}
//----- (0043B153) --------------------------------------------------------
int __fastcall mpqapi_get_hash_index(short index, int hash_a, int hash_b, int locale)
{
int v4; // ecx
signed int v5; // eax
signed int v6; // edx
_HASHENTRY *v7; // ecx
int v8; // edi
int v10; // [esp+Ch] [ebp-8h]
int i; // [esp+10h] [ebp-4h]
v4 = index & 0x7FF;
v10 = hash_a;
v5 = 2048;
for ( i = v4; ; i = (i + 1) & 0x7FF )
{
v7 = &sgpHashTbl[v4];
v8 = v7->block;
if ( v8 == -1 )
return -1;
v6 = v5--;
if ( !v6 )
return -1;
if ( v7->hashcheck[0] == v10 && v7->hashcheck[1] == hash_b && v7->lcid == locale && v8 != -2 )
break;
v4 = (i + 1) & 0x7FF;
}
return i;
}
//----- (0043B1BD) --------------------------------------------------------
void __fastcall mpqapi_remove_hash_entries(bool (__stdcall *fnGetName)(int, char *))
{
bool (__stdcall *v1)(int, char *); // edi
signed int v2; // esi
int i; // eax
int v4; // eax
char v5[260]; // [esp+8h] [ebp-104h]
v1 = fnGetName;
v2 = 1;
for ( i = fnGetName(0, v5); i; i = v1(v4, v5) )
{
mpqapi_remove_hash_entry(v5);
v4 = v2++;
}
}
//----- (0043B1F8) --------------------------------------------------------
bool __fastcall mpqapi_write_file(char *pszName, char *pbData, int dwLen)
{
char *v3; // edi
char *v4; // esi
_BLOCKENTRY *v5; // eax
v3 = pbData;
v4 = pszName;
save_archive_modified = 1;
mpqapi_remove_hash_entry(pszName);
v5 = mpqapi_add_file(v4, 0, 0);
if ( mpqapi_write_file_contents(v4, v3, dwLen, v5) )
return 1;
mpqapi_remove_hash_entry(v4);
return 0;
}
// 65AB0C: using guessed type int save_archive_modified;
//----- (0043B23D) --------------------------------------------------------
_BLOCKENTRY *__fastcall mpqapi_add_file(char *pszName, _BLOCKENTRY *pBlk, int block_index)
{
char *v3; // edi
short v4; // si
int v5; // ebx
signed int v6; // edx
int v7; // esi
int v8; // ecx
int v9; // esi
int v11; // [esp+Ch] [ebp-8h]
_BLOCKENTRY *v12; // [esp+10h] [ebp-4h]
v12 = pBlk;
v3 = pszName;
v4 = encrypt_hash(pszName, 0);
v5 = encrypt_hash(v3, 1);
v11 = encrypt_hash(v3, 2);
if ( mpqapi_get_hash_index(v4, v5, v11, 0) != -1 )
TermMsg("Hash collision between \"%s\" and existing file\n", v3);
v6 = 2048;
v7 = v4 & 0x7FF;
while ( 1 )
{
--v6;
v8 = sgpHashTbl[v7].block;
if ( v8 == -1 || v8 == -2 )
break;
v7 = (v7 + 1) & 0x7FF;
if ( !v6 )
{
v6 = -1;
break;
}
}
if ( v6 < 0 )
TermMsg("Out of hash space");
if ( !v12 )
v12 = mpqapi_new_block(&block_index);
v9 = v7;
sgpHashTbl[v9].hashcheck[0] = v5;
sgpHashTbl[v9].hashcheck[1] = v11;
sgpHashTbl[v9].lcid = 0;
sgpHashTbl[v9].block = block_index;
return v12;
}
//----- (0043B317) --------------------------------------------------------
bool __fastcall mpqapi_write_file_contents(char *pszName, char *pbData, int dwLen, _BLOCKENTRY *pBlk)
{
char *v4; // esi
char *v5; // eax
unsigned int destsize; // ebx
char *v7; // eax
unsigned int v8; // esi
_BLOCKENTRY *v9; // edi
int v10; // eax
signed int v11; // eax
unsigned int v13; // eax
unsigned int v14; // eax
int v15; // ecx
int size; // [esp+Ch] [ebp-10h]
char *v17; // [esp+10h] [ebp-Ch]
int v18; // [esp+14h] [ebp-8h]
DWORD nNumberOfBytesToWrite; // [esp+18h] [ebp-4h]
v4 = pszName;
v17 = pbData;
v5 = strchr(pszName, ':');
destsize = 0;
while ( v5 )
{
v4 = v5 + 1;
v5 = strchr(v5 + 1, ':');
}
while ( 1 )
{
v7 = strchr(v4, '\\');
if ( !v7 )
break;
v4 = v7 + 1;
}
encrypt_hash(v4, 3);
v8 = dwLen;
v9 = pBlk;
size = 4 * ((unsigned int)(dwLen + 4095) >> 12) + 4;
nNumberOfBytesToWrite = 4 * ((unsigned int)(dwLen + 4095) >> 12) + 4;
v10 = mpqapi_find_free_block(size + dwLen, &pBlk->sizealloc);
v9->offset = v10;
v9->sizefile = v8;
v9->flags = 0x80000100;
if ( SetFilePointer(sghArchive, v10, NULL, FILE_BEGIN) == -1 )
return 0;
pBlk = 0;
v18 = 0;
while ( v8 )
{
v11 = 0;
do
mpq_buf[v11++] -= 86;
while ( v11 < 4096 );
dwLen = v8;
if ( v8 >= 0x1000 )
dwLen = 4096;
memcpy(mpq_buf, v17, dwLen);
v17 += dwLen;
dwLen = encrypt_compress(mpq_buf, dwLen);
if ( !v18 )
{
nNumberOfBytesToWrite = size;
pBlk = (_BLOCKENTRY *)DiabloAllocPtr(size);
memset(pBlk, 0, nNumberOfBytesToWrite);
if ( !WriteFile(sghArchive, pBlk, nNumberOfBytesToWrite, &nNumberOfBytesToWrite, 0) )
goto LABEL_25;
destsize += nNumberOfBytesToWrite;
}
*(&pBlk->offset + v18) = destsize;
if ( !WriteFile(sghArchive, mpq_buf, dwLen, (LPDWORD)&dwLen, 0) )
goto LABEL_25;
++v18;
if ( v8 <= 0x1000 )
v8 = 0;
else
v8 -= 4096;
destsize += dwLen;
}
*(&pBlk->offset + v18) = destsize;
if ( SetFilePointer(sghArchive, -destsize, NULL, FILE_CURRENT) == -1
|| !WriteFile(sghArchive, pBlk, nNumberOfBytesToWrite, &nNumberOfBytesToWrite, 0)
|| SetFilePointer(sghArchive, destsize - nNumberOfBytesToWrite, NULL, FILE_CURRENT) == -1 )
{
LABEL_25:
if ( pBlk )
mem_free_dbg(pBlk);
return 0;
}
mem_free_dbg(pBlk);
v13 = v9->sizealloc;
if ( destsize < v13 )
{
v14 = v13 - destsize;
if ( v14 >= 0x400 )
{
v15 = destsize + v9->offset;
v9->sizealloc = destsize;
mpqapi_alloc_block(v15, v14);
}
}
return 1;
}
//----- (0043B51C) --------------------------------------------------------
int __fastcall mpqapi_find_free_block(int size, int *block_size)
{
_BLOCKENTRY *v2; // eax
signed int v3; // esi
int result; // eax
int v5; // esi
bool v6; // zf
v2 = sgpBlockTbl;
v3 = 2048;
while ( 1 )
{
--v3;
if ( v2->offset )
{
if ( !v2->flags && !v2->sizefile && v2->sizealloc >= (unsigned int)size )
break;
}
++v2;
if ( !v3 )
{
*block_size = size;
result = sgdwMpqOffset;
sgdwMpqOffset += size;
return result;
}
}
v5 = v2->offset;
*block_size = size;
v2->offset += size;
v6 = v2->sizealloc == size;
v2->sizealloc -= size;
if ( v6 )
memset(v2, 0, 0x10u);
return v5;
}
//----- (0043B570) --------------------------------------------------------
void __fastcall mpqapi_rename(char *pszOld, char *pszNew)
{
char *v2; // esi
int v3; // eax
_HASHENTRY *v4; // eax
int v5; // ST00_4
_BLOCKENTRY *v6; // edx
v2 = pszNew;
v3 = mpqapi_get_hash_index_of_path(pszOld);
if ( v3 != -1 )
{
v4 = &sgpHashTbl[v3];
v5 = v4->block;
v6 = &sgpBlockTbl[v5];
v4->block = -2;
mpqapi_add_file(v2, v6, v5);
save_archive_modified = 1;
}
}
// 65AB0C: using guessed type int save_archive_modified;
//----- (0043B5AF) --------------------------------------------------------
bool __fastcall mpqapi_has_file(char *pszName)
{
return mpqapi_get_hash_index_of_path(pszName) != -1;
}
//----- (0043B5BF) --------------------------------------------------------
bool __fastcall mpqapi_open_archive(char *pszArchive, bool hidden, int dwChar) // OpenMPQ
{
char *v3; // ebp
BOOL v4; // esi
DWORD v6; // edi
int v8; // eax
int v10; // eax
char *lpFileName; // [esp+10h] [ebp-70h]
DWORD dwTemp; // [esp+14h] [ebp-6Ch]
TMPQHeader fhdr; // [esp+18h] [ebp-68h]
v3 = pszArchive;
v4 = hidden;
lpFileName = pszArchive;
encrypt_init_lookup_table();
if ( !mpqapi_set_hidden(v3, v4) )
return 0;
v6 = (unsigned char)gbMaxPlayers > 1u ? FILE_FLAG_WRITE_THROUGH : 0;
save_archive_open = 0;
sghArchive = CreateFileA(v3, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, v6, NULL);
if ( sghArchive == (HANDLE)-1 )
{
sghArchive = CreateFileA(lpFileName, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, v6 | (v4 != 0 ? FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN : 0), NULL);
if ( sghArchive == (HANDLE)-1 )
return 0;
save_archive_open = 1;
save_archive_modified = 1;
}
if ( !sgpBlockTbl || !sgpHashTbl )
{
memset(&fhdr, 0, 0x68u);
if ( !mpqapi_parse_archive_header(&fhdr, &sgdwMpqOffset) )
{
LABEL_15:
mpqapi_close_archive(lpFileName, 1, dwChar);
return 0;
}
sgpBlockTbl = (_BLOCKENTRY *)DiabloAllocPtr(0x8000);
memset(sgpBlockTbl, 0, 0x8000u);
if ( fhdr.dwBlockTableSize )
{
if ( SetFilePointer(sghArchive, 104, NULL, FILE_BEGIN) == -1
|| !ReadFile(sghArchive, sgpBlockTbl, 0x8000u, &dwTemp, NULL) )
{
goto LABEL_15;
}
v8 = encrypt_hash("(block table)", 3);
encrypt_decrypt_block(sgpBlockTbl, 0x8000, v8);
}
sgpHashTbl = (_HASHENTRY *)DiabloAllocPtr(0x8000);
memset(sgpHashTbl, 255, 0x8000u);
if ( fhdr.dwHashTableSize )
{
if ( SetFilePointer(sghArchive, 32872, NULL, FILE_BEGIN) == -1
|| !ReadFile(sghArchive, sgpHashTbl, 0x8000u, &dwTemp, NULL) )
{
goto LABEL_15;
}
v10 = encrypt_hash("(hash table)", 3);
encrypt_decrypt_block(sgpHashTbl, 0x8000, v10);
}
}
return 1;
}
// 65AB0C: using guessed type int save_archive_modified;
// 65AB14: using guessed type char save_archive_open;
// 679660: using guessed type char gbMaxPlayers;
//----- (0043B791) --------------------------------------------------------
bool __fastcall mpqapi_parse_archive_header(TMPQHeader *pHdr, int *pdwNextFileStart) // ParseMPQHeader
{
int *v2; // ebp
TMPQHeader *v3; // esi
DWORD v4; // eax
DWORD v5; // edi
DWORD NumberOfBytesRead; // [esp+10h] [ebp-4h]
v2 = pdwNextFileStart;
v3 = pHdr;
v4 = GetFileSize(sghArchive, 0);
v5 = v4;
*v2 = v4;
if ( v4 == -1
|| v4 < 0x68
|| !ReadFile(sghArchive, v3, 0x68u, &NumberOfBytesRead, NULL)
|| NumberOfBytesRead != 104
|| v3->dwID != '\x1AQPM'
|| v3->dwHeaderSize != 32
|| v3->wFormatVersion > 0u
|| v3->wSectorSize != 3
|| v3->dwArchiveSize != v5
|| v3->dwHashTablePos != 32872
|| v3->dwBlockTablePos != 104
|| v3->dwHashTableSize != 2048
|| v3->dwBlockTableSize != 2048 )
{
if ( SetFilePointer(sghArchive, 0, NULL, FILE_BEGIN) == -1 || !SetEndOfFile(sghArchive) )
return 0;
memset(v3, 0, 0x68u);
v3->dwID = '\x1AQPM';
v3->dwHeaderSize = 32;
v3->wSectorSize = 3;
v3->wFormatVersion = 0;
*v2 = 0x10068;
save_archive_modified = 1;
save_archive_open = 1;
}
return 1;
}
// 65AB0C: using guessed type int save_archive_modified;
// 65AB14: using guessed type char save_archive_open;
//----- (0043B882) --------------------------------------------------------
void __fastcall mpqapi_close_archive(char *pszArchive, bool bFree, int dwChar) // CloseMPQ
{
char *v3; // esi
_BLOCKENTRY *v4; // ecx
_HASHENTRY *v5; // ecx
v3 = pszArchive;
if ( bFree )
{
v4 = sgpBlockTbl;
sgpBlockTbl = 0;
mem_free_dbg(v4);
v5 = sgpHashTbl;
sgpHashTbl = 0;
mem_free_dbg(v5);
}
if ( sghArchive != (HANDLE)-1 )
{
CloseHandle(sghArchive);
sghArchive = (HANDLE)-1;
}
if ( save_archive_modified )
{
save_archive_modified = 0;
mpqapi_store_modified_time(v3, dwChar);
}
if ( save_archive_open )
{
save_archive_open = 0;
mpqapi_store_creation_time(v3, dwChar);
}
}
// 65AB0C: using guessed type int save_archive_modified;
// 65AB14: using guessed type char save_archive_open;
//----- (0043B8FD) --------------------------------------------------------
void __fastcall mpqapi_store_modified_time(char *pszArchive, int dwChar)
{
int v2; // esi
char *v3; // ebx
HANDLE v4; // eax
int v5; // esi
struct _WIN32_FIND_DATAA FindFileData; // [esp+8h] [ebp-1E0h]
char dst[160]; // [esp+148h] [ebp-A0h]
v2 = dwChar;
v3 = pszArchive;
if ( gbMaxPlayers != 1 )
{
mpqapi_reg_load_modification_time(dst, 160);
v4 = FindFirstFileA(v3, &FindFileData);
if ( v4 != (HANDLE)-1 )
{
FindClose(v4);
v5 = 16 * v2;
*(_DWORD *)&dst[v5 + 8] = FindFileData.ftLastWriteTime.dwLowDateTime;
*(_DWORD *)&dst[v5 + 12] = FindFileData.ftLastWriteTime.dwHighDateTime;
mpqapi_reg_store_modification_time(dst, 160);
}
}
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0043B970) --------------------------------------------------------
void __fastcall mpqapi_flush_and_close(char *pszArchive, bool bFree, int dwChar)
{
if ( sghArchive != (HANDLE)-1 )
{
if ( save_archive_modified )
{
if ( mpqapi_can_seek() )
{
if ( mpqapi_write_header() )
{
if ( mpqapi_write_block_table() )
mpqapi_write_hash_table();
}
}
}
}
mpqapi_close_archive(pszArchive, bFree, dwChar);
}
// 65AB0C: using guessed type int save_archive_modified;
//----- (0043B9CA) --------------------------------------------------------
bool __cdecl mpqapi_write_header() // WriteMPQHeader
{
bool result; // al
TMPQHeader fhdr; // [esp+8h] [ebp-6Ch]
DWORD NumberOfBytesWritten; // [esp+70h] [ebp-4h]
memset(&fhdr, 0, 0x68u);
fhdr.dwID = '\x1AQPM';
fhdr.dwHeaderSize = 32;
fhdr.dwArchiveSize = GetFileSize(sghArchive, 0);
fhdr.wFormatVersion = 0;
fhdr.wSectorSize = 3;
fhdr.dwHashTablePos = 32872;
fhdr.dwBlockTablePos = 104;
fhdr.dwHashTableSize = 2048;
fhdr.dwBlockTableSize = 2048;
if ( SetFilePointer(sghArchive, 0, NULL, FILE_BEGIN) != -1 && WriteFile(sghArchive, &fhdr, 0x68u, &NumberOfBytesWritten, 0) )
result = NumberOfBytesWritten == 104;
else
result = 0;
return result;
}
//----- (0043BA60) --------------------------------------------------------
bool __cdecl mpqapi_write_block_table()
{
int v1; // eax
BOOL v2; // ebx
int v3; // eax
DWORD NumberOfBytesWritten; // [esp+4h] [ebp-4h]
if ( SetFilePointer(sghArchive, 104, NULL, FILE_BEGIN) == -1 )
return 0;
v1 = encrypt_hash("(block table)", 3);
encrypt_encrypt_block(sgpBlockTbl, 0x8000, v1);
v2 = WriteFile(sghArchive, sgpBlockTbl, 0x8000u, &NumberOfBytesWritten, 0);
v3 = encrypt_hash("(block table)", 3);
encrypt_decrypt_block(sgpBlockTbl, 0x8000, v3);
return v2 && NumberOfBytesWritten == 0x8000;
}
//----- (0043BAEB) --------------------------------------------------------
bool __cdecl mpqapi_write_hash_table()
{
int v1; // eax
BOOL v2; // ebx
int v3; // eax
DWORD NumberOfBytesWritten; // [esp+4h] [ebp-4h]
if ( SetFilePointer(sghArchive, 32872, NULL, FILE_BEGIN) == -1 )
return 0;
v1 = encrypt_hash("(hash table)", 3);
encrypt_encrypt_block(sgpHashTbl, 0x8000, v1);
v2 = WriteFile(sghArchive, sgpHashTbl, 0x8000u, &NumberOfBytesWritten, 0);
v3 = encrypt_hash("(hash table)", 3);
encrypt_decrypt_block(sgpHashTbl, 0x8000, v3);
return v2 && NumberOfBytesWritten == 0x8000;
}
//----- (0043BB79) --------------------------------------------------------
bool __cdecl mpqapi_can_seek()
{
bool result; // al
if ( SetFilePointer(sghArchive, sgdwMpqOffset, NULL, FILE_BEGIN) == -1 )
result = 0;
else
result = SetEndOfFile(sghArchive);
return result;
}

56
Source/mpqapi.h Normal file
View File

@ -0,0 +1,56 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//mpqapi
extern int mpqapi_cpp_init_value; // weak
extern int sgdwMpqOffset; // idb
extern char mpq_buf[4096];
extern _HASHENTRY *sgpHashTbl;
extern bool save_archive_modified; // weak
extern _BLOCKENTRY *sgpBlockTbl;
extern bool save_archive_open; // weak
void __cdecl mpqapi_cpp_init();
bool __fastcall mpqapi_set_hidden(char *pszArchive, bool hidden);
void __fastcall mpqapi_store_creation_time(char *pszArchive, int dwChar);
bool __fastcall mpqapi_reg_load_modification_time(char *dst, int size);
void __fastcall mpqapi_xor_buf(char *pbData);
bool __fastcall mpqapi_reg_store_modification_time(char *pbData, int dwLen);
_BLOCKENTRY *__fastcall j_mpqapi_remove_hash_entry(char *pszName);
void __fastcall mpqapi_remove_hash_entry(char *pszName);
void __fastcall mpqapi_alloc_block(int block_offset, int block_size);
_BLOCKENTRY *__fastcall mpqapi_new_block(int *block_index);
int __fastcall mpqapi_get_hash_index_of_path(char *pszName);
int __fastcall mpqapi_get_hash_index(short index, int hash_a, int hash_b, int locale);
void __fastcall mpqapi_remove_hash_entries(bool (__stdcall *fnGetName)(int, char *));
bool __fastcall mpqapi_write_file(char *pszName, char *pbData, int dwLen);
_BLOCKENTRY *__fastcall mpqapi_add_file(char *pszName, _BLOCKENTRY *pBlk, int block_index);
bool __fastcall mpqapi_write_file_contents(char *pszName, char *pbData, int dwLen, _BLOCKENTRY *pBlk);
int __fastcall mpqapi_find_free_block(int size, int *block_size);
void __fastcall mpqapi_rename(char *pszOld, char *pszNew);
bool __fastcall mpqapi_has_file(char *pszName);
bool __fastcall mpqapi_open_archive(char *pszArchive, bool hidden, int dwChar);
bool __fastcall mpqapi_parse_archive_header(TMPQHeader *pHdr, int *pdwNextFileStart);
void __fastcall mpqapi_close_archive(char *pszArchive, bool bFree, int dwChar);
void __fastcall mpqapi_store_modified_time(char *pszArchive, int dwChar);
void __fastcall mpqapi_flush_and_close(char *pszArchive, bool bFree, int dwChar);
bool __cdecl mpqapi_write_header();
bool __cdecl mpqapi_write_block_table();
bool __cdecl mpqapi_write_hash_table();
bool __cdecl mpqapi_can_seek();
/* data */
extern int mpqapi_inf; // weak
/* rdata */
extern HANDLE sghArchive; // idb

3980
Source/msg.cpp Normal file

File diff suppressed because it is too large Load Diff

171
Source/msg.h Normal file
View File

@ -0,0 +1,171 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//msg
extern int sgdwOwnerWait; // weak
extern int msg_cpp_init_value; // weak
extern int sgdwRecvOffset; // idb
extern int sgnCurrMegaPlayer; // weak
extern DLevel sgLevels[17];
extern char sbLastCmd; // weak
extern TMegaPkt *sgpCurrPkt;
extern char sgRecvBuf[4722];
extern unsigned char sgbRecvCmd; // idb
extern LocalLevel sgLocals[17];
extern DJunk sgJunk[4];
extern TMegaPkt *sgpMegaPkt;
extern char sgbDeltaChanged; // weak
extern char sgbDeltaChunks; // weak
extern int deltaload; // weak
extern char gbBufferMsgs; // weak
extern int dword_676198; // weak
extern int msg_err_timer; // weak
void __cdecl msg_cpp_init();
void __fastcall msg_send_drop_pkt(int pnum, int reason);
void __fastcall msg_send_packet(int pnum, void *packet, int dwSize);
TMegaPkt *__cdecl msg_get_next_packet();
int __cdecl msg_wait_resync();
void __cdecl msg_free_packets();
int __cdecl msg_wait_for_turns();
void __cdecl msg_process_net_packets();
void __cdecl msg_pre_packet();
void __fastcall DeltaExportData(int pnum);
void *__fastcall DeltaExportItem(void *dst, void *src);
void *__fastcall DeltaExportObject(void *dst, void *src);
void *__fastcall DeltaExportMonster(void *dst, void *src);
char *__fastcall DeltaExportJunk(char *a1);
int __fastcall msg_comp_level(char *buffer, int size);
void __cdecl delta_init();
void __fastcall delta_kill_monster(int mi, unsigned char x, unsigned char y, unsigned char bLevel);
void __fastcall delta_monster_hp(int mi, int hp, unsigned char bLevel);
void __fastcall delta_sync_monster(TCmdLocParam1 *packet, char level);
void __fastcall delta_sync_golem(TCmdGolem *pG, int pnum, int bLevel);
void __fastcall delta_leave_sync(unsigned char bLevel);
bool __fastcall delta_portal_inited(int portal_num);
bool __fastcall delta_quest_inited(int quest_num);
void __fastcall DeltaAddItem(int ii);
void __cdecl DeltaSaveLevel();
void __cdecl DeltaLoadLevel();
void __fastcall NetSendCmd(unsigned char bHiPri, unsigned char bCmd);
void __fastcall NetSendCmdGolem(unsigned char mx, unsigned char my, unsigned char dir, unsigned char menemy, int hp, int cl);
void __fastcall NetSendCmdLoc(unsigned char bHiPri, unsigned char bCmd, unsigned char x, unsigned char y);
void __fastcall NetSendCmdLocParam1(unsigned char bHiPri, unsigned char bCmd, unsigned char x, unsigned char y, int wParam1);
void __fastcall NetSendCmdLocParam2(unsigned char bHiPri, unsigned char bCmd, unsigned char x, unsigned char y, int wParam1, int wParam2);
void __fastcall NetSendCmdLocParam3(unsigned char bHiPri, unsigned char bCmd, unsigned char x, unsigned char y, int wParam1, int wParam2, int wParam3);
void __fastcall NetSendCmdParam1(unsigned char bHiPri, unsigned char bCmd, unsigned short wParam1);
void __fastcall NetSendCmdParam2(unsigned char bHiPri, unsigned char bCmd, unsigned short wParam1, unsigned short wParam2);
void __fastcall NetSendCmdParam3(unsigned char bHiPri, unsigned char bCmd, unsigned short wParam1, unsigned short wParam2, int wParam3);
void __fastcall NetSendCmdQuest(unsigned char bHiPri, unsigned char q);
void __fastcall NetSendCmdGItem(unsigned char bHiPri, unsigned char bCmd, unsigned char mast, unsigned char pnum, int ii);
void __fastcall NetSendCmdGItem2(unsigned char usonly, unsigned char bCmd, unsigned char mast, unsigned char pnum, struct TCmdGItem *p);
bool __fastcall NetSendCmdReq2(unsigned char bCmd, unsigned char mast, unsigned char pnum, struct TCmdGItem *p);
void __fastcall NetSendCmdExtra(struct TCmdGItem *p);
void __fastcall NetSendCmdPItem(unsigned char bHiPri, unsigned char bCmd, unsigned char x, unsigned char y);
void __fastcall NetSendCmdChItem(unsigned char bHiPri, unsigned char bLoc);
void __fastcall NetSendCmdDelItem(unsigned char bHiPri, unsigned char bLoc);
void __fastcall NetSendCmdDItem(unsigned char bHiPri, int ii);
void __fastcall NetSendCmdDamage(unsigned char bHiPri, unsigned char bPlr, unsigned int dwDam);
void __fastcall NetSendCmdString(int a1, const char *pszStr);
void __fastcall RemovePlrPortal(int pnum);
int __fastcall ParseCmd(int pnum, TCmd *pCmd);
void __fastcall DeltaImportData(unsigned char cmd, int recv_offset);
void *__fastcall DeltaImportItem(void *src, void *dst);
void *__fastcall DeltaImportObject(void *src, void *dst);
void *__fastcall DeltaImportMonster(void *src, void *dst);
char __fastcall DeltaImportJunk(int a1);
int __fastcall On_SYNCDATA(void *packet, int pnum);
int __fastcall On_WALKXY(struct TCmdLoc *pCmd, int pnum);
int __fastcall On_ADDSTR(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_ADDMAG(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_ADDDEX(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_ADDVIT(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_SBSPELL(struct TCmdParam1 *pCmd, int pnum);
void msg_errorf(char *pszFmt, ...);
int __fastcall On_GOTOGETITEM(struct TCmdLocParam1 *pCmd, int pnum);
int __fastcall On_REQUESTGITEM(struct TCmdGItem *pCmd, int pnum);
bool __fastcall i_own_level(int nReqLevel);
int __fastcall On_GETITEM(struct TCmdGItem *pCmd, int pnum);
bool __fastcall delta_get_item(struct TCmdGItem *pI, unsigned char bLevel);
int __fastcall On_GOTOAGETITEM(struct TCmdLocParam1 *pCmd, int pnum);
int __fastcall On_REQUESTAGITEM(struct TCmdGItem *pCmd, int pnum);
int __fastcall On_AGETITEM(struct TCmdGItem *pCmd, int pnum);
int __fastcall On_ITEMEXTRA(struct TCmdGItem *pCmd, int pnum);
int __fastcall On_PUTITEM(struct TCmdPItem *pCmd, int pnum);
void __fastcall delta_put_item(struct TCmdPItem *pI, int x, int y, unsigned char bLevel);
void __fastcall check_update_plr(int pnum);
int __fastcall On_SYNCPUTITEM(struct TCmdPItem *pCmd, int pnum);
int __fastcall On_RESPAWNITEM(struct TCmdPItem *pCmd, int pnum);
int __fastcall On_ATTACKXY(struct TCmdLoc *pCmd, int pnum);
int __fastcall On_SATTACKXY(struct TCmdLoc *pCmd, int pnum);
int __fastcall On_RATTACKXY(struct TCmdLoc *pCmd, int pnum);
int __fastcall On_SPELLXYD(struct TCmdLocParam3 *pCmd, int pnum);
int __fastcall On_SPELLXY(struct TCmdLocParam2 *pCmd, int pnum);
int __fastcall On_TSPELLXY(struct TCmdLocParam2 *pCmd, int pnum);
int __fastcall On_OPOBJXY(struct TCmdLocParam1 *pCmd, int pnum);
int __fastcall On_DISARMXY(struct TCmdLocParam1 *pCmd, int pnum);
int __fastcall On_OPOBJT(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_ATTACKID(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_ATTACKPID(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_RATTACKID(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_RATTACKPID(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_SPELLID(struct TCmdLocParam2 *pCmd, int pnum);
int __fastcall On_SPELLPID(struct TCmdLocParam2 *pCmd, int pnum);
int __fastcall On_TSPELLID(struct TCmdLocParam2 *pCmd, int pnum);
int __fastcall On_TSPELLPID(struct TCmdLocParam2 *pCmd, int pnum);
int __fastcall On_KNOCKBACK(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_RESURRECT(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_HEALOTHER(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_TALKXY(struct TCmdLocParam1 *pCmd, int pnum);
int __fastcall On_NEWLVL(struct TCmdParam2 *pCmd, int pnum);
int __fastcall On_WARP(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_MONSTDEATH(struct TCmdLocParam1 *pCmd, int pnum);
int __fastcall On_KILLGOLEM(struct TCmdLocParam1 *pCmd, int pnum);
int __fastcall On_AWAKEGOLEM(struct TCmdGolem *pCmd, int pnum);
int __fastcall On_MONSTDAMAGE(struct TCmdLocParam1 *pCmd, int pnum);
int __fastcall On_PLRDEAD(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_PLRDAMAGE(struct TCmdDamage *pCmd, int pnum);
int __fastcall On_OPENDOOR(struct TCmdParam1 *pCmd, int pnum);
void __fastcall delta_sync_object(int oi, unsigned char bCmd, unsigned char bLevel);
int __fastcall On_CLOSEDOOR(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_OPERATEOBJ(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_PLROPOBJ(struct TCmdParam2 *pCmd, int pnum);
int __fastcall On_BREAKOBJ(struct TCmdParam2 *pCmd, int pnum);
int __fastcall On_CHANGEPLRITEMS(struct TCmdChItem *pCmd, int pnum);
int __fastcall On_DELPLRITEMS(struct TCmdDelItem *pCmd, int pnum);
int __fastcall On_PLRLEVEL(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_DROPITEM(struct TCmdPItem *pCmd, int pnum);
int __fastcall On_SEND_PLRINFO(struct TCmdPlrInfoHdr *pCmd, int pnum);
int __fastcall On_ACK_PLRINFO(struct TCmdPlrInfoHdr *pCmd, int pnum);
int __fastcall On_PLAYER_JOINLEVEL(struct TCmdLocParam1 *pCmd, int pnum);
int __fastcall On_ACTIVATEPORTAL(DJunk *pCmd, int pnum);
void __fastcall delta_open_portal(int pnum, int x, int y, int bLevel, int bLType, int bSetLvl);
int __fastcall On_DEACTIVATEPORTAL(struct TCmd *pCmd, int pnum);
int __fastcall On_RETOWN(struct TCmd *pCmd, int pnum);
int __fastcall On_SETSTR(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_SETDEX(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_SETMAG(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_SETVIT(struct TCmdParam1 *pCmd, int pnum);
int __fastcall On_STRING(struct TCmdString *pCmd, int pnum);
int __fastcall On_SYNCQUEST(struct TCmdQuest *pCmd, int pnum);
int __fastcall On_ENDSHIELD(int a1, int pnum);
#ifdef _DEBUG
int __fastcall On_CHEAT_EXPERIENCE(struct TCmd *pCmd, int pnum);
int __fastcall On_CHEAT_SPELL_LEVEL(struct TCmd *pCmd, int pnum);
#endif
int __cdecl On_DEBUG();
int __fastcall On_NOVA(struct TCmdLoc *pCmd, int pnum);
int __fastcall On_SETSHIELD(int unused, int pnum);
int __fastcall On_REMSHIELD(int unused, int pnum);
/* data */
extern int msg_inf; // weak

296
Source/msgcmd.cpp Normal file
View File

@ -0,0 +1,296 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int msgcmd_cpp_init_value; // weak
ChatCmd sgChat_Cmd;
int sgdwMsgCmdTimer;
int msgcmd_inf = 0x7F800000; // weak
//----- (0043F84E) --------------------------------------------------------
struct msgcmd_cpp_init_1
{
msgcmd_cpp_init_1()
{
msgcmd_cpp_init_value = msgcmd_inf;
}
} _msgcmd_cpp_init_1;
// 47F150: using guessed type int msgcmd_inf;
// 6761A0: using guessed type int msgcmd_cpp_init_value;
//----- (0043F859) --------------------------------------------------------
struct msgcmd_cpp_init_2
{
msgcmd_cpp_init_2()
{
msgcmd_init_event();
msgcmd_cleanup_chatcmd_atexit();
}
} _msgcmd_cpp_init_2;
//----- (0043F863) --------------------------------------------------------
void __cdecl msgcmd_init_event()
{
msgcmd_init_chatcmd(&sgChat_Cmd);
}
//----- (0043F86D) --------------------------------------------------------
void __cdecl msgcmd_cleanup_chatcmd_atexit()
{
atexit(msgcmd_cleanup_chatcmd);
}
//----- (0043F879) --------------------------------------------------------
void __cdecl msgcmd_cleanup_chatcmd()
{
msgcmd_cleanup_chatcmd_1(&sgChat_Cmd);
msgcmd_cleanup_extern_msg(sgChat_Cmd.extern_msgs);
}
//----- (0043F88D) --------------------------------------------------------
void __cdecl msgcmd_cmd_cleanup()
{
msgcmd_free_event(&sgChat_Cmd);
}
//----- (0043F897) --------------------------------------------------------
void __cdecl msgcmd_send_chat()
{
ServerCommand *v0; // esi
int v1; // eax
return; /* fix this */
if ( (_DWORD)sgChat_Cmd.extern_msgs[1] > 0 )
{
v0 = sgChat_Cmd.extern_msgs[1];
v1 = GetTickCount();
if ( (unsigned int)(v1 - sgdwMsgCmdTimer) >= 2000 )
{
sgdwMsgCmdTimer = v1;
SNetSendServerChatCommand(v0->command);
msgcmd_delete_server_cmd_W(&sgChat_Cmd, v0);
}
}
}
//----- (0043F8D4) --------------------------------------------------------
bool __fastcall msgcmd_add_server_cmd_W(char *chat_message)
{
if ( *chat_message != '/' )
return 0;
msgcmd_add_server_cmd(chat_message);
return 1;
}
//----- (0043F8E5) --------------------------------------------------------
void __fastcall msgcmd_add_server_cmd(char *command)
{
char *v1; // edi
size_t v2; // eax
int v3; // edx
size_t v4; // esi
ChatCmd *v5; // eax
v1 = command;
v2 = strlen(command);
if ( v2 )
{
v4 = v2 + 1;
if ( v2 + 1 <= 0x80 )
{
v5 = msgcmd_alloc_event(&sgChat_Cmd, v3, 2, 0, 0);
memcpy(&v5->extern_msgs[1], v1, v4);
}
}
}
//----- (0043F920) --------------------------------------------------------
void __fastcall msgcmd_init_chatcmd(ChatCmd *chat_cmd)
{
ServerCommand **v1; // edx
v1 = chat_cmd->extern_msgs;
*v1 = 0;
v1[1] = 0;
*v1 = (ServerCommand *)v1;
chat_cmd->next = 0;
chat_cmd->extern_msgs[1] = (ServerCommand *)~(unsigned int)chat_cmd->extern_msgs;
}
//----- (0043F936) --------------------------------------------------------
void __fastcall msgcmd_free_event(ChatCmd *a1)
{
int v1; // edx
ChatCmd *v2; // edi
ChatCmd *v3; // esi
v2 = a1;
while ( 1 )
{
v3 = (ChatCmd *)v2->extern_msgs[1];
if ( (signed int)v3 <= 0 )
break;
msgcmd_remove_event(v3, v1);
SMemFree(v3, ".?AUEXTERNMESSAGE@@", -2, 0);
}
}
//----- (0043F95E) --------------------------------------------------------
bool __fastcall msgcmd_delete_server_cmd_W(ChatCmd *cmd, ServerCommand *extern_msg)
{
char *v2; // eax
ServerCommand *v3; // eax
bool v4; // si
ChatCmd *ptr; // [esp+Ch] [ebp+4h]
v2 = (char *)ptr;
if ( !ptr )
v2 = (char *)cmd->extern_msgs;
v3 = (ServerCommand *)*((_DWORD *)v2 + 1);
if ( (signed int)v3 > 0 )
v4 = (char)v3;
else
v4 = 0;
msgcmd_remove_event(ptr, (int)extern_msg);
SMemFree(ptr, ".?AUEXTERNMESSAGE@@", -2, 0);
return v4;
}
//----- (0043F999) --------------------------------------------------------
ChatCmd *__fastcall msgcmd_alloc_event(ChatCmd *a1, int a2, int a3, int a4, int a5)
{
int v5; // eax
ChatCmd *v6; // edi
ChatCmd *v7; // eax
int v8; // edx
ChatCmd *v9; // esi
v5 = a5;
_LOBYTE(v5) = a5 | 8;
v6 = a1;
v7 = (ChatCmd *)SMemAlloc(a4 + 136, ".?AUEXTERNMESSAGE@@", -2, v5);
if ( v7 )
{
v7->next = 0;
v7->extern_msgs[0] = 0;
v9 = v7;
}
else
{
v9 = 0;
}
if ( a3 )
msgcmd_event_type(v6, v8, (int *)v9, a3, 0);
return v9;
}
//----- (0043F9E5) --------------------------------------------------------
void __fastcall msgcmd_remove_event(ChatCmd *a1, int a2)
{
ServerCommand **v2; // esi
v2 = (ServerCommand **)a1;
msgcmd_cleanup_extern_msg((ServerCommand **)a1);
msgcmd_cleanup_extern_msg(v2);
if ( a2 & 1 )
{
if ( v2 )
SMemFree(v2, "delete", -1, 0);
}
}
//----- (0043FA14) --------------------------------------------------------
void __fastcall msgcmd_event_type(ChatCmd *a1, int a2, int *a3, int a4, int a5)
{
ChatCmd *v5; // edi
int *v6; // esi
int *v7; // eax
int v8; // ecx
int v9; // edx
int v10; // ecx
int v11; // edx
v5 = a1;
v6 = a3;
if ( !a3 )
v6 = (int *)a1->extern_msgs;
if ( *v6 )
msgcmd_cleanup_extern_msg((ServerCommand **)v6);
v7 = (int *)a5;
if ( !a5 )
v7 = (int *)v5->extern_msgs;
if ( a4 == 1 )
{
*v6 = (int)v7;
v6[1] = v7[1];
v9 = v7[1];
v10 = (int)v5->next;
if ( v9 > 0 )
{
if ( v10 < 0 )
v10 = (int)v7 - *(_DWORD *)(*v7 + 4);
v11 = v10 + v9;
}
else
{
v11 = ~v9;
}
*(_DWORD *)v11 = (unsigned int)v6;
v7[1] = (int)a3;
}
else if ( a4 == 2 )
{
v8 = *v7;
*v6 = *v7;
v6[1] = *(_DWORD *)(v8 + 4);
*(_DWORD *)(v8 + 4) = (unsigned int)a3;
*v7 = (int)v6;
}
}
//----- (0043FA85) --------------------------------------------------------
void __fastcall msgcmd_cleanup_chatcmd_1(ChatCmd *a1)
{
ChatCmd *v1; // esi
ServerCommand **v2; // ecx
v1 = a1;
while ( 1 )
{
v2 = (ServerCommand **)v1->extern_msgs[1];
if ( (signed int)v2 <= 0 )
break;
msgcmd_cleanup_extern_msg(v2);
}
}
//----- (0043FA98) --------------------------------------------------------
void __fastcall msgcmd_cleanup_extern_msg(ServerCommand **extern_msgs)
{
ServerCommand *v1; // esi
signed int v2; // edx
int v3; // edx
v1 = *extern_msgs;
if ( *extern_msgs )
{
v2 = (signed int)extern_msgs[1];
if ( v2 > 0 )
v3 = (int)extern_msgs + v2 - v1->field_4;
else
v3 = ~v2;
*(_DWORD *)v3 = (unsigned int)v1;
(*extern_msgs)->field_4 = (int)extern_msgs[1];
*extern_msgs = 0;
extern_msgs[1] = 0;
}
}

37
Source/msgcmd.h Normal file
View File

@ -0,0 +1,37 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//msgcmd
extern int msgcmd_cpp_init_value; // weak
extern ChatCmd sgChat_Cmd;
extern int sgdwMsgCmdTimer;
void __cdecl msgcmd_cpp_init_1();
void __cdecl msgcmd_cpp_init_2();
void __cdecl msgcmd_init_event();
void __cdecl msgcmd_cleanup_chatcmd_atexit();
void __cdecl msgcmd_cleanup_chatcmd();
void __cdecl msgcmd_cmd_cleanup();
void __cdecl msgcmd_send_chat();
bool __fastcall msgcmd_add_server_cmd_W(char *chat_message);
void __fastcall msgcmd_add_server_cmd(char *command);
void __fastcall msgcmd_init_chatcmd(ChatCmd *chat_cmd);
void __fastcall msgcmd_free_event(ChatCmd *a1);
bool __fastcall msgcmd_delete_server_cmd_W(ChatCmd *cmd, ServerCommand *extern_msg);
ChatCmd *__fastcall msgcmd_alloc_event(ChatCmd *a1, int a2, int a3, int a4, int a5);
void __fastcall msgcmd_remove_event(ChatCmd *a1, int a2);
void __fastcall msgcmd_event_type(ChatCmd *a1, int a2, int *a3, int a4, int a5);
void __fastcall msgcmd_cleanup_chatcmd_1(ChatCmd *a1);
void __fastcall msgcmd_cleanup_extern_msg(ServerCommand **extern_msgs);
/* data */
extern int msgcmd_inf; // weak

1208
Source/multi.cpp Normal file

File diff suppressed because it is too large Load Diff

80
Source/multi.h Normal file
View File

@ -0,0 +1,80 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//multi
extern char gbSomebodyWonGameKludge; // weak
extern char pkdata_6761C0[4100];
extern char szPlayerDescript[128];
extern short sgwPackPlrOffsetTbl[4];
extern PkPlayerStruct pkplr[4];
extern char sgbPlayerTurnBitTbl[4];
extern char sgbPlayerLeftGameTbl[4];
extern int multi_cpp_init_value; // weak
extern int sgbSentThisCycle; // idb
extern int dword_678628; // weak
extern char gbActivePlayers; // weak
extern char gbGameDestroyed; // weak
extern char sgbSendDeltaTbl[4];
extern _gamedata sgGameInitInfo;
extern char byte_678640; // weak
extern int sglTimeoutStart; // weak
extern int sgdwPlayerLeftReasonTbl[4];
extern char pkdata_678658[4100];
extern unsigned int sgdwGameLoops; // idb
extern char gbMaxPlayers; // weak
extern char sgbTimeout; // weak
extern char szPlayerName[128];
extern char gbDeltaSender; // weak
extern int sgbNetInited; // weak
extern int player_state[4];
void __cdecl multi_cpp_init();
void __fastcall multi_msg_add(unsigned char *a1, unsigned char a2);
void __fastcall NetSendLoPri(unsigned char *pbMsg, unsigned char bLen);
void __fastcall multi_copy_packet(void *a1, void *packet, int size);
void __fastcall multi_send_packet(void *packet, int dwSize);
void __fastcall NetRecvPlrData(TPkt *pkt);
void __fastcall NetSendHiPri(unsigned char *pbMsg, unsigned char bLen);
unsigned char *__fastcall multi_recv_packet(void *packet, unsigned char *a2, int *a3);
void __fastcall multi_send_msg_packet(int a1, unsigned char *a2, unsigned char len);
void __cdecl multi_msg_countdown();
void __fastcall multi_parse_turn(int pnum, int turn);
void __fastcall multi_handle_turn_upper_bit(int pnum);
void __fastcall multi_player_left(int pnum, int reason);
void __cdecl multi_clear_left_tbl();
void __fastcall multi_player_left_msg(int pnum, int left);
void __cdecl multi_net_ping();
int __cdecl multi_handle_delta();
int __fastcall multi_check_pkt_valid(char *a1);
void __cdecl multi_mon_seeds();
void __cdecl multi_begin_timeout();
void __cdecl multi_check_drop_player();
void __cdecl multi_process_network_packets();
void __fastcall multi_handle_all_packets(int players, TPkt *packet, int a3);
void __cdecl multi_process_tmsgs();
void __fastcall multi_send_zero_packet(int pnum, char a2, void *pbSrc, int dwLen);
void __cdecl NetClose();
char __fastcall multi_event_handler(int a1);
void __stdcall multi_handle_events(_SNETEVENT *pEvt);
int __fastcall NetInit(int bSinglePlayer, int *pfExitProgram);
void __fastcall multi_clear_pkt(char *a1);
void __fastcall multi_send_pinfo(int pnum, TCmdPlrInfoHdr *cmd);
int __fastcall InitNewSeed(int newseed);
void __cdecl SetupLocalCoords();
int __fastcall multi_init_single(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info);
int __fastcall multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int *a4);
int __fastcall multi_upgrade(int *a1);
void __fastcall multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3);
/* data */
extern int multi_inf; // weak
extern event_type event_types[3];

366
Source/nthread.cpp Normal file
View File

@ -0,0 +1,366 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int nthread_cpp_init_value; // weak
char byte_679704; // weak
int gdwMsgLenTbl[4];
static CRITICAL_SECTION sgMemCrit;
int gdwDeltaBytesSec; // weak
char byte_679734; // weak
int gdwTurnsInTransit; // weak
int glpMsgTbl[4];
unsigned int glpNThreadId;
char sgbSyncCountdown; // weak
int dword_679754; // weak
char byte_679758; // weak
char sgbPacketCountdown; // weak
char sgbThreadIsRunning; // weak
int gdwLargestMsgSize; // weak
int gdwNormalMsgSize; // weak
int dword_679764; // weak
int nthread_inf = 0x7F800000; // weak
/* rdata */
static HANDLE sghThread = (HANDLE)0xFFFFFFFF; // idb
//----- (00440DB3) --------------------------------------------------------
struct nthread_cpp_init_1
{
nthread_cpp_init_1()
{
nthread_cpp_init_value = nthread_inf;
}
} _nthread_cpp_init_1;
// 47F164: using guessed type int nthread_inf;
// 679700: using guessed type int nthread_cpp_init_value;
//----- (00440DBE) --------------------------------------------------------
struct nthread_cpp_init_2
{
nthread_cpp_init_2()
{
nthread_init_mutex();
nthread_cleanup_mutex_atexit();
}
} _nthread_cpp_init_2;
//----- (00440DC8) --------------------------------------------------------
void __cdecl nthread_init_mutex()
{
InitializeCriticalSection(&sgMemCrit);
}
//----- (00440DD4) --------------------------------------------------------
void __cdecl nthread_cleanup_mutex_atexit()
{
atexit(nthread_cleanup_mutex);
}
//----- (00440DE0) --------------------------------------------------------
void __cdecl nthread_cleanup_mutex()
{
DeleteCriticalSection(&sgMemCrit);
}
//----- (00440DEC) --------------------------------------------------------
void __fastcall nthread_terminate_game(char *pszFcn)
{
char *v1; // esi
int v2; // eax
char *v3; // eax
v1 = pszFcn;
v2 = SErrGetLastError();
if ( v2 != STORM_ERROR_INVALID_PLAYER )
{
if ( v2 == STORM_ERROR_GAME_TERMINATED || v2 == STORM_ERROR_NOT_IN_GAME )
{
gbGameDestroyed = 1;
}
else
{
v3 = GetLastErr();
TermMsg("%s:\n%s", v1, v3);
}
}
}
// 67862D: using guessed type char gbGameDestroyed;
//----- (00440E28) --------------------------------------------------------
int __fastcall nthread_send_and_recv_turn(int cur_turn, int turn_delta)
{
int v2; // ebx
unsigned int v3; // edi
char *v5; // ecx
int v6; // eax
int turn; // [esp+Ch] [ebp-8h]
int turns; // [esp+10h] [ebp-4h]
v2 = turn_delta;
v3 = cur_turn;
if ( SNetGetTurnsInTransit(&turns) )
{
if ( turns >= (unsigned int)gdwTurnsInTransit )
return v3;
while ( 1 )
{
++turns;
v6 = dword_679754 | v3 & 0x7FFFFFFF;
dword_679754 = 0;
turn = v6;
if ( !SNetSendTurn((char *)&turn, 4) )
break;
v3 += v2;
if ( v3 >= 0x7FFFFFFF )
v3 = (unsigned short)v3;
if ( turns >= (unsigned int)gdwTurnsInTransit )
return v3;
}
v5 = "SNetSendTurn";
}
else
{
v5 = "SNetGetTurnsInTransit";
}
nthread_terminate_game(v5);
return 0;
}
// 679738: using guessed type int gdwTurnsInTransit;
// 679754: using guessed type int dword_679754;
//----- (00440EAA) --------------------------------------------------------
int __fastcall nthread_recv_turns(int *pfSendAsync)
{
int *v1; // esi
bool v2; // zf
v1 = pfSendAsync;
*pfSendAsync = 0;
if ( --sgbPacketCountdown )
{
dword_679764 += 50;
return 1;
}
v2 = sgbSyncCountdown-- == 1;
sgbPacketCountdown = byte_679704;
if ( !v2 )
goto LABEL_11;
if ( SNetReceiveTurns(0, 4, (char **)glpMsgTbl, (unsigned int *)gdwMsgLenTbl, (unsigned long *)player_state) )
{
if ( !byte_679758 )
{
byte_679758 = 1;
dword_679764 = GetTickCount();
}
sgbSyncCountdown = 4;
multi_msg_countdown();
LABEL_11:
*v1 = 1;
dword_679764 += 50;
return 1;
}
if ( SErrGetLastError() != STORM_ERROR_NO_MESSAGES_WAITING )
nthread_terminate_game("SNetReceiveTurns");
byte_679758 = 0;
sgbSyncCountdown = 1;
sgbPacketCountdown = 1;
return 0;
}
// 679704: using guessed type char byte_679704;
// 679750: using guessed type char sgbSyncCountdown;
// 679758: using guessed type char byte_679758;
// 679759: using guessed type char sgbPacketCountdown;
// 679764: using guessed type int dword_679764;
//----- (00440F56) --------------------------------------------------------
void __cdecl nthread_set_turn_upper_bit()
{
dword_679754 = 0x80000000;
}
// 679754: using guessed type int dword_679754;
//----- (00440F61) --------------------------------------------------------
void __fastcall nthread_start(bool set_turn_upper_bit)
{
BOOL v1; // esi
char *v3; // eax
unsigned int v4; // esi
unsigned int v5; // eax
char *v6; // eax
_SNETCAPS caps; // [esp+8h] [ebp-24h]
v1 = set_turn_upper_bit;
dword_679764 = GetTickCount();
sgbPacketCountdown = 1;
sgbSyncCountdown = 1;
byte_679758 = 1;
if ( v1 )
nthread_set_turn_upper_bit();
else
dword_679754 = 0;
caps.size = 36;
if ( !SNetGetProviderCaps(&caps) )
{
v3 = GetLastErr();
TermMsg("SNetGetProviderCaps:\n%s", v3);
}
gdwTurnsInTransit = caps.defaultturnsintransit;
if ( !caps.defaultturnsintransit )
gdwTurnsInTransit = 1;
if ( caps.defaultturnssec <= 0x14u && caps.defaultturnssec )
byte_679704 = 0x14u / caps.defaultturnssec;
else
byte_679704 = 1;
v4 = 512;
if ( caps.maxmessagesize < 0x200u )
v4 = caps.maxmessagesize;
gdwDeltaBytesSec = (unsigned int)caps.bytessec >> 2;
gdwLargestMsgSize = v4;
if ( caps.maxplayers > 4u )
caps.maxplayers = 4;
v5 = (3 * (caps.bytessec * (unsigned int)(unsigned char)byte_679704 / 0x14) >> 2) / caps.maxplayers;
gdwNormalMsgSize = v5;
if ( v5 < 0x80 )
{
do
{
byte_679704 *= 2;
v5 *= 2;
}
while ( v5 < 0x80 );
gdwNormalMsgSize = v5;
}
if ( v5 > v4 )
gdwNormalMsgSize = v4;
if ( (unsigned char)gbMaxPlayers > 1u )
{
sgbThreadIsRunning = 0;
EnterCriticalSection(&sgMemCrit);
byte_679734 = 1;
sghThread = (HANDLE)_beginthreadex(NULL, 0, nthread_handler, NULL, 0, &glpNThreadId);
if ( sghThread == (HANDLE)-1 )
{
v6 = GetLastErr();
TermMsg("nthread2:\n%s", v6);
}
SetThreadPriority(sghThread, THREAD_PRIORITY_HIGHEST);
}
}
// 679660: using guessed type char gbMaxPlayers;
// 679704: using guessed type char byte_679704;
// 679730: using guessed type int gdwDeltaBytesSec;
// 679734: using guessed type char byte_679734;
// 679738: using guessed type int gdwTurnsInTransit;
// 679750: using guessed type char sgbSyncCountdown;
// 679754: using guessed type int dword_679754;
// 679758: using guessed type char byte_679758;
// 679759: using guessed type char sgbPacketCountdown;
// 67975A: using guessed type char sgbThreadIsRunning;
// 67975C: using guessed type int gdwLargestMsgSize;
// 679760: using guessed type int gdwNormalMsgSize;
// 679764: using guessed type int dword_679764;
//----- (004410CF) --------------------------------------------------------
unsigned int __stdcall nthread_handler(void *a1)
{
signed int v1; // esi
int recieved; // [esp+Ch] [ebp-4h]
if ( byte_679734 )
{
while ( 1 )
{
EnterCriticalSection(&sgMemCrit);
if ( !byte_679734 )
break;
nthread_send_and_recv_turn(0, 0);
if ( nthread_recv_turns(&recieved) )
v1 = dword_679764 - GetTickCount();
else
v1 = 50;
LeaveCriticalSection(&sgMemCrit);
if ( v1 > 0 )
Sleep(v1);
if ( !byte_679734 )
return 0;
}
LeaveCriticalSection(&sgMemCrit);
}
return 0;
}
// 679734: using guessed type char byte_679734;
// 679764: using guessed type int dword_679764;
//----- (00441145) --------------------------------------------------------
void __cdecl nthread_cleanup()
{
char *v0; // eax
byte_679734 = 0;
gdwTurnsInTransit = 0;
gdwNormalMsgSize = 0;
gdwLargestMsgSize = 0;
if ( sghThread != (HANDLE)-1 && glpNThreadId != GetCurrentThreadId() )
{
if ( !sgbThreadIsRunning )
LeaveCriticalSection(&sgMemCrit);
if ( WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1 )
{
v0 = GetLastErr();
TermMsg("nthread3:\n(%s)", v0);
}
CloseHandle(sghThread);
sghThread = (HANDLE)-1;
}
}
// 679734: using guessed type char byte_679734;
// 679738: using guessed type int gdwTurnsInTransit;
// 67975A: using guessed type char sgbThreadIsRunning;
// 67975C: using guessed type int gdwLargestMsgSize;
// 679760: using guessed type int gdwNormalMsgSize;
//----- (004411C4) --------------------------------------------------------
void __fastcall nthread_ignore_mutex(bool bStart)
{
bool v1; // bl
v1 = bStart;
if ( sghThread != (HANDLE)-1 )
{
if ( bStart )
LeaveCriticalSection(&sgMemCrit);
else
EnterCriticalSection(&sgMemCrit);
sgbThreadIsRunning = v1;
}
}
// 67975A: using guessed type char sgbThreadIsRunning;
//----- (004411EF) --------------------------------------------------------
bool __cdecl nthread_has_500ms_passed()
{
DWORD v0; // eax
int v1; // ecx
v0 = GetTickCount();
v1 = v0 - dword_679764;
if ( gbMaxPlayers == 1 && v1 > 500 )
{
dword_679764 = v0;
v1 = 0;
}
return v1 >= 0;
}
// 679660: using guessed type char gbMaxPlayers;
// 679764: using guessed type int dword_679764;

47
Source/nthread.h Normal file
View File

@ -0,0 +1,47 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//nthread
extern int nthread_cpp_init_value; // weak
extern char byte_679704; // weak
extern int gdwMsgLenTbl[4];
extern int gdwDeltaBytesSec; // weak
extern char byte_679734; // weak
extern int gdwTurnsInTransit; // weak
extern int glpMsgTbl[4];
extern unsigned int glpNThreadId;
extern char sgbSyncCountdown; // weak
extern int dword_679754; // weak
extern char byte_679758; // weak
extern char sgbPacketCountdown; // weak
extern char sgbThreadIsRunning; // weak
extern int gdwLargestMsgSize; // weak
extern int gdwNormalMsgSize; // weak
extern int dword_679764; // weak
void __cdecl nthread_cpp_init_1();
void __cdecl nthread_cpp_init_2();
void __cdecl nthread_init_mutex();
void __cdecl nthread_cleanup_mutex_atexit();
void __cdecl nthread_cleanup_mutex();
void __fastcall nthread_terminate_game(char *pszFcn);
int __fastcall nthread_send_and_recv_turn(int cur_turn, int turn_delta);
int __fastcall nthread_recv_turns(int *pfSendAsync);
void __cdecl nthread_set_turn_upper_bit();
void __fastcall nthread_start(bool set_turn_upper_bit);
unsigned int __stdcall nthread_handler(void *a1);
void __cdecl nthread_cleanup();
void __fastcall nthread_ignore_mutex(bool bStart);
bool __cdecl nthread_has_500ms_passed();
/* data */
extern int nthread_inf; // weak

7489
Source/objects.cpp Normal file

File diff suppressed because it is too large Load Diff

169
Source/objects.h Normal file
View File

@ -0,0 +1,169 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//objects
extern int trapid; // weak
extern int trapdir; // weak
extern int pObjCels[40];
extern char ObjFileList[40];
extern int objectactive[127];
extern int nobjects; // idb
extern int leverid; // idb
extern int objectavail[127];
extern ObjectStruct object[127];
extern int InitObjFlag; // weak
extern int numobjfiles; // weak
void __cdecl InitObjectGFX();
void __cdecl FreeObjectGFX();
bool __fastcall RndLocOk(int xp, int yp);
void __fastcall InitRndLocObj(int min, int max, int objtype);
void __fastcall InitRndLocBigObj(int min, int max, int objtype);
void __fastcall InitRndLocObj5x5(int min, int max, int objtype);
void __cdecl ClrAllObjects();
void __cdecl AddTortures();
void __cdecl AddCandles();
void __fastcall AddBookLever(int lx1, int ly1, int lx2, int ly2, int x1, int y1, int x2, int y2, int msg);
void __cdecl InitRndBarrels();
void __fastcall AddL1Objs(int x1, int y1, int x2, int y2);
void __fastcall AddL2Objs(int x1, int y1, int x2, int y2);
void __fastcall AddL3Objs(int x1, int y1, int x2, int y2);
bool __fastcall WallTrapLocOk(int xp, int yp);
void __cdecl AddL2Torches();
bool __fastcall TorchLocOK(int xp, int yp);
void __cdecl AddObjTraps();
void __cdecl AddChestTraps();
void __fastcall LoadMapObjects(unsigned char *pMap, int startx, int starty, int x1, int y1, int w, int h, int leveridx);
void __fastcall LoadMapObjs(unsigned char *pMap, int startx, int starty);
void __cdecl AddDiabObjs();
void __cdecl AddStoryBooks();
void __fastcall AddHookedBodies(int freq);
void __cdecl AddL4Goodies();
void __cdecl AddLazStand();
void __fastcall InitObjects(int a1);
void __fastcall SetMapObjects(char *pMap, int startx, int starty);
void __fastcall DeleteObject(int oi, int i);
void __fastcall SetupObject(int i, int x, int y, int ot);
void __fastcall SetObjMapRange(int i, int x1, int y1, int x2, int y2, int v);
void __fastcall SetBookMsg(int i, int msg);
void __fastcall AddL1Door(int i, int x, int y, int ot);
void __fastcall AddSCambBook(int i);
void __fastcall AddChest(int i, int t);
void __fastcall AddL2Door(int i, int x, int y, int ot);
void __fastcall AddL3Door(int i, int x, int y, int ot);
void __fastcall AddSarc(int i);
void __fastcall AddFlameTrap(int i);
void __fastcall AddFlameLvr(int i);
void __fastcall AddTrap(int i);
void __fastcall AddObjLight(int i, int r);
void __fastcall AddBarrel(int i);
void __fastcall AddShrine(int i);
void __fastcall AddBookcase(int i);
void __fastcall AddPurifyingFountain(int i);
void __fastcall AddArmorStand(int i);
void __fastcall AddDecap(int i);
void __fastcall AddVilebook(int i);
void __fastcall AddMagicCircle(int i);
void __fastcall AddBookstand(int i);
void __fastcall AddPedistal(int i);
void __fastcall AddStoryBook(int i);
void __fastcall AddWeaponRack(int i);
void __fastcall AddTorturedBody(int i);
void __fastcall GetRndObjLoc(int randarea, int *xx, int *yy);
void __cdecl AddMushPatch();
void __cdecl AddSlainHero();
void __fastcall AddObject(int ot, int ox, int oy);
void __fastcall Obj_Light(int i, int lr);
void __fastcall Obj_Circle(int i);
void __fastcall Obj_StopAnim(int i);
void __fastcall Obj_Door(int i);
void __fastcall Obj_Sarc(int i);
void __fastcall ActivateTrapLine(int ttype, int tid);
void __fastcall Obj_FlameTrap(int i);
void __fastcall Obj_Trap(int i);
void __fastcall Obj_BCrossDamage(int i);
void __cdecl ProcessObjects();
void __fastcall ObjSetMicro(int dx, int dy, int pn);
void __fastcall objects_set_door_piece(int x, int y);
void __fastcall ObjSetMini(int x, int y, int v);
void __fastcall ObjL1Special(int x1, int y1, int x2, int y2);
void __fastcall ObjL2Special(int x1, int y1, int x2, int y2);
void __fastcall DoorSet(int oi, int dx, int dy);
void __cdecl RedoPlayerVision();
void __fastcall OperateL1RDoor(int pnum, int oi, unsigned char sendflag);
void __fastcall OperateL1LDoor(int pnum, int oi, unsigned char sendflag);
void __fastcall OperateL2RDoor(int pnum, int oi, unsigned char sendflag);
void __fastcall OperateL2LDoor(int pnum, int oi, unsigned char sendflag);
void __fastcall OperateL3RDoor(int pnum, int oi, unsigned char sendflag);
void __fastcall OperateL3LDoor(int pnum, int oi, unsigned char sendflag);
void __fastcall MonstCheckDoors(int m);
void __fastcall ObjChangeMap(int x1, int y1, int x2, int y2);
void __fastcall ObjChangeMapResync(int x1, int y1, int x2, int y2);
void __fastcall OperateL1Door(int pnum, int i, unsigned char sendflag);
void __fastcall OperateLever(int pnum, int i);
void __fastcall OperateBook(int pnum, int i);
void __fastcall OperateBookLever(int pnum, int i);
void __fastcall OperateSChambBk(int pnum, int i);
void __fastcall OperateChest(int pnum, int i, unsigned char sendmsg);
void __fastcall OperateMushPatch(int pnum, int i);
void __fastcall OperateInnSignChest(int pnum, int i);
void __fastcall OperateSlainHero(int pnum, int i, unsigned char sendmsg);
void __fastcall OperateTrapLvr(int i);
void __fastcall OperateSarc(int pnum, int i, unsigned char sendmsg);
void __fastcall OperateL2Door(int pnum, int i, unsigned char sendflag);
void __fastcall OperateL3Door(int pnum, int i, unsigned char sendflag);
void __fastcall OperatePedistal(int pnum, int i);
void __fastcall TryDisarm(int pnum, int i);
int __fastcall ItemMiscIdIdx(int imiscid);
void __fastcall OperateShrine(int pnum, int i, int sType);
void __fastcall OperateSkelBook(int pnum, int i, unsigned char sendmsg);
void __fastcall OperateBookCase(int pnum, int i, unsigned char sendmsg);
void __fastcall OperateDecap(int pnum, int i, unsigned char sendmsg);
void __fastcall OperateArmorStand(int pnum, int i, unsigned char sendmsg);
int __fastcall FindValidShrine(int i);
void __fastcall OperateGoatShrine(int pnum, int i, int sType);
void __fastcall OperateCauldron(int pnum, int i, int sType);
bool __fastcall OperateFountains(int pnum, int i);
void __fastcall OperateWeaponRack(int pnum, int i, unsigned char sendmsg);
void __fastcall OperateStoryBook(int pnum, int i);
void __fastcall OperateLazStand(int pnum, int i);
void __fastcall OperateObject(int pnum, int i, unsigned char TeleFlag);
void __fastcall SyncOpL1Door(int pnum, int cmd, int i);
void __fastcall SyncOpL2Door(int pnum, int cmd, int i);
void __fastcall SyncOpL3Door(int pnum, int cmd, int i);
void __fastcall SyncOpObject(int pnum, int cmd, int i);
void __fastcall BreakCrux(int i);
void __fastcall BreakBarrel(int pnum, int i, int dam, unsigned char forcebreak, int sendmsg);
void __fastcall BreakObject(int pnum, int oi);
void __fastcall SyncBreakObj(int pnum, int oi);
void __fastcall SyncL1Doors(int i);
void __fastcall SyncCrux(int i);
void __fastcall SyncLever(int i);
void __fastcall SyncQSTLever(int i);
void __fastcall SyncPedistal(int i);
void __fastcall SyncL2Doors(int i);
void __fastcall SyncL3Doors(int i);
void __fastcall SyncObjectAnim(int o);
void __fastcall GetObjectStr(int i);
/* rdata */
extern int ObjTypeConv[113];
extern ObjDataStruct AllObjects[99];
extern char *ObjMasterLoadList[56];
extern int bxadd[8];
extern int byadd[8];
extern char *shrinestrs[26];
extern unsigned char shrinemin[26];
extern unsigned char shrinemax[26];
extern unsigned char shrineavail[26];
extern char *StoryBookName[9];
extern int StoryText[3][3];

302
Source/pack.cpp Normal file
View File

@ -0,0 +1,302 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int pack_cpp_init_value; // weak
int pack_inf = 0x7F800000; // weak
//----- (0044875A) --------------------------------------------------------
struct pack_cpp_init
{
pack_cpp_init()
{
pack_cpp_init_value = pack_inf;
}
} _pack_cpp_init;
// 47F168: using guessed type int pack_inf;
// 67D7C8: using guessed type int pack_cpp_init_value;
//----- (00448765) --------------------------------------------------------
void __fastcall PackPlayer(PkPlayerStruct *pPack, int pnum, bool manashield)
{
PlayerStruct *pPlayer; // edi
int i; // [esp+8h] [ebp-Ch]
ItemStruct *pi; // [esp+Ch] [ebp-8h]
PkItemStruct *pki; // [esp+10h] [ebp-4h]
memset(pPack, 0, 0x4F2);
pPlayer = &plr[pnum];
pPack->destAction = pPlayer->destAction;
pPack->destParam1 = pPlayer->destParam1;
pPack->destParam2 = pPlayer->destParam2;
pPack->plrlevel = pPlayer->plrlevel;
pPack->px = pPlayer->WorldX;
pPack->py = pPlayer->WorldY;
pPack->targx = pPlayer->_ptargx;
pPack->targy = pPlayer->_ptargy;
strcpy(pPack->pName, pPlayer->_pName);
pPack->pClass = pPlayer->_pClass;
pPack->pBaseStr = pPlayer->_pBaseStr;
pPack->pBaseMag = pPlayer->_pBaseMag;
pPack->pBaseDex = pPlayer->_pBaseDex;
pPack->pBaseVit = pPlayer->_pBaseVit;
pPack->pLevel = pPlayer->_pLevel;
pPack->pStatPts = pPlayer->_pStatPts;
pPack->pExperience = pPlayer->_pExperience;
pPack->pGold = pPlayer->_pGold;
pPack->pHPBase = pPlayer->_pHPBase;
pPack->pMaxHPBase = pPlayer->_pMaxHPBase;
pPack->pManaBase = pPlayer->_pManaBase;
pPack->pMaxManaBase = pPlayer->_pMaxManaBase;
pPack->pMemSpells = pPlayer->_pMemSpells[0];
pPack->pMemSpells2 = pPlayer->_pMemSpells[1];
for(i = 0; i < 37; i++)
pPack->pSplLvl[i] = pPlayer->_pSplLvl[i];
pki = pPack->InvBody;
pi = pPlayer->InvBody;
for(i = 0; i < 7; i++)
PackItem(pki++, pi++);
pki = pPack->InvList;
pi = pPlayer->InvList;
for(i = 0; i < 40; i++)
PackItem(pki++, pi++);
for(i = 0; i < 40; i++)
pPack->InvGrid[i] = pPlayer->InvGrid[i];
pPack->_pNumInv = pPlayer->_pNumInv;
pki = pPack->SpdList;
pi = pPlayer->SpdList;
for(i = 0; i < 8; i++)
PackItem(pki++, pi++);
pPack->pDiabloKillLevel = pPlayer->pDiabloKillLevel;
if ( gbMaxPlayers == 1 || manashield )
pPack->pManaShield = pPlayer->pManaShield;
else
pPack->pManaShield = 0;
}
// 679660: using guessed type char gbMaxPlayers;
//----- (00448953) --------------------------------------------------------
void __fastcall PackItem(PkItemStruct *id, ItemStruct *is)
{
short v2; // ax
short v3; // bx
if ( is->_itype == -1 )
{
id->idx = -1;
}
else
{
id->idx = is->IDidx;
if ( is->IDidx == IDI_EAR )
{
_LOBYTE(v2) = 0;
_LOBYTE(v3) = 0;
_HIBYTE(v2) = is->_iName[7];
id->iCreateInfo = is->_iName[8] | v2;
id->iSeed = is->_iName[12] | ((is->_iName[11] | ((is->_iName[10] | (is->_iName[9] << 8)) << 8)) << 8);
id->bId = is->_iName[13];
id->bDur = is->_iName[14];
id->bMDur = is->_iName[15];
id->bCh = is->_iName[16];
id->bMCh = is->_iName[17];
_HIBYTE(v3) = is->_iName[18];
id->wValue = _LOWORD(is->_ivalue) | v3 | ((_LOWORD(is->_iCurs) - 19) << 6);
id->dwBuff = is->_iName[22] | ((is->_iName[21] | ((is->_iName[20] | (is->_iName[19] << 8)) << 8)) << 8);
}
else
{
id->iSeed = is->_iSeed;
id->iCreateInfo = is->_iCreateInfo;
id->bId = _LOBYTE(is->_iIdentified) + 2 * is->_iMagical;
id->bDur = is->_iDurability;
id->bMDur = is->_iMaxDur;
id->bCh = is->_iCharges;
id->bMCh = is->_iMaxCharges;
if ( !is->IDidx )
id->wValue = is->_ivalue;
}
}
}
//----- (00448A5E) --------------------------------------------------------
void __fastcall VerifyGoldSeeds(PlayerStruct *pPlayer)
{
int i; // ebp
int j; // ecx
for(i = 0; i < pPlayer->_pNumInv; i++)
{
if ( pPlayer->InvList[i].IDidx == IDI_GOLD && pPlayer->_pNumInv > 0 )
{
for(j = 0; j < pPlayer->_pNumInv; j++)
{
if ( i != j )
{
if ( pPlayer->InvList[j].IDidx == IDI_GOLD && pPlayer->InvList[i]._iSeed == pPlayer->InvList[j]._iSeed )
{
pPlayer->InvList[i]._iSeed = GetRndSeed();
j = -1;
}
}
}
}
}
}
//----- (00448AD0) --------------------------------------------------------
void __fastcall UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool killok)
{
PlayerStruct *pPlayer; // esi
signed int v6; // eax
int i; // [esp+10h] [ebp-8h]
ItemStruct *pi; // [esp+14h] [ebp-4h]
PkItemStruct *pki; // [esp+20h] [ebp+8h]
pPlayer = &plr[pnum];
ClearPlrRVars(&plr[pnum]);
pPlayer->WorldX = (unsigned char)pPack->px;
pPlayer->WorldY = (unsigned char)pPack->py;
pPlayer->_px = (unsigned char)pPack->px;
pPlayer->_py = (unsigned char)pPack->py;
pPlayer->_ptargx = (unsigned char)pPack->targx;
pPlayer->_ptargy = (unsigned char)pPack->targy;
pPlayer->plrlevel = (unsigned char)pPack->plrlevel;
ClrPlrPath(pnum);
pPlayer->destAction = -1;
strcpy(pPlayer->_pName, pPack->pName);
_LOBYTE(pPlayer->_pClass) = pPack->pClass;
InitPlayer(pnum, 1);
pPlayer->_pBaseStr = (unsigned char)pPack->pBaseStr;
pPlayer->_pStrength = (unsigned char)pPack->pBaseStr;
pPlayer->_pBaseMag = (unsigned char)pPack->pBaseMag;
pPlayer->_pMagic = (unsigned char)pPack->pBaseMag;
pPlayer->_pBaseDex = (unsigned char)pPack->pBaseDex;
pPlayer->_pDexterity = (unsigned char)pPack->pBaseDex;
pPlayer->_pBaseVit = (unsigned char)pPack->pBaseVit;
pPlayer->_pVitality = (unsigned char)pPack->pBaseVit;
pPlayer->_pLevel = pPack->pLevel;
pPlayer->_pStatPts = (unsigned char)pPack->pStatPts;
pPlayer->_pExperience = pPack->pExperience;
pPlayer->_pGold = pPack->pGold;
pPlayer->_pMaxHPBase = pPack->pMaxHPBase;
v6 = pPack->pHPBase;
pPlayer->_pHPBase = v6;
if ( !killok )
{
_LOBYTE(v6) = v6 & 0xC0;
if ( v6 < 64 )
pPlayer->_pHPBase = 64;
}
pPlayer->_pMaxManaBase = pPack->pMaxManaBase;
pPlayer->_pManaBase = pPack->pManaBase;
pPlayer->_pMemSpells[0] = pPack->pMemSpells;
pPlayer->_pMemSpells[1] = pPack->pMemSpells2;
for(i = 0; i < 37; i++)
pPlayer->_pSplLvl[i] = pPack->pSplLvl[i];
pki = pPack->InvBody;
pi = pPlayer->InvBody;
for(i = 0; i < 7; i++)
UnPackItem(pki++, pi++);
pki = pPack->InvList;
pi = pPlayer->InvList;
for(i = 0; i < 40; i++)
UnPackItem(pki++, pi++);
for(i = 0; i < 40; i++)
pPlayer->InvGrid[i] = pPack->InvGrid[i];
pPlayer->_pNumInv = (unsigned char)pPack->_pNumInv;
VerifyGoldSeeds(pPlayer);
pki = pPack->SpdList;
pi = pPlayer->SpdList;
for(i = 0; i < 8; i++)
UnPackItem(pki++, pi++);
if ( pnum == myplr )
{
for(i = 0; i < 20; i++)
witchitem[i]._itype = -1;
}
CalcPlrInv(pnum, 0);
pPlayer->pTownWarps = 0;
pPlayer->pDungMsgs = 0;
pPlayer->pLvlLoad = 0;
pPlayer->pDiabloKillLevel = pPack->pDiabloKillLevel;
pPlayer->pBattleNet = pPack->pBattleNet;
pPlayer->pManaShield = pPack->pManaShield;
}
//----- (00448D48) --------------------------------------------------------
void __fastcall UnPackItem(PkItemStruct *is, ItemStruct *id)
{
PkItemStruct *v2; // esi
ItemStruct *v3; // edi
int v5; // ecx
v2 = is;
v3 = id;
if ( is->idx == -1 )
{
id->_itype = -1;
}
else
{
if ( is->idx == IDI_EAR )
{
RecreateEar(
127,
is->iCreateInfo,
is->iSeed,
is->bId,
(unsigned char)is->bDur,
(unsigned char)is->bMDur,
(unsigned char)is->bCh,
(unsigned char)is->bMCh,
(unsigned short)is->wValue,
is->dwBuff);
}
else
{
v5 = (unsigned short)is->wValue;
_LOWORD(v5) = v2->iCreateInfo;
RecreateItem(127, is->idx, v5, v2->iSeed, (unsigned short)v2->wValue);
item[127]._iMagical = (unsigned char)v2->bId >> 1;
item[127]._iIdentified = v2->bId & 1;
item[127]._iDurability = (unsigned char)v2->bDur;
item[127]._iMaxDur = (unsigned char)v2->bMDur;
item[127]._iCharges = (unsigned char)v2->bCh;
item[127]._iMaxCharges = (unsigned char)v2->bMCh;
}
qmemcpy(v3, &item[127], sizeof(ItemStruct));
}
}

24
Source/pack.h Normal file
View File

@ -0,0 +1,24 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//pack
extern int pack_cpp_init_value; // weak
void __cdecl pack_cpp_init();
void __fastcall PackPlayer(PkPlayerStruct *pPack, int pnum, bool manashield);
void __fastcall PackItem(PkItemStruct *id, ItemStruct *is);
void __fastcall VerifyGoldSeeds(PlayerStruct *pPlayer);
void __fastcall UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool killok);
void __fastcall UnPackItem(PkItemStruct *is, ItemStruct *id);
/* data */
extern int pack_inf; // weak

353
Source/palette.cpp Normal file
View File

@ -0,0 +1,353 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
PALETTEENTRY logical_palette[256];
int palette_cpp_init_value; // weak
PALETTEENTRY system_palette[256];
PALETTEENTRY orig_palette[256];
UINT gdwPalEntries;
int palette_inf = 0x7F800000; // weak
/* rdata */
int gamma_correction = 100; // idb
int color_cycling_enabled = 1; // idb
bool sgbFadedIn = 1;
//----- (00448DFA) --------------------------------------------------------
struct palette_cpp_init
{
palette_cpp_init()
{
palette_cpp_init_value = palette_inf;
}
} _palette_cpp_init;
// 47F16C: using guessed type int palette_inf;
// 67DBCC: using guessed type int palette_cpp_init_value;
//----- (00448E05) --------------------------------------------------------
void __cdecl palette_save_gamme()
{
SRegSaveValue("Diablo", "Gamma Correction", 0, gamma_correction);
SRegSaveValue("Diablo", "Color Cycling", 0, color_cycling_enabled);
}
//----- (00448E33) --------------------------------------------------------
void __cdecl palette_init()
{
int v0; // eax
int v1; // eax
palette_load_gamma();
memcpy(system_palette, orig_palette, 0x400u);
LoadSysPal();
v0 = IDirectDraw_CreatePalette(lpDDInterface, DDPCAPS_ALLOW256|DDPCAPS_8BIT, system_palette, &lpDDPalette, NULL);
if ( v0 )
TermDlg(111, v0, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 143);
v1 = IDirectDrawSurface_SetPalette(lpDDSPrimary, lpDDPalette);
if ( v1 )
TermDlg(111, v1, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 146);
}
//----- (00448EAB) --------------------------------------------------------
void __cdecl palette_load_gamma()
{
int v3; // eax
int value; // [esp+8h] [ebp-4h]
value = gamma_correction;
if ( !SRegLoadValue("Diablo", "Gamma Correction", 0, &value) )
value = 100;
if ( value >= 30 )
{
if ( value > 100 )
value = 100;
}
else
{
value = 30;
}
gamma_correction = value - value % 5;
if ( SRegLoadValue("Diablo", "Color Cycling", 0, &value) )
v3 = value;
else
v3 = 1;
color_cycling_enabled = v3;
}
//----- (00448F20) --------------------------------------------------------
void __cdecl LoadSysPal()
{
HDC hDC; // ebx
int i; // ecx
int iStartIndex; // edi
for(i = 0; i < 256; i++)
system_palette[i].peFlags = PC_NOCOLLAPSE|PC_RESERVED;
if ( !fullscreen )
{
hDC = GetDC(NULL);
gdwPalEntries = GetDeviceCaps(hDC, NUMRESERVED) / 2;
GetSystemPaletteEntries(hDC, 0, gdwPalEntries, system_palette);
for ( i = 0; i < gdwPalEntries; i++ )
system_palette[i].peFlags = 0;
iStartIndex = 256 - gdwPalEntries;
GetSystemPaletteEntries(hDC, iStartIndex, gdwPalEntries, &system_palette[iStartIndex]);
if ( iStartIndex < 256 )
{
for(i = iStartIndex; i < 256; i++)
system_palette[i].peFlags = 0;
}
ReleaseDC(NULL, hDC);
}
}
// 484364: using guessed type int fullscreen;
//----- (00448FC9) --------------------------------------------------------
void __fastcall LoadPalette(char *pszFileName)
{
int i; // eax
char PalData[256][3]; // [esp+0h] [ebp-304h]
void *pBuf; // [esp+300h] [ebp-4h]
WOpenFile(pszFileName, &pBuf, 0);
WReadFile(pBuf, (char *)PalData, 768);
WCloseFile(pBuf);
for(i = 0; i < 256; i++)
{
orig_palette[i].peFlags = 0;
orig_palette[i].peRed = PalData[i][0];
orig_palette[i].peGreen = PalData[i][1];
orig_palette[i].peBlue = PalData[i][2];
}
}
//----- (00449025) --------------------------------------------------------
void __fastcall LoadRndLvlPal(int l)
{
char *pszPal; // ecx
char szTemp[260]; // [esp+4h] [ebp-104h]
if ( l )
{
sprintf(szTemp, "Levels\\L%iData\\L%i_%i.PAL", l, l, random(0, 4) + 1);
pszPal = szTemp;
}
else
{
pszPal = "Levels\\TownData\\Town.pal";
}
LoadPalette(pszPal);
}
//----- (0044906C) --------------------------------------------------------
void __cdecl ResetPal()
{
if ( !lpDDSPrimary
|| IDirectDrawSurface_IsLost(lpDDSPrimary) != DDERR_SURFACELOST
|| !IDirectDrawSurface_Restore(lpDDSPrimary) )
{
SDrawRealizePalette();
}
}
//----- (00449097) --------------------------------------------------------
void __cdecl palette_inc_gamma()
{
if ( gamma_correction < 100 )
{
gamma_correction += 5;
if ( gamma_correction > 100 )
gamma_correction = 100;
palette_apply_gamma_correction(system_palette, logical_palette, 256);
palette_update();
}
}
//----- (004490D0) --------------------------------------------------------
void __cdecl palette_update()
{
int v0; // ecx
int v1; // eax
if ( lpDDPalette )
{
v0 = 0;
v1 = 256;
if ( !fullscreen )
{
v0 = gdwPalEntries;
v1 = 2 * (128 - gdwPalEntries);
}
SDrawUpdatePalette(v0, v1, &system_palette[v0], 0);
}
}
// 484364: using guessed type int fullscreen;
//----- (00449107) --------------------------------------------------------
void __fastcall palette_apply_gamma_correction(PALETTEENTRY *dst, PALETTEENTRY *src, int n)
{
PALETTEENTRY *v3; // edi
PALETTEENTRY *v4; // esi
double v5; // [esp+18h] [ebp-Ch]
v3 = src;
v4 = dst;
v5 = (double)gamma_correction * 0.01;
if ( n > 0 )
{
do
{
v4->peRed = pow(v3->peRed * 0.00390625, v5) * 256.0;
v4->peGreen = pow(v3->peGreen * 0.00390625, v5) * 256.0;
v4->peBlue = pow(v3->peBlue * 0.00390625, v5) * 256.0;
++v4;
++v3;
--n;
}
while ( n );
}
}
//----- (004491D0) --------------------------------------------------------
void __cdecl palette_dec_gamma()
{
if ( gamma_correction > 30 )
{
gamma_correction -= 5;
if ( gamma_correction < 30 )
gamma_correction = 30;
palette_apply_gamma_correction(system_palette, logical_palette, 256);
palette_update();
}
}
//----- (00449209) --------------------------------------------------------
int __fastcall palette_update_gamma(int gamma)
{
if ( gamma )
{
gamma_correction = 130 - gamma;
palette_apply_gamma_correction(system_palette, logical_palette, 256);
palette_update();
}
return 130 - gamma_correction;
}
//----- (0044923E) --------------------------------------------------------
void __cdecl BlackPalette()
{
SetFadeLevel(0);
}
//----- (00449245) --------------------------------------------------------
void __fastcall SetFadeLevel(int fadeval)
{
int i; // eax
if ( lpDDInterface )
{
for(i = 0; i < 255; i++)
{
system_palette[i].peRed = (fadeval * logical_palette[i].peRed) >> 8;
system_palette[i].peGreen = (fadeval * logical_palette[i].peGreen) >> 8;
system_palette[i].peBlue = (fadeval * logical_palette[i].peBlue) >> 8;
}
Sleep(3);
IDirectDraw_WaitForVerticalBlank(lpDDInterface, DDWAITVB_BLOCKBEGIN, NULL);
palette_update();
}
}
//----- (004492B0) --------------------------------------------------------
void __fastcall PaletteFadeIn(int fr)
{
int i; // ebp
palette_apply_gamma_correction(logical_palette, orig_palette, 256);
for(i = 0; i < 256; i += fr)
SetFadeLevel(i);
SetFadeLevel(256);
memcpy(logical_palette, orig_palette, 0x400u);
sgbFadedIn = 1;
}
//----- (00449306) --------------------------------------------------------
void __fastcall PaletteFadeOut(int fr)
{
int i; // esi
if ( sgbFadedIn )
{
for(i = 256; i > 0; i -= fr)
SetFadeLevel(i);
SetFadeLevel(0);
sgbFadedIn = 0;
}
}
//----- (00449336) --------------------------------------------------------
void __cdecl palette_update_caves()
{
BYTE v0; // cx
signed int v1; // esi
signed int v2; // eax
BYTE v4; // [esp+6h] [ebp-2h]
BYTE v5;
v0 = system_palette[1].peRed;
v5 = system_palette[1].peGreen;
v4 = system_palette[1].peBlue;
v1 = 1;
do
{
v2 = v1++;
system_palette[v2].peRed = system_palette[v2 + 1].peRed;
system_palette[v2].peGreen = system_palette[v2 + 1].peGreen;
system_palette[v2].peBlue = system_palette[v2 + 1].peBlue;
}
while ( v1 < 31 );
system_palette[v1].peRed = v0;
system_palette[v1].peGreen = v5;
system_palette[v1].peBlue = v4;
palette_update();
}
//----- (00449398) --------------------------------------------------------
void __fastcall palette_update_quest_palette(int n)
{
int i; // eax
for ( i = 32 - n; i >= 0; --i )
logical_palette[i] = orig_palette[i];
palette_apply_gamma_correction(system_palette, logical_palette, 32);
palette_update();
}
//----- (004493C6) --------------------------------------------------------
bool __cdecl palette_get_colour_cycling()
{
return color_cycling_enabled;
}
//----- (004493CC) --------------------------------------------------------
void __fastcall palette_set_color_cycling(bool enabled)
{
color_cycling_enabled = enabled;
}

49
Source/palette.h Normal file
View File

@ -0,0 +1,49 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//palette
extern PALETTEENTRY logical_palette[256];
extern int palette_cpp_init_value; // weak
extern PALETTEENTRY system_palette[256];
extern PALETTEENTRY orig_palette[256];
extern UINT gdwPalEntries;
void __cdecl palette_cpp_init();
void __cdecl palette_save_gamme();
void __cdecl palette_init();
void __cdecl palette_load_gamma();
void __cdecl LoadSysPal();
void __fastcall LoadPalette(char *pszFileName);
void __fastcall LoadRndLvlPal(int l);
void __cdecl ResetPal();
void __cdecl palette_inc_gamma();
void __cdecl palette_update();
void __fastcall palette_apply_gamma_correction(PALETTEENTRY *dst, PALETTEENTRY *src, int n);
void __cdecl palette_dec_gamma();
int __fastcall palette_update_gamma(int gamma);
void __cdecl BlackPalette();
void __fastcall SetFadeLevel(int brightness);
void __fastcall PaletteFadeIn(int fr);
void __fastcall PaletteFadeOut(int fr);
void __cdecl palette_update_caves();
void __fastcall palette_update_quest_palette(int n);
bool __cdecl palette_get_colour_cycling();
void __fastcall palette_set_color_cycling(bool enabled);
/* data */
extern int palette_inf; // weak
/* rdata */
extern int gamma_correction; // idb
extern int color_cycling_enabled; // idb
extern bool sgbFadedIn;

441
Source/path.cpp Normal file
View File

@ -0,0 +1,441 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
PATHNODE path_nodes[300];
int gdwCurPathStep;
int pnode_vals[26];
PATHNODE *pnode_ptr;
PATHNODE *pnode_tblptr[300];
PATHNODE path_2_nodes[300];
char pathxdir[8] = { -1, -1, 1, 1, -1, 0, 1, 0 };
char pathydir[8] = { -1, 1, -1, 1, 0, -1, 0, 1 };
/* rdata */
char path_directions[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 };
//----- (004493D4) --------------------------------------------------------
int __fastcall FindPath(bool (__fastcall *PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path)
{
PATHNODE *v8; // esi
char v9; // al
PATHNODE *v11; // eax
int result; // eax
PATHNODE *v13; // edx
int v14; // eax
int v15; // edi
bool v16; // zf
int *v17; // ecx
char v18; // dl
pnode_vals[0] = 0;
*(_DWORD *)&path_2_nodes[0].f = (unsigned int)path_new_step();
gdwCurPathStep = 0;
pnode_ptr = path_new_step();
v8 = path_new_step();
v8->g = 0;
v9 = path_get_h_cost(sx, sy, dx, dy);
v8->h = v9;
v8->x = sx;
v8->f = v9 + v8->g;
v8->y = sy;
*(_DWORD *)(*(_DWORD *)&path_2_nodes[0].f + 48) = (unsigned int)v8;
while ( 1 )
{
v11 = GetNextPath();
if ( !v11 )
return 0;
if ( v11->x == dx && v11->y == dy )
break;
if ( !path_get_path(PosOk, PosOkArg, v11, dx, dy) )
return 0;
}
v13 = v11;
v14 = (int)&v11->Parent;
v15 = 0;
if ( *(_DWORD *)v14 )
{
while ( 1 )
{
v16 = v15 == 25;
if ( v15 >= 25 )
break;
pnode_vals[++v15] = path_directions[3 * (v13->y - *(_DWORD *)(*(_DWORD *)v14 + 8))
- *(_DWORD *)(*(_DWORD *)v14 + 4)
+ 4
+ v13->x];
v13 = *(PATHNODE **)v14;
v14 = *(_DWORD *)v14 + 12;
if ( !*(_DWORD *)v14 )
{
v16 = v15 == 25;
break;
}
}
if ( v16 )
return 0;
}
result = 0;
if ( v15 > 0 )
{
v17 = &pnode_vals[v15];
do
{
v18 = *(_BYTE *)v17;
--v17;
path[result++] = v18;
}
while ( result < v15 );
}
return result;
}
//----- (004494D3) --------------------------------------------------------
int __fastcall path_get_h_cost(int sx, int sy, int dx, int dy)
{
int v4; // esi
int v5; // edi
int v6; // eax
int v7; // ecx
v4 = sy;
v5 = abs(sx - dx);
v6 = abs(v4 - dy);
v7 = v5;
if ( v5 >= v6 )
{
v7 = v6;
if ( v5 > v6 )
v6 = v5;
}
return 2 * (v7 + v6);
}
//----- (00449504) --------------------------------------------------------
int __fastcall path_check_equal(PATHNODE *pPath, int dx, int dy)
{
int v4; // [esp-4h] [ebp-4h]
if ( pPath->x == dx || pPath->y == dy )
v4 = 2;
else
v4 = 3;
return v4;
}
//----- (0044951C) --------------------------------------------------------
PATHNODE *__cdecl GetNextPath()
{
PATHNODE *result; // eax
result = *(PATHNODE **)(*(_DWORD *)&path_2_nodes[0].f + 48);
if ( result )
{
*(_DWORD *)(*(_DWORD *)&path_2_nodes[0].f + 48) = (unsigned int)result->NextNode;
result->NextNode = pnode_ptr->NextNode;
pnode_ptr->NextNode = result;
}
return result;
}
//----- (00449546) --------------------------------------------------------
bool __fastcall path_solid_pieces(PATHNODE *pPath, int dx, int dy)
{
bool result; // eax
int dir; // ecx
int v8; // ecx
int v10; // edx
result = 1;
dir = path_directions[3 * (dy - pPath->y) - pPath->x + 4 + dx] - 5;
if ( !dir )
{
result = 0;
if ( nSolidTable[dPiece[dx][dy + 1]] )
return result;
v8 = dPiece[dx + 1][dy];
goto LABEL_13;
}
dir--;
if ( !dir )
{
v10 = dPiece[dx][dy + 1];
goto LABEL_9;
}
dir--;
if ( !dir )
{
v10 = dPiece[dx][dy-1]; /* check */
LABEL_9:
result = 0;
if ( nSolidTable[v10] )
return result;
v8 = dPiece[dx-4][dy]; /* check */
goto LABEL_13;
}
if ( dir == 1 )
{
result = 0;
if ( !nSolidTable[dPiece[dx + 1][dy]] )
{
v8 = dPiece[dx][dy-1]; /* check */
LABEL_13:
if ( nSolidTable[v8] == result )
result = 1;
return result;
}
}
return result;
}
//----- (004495ED) --------------------------------------------------------
int __fastcall path_get_path(bool (__fastcall *PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y)
{
int v5; // eax
int dx; // esi
int dy; // edi
int i; // [esp+14h] [ebp-4h]
v5 = 0;
for ( i = 0; ; v5 = i )
{
dx = pPath->x + pathxdir[v5];
dy = pPath->y + pathydir[v5];
if ( !PosOk(PosOkArg, dx, dy) )
break;
if ( path_solid_pieces(pPath, dx, dy) )
goto LABEL_8;
LABEL_9:
if ( ++i >= 8 )
return 1;
}
if ( dx != x || dy != y )
goto LABEL_9;
LABEL_8:
if ( path_parent_path(pPath, dx, dy, x, y) )
goto LABEL_9;
return 0;
}
//----- (0044966F) --------------------------------------------------------
int __fastcall path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy)
{
PATHNODE *v5; // edi
int v6; // ebx
PATHNODE *v7; // esi
signed int v8; // eax
struct PATHNODE **v9; // ecx
char v10; // al
PATHNODE *v11; // esi
signed int v12; // eax
struct PATHNODE **v13; // ecx
char v14; // al
PATHNODE *result; // eax
PATHNODE *v16; // esi
char v17; // al
signed int v18; // ecx
struct PATHNODE **v19; // eax
int a1; // [esp+Ch] [ebp-4h]
a1 = dx;
v5 = pPath;
v6 = pPath->g + path_check_equal(pPath, dx, dy);
v7 = path_get_node1(a1, dy);
if ( v7 )
{
v8 = 0;
v9 = v5->Child;
do
{
if ( !*v9 )
break;
++v8;
++v9;
}
while ( v8 < 8 );
v5->Child[v8] = v7;
if ( v6 < v7->g )
{
if ( path_solid_pieces(v5, a1, dy) )
{
v10 = v7->h;
v7->Parent = v5;
v7->g = v6;
v7->f = v6 + v10;
}
}
}
else
{
v11 = path_get_node2(a1, dy);
if ( v11 )
{
v12 = 0;
v13 = v5->Child;
do
{
if ( !*v13 )
break;
++v12;
++v13;
}
while ( v12 < 8 );
v5->Child[v12] = v11;
if ( v6 < v11->g && path_solid_pieces(v5, a1, dy) )
{
v14 = v6 + v11->h;
v11->Parent = v5;
v11->g = v6;
v11->f = v14;
path_set_coords(v11);
}
}
else
{
result = path_new_step();
v16 = result;
if ( !result )
return 0;
result->Parent = v5;
result->g = v6;
v17 = path_get_h_cost(a1, dy, sx, sy);
v16->h = v17;
v16->f = v6 + v17;
v16->x = a1;
v16->y = dy;
path_next_node(v16);
v18 = 0;
v19 = v5->Child;
do
{
if ( !*v19 )
break;
++v18;
++v19;
}
while ( v18 < 8 );
v5->Child[v18] = v16;
}
}
return 1;
}
//----- (0044979A) --------------------------------------------------------
PATHNODE *__fastcall path_get_node1(int dx, int dy)
{
PATHNODE *result; // eax
result = *(PATHNODE **)&path_2_nodes[0].f;
do
result = result->NextNode;
while ( result && (result->x != dx || result->y != dy) );
return result;
}
//----- (004497B3) --------------------------------------------------------
PATHNODE *__fastcall path_get_node2(int dx, int dy)
{
PATHNODE *result; // eax
result = pnode_ptr;
do
result = result->NextNode;
while ( result && (result->x != dx || result->y != dy) );
return result;
}
//----- (004497CC) --------------------------------------------------------
void __fastcall path_next_node(PATHNODE *pPath)
{
PATHNODE *v1; // edx
PATHNODE *v2; // eax
v1 = *(PATHNODE **)&path_2_nodes[0].f;
v2 = *(PATHNODE **)(*(_DWORD *)&path_2_nodes[0].f + 48);
if ( v2 )
{
do
{
if ( v2->f >= pPath->f )
break;
v1 = v2;
v2 = v2->NextNode;
}
while ( v2 );
pPath->NextNode = v2;
}
v1->NextNode = pPath;
}
//----- (004497F7) --------------------------------------------------------
void __fastcall path_set_coords(PATHNODE *pPath)
{
PATHNODE *PathOld; // edi
PATHNODE *PathAct; // esi
char v6; // al
int i; // [esp+0h] [ebp-8h]
PATHNODE **v9; // [esp+4h] [ebp-4h]
path_push_active_step(pPath);
while ( gdwCurPathStep )
{
PathOld = path_pop_active_step();
v9 = PathOld->Child;
for(i = 0; i < 8; i++)
{
PathAct = *v9;
if ( !*v9 )
break;
if ( PathOld->g + path_check_equal(PathOld, PathAct->x, PathAct->y) < PathAct->g )
{
if ( path_solid_pieces(PathOld, PathAct->x, PathAct->y) )
{
PathAct->Parent = PathOld;
v6 = PathOld->g + path_check_equal(PathOld, PathAct->x, PathAct->y);
PathAct->g = v6;
PathAct->f = v6 + PathAct->h;
path_push_active_step(PathAct);
}
}
++v9;
}
}
}
//----- (00449890) --------------------------------------------------------
void __fastcall path_push_active_step(PATHNODE *pPath)
{
int v1; // eax
v1 = gdwCurPathStep++;
pnode_tblptr[v1] = pPath;
}
//----- (004498A3) --------------------------------------------------------
PATHNODE *__cdecl path_pop_active_step()
{
return pnode_tblptr[--gdwCurPathStep];
}
//----- (004498B6) --------------------------------------------------------
PATHNODE *__cdecl path_new_step()
{
PATHNODE *v1; // esi
if ( pnode_vals[0] == 300 )
return 0;
v1 = &path_nodes[pnode_vals[0]++];
memset(v1, 0, 0x34u);
return v1;
}

41
Source/path.h Normal file
View File

@ -0,0 +1,41 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//path
extern PATHNODE path_nodes[300];
extern int gdwCurPathStep;
extern int pnode_vals[26];
extern PATHNODE *pnode_ptr;
extern PATHNODE *pnode_tblptr[300];
extern PATHNODE path_2_nodes[300];
int __fastcall FindPath(bool (__fastcall *PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path);
int __fastcall path_get_h_cost(int sx, int sy, int dx, int dy);
int __fastcall path_check_equal(PATHNODE *pPath, int dx, int dy);
PATHNODE *__cdecl GetNextPath();
bool __fastcall path_solid_pieces(PATHNODE *pPath, int dx, int dy);
int __fastcall path_get_path(bool (__fastcall *PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y);
int __fastcall path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy);
PATHNODE *__fastcall path_get_node1(int dx, int dy);
PATHNODE *__fastcall path_get_node2(int dx, int dy);
void __fastcall path_next_node(PATHNODE *pPath);
void __fastcall path_set_coords(PATHNODE *pPath);
void __fastcall path_push_active_step(PATHNODE *pPath);
PATHNODE *__cdecl path_pop_active_step();
PATHNODE *__cdecl path_new_step();
/* data */
extern char pathxdir[8];
extern char pathydir[8];
/* rdata */
extern char path_directions[9];

970
Source/pfile.cpp Normal file
View File

@ -0,0 +1,970 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int pfile_cpp_init_value;
char hero_names[320];
bool gbValidSaveFile; // idb
int save_prev_tc; // weak
int pfile_inf = 0x7F800000; // weak
//----- (004498F1) --------------------------------------------------------
struct pfile_cpp_init
{
pfile_cpp_init()
{
pfile_cpp_init_value = pfile_inf;
}
} _pfile_cpp_init;
// 47F1C0: using guessed type int pfile_inf;
//----- (004498FC) --------------------------------------------------------
void __cdecl pfile_init_save_directory()
{
char Buffer[260]; // [esp+4h] [ebp-104h]
if ( GetWindowsDirectoryA(Buffer, 0x104u)
&& (pfile_check_available_space(Buffer), GetModuleFileNameA(ghInst, Buffer, 0x104u)) )
{
pfile_check_available_space(Buffer);
}
else
{
TermMsg("Unable to initialize save directory");
}
}
//----- (0044995B) --------------------------------------------------------
void __fastcall pfile_check_available_space(char *pszDir)
{
char *v1; // edi
char *v2; // eax
char v3; // cl
BOOL v4; // esi
DWORD TotalNumberOfClusters; // [esp+8h] [ebp-10h]
DWORD NumberOfFreeClusters; // [esp+Ch] [ebp-Ch]
DWORD BytesPerSector; // [esp+10h] [ebp-8h]
DWORD SectorsPerCluster; // [esp+14h] [ebp-4h]
v1 = pszDir;
v2 = pszDir;
while ( 1 )
{
v3 = *v2;
if ( !*v2 )
break;
++v2;
if ( v3 == '\\' )
{
*v2 = '\0';
break;
}
}
v4 = GetDiskFreeSpaceA(v1, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters);
if ( !v4 )
goto LABEL_12;
if ( (signed __int64)(BytesPerSector * (unsigned __int64)SectorsPerCluster * NumberOfFreeClusters) < 0xA00000 )
v4 = 0;
if ( !v4 )
LABEL_12:
DiskFreeDlg(v1);
}
//----- (004499C3) --------------------------------------------------------
void __cdecl pfile_write_hero()
{
int v0; // eax
int v1; // esi
//int v2; // eax
PkPlayerStruct pkplr; // [esp+4h] [ebp-4F4h]
v0 = pfile_get_save_num_from_name(plr[myplr]._pName);
v1 = v0;
//_LOBYTE(v2) = pfile_open_archive(1, v0);
if ( pfile_open_archive(1, v0) )
{
PackPlayer(&pkplr, myplr, gbMaxPlayers == 1);
pfile_encode_hero(&pkplr);
pfile_flush(gbMaxPlayers == 1, v1);
}
}
// 679660: using guessed type char gbMaxPlayers;
//----- (00449A33) --------------------------------------------------------
int __fastcall pfile_get_save_num_from_name(char *name)
{
char *v1; // ebx
unsigned int v2; // esi
char *v3; // edi
v1 = name;
v2 = 0;
v3 = hero_names;
do
{
if ( !_strcmpi(v3, v1) )
break;
++v2;
v3 += 32;
}
while ( v2 < 0xA );
return v2;
}
//----- (00449A5B) --------------------------------------------------------
void __fastcall pfile_encode_hero(PkPlayerStruct *pPack)
{
int v1; // ebx
void *v2; // edi
char password[16]; // [esp+Ch] [ebp-14h]
void *v4; // [esp+1Ch] [ebp-4h]
strcpy(password, "xrgyrkj1");
*(_DWORD *)&password[9] = 0;
*(_WORD *)&password[13] = 0;
v4 = pPack;
password[15] = 0;
if ( (unsigned char)gbMaxPlayers > 1u )
strcpy(password, "szqnlsk1");
v1 = codec_get_encoded_len(1266);
v2 = DiabloAllocPtr(v1);
memcpy(v2, v4, 0x4F2u);
codec_encode(v2, 1266, v1, password);
mpqapi_write_file("hero", (char *)v2, v1);
mem_free_dbg(v2);
}
// 679660: using guessed type char gbMaxPlayers;
//----- (00449ADF) --------------------------------------------------------
bool __fastcall pfile_open_archive(bool a1, int save_num)
{
int v2; // esi
BOOL v3; // edi
//int v4; // eax
char FileName[260]; // [esp+8h] [ebp-104h]
v2 = save_num;
v3 = a1;
pfile_get_save_path(FileName, 260, save_num);
//_LOBYTE(v4) = mpqapi_open_archive(FileName, 0, v2);
if ( mpqapi_open_archive(FileName, 0, v2) )
return 1;
if ( v3 )
{
if ( (unsigned char)gbMaxPlayers > 1u )
MI_Dummy(v2);
}
return 0;
}
// 679660: using guessed type char gbMaxPlayers;
//----- (00449B30) --------------------------------------------------------
void __fastcall pfile_get_save_path(char *pszBuf, int dwBufSize, int save_num)
{
char *v3; // esi
const char *v4; // ebx
DWORD v5; // edi
char *v6; // eax
char v7[260]; // [esp+8h] [ebp-104h]
v3 = pszBuf;
v4 = "\\multi_%d.sv";
if ( (unsigned char)gbMaxPlayers <= 1u )
v4 = "\\single_%d.sv";
v5 = GetModuleFileNameA(ghInst, pszBuf, 0x104u);
v6 = strrchr(v3, '\\');
if ( v6 )
*v6 = 0;
if ( !v5 )
TermMsg("Unable to get save directory");
sprintf(v7, v4, save_num);
strcat(v3, v7);
strlwr(v3);
}
// 679660: using guessed type char gbMaxPlayers;
//----- (00449BB2) --------------------------------------------------------
void __fastcall pfile_flush(bool is_single_player, int save_num)
{
int v2; // esi
bool v3; // di
char FileName[260]; // [esp+8h] [ebp-104h]
v2 = save_num;
v3 = is_single_player;
pfile_get_save_path(FileName, 260, save_num);
mpqapi_flush_and_close(FileName, v3, v2);
}
//----- (00449BE4) --------------------------------------------------------
bool __fastcall pfile_create_player_description(char *dst, int len)
{
int v2; // edi
char *v3; // ebx
int v4; // eax
char src[128]; // [esp+Ch] [ebp-ACh]
_uiheroinfo hero_info; // [esp+8Ch] [ebp-2Ch]
myplr = 0;
v2 = len;
v3 = dst;
pfile_read_player_from_save();
game_2_ui_player(plr, &hero_info, gbValidSaveFile);
UiSetupPlayerInfo(chr_name_str, &hero_info, 'DRTL');
if ( !v3 || !v2 )
goto LABEL_5;
v4 = UiCreatePlayerDescription(&hero_info, 'DRTL', src);
if ( v4 )
{
SStrCopy(v3, src, v2);
LABEL_5:
v4 = 1;
}
return v4;
}
//----- (00449C5A) --------------------------------------------------------
int __fastcall pfile_create_save_file(char *name_1, char *name_2)
{
char *v2; // edi
char *v3; // ebp
int v4; // esi
int v5; // eax
char *v7; // [esp+20h] [ebp-30h]
_uiheroinfo heroinfo; // [esp+24h] [ebp-2Ch]
v2 = name_2;
v3 = name_1;
if ( pfile_get_save_num_from_name(name_2) != 10 )
return 0;
v4 = 0;
v7 = plr[0]._pName;
while ( _strcmpi(v3, v7) )
{
v7 += 21720;
++v4;
if ( v7 == plr[4]._pName )
return 0;
}
v5 = pfile_get_save_num_from_name(v3);
if ( v5 == 10 )
return 0;
SStrCopy(&hero_names[32 * v5], v2, 32);
SStrCopy(plr[v4]._pName, v2, 32);
if ( !_strcmpi(chr_name_str, v3) )
SStrCopy(chr_name_str, v2, 16);
game_2_ui_player(plr, &heroinfo, gbValidSaveFile);
UiSetupPlayerInfo(chr_name_str, &heroinfo, 'DRTL');
pfile_write_hero();
return 1;
}
//----- (00449D22) --------------------------------------------------------
void __cdecl pfile_flush_W()
{
int v0; // eax
v0 = pfile_get_save_num_from_name(plr[myplr]._pName);
pfile_flush(1, v0);
}
//----- (00449D43) --------------------------------------------------------
void __fastcall game_2_ui_player(PlayerStruct *p, _uiheroinfo *heroinfo, bool bHasSaveFile)
{
_uiheroinfo *v3; // esi
PlayerStruct *v4; // edi
char v5; // al
v3 = heroinfo;
v4 = p;
memset(heroinfo, 0, 0x2Cu);
strncpy(v3->name, v4->_pName, 0xFu);
v3->name[15] = 0;
v3->level = v4->_pLevel;
v3->heroclass = game_2_ui_class(v4);
v3->strength = v4->_pStrength;
v3->magic = v4->_pMagic;
v3->dexterity = v4->_pDexterity;
v3->vitality = v4->_pVitality;
v3->gold = v4->_pGold;
v3->hassaved = bHasSaveFile;
v5 = v4->pDiabloKillLevel;
v3->spawned = 0;
v3->herorank = v5;
}
//----- (00449DD0) --------------------------------------------------------
char __fastcall game_2_ui_class(PlayerStruct *p)
{
char result; // al
result = p->_pClass;
if ( result )
result = (result != 1) + 1;
return result;
}
//----- (00449DE3) --------------------------------------------------------
bool __stdcall pfile_ui_set_hero_infos(void (__stdcall *ui_add_hero_info)(_uiheroinfo *))
{
char *v1; // esi
//int v2; // eax
int v3; // eax
DWORD v4; // eax
unsigned int v5; // esi
char *v6; // ebx
void *v7; // eax
void *v8; // edi
//int v9; // eax
bool v10; // al
PkPlayerStruct pkplr; // [esp+Ch] [ebp-7BCh]
struct _OFSTRUCT ReOpenBuff; // [esp+500h] [ebp-2C8h]
char FileName[260]; // [esp+588h] [ebp-240h]
char NewFileName[260]; // [esp+68Ch] [ebp-13Ch]
_uiheroinfo hero_info; // [esp+790h] [ebp-38h]
int unused; // [esp+7BCh] [ebp-Ch]
LPCSTR lpSrcStr; // [esp+7C0h] [ebp-8h]
int save_num; // [esp+7C4h] [ebp-4h]
memset(hero_names, 0, 0x140u);
if ( (unsigned char)gbMaxPlayers > 1u )
{
lpSrcStr = 0;
save_num = 0;
do
{
if ( (unsigned int)save_num >= 0xA )
break;
GetSaveDirectory(FileName, 260, (int)lpSrcStr);
v1 = strrchr(FileName, '\\') + 1;
if ( v1 != (char *)1 && OpenFile(FileName, &ReOpenBuff, 0x4000u) != -1 )
{
if ( !SRegLoadString("Diablo\\Converted", (const char *)v1, 0, NewFileName, 260) )
{
while ( 1 )
{
v3 = save_num++;
pfile_get_save_path(NewFileName, 260, v3);
if ( OpenFile(NewFileName, &ReOpenBuff, 0x4000u) == -1 )
break;
if ( (unsigned int)save_num >= 0xA )
goto LABEL_13;
}
if ( CopyFileA(FileName, NewFileName, 1) )
{
SRegSaveString("Diablo\\Converted", v1, 0, NewFileName);
v4 = GetFileAttributesA(NewFileName);
if ( v4 != -1 )
{
_LOBYTE(v4) = v4 & 0xF9;
SetFileAttributesA(NewFileName, v4);
}
}
}
}
LABEL_13:
++lpSrcStr;
}
while ( (unsigned int)lpSrcStr < 0xA );
}
unused = 1;
v5 = 0;
v6 = hero_names;
do
{
v7 = pfile_open_save_archive(&unused, v5);
v8 = v7;
if ( v7 )
{
if ( pfile_read_hero(v7, &pkplr) )
{
strcpy(v6, pkplr.pName);
UnPackPlayer(&pkplr, 0, 0);
v10 = pfile_archive_contains_game(v8);
game_2_ui_player(plr, &hero_info, v10);
ui_add_hero_info(&hero_info);
}
pfile_SFileCloseArchive(v8);
}
++v5;
v6 += 32;
}
while ( v5 < 0xA );
return 1;
}
// 679660: using guessed type char gbMaxPlayers;
//----- (00449FAA) --------------------------------------------------------
char *__fastcall GetSaveDirectory(char *dst, int dst_size, int save_num)
{
char *v3; // esi
const char *v4; // ebx
DWORD v5; // edi
char *v6; // eax
char path_buf[260]; // [esp+Ch] [ebp-104h]
v3 = dst;
if ( (unsigned char)gbMaxPlayers <= 1u )
{
v4 = "\\single_%d.sv";
v5 = GetModuleFileNameA(ghInst, dst, 0x104u);
v6 = strrchr(v3, '\\');
if ( v6 )
*v6 = '\0';
}
else
{
v4 = "\\dlinfo_%d.drv";
v5 = GetWindowsDirectoryA(dst, 0x104u);
}
if ( !v5 )
TermMsg("Unable to get save directory");
sprintf(path_buf, v4, save_num);
strcat(v3, path_buf);
return strlwr(v3);
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0044A036) --------------------------------------------------------
bool __fastcall pfile_read_hero(void *archive, PkPlayerStruct *pPack)
{
BOOL v2; // eax
int dwSize; // eax
int v4; // edi
char *v5; // eax
char *v6; // esi
//int v7; // eax
//int v8; // eax
char password[16]; // [esp+4h] [ebp-24h]
void *v11; // [esp+14h] [ebp-14h]
DWORD nSize; // [esp+18h] [ebp-10h]
int v13; // [esp+1Ch] [ebp-Ch]
int dwBytes; // [esp+20h] [ebp-8h]
void *file; // [esp+24h] [ebp-4h]
v11 = pPack;
v2 = SFileOpenFileEx(archive, "hero", 0, &file);
if ( v2 )
{
strcpy(password, "xrgyrkj1");
v13 = 0;
*(_DWORD *)&password[9] = 0;
*(_WORD *)&password[13] = 0;
password[15] = 0;
nSize = 16;
if ( (unsigned char)gbMaxPlayers > 1u )
strcpy(password, "szqnlsk1");
dwSize = SFileGetFileSize((int *)file, 0);
v4 = dwSize;
if ( !dwSize )
goto LABEL_15;
v5 = (char *)DiabloAllocPtr(dwSize);
v6 = v5;
//_LOBYTE(v7) = SFileReadFile(file, v5, v4, (unsigned long *)&dwBytes, 0);
if ( SFileReadFile(file, v5, v4, (unsigned long *)&dwBytes, 0) )
{
dwBytes = codec_decode(v6, v4, password);
if ( dwBytes )
goto LABEL_11;
if ( (unsigned char)gbMaxPlayers > 1u )
{
GetComputerNameA(password, &nSize);
if ( !SFileSetFilePointer(file, 0, 0, 0) )
{
//_LOBYTE(v8) = SFileReadFile(file, v6, v4, (unsigned long *)&dwBytes, 0);
if ( SFileReadFile(file, v6, v4, (unsigned long *)&dwBytes, 0) )
{
dwBytes = codec_decode(v6, v4, password);
LABEL_11:
if ( dwBytes == 1266 )
{
memcpy(v11, v6, 0x4F2u);
v13 = 1;
}
goto LABEL_13;
}
}
}
}
LABEL_13:
if ( v6 )
mem_free_dbg(v6);
LABEL_15:
SFileCloseFile(file);
v2 = v13;
}
return v2;
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0044A158) --------------------------------------------------------
void *__fastcall pfile_open_save_archive(int *unused, int save_num)
{
//int v2; // eax
char SrcStr[260]; // [esp+0h] [ebp-108h]
void *archive; // [esp+104h] [ebp-4h]
pfile_get_save_path(SrcStr, 260, save_num);
//_LOBYTE(v2) = SFileOpenArchive(SrcStr, 0x7000, 0, &archive);
return SFileOpenArchive(SrcStr, 0x7000, 0, &archive) != 0 ? archive : NULL;
}
//----- (0044A192) --------------------------------------------------------
void __fastcall pfile_SFileCloseArchive(void *hsArchive)
{
SFileCloseArchive(hsArchive);
}
//----- (0044A199) --------------------------------------------------------
bool __fastcall pfile_archive_contains_game(void *hsArchive)
{
//int v1; // eax
void *file; // [esp+0h] [ebp-4h]
file = hsArchive;
if ( gbMaxPlayers != 1 )
return 0;
//_LOBYTE(v1) = SFileOpenFileEx(hsArchive, "game", 0, &file);
if ( !SFileOpenFileEx(hsArchive, "game", 0, &file) )
return 0;
SFileCloseFile(file);
return 1;
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0044A1CC) --------------------------------------------------------
bool __stdcall pfile_ui_set_class_stats(int player_class_nr, _uidefaultstats *class_stats)
{
int v2; // eax
v2 = (char)pfile_get_player_class(player_class_nr);
class_stats->strength = StrengthTbl[v2];
class_stats->magic = MagicTbl[v2];
class_stats->dexterity = DexterityTbl[v2];
class_stats->vitality = VitalityTbl[v2];
return 1;
}
//----- (0044A210) --------------------------------------------------------
int __fastcall pfile_get_player_class(int player_class_nr)
{
int result; // eax
if ( player_class_nr )
_LOBYTE(result) = (player_class_nr != 1) + 1;
else
_LOBYTE(result) = 0;
return result;
}
//----- (0044A220) --------------------------------------------------------
bool __stdcall pfile_ui_save_create(_uiheroinfo *heroinfo)
{
unsigned int v1; // edi
char *v2; // eax
//int v3; // eax
char v5; // al
PkPlayerStruct pkplr; // [esp+8h] [ebp-4F4h]
v1 = pfile_get_save_num_from_name(heroinfo->name);
if ( v1 == 10 )
{
v1 = 0;
v2 = hero_names;
do
{
if ( !*v2 )
break;
++v1;
v2 += 32;
}
while ( v1 < 0xA );
if ( v1 == 10 )
return 0;
}
//_LOBYTE(v3) = pfile_open_archive(0, v1);
if ( !pfile_open_archive(0, v1) )
return 0;
mpqapi_remove_hash_entries(pfile_get_file_name);
strncpy(&hero_names[32 * v1], heroinfo->name, 0x20u);
hero_names[32 * v1 + 31] = 0;
v5 = pfile_get_player_class((unsigned char)heroinfo->heroclass);
CreatePlayer(0, v5);
strncpy(plr[0]._pName, heroinfo->name, 0x20u);
plr[0]._pName[31] = 0;
PackPlayer(&pkplr, 0, 1);
pfile_encode_hero(&pkplr);
game_2_ui_player(plr, heroinfo, 0);
pfile_flush(1, v1);
return 1;
}
//----- (0044A2FF) --------------------------------------------------------
bool __stdcall pfile_get_file_name(int lvl, char *dst)
{
int v2; // ecx
bool v3; // zf
const char *v4; // eax
v2 = lvl;
if ( (unsigned char)gbMaxPlayers > 1u )
{
v3 = lvl == 0;
goto LABEL_10;
}
if ( (unsigned int)lvl < 0x11 )
{
v4 = "perml%02d";
LABEL_12:
sprintf(dst, v4, v2);
return 1;
}
if ( (unsigned int)lvl < 0x22 )
{
v2 = lvl - 17;
v4 = "perms%02d";
goto LABEL_12;
}
if ( lvl == 34 )
{
v4 = "game";
goto LABEL_12;
}
v3 = lvl == 35;
LABEL_10:
if ( v3 )
{
v4 = "hero";
goto LABEL_12;
}
return 0;
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0044A356) --------------------------------------------------------
bool __stdcall pfile_delete_save(_uiheroinfo *hero_info)
{
unsigned int v1; // eax
char FileName[260]; // [esp+0h] [ebp-104h]
v1 = pfile_get_save_num_from_name(hero_info->name);
if ( v1 < 0xA )
{
hero_names[32 * v1] = 0;
pfile_get_save_path(FileName, 260, v1);
DeleteFileA(FileName);
}
return 1;
}
//----- (0044A3A0) --------------------------------------------------------
void __cdecl pfile_read_player_from_save()
{
int dwChar; // edi
void *v1; // esi
//int v2; // eax
PkPlayerStruct pkplr; // [esp+8h] [ebp-4F4h]
dwChar = pfile_get_save_num_from_name(chr_name_str);
v1 = pfile_open_save_archive(0, dwChar);
if ( !v1 )
TermMsg("Unable to open archive");
//_LOBYTE(v2) = pfile_read_hero(v1, &pkplr);
if ( !pfile_read_hero(v1, &pkplr) )
TermMsg("Unable to load character");
UnPackPlayer(&pkplr, myplr, 0);
*(_DWORD *)&gbValidSaveFile = pfile_archive_contains_game(v1);
pfile_SFileCloseArchive(v1);
}
//----- (0044A419) --------------------------------------------------------
void __fastcall GetTempLevelNames(char *szTemp)
{
char *v1; // esi
v1 = szTemp;
pfile_get_save_num_from_name(plr[myplr]._pName);
if ( setlevel )
sprintf(v1, "temps%02d", (unsigned char)setlvlnum);
else
sprintf(v1, "templ%02d", currlevel);
}
// 5CCB10: using guessed type char setlvlnum;
// 5CF31D: using guessed type char setlevel;
//----- (0044A463) --------------------------------------------------------
void __fastcall GetPermLevelNames(char *szPerm)
{
char *v1; // esi
int v2; // ebx
//int v3; // eax
//int v4; // eax
int v5; // edi
v1 = szPerm;
v2 = pfile_get_save_num_from_name(plr[myplr]._pName);
GetTempLevelNames(v1);
//_LOBYTE(v3) = pfile_open_archive(0, v2);
if ( !pfile_open_archive(0, v2) )
TermMsg("Unable to read to save file archive");
//_LOBYTE(v4) = mpqapi_has_file(v1);
v5 = mpqapi_has_file(v1);
pfile_flush(1, v2);
if ( !v5 )
{
if ( setlevel )
sprintf(v1, "perms%02d", (unsigned char)setlvlnum);
else
sprintf(v1, "perml%02d", currlevel);
}
}
// 5CCB10: using guessed type char setlvlnum;
// 5CF31D: using guessed type char setlevel;
//----- (0044A4E9) --------------------------------------------------------
void __fastcall pfile_get_game_name(char *dst)
{
char *v1; // esi
v1 = dst;
pfile_get_save_num_from_name(plr[myplr]._pName);
strcpy(v1, "game");
}
//----- (0044A512) --------------------------------------------------------
void __cdecl pfile_remove_temp_files()
{
int v0; // eax
int v1; // esi
//int v2; // eax
if ( (unsigned char)gbMaxPlayers <= 1u )
{
v0 = pfile_get_save_num_from_name(plr[myplr]._pName);
v1 = v0;
//_LOBYTE(v2) = pfile_open_archive(0, v0);
if ( !pfile_open_archive(0, v0) )
TermMsg("Unable to write to save file archive");
mpqapi_remove_hash_entries(GetTempSaveNames);
pfile_flush(1, v1);
}
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0044A563) --------------------------------------------------------
bool __stdcall GetTempSaveNames(int dwIndex, char *szTemp)
{
int v2; // eax
const char *v3; // ecx
v2 = dwIndex;
if ( (unsigned int)dwIndex < 0x11 )
{
v3 = "templ%02d";
LABEL_5:
sprintf(szTemp, v3, v2);
return 1;
}
if ( (unsigned int)dwIndex < 0x22 )
{
v2 = dwIndex - 17;
v3 = "temps%02d";
goto LABEL_5;
}
return 0;
}
//----- (0044A598) --------------------------------------------------------
void __cdecl pfile_rename_temp_to_perm()
{
int v0; // eax
int v1; // edi
//int v2; // eax
int v3; // esi
//int v4; // eax
//int v5; // eax
//int v6; // eax
char v7[260]; // [esp+8h] [ebp-208h]
char v8[260]; // [esp+10Ch] [ebp-104h]
v0 = pfile_get_save_num_from_name(plr[myplr]._pName);
v1 = v0;
//_LOBYTE(v2) = pfile_open_archive(0, v0);
if ( !pfile_open_archive(0, v0) )
TermMsg("Unable to write to save file archive");
v3 = 0;
while ( 1 )
{
//_LOBYTE(v6) = GetTempSaveNames(v3, v7);
if ( !GetTempSaveNames(v3, v7) )
break;
GetPermSaveNames(v3++, v8);
//_LOBYTE(v4) = mpqapi_has_file(v7);
if ( mpqapi_has_file(v7) )
{
//_LOBYTE(v5) = mpqapi_has_file(v8);
if ( mpqapi_has_file(v8) )
mpqapi_remove_hash_entry(v8);
mpqapi_rename(v7, v8);
}
}
GetPermSaveNames(v3, v8);
pfile_flush(1, v1);
}
//----- (0044A644) --------------------------------------------------------
bool __stdcall GetPermSaveNames(int dwIndex, char *szPerm)
{
int v2; // eax
const char *v3; // ecx
v2 = dwIndex;
if ( (unsigned int)dwIndex < 0x11 )
{
v3 = "perml%02d";
LABEL_5:
sprintf(szPerm, v3, v2);
return 1;
}
if ( (unsigned int)dwIndex < 0x22 )
{
v2 = dwIndex - 17;
v3 = "perms%02d";
goto LABEL_5;
}
return 0;
}
//----- (0044A679) --------------------------------------------------------
void __fastcall pfile_write_save_file(char *pszName, void *pbData, int dwLen, int qwLen)
{
void *v4; // ebx
int v5; // eax
//int v6; // eax
char file_name[260]; // [esp+Ch] [ebp-118h]
char password[16]; // [esp+110h] [ebp-14h]
int v9; // [esp+120h] [ebp-4h]
v4 = pbData;
pfile_strcpy(file_name, pszName);
v5 = pfile_get_save_num_from_name(plr[myplr]._pName);
strcpy(password, "xrgyrkj1");
v9 = v5;
*(_DWORD *)&password[9] = 0;
*(_WORD *)&password[13] = 0;
password[15] = 0;
if ( (unsigned char)gbMaxPlayers > 1u )
strcpy(password, "szqnlsk1");
codec_encode(v4, dwLen, qwLen, password);
//_LOBYTE(v6) = pfile_open_archive(0, v9);
if ( !pfile_open_archive(0, v9) )
TermMsg("Unable to write to save file archive");
mpqapi_write_file(file_name, (char *)v4, qwLen);
pfile_flush(1, v9);
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0044A727) --------------------------------------------------------
void __fastcall pfile_strcpy(char *dst, char *src)
{
strcpy(dst, src);
}
//----- (0044A731) --------------------------------------------------------
char *__fastcall pfile_read(char *pszName, int *pdwLen)
{
int *v2; // ebx
int v3; // eax
void *v4; // edi
//int v5; // eax
int v6; // eax
void *v7; // eax
//int v8; // eax
char *v9; // esi
int v10; // eax
//int v11; // eax
char v13[260]; // [esp+Ch] [ebp-124h]
char password[16]; // [esp+110h] [ebp-20h]
void *src_dst; // [esp+120h] [ebp-10h]
int nread; // [esp+124h] [ebp-Ch]
DWORD nSize; // [esp+128h] [ebp-8h]
void *file; // [esp+12Ch] [ebp-4h]
v2 = pdwLen;
pfile_strcpy(v13, pszName);
v3 = pfile_get_save_num_from_name(plr[myplr]._pName);
v4 = pfile_open_save_archive(0, v3);
if ( !v4 )
TermMsg("Unable to open save file archive");
//_LOBYTE(v5) = SFileOpenFileEx(v4, v13, 0, &file);
if ( !SFileOpenFileEx(v4, v13, 0, &file) )
TermMsg("Unable to open save file");
v6 = SFileGetFileSize((int *)file, 0);
*v2 = v6;
if ( !v6 )
TermMsg("Invalid save file");
v7 = DiabloAllocPtr(*v2);
src_dst = v7;
//_LOBYTE(v8) = SFileReadFile(file, (char *)v7, *v2, (unsigned long *)&nread, 0);
if ( !SFileReadFile(file, (char *)v7, *v2, (unsigned long *)&nread, 0) )
TermMsg("Unable to read save file");
SFileCloseFile(file);
pfile_SFileCloseArchive(v4);
strcpy(password, "xrgyrkj1");
nSize = 16;
*(_DWORD *)&password[9] = 0;
*(_WORD *)&password[13] = 0;
password[15] = 0;
if ( (unsigned char)gbMaxPlayers > 1u )
strcpy(password, "szqnlsk1");
v9 = (char *)src_dst;
v10 = codec_decode(src_dst, *v2, password);
*v2 = v10;
if ( !v10 )
{
if ( (unsigned char)gbMaxPlayers > 1u )
{
GetComputerNameA(password, &nSize);
if ( SFileSetFilePointer(file, 0, 0, 0) )
TermMsg("Unable to read save file");
//_LOBYTE(v11) = SFileReadFile(file, v9, *v2, (unsigned long *)&nread, 0);
if ( !SFileReadFile(file, v9, *v2, (unsigned long *)&nread, 0) )
TermMsg("Unable to read save file");
*v2 = codec_decode(v9, *v2, password);
}
if ( !*v2 )
TermMsg("Invalid save file");
}
return v9;
}
// 679660: using guessed type char gbMaxPlayers;
//----- (0044A8B3) --------------------------------------------------------
void __fastcall pfile_update(bool force_save)
{
BOOL v1; // esi
DWORD v2; // eax
v1 = force_save;
if ( gbMaxPlayers != 1 )
{
v2 = GetTickCount();
if ( v1 || (signed int)(v2 - save_prev_tc) > 60000 )
{
save_prev_tc = v2;
pfile_write_hero();
}
}
}
// 679660: using guessed type char gbMaxPlayers;
// 686428: using guessed type int save_prev_tc;

58
Source/pfile.h Normal file
View File

@ -0,0 +1,58 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//pfile
extern int pfile_cpp_init_value;
extern char hero_names[320];
extern bool gbValidSaveFile; // idb
extern int save_prev_tc; // weak
void __cdecl pfile_cpp_init();
void __cdecl pfile_init_save_directory();
void __fastcall pfile_check_available_space(char *pszDir);
void __cdecl pfile_write_hero();
int __fastcall pfile_get_save_num_from_name(char *name);
void __fastcall pfile_encode_hero(PkPlayerStruct *pPack);
bool __fastcall pfile_open_archive(bool a1, int save_num);
void __fastcall pfile_get_save_path(char *pszBuf, int dwBufSize, int save_num);
void __fastcall pfile_flush(bool is_single_player, int save_num);
bool __fastcall pfile_create_player_description(char *dst, int len);
int __fastcall pfile_create_save_file(char *name_1, char *name_2);
void __cdecl pfile_flush_W();
void __fastcall game_2_ui_player(PlayerStruct *p, _uiheroinfo *heroinfo, bool bHasSaveFile);
char __fastcall game_2_ui_class(PlayerStruct *p);
bool __stdcall pfile_ui_set_hero_infos(void (__stdcall *ui_add_hero_info)(_uiheroinfo *));
char *__fastcall GetSaveDirectory(char *dst, int dst_size, int save_num);
bool __fastcall pfile_read_hero(void *archive, PkPlayerStruct *pPack);
void *__fastcall pfile_open_save_archive(int *unused, int save_num);
void __fastcall pfile_SFileCloseArchive(void *hsArchive);
bool __fastcall pfile_archive_contains_game(void *hsArchive);
bool __stdcall pfile_ui_set_class_stats(int player_class_nr, _uidefaultstats *class_stats);
int __fastcall pfile_get_player_class(int player_class_nr);
bool __stdcall pfile_ui_save_create(_uiheroinfo *heroinfo);
bool __stdcall pfile_get_file_name(int lvl, char *dst);
bool __stdcall pfile_delete_save(_uiheroinfo *hero_info);
void __cdecl pfile_read_player_from_save();
void __fastcall GetTempLevelNames(char *szTemp);
void __fastcall GetPermLevelNames(char *szPerm);
void __fastcall pfile_get_game_name(char *dst);
void __cdecl pfile_remove_temp_files();
bool __stdcall GetTempSaveNames(int dwIndex, char *szTemp);
void __cdecl pfile_rename_temp_to_perm();
bool __stdcall GetPermSaveNames(int dwIndex, char *szPerm);
void __fastcall pfile_write_save_file(char *pszName, void *pbData, int dwLen, int qwLen);
void __fastcall pfile_strcpy(char *dst, char *src);
char *__fastcall pfile_read(char *pszName, int *pdwLen);
void __fastcall pfile_update(bool force_save);
/* data */
extern int pfile_inf; // weak

5857
Source/player.cpp Normal file

File diff suppressed because it is too large Load Diff

145
Source/player.h Normal file
View File

@ -0,0 +1,145 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//player
extern int plr_lframe_size; // idb
extern int plr_wframe_size; // idb
extern char plr_gfx_flag; // weak
extern int player_cpp_init_value; // weak
extern int plr_aframe_size; // idb
extern int myplr;
extern PlayerStruct plr[4];
extern int plr_fframe_size; // idb
extern int plr_qframe_size; // idb
extern int deathflag; // idb
extern int plr_hframe_size; // idb
extern int plr_bframe_size; // idb
extern char plr_gfx_bflag; // weak
extern int plr_sframe_size; // idb
extern int deathdelay; // weak
extern int plr_dframe_size; // idb
void __cdecl player_cpp_init();
void __fastcall player_init_cl2_hdrs(char *src, char *dst);
void __fastcall LoadPlrGFX(int pnum, int gfxflag);
void __fastcall InitPlayerGFX(int pnum);
void __fastcall InitPlrGFXMem(int pnum);
int __fastcall GetPlrGFXSize(char *szCel);
void __fastcall FreePlayerGFX(int pnum);
void __fastcall NewPlrAnim(int pnum, int Peq, int numFrames, int Delay, int width);
void __fastcall ClearPlrPVars(int pnum);
void __fastcall SetPlrAnims(int pnum);
void __fastcall ClearPlrRVars(PlayerStruct *pPlayer);
void __fastcall CreatePlayer(int pnum, char c);
int __fastcall CalcStatDiff(int pnum);
void __fastcall NextPlrLevel(int pnum);
void __fastcall AddPlrExperience(int pnum, int lvl, int exp);
void __fastcall AddPlrMonstExper(int lvl, int exp, char pmask);
void __fastcall InitPlayer(int pnum, bool FirstTime);
void __cdecl InitMultiView();
void __fastcall InitPlayerLoc(int pnum, bool flag);
bool __fastcall SolidLoc(int x, int y);
bool __fastcall PlrDirOK(int pnum, int dir);
void __fastcall PlrClrTrans(int x, int y);
void __fastcall PlrDoTrans(int x, int y);
void __fastcall SetPlayerOld(int pnum);
void __fastcall FixPlayerLocation(int pnum, int dir);
void __fastcall StartStand(int pnum, int dir);
void __fastcall StartWalkStand(int pnum);
void __fastcall PM_ChangeLightOff(int pnum);
void __fastcall PM_ChangeOffset(int pnum);
void __fastcall StartWalk(int pnum, int xvel, int yvel, int xadd, int yadd, int EndDir, int sdir);
void __fastcall StartWalk2(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int EndDir, int sdir);
void __fastcall StartWalk3(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, int EndDir, int sdir);
void __fastcall StartAttack(int pnum, int d);
void __fastcall StartRangeAttack(int pnum, int d, int cx, int cy);
void __fastcall StartPlrBlock(int pnum, int dir);
void __fastcall StartSpell(int pnum, int d, int cx, int cy);
void __fastcall FixPlrWalkTags(int pnum);
void __fastcall RemovePlrFromMap(int pnum);
void __fastcall StartPlrHit(int pnum, int dam, unsigned char forcehit);
void __fastcall RespawnDeadItem(ItemStruct *itm, int x, int y);
void __fastcall StartPlayerKill(int pnum, int earflag);
void __fastcall PlrDeadItem(int pnum, struct ItemStruct *itm, int xx, int yy);
void __fastcall DropHalfPlayersGold(int pnum);
void __fastcall SyncPlrKill(int pnum, int earflag);
void __fastcall j_StartPlayerKill(int pnum, int earflag);
void __fastcall RemovePlrMissiles(int pnum);
void __fastcall InitLevelChange(int pnum);
void __fastcall StartNewLvl(int pnum, int fom, int lvl);
void __fastcall RestartTownLvl(int pnum);
void __fastcall StartWarpLvl(int pnum, int pidx);
int __fastcall PM_DoStand(int pnum);
int __fastcall PM_DoWalk(int pnum);
int __fastcall PM_DoWalk2(int pnum);
int __fastcall PM_DoWalk3(int pnum);
bool __fastcall WeaponDur(int pnum, int durrnd);
bool __fastcall PlrHitMonst(int pnum, int m);
bool __fastcall PlrHitPlr(int pnum, char p);
bool __fastcall PlrHitObj(int pnum, int mx, int my);
int __fastcall PM_DoAttack(int pnum);
int __fastcall PM_DoRangeAttack(int pnum);
void __fastcall ShieldDur(int pnum);
int __fastcall PM_DoBlock(int pnum);
int __fastcall PM_DoSpell(int pnum);
int __fastcall PM_DoGotHit(int pnum);
void __fastcall ArmorDur(int pnum);
int __fastcall PM_DoDeath(int pnum);
void __fastcall CheckNewPath(int pnum);
bool __fastcall PlrDeathModeOK(int pnum);
void __cdecl ValidatePlayer();
void __cdecl ProcessPlayers();
void __fastcall CheckCheatStats(int pnum);
void __fastcall ClrPlrPath(int pnum);
bool __fastcall PosOkPlayer(int pnum, int px, int py);
void __fastcall MakePlrPath(int pnum, int xx, int yy, unsigned char endspace);
void __fastcall CheckPlrSpell();
void __fastcall SyncPlrAnim(int pnum);
void __fastcall SyncInitPlrPos(int pnum);
void __fastcall SyncInitPlr(int pnum);
void __fastcall CheckStats(int pnum);
void __fastcall ModifyPlrStr(int pnum, int l);
void __fastcall ModifyPlrMag(int pnum, int l);
void __fastcall ModifyPlrDex(int pnum, int l);
void __fastcall ModifyPlrVit(int pnum, int l);
void __fastcall SetPlayerHitPoints(int pnum, int newhp);
void __fastcall SetPlrStr(int pnum, int v);
void __fastcall SetPlrMag(int pnum, int v);
void __fastcall SetPlrDex(int pnum, int v);
void __fastcall SetPlrVit(int pnum, int v);
void __fastcall InitDungMsgs(int pnum);
void __cdecl PlayDungMsgs();
/* data */
extern int player_inf;
extern char ArmourChar[4];
extern char WepChar[10];
extern char CharChar[4];
/* rdata */
extern int plrxoff[9];
extern int plryoff[9];
extern int plrxoff2[9];
extern int plryoff2[9];
extern char PlrGFXAnimLens[3][11];
extern int PWVel[4][3];
extern int StrengthTbl[3];
extern int MagicTbl[3];
extern int DexterityTbl[3];
extern int VitalityTbl[3];
extern int ToBlkTbl[3];
extern char *ClassStrTblOld[3];
extern int MaxStats[3][4];
extern int ExpLvlsTbl[51];
extern char *ClassStrTbl[3];
extern unsigned char fix[9];

235
Source/plrmsg.cpp Normal file
View File

@ -0,0 +1,235 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
int plrmsg_ticks; // weak
char plr_msg_slot; // weak
_plrmsg plr_msgs[8];
text_color text_color_from_player_num[2] = { COL_WHITE, COL_GOLD };
//----- (00450D33) --------------------------------------------------------
void __fastcall plrmsg_delay(int a1)
{
_plrmsg *pMsg; // eax
signed int v2; // ecx
if ( a1 )
{
plrmsg_ticks = -GetTickCount();
}
else
{
plrmsg_ticks += GetTickCount();
pMsg = plr_msgs;
v2 = 8;
do
{
pMsg->time += plrmsg_ticks;
++pMsg;
--v2;
}
while ( v2 );
}
}
// 69B7D0: using guessed type int plrmsg_ticks;
//----- (00450D6A) --------------------------------------------------------
char *__fastcall ErrorPlrMsg(char *pszMsg)
{
_plrmsg *pMsg; // esi
char *v2; // edi
char *result; // eax
pMsg = &plr_msgs[(unsigned char)plr_msg_slot];
v2 = pszMsg;
plr_msg_slot = (plr_msg_slot + 1) & 7;
pMsg->player = 4;
pMsg->time = GetTickCount();
result = strncpy(pMsg->str, v2, 0x90u);
pMsg->str[143] = 0;
return result;
}
// 69B7D4: using guessed type char plr_msg_slot;
//----- (00450DB3) --------------------------------------------------------
size_t EventPlrMsg(char *pszFmt, ...)
{
char *v1; // esi
va_list va; // [esp+Ch] [ebp+8h]
va_start(va, pszFmt);
v1 = (char *)&plr_msgs[(unsigned char)plr_msg_slot];
plr_msg_slot = (plr_msg_slot + 1) & 7;
v1[4] = 4;
*(_DWORD *)v1 = GetTickCount();
v1 += 5;
vsprintf(v1, pszFmt, va);
return strlen(v1);
}
// 69B7D4: using guessed type char plr_msg_slot;
//----- (00450DFA) --------------------------------------------------------
void __fastcall SendPlrMsg(int pnum, const char *pszStr)
{
_plrmsg *pMsg; // esi
int v3; // ebx
const char *v4; // ebp
int v5; // edi
const char *v6; // ebx
pMsg = &plr_msgs[(unsigned char)plr_msg_slot];
v3 = pnum;
v4 = pszStr;
plr_msg_slot = (plr_msg_slot + 1) & 7;
pMsg->player = pnum;
pMsg->time = GetTickCount();
v5 = v3;
v6 = plr[v3]._pName;
strlen(v6); /* these are used in debug */
strlen(v4);
sprintf(pMsg->str, "%s (lvl %d): %s", v6, plr[v5]._pLevel, v4);
}
// 69B7D4: using guessed type char plr_msg_slot;
//----- (00450E64) --------------------------------------------------------
void __cdecl ClearPlrMsg()
{
_plrmsg *pMsg; // esi
DWORD v1; // eax
signed int v2; // ecx
pMsg = plr_msgs;
v1 = GetTickCount();
v2 = 8;
do
{
if ( (signed int)(v1 - pMsg->time) > 10000 )
pMsg->str[0] = 0;
++pMsg;
--v2;
}
while ( v2 );
}
//----- (00450E8E) --------------------------------------------------------
void __cdecl InitPlrMsg()
{
memset(plr_msgs, 0, 0x4C0u);
plr_msg_slot = 0;
}
// 69B7D4: using guessed type char plr_msg_slot;
//----- (00450EAA) --------------------------------------------------------
void __cdecl DrawPlrMsg()
{
int v0; // ebx
int v1; // ebp
int v2; // edi
char *v3; // esi
signed int v4; // [esp+Ch] [ebp-4h]
v0 = 74;
v1 = 230;
v2 = 620;
if ( chrflag || questlog )
{
if ( invflag || sbookflag )
return;
v0 = 394;
goto LABEL_9;
}
if ( invflag || sbookflag )
LABEL_9:
v2 = 300;
v3 = plr_msgs[0].str;
v4 = 8;
do
{
if ( *v3 )
PrintPlrMsg(v0, v1, v2, v3, *((unsigned char *)text_color_from_player_num + (unsigned char)*(v3 - 1)));
v3 += 152;
v1 += 35;
--v4;
}
while ( v4 );
}
// 4B8968: using guessed type int sbookflag;
// 69BD04: using guessed type int questlog;
//----- (00450F37) --------------------------------------------------------
void __fastcall PrintPlrMsg(int no, int x, int y, char *str, int just)
{
char *v5; // edi
int *v6; // edx
int v7; // esi
char *v8; // edx
int v9; // esi
unsigned int v10; // eax
unsigned char v11; // cl
unsigned char v12; // cl
int v13; // eax
unsigned char v14; // bl
int v15; // [esp+Ch] [ebp-Ch]
int *v16; // [esp+10h] [ebp-8h]
int v17; // [esp+14h] [ebp-4h]
char *stra; // [esp+24h] [ebp+Ch]
v17 = 0;
v5 = str;
v15 = no;
if ( *str )
{
v6 = &screen_y_times_768[x];
v16 = v6;
do
{
v7 = *v6;
v8 = v5;
v9 = v15 + v7;
v10 = 0;
stra = v5;
while ( 1 )
{
v11 = *v8;
if ( !*v8 )
break;
++v8;
v12 = fontframe[fontidx[v11]];
v10 += fontkern[v12] + 1;
if ( v12 )
{
if ( v10 >= y )
goto LABEL_13;
}
else
{
stra = v8;
}
}
stra = v8;
LABEL_13:
while ( v5 < stra )
{
v13 = (unsigned char)*v5++;
v14 = fontframe[fontidx[v13]];
if ( v14 )
CPrintString(v9, v14, just);
v9 += fontkern[v14] + 1;
}
v6 = v16 + 10;
++v17;
v16 += 10;
}
while ( v17 != 3 && *v5 );
}
}

28
Source/plrmsg.h Normal file
View File

@ -0,0 +1,28 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//plrmsg
extern int plrmsg_ticks; // weak
extern char plr_msg_slot; // weak
extern _plrmsg plr_msgs[8];
void __fastcall plrmsg_delay(int a1);
char *__fastcall ErrorPlrMsg(char *pszMsg);
size_t EventPlrMsg(char *pszFmt, ...);
void __fastcall SendPlrMsg(int pnum, const char *pszStr);
void __cdecl ClearPlrMsg();
void __cdecl InitPlrMsg();
void __cdecl DrawPlrMsg();
void __fastcall PrintPlrMsg(int no, int x, int y, char *str, int just);
/* data */
extern text_color text_color_from_player_num[2];

234
Source/portal.cpp Normal file
View File

@ -0,0 +1,234 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
#include "../types.h"
PortalStruct portal[4];
int portalindex;
int WarpDropX[4] = { 57, 59, 61, 63 };
int WarpDropY[4] = { 40, 40, 40, 40 };
//----- (00450FFE) --------------------------------------------------------
void __cdecl InitPortals()
{
int i; // edi
for(i = 0; i < 4; i++)
{
if(delta_portal_inited(i))
portal[i].open = 0;
}
}
//----- (00451024) --------------------------------------------------------
void __fastcall SetPortalStats(int i, int o, int x, int y, int lvl, int lvltype)
{
portal[i].x = x;
portal[i].setlvl = 0;
portal[i].y = y;
portal[i].open = o;
portal[i].level = lvl;
portal[i].ltype = lvltype;
}
//----- (00451062) --------------------------------------------------------
void __fastcall AddWarpMissile(int i, int x, int y)
{
int mi; // eax
missiledata[MIS_TOWN].mlSFX = -1;
dMissile[x][y] = 0;
mi = AddMissile(0, 0, x, y, 0, MIS_TOWN, 0, i, 0, 0);
if ( mi != -1 )
{
SetMissDir(mi, 1);
if ( currlevel )
missile[mi]._mlid = AddLight(missile[mi]._mix, missile[mi]._miy, 15);
missiledata[MIS_TOWN].mlSFX = LS_SENTINEL;
}
}
//----- (004510D6) --------------------------------------------------------
void __cdecl SyncPortals()
{
int v0; // edi
int *v1; // esi
int v2; // eax
v0 = 0;
v1 = &portal[0].level;
do
{
if ( *(v1 - 3) )
{
if ( currlevel )
{
v2 = currlevel;
if ( setlevel )
v2 = (unsigned char)setlvlnum;
if ( *v1 == v2 )
AddWarpMissile(v0, *(v1 - 2), *(v1 - 1));
}
else
{
AddWarpMissile(v0, WarpDropX[v0], WarpDropY[v0]);
}
}
v1 += 6;
++v0;
}
while ( (signed int)v1 < (signed int)&portal[4].level );
}
// 5CCB10: using guessed type char setlvlnum;
// 5CF31D: using guessed type char setlevel;
// 69BD04: using guessed type int questlog;
//----- (00451131) --------------------------------------------------------
void __fastcall AddInTownPortal(int i)
{
AddWarpMissile(i, WarpDropX[i], WarpDropY[i]);
}
//----- (00451145) --------------------------------------------------------
void __fastcall ActivatePortal(int i, int x, int y, int lvl, int lvltype, int sp)
{
portal[i].open = 1;
if ( lvl )
{
portal[i].level = lvl;
portal[i].x = x;
portal[i].ltype = lvltype;
portal[i].y = y;
portal[i].setlvl = sp;
}
}
//----- (0045118A) --------------------------------------------------------
void __fastcall DeactivatePortal(int i)
{
portal[i].open = 0;
}
//----- (00451196) --------------------------------------------------------
bool __fastcall PortalOnLevel(int i)
{
if ( portal[i].level == currlevel )
return 1;
else
return currlevel == 0;
}
//----- (004511B8) --------------------------------------------------------
void __fastcall RemovePortalMissile(int id)
{
int i; // esi
int mi; // eax
for ( i = 0; i < nummissiles; ++i )
{
mi = missileactive[i];
if ( missile[mi]._mitype == MIS_TOWN && missile[mi]._misource == id )
{
dFlags[missile[mi]._mix][missile[mi]._miy] &= 0xFE;
dMissile[missile[mi]._mix][missile[mi]._miy] = 0;
if ( portal[id].level )
AddUnLight(missile[mi]._mlid);
DeleteMissile(mi, i);
}
}
}
//----- (00451234) --------------------------------------------------------
void __fastcall SetCurrentPortal(int p)
{
portalindex = p;
}
//----- (0045123B) --------------------------------------------------------
void __cdecl GetPortalLevel()
{
if ( currlevel )
{
setlevel = 0;
currlevel = 0;
leveltype = 0;
plr[myplr].plrlevel = 0;
}
else
{
if ( portal[portalindex].setlvl )
{
setlevel = 1;
setlvlnum = portal[portalindex].level;
}
else
{
setlevel = 0;
}
currlevel = portal[portalindex].level;
leveltype = portal[portalindex].ltype;
plr[myplr].plrlevel = portal[portalindex].level;
if ( portalindex == myplr )
{
NetSendCmd(1, CMD_DEACTIVATEPORTAL);
DeactivatePortal(portalindex);
}
}
}
// 5BB1ED: using guessed type char leveltype;
// 5CCB10: using guessed type char setlvlnum;
// 5CF31D: using guessed type char setlevel;
//----- (004512E3) --------------------------------------------------------
void __cdecl GetPortalLvlPos()
{
if ( currlevel )
{
ViewX = portal[portalindex].x;
ViewY = portal[portalindex].y;
if ( portalindex != myplr )
{
ViewX++;
ViewY++;
}
}
else
{
ViewX = WarpDropX[portalindex] + 1;
ViewY = WarpDropY[portalindex] + 1;
}
}
//----- (00451346) --------------------------------------------------------
bool __fastcall PosOkPortal(int level, int x, int y)
{
int *v3; // eax
v3 = &portal[0].x;
while ( !*(v3 - 1) || v3[2] != level || (*v3 != x || v3[1] != y) && (*v3 != x - 1 || v3[1] != y - 1) )
{
v3 += 6;
if ( (signed int)v3 >= (signed int)&portal[4].x )
return 0;
}
return 1;
}
// 69BCFC: using guessed type int END_portalstruct;

33
Source/portal.h Normal file
View File

@ -0,0 +1,33 @@
/*
* UNPUBLISHED -- Rights reserved under the copyright laws of the
* United States. Use of a copyright notice is precautionary only and
* does not imply publication or disclosure.
*
* THIS DOCUMENTATION CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION
* OF BLIZZARD ENTERTAINMENT. ANY DUPLICATION, MODIFICATION,
* DISTRIBUTION, OR DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF BLIZZARD ENTERTAINMENT.
*/
//portal
extern PortalStruct portal[4];
extern int portalindex;
// int END_portalstruct; // weak
void __cdecl InitPortals();
void __fastcall SetPortalStats(int i, int o, int x, int y, int lvl, int lvltype);
void __fastcall AddWarpMissile(int i, int x, int y);
void __cdecl SyncPortals();
void __fastcall AddInTownPortal(int i);
void __fastcall ActivatePortal(int i, int x, int y, int lvl, int lvltype, int sp);
void __fastcall DeactivatePortal(int i);
bool __fastcall PortalOnLevel(int i);
void __fastcall RemovePortalMissile(int id);
void __fastcall SetCurrentPortal(int p);
void __cdecl GetPortalLevel();
void __cdecl GetPortalLvlPos();
bool __fastcall PosOkPortal(int level, int x, int y);
/* rdata */
extern int WarpDropX[4];
extern int WarpDropY[4];