From 51722eeed50f7de21c593519218c22608748f635 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 6 Oct 2018 18:05:13 +0200 Subject: [PATCH 1/6] Add clang-format script. Base default style on WebKit and set a few options specific to Devilution. * `AlignTrailingComments: true` * `AllowShortBlocksOnASingleLine: true` * `AllowShortFunctionsOnASingleLine: None` * `PointerAlignment: Right` For header files, we also want to add * `AlignConsecutiveAssignments: true` --- format.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 format.sh diff --git a/format.sh b/format.sh new file mode 100755 index 000000000..66c6de538 --- /dev/null +++ b/format.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +CPP_DONE="Source/doom.cpp Source/movie.cpp Source/pfile.cpp Source/player.cpp Source/plrmsg.cpp Source/sound.cpp Source/spells.cpp Source/tmsg.cpp" + +for f in $CPP_DONE; do + echo "Formatting $f" + clang-format -style="{BasedOnStyle: webkit, AlignTrailingComments: true, AllowShortBlocksOnASingleLine: true, AllowShortFunctionsOnASingleLine: None, PointerAlignment: Right}" -i $f +done + +H_DONE="enums.h structs.h" + +for f in $H_DONE; do + echo "Formatting $f" + clang-format -style="{BasedOnStyle: webkit, AlignTrailingComments: true, AllowShortBlocksOnASingleLine: true, AllowShortFunctionsOnASingleLine: None, PointerAlignment: Right, AlignConsecutiveAssignments: true}" -i $f +done From df8a886d0151dfe2c4191c72252ae1011ee09bf1 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 6 Oct 2018 18:05:58 +0200 Subject: [PATCH 2/6] Run format.sh --- Source/doom.cpp | 87 +- Source/movie.cpp | 109 +- Source/pfile.cpp | 1016 ++++--- Source/player.cpp | 6981 ++++++++++++++++++++++----------------------- Source/plrmsg.cpp | 217 +- Source/sound.cpp | 545 ++-- Source/spells.cpp | 594 ++-- Source/tmsg.cpp | 67 +- enums.h | 5201 +++++++++++++++++---------------- structs.h | 2659 +++++++++-------- 10 files changed, 8626 insertions(+), 8850 deletions(-) diff --git a/Source/doom.cpp b/Source/doom.cpp index 8d1a0cab6..3f5dcaaad 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -2,10 +2,10 @@ #include "../types.h" -int doom_quest_time; // weak +int doom_quest_time; // weak int doom_stars_drawn; // weak void *pDoomCel; -int doomflag; // weak +int doomflag; // weak int DoomQuestState; // idb /* @@ -30,81 +30,76 @@ void __cdecl doom_play_movie() int __cdecl doom_get_frame_from_time() { - if ( DoomQuestState == 36001 ) { - return 31; - } + if (DoomQuestState == 36001) { + return 31; + } - return DoomQuestState / 1200; + return DoomQuestState / 1200; } void __cdecl doom_alloc_cel() { - pDoomCel = DiabloAllocPtr(229376); + pDoomCel = DiabloAllocPtr(229376); } void __cdecl doom_cleanup() { - void *ptr = pDoomCel; - pDoomCel = NULL; - mem_free_dbg(ptr); + void *ptr = pDoomCel; + pDoomCel = NULL; + mem_free_dbg(ptr); } 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\\MapZ000%i.CEL", doom_quest_time); - } - else - { - sprintf(tempstr, "Items\\Map\\MapZ00%i.CEL", doom_quest_time); - } - LoadFileWithMem(tempstr, pDoomCel); + if (doom_quest_time == 31) { + strcpy(tempstr, "Items\\Map\\MapZDoom.CEL"); + } else if (doom_quest_time < 10) { + sprintf(tempstr, "Items\\Map\\MapZ000%i.CEL", doom_quest_time); + } else { + sprintf(tempstr, "Items\\Map\\MapZ00%i.CEL", doom_quest_time); + } + LoadFileWithMem(tempstr, pDoomCel); } // 525750: using guessed type int doom_quest_time; void __cdecl doom_init() { - doomflag = 1; - doom_alloc_cel(); - doom_quest_time = doom_get_frame_from_time() == 31 ? 31 : 0; - doom_load_graphics(); + doomflag = 1; + doom_alloc_cel(); + doom_quest_time = doom_get_frame_from_time() == 31 ? 31 : 0; + doom_load_graphics(); } // 525750: using guessed type int doom_quest_time; // 52575C: using guessed type int doomflag; void __cdecl doom_close() { - if ( doomflag ) { - doomflag = 0; - doom_cleanup(); - } + if (doomflag) { + doomflag = 0; + doom_cleanup(); + } } // 52575C: using guessed type int doomflag; void __cdecl doom_draw() { - if ( !doomflag ) { - return; - } + if (!doomflag) { + return; + } - if ( doom_quest_time != 31 ) { - doom_stars_drawn++; - if ( doom_stars_drawn >= 5 ) { - doom_stars_drawn = 0; - doom_quest_time++; - if ( doom_quest_time > doom_get_frame_from_time() ) { - doom_quest_time = 0; - } - doom_load_graphics(); - } - } + if (doom_quest_time != 31) { + doom_stars_drawn++; + if (doom_stars_drawn >= 5) { + doom_stars_drawn = 0; + doom_quest_time++; + if (doom_quest_time > doom_get_frame_from_time()) { + doom_quest_time = 0; + } + doom_load_graphics(); + } + } - CelDecodeOnly(64, 511, pDoomCel, 1, 640); + CelDecodeOnly(64, 511, pDoomCel, 1, 640); } // 525750: using guessed type int doom_quest_time; // 525754: using guessed type int doom_stars_drawn; diff --git a/Source/movie.cpp b/Source/movie.cpp index 9183df732..41736e1f6 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -3,56 +3,55 @@ #include "../types.h" int movie_cpp_init_value; // weak -char movie_playing; // weak -BOOL loop_movie; // weak +char movie_playing; // weak +BOOL loop_movie; // weak const int movie_inf = 0x7F800000; // weak -struct movie_cpp_init -{ - movie_cpp_init() - { - movie_cpp_init_value = movie_inf; - } +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; void __fastcall play_movie(char *pszMovie, BOOL user_can_close) { - if ( !gbActive ) { - return; - } + if (!gbActive) { + return; + } - WNDPROC saveProc = SetWindowProc(MovieWndProc); - InvalidateRect(ghMainWnd, 0, 0); - UpdateWindow(ghMainWnd); - movie_playing = TRUE; - sound_disable_music(TRUE); - sfx_stop(); - effects_play_sound("Sfx\\Misc\\blank.wav"); + WNDPROC saveProc = SetWindowProc(MovieWndProc); + InvalidateRect(ghMainWnd, 0, 0); + UpdateWindow(ghMainWnd); + movie_playing = TRUE; + sound_disable_music(TRUE); + sfx_stop(); + effects_play_sound("Sfx\\Misc\\blank.wav"); - void *video_stream; - SVidPlayBegin(pszMovie, 0, 0, 0, 0, loop_movie ? 0x100C0808 : 0x10280808, &video_stream); - if ( video_stream ) { - MSG Msg; - while ( video_stream ) { - if ( !gbActive || user_can_close && !movie_playing ) - break; - while ( PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE) ) { - if ( Msg.message != WM_QUIT ) { - TranslateMessage(&Msg); - DispatchMessage(&Msg); - } - } - if ( !SVidPlayContinue() ) - break; - } - if ( video_stream ) - SVidPlayEnd(video_stream); - } - SetWindowProc(saveProc); - sound_disable_music(FALSE); + void *video_stream; + SVidPlayBegin(pszMovie, 0, 0, 0, 0, loop_movie ? 0x100C0808 : 0x10280808, &video_stream); + if (video_stream) { + MSG Msg; + while (video_stream) { + if (!gbActive || user_can_close && !movie_playing) + break; + while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { + if (Msg.message != WM_QUIT) { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + } + if (!SVidPlayContinue()) + break; + } + if (video_stream) + SVidPlayEnd(video_stream); + } + SetWindowProc(saveProc); + sound_disable_music(FALSE); } // 634980: using guessed type int gbActive; // 659AF8: using guessed type int movie_playing; @@ -60,23 +59,21 @@ void __fastcall play_movie(char *pszMovie, BOOL user_can_close) LRESULT __stdcall MovieWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - switch ( Msg ) { - case WM_KEYFIRST: - case WM_CHAR: - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - movie_playing = FALSE; - break; - case WM_SYSCOMMAND: - if ( wParam == SC_CLOSE ) { - movie_playing = FALSE; - return NULL; - } - break; - } - - return MainWndProc(hWnd, Msg, wParam, lParam); - + switch (Msg) { + case WM_KEYFIRST: + case WM_CHAR: + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + movie_playing = FALSE; + break; + case WM_SYSCOMMAND: + if (wParam == SC_CLOSE) { + movie_playing = FALSE; + return NULL; + } + break; + } + return MainWndProc(hWnd, Msg, wParam, lParam); } // 659AF8: using guessed type int movie_playing; diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 9372eba15..da9ce4ab0 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -2,8 +2,8 @@ #include "../types.h" -#define PASSWORD_SINGLE "xrgyrkj1" -#define PASSWORD_MULTI "szqnlsk1" +#define PASSWORD_SINGLE "xrgyrkj1" +#define PASSWORD_MULTI "szqnlsk1" static float pfile_cpp_init_value = INFINITY; @@ -12,691 +12,689 @@ BOOL gbValidSaveFile; void __cdecl pfile_init_save_directory() { - DWORD len; - char Buffer[MAX_PATH]; + DWORD len; + char Buffer[MAX_PATH]; - len = GetWindowsDirectory(Buffer, sizeof(Buffer)); - if ( len ) { - pfile_check_available_space(Buffer); - len = GetModuleFileName(ghInst, Buffer, sizeof(Buffer)); - } + len = GetWindowsDirectory(Buffer, sizeof(Buffer)); + if (len) { + pfile_check_available_space(Buffer); + len = GetModuleFileName(ghInst, Buffer, sizeof(Buffer)); + } - if ( !len ) - TermMsg("Unable to initialize save directory"); - else - pfile_check_available_space(Buffer); + if (!len) + TermMsg("Unable to initialize save directory"); + else + pfile_check_available_space(Buffer); } void __fastcall pfile_check_available_space(char *pszDir) { - char *s; - BOOL hasSpace; - DWORD TotalNumberOfClusters; - DWORD NumberOfFreeClusters; - DWORD BytesPerSector; - DWORD SectorsPerCluster; + char *s; + BOOL hasSpace; + DWORD TotalNumberOfClusters; + DWORD NumberOfFreeClusters; + DWORD BytesPerSector; + DWORD SectorsPerCluster; - s = pszDir; - while ( *s ) { - if ( *s++ != '\\' ) - continue; - *s = '\0'; - break; - } + s = pszDir; + while (*s) { + if (*s++ != '\\') + continue; + *s = '\0'; + break; + } - hasSpace = GetDiskFreeSpace(pszDir, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters); - if ( hasSpace ) { - // 10MB is the amount hardcoded in the error dialog - if ( (__int64)SectorsPerCluster * BytesPerSector * NumberOfFreeClusters < (__int64)(10 << 20) ) - hasSpace = FALSE; - } + hasSpace = GetDiskFreeSpace(pszDir, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters); + if (hasSpace) { + // 10MB is the amount hardcoded in the error dialog + if ((__int64)SectorsPerCluster * BytesPerSector * NumberOfFreeClusters < (__int64)(10 << 20)) + hasSpace = FALSE; + } - if ( !hasSpace ) - DiskFreeDlg(pszDir); + if (!hasSpace) + DiskFreeDlg(pszDir); } void __cdecl pfile_write_hero() { - unsigned int save_num; - PkPlayerStruct pkplr; + unsigned int save_num; + PkPlayerStruct pkplr; - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - if (pfile_open_archive(TRUE, save_num)) { - PackPlayer(&pkplr, myplr, gbMaxPlayers == 1); - pfile_encode_hero(&pkplr); - pfile_flush(gbMaxPlayers == 1, save_num); - } + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + if (pfile_open_archive(TRUE, save_num)) { + PackPlayer(&pkplr, myplr, gbMaxPlayers == 1); + pfile_encode_hero(&pkplr); + pfile_flush(gbMaxPlayers == 1, save_num); + } } unsigned int __fastcall pfile_get_save_num_from_name(const char *name) { - unsigned int i; + unsigned int i; - for ( i=0; i < MAX_CHARACTERS; i++ ) { - if ( !_strcmpi(hero_names[i], name) ) - break; - } + for (i = 0; i < MAX_CHARACTERS; i++) { + if (!_strcmpi(hero_names[i], name)) + break; + } - return i; + return i; } void __fastcall pfile_encode_hero(const PkPlayerStruct *pPack) { - BYTE *packed; - DWORD packed_len; - char password[16] = PASSWORD_SINGLE; + BYTE *packed; + DWORD packed_len; + char password[16] = PASSWORD_SINGLE; - if ( gbMaxPlayers > 1 ) - strcpy(password, PASSWORD_MULTI); + if (gbMaxPlayers > 1) + strcpy(password, PASSWORD_MULTI); - packed_len = codec_get_encoded_len(sizeof(*pPack)); - packed = (BYTE*)DiabloAllocPtr(packed_len); - memcpy(packed, pPack, sizeof(*pPack)); - codec_encode(packed, sizeof(*pPack), packed_len, password); - mpqapi_write_file("hero", packed, packed_len); - mem_free_dbg(packed); + packed_len = codec_get_encoded_len(sizeof(*pPack)); + packed = (BYTE *)DiabloAllocPtr(packed_len); + memcpy(packed, pPack, sizeof(*pPack)); + codec_encode(packed, sizeof(*pPack), packed_len, password); + mpqapi_write_file("hero", packed, packed_len); + mem_free_dbg(packed); } BOOL __fastcall pfile_open_archive(BOOL a1, unsigned int save_num) { - char FileName[MAX_PATH]; + char FileName[MAX_PATH]; - pfile_get_save_path(FileName, sizeof(FileName), save_num); - if ( mpqapi_open_archive(FileName, FALSE, save_num) ) - return TRUE; + pfile_get_save_path(FileName, sizeof(FileName), save_num); + if (mpqapi_open_archive(FileName, FALSE, save_num)) + return TRUE; - if ( a1 && gbMaxPlayers > 1 ) - mpqapi_update_multi_creation_time(save_num); - return FALSE; + if (a1 && gbMaxPlayers > 1) + mpqapi_update_multi_creation_time(save_num); + return FALSE; } void __fastcall pfile_get_save_path(char *pszBuf, DWORD dwBufSize, unsigned int save_num) { - DWORD plen; - char *s; - char path[MAX_PATH]; - const char *fmt = "\\multi_%d.sv"; + DWORD plen; + char *s; + char path[MAX_PATH]; + const char *fmt = "\\multi_%d.sv"; - if ( gbMaxPlayers <= 1 ) - fmt = "\\single_%d.sv"; + if (gbMaxPlayers <= 1) + fmt = "\\single_%d.sv"; - // BUGFIX: ignores dwBufSize and uses MAX_PATH instead - plen = GetModuleFileName(ghInst, pszBuf, MAX_PATH); - s = strrchr(pszBuf, '\\'); - if ( s ) - *s = '\0'; + // BUGFIX: ignores dwBufSize and uses MAX_PATH instead + plen = GetModuleFileName(ghInst, pszBuf, MAX_PATH); + s = strrchr(pszBuf, '\\'); + if (s) + *s = '\0'; - if ( !plen ) - TermMsg("Unable to get save directory"); + if (!plen) + TermMsg("Unable to get save directory"); - sprintf(path, fmt, save_num); - strcat(pszBuf, path); - _strlwr(pszBuf); + sprintf(path, fmt, save_num); + strcat(pszBuf, path); + _strlwr(pszBuf); } void __fastcall pfile_flush(BOOL is_single_player, unsigned int save_num) { - char FileName[MAX_PATH]; + char FileName[MAX_PATH]; - pfile_get_save_path(FileName, sizeof(FileName), save_num); - mpqapi_flush_and_close(FileName, is_single_player, save_num); + pfile_get_save_path(FileName, sizeof(FileName), save_num); + mpqapi_flush_and_close(FileName, is_single_player, save_num); } BOOL __fastcall pfile_create_player_description(char *dst, unsigned int len) { - char desc[128]; - _uiheroinfo uihero; + char desc[128]; + _uiheroinfo uihero; - myplr = 0; - pfile_read_player_from_save(); - game_2_ui_player(plr, &uihero, gbValidSaveFile); - UiSetupPlayerInfo(chr_name_str, &uihero, GAME_ID); + myplr = 0; + pfile_read_player_from_save(); + game_2_ui_player(plr, &uihero, gbValidSaveFile); + UiSetupPlayerInfo(chr_name_str, &uihero, GAME_ID); - if ( dst != NULL && len ) { - if ( UiCreatePlayerDescription(&uihero, GAME_ID, desc) == 0 ) - return FALSE; - SStrCopy(dst, desc, len); - } - return TRUE; + if (dst != NULL && len) { + if (UiCreatePlayerDescription(&uihero, GAME_ID, desc) == 0) + return FALSE; + SStrCopy(dst, desc, len); + } + return TRUE; } BOOL __fastcall pfile_create_save_file(const char *name_1, const char *name_2) { - int i; - unsigned int save_num; - _uiheroinfo uihero; - BOOL found = FALSE; - - if ( pfile_get_save_num_from_name(name_2) == MAX_CHARACTERS ) { - for ( i = 0; i != MAX_PLRS; i++ ) { - if ( !_strcmpi(name_1, plr[i]._pName) ) { - found = TRUE; - break; - } - } - } - - if ( !found ) - return FALSE; - save_num = pfile_get_save_num_from_name(name_1); - if ( save_num == MAX_CHARACTERS ) - return FALSE; - - SStrCopy(hero_names[save_num], name_2, PLR_NAME_LEN); - SStrCopy(plr[i]._pName, name_2, PLR_NAME_LEN); - if ( !_strcmpi(chr_name_str, name_1) ) - SStrCopy(chr_name_str, name_2, sizeof(chr_name_str)); - game_2_ui_player(plr, &uihero, gbValidSaveFile); - UiSetupPlayerInfo(chr_name_str, &uihero, GAME_ID); - pfile_write_hero(); - return TRUE; + int i; + unsigned int save_num; + _uiheroinfo uihero; + BOOL found = FALSE; + + if (pfile_get_save_num_from_name(name_2) == MAX_CHARACTERS) { + for (i = 0; i != MAX_PLRS; i++) { + if (!_strcmpi(name_1, plr[i]._pName)) { + found = TRUE; + break; + } + } + } + + if (!found) + return FALSE; + save_num = pfile_get_save_num_from_name(name_1); + if (save_num == MAX_CHARACTERS) + return FALSE; + + SStrCopy(hero_names[save_num], name_2, PLR_NAME_LEN); + SStrCopy(plr[i]._pName, name_2, PLR_NAME_LEN); + if (!_strcmpi(chr_name_str, name_1)) + SStrCopy(chr_name_str, name_2, sizeof(chr_name_str)); + game_2_ui_player(plr, &uihero, gbValidSaveFile); + UiSetupPlayerInfo(chr_name_str, &uihero, GAME_ID); + pfile_write_hero(); + return TRUE; } void __cdecl pfile_flush_W() { - pfile_flush(TRUE, pfile_get_save_num_from_name(plr[myplr]._pName)); + pfile_flush(TRUE, pfile_get_save_num_from_name(plr[myplr]._pName)); } void __fastcall game_2_ui_player(const PlayerStruct *p, _uiheroinfo *heroinfo, BOOL bHasSaveFile) { - memset(heroinfo, 0, sizeof(*heroinfo)); - strncpy(heroinfo->name, p->_pName, sizeof(heroinfo->name) - 1); - heroinfo->name[sizeof(heroinfo->name) - 1] = '\0'; - heroinfo->level = p->_pLevel; - heroinfo->heroclass = game_2_ui_class(p); - heroinfo->strength = p->_pStrength; - heroinfo->magic = p->_pMagic; - heroinfo->dexterity = p->_pDexterity; - heroinfo->vitality = p->_pVitality; - heroinfo->gold = p->_pGold; - heroinfo->hassaved = bHasSaveFile; - heroinfo->herorank = (unsigned char)p->pDiabloKillLevel; - heroinfo->spawned = 0; + memset(heroinfo, 0, sizeof(*heroinfo)); + strncpy(heroinfo->name, p->_pName, sizeof(heroinfo->name) - 1); + heroinfo->name[sizeof(heroinfo->name) - 1] = '\0'; + heroinfo->level = p->_pLevel; + heroinfo->heroclass = game_2_ui_class(p); + heroinfo->strength = p->_pStrength; + heroinfo->magic = p->_pMagic; + heroinfo->dexterity = p->_pDexterity; + heroinfo->vitality = p->_pVitality; + heroinfo->gold = p->_pGold; + heroinfo->hassaved = bHasSaveFile; + heroinfo->herorank = (unsigned char)p->pDiabloKillLevel; + heroinfo->spawned = 0; } unsigned char __fastcall game_2_ui_class(const PlayerStruct *p) { - unsigned char uiclass; - if ( p->_pClass == PC_WARRIOR ) - uiclass = UI_WARRIOR; - else if ( p->_pClass == PC_ROGUE ) - uiclass = UI_ROGUE; - else - uiclass = UI_SORCERER; - - return uiclass; -} - -BOOL __stdcall pfile_ui_set_hero_infos(BOOL (__stdcall *ui_add_hero_info)(_uiheroinfo *)) -{ - unsigned int i, save_num; - char FileName[MAX_PATH]; - char NewFileName[MAX_PATH]; - int a1; - - memset(hero_names, 0, sizeof(hero_names)); - if (gbMaxPlayers > 1) { - for ( i = 0, save_num = 0; i < MAX_CHARACTERS && save_num < MAX_CHARACTERS; i++) { - struct _OFSTRUCT ReOpenBuff; - const char *s; - - GetSaveDirectory(FileName, sizeof(FileName), i); - s = strrchr(FileName, '\\') + 1; - if ( s == (const char*)1 ) - continue; - if ( OpenFile(FileName, &ReOpenBuff, OF_EXIST) == HFILE_ERROR ) - continue; - if (!SRegLoadString("Diablo\\Converted", s, 0, NewFileName, sizeof(NewFileName))) { - while (save_num < MAX_CHARACTERS) { - pfile_get_save_path(NewFileName, sizeof(NewFileName), save_num++); - if (OpenFile(NewFileName, &ReOpenBuff, OF_EXIST)==HFILE_ERROR) { - if (CopyFile(FileName, NewFileName, TRUE)) { - DWORD attrib; - SRegSaveString("Diablo\\Converted", s, 0, NewFileName); - attrib = GetFileAttributes(NewFileName); - if (attrib != INVALID_FILE_ATTRIBUTES) { - attrib &= ~(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); - SetFileAttributes(NewFileName, attrib); - } - } - break; - } - } - } - } - } - - a1 = 1; - for (i=0; i < MAX_CHARACTERS; i++) { - PkPlayerStruct pkplr; - HANDLE archive = pfile_open_save_archive(&a1, i); - if (archive) { - if (pfile_read_hero(archive, &pkplr)) { - _uiheroinfo uihero; - strcpy(hero_names[i], pkplr.pName); - UnPackPlayer(&pkplr, 0, FALSE); - game_2_ui_player(plr, &uihero, pfile_archive_contains_game(archive, i)); - ui_add_hero_info(&uihero); - } - pfile_SFileCloseArchive(archive); - } - } - - return TRUE; + unsigned char uiclass; + if (p->_pClass == PC_WARRIOR) + uiclass = UI_WARRIOR; + else if (p->_pClass == PC_ROGUE) + uiclass = UI_ROGUE; + else + uiclass = UI_SORCERER; + + return uiclass; +} + +BOOL __stdcall pfile_ui_set_hero_infos(BOOL(__stdcall *ui_add_hero_info)(_uiheroinfo *)) +{ + unsigned int i, save_num; + char FileName[MAX_PATH]; + char NewFileName[MAX_PATH]; + int a1; + + memset(hero_names, 0, sizeof(hero_names)); + if (gbMaxPlayers > 1) { + for (i = 0, save_num = 0; i < MAX_CHARACTERS && save_num < MAX_CHARACTERS; i++) { + struct _OFSTRUCT ReOpenBuff; + const char *s; + + GetSaveDirectory(FileName, sizeof(FileName), i); + s = strrchr(FileName, '\\') + 1; + if (s == (const char *)1) + continue; + if (OpenFile(FileName, &ReOpenBuff, OF_EXIST) == HFILE_ERROR) + continue; + if (!SRegLoadString("Diablo\\Converted", s, 0, NewFileName, sizeof(NewFileName))) { + while (save_num < MAX_CHARACTERS) { + pfile_get_save_path(NewFileName, sizeof(NewFileName), save_num++); + if (OpenFile(NewFileName, &ReOpenBuff, OF_EXIST) == HFILE_ERROR) { + if (CopyFile(FileName, NewFileName, TRUE)) { + DWORD attrib; + SRegSaveString("Diablo\\Converted", s, 0, NewFileName); + attrib = GetFileAttributes(NewFileName); + if (attrib != INVALID_FILE_ATTRIBUTES) { + attrib &= ~(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); + SetFileAttributes(NewFileName, attrib); + } + } + break; + } + } + } + } + } + + a1 = 1; + for (i = 0; i < MAX_CHARACTERS; i++) { + PkPlayerStruct pkplr; + HANDLE archive = pfile_open_save_archive(&a1, i); + if (archive) { + if (pfile_read_hero(archive, &pkplr)) { + _uiheroinfo uihero; + strcpy(hero_names[i], pkplr.pName); + UnPackPlayer(&pkplr, 0, FALSE); + game_2_ui_player(plr, &uihero, pfile_archive_contains_game(archive, i)); + ui_add_hero_info(&uihero); + } + pfile_SFileCloseArchive(archive); + } + } + + return TRUE; } char *__fastcall GetSaveDirectory(char *dst, int dst_size, unsigned int save_num) { - DWORD dirLen; - char FileName[MAX_PATH]; - const char *savename; + DWORD dirLen; + char FileName[MAX_PATH]; + const char *savename; - // BUGFIX: ignores dst_size and uses MAX_PATH instead - if ( gbMaxPlayers > 1 ) { - savename = "\\dlinfo_%d.drv"; - dirLen = GetWindowsDirectory(dst, MAX_PATH); - } else { - char *s; - savename = "\\single_%d.sv"; - dirLen = GetModuleFileName(ghInst, dst, MAX_PATH); - s = strrchr(dst, '\\'); - if ( s ) - *s = '\0'; - } + // BUGFIX: ignores dst_size and uses MAX_PATH instead + if (gbMaxPlayers > 1) { + savename = "\\dlinfo_%d.drv"; + dirLen = GetWindowsDirectory(dst, MAX_PATH); + } else { + char *s; + savename = "\\single_%d.sv"; + dirLen = GetModuleFileName(ghInst, dst, MAX_PATH); + s = strrchr(dst, '\\'); + if (s) + *s = '\0'; + } - if ( !dirLen ) - TermMsg("Unable to get save directory"); + if (!dirLen) + TermMsg("Unable to get save directory"); - sprintf(FileName, savename, save_num); - strcat(dst, FileName); - return _strlwr(dst); + sprintf(FileName, savename, save_num); + strcat(dst, FileName); + return _strlwr(dst); } BOOL __fastcall pfile_read_hero(HANDLE archive, PkPlayerStruct *pPack) { - HANDLE file; - - if ( !SFileOpenFileEx(archive, "hero", 0, &file) ) - return FALSE; - else { - DWORD dwlen; - BOOL ret = FALSE; - char password[16] = PASSWORD_SINGLE; - DWORD nSize = 16; - - if ( gbMaxPlayers > 1 ) - strcpy(password, PASSWORD_MULTI); - - dwlen = SFileGetFileSize(file, NULL); - if ( dwlen ) { - DWORD read; - unsigned char *buf = DiabloAllocPtr(dwlen); - if ( SFileReadFile(file, buf, dwlen, &read, NULL) ) { - BOOL decoded = TRUE; - read = codec_decode(buf, dwlen, password); - if ( !read && gbMaxPlayers > 1 ) { - GetComputerName(password, &nSize); - if ( SFileSetFilePointer(file, 0, NULL, 0) || !SFileReadFile(file, buf, dwlen, &read, NULL) ) - decoded = FALSE; - else - read = codec_decode(buf, dwlen, password); - } - if ( decoded && read == sizeof(*pPack) ) { - memcpy(pPack, buf, sizeof(*pPack)); - ret = TRUE; - } - } - if ( buf ) - mem_free_dbg(buf); - } - SFileCloseFile(file); - return ret; - } + HANDLE file; + + if (!SFileOpenFileEx(archive, "hero", 0, &file)) + return FALSE; + else { + DWORD dwlen; + BOOL ret = FALSE; + char password[16] = PASSWORD_SINGLE; + DWORD nSize = 16; + + if (gbMaxPlayers > 1) + strcpy(password, PASSWORD_MULTI); + + dwlen = SFileGetFileSize(file, NULL); + if (dwlen) { + DWORD read; + unsigned char *buf = DiabloAllocPtr(dwlen); + if (SFileReadFile(file, buf, dwlen, &read, NULL)) { + BOOL decoded = TRUE; + read = codec_decode(buf, dwlen, password); + if (!read && gbMaxPlayers > 1) { + GetComputerName(password, &nSize); + if (SFileSetFilePointer(file, 0, NULL, 0) || !SFileReadFile(file, buf, dwlen, &read, NULL)) + decoded = FALSE; + else + read = codec_decode(buf, dwlen, password); + } + if (decoded && read == sizeof(*pPack)) { + memcpy(pPack, buf, sizeof(*pPack)); + ret = TRUE; + } + } + if (buf) + mem_free_dbg(buf); + } + SFileCloseFile(file); + return ret; + } } HANDLE __fastcall pfile_open_save_archive(int *unused, unsigned int save_num) { - char SrcStr[MAX_PATH]; - HANDLE archive; + char SrcStr[MAX_PATH]; + HANDLE archive; - pfile_get_save_path(SrcStr, sizeof(SrcStr), save_num); - if ( SFileOpenArchive(SrcStr, 0x7000, 0, &archive) ) - return archive; - return NULL; + pfile_get_save_path(SrcStr, sizeof(SrcStr), save_num); + if (SFileOpenArchive(SrcStr, 0x7000, 0, &archive)) + return archive; + return NULL; } void __fastcall pfile_SFileCloseArchive(HANDLE hsArchive) { - SFileCloseArchive(hsArchive); + SFileCloseArchive(hsArchive); } BOOL __fastcall pfile_archive_contains_game(HANDLE hsArchive, unsigned int save_num) { - HANDLE file; + HANDLE file; - if ( gbMaxPlayers != 1 ) - return FALSE; + if (gbMaxPlayers != 1) + return FALSE; - if ( !SFileOpenFileEx(hsArchive, "game", 0, &file) ) - return FALSE; + if (!SFileOpenFileEx(hsArchive, "game", 0, &file)) + return FALSE; - SFileCloseFile(file); - return TRUE; + SFileCloseFile(file); + return TRUE; } BOOL __stdcall pfile_ui_set_class_stats(unsigned int player_class_nr, _uidefaultstats *class_stats) { - int c; + int c; - c = pfile_get_player_class(player_class_nr); - class_stats->strength = StrengthTbl[c]; - class_stats->magic = MagicTbl[c]; - class_stats->dexterity = DexterityTbl[c]; - class_stats->vitality = VitalityTbl[c]; - return TRUE; + c = pfile_get_player_class(player_class_nr); + class_stats->strength = StrengthTbl[c]; + class_stats->magic = MagicTbl[c]; + class_stats->dexterity = DexterityTbl[c]; + class_stats->vitality = VitalityTbl[c]; + return TRUE; } char __fastcall pfile_get_player_class(unsigned int player_class_nr) { - char pc_class; + char pc_class; - if ( player_class_nr == UI_WARRIOR ) - pc_class = PC_WARRIOR; - else if ( player_class_nr == UI_ROGUE ) - pc_class = PC_ROGUE; - else - pc_class = PC_SORCERER; - return pc_class; + if (player_class_nr == UI_WARRIOR) + pc_class = PC_WARRIOR; + else if (player_class_nr == UI_ROGUE) + pc_class = PC_ROGUE; + else + pc_class = PC_SORCERER; + return pc_class; } BOOL __stdcall pfile_ui_save_create(_uiheroinfo *heroinfo) { - unsigned int save_num; - char cl; - PkPlayerStruct pkplr; - - save_num = pfile_get_save_num_from_name(heroinfo->name); - if ( save_num == MAX_CHARACTERS ) { - for ( save_num=0; save_num < MAX_CHARACTERS; save_num++) { - if ( !hero_names[save_num][0] ) - break; - } - if ( save_num == MAX_CHARACTERS ) - return false; - } - if ( !pfile_open_archive(FALSE, save_num) ) - return FALSE; - mpqapi_remove_hash_entries(pfile_get_file_name); - strncpy(hero_names[save_num], heroinfo->name, PLR_NAME_LEN); - hero_names[save_num][PLR_NAME_LEN - 1] = '\0'; - cl = pfile_get_player_class(heroinfo->heroclass); - CreatePlayer(0, cl); - strncpy(plr[0]._pName, heroinfo->name, PLR_NAME_LEN); - plr[0]._pName[PLR_NAME_LEN - 1] = '\0'; - PackPlayer(&pkplr, 0, TRUE); - pfile_encode_hero(&pkplr); - game_2_ui_player(&plr[0], heroinfo, FALSE); - pfile_flush(TRUE, save_num); - return TRUE; + unsigned int save_num; + char cl; + PkPlayerStruct pkplr; + + save_num = pfile_get_save_num_from_name(heroinfo->name); + if (save_num == MAX_CHARACTERS) { + for (save_num = 0; save_num < MAX_CHARACTERS; save_num++) { + if (!hero_names[save_num][0]) + break; + } + if (save_num == MAX_CHARACTERS) + return false; + } + if (!pfile_open_archive(FALSE, save_num)) + return FALSE; + mpqapi_remove_hash_entries(pfile_get_file_name); + strncpy(hero_names[save_num], heroinfo->name, PLR_NAME_LEN); + hero_names[save_num][PLR_NAME_LEN - 1] = '\0'; + cl = pfile_get_player_class(heroinfo->heroclass); + CreatePlayer(0, cl); + strncpy(plr[0]._pName, heroinfo->name, PLR_NAME_LEN); + plr[0]._pName[PLR_NAME_LEN - 1] = '\0'; + PackPlayer(&pkplr, 0, TRUE); + pfile_encode_hero(&pkplr); + game_2_ui_player(&plr[0], heroinfo, FALSE); + pfile_flush(TRUE, save_num); + return TRUE; } BOOL __stdcall pfile_get_file_name(DWORD lvl, char *dst) { - const char *fmt; - - if ( gbMaxPlayers > 1 ) { - if ( lvl ) - return FALSE; - fmt = "hero"; - } else { - if ( lvl < 17 ) - fmt = "perml%02d"; - else if ( lvl < 34 ) { - lvl -= 17; - fmt = "perms%02d"; - } else if ( lvl == 34 ) - fmt = "game"; - else if ( lvl == 35 ) - fmt = "hero"; - else - return FALSE; - } - sprintf(dst, fmt, lvl); - return TRUE; + const char *fmt; + + if (gbMaxPlayers > 1) { + if (lvl) + return FALSE; + fmt = "hero"; + } else { + if (lvl < 17) + fmt = "perml%02d"; + else if (lvl < 34) { + lvl -= 17; + fmt = "perms%02d"; + } else if (lvl == 34) + fmt = "game"; + else if (lvl == 35) + fmt = "hero"; + else + return FALSE; + } + sprintf(dst, fmt, lvl); + return TRUE; } BOOL __stdcall pfile_delete_save(_uiheroinfo *hero_info) { - unsigned int save_num; - char FileName[MAX_PATH]; + unsigned int save_num; + char FileName[MAX_PATH]; - save_num = pfile_get_save_num_from_name(hero_info->name); - if ( save_num < MAX_CHARACTERS ) { - hero_names[save_num][0] = '\0'; - pfile_get_save_path(FileName, sizeof(FileName), save_num); - DeleteFile(FileName); - } - return TRUE; + save_num = pfile_get_save_num_from_name(hero_info->name); + if (save_num < MAX_CHARACTERS) { + hero_names[save_num][0] = '\0'; + pfile_get_save_path(FileName, sizeof(FileName), save_num); + DeleteFile(FileName); + } + return TRUE; } void __cdecl pfile_read_player_from_save() { - HANDLE archive; - unsigned int save_num; - PkPlayerStruct pkplr; + HANDLE archive; + unsigned int save_num; + PkPlayerStruct pkplr; - save_num = pfile_get_save_num_from_name(chr_name_str); - archive = pfile_open_save_archive(NULL, save_num); - if ( archive == NULL ) - TermMsg("Unable to open archive"); - if ( !pfile_read_hero(archive, &pkplr) ) - TermMsg("Unable to load character"); + save_num = pfile_get_save_num_from_name(chr_name_str); + archive = pfile_open_save_archive(NULL, save_num); + if (archive == NULL) + TermMsg("Unable to open archive"); + if (!pfile_read_hero(archive, &pkplr)) + TermMsg("Unable to load character"); - UnPackPlayer(&pkplr, myplr, FALSE); - gbValidSaveFile = pfile_archive_contains_game(archive, save_num); - pfile_SFileCloseArchive(archive); + UnPackPlayer(&pkplr, myplr, FALSE); + gbValidSaveFile = pfile_archive_contains_game(archive, save_num); + pfile_SFileCloseArchive(archive); } void __fastcall GetTempLevelNames(char *szTemp) { - // BUGFIX: function call has no purpose - pfile_get_save_num_from_name(plr[myplr]._pName); - if ( setlevel ) - sprintf(szTemp, "temps%02d", (unsigned char)setlvlnum); - else - sprintf(szTemp, "templ%02d", currlevel); + // BUGFIX: function call has no purpose + pfile_get_save_num_from_name(plr[myplr]._pName); + if (setlevel) + sprintf(szTemp, "temps%02d", (unsigned char)setlvlnum); + else + sprintf(szTemp, "templ%02d", currlevel); } // 5CCB10: using guessed type char setlvlnum; // 5CF31D: using guessed type char setlevel; void __fastcall GetPermLevelNames(char *szPerm) { - unsigned int save_num; - BOOL has_file; + unsigned int save_num; + BOOL has_file; - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - GetTempLevelNames(szPerm); - if ( !pfile_open_archive(FALSE, save_num) ) - TermMsg("Unable to read to save file archive"); + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + GetTempLevelNames(szPerm); + if (!pfile_open_archive(FALSE, save_num)) + TermMsg("Unable to read to save file archive"); - has_file = mpqapi_has_file(szPerm); - pfile_flush(TRUE, save_num); - if ( !has_file ) - { - if ( setlevel ) - sprintf(szPerm, "perms%02d", (unsigned char)setlvlnum); - else - sprintf(szPerm, "perml%02d", currlevel); - } + has_file = mpqapi_has_file(szPerm); + pfile_flush(TRUE, save_num); + if (!has_file) { + if (setlevel) + sprintf(szPerm, "perms%02d", (unsigned char)setlvlnum); + else + sprintf(szPerm, "perml%02d", currlevel); + } } // 5CCB10: using guessed type char setlvlnum; // 5CF31D: using guessed type char setlevel; void __fastcall pfile_get_game_name(char *dst) { - // BUGFIX: function call with no purpose - pfile_get_save_num_from_name(plr[myplr]._pName); - strcpy(dst, "game"); + // BUGFIX: function call with no purpose + pfile_get_save_num_from_name(plr[myplr]._pName); + strcpy(dst, "game"); } void __cdecl pfile_remove_temp_files() { - if ( gbMaxPlayers <= 1 ) - { - unsigned int save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - if ( !pfile_open_archive(FALSE, save_num) ) - TermMsg("Unable to write to save file archive"); - mpqapi_remove_hash_entries(GetTempSaveNames); - pfile_flush(TRUE, save_num); - } + if (gbMaxPlayers <= 1) { + unsigned int save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + if (!pfile_open_archive(FALSE, save_num)) + TermMsg("Unable to write to save file archive"); + mpqapi_remove_hash_entries(GetTempSaveNames); + pfile_flush(TRUE, save_num); + } } BOOL __stdcall GetTempSaveNames(DWORD dwIndex, char *szTemp) { - const char *fmt; + const char *fmt; - if ( dwIndex < 17 ) - fmt = "templ%02d"; - else if ( dwIndex < 34 ) { - dwIndex -= 17; - fmt = "temps%02d"; - } else - return FALSE; + if (dwIndex < 17) + fmt = "templ%02d"; + else if (dwIndex < 34) { + dwIndex -= 17; + fmt = "temps%02d"; + } else + return FALSE; - sprintf(szTemp, fmt, dwIndex); - return TRUE; + sprintf(szTemp, fmt, dwIndex); + return TRUE; } void __cdecl pfile_rename_temp_to_perm() { - unsigned int save_num; - unsigned int i; - char TempName[MAX_PATH]; - char PermName[MAX_PATH]; - - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - if ( !pfile_open_archive(FALSE, save_num) ) - TermMsg("Unable to write to save file archive"); - - i = 0; - while (GetTempSaveNames(i,TempName)) { - GetPermSaveNames(i, PermName); - i++; - if ( mpqapi_has_file(TempName) ) { - if ( mpqapi_has_file(PermName) ) - mpqapi_remove_hash_entry(PermName); - mpqapi_rename(TempName, PermName); - } - } - GetPermSaveNames(i, PermName); - pfile_flush(TRUE, save_num); + unsigned int save_num; + unsigned int i; + char TempName[MAX_PATH]; + char PermName[MAX_PATH]; + + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + if (!pfile_open_archive(FALSE, save_num)) + TermMsg("Unable to write to save file archive"); + + i = 0; + while (GetTempSaveNames(i, TempName)) { + GetPermSaveNames(i, PermName); + i++; + if (mpqapi_has_file(TempName)) { + if (mpqapi_has_file(PermName)) + mpqapi_remove_hash_entry(PermName); + mpqapi_rename(TempName, PermName); + } + } + GetPermSaveNames(i, PermName); + pfile_flush(TRUE, save_num); } BOOL __stdcall GetPermSaveNames(DWORD dwIndex, char *szPerm) { - const char *fmt; + const char *fmt; - if ( dwIndex < 17 ) - fmt = "perml%02d"; - else if ( dwIndex < 34 ) { - dwIndex -= 17; - fmt = "perms%02d"; - } else - return FALSE; + if (dwIndex < 17) + fmt = "perml%02d"; + else if (dwIndex < 34) { + dwIndex -= 17; + fmt = "perms%02d"; + } else + return FALSE; - sprintf(szPerm, fmt, dwIndex); - return TRUE; + sprintf(szPerm, fmt, dwIndex); + return TRUE; } void __fastcall pfile_write_save_file(const char *pszName, BYTE *pbData, DWORD dwLen, DWORD qwLen) { - unsigned int save_num; - char FileName[MAX_PATH]; + unsigned int save_num; + char FileName[MAX_PATH]; - pfile_strcpy(FileName, pszName); - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - { - char password[16] = PASSWORD_SINGLE; - if ( gbMaxPlayers > 1 ) - strcpy(password, PASSWORD_MULTI); + pfile_strcpy(FileName, pszName); + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + { + char password[16] = PASSWORD_SINGLE; + if (gbMaxPlayers > 1) + strcpy(password, PASSWORD_MULTI); - codec_encode(pbData, dwLen, qwLen, password); - } - if ( !pfile_open_archive(FALSE, save_num) ) - TermMsg("Unable to write so save file archive"); - mpqapi_write_file(FileName, pbData, qwLen); - pfile_flush(TRUE, save_num); + codec_encode(pbData, dwLen, qwLen, password); + } + if (!pfile_open_archive(FALSE, save_num)) + TermMsg("Unable to write so save file archive"); + mpqapi_write_file(FileName, pbData, qwLen); + pfile_flush(TRUE, save_num); } void __fastcall pfile_strcpy(char *dst, const char *src) { - strcpy(dst, src); + strcpy(dst, src); } BYTE *__fastcall pfile_read(const char *pszName, DWORD *pdwLen) { - unsigned int save_num; - char FileName[MAX_PATH]; - HANDLE archive, save; - BYTE *buf; - DWORD nread; - - pfile_strcpy(FileName, pszName); - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - archive = pfile_open_save_archive(NULL, save_num); - if ( archive == NULL ) - TermMsg("Unable to open save file archive"); - - if ( !SFileOpenFileEx(archive, FileName, 0, &save) ) - TermMsg("Unable to open save file"); - - *pdwLen = SFileGetFileSize(save, NULL); - if ( *pdwLen == 0 ) - TermMsg("Invalid save file"); - - buf = (BYTE*)DiabloAllocPtr(*pdwLen); - if ( !SFileReadFile(save, buf, *pdwLen, &nread, NULL) ) - TermMsg("Unable to read save file"); - SFileCloseFile(save); - pfile_SFileCloseArchive(archive); - - { - char password[16] = PASSWORD_SINGLE; - DWORD nSize = 16; - - if ( gbMaxPlayers > 1 ) - strcpy(password, PASSWORD_MULTI); - - *pdwLen = codec_decode(buf, *pdwLen, password); - if (*pdwLen == 0) { - // BUGFIFX: *pdwLen has already been overwritten with zero and the savefile has been closed - // there is no way this can work correctly - if (gbMaxPlayers > 1) { - GetComputerName(password, &nSize); - if ( SFileSetFilePointer(save, 0, NULL, 0) ) - TermMsg("Unable to read save file"); - - if ( !SFileReadFile(save, buf, *pdwLen, &nread, NULL) ) - TermMsg("Unable to read save file"); - *pdwLen = codec_decode(buf, *pdwLen, password); - } - if ( *pdwLen == 0 ) - TermMsg("Invalid save file"); - } - } - return buf; + unsigned int save_num; + char FileName[MAX_PATH]; + HANDLE archive, save; + BYTE *buf; + DWORD nread; + + pfile_strcpy(FileName, pszName); + save_num = pfile_get_save_num_from_name(plr[myplr]._pName); + archive = pfile_open_save_archive(NULL, save_num); + if (archive == NULL) + TermMsg("Unable to open save file archive"); + + if (!SFileOpenFileEx(archive, FileName, 0, &save)) + TermMsg("Unable to open save file"); + + *pdwLen = SFileGetFileSize(save, NULL); + if (*pdwLen == 0) + TermMsg("Invalid save file"); + + buf = (BYTE *)DiabloAllocPtr(*pdwLen); + if (!SFileReadFile(save, buf, *pdwLen, &nread, NULL)) + TermMsg("Unable to read save file"); + SFileCloseFile(save); + pfile_SFileCloseArchive(archive); + + { + char password[16] = PASSWORD_SINGLE; + DWORD nSize = 16; + + if (gbMaxPlayers > 1) + strcpy(password, PASSWORD_MULTI); + + *pdwLen = codec_decode(buf, *pdwLen, password); + if (*pdwLen == 0) { + // BUGFIFX: *pdwLen has already been overwritten with zero and the savefile has been closed + // there is no way this can work correctly + if (gbMaxPlayers > 1) { + GetComputerName(password, &nSize); + if (SFileSetFilePointer(save, 0, NULL, 0)) + TermMsg("Unable to read save file"); + + if (!SFileReadFile(save, buf, *pdwLen, &nread, NULL)) + TermMsg("Unable to read save file"); + *pdwLen = codec_decode(buf, *pdwLen, password); + } + if (*pdwLen == 0) + TermMsg("Invalid save file"); + } + } + return buf; } void __fastcall pfile_update(BOOL force_save) { - // BUGFIX: these tick values should be treated as unsigned to handle overflows correctly - static int save_prev_tc; + // BUGFIX: these tick values should be treated as unsigned to handle overflows correctly + static int save_prev_tc; - if (gbMaxPlayers != 1) { - int tick = GetTickCount(); - if(force_save || tick - save_prev_tc > 60000) { - save_prev_tc = tick; - pfile_write_hero(); - } - } + if (gbMaxPlayers != 1) { + int tick = GetTickCount(); + if (force_save || tick - save_prev_tc > 60000) { + save_prev_tc = tick; + pfile_write_hero(); + } + } } diff --git a/Source/player.cpp b/Source/player.cpp index 6a2f05635..7daa6ff4d 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -6,17 +6,17 @@ int plr_lframe_size; // idb int plr_wframe_size; // idb UCHAR plr_gfx_flag = 0; int player_cpp_init_value; // weak -int plr_aframe_size; // idb +int plr_aframe_size; // idb int myplr; PlayerStruct plr[MAX_PLRS]; int plr_fframe_size; // idb int plr_qframe_size; // idb -BOOL deathflag; // idb +BOOL deathflag; // idb int plr_hframe_size; // idb int plr_bframe_size; // idb UCHAR plr_gfx_bflag = 0; int plr_sframe_size; // idb -int deathdelay; // weak +int deathdelay; // weak int plr_dframe_size; // idb const int player_inf = 0x7F800000; // weak @@ -30,11 +30,10 @@ int plrxoff[9] = { 0, 2, 0, 2, 1, 0, 1, 2, 1 }; int plryoff[9] = { 0, 2, 2, 0, 1, 1, 0, 1, 2 }; int plrxoff2[9] = { 0, 1, 0, 1, 2, 0, 1, 2, 2 }; int plryoff2[9] = { 0, 0, 1, 1, 0, 2, 2, 1, 2 }; -char PlrGFXAnimLens[3][11] = -{ - { 10, 16, 8, 2, 20, 20, 6, 20, 8, 9, 14 }, - { 8, 18, 8, 4, 20, 16, 7, 20, 8, 10, 12 }, - { 8, 16, 8, 6, 20, 12, 8, 20, 8, 12, 8 } +char PlrGFXAnimLens[3][11] = { + { 10, 16, 8, 2, 20, 20, 6, 20, 8, 9, 14 }, + { 8, 18, 8, 4, 20, 16, 7, 20, 8, 10, 12 }, + { 8, 16, 8, 6, 20, 12, 8, 20, 8, 12, 8 } }; int PWVel[4][3] = { { 2048, 1024, 512 }, { 2048, 1024, 512 }, { 2048, 1024, 512 }, { 8, 8, 8 } }; int StrengthTbl[3] = { 30, 20, 15 }; @@ -44,873 +43,870 @@ int VitalityTbl[3] = { 25, 20, 20 }; int ToBlkTbl[3] = { 30, 20, 10 }; char *ClassStrTblOld[3] = { "Warrior", "Rogue", "Sorceror" }; // unused int MaxStats[3][4] = { { 250, 50, 60, 100 }, { 55, 70, 250, 80 }, { 45, 250, 85, 80 } }; -int ExpLvlsTbl[51] = -{ - 0, - 2000, - 4620, - 8040, - 12489, - 18258, - 25712, - 35309, - 47622, - 63364, - 83419, - 108879, - 141086, - 181683, - 231075, - 313656, - 424067, - 571190, - 766569, - 1025154, - 1366227, - 1814568, - 2401895, - 3168651, - 4166200, - 5459523, - 7130496, - 9281874, - 12042092, - 15571031, - 20066900, - 25774405, - 32994399, - 42095202, - 53525811, - 67831218, - 85670061, - 107834823, - 135274799, - 169122009, - 210720231, - 261657253, - 323800420, - 399335440, - 490808349, - 601170414, - 733825617, - 892680222, - 1082908612, - 1310707109, - 1583495809 +int ExpLvlsTbl[51] = { + 0, + 2000, + 4620, + 8040, + 12489, + 18258, + 25712, + 35309, + 47622, + 63364, + 83419, + 108879, + 141086, + 181683, + 231075, + 313656, + 424067, + 571190, + 766569, + 1025154, + 1366227, + 1814568, + 2401895, + 3168651, + 4166200, + 5459523, + 7130496, + 9281874, + 12042092, + 15571031, + 20066900, + 25774405, + 32994399, + 42095202, + 53525811, + 67831218, + 85670061, + 107834823, + 135274799, + 169122009, + 210720231, + 261657253, + 323800420, + 399335440, + 490808349, + 601170414, + 733825617, + 892680222, + 1082908612, + 1310707109, + 1583495809 }; char *ClassStrTbl[3] = { "Warrior", "Rogue", "Sorceror" }; unsigned char fix[9] = { 0u, 0u, 3u, 3u, 3u, 6u, 6u, 6u, 8u }; /* PM_ChangeLightOff local type */ -struct player_cpp_init -{ - player_cpp_init() - { - player_cpp_init_value = player_inf; - } +struct player_cpp_init { + player_cpp_init() + { + player_cpp_init_value = player_inf; + } } _player_cpp_init; // 47F204: using guessed type int player_inf; // 68643C: using guessed type int player_cpp_init_value; void __fastcall SetPlayerGPtrs(UCHAR *pData, UCHAR **pAnim) { - for ( int i = 0; i < 8; i++ ) { - pAnim[i] = pData + ((DWORD *)pData)[i]; - } + for (int i = 0; i < 8; i++) { + pAnim[i] = pData + ((DWORD *)pData)[i]; + } } void __fastcall LoadPlrGFX(int pnum, player_graphic gfxflag) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("LoadPlrGFX: illegal player %d", pnum); - } - - char prefix[16]; - char pszName[256]; - char *szCel; - PlayerStruct *p = &plr[pnum]; - sprintf(prefix, "%c%c%c", CharChar[p->_pClass], ArmourChar[p->_pgfxnum >> 4], WepChar[p->_pgfxnum & 0xF]); - char *cs = ClassStrTbl[p->_pClass]; - UCHAR *pData; - UCHAR *pAnim; - - for (DWORD i = 1; i <= PFILE_NONDEATH; i <<= 1) { - if ( !(i & gfxflag) ) { - continue; - } - - switch ( i ) { - case PFILE_STAND: - szCel = "AS"; - if ( leveltype == DTYPE_TOWN ) { - szCel = "ST"; - } - pData = p->_pNData; - pAnim = (UCHAR *)p->_pNAnim; - break; - case PFILE_WALK: - szCel = "AW"; - if ( leveltype == DTYPE_TOWN ) { - szCel = "WL"; - } - pData = p->_pWData; - pAnim = (UCHAR *)p->_pWAnim; - break; - case PFILE_ATTACK: - if ( leveltype == DTYPE_TOWN ) { - continue; - } - szCel = "AT"; - pData = p->_pAData; - pAnim = (UCHAR *)p->_pAAnim; - break; - case PFILE_HIT: - if ( leveltype == DTYPE_TOWN ) { - continue; - } - szCel = "HT"; - pData = p->_pHData; - pAnim = (UCHAR *)p->_pHAnim; - break; - case PFILE_LIGHTNING: - if ( leveltype == DTYPE_TOWN ) { - continue; - } - szCel = "LM"; - pData = p->_pLData; - pAnim = (UCHAR *)p->_pLAnim; - break; - case PFILE_FIRE: - if ( leveltype == DTYPE_TOWN ) { - continue; - } - szCel = "FM"; - pData = p->_pFData; - pAnim = (UCHAR *)p->_pFAnim; - break; - case PFILE_MAGIC: - if ( leveltype == DTYPE_TOWN ) { - continue; - } - szCel = "QM"; - pData = p->_pTData; - pAnim = (UCHAR *)p->_pTAnim; - break; - case PFILE_DEATH: - if ( p->_pgfxnum & 0xF ) { - continue; - } - szCel = "DT"; - pData = p->_pDData; - pAnim = (UCHAR *)p->_pDAnim; - break; - case PFILE_BLOCK: - if ( leveltype == DTYPE_TOWN ) { - continue; - } - if ( !p->_pBlockFlag ) { - continue; - } - - szCel = "BL"; - pData = p->_pBData; - pAnim = (UCHAR *)p->_pBAnim; - break; - default: - TermMsg("PLR:2"); - break; - } - - sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", cs, prefix, prefix, szCel); - LoadFileWithMem(pszName, pData); - SetPlayerGPtrs((UCHAR *)pData, (UCHAR **)pAnim); - p->_pGFXLoad |= i; - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("LoadPlrGFX: illegal player %d", pnum); + } + + char prefix[16]; + char pszName[256]; + char *szCel; + PlayerStruct *p = &plr[pnum]; + sprintf(prefix, "%c%c%c", CharChar[p->_pClass], ArmourChar[p->_pgfxnum >> 4], WepChar[p->_pgfxnum & 0xF]); + char *cs = ClassStrTbl[p->_pClass]; + UCHAR *pData; + UCHAR *pAnim; + + for (DWORD i = 1; i <= PFILE_NONDEATH; i <<= 1) { + if (!(i & gfxflag)) { + continue; + } + + switch (i) { + case PFILE_STAND: + szCel = "AS"; + if (leveltype == DTYPE_TOWN) { + szCel = "ST"; + } + pData = p->_pNData; + pAnim = (UCHAR *)p->_pNAnim; + break; + case PFILE_WALK: + szCel = "AW"; + if (leveltype == DTYPE_TOWN) { + szCel = "WL"; + } + pData = p->_pWData; + pAnim = (UCHAR *)p->_pWAnim; + break; + case PFILE_ATTACK: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "AT"; + pData = p->_pAData; + pAnim = (UCHAR *)p->_pAAnim; + break; + case PFILE_HIT: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "HT"; + pData = p->_pHData; + pAnim = (UCHAR *)p->_pHAnim; + break; + case PFILE_LIGHTNING: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "LM"; + pData = p->_pLData; + pAnim = (UCHAR *)p->_pLAnim; + break; + case PFILE_FIRE: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "FM"; + pData = p->_pFData; + pAnim = (UCHAR *)p->_pFAnim; + break; + case PFILE_MAGIC: + if (leveltype == DTYPE_TOWN) { + continue; + } + szCel = "QM"; + pData = p->_pTData; + pAnim = (UCHAR *)p->_pTAnim; + break; + case PFILE_DEATH: + if (p->_pgfxnum & 0xF) { + continue; + } + szCel = "DT"; + pData = p->_pDData; + pAnim = (UCHAR *)p->_pDAnim; + break; + case PFILE_BLOCK: + if (leveltype == DTYPE_TOWN) { + continue; + } + if (!p->_pBlockFlag) { + continue; + } + + szCel = "BL"; + pData = p->_pBData; + pAnim = (UCHAR *)p->_pBAnim; + break; + default: + TermMsg("PLR:2"); + break; + } + + sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", cs, prefix, prefix, szCel); + LoadFileWithMem(pszName, pData); + SetPlayerGPtrs((UCHAR *)pData, (UCHAR **)pAnim); + p->_pGFXLoad |= i; + } } // 5BB1ED: using guessed type char leveltype; void __fastcall InitPlayerGFX(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("InitPlayerGFX: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitPlayerGFX: illegal player %d", pnum); + } - if ( plr[pnum]._pHitPoints >> 6 == 0 ) { - plr[pnum]._pgfxnum = 0; - LoadPlrGFX(pnum, PFILE_DEATH); - } else { - LoadPlrGFX(pnum, PFILE_NONDEATH); - } + if (plr[pnum]._pHitPoints >> 6 == 0) { + plr[pnum]._pgfxnum = 0; + LoadPlrGFX(pnum, PFILE_DEATH); + } else { + LoadPlrGFX(pnum, PFILE_NONDEATH); + } } void __fastcall InitPlrGFXMem(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("InitPlrGFXMem: illegal player %d", pnum); - } - - if ( !(plr_gfx_flag & 0x1) ) {//STAND - plr_gfx_flag |= 0x1; - if ( GetPlrGFXSize("ST") > GetPlrGFXSize("AS") ) { - plr_sframe_size = GetPlrGFXSize("ST");//TOWN - } else { - plr_sframe_size = GetPlrGFXSize("AS");//DUNGION - } - } - plr[pnum]._pNData = DiabloAllocPtr(plr_sframe_size); - - if ( !(plr_gfx_flag & 0x2) ) {//WALK - plr_gfx_flag |= 0x2; - if ( GetPlrGFXSize("WL") > GetPlrGFXSize("AW") ) { - plr_wframe_size = GetPlrGFXSize("WL");//TOWN - } else { - plr_wframe_size = GetPlrGFXSize("AW");//DUNGION - } - } - plr[pnum]._pWData = DiabloAllocPtr(plr_wframe_size); - - if ( !(plr_gfx_flag & 0x4) ) {//ATTACK - plr_gfx_flag |= 0x4; - plr_aframe_size = GetPlrGFXSize("AT"); - } - plr[pnum]._pAData = DiabloAllocPtr(plr_aframe_size); - - if ( !(plr_gfx_flag & 0x8) ) {//HIT - plr_gfx_flag |= 0x8; - plr_hframe_size = GetPlrGFXSize("HT"); - } - plr[pnum]._pHData = DiabloAllocPtr(plr_hframe_size); - - if ( !(plr_gfx_flag & 0x10) ) {//LIGHTNING - plr_gfx_flag |= 0x10; - plr_lframe_size = GetPlrGFXSize("LM"); - } - plr[pnum]._pLData = DiabloAllocPtr(plr_lframe_size); - - if ( !(plr_gfx_flag & 0x20) ) {//FIRE - plr_gfx_flag |= 0x20; - plr_fframe_size = GetPlrGFXSize("FM"); - } - plr[pnum]._pFData = DiabloAllocPtr(plr_fframe_size); - - if ( !(plr_gfx_flag & 0x40) ) {//MAGIC - plr_gfx_flag |= 0x40; - plr_qframe_size = GetPlrGFXSize("QM"); - } - plr[pnum]._pTData = DiabloAllocPtr(plr_qframe_size); - - if ( !(plr_gfx_flag & 0x80) ) {//DEATH - plr_gfx_flag |= 0x80; - plr_dframe_size = GetPlrGFXSize("DT"); - } - plr[pnum]._pDData = DiabloAllocPtr(plr_dframe_size); - - if ( !(plr_gfx_bflag & 0x1) ) {//BLOCK - plr_gfx_bflag |= 0x1; - plr_bframe_size = GetPlrGFXSize("BL"); - } - plr[pnum]._pBData = DiabloAllocPtr(plr_bframe_size); - - plr[pnum]._pGFXLoad = 0; + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitPlrGFXMem: illegal player %d", pnum); + } + + if (!(plr_gfx_flag & 0x1)) { //STAND + plr_gfx_flag |= 0x1; + if (GetPlrGFXSize("ST") > GetPlrGFXSize("AS")) { + plr_sframe_size = GetPlrGFXSize("ST"); //TOWN + } else { + plr_sframe_size = GetPlrGFXSize("AS"); //DUNGION + } + } + plr[pnum]._pNData = DiabloAllocPtr(plr_sframe_size); + + if (!(plr_gfx_flag & 0x2)) { //WALK + plr_gfx_flag |= 0x2; + if (GetPlrGFXSize("WL") > GetPlrGFXSize("AW")) { + plr_wframe_size = GetPlrGFXSize("WL"); //TOWN + } else { + plr_wframe_size = GetPlrGFXSize("AW"); //DUNGION + } + } + plr[pnum]._pWData = DiabloAllocPtr(plr_wframe_size); + + if (!(plr_gfx_flag & 0x4)) { //ATTACK + plr_gfx_flag |= 0x4; + plr_aframe_size = GetPlrGFXSize("AT"); + } + plr[pnum]._pAData = DiabloAllocPtr(plr_aframe_size); + + if (!(plr_gfx_flag & 0x8)) { //HIT + plr_gfx_flag |= 0x8; + plr_hframe_size = GetPlrGFXSize("HT"); + } + plr[pnum]._pHData = DiabloAllocPtr(plr_hframe_size); + + if (!(plr_gfx_flag & 0x10)) { //LIGHTNING + plr_gfx_flag |= 0x10; + plr_lframe_size = GetPlrGFXSize("LM"); + } + plr[pnum]._pLData = DiabloAllocPtr(plr_lframe_size); + + if (!(plr_gfx_flag & 0x20)) { //FIRE + plr_gfx_flag |= 0x20; + plr_fframe_size = GetPlrGFXSize("FM"); + } + plr[pnum]._pFData = DiabloAllocPtr(plr_fframe_size); + + if (!(plr_gfx_flag & 0x40)) { //MAGIC + plr_gfx_flag |= 0x40; + plr_qframe_size = GetPlrGFXSize("QM"); + } + plr[pnum]._pTData = DiabloAllocPtr(plr_qframe_size); + + if (!(plr_gfx_flag & 0x80)) { //DEATH + plr_gfx_flag |= 0x80; + plr_dframe_size = GetPlrGFXSize("DT"); + } + plr[pnum]._pDData = DiabloAllocPtr(plr_dframe_size); + + if (!(plr_gfx_bflag & 0x1)) { //BLOCK + plr_gfx_bflag |= 0x1; + plr_bframe_size = GetPlrGFXSize("BL"); + } + plr[pnum]._pBData = DiabloAllocPtr(plr_bframe_size); + + plr[pnum]._pGFXLoad = 0; } // 686438: using guessed type char plr_gfx_flag; // 69B7BC: using guessed type char plr_gfx_bflag; DWORD __fastcall GetPlrGFXSize(char *szCel) { - char prefix[16]; - char pszName[256]; - void *file; - DWORD size = 0; - DWORD result = 0; - int a = 0; - int w = 0; - - for (int c = 0; c < sizeof(ClassStrTbl) / sizeof(ClassStrTbl[0]); c++) { - for (a = 0; ArmourChar[a]; a++) { - for (w = 0; WepChar[w]; w++) { - sprintf(prefix, "%c%c%c", CharChar[c], ArmourChar[a], WepChar[w]); - sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassStrTbl[c], prefix, prefix, szCel); - if ( WOpenFile(pszName, &file, TRUE) ) { - size = WGetFileSize(file, 0); - WCloseFile(file); - if ( result <= size ) { - result = size; - } - } - } - } - } - - return result; + char prefix[16]; + char pszName[256]; + void *file; + DWORD size = 0; + DWORD result = 0; + int a = 0; + int w = 0; + + for (int c = 0; c < sizeof(ClassStrTbl) / sizeof(ClassStrTbl[0]); c++) { + for (a = 0; ArmourChar[a]; a++) { + for (w = 0; WepChar[w]; w++) { + sprintf(prefix, "%c%c%c", CharChar[c], ArmourChar[a], WepChar[w]); + sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", ClassStrTbl[c], prefix, prefix, szCel); + if (WOpenFile(pszName, &file, TRUE)) { + size = WGetFileSize(file, 0); + WCloseFile(file); + if (result <= size) { + result = size; + } + } + } + } + } + + return result; } void __fastcall FreePlayerGFX(int pnum) { - void *ptr; - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("FreePlayerGFX: illegal player %d", pnum); - } - - ptr = plr[pnum]._pNData; - plr[pnum]._pNData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pWData; - plr[pnum]._pWData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pAData; - plr[pnum]._pAData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pHData; - plr[pnum]._pHData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pLData; - plr[pnum]._pLData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pFData; - plr[pnum]._pFData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pTData; - plr[pnum]._pTData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pDData; - plr[pnum]._pDData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pBData; - plr[pnum]._pBData = NULL; - mem_free_dbg(ptr); - plr[pnum]._pGFXLoad = 0; + void *ptr; + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("FreePlayerGFX: illegal player %d", pnum); + } + + ptr = plr[pnum]._pNData; + plr[pnum]._pNData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pWData; + plr[pnum]._pWData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pAData; + plr[pnum]._pAData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pHData; + plr[pnum]._pHData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pLData; + plr[pnum]._pLData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pFData; + plr[pnum]._pFData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pTData; + plr[pnum]._pTData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pDData; + plr[pnum]._pDData = NULL; + mem_free_dbg(ptr); + ptr = plr[pnum]._pBData; + plr[pnum]._pBData = NULL; + mem_free_dbg(ptr); + plr[pnum]._pGFXLoad = 0; } void __fastcall NewPlrAnim(int pnum, unsigned char *Peq, int numFrames, int Delay, int width) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("NewPlrAnim: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("NewPlrAnim: illegal player %d", pnum); + } - plr[pnum]._pAnimData = Peq; - plr[pnum]._pAnimLen = numFrames; - plr[pnum]._pAnimFrame = 1; - plr[pnum]._pAnimCnt = 0; - plr[pnum]._pAnimDelay = Delay; - plr[pnum]._pAnimWidth = width; - plr[pnum]._pAnimWidth2 = (width - 64) >> 1; + plr[pnum]._pAnimData = Peq; + plr[pnum]._pAnimLen = numFrames; + plr[pnum]._pAnimFrame = 1; + plr[pnum]._pAnimCnt = 0; + plr[pnum]._pAnimDelay = Delay; + plr[pnum]._pAnimWidth = width; + plr[pnum]._pAnimWidth2 = (width - 64) >> 1; } void __fastcall ClearPlrPVars(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("ClearPlrPVars: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ClearPlrPVars: illegal player %d", pnum); + } - plr[pnum]._pVar1 = 0; - plr[pnum]._pVar2 = 0; - plr[pnum]._pVar3 = 0; - plr[pnum]._pVar4 = 0; - plr[pnum]._pVar5 = 0; - plr[pnum]._pVar6 = 0; - plr[pnum]._pVar7 = 0; - plr[pnum]._pVar8 = 0; + plr[pnum]._pVar1 = 0; + plr[pnum]._pVar2 = 0; + plr[pnum]._pVar3 = 0; + plr[pnum]._pVar4 = 0; + plr[pnum]._pVar5 = 0; + plr[pnum]._pVar6 = 0; + plr[pnum]._pVar7 = 0; + plr[pnum]._pVar8 = 0; } void __fastcall SetPlrAnims(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("SetPlrAnims: illegal player %d", pnum); - } - - int pc = plr[pnum]._pClass; - - plr[pnum]._pNWidth = 96; - plr[pnum]._pWWidth = 96; - plr[pnum]._pAWidth = 128; - plr[pnum]._pHWidth = 96; - plr[pnum]._pSWidth = 96; - plr[pnum]._pDWidth = 128; - plr[pnum]._pBWidth = 96; - - if ( leveltype == DTYPE_TOWN ) { - plr[pnum]._pNFrames = PlrGFXAnimLens[pc][7]; - plr[pnum]._pWFrames = PlrGFXAnimLens[pc][8]; - plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; - plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; - } else { - plr[pnum]._pNFrames = PlrGFXAnimLens[pc][0]; - plr[pnum]._pWFrames = PlrGFXAnimLens[pc][2]; - plr[pnum]._pAFrames = PlrGFXAnimLens[pc][1]; - plr[pnum]._pHFrames = PlrGFXAnimLens[pc][6]; - plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; - plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; - plr[pnum]._pBFrames = PlrGFXAnimLens[pc][3]; - plr[pnum]._pAFNum = PlrGFXAnimLens[pc][9]; - - } - plr[pnum]._pSFNum = PlrGFXAnimLens[pc][10]; - - int gn = plr[pnum]._pgfxnum & 0xF; - if ( pc == PC_WARRIOR ) { - if ( gn == 4 ) { - if ( leveltype != DTYPE_TOWN ) { - plr[pnum]._pNFrames = 8; - } - plr[pnum]._pAWidth = 96; - plr[pnum]._pAFNum = 11; - } else if ( gn == 5 ) { - plr[pnum]._pAFrames = 20; - plr[pnum]._pAFNum = 10; - } else if ( gn == 8 ) { - plr[pnum]._pAFrames = 16; - plr[pnum]._pAFNum = 11; - } - } else if ( pc == PC_ROGUE ) { - if ( gn == 5 ) { - plr[pnum]._pAFrames = 22; - plr[pnum]._pAFNum = 13; - } else if ( gn == 4 ) { - plr[pnum]._pAFrames = 12; - plr[pnum]._pAFNum = 7; - } else if ( gn == 8 ) { - plr[pnum]._pAFrames = 16; - plr[pnum]._pAFNum = 11; - } - } else if ( pc == PC_SORCERER ) { - plr[pnum]._pSWidth = 128; - if ( gn == 0 ) { - plr[pnum]._pAFrames = 20; - } else if ( gn == 1 ) { - plr[pnum]._pAFNum = 9; - } else if ( gn == 4 ) { - plr[pnum]._pAFrames = 20; - plr[pnum]._pAFNum = 16; - } else if ( gn == 5 ) { - plr[pnum]._pAFrames = 24; - plr[pnum]._pAFNum = 16; - } - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrAnims: illegal player %d", pnum); + } + + int pc = plr[pnum]._pClass; + + plr[pnum]._pNWidth = 96; + plr[pnum]._pWWidth = 96; + plr[pnum]._pAWidth = 128; + plr[pnum]._pHWidth = 96; + plr[pnum]._pSWidth = 96; + plr[pnum]._pDWidth = 128; + plr[pnum]._pBWidth = 96; + + if (leveltype == DTYPE_TOWN) { + plr[pnum]._pNFrames = PlrGFXAnimLens[pc][7]; + plr[pnum]._pWFrames = PlrGFXAnimLens[pc][8]; + plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; + plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; + } else { + plr[pnum]._pNFrames = PlrGFXAnimLens[pc][0]; + plr[pnum]._pWFrames = PlrGFXAnimLens[pc][2]; + plr[pnum]._pAFrames = PlrGFXAnimLens[pc][1]; + plr[pnum]._pHFrames = PlrGFXAnimLens[pc][6]; + plr[pnum]._pSFrames = PlrGFXAnimLens[pc][5]; + plr[pnum]._pDFrames = PlrGFXAnimLens[pc][4]; + plr[pnum]._pBFrames = PlrGFXAnimLens[pc][3]; + plr[pnum]._pAFNum = PlrGFXAnimLens[pc][9]; + } + plr[pnum]._pSFNum = PlrGFXAnimLens[pc][10]; + + int gn = plr[pnum]._pgfxnum & 0xF; + if (pc == PC_WARRIOR) { + if (gn == 4) { + if (leveltype != DTYPE_TOWN) { + plr[pnum]._pNFrames = 8; + } + plr[pnum]._pAWidth = 96; + plr[pnum]._pAFNum = 11; + } else if (gn == 5) { + plr[pnum]._pAFrames = 20; + plr[pnum]._pAFNum = 10; + } else if (gn == 8) { + plr[pnum]._pAFrames = 16; + plr[pnum]._pAFNum = 11; + } + } else if (pc == PC_ROGUE) { + if (gn == 5) { + plr[pnum]._pAFrames = 22; + plr[pnum]._pAFNum = 13; + } else if (gn == 4) { + plr[pnum]._pAFrames = 12; + plr[pnum]._pAFNum = 7; + } else if (gn == 8) { + plr[pnum]._pAFrames = 16; + plr[pnum]._pAFNum = 11; + } + } else if (pc == PC_SORCERER) { + plr[pnum]._pSWidth = 128; + if (gn == 0) { + plr[pnum]._pAFrames = 20; + } else if (gn == 1) { + plr[pnum]._pAFNum = 9; + } else if (gn == 4) { + plr[pnum]._pAFrames = 20; + plr[pnum]._pAFNum = 16; + } else if (gn == 5) { + plr[pnum]._pAFrames = 24; + plr[pnum]._pAFNum = 16; + } + } } // 5BB1ED: using guessed type char leveltype; void __fastcall ClearPlrRVars(PlayerStruct *p) { - // TODO: Missing debug assert p != NULL - p->bReserved[0] = 0; - p->bReserved[1] = 0; - p->bReserved[2] = 0; - p->wReserved[0] = 0; - p->wReserved[1] = 0; - p->wReserved[2] = 0; - p->wReserved[3] = 0; - p->wReserved[4] = 0; - p->wReserved[5] = 0; - p->wReserved[6] = 0; - p->wReserved[7] = 0; - p->dwReserved[0] = 0; - p->dwReserved[1] = 0; - p->dwReserved[2] = 0; - p->dwReserved[3] = 0; - p->dwReserved[4] = 0; - p->dwReserved[5] = 0; - p->dwReserved[6] = 0; + // TODO: Missing debug assert p != NULL + p->bReserved[0] = 0; + p->bReserved[1] = 0; + p->bReserved[2] = 0; + p->wReserved[0] = 0; + p->wReserved[1] = 0; + p->wReserved[2] = 0; + p->wReserved[3] = 0; + p->wReserved[4] = 0; + p->wReserved[5] = 0; + p->wReserved[6] = 0; + p->wReserved[7] = 0; + p->dwReserved[0] = 0; + p->dwReserved[1] = 0; + p->dwReserved[2] = 0; + p->dwReserved[3] = 0; + p->dwReserved[4] = 0; + p->dwReserved[5] = 0; + p->dwReserved[6] = 0; } // c: plr_classes value void __fastcall CreatePlayer(int pnum, char c) { - ClearPlrRVars(&plr[pnum]); - SetRndSeed(GetTickCount()); - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("CreatePlayer: illegal player %d", pnum); - } - plr[pnum]._pClass = c; - - char val = StrengthTbl[c]; - if ( val < 0 ) { - val = 0; - } - plr[pnum]._pStrength = val; - plr[pnum]._pBaseStr = val; - - val = MagicTbl[c]; - if ( val < 0 ) { - val = 0; - } - plr[pnum]._pMagic = val; - plr[pnum]._pBaseMag = val; - - val = DexterityTbl[c]; - if ( val < 0 ) { - val = 0; - } - plr[pnum]._pDexterity = val; - plr[pnum]._pBaseDex = val; - - val = VitalityTbl[c]; - if ( val < 0 ) { - val = 0; - } - plr[pnum]._pVitality = val; - plr[pnum]._pBaseVit = val; - - plr[pnum]._pStatPts = 0; - plr[pnum].pTownWarps = 0; - plr[pnum].pDungMsgs = 0; - plr[pnum].pLvlLoad = 0; - plr[pnum].pDiabloKillLevel = 0; - - if ( c == PC_ROGUE ) { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; - } else { - plr[pnum]._pDamageMod = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; - } - - plr[pnum]._pBaseToBlk = ToBlkTbl[c]; - - - plr[pnum]._pHitPoints = (val + 10) << 6; - if ( c == PC_WARRIOR ) { - plr[pnum]._pHitPoints *= 2; - } - if ( c == PC_ROGUE ) { - plr[pnum]._pHitPoints += plr[pnum]._pHitPoints >> 1; - } - - int hp = plr[pnum]._pHitPoints; - plr[pnum]._pMaxHP = hp; - plr[pnum]._pHPBase = hp; - plr[pnum]._pMaxHPBase = hp; - - plr[pnum]._pMana = plr[pnum]._pMagic << 6; - if ( c == PC_SORCERER ) { - plr[pnum]._pMana *= 2; - } - if ( c == PC_ROGUE ) { - plr[pnum]._pMana += plr[pnum]._pMana >> 1; - } - - int mana = plr[pnum]._pMana; - plr[pnum]._pMaxMana = mana; - plr[pnum]._pManaBase = mana; - plr[pnum]._pMaxManaBase = mana; - - plr[pnum]._pLevel = 1; - plr[pnum]._pMaxLvl = 1; - plr[pnum]._pExperience = 0; - plr[pnum]._pMaxExp = 0; - plr[pnum]._pNextExper = ExpLvlsTbl[1]; - plr[pnum]._pArmorClass = 0; - plr[pnum]._pMagResist = 0; - plr[pnum]._pFireResist = 0; - plr[pnum]._pLghtResist = 0; - plr[pnum]._pLightRad = 10; - plr[pnum]._pInfraFlag = 0; - - if ( c == PC_WARRIOR ) { - plr[pnum]._pAblSpells64 = (__int64)1 << (SPL_REPAIR - 1); - } else if ( c == PC_ROGUE ) { - plr[pnum]._pAblSpells64 = (__int64)1 << (SPL_DISARM - 1); - } else if ( c == PC_SORCERER ) { - plr[pnum]._pAblSpells64 = (__int64)1 << (SPL_RECHARGE - 1); - } - - if ( c == PC_SORCERER) { - plr[pnum]._pMemSpells64 = 1; - } else { - plr[pnum]._pMemSpells64 = 0; - } - - int i; - for ( i = 0; i < sizeof(plr[pnum]._pSplLvl); i++ ) { - plr[pnum]._pSplLvl[i] = 0; - } - - plr[pnum]._pSpellFlags = 0; - - if ( plr[pnum]._pClass == PC_SORCERER ) { - plr[pnum]._pSplLvl[1] = 2; - } - - // interestingly, only the first three hotkeys are reset - // TODO: BUGFIX: clear all 4 hotkeys instead of 3 (demo leftover) - for ( i = 0; i < 3; i++ ) { - plr[pnum]._pSplHotKey[i] = -1; - } - - if ( c == PC_WARRIOR ) { - plr[pnum]._pgfxnum = 3; - } else if ( c == PC_ROGUE ) { - plr[pnum]._pgfxnum = 4; - } else if ( c == PC_SORCERER ) { - plr[pnum]._pgfxnum = 8; - } - - for ( i = 0; i < sizeof(plr[pnum]._pLvlVisited); i++ ) { - plr[pnum]._pLvlVisited[i] = 0; - } - - for ( i = 0; i < 10; i++ ) { - plr[pnum]._pSLvlVisited[i] = 0; // TODO double check size of _pSLvlVisited - } - - plr[pnum]._pLvlChanging = 0; - plr[pnum].pTownWarps = 0; - plr[pnum].pLvlLoad = 0; - plr[pnum].pBattleNet = 0; - plr[pnum].pManaShield = 0; - - InitDungMsgs(pnum); - CreatePlrItems(pnum); - SetRndSeed(0); + ClearPlrRVars(&plr[pnum]); + SetRndSeed(GetTickCount()); + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("CreatePlayer: illegal player %d", pnum); + } + plr[pnum]._pClass = c; + + char val = StrengthTbl[c]; + if (val < 0) { + val = 0; + } + plr[pnum]._pStrength = val; + plr[pnum]._pBaseStr = val; + + val = MagicTbl[c]; + if (val < 0) { + val = 0; + } + plr[pnum]._pMagic = val; + plr[pnum]._pBaseMag = val; + + val = DexterityTbl[c]; + if (val < 0) { + val = 0; + } + plr[pnum]._pDexterity = val; + plr[pnum]._pBaseDex = val; + + val = VitalityTbl[c]; + if (val < 0) { + val = 0; + } + plr[pnum]._pVitality = val; + plr[pnum]._pBaseVit = val; + + plr[pnum]._pStatPts = 0; + plr[pnum].pTownWarps = 0; + plr[pnum].pDungMsgs = 0; + plr[pnum].pLvlLoad = 0; + plr[pnum].pDiabloKillLevel = 0; + + if (c == PC_ROGUE) { + plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + } else { + plr[pnum]._pDamageMod = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; + } + + plr[pnum]._pBaseToBlk = ToBlkTbl[c]; + + plr[pnum]._pHitPoints = (val + 10) << 6; + if (c == PC_WARRIOR) { + plr[pnum]._pHitPoints *= 2; + } + if (c == PC_ROGUE) { + plr[pnum]._pHitPoints += plr[pnum]._pHitPoints >> 1; + } + + int hp = plr[pnum]._pHitPoints; + plr[pnum]._pMaxHP = hp; + plr[pnum]._pHPBase = hp; + plr[pnum]._pMaxHPBase = hp; + + plr[pnum]._pMana = plr[pnum]._pMagic << 6; + if (c == PC_SORCERER) { + plr[pnum]._pMana *= 2; + } + if (c == PC_ROGUE) { + plr[pnum]._pMana += plr[pnum]._pMana >> 1; + } + + int mana = plr[pnum]._pMana; + plr[pnum]._pMaxMana = mana; + plr[pnum]._pManaBase = mana; + plr[pnum]._pMaxManaBase = mana; + + plr[pnum]._pLevel = 1; + plr[pnum]._pMaxLvl = 1; + plr[pnum]._pExperience = 0; + plr[pnum]._pMaxExp = 0; + plr[pnum]._pNextExper = ExpLvlsTbl[1]; + plr[pnum]._pArmorClass = 0; + plr[pnum]._pMagResist = 0; + plr[pnum]._pFireResist = 0; + plr[pnum]._pLghtResist = 0; + plr[pnum]._pLightRad = 10; + plr[pnum]._pInfraFlag = 0; + + if (c == PC_WARRIOR) { + plr[pnum]._pAblSpells64 = (__int64)1 << (SPL_REPAIR - 1); + } else if (c == PC_ROGUE) { + plr[pnum]._pAblSpells64 = (__int64)1 << (SPL_DISARM - 1); + } else if (c == PC_SORCERER) { + plr[pnum]._pAblSpells64 = (__int64)1 << (SPL_RECHARGE - 1); + } + + if (c == PC_SORCERER) { + plr[pnum]._pMemSpells64 = 1; + } else { + plr[pnum]._pMemSpells64 = 0; + } + + int i; + for (i = 0; i < sizeof(plr[pnum]._pSplLvl); i++) { + plr[pnum]._pSplLvl[i] = 0; + } + + plr[pnum]._pSpellFlags = 0; + + if (plr[pnum]._pClass == PC_SORCERER) { + plr[pnum]._pSplLvl[1] = 2; + } + + // interestingly, only the first three hotkeys are reset + // TODO: BUGFIX: clear all 4 hotkeys instead of 3 (demo leftover) + for (i = 0; i < 3; i++) { + plr[pnum]._pSplHotKey[i] = -1; + } + + if (c == PC_WARRIOR) { + plr[pnum]._pgfxnum = 3; + } else if (c == PC_ROGUE) { + plr[pnum]._pgfxnum = 4; + } else if (c == PC_SORCERER) { + plr[pnum]._pgfxnum = 8; + } + + for (i = 0; i < sizeof(plr[pnum]._pLvlVisited); i++) { + plr[pnum]._pLvlVisited[i] = 0; + } + + for (i = 0; i < 10; i++) { + plr[pnum]._pSLvlVisited[i] = 0; // TODO double check size of _pSLvlVisited + } + + plr[pnum]._pLvlChanging = 0; + plr[pnum].pTownWarps = 0; + plr[pnum].pLvlLoad = 0; + plr[pnum].pBattleNet = 0; + plr[pnum].pManaShield = 0; + + InitDungMsgs(pnum); + CreatePlrItems(pnum); + SetRndSeed(0); } int __fastcall CalcStatDiff(int pnum) { - int c = plr[pnum]._pClass; - return MaxStats[c][ATTRIB_STR] - - plr[pnum]._pBaseStr - + MaxStats[c][ATTRIB_MAG] - - plr[pnum]._pBaseMag - + MaxStats[c][ATTRIB_DEX] - - plr[pnum]._pBaseDex - + MaxStats[c][ATTRIB_VIT] - - plr[pnum]._pBaseVit; + int c = plr[pnum]._pClass; + return MaxStats[c][ATTRIB_STR] + - plr[pnum]._pBaseStr + + MaxStats[c][ATTRIB_MAG] + - plr[pnum]._pBaseMag + + MaxStats[c][ATTRIB_DEX] + - plr[pnum]._pBaseDex + + MaxStats[c][ATTRIB_VIT] + - plr[pnum]._pBaseVit; } void __fastcall NextPlrLevel(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("NextPlrLevel: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("NextPlrLevel: illegal player %d", pnum); + } - plr[pnum]._pLevel++; - char l = plr[pnum]._pLevel; + plr[pnum]._pLevel++; + char l = plr[pnum]._pLevel; - plr[pnum]._pMaxLvl++; + plr[pnum]._pMaxLvl++; - if ( CalcStatDiff(pnum) < 5 ) { - plr[pnum]._pStatPts = CalcStatDiff(pnum); - } else { - plr[pnum]._pStatPts += 5; - } + if (CalcStatDiff(pnum) < 5) { + plr[pnum]._pStatPts = CalcStatDiff(pnum); + } else { + plr[pnum]._pStatPts += 5; + } - plr[pnum]._pNextExper = ExpLvlsTbl[l]; + plr[pnum]._pNextExper = ExpLvlsTbl[l]; - char c = plr[pnum]._pClass; + char c = plr[pnum]._pClass; - int hp = c == PC_SORCERER ? 64 : 128; - if ( gbMaxPlayers == 1 ) { - hp++; - } - plr[pnum]._pMaxHP += hp; - plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; - plr[pnum]._pMaxHPBase += hp; - plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; + int hp = c == PC_SORCERER ? 64 : 128; + if (gbMaxPlayers == 1) { + hp++; + } + plr[pnum]._pMaxHP += hp; + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; + plr[pnum]._pMaxHPBase += hp; + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; - if ( pnum == myplr ) { - drawhpflag = TRUE; - } + if (pnum == myplr) { + drawhpflag = TRUE; + } - int mana = c != PC_WARRIOR ? 128 : 64; - if ( gbMaxPlayers == 1 ) { - mana++; - } - plr[pnum]._pMaxMana += mana; - plr[pnum]._pMaxManaBase += mana; + int mana = c != PC_WARRIOR ? 128 : 64; + if (gbMaxPlayers == 1) { + mana++; + } + plr[pnum]._pMaxMana += mana; + plr[pnum]._pMaxManaBase += mana; - if ( !(plr[pnum]._pIFlags & ISPL_NOMANA) ) { - plr[pnum]._pMana = plr[pnum]._pMaxMana; - plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; - } + if (!(plr[pnum]._pIFlags & ISPL_NOMANA)) { + plr[pnum]._pMana = plr[pnum]._pMaxMana; + plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; + } - if ( pnum == myplr ) { - drawmanaflag = TRUE; - } + if (pnum == myplr) { + drawmanaflag = TRUE; + } } // 679660: using guessed type char gbMaxPlayers; void __fastcall AddPlrExperience(int pnum, int lvl, int exp) { - if ( pnum != myplr ) { - return; - } - - if ( (DWORD)myplr >= MAX_PLRS ) { - TermMsg("AddPlrExperience: illegal player %d", myplr); - } - - if ( plr[myplr]._pHitPoints <= 0 ) { - return; - } - - // Adjust xp based on difference in level between player and monster - exp *= 1 + ((double)lvl - plr[pnum]._pLevel) / 10; - if ( exp < 0 ) { - exp = 0; - } - - // Prevent power leveling - if ( gbMaxPlayers > 1 ) { - int powerLvlCap = plr[pnum]._pLevel < 0 ? 0 : plr[pnum]._pLevel; - if ( powerLvlCap >= 50 ) { - powerLvlCap = 50; - } - // cap to 1/20 of current levels xp - if ( exp >= ExpLvlsTbl[powerLvlCap] / 20 ) { - exp = ExpLvlsTbl[powerLvlCap] / 20; - } - // cap to 200 * current level - int expCap = 200 * powerLvlCap; - if ( exp >= expCap ) { - exp = expCap; - } - } - - plr[pnum]._pExperience += exp; - if ( (DWORD)plr[pnum]._pExperience > MAXEXP ) { - plr[pnum]._pExperience = MAXEXP; - } - - if ( plr[pnum]._pExperience >= ExpLvlsTbl[49] ) { - plr[pnum]._pLevel = 50; - return; - } - - // Increase player level if applicable - int newLvl = 0; - while ( plr[pnum]._pExperience >= ExpLvlsTbl[newLvl] ) { - newLvl++; - } - if ( newLvl != plr[pnum]._pLevel ) { - for ( int i = newLvl - plr[pnum]._pLevel; i > 0; i--) { - NextPlrLevel(pnum); - } - } - - NetSendCmdParam1(FALSE, CMD_PLRLEVEL, plr[myplr]._pLevel); + if (pnum != myplr) { + return; + } + + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("AddPlrExperience: illegal player %d", myplr); + } + + if (plr[myplr]._pHitPoints <= 0) { + return; + } + + // Adjust xp based on difference in level between player and monster + exp *= 1 + ((double)lvl - plr[pnum]._pLevel) / 10; + if (exp < 0) { + exp = 0; + } + + // Prevent power leveling + if (gbMaxPlayers > 1) { + int powerLvlCap = plr[pnum]._pLevel < 0 ? 0 : plr[pnum]._pLevel; + if (powerLvlCap >= 50) { + powerLvlCap = 50; + } + // cap to 1/20 of current levels xp + if (exp >= ExpLvlsTbl[powerLvlCap] / 20) { + exp = ExpLvlsTbl[powerLvlCap] / 20; + } + // cap to 200 * current level + int expCap = 200 * powerLvlCap; + if (exp >= expCap) { + exp = expCap; + } + } + + plr[pnum]._pExperience += exp; + if ((DWORD)plr[pnum]._pExperience > MAXEXP) { + plr[pnum]._pExperience = MAXEXP; + } + + if (plr[pnum]._pExperience >= ExpLvlsTbl[49]) { + plr[pnum]._pLevel = 50; + return; + } + + // Increase player level if applicable + int newLvl = 0; + while (plr[pnum]._pExperience >= ExpLvlsTbl[newLvl]) { + newLvl++; + } + if (newLvl != plr[pnum]._pLevel) { + for (int i = newLvl - plr[pnum]._pLevel; i > 0; i--) { + NextPlrLevel(pnum); + } + } + + NetSendCmdParam1(FALSE, CMD_PLRLEVEL, plr[myplr]._pLevel); } // 679660: using guessed type char gbMaxPlayers; void __fastcall AddPlrMonstExper(int lvl, int exp, char pmask) { - int totplrs = 0; - for (int i = 0; i < MAX_PLRS; i++ ) { - if ( (1 << i) & pmask ) { - totplrs++; - } - } + int totplrs = 0; + for (int i = 0; i < MAX_PLRS; i++) { + if ((1 << i) & pmask) { + totplrs++; + } + } - if ( totplrs && (1 << myplr) & pmask ) { - AddPlrExperience(myplr, lvl, exp / totplrs); - } + if (totplrs && (1 << myplr) & pmask) { + AddPlrExperience(myplr, lvl, exp / totplrs); + } } void __fastcall InitPlayer(int pnum, BOOL FirstTime) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("InitPlayer: illegal player %d", pnum); - } - - ClearPlrRVars(&plr[pnum]); - - if ( FirstTime ) { - plr[pnum]._pRSpell = SPL_INVALID; - plr[pnum]._pSBkSpell = SPL_INVALID; - plr[pnum]._pSpell = SPL_INVALID; - plr[pnum]._pRSplType = RSPLTYPE_INVALID; - plr[pnum]._pSplType = RSPLTYPE_INVALID; - if ((plr[pnum]._pgfxnum & 0xF) == 4) { - plr[pnum]._pwtype = TRUE; - } else { - plr[pnum]._pwtype = FALSE; - } - plr[pnum].pManaShield = 0; - } - - if ( plr[pnum].plrlevel == currlevel || leveldebug ) { - - SetPlrAnims(pnum); - - plr[pnum]._pxoff = 0; - plr[pnum]._pyoff = 0; - plr[pnum]._pxvel = 0; - plr[pnum]._pyvel = 0; - - ClearPlrPVars(pnum); - - if ( plr[pnum]._pHitPoints >> 6 > 0 ) { - plr[pnum]._pmode = PM_STAND; - NewPlrAnim(pnum, plr[pnum]._pNAnim[0], plr[pnum]._pNFrames, 3, plr[pnum]._pNWidth); - plr[pnum]._pAnimFrame = random(2, plr[pnum]._pNFrames - 1) + 1; - plr[pnum]._pAnimCnt = random(2, 3); - } else { - plr[pnum]._pmode = PM_DEATH; - NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth); - plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1; - plr[pnum]._pVar8 = 2 * plr[pnum]._pAnimLen; - } - - plr[pnum]._pdir = 0; - plr[pnum]._peflag = 0; - - if ( pnum == myplr ) { - if ( !FirstTime || currlevel != 0 ) { - plr[pnum].WorldX = ViewX; - plr[pnum].WorldY = ViewY; - } - plr[pnum]._ptargx = plr[pnum].WorldX; - plr[pnum]._ptargy = plr[pnum].WorldY; - } else { - plr[pnum]._ptargx = plr[pnum].WorldX; - plr[pnum]._ptargy = plr[pnum].WorldY; - DWORD i; - for ( i = 0; i < 8 && !PosOkPlayer(pnum, plrxoff2[i] + plr[pnum].WorldX, plryoff2[i] + plr[pnum].WorldY); ++i ); - plr[pnum].WorldX += plrxoff2[i]; - plr[pnum].WorldY += plryoff2[i]; - } - - plr[pnum]._px = plr[pnum].WorldX; - plr[pnum]._py = plr[pnum].WorldY; - plr[pnum].walkpath[0] = WALK_NONE; - plr[pnum].destAction = ACTION_NONE; - - if ( pnum == myplr ) { - plr[pnum]._plid = AddLight(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad); - } else { - plr[pnum]._plid = WALK_NONE; - } - plr[pnum]._pvid = AddVision(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad, pnum == myplr); - } - - if ( plr[pnum]._pClass == PC_WARRIOR ) { - plr[pnum]._pAblSpells64 = 1 << (SPL_REPAIR - 1); - } else if ( plr[pnum]._pClass == PC_ROGUE ) { - plr[pnum]._pAblSpells64 = 1 << (SPL_DISARM - 1); - } else if ( plr[pnum]._pClass == PC_SORCERER ) { - plr[pnum]._pAblSpells64 = 1 << (SPL_RECHARGE - 1); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitPlayer: illegal player %d", pnum); + } + + ClearPlrRVars(&plr[pnum]); + + if (FirstTime) { + plr[pnum]._pRSpell = SPL_INVALID; + plr[pnum]._pSBkSpell = SPL_INVALID; + plr[pnum]._pSpell = SPL_INVALID; + plr[pnum]._pRSplType = RSPLTYPE_INVALID; + plr[pnum]._pSplType = RSPLTYPE_INVALID; + if ((plr[pnum]._pgfxnum & 0xF) == 4) { + plr[pnum]._pwtype = TRUE; + } else { + plr[pnum]._pwtype = FALSE; + } + plr[pnum].pManaShield = 0; + } + + if (plr[pnum].plrlevel == currlevel || leveldebug) { + + SetPlrAnims(pnum); + + plr[pnum]._pxoff = 0; + plr[pnum]._pyoff = 0; + plr[pnum]._pxvel = 0; + plr[pnum]._pyvel = 0; + + ClearPlrPVars(pnum); + + if (plr[pnum]._pHitPoints >> 6 > 0) { + plr[pnum]._pmode = PM_STAND; + NewPlrAnim(pnum, plr[pnum]._pNAnim[0], plr[pnum]._pNFrames, 3, plr[pnum]._pNWidth); + plr[pnum]._pAnimFrame = random(2, plr[pnum]._pNFrames - 1) + 1; + plr[pnum]._pAnimCnt = random(2, 3); + } else { + plr[pnum]._pmode = PM_DEATH; + NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth); + plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1; + plr[pnum]._pVar8 = 2 * plr[pnum]._pAnimLen; + } + + plr[pnum]._pdir = 0; + plr[pnum]._peflag = 0; + + if (pnum == myplr) { + if (!FirstTime || currlevel != 0) { + plr[pnum].WorldX = ViewX; + plr[pnum].WorldY = ViewY; + } + plr[pnum]._ptargx = plr[pnum].WorldX; + plr[pnum]._ptargy = plr[pnum].WorldY; + } else { + plr[pnum]._ptargx = plr[pnum].WorldX; + plr[pnum]._ptargy = plr[pnum].WorldY; + DWORD i; + for (i = 0; i < 8 && !PosOkPlayer(pnum, plrxoff2[i] + plr[pnum].WorldX, plryoff2[i] + plr[pnum].WorldY); ++i) + ; + plr[pnum].WorldX += plrxoff2[i]; + plr[pnum].WorldY += plryoff2[i]; + } + + plr[pnum]._px = plr[pnum].WorldX; + plr[pnum]._py = plr[pnum].WorldY; + plr[pnum].walkpath[0] = WALK_NONE; + plr[pnum].destAction = ACTION_NONE; + + if (pnum == myplr) { + plr[pnum]._plid = AddLight(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad); + } else { + plr[pnum]._plid = WALK_NONE; + } + plr[pnum]._pvid = AddVision(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad, pnum == myplr); + } + + if (plr[pnum]._pClass == PC_WARRIOR) { + plr[pnum]._pAblSpells64 = 1 << (SPL_REPAIR - 1); + } else if (plr[pnum]._pClass == PC_ROGUE) { + plr[pnum]._pAblSpells64 = 1 << (SPL_DISARM - 1); + } else if (plr[pnum]._pClass == PC_SORCERER) { + plr[pnum]._pAblSpells64 = 1 << (SPL_RECHARGE - 1); + } #ifdef _DEBUG - if ( debug_mode_dollar_sign && FirstTime ) { - plr[pnum]._pMemSpells64 |= 1 << (SPL_TELEPORT - 1); - if ( !plr[myplr]._pSplLvl[SPL_TELEPORT] ) { - plr[myplr]._pSplLvl[SPL_TELEPORT] = 1; - } - } - if ( debug_mode_key_inverted_v && FirstTime ) { - plr[pnum]._pMemSpells64 = SPL_INVALID; - } + if (debug_mode_dollar_sign && FirstTime) { + plr[pnum]._pMemSpells64 |= 1 << (SPL_TELEPORT - 1); + if (!plr[myplr]._pSplLvl[SPL_TELEPORT]) { + plr[myplr]._pSplLvl[SPL_TELEPORT] = 1; + } + } + if (debug_mode_key_inverted_v && FirstTime) { + plr[pnum]._pMemSpells64 = SPL_INVALID; + } #endif - plr[pnum]._pNextExper = ExpLvlsTbl[plr[pnum]._pLevel]; - plr[pnum]._pInvincible = FALSE; + plr[pnum]._pNextExper = ExpLvlsTbl[plr[pnum]._pLevel]; + plr[pnum]._pInvincible = FALSE; - if ( pnum == myplr ) { - deathdelay = 0; - deathflag = FALSE; - ScrollInfo._sxoff = 0; - ScrollInfo._syoff = 0; - ScrollInfo._sdir = 0; - } + if (pnum == myplr) { + deathdelay = 0; + deathflag = FALSE; + ScrollInfo._sxoff = 0; + ScrollInfo._syoff = 0; + ScrollInfo._sdir = 0; + } } // 44B83C: could not find valid save-restore pair for edi // 52572C: using guessed type int leveldebug; @@ -918,1083 +914,1081 @@ void __fastcall InitPlayer(int pnum, BOOL FirstTime) void __cdecl InitMultiView() { - if ( (DWORD)myplr >= MAX_PLRS ) { - TermMsg("InitPlayer: illegal player %d", myplr); - } + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("InitPlayer: illegal player %d", myplr); + } - ViewX = plr[myplr].WorldX; - ViewY = plr[myplr].WorldY; + ViewX = plr[myplr].WorldX; + ViewY = plr[myplr].WorldY; } void __fastcall InitPlayerLoc(int pnum, BOOL flag) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("InitPlayer: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitPlayer: illegal player %d", pnum); + } - int x = plr[pnum].WorldX - 1; - int y = plr[pnum].WorldY + 1; - int bitflags = 0; - USHORT *pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); + int x = plr[pnum].WorldX - 1; + int y = plr[pnum].WorldY + 1; + int bitflags = 0; + USHORT *pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); - int i; - for ( i = 2; i < 10; i++ ) { - bitflags |= pieces[i]; - } + int i; + for (i = 2; i < 10; i++) { + bitflags |= pieces[i]; + } - if ( bitflags | nSolidTable[dPiece[x][y]] | dArch[x][y] ) { - plr[pnum]._peflag = 1; - } - else { - plr[pnum]._peflag = 0; - } + if (bitflags | nSolidTable[dPiece[x][y]] | dArch[x][y]) { + plr[pnum]._peflag = 1; + } else { + plr[pnum]._peflag = 0; + } - if ( flag != 1 || plr[pnum]._peflag != 1 ) { - return; - } + if (flag != 1 || plr[pnum]._peflag != 1) { + return; + } - x = plr[pnum].WorldX; - y = plr[pnum].WorldY + 2; - bitflags = 0; - pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); + x = plr[pnum].WorldX; + y = plr[pnum].WorldY + 2; + bitflags = 0; + pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); - for ( i = 2; i < 10; i++ ) { - bitflags |= pieces[i]; - } + for (i = 2; i < 10; i++) { + bitflags |= pieces[i]; + } - if ( bitflags | dArch[x][y] ) { - return; - } + if (bitflags | dArch[x][y]) { + return; + } - x = plr[pnum].WorldX - 2; - y = plr[pnum].WorldY + 1; - bitflags = 0; - pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); + x = plr[pnum].WorldX - 2; + y = plr[pnum].WorldY + 1; + bitflags = 0; + pieces = (USHORT *)dpiece_defs_map_1 + 16 * gendung_get_dpiece_num_from_coord(x, y); - for ( i = 2; i < 10; i++ ) { - bitflags |= pieces[i]; - } + for (i = 2; i < 10; i++) { + bitflags |= pieces[i]; + } - if ( bitflags | dArch[x][y] ) { - plr[pnum]._peflag = 2; - } + if (bitflags | dArch[x][y]) { + plr[pnum]._peflag = 2; + } } BOOL __fastcall SolidLoc(int x, int y) { - if ( x < 0 || y < 0 || x >= MAXDUNX || y >= MAXDUNY ) { - return FALSE; - } + if (x < 0 || y < 0 || x >= MAXDUNX || y >= MAXDUNY) { + return FALSE; + } - return nSolidTable[dPiece[x][y]]; + return nSolidTable[dPiece[x][y]]; } BOOL __fastcall PlrDirOK(int pnum, int dir) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PlrDirOK: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrDirOK: illegal player %d", pnum); + } - int px = plr[pnum].WorldX + offset_x[dir]; - int py = plr[pnum].WorldY + offset_y[dir]; + int px = plr[pnum].WorldX + offset_x[dir]; + int py = plr[pnum].WorldY + offset_y[dir]; - if ( px < 0 || !dPiece[px][py] || !PosOkPlayer(pnum, px, py) ) { - return FALSE; - } + if (px < 0 || !dPiece[px][py] || !PosOkPlayer(pnum, px, py)) { + return FALSE; + } - BOOL isOk = TRUE; - if ( dir == DIR_E ) { - isOk = !SolidLoc(px, py + 1) && !(dFlags[px][py + 1] & DFLAG_PLAYER); - } + BOOL isOk = TRUE; + if (dir == DIR_E) { + isOk = !SolidLoc(px, py + 1) && !(dFlags[px][py + 1] & DFLAG_PLAYER); + } - if ( isOk && dir == DIR_W ) { - isOk = !SolidLoc(px + 1, py) && !(dFlags[px + 1][py] & DFLAG_PLAYER); - } + if (isOk && dir == DIR_W) { + isOk = !SolidLoc(px + 1, py) && !(dFlags[px + 1][py] & DFLAG_PLAYER); + } - return isOk; + return isOk; } void __fastcall PlrClrTrans(int x, int y) { - for ( int i = y - 1; i <= y + 1; i++ ) { - for ( int j = x - 1; j <= x + 1; j++ ) { - TransList[dung_map[j][i]] = 0; - } - } + for (int i = y - 1; i <= y + 1; i++) { + for (int j = x - 1; j <= x + 1; j++) { + TransList[dung_map[j][i]] = 0; + } + } } void __fastcall PlrDoTrans(int x, int y) { - if ( leveltype != DTYPE_CATHEDRAL && leveltype != DTYPE_CATACOMBS ) { - TransList[1] = 1; - } else { - for ( int i = y - 1; i <= y + 1; i++ ) { - for ( int j = x - 1; j <= x + 1; j++ ) { - if ( !nSolidTable[dPiece[j][i]] && dung_map[j][i] ) { - TransList[dung_map[j][i]] = 1; - } - } - } - } + if (leveltype != DTYPE_CATHEDRAL && leveltype != DTYPE_CATACOMBS) { + TransList[1] = 1; + } else { + for (int i = y - 1; i <= y + 1; i++) { + for (int j = x - 1; j <= x + 1; j++) { + if (!nSolidTable[dPiece[j][i]] && dung_map[j][i]) { + TransList[dung_map[j][i]] = 1; + } + } + } + } } // 5BB1ED: using guessed type char leveltype; void __fastcall SetPlayerOld(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("SetPlayerOld: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlayerOld: illegal player %d", pnum); + } - plr[pnum]._poldx = plr[pnum].WorldX; - plr[pnum]._poldy = plr[pnum].WorldY; + plr[pnum]._poldx = plr[pnum].WorldX; + plr[pnum]._poldy = plr[pnum].WorldY; } void __fastcall FixPlayerLocation(int pnum, int dir) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("FixPlayerLocation: illegal player %d", pnum); - } - - plr[pnum]._px = plr[pnum].WorldX; - plr[pnum]._py = plr[pnum].WorldY; - plr[pnum]._ptargx = plr[pnum].WorldX; - plr[pnum]._ptargy = plr[pnum].WorldY; - plr[pnum]._pxoff = 0; - plr[pnum]._pyoff = 0; - InitPlayerLoc(pnum, FALSE); - plr[pnum]._pdir = dir; - if ( pnum == myplr ) { - ScrollInfo._sxoff = 0; - ScrollInfo._syoff = 0; - ScrollInfo._sdir = 0; - ViewX = plr[pnum].WorldX; - ViewY = plr[pnum].WorldY; - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("FixPlayerLocation: illegal player %d", pnum); + } + + plr[pnum]._px = plr[pnum].WorldX; + plr[pnum]._py = plr[pnum].WorldY; + plr[pnum]._ptargx = plr[pnum].WorldX; + plr[pnum]._ptargy = plr[pnum].WorldY; + plr[pnum]._pxoff = 0; + plr[pnum]._pyoff = 0; + InitPlayerLoc(pnum, FALSE); + plr[pnum]._pdir = dir; + if (pnum == myplr) { + ScrollInfo._sxoff = 0; + ScrollInfo._syoff = 0; + ScrollInfo._sdir = 0; + ViewX = plr[pnum].WorldX; + ViewY = plr[pnum].WorldY; + } } void __fastcall StartStand(int pnum, int dir) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartStand: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartStand: illegal player %d", pnum); + } - if ( !plr[pnum]._pInvincible || plr[pnum]._pHitPoints || pnum != myplr ) { - if ( !(plr[pnum]._pGFXLoad & PFILE_STAND) ) { - LoadPlrGFX(pnum, PFILE_STAND); - } + if (!plr[pnum]._pInvincible || plr[pnum]._pHitPoints || pnum != myplr) { + if (!(plr[pnum]._pGFXLoad & PFILE_STAND)) { + LoadPlrGFX(pnum, PFILE_STAND); + } - NewPlrAnim(pnum, plr[pnum]._pNAnim[dir], plr[pnum]._pNFrames, 3, plr[pnum]._pNWidth); - plr[pnum]._pmode = PM_STAND; - FixPlayerLocation(pnum, dir); - FixPlrWalkTags(pnum); - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; - SetPlayerOld(pnum); - } else { - SyncPlrKill(pnum, -1); - } + NewPlrAnim(pnum, plr[pnum]._pNAnim[dir], plr[pnum]._pNFrames, 3, plr[pnum]._pNWidth); + plr[pnum]._pmode = PM_STAND; + FixPlayerLocation(pnum, dir); + FixPlrWalkTags(pnum); + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; + SetPlayerOld(pnum); + } else { + SyncPlrKill(pnum, -1); + } } void __fastcall StartWalkStand(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartWalkStand: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartWalkStand: illegal player %d", pnum); + } - plr[pnum]._pmode = 0; - plr[pnum]._px = plr[pnum].WorldX; - plr[pnum]._py = plr[pnum].WorldY; - plr[pnum]._pxoff = 0; - plr[pnum]._pyoff = 0; + plr[pnum]._pmode = 0; + plr[pnum]._px = plr[pnum].WorldX; + plr[pnum]._py = plr[pnum].WorldY; + plr[pnum]._pxoff = 0; + plr[pnum]._pyoff = 0; - InitPlayerLoc(pnum, 0); + InitPlayerLoc(pnum, 0); - if ( pnum == myplr ) { - ScrollInfo._sxoff = 0; - ScrollInfo._syoff = 0; - ScrollInfo._sdir = 0; - ViewX = plr[pnum].WorldX; - ViewY = plr[pnum].WorldY; - } + if (pnum == myplr) { + ScrollInfo._sxoff = 0; + ScrollInfo._syoff = 0; + ScrollInfo._sdir = 0; + ViewX = plr[pnum].WorldX; + ViewY = plr[pnum].WorldY; + } } void __fastcall PM_ChangeLightOff(int pnum) { - int x, y; - int xmul, ymul; - int lx, ly; - int offx, offy; - const LightListStruct *l; - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_ChangeLightOff: illegal player %d", pnum); - } - - l = &LightList[plr[pnum]._plid]; - ymul = -1; - x = 2 * plr[pnum]._py + plr[pnum]._px; - y = 2 * plr[pnum]._py - plr[pnum]._px; - if (x < 0) { - xmul = -1; - x = -x; - } else { - xmul = 1; - } - if (y < 0) { - y = -y; - } else { - ymul = 1; - } - - x = (x >> 3) * xmul; - y = (y >> 3) * ymul; - lx = x + (l->_lx << 3); - ly = y + (l->_ly << 3); - offx = l->_xoff + (l->_lx << 3); - offy = l->_yoff + (l->_ly << 3); - - if ( abs(lx - offx) < 3 && abs(ly - offy) < 3 ) - return; - - ChangeLightOff(plr[pnum]._plid, x, y); + int x, y; + int xmul, ymul; + int lx, ly; + int offx, offy; + const LightListStruct *l; + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_ChangeLightOff: illegal player %d", pnum); + } + + l = &LightList[plr[pnum]._plid]; + ymul = -1; + x = 2 * plr[pnum]._py + plr[pnum]._px; + y = 2 * plr[pnum]._py - plr[pnum]._px; + if (x < 0) { + xmul = -1; + x = -x; + } else { + xmul = 1; + } + if (y < 0) { + y = -y; + } else { + ymul = 1; + } + + x = (x >> 3) * xmul; + y = (y >> 3) * ymul; + lx = x + (l->_lx << 3); + ly = y + (l->_ly << 3); + offx = l->_xoff + (l->_lx << 3); + offy = l->_yoff + (l->_ly << 3); + + if (abs(lx - offx) < 3 && abs(ly - offy) < 3) + return; + + ChangeLightOff(plr[pnum]._plid, x, y); } void __fastcall PM_ChangeOffset(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_ChangeOffset: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_ChangeOffset: illegal player %d", pnum); + } - plr[pnum]._pVar8++; - int px = plr[pnum]._pVar6 >> 8; - int py = plr[pnum]._pVar7 >> 8; + plr[pnum]._pVar8++; + int px = plr[pnum]._pVar6 >> 8; + int py = plr[pnum]._pVar7 >> 8; - plr[pnum]._pVar6 += plr[pnum]._pxvel; - plr[pnum]._pVar7 += plr[pnum]._pyvel; - plr[pnum]._pxoff = plr[pnum]._pVar6 >> 8; - plr[pnum]._pyoff = plr[pnum]._pVar7 >> 8; + plr[pnum]._pVar6 += plr[pnum]._pxvel; + plr[pnum]._pVar7 += plr[pnum]._pyvel; + plr[pnum]._pxoff = plr[pnum]._pVar6 >> 8; + plr[pnum]._pyoff = plr[pnum]._pVar7 >> 8; - if ( pnum == myplr && ScrollInfo._sdir ) { - ScrollInfo._sxoff += px - plr[pnum]._pxoff; - ScrollInfo._syoff += py - plr[pnum]._pyoff; - } + if (pnum == myplr && ScrollInfo._sdir) { + ScrollInfo._sxoff += px - plr[pnum]._pxoff; + ScrollInfo._syoff += py - plr[pnum]._pyoff; + } - PM_ChangeLightOff(pnum); + PM_ChangeLightOff(pnum); } void __fastcall StartWalk(int pnum, int xvel, int yvel, int xadd, int yadd, int EndDir, int sdir) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartWalk: illegal player %d", pnum); - } - - if ( plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr ) { - SyncPlrKill(pnum, -1); - return; - } - - SetPlayerOld(pnum); - - int px = xadd + plr[pnum].WorldX; - int py = yadd + plr[pnum].WorldY; - - if ( !PlrDirOK(pnum, EndDir) ) { - return; - } - - plr[pnum]._px = px; - plr[pnum]._py = py; - - if ( pnum == myplr ) { - ScrollInfo._sdx = plr[pnum].WorldX - ViewX; - ScrollInfo._sdy = plr[pnum].WorldY - ViewY; - } - - dPlayer[px][py] = -(pnum + 1); - plr[pnum]._pmode = PM_WALK; - plr[pnum]._pxvel = xvel; - plr[pnum]._pyvel = yvel; - plr[pnum]._pxoff = 0; - plr[pnum]._pyoff = 0; - plr[pnum]._pVar1 = xadd; - plr[pnum]._pVar2 = yadd; - plr[pnum]._pVar3 = EndDir; - - if ( !(plr[pnum]._pGFXLoad & PFILE_WALK) ) { - LoadPlrGFX(pnum, PFILE_WALK); - } - - NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); - - plr[pnum]._pdir = EndDir; - plr[pnum]._pVar6 = 0; - plr[pnum]._pVar7 = 0; - plr[pnum]._pVar8 = 0; - - InitPlayerLoc(pnum, FALSE); - - if ( pnum != myplr ) { - return; - } - - if ( zoomflag ) { - if ( abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3 ) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } - } else if ( abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2 ) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartWalk: illegal player %d", pnum); + } + + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } + + SetPlayerOld(pnum); + + int px = xadd + plr[pnum].WorldX; + int py = yadd + plr[pnum].WorldY; + + if (!PlrDirOK(pnum, EndDir)) { + return; + } + + plr[pnum]._px = px; + plr[pnum]._py = py; + + if (pnum == myplr) { + ScrollInfo._sdx = plr[pnum].WorldX - ViewX; + ScrollInfo._sdy = plr[pnum].WorldY - ViewY; + } + + dPlayer[px][py] = -(pnum + 1); + plr[pnum]._pmode = PM_WALK; + plr[pnum]._pxvel = xvel; + plr[pnum]._pyvel = yvel; + plr[pnum]._pxoff = 0; + plr[pnum]._pyoff = 0; + plr[pnum]._pVar1 = xadd; + plr[pnum]._pVar2 = yadd; + plr[pnum]._pVar3 = EndDir; + + if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { + LoadPlrGFX(pnum, PFILE_WALK); + } + + NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); + + plr[pnum]._pdir = EndDir; + plr[pnum]._pVar6 = 0; + plr[pnum]._pVar7 = 0; + plr[pnum]._pVar8 = 0; + + InitPlayerLoc(pnum, FALSE); + + if (pnum != myplr) { + return; + } + + if (zoomflag) { + if (abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } + } else if (abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } } // 52569C: using guessed type int zoomflag; void __fastcall StartWalk2(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int EndDir, int sdir) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartWalk2: illegal player %d", pnum); - } - - if ( plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr ) { - SyncPlrKill(pnum, -1); - return; - } - - SetPlayerOld(pnum); - int px = xadd + plr[pnum].WorldX; - int py = yadd + plr[pnum].WorldY; - - if ( !PlrDirOK(pnum, EndDir) ) { - return; - } - - plr[pnum]._px = px; - plr[pnum]._py = py; - - if ( pnum == myplr ) { - ScrollInfo._sdx = plr[pnum].WorldX - ViewX; - ScrollInfo._sdy = plr[pnum].WorldY - ViewY; - } - - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = -1 - pnum; - plr[pnum]._pVar1 = plr[pnum].WorldX; - plr[pnum]._pVar2 = plr[pnum].WorldY; - plr[pnum].WorldX = px; - plr[pnum].WorldY = py; - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; - plr[pnum]._pxoff = xoff; - plr[pnum]._pyoff = yoff; - - ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); - PM_ChangeLightOff(pnum); - - plr[pnum]._pmode = PM_WALK2; - plr[pnum]._pxvel = xvel; - plr[pnum]._pyvel = yvel; - plr[pnum]._pVar6 = xoff << 8; - plr[pnum]._pVar7 = yoff << 8; - plr[pnum]._pVar3 = EndDir; - - if ( !(plr[pnum]._pGFXLoad & PFILE_WALK) ) { - LoadPlrGFX(pnum, PFILE_WALK); - } - NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); - - plr[pnum]._pdir = EndDir; - plr[pnum]._pVar8 = 0; - - if ( EndDir == DIR_SE ) { - InitPlayerLoc(pnum, TRUE); - } else { - InitPlayerLoc(pnum, FALSE); - } - - if ( pnum != myplr ) { - return; - } - - if ( zoomflag ) { - if ( abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3 ) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } - } else if ( abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2 ) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartWalk2: illegal player %d", pnum); + } + + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } + + SetPlayerOld(pnum); + int px = xadd + plr[pnum].WorldX; + int py = yadd + plr[pnum].WorldY; + + if (!PlrDirOK(pnum, EndDir)) { + return; + } + + plr[pnum]._px = px; + plr[pnum]._py = py; + + if (pnum == myplr) { + ScrollInfo._sdx = plr[pnum].WorldX - ViewX; + ScrollInfo._sdy = plr[pnum].WorldY - ViewY; + } + + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = -1 - pnum; + plr[pnum]._pVar1 = plr[pnum].WorldX; + plr[pnum]._pVar2 = plr[pnum].WorldY; + plr[pnum].WorldX = px; + plr[pnum].WorldY = py; + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; + plr[pnum]._pxoff = xoff; + plr[pnum]._pyoff = yoff; + + ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); + PM_ChangeLightOff(pnum); + + plr[pnum]._pmode = PM_WALK2; + plr[pnum]._pxvel = xvel; + plr[pnum]._pyvel = yvel; + plr[pnum]._pVar6 = xoff << 8; + plr[pnum]._pVar7 = yoff << 8; + plr[pnum]._pVar3 = EndDir; + + if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { + LoadPlrGFX(pnum, PFILE_WALK); + } + NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); + + plr[pnum]._pdir = EndDir; + plr[pnum]._pVar8 = 0; + + if (EndDir == DIR_SE) { + InitPlayerLoc(pnum, TRUE); + } else { + InitPlayerLoc(pnum, FALSE); + } + + if (pnum != myplr) { + return; + } + + if (zoomflag) { + if (abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } + } else if (abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } } // 52569C: using guessed type int zoomflag; 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) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartWalk3: illegal player %d", pnum); - } - - if ( plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr ) { - SyncPlrKill(pnum, -1); - return; - } - - SetPlayerOld(pnum); - int px = xadd + plr[pnum].WorldX; - int py = yadd + plr[pnum].WorldY; - int x = mapx + plr[pnum].WorldX; - int y = mapy + plr[pnum].WorldY; - - if ( !PlrDirOK(pnum, EndDir) ) { - return; - } - - plr[pnum]._px = px; - plr[pnum]._py = py; - - if ( pnum == myplr ) { - ScrollInfo._sdx = plr[pnum].WorldX - ViewX; - ScrollInfo._sdy = plr[pnum].WorldY - ViewY; - } - - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = -1 - pnum; - dPlayer[px][py] = -1 - pnum; - plr[pnum]._pVar4 = x; - plr[pnum]._pVar5 = y; - dFlags[x][y] |= DFLAG_PLAYER; - plr[pnum]._pxoff = xoff; - plr[pnum]._pyoff = yoff; - - if ( leveltype ) { - ChangeLightXY(plr[pnum]._plid, x, y); - PM_ChangeLightOff(pnum); - } - - plr[pnum]._pmode = PM_WALK3; - plr[pnum]._pxvel = xvel; - plr[pnum]._pyvel = yvel; - plr[pnum]._pVar1 = px; - plr[pnum]._pVar2 = py; - plr[pnum]._pVar6 = xoff << 8; - plr[pnum]._pVar7 = yoff << 8; - plr[pnum]._pVar3 = EndDir; - - if ( !(plr[pnum]._pGFXLoad & PFILE_WALK) ) { - LoadPlrGFX(pnum, PFILE_WALK); - } - NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); - - plr[pnum]._pdir = EndDir; - plr[pnum]._pVar8 = 0; - - InitPlayerLoc(pnum, FALSE); - - if ( pnum != myplr ) { - return; - } - - if ( zoomflag ) { - if ( abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3 ) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } - } else if ( abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2 ) { - ScrollInfo._sdir = SDIR_NONE; - } else { - ScrollInfo._sdir = sdir; - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartWalk3: illegal player %d", pnum); + } + + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } + + SetPlayerOld(pnum); + int px = xadd + plr[pnum].WorldX; + int py = yadd + plr[pnum].WorldY; + int x = mapx + plr[pnum].WorldX; + int y = mapy + plr[pnum].WorldY; + + if (!PlrDirOK(pnum, EndDir)) { + return; + } + + plr[pnum]._px = px; + plr[pnum]._py = py; + + if (pnum == myplr) { + ScrollInfo._sdx = plr[pnum].WorldX - ViewX; + ScrollInfo._sdy = plr[pnum].WorldY - ViewY; + } + + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = -1 - pnum; + dPlayer[px][py] = -1 - pnum; + plr[pnum]._pVar4 = x; + plr[pnum]._pVar5 = y; + dFlags[x][y] |= DFLAG_PLAYER; + plr[pnum]._pxoff = xoff; + plr[pnum]._pyoff = yoff; + + if (leveltype) { + ChangeLightXY(plr[pnum]._plid, x, y); + PM_ChangeLightOff(pnum); + } + + plr[pnum]._pmode = PM_WALK3; + plr[pnum]._pxvel = xvel; + plr[pnum]._pyvel = yvel; + plr[pnum]._pVar1 = px; + plr[pnum]._pVar2 = py; + plr[pnum]._pVar6 = xoff << 8; + plr[pnum]._pVar7 = yoff << 8; + plr[pnum]._pVar3 = EndDir; + + if (!(plr[pnum]._pGFXLoad & PFILE_WALK)) { + LoadPlrGFX(pnum, PFILE_WALK); + } + NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth); + + plr[pnum]._pdir = EndDir; + plr[pnum]._pVar8 = 0; + + InitPlayerLoc(pnum, FALSE); + + if (pnum != myplr) { + return; + } + + if (zoomflag) { + if (abs(ScrollInfo._sdx) >= 3 || abs(ScrollInfo._sdy) >= 3) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } + } else if (abs(ScrollInfo._sdx) >= 2 || abs(ScrollInfo._sdy) >= 2) { + ScrollInfo._sdir = SDIR_NONE; + } else { + ScrollInfo._sdir = sdir; + } } // 52569C: using guessed type int zoomflag; // 5BB1ED: using guessed type char leveltype; void __fastcall StartAttack(int pnum, int d) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartAttack: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartAttack: illegal player %d", pnum); + } - if ( plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr ) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - if ( !(plr[pnum]._pGFXLoad & PFILE_ATTACK) ) { - LoadPlrGFX(pnum, PFILE_ATTACK); - } + if (!(plr[pnum]._pGFXLoad & PFILE_ATTACK)) { + LoadPlrGFX(pnum, PFILE_ATTACK); + } - NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth); - plr[pnum]._pmode = PM_ATTACK; - FixPlayerLocation(pnum, d); - SetPlayerOld(pnum); + NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth); + plr[pnum]._pmode = PM_ATTACK; + FixPlayerLocation(pnum, d); + SetPlayerOld(pnum); } void __fastcall StartRangeAttack(int pnum, int d, int cx, int cy) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartRangeAttack: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartRangeAttack: illegal player %d", pnum); + } - if ( plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr ) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - if ( !(plr[pnum]._pGFXLoad & PFILE_ATTACK) ) { - LoadPlrGFX(pnum, PFILE_ATTACK); - } - NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth); + if (!(plr[pnum]._pGFXLoad & PFILE_ATTACK)) { + LoadPlrGFX(pnum, PFILE_ATTACK); + } + NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth); - plr[pnum]._pmode = PM_RATTACK; - FixPlayerLocation(pnum, d); - SetPlayerOld(pnum); - plr[pnum]._pVar1 = cx; - plr[pnum]._pVar2 = cy; + plr[pnum]._pmode = PM_RATTACK; + FixPlayerLocation(pnum, d); + SetPlayerOld(pnum); + plr[pnum]._pVar1 = cx; + plr[pnum]._pVar2 = cy; } void __fastcall StartPlrBlock(int pnum, int dir) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartPlrBlock: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartPlrBlock: illegal player %d", pnum); + } - if ( plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr ) { - SyncPlrKill(pnum, -1); - return; - } + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } - PlaySfxLoc(IS_ISWORD, plr[pnum].WorldX, plr[pnum].WorldY); + PlaySfxLoc(IS_ISWORD, plr[pnum].WorldX, plr[pnum].WorldY); - if ( !(plr[pnum]._pGFXLoad & PFILE_BLOCK) ) { - LoadPlrGFX(pnum, PFILE_BLOCK); - } - NewPlrAnim(pnum, plr[pnum]._pBAnim[dir], plr[pnum]._pBFrames, 2, plr[pnum]._pBWidth); + if (!(plr[pnum]._pGFXLoad & PFILE_BLOCK)) { + LoadPlrGFX(pnum, PFILE_BLOCK); + } + NewPlrAnim(pnum, plr[pnum]._pBAnim[dir], plr[pnum]._pBFrames, 2, plr[pnum]._pBWidth); - plr[pnum]._pmode = PM_BLOCK; - FixPlayerLocation(pnum, dir); - SetPlayerOld(pnum); + plr[pnum]._pmode = PM_BLOCK; + FixPlayerLocation(pnum, dir); + SetPlayerOld(pnum); } void __fastcall StartSpell(int pnum, int d, int cx, int cy) { - if ( (DWORD)pnum >= MAX_PLRS ) - TermMsg("StartSpell: illegal player %d", pnum); - - if ( plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr ) { - SyncPlrKill(pnum, -1); - return; - } - - if ( leveltype != DTYPE_TOWN ) { - switch ( spelldata[plr[pnum]._pSpell].sType ) - { - case STYPE_FIRE: - if ( !(plr[pnum]._pGFXLoad & PFILE_FIRE) ) { - LoadPlrGFX(pnum, PFILE_FIRE); - } - NewPlrAnim(pnum, plr[pnum]._pFAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); - break; - case STYPE_LIGHTNING: - if ( !(plr[pnum]._pGFXLoad & PFILE_LIGHTNING) ) { - LoadPlrGFX(pnum, PFILE_LIGHTNING); - } - NewPlrAnim(pnum, plr[pnum]._pLAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); - break; - case STYPE_MAGIC: - if ( !(plr[pnum]._pGFXLoad & PFILE_MAGIC) ) { - LoadPlrGFX(pnum, PFILE_MAGIC); - } - NewPlrAnim(pnum, plr[pnum]._pTAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); - break; - } - } - - PlaySfxLoc(spelldata[plr[pnum]._pSpell].sSFX, plr[pnum].WorldX, plr[pnum].WorldY); - - plr[pnum]._pmode = PM_SPELL; - - FixPlayerLocation(pnum, d); - SetPlayerOld(pnum); - - plr[pnum]._pVar1 = cx; - plr[pnum]._pVar2 = cy; - plr[pnum]._pVar4 = GetSpellLevel(pnum, plr[pnum]._pSpell); - plr[pnum]._pVar8 = 1; + if ((DWORD)pnum >= MAX_PLRS) + TermMsg("StartSpell: illegal player %d", pnum); + + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } + + if (leveltype != DTYPE_TOWN) { + switch (spelldata[plr[pnum]._pSpell].sType) { + case STYPE_FIRE: + if (!(plr[pnum]._pGFXLoad & PFILE_FIRE)) { + LoadPlrGFX(pnum, PFILE_FIRE); + } + NewPlrAnim(pnum, plr[pnum]._pFAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); + break; + case STYPE_LIGHTNING: + if (!(plr[pnum]._pGFXLoad & PFILE_LIGHTNING)) { + LoadPlrGFX(pnum, PFILE_LIGHTNING); + } + NewPlrAnim(pnum, plr[pnum]._pLAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); + break; + case STYPE_MAGIC: + if (!(plr[pnum]._pGFXLoad & PFILE_MAGIC)) { + LoadPlrGFX(pnum, PFILE_MAGIC); + } + NewPlrAnim(pnum, plr[pnum]._pTAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth); + break; + } + } + + PlaySfxLoc(spelldata[plr[pnum]._pSpell].sSFX, plr[pnum].WorldX, plr[pnum].WorldY); + + plr[pnum]._pmode = PM_SPELL; + + FixPlayerLocation(pnum, d); + SetPlayerOld(pnum); + + plr[pnum]._pVar1 = cx; + plr[pnum]._pVar2 = cy; + plr[pnum]._pVar4 = GetSpellLevel(pnum, plr[pnum]._pSpell); + plr[pnum]._pVar8 = 1; } // 5BB1ED: using guessed type char leveltype; void __fastcall FixPlrWalkTags(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("FixPlrWalkTags: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("FixPlrWalkTags: illegal player %d", pnum); + } - int pp = pnum + 1; - int pn = -(pnum + 1); - int dx = plr[pnum]._poldx; - int dy = plr[pnum]._poldy; - for ( int y = dy - 1; y <= dy + 1; y++ ) { - for ( int x = dx - 1; x <= dx + 1; x++ ) { - if ( x >= 0 && x < MAXDUNX && y >= 0 && y < MAXDUNY && (dPlayer[x][y] == pp || dPlayer[x][y] == pn) ) { - dPlayer[x][y] = 0; - } - } - } + int pp = pnum + 1; + int pn = -(pnum + 1); + int dx = plr[pnum]._poldx; + int dy = plr[pnum]._poldy; + for (int y = dy - 1; y <= dy + 1; y++) { + for (int x = dx - 1; x <= dx + 1; x++) { + if (x >= 0 && x < MAXDUNX && y >= 0 && y < MAXDUNY && (dPlayer[x][y] == pp || dPlayer[x][y] == pn)) { + dPlayer[x][y] = 0; + } + } + } - if ( dx >= 0 && dx < MAXDUNX - 1 && dy >= 0 && dy < MAXDUNY -1 ) { - dFlags[dx + 1][dy] &= ~DFLAG_PLAYER; - dFlags[dx][dy + 1] &= ~DFLAG_PLAYER; - } + if (dx >= 0 && dx < MAXDUNX - 1 && dy >= 0 && dy < MAXDUNY - 1) { + dFlags[dx + 1][dy] &= ~DFLAG_PLAYER; + dFlags[dx][dy + 1] &= ~DFLAG_PLAYER; + } } void __fastcall RemovePlrFromMap(int pnum) { - int x, y; - int pp = pnum + 1; - int pn = -(pnum + 1); + int x, y; + int pp = pnum + 1; + int pn = -(pnum + 1); - for(y = 1; y < MAXDUNY; y++) - for(x = 1; x < MAXDUNX; x++) - if(dPlayer[x][y-1] == pn || dPlayer[x-1][y] == pn) - if(dFlags[x][y] & DFLAG_PLAYER) - dFlags[x][y] &= ~DFLAG_PLAYER; + for (y = 1; y < MAXDUNY; y++) + for (x = 1; x < MAXDUNX; x++) + if (dPlayer[x][y - 1] == pn || dPlayer[x - 1][y] == pn) + if (dFlags[x][y] & DFLAG_PLAYER) + dFlags[x][y] &= ~DFLAG_PLAYER; - for(y = 0; y < MAXDUNY; y++) - for(x = 0; x < MAXDUNX; x++) - if(dPlayer[x][y] == pp || dPlayer[x][y] == pn) - dPlayer[x][y] = 0; + for (y = 0; y < MAXDUNY; y++) + for (x = 0; x < MAXDUNX; x++) + if (dPlayer[x][y] == pp || dPlayer[x][y] == pn) + dPlayer[x][y] = 0; } void __fastcall StartPlrHit(int pnum, int dam, BOOL forcehit) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartPlrHit: illegal player %d", pnum); - } - - if ( plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr ) { - SyncPlrKill(pnum, -1); - return; - } - - if ( plr[pnum]._pClass == PC_WARRIOR ) { - PlaySfxLoc(PS_WARR69, plr[pnum].WorldX, plr[pnum].WorldY); - } else if ( plr[pnum]._pClass == PC_ROGUE ) { - PlaySfxLoc(PS_ROGUE69, plr[pnum].WorldX, plr[pnum].WorldY); - } else if ( plr[pnum]._pClass == PC_SORCERER ) { - PlaySfxLoc(PS_MAGE69, plr[pnum].WorldX, plr[pnum].WorldY); - } - - drawhpflag = TRUE; - if ( dam >> 6 >= plr[pnum]._pLevel || forcehit ) { - int dir = plr[pnum]._pdir; - - if ( !(plr[pnum]._pGFXLoad & PFILE_HIT) ) { - LoadPlrGFX(pnum, PFILE_HIT); - } - NewPlrAnim(pnum, plr[pnum]._pHAnim[dir], plr[pnum]._pHFrames, 0, plr[pnum]._pHWidth); - - plr[pnum]._pmode = PM_GOTHIT; - FixPlayerLocation(pnum, dir); - plr[pnum]._pVar8 = 1; - FixPlrWalkTags(pnum); - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; - SetPlayerOld(pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartPlrHit: illegal player %d", pnum); + } + + if (plr[pnum]._pInvincible && !plr[pnum]._pHitPoints && pnum == myplr) { + SyncPlrKill(pnum, -1); + return; + } + + if (plr[pnum]._pClass == PC_WARRIOR) { + PlaySfxLoc(PS_WARR69, plr[pnum].WorldX, plr[pnum].WorldY); + } else if (plr[pnum]._pClass == PC_ROGUE) { + PlaySfxLoc(PS_ROGUE69, plr[pnum].WorldX, plr[pnum].WorldY); + } else if (plr[pnum]._pClass == PC_SORCERER) { + PlaySfxLoc(PS_MAGE69, plr[pnum].WorldX, plr[pnum].WorldY); + } + + drawhpflag = TRUE; + if (dam >> 6 >= plr[pnum]._pLevel || forcehit) { + int dir = plr[pnum]._pdir; + + if (!(plr[pnum]._pGFXLoad & PFILE_HIT)) { + LoadPlrGFX(pnum, PFILE_HIT); + } + NewPlrAnim(pnum, plr[pnum]._pHAnim[dir], plr[pnum]._pHFrames, 0, plr[pnum]._pHWidth); + + plr[pnum]._pmode = PM_GOTHIT; + FixPlayerLocation(pnum, dir); + plr[pnum]._pVar8 = 1; + FixPlrWalkTags(pnum); + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; + SetPlayerOld(pnum); + } } void __fastcall RespawnDeadItem(ItemStruct *itm, int x, int y) { - if ( numitems >= MAXITEMS ) { - return; - } + if (numitems >= MAXITEMS) { + return; + } - if ( FindGetItem(itm->IDidx, itm->_iCreateInfo, itm->_iSeed) >= 0 ) { - DrawInvMsg("A duplicate item has been detected. Destroying duplicate..."); - SyncGetItem(x, y, itm->IDidx, itm->_iCreateInfo, itm->_iSeed); - } + if (FindGetItem(itm->IDidx, itm->_iCreateInfo, itm->_iSeed) >= 0) { + DrawInvMsg("A duplicate item has been detected. Destroying duplicate..."); + SyncGetItem(x, y, itm->IDidx, itm->_iCreateInfo, itm->_iSeed); + } - int i = itemavail[0]; - dItem[x][y] = i + 1; - itemavail[0] = itemavail[MAXITEMS - numitems - 1]; - itemactive[numitems] = i; - item[i] = *itm; - item[i]._ix = x; - item[i]._iy = y; - RespawnItem(i, TRUE); - numitems++; - itm->_itype = ITYPE_NONE; + int i = itemavail[0]; + dItem[x][y] = i + 1; + itemavail[0] = itemavail[MAXITEMS - numitems - 1]; + itemactive[numitems] = i; + item[i] = *itm; + item[i]._ix = x; + item[i]._iy = y; + RespawnItem(i, TRUE); + numitems++; + itm->_itype = ITYPE_NONE; } void __fastcall StartPlayerKill(int pnum, int earflag) { - if ( plr[pnum]._pHitPoints <= 0 && plr[pnum]._pmode == PM_DEATH ) { - return; - } - - if ( myplr == pnum ) { - NetSendCmdParam1(TRUE, CMD_PLRDEAD, earflag); - } - - BOOL diablolevel = gbMaxPlayers > 1 && plr[pnum].plrlevel == 16; - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartPlayerKill: illegal player %d", pnum); - } - - if ( plr[pnum]._pClass == PC_WARRIOR ) { - PlaySfxLoc(PS_DEAD, plr[pnum].WorldX, plr[pnum].WorldY); // BUGFIX: should use `PS_WARR71` like other classes - } else if ( plr[pnum]._pClass == PC_ROGUE ) { - PlaySfxLoc(PS_ROGUE71, plr[pnum].WorldX, plr[pnum].WorldY); - } else if ( plr[pnum]._pClass == PC_SORCERER ) { - PlaySfxLoc(PS_MAGE71, plr[pnum].WorldX, plr[pnum].WorldY); - } - - if ( plr[pnum]._pgfxnum ) { - plr[pnum]._pgfxnum = 0; - plr[pnum]._pGFXLoad = 0; - SetPlrAnims(pnum); - } - - if ( !(plr[pnum]._pGFXLoad & PFILE_DEATH) ) { - LoadPlrGFX(pnum, PFILE_DEATH); - } - - PlayerStruct *p = &plr[pnum]; - NewPlrAnim(pnum, p->_pDAnim[plr[pnum]._pdir], p->_pDFrames, 1, p->_pDWidth); - - plr[pnum]._pBlockFlag = FALSE; - plr[pnum]._pmode = PM_DEATH; - plr[pnum]._pInvincible = TRUE; - SetPlayerHitPoints(pnum, 0); - plr[pnum]._pVar8 = 1; - - int i; - if ( pnum != myplr && !earflag && !diablolevel ) { - for ( i = 0; i < NUM_INVLOC; i++ ) { - plr[pnum].InvBody[i]._itype = ITYPE_NONE; - } - CalcPlrInv(pnum, FALSE); - } - - if ( plr[pnum].plrlevel == currlevel ) { - FixPlayerLocation(pnum, plr[pnum]._pdir); - RemovePlrFromMap(pnum); - dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; - SetPlayerOld(pnum); - - if ( pnum == myplr ) { - drawhpflag = TRUE; - deathdelay = 30; - - if ( pcurs >= CURSOR_FIRSTITEM ) { - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - SetCursor(CURSOR_HAND); - } - - if ( !diablolevel ) { - DropHalfPlayersGold(pnum); - if ( earflag != -1 ) { - if ( earflag != 0 ) { - ItemStruct ear; - SetPlrHandItem(&ear, IDI_EAR); - sprintf(ear._iName, "Ear of %s", plr[pnum]._pName); - if ( plr[pnum]._pClass == PC_SORCERER ) { - ear._iCurs = ICURS_EAR_SORCEROR; - } else if ( plr[pnum]._pClass == PC_WARRIOR ) { - ear._iCurs = ICURS_EAR_WARRIOR; - } else if ( plr[pnum]._pClass == PC_ROGUE ) { - ear._iCurs = ICURS_EAR_ROGUE; - } - - ear._iCreateInfo = plr[pnum]._pName[0] << 8 | plr[pnum]._pName[1]; - ear._iSeed = plr[pnum]._pName[2] << 24 | plr[pnum]._pName[3] << 16 | plr[pnum]._pName[4] << 8 | plr[pnum]._pName[5]; - ear._ivalue = plr[pnum]._pLevel; - - if ( FindGetItem(IDI_EAR, ear._iCreateInfo, ear._iSeed) == -1 ) { - PlrDeadItem(pnum, &ear, 0, 0); - } - } else { - ItemStruct *pi = &plr[pnum].InvBody[0]; - i = NUM_INVLOC; - while ( i != 0 ) { - i--; - int pdd = (i + plr[pnum]._pdir) & 7; - PlrDeadItem(pnum, pi, offset_x[pdd], offset_y[pdd]); - pi++; - } - - CalcPlrInv(pnum, FALSE); - } - } - } - } - } - SetPlayerHitPoints(pnum, 0); + if (plr[pnum]._pHitPoints <= 0 && plr[pnum]._pmode == PM_DEATH) { + return; + } + + if (myplr == pnum) { + NetSendCmdParam1(TRUE, CMD_PLRDEAD, earflag); + } + + BOOL diablolevel = gbMaxPlayers > 1 && plr[pnum].plrlevel == 16; + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartPlayerKill: illegal player %d", pnum); + } + + if (plr[pnum]._pClass == PC_WARRIOR) { + PlaySfxLoc(PS_DEAD, plr[pnum].WorldX, plr[pnum].WorldY); // BUGFIX: should use `PS_WARR71` like other classes + } else if (plr[pnum]._pClass == PC_ROGUE) { + PlaySfxLoc(PS_ROGUE71, plr[pnum].WorldX, plr[pnum].WorldY); + } else if (plr[pnum]._pClass == PC_SORCERER) { + PlaySfxLoc(PS_MAGE71, plr[pnum].WorldX, plr[pnum].WorldY); + } + + if (plr[pnum]._pgfxnum) { + plr[pnum]._pgfxnum = 0; + plr[pnum]._pGFXLoad = 0; + SetPlrAnims(pnum); + } + + if (!(plr[pnum]._pGFXLoad & PFILE_DEATH)) { + LoadPlrGFX(pnum, PFILE_DEATH); + } + + PlayerStruct *p = &plr[pnum]; + NewPlrAnim(pnum, p->_pDAnim[plr[pnum]._pdir], p->_pDFrames, 1, p->_pDWidth); + + plr[pnum]._pBlockFlag = FALSE; + plr[pnum]._pmode = PM_DEATH; + plr[pnum]._pInvincible = TRUE; + SetPlayerHitPoints(pnum, 0); + plr[pnum]._pVar8 = 1; + + int i; + if (pnum != myplr && !earflag && !diablolevel) { + for (i = 0; i < NUM_INVLOC; i++) { + plr[pnum].InvBody[i]._itype = ITYPE_NONE; + } + CalcPlrInv(pnum, FALSE); + } + + if (plr[pnum].plrlevel == currlevel) { + FixPlayerLocation(pnum, plr[pnum]._pdir); + RemovePlrFromMap(pnum); + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; + SetPlayerOld(pnum); + + if (pnum == myplr) { + drawhpflag = TRUE; + deathdelay = 30; + + if (pcurs >= CURSOR_FIRSTITEM) { + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + SetCursor(CURSOR_HAND); + } + + if (!diablolevel) { + DropHalfPlayersGold(pnum); + if (earflag != -1) { + if (earflag != 0) { + ItemStruct ear; + SetPlrHandItem(&ear, IDI_EAR); + sprintf(ear._iName, "Ear of %s", plr[pnum]._pName); + if (plr[pnum]._pClass == PC_SORCERER) { + ear._iCurs = ICURS_EAR_SORCEROR; + } else if (plr[pnum]._pClass == PC_WARRIOR) { + ear._iCurs = ICURS_EAR_WARRIOR; + } else if (plr[pnum]._pClass == PC_ROGUE) { + ear._iCurs = ICURS_EAR_ROGUE; + } + + ear._iCreateInfo = plr[pnum]._pName[0] << 8 | plr[pnum]._pName[1]; + ear._iSeed = plr[pnum]._pName[2] << 24 | plr[pnum]._pName[3] << 16 | plr[pnum]._pName[4] << 8 | plr[pnum]._pName[5]; + ear._ivalue = plr[pnum]._pLevel; + + if (FindGetItem(IDI_EAR, ear._iCreateInfo, ear._iSeed) == -1) { + PlrDeadItem(pnum, &ear, 0, 0); + } + } else { + ItemStruct *pi = &plr[pnum].InvBody[0]; + i = NUM_INVLOC; + while (i != 0) { + i--; + int pdd = (i + plr[pnum]._pdir) & 7; + PlrDeadItem(pnum, pi, offset_x[pdd], offset_y[pdd]); + pi++; + } + + CalcPlrInv(pnum, FALSE); + } + } + } + } + } + SetPlayerHitPoints(pnum, 0); } // 679660: using guessed type char gbMaxPlayers; // 69B7C4: using guessed type int deathdelay; void __fastcall PlrDeadItem(int pnum, struct ItemStruct *itm, int xx, int yy) { - int x, y; - int i, j; - - if ( itm->_itype == ITYPE_NONE ) - return; - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PlrDeadItem: illegal player %d", pnum); - } - - x = xx + plr[pnum].WorldX; - y = yy + plr[pnum].WorldY; - if ( (xx || yy) && ItemSpaceOk(x, y) ) { - RespawnDeadItem(itm, x, y); - plr[pnum].HoldItem = *itm; - NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y); - return; - } - - for ( yy = -1, xx = 1; yy > -50; xx++, yy-- ) { - for ( j = yy; j <= xx; j++ ) { - y = j + plr[pnum].WorldY; - for ( i = yy; i <= xx; i++ ) { - x = i + plr[pnum].WorldX; - if ( ItemSpaceOk(x, y) ) { - RespawnDeadItem(itm, x, y); - plr[pnum].HoldItem = *itm; - NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y); - return; - } - } - } - } + int x, y; + int i, j; + + if (itm->_itype == ITYPE_NONE) + return; + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrDeadItem: illegal player %d", pnum); + } + + x = xx + plr[pnum].WorldX; + y = yy + plr[pnum].WorldY; + if ((xx || yy) && ItemSpaceOk(x, y)) { + RespawnDeadItem(itm, x, y); + plr[pnum].HoldItem = *itm; + NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y); + return; + } + + for (yy = -1, xx = 1; yy > -50; xx++, yy--) { + for (j = yy; j <= xx; j++) { + y = j + plr[pnum].WorldY; + for (i = yy; i <= xx; i++) { + x = i + plr[pnum].WorldX; + if (ItemSpaceOk(x, y)) { + RespawnDeadItem(itm, x, y); + plr[pnum].HoldItem = *itm; + NetSendCmdPItem(FALSE, CMD_RESPAWNITEM, x, y); + return; + } + } + } + } } void __fastcall DropHalfPlayersGold(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("DropHalfPlayersGold: illegal player %d", pnum); - } - - int i; - int hGold = plr[pnum]._pGold >> 1; - for ( i = 0; i < MAXBELTITEMS && hGold > 0; i++ ) { - if ( plr[pnum].SpdList[i]._itype == ITYPE_GOLD && plr[pnum].SpdList[i]._ivalue != 5000 ) { - if ( hGold < plr[pnum].SpdList[i]._ivalue ) { - plr[pnum].SpdList[i]._ivalue -= hGold; - SetSpdbarGoldCurs(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = hGold; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - hGold = 0; - } else { - hGold -= plr[pnum].SpdList[i]._ivalue; - RemoveSpdBarItem(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = plr[pnum].SpdList[i]._ivalue; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - i = -1; - } - } - } - if ( hGold > 0 ) { - for ( i = 0; i < MAXBELTITEMS && hGold > 0; i++ ) { - if ( plr[pnum].SpdList[i]._itype == ITYPE_GOLD ) { - if ( hGold < plr[pnum].SpdList[i]._ivalue ) { - plr[pnum].SpdList[i]._ivalue -= hGold; - SetSpdbarGoldCurs(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = hGold; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - hGold = 0; - } else { - hGold -= plr[pnum].SpdList[i]._ivalue; - RemoveSpdBarItem(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = plr[pnum].SpdList[i]._ivalue; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - i = -1; - } - } - } - } - drawpanflag = 255; - if ( hGold > 0 ) { - for ( i = 0; i < plr[pnum]._pNumInv && hGold > 0; i++ ) { - if ( plr[pnum].InvList[i]._itype == ITYPE_GOLD && plr[pnum].InvList[i]._ivalue != 5000 ) { - if ( hGold < plr[pnum].InvList[i]._ivalue ) { - plr[pnum].InvList[i]._ivalue -= hGold; - SetGoldCurs(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = hGold; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - hGold = 0; - } else { - hGold -= plr[pnum].InvList[i]._ivalue; - RemoveInvItem(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = plr[pnum].InvList[i]._ivalue; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - i = -1; - } - } - } - } - if ( hGold > 0 ) { - for ( i = 0; i < plr[pnum]._pNumInv && hGold > 0; i++ ) { - if ( plr[pnum].InvList[i]._itype == ITYPE_GOLD ) { - if ( hGold < plr[pnum].InvList[i]._ivalue ) { - plr[pnum].InvList[i]._ivalue -= hGold; - SetGoldCurs(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = hGold; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - hGold = 0; - } else { - hGold -= plr[pnum].InvList[i]._ivalue; - RemoveInvItem(pnum, i); - SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); - GetGoldSeed(pnum, &plr[pnum].HoldItem); - SetPlrHandGoldCurs(&plr[pnum].HoldItem); - plr[pnum].HoldItem._ivalue = plr[pnum].InvList[i]._ivalue; - PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); - i = -1; - } - } - } - } - plr[pnum]._pGold = CalculateGold(pnum); + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("DropHalfPlayersGold: illegal player %d", pnum); + } + + int i; + int hGold = plr[pnum]._pGold >> 1; + for (i = 0; i < MAXBELTITEMS && hGold > 0; i++) { + if (plr[pnum].SpdList[i]._itype == ITYPE_GOLD && plr[pnum].SpdList[i]._ivalue != 5000) { + if (hGold < plr[pnum].SpdList[i]._ivalue) { + plr[pnum].SpdList[i]._ivalue -= hGold; + SetSpdbarGoldCurs(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = hGold; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + hGold = 0; + } else { + hGold -= plr[pnum].SpdList[i]._ivalue; + RemoveSpdBarItem(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = plr[pnum].SpdList[i]._ivalue; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + i = -1; + } + } + } + if (hGold > 0) { + for (i = 0; i < MAXBELTITEMS && hGold > 0; i++) { + if (plr[pnum].SpdList[i]._itype == ITYPE_GOLD) { + if (hGold < plr[pnum].SpdList[i]._ivalue) { + plr[pnum].SpdList[i]._ivalue -= hGold; + SetSpdbarGoldCurs(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = hGold; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + hGold = 0; + } else { + hGold -= plr[pnum].SpdList[i]._ivalue; + RemoveSpdBarItem(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = plr[pnum].SpdList[i]._ivalue; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + i = -1; + } + } + } + } + drawpanflag = 255; + if (hGold > 0) { + for (i = 0; i < plr[pnum]._pNumInv && hGold > 0; i++) { + if (plr[pnum].InvList[i]._itype == ITYPE_GOLD && plr[pnum].InvList[i]._ivalue != 5000) { + if (hGold < plr[pnum].InvList[i]._ivalue) { + plr[pnum].InvList[i]._ivalue -= hGold; + SetGoldCurs(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = hGold; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + hGold = 0; + } else { + hGold -= plr[pnum].InvList[i]._ivalue; + RemoveInvItem(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = plr[pnum].InvList[i]._ivalue; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + i = -1; + } + } + } + } + if (hGold > 0) { + for (i = 0; i < plr[pnum]._pNumInv && hGold > 0; i++) { + if (plr[pnum].InvList[i]._itype == ITYPE_GOLD) { + if (hGold < plr[pnum].InvList[i]._ivalue) { + plr[pnum].InvList[i]._ivalue -= hGold; + SetGoldCurs(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = hGold; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + hGold = 0; + } else { + hGold -= plr[pnum].InvList[i]._ivalue; + RemoveInvItem(pnum, i); + SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); + GetGoldSeed(pnum, &plr[pnum].HoldItem); + SetPlrHandGoldCurs(&plr[pnum].HoldItem); + plr[pnum].HoldItem._ivalue = plr[pnum].InvList[i]._ivalue; + PlrDeadItem(pnum, &plr[pnum].HoldItem, 0, 0); + i = -1; + } + } + } + } + plr[pnum]._pGold = CalculateGold(pnum); } // 52571C: using guessed type int drawpanflag; void __fastcall SyncPlrKill(int pnum, int earflag) { - if ( plr[pnum]._pHitPoints == 0 && currlevel == 0 ) { - SetPlayerHitPoints(pnum, 64); - return; - } + if (plr[pnum]._pHitPoints == 0 && currlevel == 0) { + SetPlayerHitPoints(pnum, 64); + return; + } - for ( int i = 0; i < nummissiles; i++ ) { - int ma = missileactive[i]; - if ( missile[ma]._mitype == MIS_MANASHIELD && missile[ma]._misource == pnum && missile[ma]._miDelFlag == 0 ) { - if ( earflag != -1 ) { - missile[ma]._miVar8 = earflag; - } + for (int i = 0; i < nummissiles; i++) { + int ma = missileactive[i]; + if (missile[ma]._mitype == MIS_MANASHIELD && missile[ma]._misource == pnum && missile[ma]._miDelFlag == 0) { + if (earflag != -1) { + missile[ma]._miVar8 = earflag; + } - return; - } - } + return; + } + } - SetPlayerHitPoints(pnum, 0); - StartPlayerKill(pnum, earflag); + SetPlayerHitPoints(pnum, 0); + StartPlayerKill(pnum, earflag); } void __fastcall RemovePlrMissiles(int pnum) { - if ( currlevel != 0 && pnum == myplr && (monster[myplr]._mx != 1 || monster[myplr]._my != 0 ) ) { - M_StartKill(myplr, myplr); - AddDead(monster[myplr]._mx, monster[myplr]._my, monster[myplr].MType->mdeadval, (direction)monster[myplr]._mdir); - dMonster[monster[myplr]._mx][monster[myplr]._my] = 0; - monster[myplr]._mDelFlag = TRUE; - DeleteMonsterList(); - } - - for ( int mi = 0; mi < nummissiles; mi++ ) { - int am = missileactive[mi]; - if ( missile[am]._mitype == MIS_STONE && missile[am]._misource == pnum ) { - monster[missile[am]._miVar2]._mmode = missile[am]._miVar1; - } - if ( missile[am]._mitype == MIS_MANASHIELD && missile[am]._misource == pnum ) { - ClearMissileSpot(am); - DeleteMissile(am, mi); - } - if ( missile[am]._mitype == MIS_ETHEREALIZE && missile[am]._misource == pnum ) { - ClearMissileSpot(am); - DeleteMissile(am, mi); - } - } + if (currlevel != 0 && pnum == myplr && (monster[myplr]._mx != 1 || monster[myplr]._my != 0)) { + M_StartKill(myplr, myplr); + AddDead(monster[myplr]._mx, monster[myplr]._my, monster[myplr].MType->mdeadval, (direction)monster[myplr]._mdir); + dMonster[monster[myplr]._mx][monster[myplr]._my] = 0; + monster[myplr]._mDelFlag = TRUE; + DeleteMonsterList(); + } + + for (int mi = 0; mi < nummissiles; mi++) { + int am = missileactive[mi]; + if (missile[am]._mitype == MIS_STONE && missile[am]._misource == pnum) { + monster[missile[am]._miVar2]._mmode = missile[am]._miVar1; + } + if (missile[am]._mitype == MIS_MANASHIELD && missile[am]._misource == pnum) { + ClearMissileSpot(am); + DeleteMissile(am, mi); + } + if (missile[am]._mitype == MIS_ETHEREALIZE && missile[am]._misource == pnum) { + ClearMissileSpot(am); + DeleteMissile(am, mi); + } + } } void __fastcall InitLevelChange(int pnum) { - RemovePlrMissiles(pnum); - if ( pnum == myplr && qtextflag ) { - qtextflag = FALSE; - sfx_stop(); - } + RemovePlrMissiles(pnum); + if (pnum == myplr && qtextflag) { + qtextflag = FALSE; + sfx_stop(); + } - RemovePlrFromMap(pnum); - SetPlayerOld(pnum); - if ( pnum == myplr ) { - dPlayer[plr[myplr].WorldX][plr[myplr].WorldY] = myplr + 1; - } else { - plr[pnum]._pLvlVisited[plr[pnum].plrlevel] = 1; - } + RemovePlrFromMap(pnum); + SetPlayerOld(pnum); + if (pnum == myplr) { + dPlayer[plr[myplr].WorldX][plr[myplr].WorldY] = myplr + 1; + } else { + plr[pnum]._pLvlVisited[plr[pnum].plrlevel] = 1; + } - ClrPlrPath(pnum); - plr[pnum].destAction = ACTION_NONE; - plr[pnum]._pLvlChanging = 1; + ClrPlrPath(pnum); + plr[pnum].destAction = ACTION_NONE; + plr[pnum]._pLvlChanging = 1; - if ( pnum == myplr ) { - plr[pnum].pLvlLoad = 10; - } + if (pnum == myplr) { + plr[pnum].pLvlLoad = 10; + } } // 646D00: using guessed type char qtextflag; void __fastcall StartNewLvl(int pnum, int fom, int lvl) { - InitLevelChange(pnum); - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("StartNewLvl: illegal player %d", pnum); - } - - switch ( fom ) { - case WM_DIABNEXTLVL: - case WM_DIABPREVLVL: - plr[pnum].plrlevel = lvl; - break; - case WM_DIABRTNLVL: - case WM_DIABTOWNWARP: - plr[pnum].plrlevel = lvl; - break; - case WM_DIABSETLVL: - setlvlnum = lvl; - break; - case WM_DIABTWARPUP: - plr[myplr].pTownWarps |= 1 << (leveltype - 2); - plr[pnum].plrlevel = lvl; - break; - case WM_DIABRETOWN: - break; - default: - TermMsg("StartNewLvl"); - break; - } - - if ( pnum == myplr ) { - plr[pnum]._pmode = PM_NEWLVL; - plr[pnum]._pInvincible = TRUE; - PostMessage(ghMainWnd, fom, 0, 0); - if ( gbMaxPlayers > 1 ) { - NetSendCmdParam2(TRUE, CMD_NEWLVL, fom, lvl); - } - } + InitLevelChange(pnum); + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("StartNewLvl: illegal player %d", pnum); + } + + switch (fom) { + case WM_DIABNEXTLVL: + case WM_DIABPREVLVL: + plr[pnum].plrlevel = lvl; + break; + case WM_DIABRTNLVL: + case WM_DIABTOWNWARP: + plr[pnum].plrlevel = lvl; + break; + case WM_DIABSETLVL: + setlvlnum = lvl; + break; + case WM_DIABTWARPUP: + plr[myplr].pTownWarps |= 1 << (leveltype - 2); + plr[pnum].plrlevel = lvl; + break; + case WM_DIABRETOWN: + break; + default: + TermMsg("StartNewLvl"); + break; + } + + if (pnum == myplr) { + plr[pnum]._pmode = PM_NEWLVL; + plr[pnum]._pInvincible = TRUE; + PostMessage(ghMainWnd, fom, 0, 0); + if (gbMaxPlayers > 1) { + NetSendCmdParam2(TRUE, CMD_NEWLVL, fom, lvl); + } + } } // 5BB1ED: using guessed type char leveltype; // 5CCB10: using guessed type char setlvlnum; @@ -2002,2092 +1996,2081 @@ void __fastcall StartNewLvl(int pnum, int fom, int lvl) void __fastcall RestartTownLvl(int pnum) { - InitLevelChange(pnum); - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("RestartTownLvl: illegal player %d", pnum); - } + InitLevelChange(pnum); + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("RestartTownLvl: illegal player %d", pnum); + } - plr[pnum].plrlevel = 0; - plr[pnum]._pInvincible = FALSE; + plr[pnum].plrlevel = 0; + plr[pnum]._pInvincible = FALSE; - SetPlayerHitPoints(pnum, 64); + SetPlayerHitPoints(pnum, 64); - plr[pnum]._pMana = 0; - plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase - plr[pnum]._pMaxMana; + plr[pnum]._pMana = 0; + plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase - plr[pnum]._pMaxMana; - CalcPlrInv(pnum, FALSE); + CalcPlrInv(pnum, FALSE); - if ( pnum == myplr ) { - plr[pnum]._pmode = PM_NEWLVL; - plr[pnum]._pInvincible = TRUE; - PostMessage(ghMainWnd, WM_DIABRETOWN, 0, 0); - } + if (pnum == myplr) { + plr[pnum]._pmode = PM_NEWLVL; + plr[pnum]._pInvincible = TRUE; + PostMessage(ghMainWnd, WM_DIABRETOWN, 0, 0); + } } void __fastcall StartWarpLvl(int pnum, int pidx) { - InitLevelChange(pnum); + InitLevelChange(pnum); - if ( gbMaxPlayers != 1 ) { - if ( plr[pnum].plrlevel != 0 ) { - plr[pnum].plrlevel = 0; - } else { - plr[pnum].plrlevel = portal[pidx].level; - } - } + if (gbMaxPlayers != 1) { + if (plr[pnum].plrlevel != 0) { + plr[pnum].plrlevel = 0; + } else { + plr[pnum].plrlevel = portal[pidx].level; + } + } - if ( pnum == myplr ) { - SetCurrentPortal(pidx); - plr[pnum]._pmode = PM_NEWLVL; - plr[pnum]._pInvincible = TRUE; - PostMessage(ghMainWnd, WM_DIABWARPLVL, 0, 0); - } + if (pnum == myplr) { + SetCurrentPortal(pidx); + plr[pnum]._pmode = PM_NEWLVL; + plr[pnum]._pInvincible = TRUE; + PostMessage(ghMainWnd, WM_DIABWARPLVL, 0, 0); + } } // 679660: using guessed type char gbMaxPlayers; BOOL __fastcall PM_DoStand(int pnum) { - return FALSE; + return FALSE; } BOOL __fastcall PM_DoWalk(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_DoWalk: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoWalk: illegal player %d", pnum); + } + + if (plr[pnum]._pAnimFrame == 3 + || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) + || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4)) { + PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); + } + + int vel = 8; + if (currlevel != 0) { + vel = PWVel[3][plr[pnum]._pClass]; + } + + if (plr[pnum]._pVar8 == vel) { + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = 0; + plr[pnum].WorldX += plr[pnum]._pVar1; + plr[pnum].WorldY += plr[pnum]._pVar2; + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; + + if (leveltype != DTYPE_TOWN) { + ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); + ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); + } + + if (pnum == myplr && ScrollInfo._sdir) { + ViewX = plr[pnum].WorldX - ScrollInfo._sdx; + ViewY = plr[pnum].WorldY - ScrollInfo._sdy; + } + + if (plr[pnum].walkpath[0] != WALK_NONE) { + StartWalkStand(pnum); + } else { + StartStand(pnum, plr[pnum]._pVar3); + } + + ClearPlrPVars(pnum); + if (leveltype != DTYPE_TOWN) { + ChangeLightOff(plr[pnum]._plid, 0, 0); + } + + return TRUE; + } + + PM_ChangeOffset(pnum); + return FALSE; +} +// 5BB1ED: using guessed type char leveltype; - if ( plr[pnum]._pAnimFrame == 3 - || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) - || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4) - ) { - PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); - } +BOOL __fastcall PM_DoWalk2(int pnum) +{ + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoWalk2: illegal player %d", pnum); + } - int vel = 8; - if ( currlevel != 0 ) { - vel = PWVel[3][plr[pnum]._pClass]; - } + if (plr[pnum]._pAnimFrame == 3 + || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) + || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4)) { + PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); + } - if ( plr[pnum]._pVar8 == vel ) { - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = 0; - plr[pnum].WorldX += plr[pnum]._pVar1; - plr[pnum].WorldY += plr[pnum]._pVar2; - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = pnum + 1; + int vel = 8; + if (currlevel != 0) { + vel = PWVel[3][plr[pnum]._pClass]; + } - if ( leveltype != DTYPE_TOWN ) { - ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); - ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (plr[pnum]._pVar8 == vel) { + dPlayer[plr[pnum]._pVar1][plr[pnum]._pVar2] = 0; + if (leveltype != DTYPE_TOWN) { + ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); + ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); + } - if ( pnum == myplr && ScrollInfo._sdir ) { - ViewX = plr[pnum].WorldX - ScrollInfo._sdx; - ViewY = plr[pnum].WorldY - ScrollInfo._sdy; - } + if (pnum == myplr && ScrollInfo._sdir) { + ViewX = plr[pnum].WorldX - ScrollInfo._sdx; + ViewY = plr[pnum].WorldY - ScrollInfo._sdy; + } - if ( plr[pnum].walkpath[0] != WALK_NONE ) { - StartWalkStand(pnum); - } else { - StartStand(pnum, plr[pnum]._pVar3); - } + if (plr[pnum].walkpath[0] != WALK_NONE) { + StartWalkStand(pnum); + } else { + StartStand(pnum, plr[pnum]._pVar3); + } - ClearPlrPVars(pnum); - if ( leveltype != DTYPE_TOWN ) { - ChangeLightOff(plr[pnum]._plid, 0, 0); - } + ClearPlrPVars(pnum); - return TRUE; - } + if (leveltype != DTYPE_TOWN) { + ChangeLightOff(plr[pnum]._plid, 0, 0); + } - PM_ChangeOffset(pnum); - return FALSE; + return TRUE; + } + PM_ChangeOffset(pnum); + return FALSE; } // 5BB1ED: using guessed type char leveltype; -BOOL __fastcall PM_DoWalk2(int pnum) +BOOL __fastcall PM_DoWalk3(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_DoWalk2: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoWalk3: illegal player %d", pnum); + } - if ( plr[pnum]._pAnimFrame == 3 - || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) - || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4) - ) { - PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (plr[pnum]._pAnimFrame == 3 + || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) + || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4)) { + PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); + } - int vel = 8; - if ( currlevel != 0 ) { - vel = PWVel[3][plr[pnum]._pClass]; - } + int vel = 8; + if (currlevel != 0) { + vel = PWVel[3][plr[pnum]._pClass]; + } - if ( plr[pnum]._pVar8 == vel ) { - dPlayer[plr[pnum]._pVar1][plr[pnum]._pVar2] = 0; - if ( leveltype != DTYPE_TOWN ) { - ChangeLightXY(plr[pnum]._plid, plr[pnum].WorldX, plr[pnum].WorldY); - ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); - } + if (plr[pnum]._pVar8 == vel) { + dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = 0; + dFlags[plr[pnum]._pVar4][plr[pnum]._pVar5] &= ~DFLAG_PLAYER; + plr[pnum].WorldX = plr[pnum]._pVar1; + plr[pnum].WorldY = plr[pnum]._pVar2; + dPlayer[plr[pnum]._pVar1][plr[pnum]._pVar2] = pnum + 1; - if ( pnum == myplr && ScrollInfo._sdir ) { - ViewX = plr[pnum].WorldX - ScrollInfo._sdx; - ViewY = plr[pnum].WorldY - ScrollInfo._sdy; - } + if (leveltype != DTYPE_TOWN) { + ChangeLightXY(plr[pnum]._plid, plr[pnum]._pVar1, plr[pnum]._pVar2); + ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); + } - if ( plr[pnum].walkpath[0] != WALK_NONE ) { - StartWalkStand(pnum); - } else { - StartStand(pnum, plr[pnum]._pVar3); - } + if (pnum == myplr && ScrollInfo._sdir) { + ViewX = plr[pnum].WorldX - ScrollInfo._sdx; + ViewY = plr[pnum].WorldY - ScrollInfo._sdy; + } - ClearPlrPVars(pnum); + if (plr[pnum].walkpath[0] != WALK_NONE) { + StartWalkStand(pnum); + } else { + StartStand(pnum, plr[pnum]._pVar3); + } - if ( leveltype != DTYPE_TOWN ) { - ChangeLightOff(plr[pnum]._plid, 0, 0); - } + ClearPlrPVars(pnum); - return TRUE; - } + if (leveltype != DTYPE_TOWN) { + ChangeLightOff(plr[pnum]._plid, 0, 0); + } - PM_ChangeOffset(pnum); - return FALSE; -} -// 5BB1ED: using guessed type char leveltype; + return TRUE; + } -BOOL __fastcall PM_DoWalk3(int pnum) -{ - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_DoWalk3: illegal player %d", pnum); - } - - if ( plr[pnum]._pAnimFrame == 3 - || (plr[pnum]._pWFrames == 8 && plr[pnum]._pAnimFrame == 7) - || (plr[pnum]._pWFrames != 8 && plr[pnum]._pAnimFrame == 4) - ) { - PlaySfxLoc(PS_WALK1, plr[pnum].WorldX, plr[pnum].WorldY); - } - - int vel = 8; - if ( currlevel != 0 ) { - vel = PWVel[3][plr[pnum]._pClass]; - } - - if ( plr[pnum]._pVar8 == vel ) { - dPlayer[plr[pnum].WorldX][plr[pnum].WorldY] = 0; - dFlags[plr[pnum]._pVar4][plr[pnum]._pVar5] &= ~DFLAG_PLAYER; - plr[pnum].WorldX = plr[pnum]._pVar1; - plr[pnum].WorldY = plr[pnum]._pVar2; - dPlayer[plr[pnum]._pVar1][plr[pnum]._pVar2] = pnum + 1; - - if ( leveltype != DTYPE_TOWN ) { - ChangeLightXY(plr[pnum]._plid, plr[pnum]._pVar1, plr[pnum]._pVar2); - ChangeVisionXY(plr[pnum]._pvid, plr[pnum].WorldX, plr[pnum].WorldY); - } - - if ( pnum == myplr && ScrollInfo._sdir ) { - ViewX = plr[pnum].WorldX - ScrollInfo._sdx; - ViewY = plr[pnum].WorldY - ScrollInfo._sdy; - } - - if ( plr[pnum].walkpath[0] != WALK_NONE ) { - StartWalkStand(pnum); - } else { - StartStand(pnum, plr[pnum]._pVar3); - } - - ClearPlrPVars(pnum); - - if ( leveltype != DTYPE_TOWN ) { - ChangeLightOff(plr[pnum]._plid, 0, 0); - } - - return TRUE; - } - - PM_ChangeOffset(pnum); - return FALSE; + PM_ChangeOffset(pnum); + return FALSE; } // 5BB1ED: using guessed type char leveltype; BOOL __fastcall WeaponDur(int pnum, int durrnd) { - if ( pnum != myplr ) { - return FALSE; - } - - if ( random(3, durrnd) != 0 ) { - return FALSE; - } - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("WeaponDur: illegal player %d", pnum); - } - - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON ) { - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE ) { - return FALSE; - } - - plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); - plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - return TRUE; - } - } - - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON ) { - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE ) { - return FALSE; - } - - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0 ) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - return TRUE; - } - } - - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD ) { - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE ) { - return FALSE; - } - - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0 ) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - return TRUE; - } - } - - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD ) { - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE ) { - return FALSE; - } - - plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0 ) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); - plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - return TRUE; - } - } - - return FALSE; + if (pnum != myplr) { + return FALSE; + } + + if (random(3, durrnd) != 0) { + return FALSE; + } + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("WeaponDur: illegal player %d", pnum); + } + + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON) { + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { + return FALSE; + } + + plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); + plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + return TRUE; + } + } + + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON) { + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { + return FALSE; + } + + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + return TRUE; + } + } + + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD) { + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == DUR_INDESTRUCTIBLE) { + return FALSE; + } + + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + return TRUE; + } + } + + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD) { + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { + return FALSE; + } + + plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); + plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + return TRUE; + } + } + + return FALSE; } BOOL __fastcall PlrHitMonst(int pnum, int m) { - if ( (DWORD)m >= MAXMONSTERS ) { - TermMsg("PlrHitMonst: illegal monster %d", m); - } - - if ( (monster[m]._mhitpoints >> 6) <= 0 ) { - return FALSE; - } - - if ( monster[m].MType->mtype == MT_ILLWEAV && monster[m]._mgoal == 2 ) { - return FALSE; - } - - if ( monster[m]._mmode == MM_CHARGE ) { - return FALSE; - } - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PlrHitMonst: illegal player %d", pnum); - } - - BOOL rv = FALSE; - - int hit = random(4, 100); - if ( monster[m]._mmode == MM_STONE ) { - hit = 0; - } - - int hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (monster[m].mArmorClass - plr[pnum]._pIEnAc); - if ( plr[pnum]._pClass == PC_WARRIOR ) { - hper += 20; - } - hper += plr[pnum]._pIBonusToHit; - if ( hper < 5 ) { - hper = 5; - } - if ( hper > 95 ) { - hper = 95; - } - - BOOL ret; - if ( CheckMonsterHit(m, &ret) ) { - return ret; - } + if ((DWORD)m >= MAXMONSTERS) { + TermMsg("PlrHitMonst: illegal monster %d", m); + } + + if ((monster[m]._mhitpoints >> 6) <= 0) { + return FALSE; + } + + if (monster[m].MType->mtype == MT_ILLWEAV && monster[m]._mgoal == 2) { + return FALSE; + } + + if (monster[m]._mmode == MM_CHARGE) { + return FALSE; + } + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrHitMonst: illegal player %d", pnum); + } + + BOOL rv = FALSE; + + int hit = random(4, 100); + if (monster[m]._mmode == MM_STONE) { + hit = 0; + } + + int hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (monster[m].mArmorClass - plr[pnum]._pIEnAc); + if (plr[pnum]._pClass == PC_WARRIOR) { + hper += 20; + } + hper += plr[pnum]._pIBonusToHit; + if (hper < 5) { + hper = 5; + } + if (hper > 95) { + hper = 95; + } + + BOOL ret; + if (CheckMonsterHit(m, &ret)) { + return ret; + } #ifdef _DEBUG - if ( hit < hper || debug_mode_key_inverted_v || debug_mode_dollar_sign ) { + if (hit < hper || debug_mode_key_inverted_v || debug_mode_dollar_sign) { #else - if ( hit < hper ) { + if (hit < hper) { #endif - int mind = plr[pnum]._pIMinDam; - int maxd = random(5, plr[pnum]._pIMaxDam - mind + 1); - int dam = maxd + mind; - dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100; - if ( plr[pnum]._pClass == PC_WARRIOR ) { - int lvl = plr[pnum]._pLevel; - if ( random(6, 100) < lvl ) { - dam *= 2; - } - } - - int phanditype = ITYPE_NONE; - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SWORD ) { - phanditype = ITYPE_SWORD; - } - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_MACE || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_MACE ) { - phanditype = ITYPE_MACE; - } - - int mClass = monster[m].MData->mMonstClass; - switch ( mClass ) { - case MC_UNDEAD: - if ( phanditype == ITYPE_SWORD ) { - dam -= dam >> 1; - } - if ( phanditype == ITYPE_MACE ) { - dam += dam >> 1; - } - break; - case MC_ANIMAL: - if ( phanditype == ITYPE_MACE ) { - dam -= dam >> 1; - } - if ( phanditype == ITYPE_SWORD ) { - dam += dam >> 1; - } - break; - } - - if ( plr[pnum]._pIFlags & ISPL_3XDAMVDEM && monster[m].MData->mMonstClass == MC_DEMON ) { - dam *= 3; - } - - int skdam = dam << 6; - if ( pnum == myplr ) { - monster[m]._mhitpoints -= skdam; - } - - int tac; - if ( plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE ) { - tac = random(7, skdam >> 3); - plr[pnum]._pHitPoints += tac; - if ( plr[pnum]._pHitPoints > plr[pnum]._pMaxHP ) { - plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; - } - plr[pnum]._pHPBase += tac; - if ( plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase ) { - plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; - } - drawhpflag = TRUE; - } - if ( plr[pnum]._pIFlags & (ISPL_STEALMANA_3 | ISPL_STEALMANA_5) && !(plr[pnum]._pIFlags & ISPL_NOMANA) ) { - if ( plr[pnum]._pIFlags & ISPL_STEALMANA_3 ) { - tac = 3 * skdam / 100; - } - if ( plr[pnum]._pIFlags & ISPL_STEALMANA_5 ) { - tac = 5 * skdam / 100; - } - plr[pnum]._pMana += tac; - if ( plr[pnum]._pMana > plr[pnum]._pMaxMana ) { - plr[pnum]._pMana = plr[pnum]._pMaxMana; - } - plr[pnum]._pManaBase += tac; - if ( plr[pnum]._pManaBase > plr[pnum]._pMaxManaBase ) { - plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; - } - drawmanaflag = TRUE; - } - if ( plr[pnum]._pIFlags & (ISPL_STEALLIFE_3 | ISPL_STEALLIFE_5) ) { - if ( plr[pnum]._pIFlags & ISPL_STEALLIFE_3 ) { - tac = 3 * skdam / 100; - } - if ( plr[pnum]._pIFlags & ISPL_STEALLIFE_5 ) { - tac = 5 * skdam / 100; - } - plr[pnum]._pHitPoints += tac; - if ( plr[pnum]._pHitPoints > plr[pnum]._pMaxHP ) { - plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; - } - plr[pnum]._pHPBase += tac; - if ( plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase ) { - plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; - } - drawhpflag = TRUE; - } - if ( plr[pnum]._pIFlags & ISPL_NOHEALPLR ) { - monster[m]._mFlags |= 8; - } + int mind = plr[pnum]._pIMinDam; + int maxd = random(5, plr[pnum]._pIMaxDam - mind + 1); + int dam = maxd + mind; + dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100; + if (plr[pnum]._pClass == PC_WARRIOR) { + int lvl = plr[pnum]._pLevel; + if (random(6, 100) < lvl) { + dam *= 2; + } + } + + int phanditype = ITYPE_NONE; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SWORD || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SWORD) { + phanditype = ITYPE_SWORD; + } + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_MACE || plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_MACE) { + phanditype = ITYPE_MACE; + } + + int mClass = monster[m].MData->mMonstClass; + switch (mClass) { + case MC_UNDEAD: + if (phanditype == ITYPE_SWORD) { + dam -= dam >> 1; + } + if (phanditype == ITYPE_MACE) { + dam += dam >> 1; + } + break; + case MC_ANIMAL: + if (phanditype == ITYPE_MACE) { + dam -= dam >> 1; + } + if (phanditype == ITYPE_SWORD) { + dam += dam >> 1; + } + break; + } + + if (plr[pnum]._pIFlags & ISPL_3XDAMVDEM && monster[m].MData->mMonstClass == MC_DEMON) { + dam *= 3; + } + + int skdam = dam << 6; + if (pnum == myplr) { + monster[m]._mhitpoints -= skdam; + } + + int tac; + if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) { + tac = random(7, skdam >> 3); + plr[pnum]._pHitPoints += tac; + if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; + } + plr[pnum]._pHPBase += tac; + if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; + } + drawhpflag = TRUE; + } + if (plr[pnum]._pIFlags & (ISPL_STEALMANA_3 | ISPL_STEALMANA_5) && !(plr[pnum]._pIFlags & ISPL_NOMANA)) { + if (plr[pnum]._pIFlags & ISPL_STEALMANA_3) { + tac = 3 * skdam / 100; + } + if (plr[pnum]._pIFlags & ISPL_STEALMANA_5) { + tac = 5 * skdam / 100; + } + plr[pnum]._pMana += tac; + if (plr[pnum]._pMana > plr[pnum]._pMaxMana) { + plr[pnum]._pMana = plr[pnum]._pMaxMana; + } + plr[pnum]._pManaBase += tac; + if (plr[pnum]._pManaBase > plr[pnum]._pMaxManaBase) { + plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; + } + drawmanaflag = TRUE; + } + if (plr[pnum]._pIFlags & (ISPL_STEALLIFE_3 | ISPL_STEALLIFE_5)) { + if (plr[pnum]._pIFlags & ISPL_STEALLIFE_3) { + tac = 3 * skdam / 100; + } + if (plr[pnum]._pIFlags & ISPL_STEALLIFE_5) { + tac = 5 * skdam / 100; + } + plr[pnum]._pHitPoints += tac; + if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; + } + plr[pnum]._pHPBase += tac; + if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; + } + drawhpflag = TRUE; + } + if (plr[pnum]._pIFlags & ISPL_NOHEALPLR) { + monster[m]._mFlags |= 8; + } #ifdef _DEBUG - if ( debug_mode_dollar_sign || debug_mode_key_inverted_v ) { - monster[m]._mhitpoints = 0; /* double check */ - } + if (debug_mode_dollar_sign || debug_mode_key_inverted_v) { + monster[m]._mhitpoints = 0; /* double check */ + } #endif - if ( (monster[m]._mhitpoints >> 6) <= 0) { - if ( monster[m]._mmode == MM_STONE ) { - M_StartKill(m, pnum); - monster[m]._mmode = MM_STONE; - } else { - M_StartKill(m, pnum); - } - } else { - if ( monster[m]._mmode == MM_STONE ) { - M_StartHit(m, pnum, skdam); - monster[m]._mmode = MM_STONE; - } else { - if ( plr[pnum]._pIFlags & ISPL_KNOCKBACK ) { - M_GetKnockback(m); - } - M_StartHit(m, pnum, skdam); - } - } - rv = TRUE; - } - - return rv; + if ((monster[m]._mhitpoints >> 6) <= 0) { + if (monster[m]._mmode == MM_STONE) { + M_StartKill(m, pnum); + monster[m]._mmode = MM_STONE; + } else { + M_StartKill(m, pnum); + } + } else { + if (monster[m]._mmode == MM_STONE) { + M_StartHit(m, pnum, skdam); + monster[m]._mmode = MM_STONE; + } else { + if (plr[pnum]._pIFlags & ISPL_KNOCKBACK) { + M_GetKnockback(m); + } + M_StartHit(m, pnum, skdam); + } + } + rv = TRUE; + } + + return rv; } BOOL __fastcall PlrHitPlr(int pnum, char p) { - if ( (DWORD)p >= MAX_PLRS ) { - TermMsg("PlrHitPlr: illegal target player %d", p); - } - - BOOL rv = FALSE; - - if ( plr[p]._pInvincible ) { - return rv; - } - - if ( plr[p]._pSpellFlags & 1 ) { - return rv; - } - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PlrHitPlr: illegal attacking player %d", pnum); - } - - int hit = random(4, 100); - - int hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (plr[p]._pIBonusAC + plr[p]._pIAC + plr[p]._pDexterity / 5); - - if ( plr[pnum]._pClass == PC_WARRIOR ) { - hper += 20; - } - hper += plr[pnum]._pIBonusToHit; - if ( hper < 5 ) { - hper = 5; - } - if ( hper > 95 ) { - hper = 95; - } - - int blk; - if ( (plr[p]._pmode == PM_STAND || plr[p]._pmode == PM_ATTACK) && plr[p]._pBlockFlag ) { - blk = random(5, 100); - } else { - blk = 100; - } - - int blkper = plr[p]._pDexterity + plr[p]._pBaseToBlk + (plr[p]._pLevel << 1) - (plr[pnum]._pLevel << 1); - if ( blkper < 0 ) { - blkper = 0; - } - if ( blkper > 100 ) { - blkper = 100; - } - - if ( hit < hper ) { - if ( blk < blkper ) { - int dir = GetDirection(plr[p].WorldX, plr[p].WorldY, plr[pnum].WorldX, plr[pnum].WorldY); - StartPlrBlock(p, dir); - } else { - int mind = plr[pnum]._pIMinDam; - int maxd = random(5, plr[pnum]._pIMaxDam - mind + 1); - int dam = maxd + mind; - dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100; - - if ( plr[pnum]._pClass == PC_WARRIOR ) { - int lvl = plr[pnum]._pLevel; - if ( random(6, 100) < lvl) { - dam *= 2; - } - } - int skdam = dam << 6; - if ( plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE ) { - int tac = random(7, skdam >> 3); - plr[pnum]._pHitPoints += tac; - if ( plr[pnum]._pHitPoints > plr[pnum]._pMaxHP ) { - plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; - } - plr[pnum]._pHPBase += tac; - if ( plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase ) { - plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; - } - drawhpflag = TRUE; - } - if ( pnum == myplr ) { - NetSendCmdDamage(TRUE, p, skdam); - } - StartPlrHit(p, skdam, FALSE); - } - - rv = TRUE; - } - - return rv; + if ((DWORD)p >= MAX_PLRS) { + TermMsg("PlrHitPlr: illegal target player %d", p); + } + + BOOL rv = FALSE; + + if (plr[p]._pInvincible) { + return rv; + } + + if (plr[p]._pSpellFlags & 1) { + return rv; + } + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrHitPlr: illegal attacking player %d", pnum); + } + + int hit = random(4, 100); + + int hper = (plr[pnum]._pDexterity >> 1) + plr[pnum]._pLevel + 50 - (plr[p]._pIBonusAC + plr[p]._pIAC + plr[p]._pDexterity / 5); + + if (plr[pnum]._pClass == PC_WARRIOR) { + hper += 20; + } + hper += plr[pnum]._pIBonusToHit; + if (hper < 5) { + hper = 5; + } + if (hper > 95) { + hper = 95; + } + + int blk; + if ((plr[p]._pmode == PM_STAND || plr[p]._pmode == PM_ATTACK) && plr[p]._pBlockFlag) { + blk = random(5, 100); + } else { + blk = 100; + } + + int blkper = plr[p]._pDexterity + plr[p]._pBaseToBlk + (plr[p]._pLevel << 1) - (plr[pnum]._pLevel << 1); + if (blkper < 0) { + blkper = 0; + } + if (blkper > 100) { + blkper = 100; + } + + if (hit < hper) { + if (blk < blkper) { + int dir = GetDirection(plr[p].WorldX, plr[p].WorldY, plr[pnum].WorldX, plr[pnum].WorldY); + StartPlrBlock(p, dir); + } else { + int mind = plr[pnum]._pIMinDam; + int maxd = random(5, plr[pnum]._pIMaxDam - mind + 1); + int dam = maxd + mind; + dam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + dam * plr[pnum]._pIBonusDam / 100; + + if (plr[pnum]._pClass == PC_WARRIOR) { + int lvl = plr[pnum]._pLevel; + if (random(6, 100) < lvl) { + dam *= 2; + } + } + int skdam = dam << 6; + if (plr[pnum]._pIFlags & ISPL_RNDSTEALLIFE) { + int tac = random(7, skdam >> 3); + plr[pnum]._pHitPoints += tac; + if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; + } + plr[pnum]._pHPBase += tac; + if (plr[pnum]._pHPBase > plr[pnum]._pMaxHPBase) { + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; + } + drawhpflag = TRUE; + } + if (pnum == myplr) { + NetSendCmdDamage(TRUE, p, skdam); + } + StartPlrHit(p, skdam, FALSE); + } + + rv = TRUE; + } + + return rv; } BOOL __fastcall PlrHitObj(int pnum, int mx, int my) { - int oi; + int oi; - if ( dObject[mx][my] > 0 ) { - oi = dObject[mx][my] - 1; - } else { - oi = -dObject[mx][my] - 1; - } + if (dObject[mx][my] > 0) { + oi = dObject[mx][my] - 1; + } else { + oi = -dObject[mx][my] - 1; + } - if ( object[oi]._oBreak == 1 ) { - BreakObject(pnum, oi); - return TRUE; - } + if (object[oi]._oBreak == 1) { + BreakObject(pnum, oi); + return TRUE; + } - return FALSE; + return FALSE; } BOOL __fastcall PM_DoAttack(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_DoAttack: illegal player %d", pnum); - } - - int frame = plr[pnum]._pAnimFrame; - if ( plr[pnum]._pIFlags & ISPL_QUICKATTACK && frame == 1 ) { - plr[pnum]._pAnimFrame++; - } - if ( plr[pnum]._pIFlags & ISPL_FASTATTACK && (frame == 1 || frame == 3) ) { - plr[pnum]._pAnimFrame++; - } - if ( plr[pnum]._pIFlags & ISPL_FASTERATTACK && (frame == 1 || frame == 3 || frame == 5) ) { - plr[pnum]._pAnimFrame++; - } - if ( plr[pnum]._pIFlags & ISPL_FASTESTATTACK && (frame == 1 || frame == 4) ) { - plr[pnum]._pAnimFrame += 2; - } - if ( plr[pnum]._pAnimFrame == plr[pnum]._pAFNum - 1 ) { - PlaySfxLoc(PS_SWING, plr[pnum].WorldX, plr[pnum].WorldY); - } - - if ( plr[pnum]._pAnimFrame == plr[pnum]._pAFNum ) { - int dir = plr[pnum]._pdir; - int dx = plr[pnum].WorldX + offset_x[dir]; - int dy = plr[pnum].WorldY + offset_y[dir]; - - int m; - if (dMonster[dx][dy]) { - if ( dMonster[dx][dy] > 0 ) { - m = dMonster[dx][dy] - 1; - } else { - m = -(dMonster[dx][dy] + 1); - } - if ( CanTalkToMonst(m) ) { - plr[pnum]._pVar1 = 0; - return FALSE; - } - } - - if ( plr[pnum]._pIFlags & ISPL_FIREDAM ) { - AddMissile(dx, dy, 1, 0, 0, MIS_WEAPEXP, 0, pnum, 0, 0); - } - if ( plr[pnum]._pIFlags & ISPL_LIGHTDAM ) { - AddMissile(dx, dy, 2, 0, 0, MIS_WEAPEXP, 0, pnum, 0, 0); - } - - BOOL didhit = FALSE; - if ( dMonster[dx][dy] ) { - m = dMonster[dx][dy]; - if ( dMonster[dx][dy] > 0 ) { - m = dMonster[dx][dy] - 1; - } else { - m = -(dMonster[dx][dy] + 1); - } - didhit = PlrHitMonst(pnum, m); - } else if ( dPlayer[dx][dy] && !FriendlyMode ) { - UCHAR p = dPlayer[dx][dy]; - if ( dPlayer[dx][dy] > 0 ) { - p = dPlayer[dx][dy] - 1; - } else { - p = -(dPlayer[dx][dy] + 1); - } - didhit = PlrHitPlr(pnum, p); - } else if ( dObject[dx][dy] > 0 ) { - didhit = PlrHitObj(pnum, dx, dy); - } - - if ( didhit && WeaponDur(pnum, 30) ) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } - } - - if ( plr[pnum]._pAnimFrame == plr[pnum]._pAFrames ) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } else { - return FALSE; - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoAttack: illegal player %d", pnum); + } + + int frame = plr[pnum]._pAnimFrame; + if (plr[pnum]._pIFlags & ISPL_QUICKATTACK && frame == 1) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTATTACK && (frame == 1 || frame == 3)) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTERATTACK && (frame == 1 || frame == 3 || frame == 5)) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTESTATTACK && (frame == 1 || frame == 4)) { + plr[pnum]._pAnimFrame += 2; + } + if (plr[pnum]._pAnimFrame == plr[pnum]._pAFNum - 1) { + PlaySfxLoc(PS_SWING, plr[pnum].WorldX, plr[pnum].WorldY); + } + + if (plr[pnum]._pAnimFrame == plr[pnum]._pAFNum) { + int dir = plr[pnum]._pdir; + int dx = plr[pnum].WorldX + offset_x[dir]; + int dy = plr[pnum].WorldY + offset_y[dir]; + + int m; + if (dMonster[dx][dy]) { + if (dMonster[dx][dy] > 0) { + m = dMonster[dx][dy] - 1; + } else { + m = -(dMonster[dx][dy] + 1); + } + if (CanTalkToMonst(m)) { + plr[pnum]._pVar1 = 0; + return FALSE; + } + } + + if (plr[pnum]._pIFlags & ISPL_FIREDAM) { + AddMissile(dx, dy, 1, 0, 0, MIS_WEAPEXP, 0, pnum, 0, 0); + } + if (plr[pnum]._pIFlags & ISPL_LIGHTDAM) { + AddMissile(dx, dy, 2, 0, 0, MIS_WEAPEXP, 0, pnum, 0, 0); + } + + BOOL didhit = FALSE; + if (dMonster[dx][dy]) { + m = dMonster[dx][dy]; + if (dMonster[dx][dy] > 0) { + m = dMonster[dx][dy] - 1; + } else { + m = -(dMonster[dx][dy] + 1); + } + didhit = PlrHitMonst(pnum, m); + } else if (dPlayer[dx][dy] && !FriendlyMode) { + UCHAR p = dPlayer[dx][dy]; + if (dPlayer[dx][dy] > 0) { + p = dPlayer[dx][dy] - 1; + } else { + p = -(dPlayer[dx][dy] + 1); + } + didhit = PlrHitPlr(pnum, p); + } else if (dObject[dx][dy] > 0) { + didhit = PlrHitObj(pnum, dx, dy); + } + + if (didhit && WeaponDur(pnum, 30)) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } + } + + if (plr[pnum]._pAnimFrame == plr[pnum]._pAFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } else { + return FALSE; + } } // 484368: using guessed type int FriendlyMode; BOOL __fastcall PM_DoRangeAttack(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_DoRangeAttack: illegal player %d", pnum); - } - - int origFrame = plr[pnum]._pAnimFrame; - if ( plr[pnum]._pIFlags & ISPL_QUICKATTACK && origFrame == 1 ) { - plr[pnum]._pAnimFrame++; - } - if ( plr[pnum]._pIFlags & ISPL_FASTATTACK && (origFrame == 1 || origFrame == 3) ) { - plr[pnum]._pAnimFrame++; - } - - if ( plr[pnum]._pAnimFrame == plr[pnum]._pAFNum ) { - int mistype = MIS_ARROW; - if ( plr[pnum]._pIFlags & ISPL_FIRE_ARROWS ) { - mistype = MIS_FARROW; - } - if ( plr[pnum]._pIFlags & ISPL_LIGHT_ARROWS ) { - mistype = MIS_LARROW; - } - AddMissile( - plr[pnum].WorldX, - plr[pnum].WorldY, - plr[pnum]._pVar1, - plr[pnum]._pVar2, - plr[pnum]._pdir, - mistype, - 0, - pnum, - 4, - 0 - ); - - PlaySfxLoc(PS_BFIRE, plr[pnum].WorldX, plr[pnum].WorldY); - - if ( WeaponDur(pnum, 40) ) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } - } - - if ( plr[pnum]._pAnimFrame >= plr[pnum]._pAFrames ) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } else { - return FALSE; - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoRangeAttack: illegal player %d", pnum); + } + + int origFrame = plr[pnum]._pAnimFrame; + if (plr[pnum]._pIFlags & ISPL_QUICKATTACK && origFrame == 1) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTATTACK && (origFrame == 1 || origFrame == 3)) { + plr[pnum]._pAnimFrame++; + } + + if (plr[pnum]._pAnimFrame == plr[pnum]._pAFNum) { + int mistype = MIS_ARROW; + if (plr[pnum]._pIFlags & ISPL_FIRE_ARROWS) { + mistype = MIS_FARROW; + } + if (plr[pnum]._pIFlags & ISPL_LIGHT_ARROWS) { + mistype = MIS_LARROW; + } + AddMissile( + plr[pnum].WorldX, + plr[pnum].WorldY, + plr[pnum]._pVar1, + plr[pnum]._pVar2, + plr[pnum]._pdir, + mistype, + 0, + pnum, + 4, + 0); + + PlaySfxLoc(PS_BFIRE, plr[pnum].WorldX, plr[pnum].WorldY); + + if (WeaponDur(pnum, 40)) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } + } + + if (plr[pnum]._pAnimFrame >= plr[pnum]._pAFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } else { + return FALSE; + } } void __fastcall ShieldDur(int pnum) { - if ( pnum != myplr ) { - return; - } - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("ShieldDur: illegal player %d", pnum); - } - - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD ) { - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE ) { - return; - } - - plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0 ) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); - plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - } - } - - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD ) { - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability != DUR_INDESTRUCTIBLE ) { - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; - if ( plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0 ) { - NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); - plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); - } - } - } + if (pnum != myplr) { + return; + } + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ShieldDur: illegal player %d", pnum); + } + + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD) { + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == DUR_INDESTRUCTIBLE) { + return; + } + + plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_LEFT); + plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + } + } + + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD) { + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability != DUR_INDESTRUCTIBLE) { + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability--; + if (plr[pnum].InvBody[INVLOC_HAND_RIGHT]._iDurability == 0) { + NetSendCmdDelItem(TRUE, INVLOC_HAND_RIGHT); + plr[pnum].InvBody[INVLOC_HAND_RIGHT]._itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); + } + } + } } BOOL __fastcall PM_DoBlock(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_DoBlock: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoBlock: illegal player %d", pnum); + } - if ( plr[pnum]._pIFlags & ISPL_FASTBLOCK && plr[pnum]._pAnimFrame != 1 ) { - plr[pnum]._pAnimFrame = plr[pnum]._pBFrames; - } + if (plr[pnum]._pIFlags & ISPL_FASTBLOCK && plr[pnum]._pAnimFrame != 1) { + plr[pnum]._pAnimFrame = plr[pnum]._pBFrames; + } - if ( plr[pnum]._pAnimFrame >= plr[pnum]._pBFrames ) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); + if (plr[pnum]._pAnimFrame >= plr[pnum]._pBFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); - if ( !random(3, 10) ) { - ShieldDur(pnum); - } - return TRUE; - } + if (!random(3, 10)) { + ShieldDur(pnum); + } + return TRUE; + } - return FALSE; + return FALSE; } BOOL __fastcall PM_DoSpell(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_DoSpell: illegal player %d", pnum); - } - - if ( plr[pnum]._pVar8 == plr[pnum]._pSFNum ) - { - CastSpell( - pnum, - plr[pnum]._pSpell, - plr[pnum].WorldX, - plr[pnum].WorldY, - plr[pnum]._pVar1, - plr[pnum]._pVar2, - FALSE, - plr[pnum]._pVar4 - ); - - if ( !plr[pnum]._pSplFrom ) { - if ( plr[pnum]._pRSplType == RSPLTYPE_SCROLL) { - if ( !(plr[pnum]._pScrlSpells64 - & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1)) - ) { - plr[pnum]._pRSpell = SPL_INVALID; - plr[pnum]._pRSplType = RSPLTYPE_INVALID; - drawpanflag = 255; - } - } - - if ( plr[pnum]._pRSplType == RSPLTYPE_CHARGES) { - if ( !(plr[pnum]._pISpells64 - & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1)) - ) { - plr[pnum]._pRSpell = SPL_INVALID; - plr[pnum]._pRSplType = RSPLTYPE_INVALID; - drawpanflag = 255; - } - } - } - } - - plr[pnum]._pVar8++; - - if ( leveltype == DTYPE_TOWN ) { - if ( plr[pnum]._pVar8 > plr[pnum]._pSFrames ) { - StartWalkStand(pnum); - ClearPlrPVars(pnum); - return TRUE; - } - } else if ( plr[pnum]._pAnimFrame == plr[pnum]._pSFrames ) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - return TRUE; - } - - return FALSE; + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoSpell: illegal player %d", pnum); + } + + if (plr[pnum]._pVar8 == plr[pnum]._pSFNum) { + CastSpell( + pnum, + plr[pnum]._pSpell, + plr[pnum].WorldX, + plr[pnum].WorldY, + plr[pnum]._pVar1, + plr[pnum]._pVar2, + FALSE, + plr[pnum]._pVar4); + + if (!plr[pnum]._pSplFrom) { + if (plr[pnum]._pRSplType == RSPLTYPE_SCROLL) { + if (!(plr[pnum]._pScrlSpells64 + & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1))) { + plr[pnum]._pRSpell = SPL_INVALID; + plr[pnum]._pRSplType = RSPLTYPE_INVALID; + drawpanflag = 255; + } + } + + if (plr[pnum]._pRSplType == RSPLTYPE_CHARGES) { + if (!(plr[pnum]._pISpells64 + & (unsigned __int64)1 << (plr[pnum]._pRSpell - 1))) { + plr[pnum]._pRSpell = SPL_INVALID; + plr[pnum]._pRSplType = RSPLTYPE_INVALID; + drawpanflag = 255; + } + } + } + } + + plr[pnum]._pVar8++; + + if (leveltype == DTYPE_TOWN) { + if (plr[pnum]._pVar8 > plr[pnum]._pSFrames) { + StartWalkStand(pnum); + ClearPlrPVars(pnum); + return TRUE; + } + } else if (plr[pnum]._pAnimFrame == plr[pnum]._pSFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + return TRUE; + } + + return FALSE; } // 52571C: using guessed type int drawpanflag; // 5BB1ED: using guessed type char leveltype; BOOL __fastcall PM_DoGotHit(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_DoGotHit: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoGotHit: illegal player %d", pnum); + } - int frame = plr[pnum]._pAnimFrame; - if ( plr[pnum]._pIFlags & ISPL_FASTRECOVER && frame == 3 ) { - plr[pnum]._pAnimFrame++; - } - if ( plr[pnum]._pIFlags & ISPL_FASTERRECOVER && (frame == 3 || frame == 5) ) { - plr[pnum]._pAnimFrame++; - } - if ( plr[pnum]._pIFlags & ISPL_FASTESTRECOVER && (frame == 1 || frame == 3 || frame == 5) ) { - plr[pnum]._pAnimFrame++; - } + int frame = plr[pnum]._pAnimFrame; + if (plr[pnum]._pIFlags & ISPL_FASTRECOVER && frame == 3) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTERRECOVER && (frame == 3 || frame == 5)) { + plr[pnum]._pAnimFrame++; + } + if (plr[pnum]._pIFlags & ISPL_FASTESTRECOVER && (frame == 1 || frame == 3 || frame == 5)) { + plr[pnum]._pAnimFrame++; + } - if ( plr[pnum]._pAnimFrame >= plr[pnum]._pHFrames ) { - StartStand(pnum, plr[pnum]._pdir); - ClearPlrPVars(pnum); - if ( random(3, 4) ) { - ArmorDur(pnum); - } + if (plr[pnum]._pAnimFrame >= plr[pnum]._pHFrames) { + StartStand(pnum, plr[pnum]._pdir); + ClearPlrPVars(pnum); + if (random(3, 4)) { + ArmorDur(pnum); + } - return TRUE; - } + return TRUE; + } - return FALSE; + return FALSE; } void __fastcall ArmorDur(int pnum) { - if ( pnum != myplr ) { - return; - } - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("ArmorDur: illegal player %d", pnum); - } - - PlayerStruct *p = &plr[pnum]; - if ( p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE ) { - return; - } - - int a = random(8, 3); - if ( p->InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE ) { - a = 1; - } - if ( p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype != ITYPE_NONE ) { - a = 0; - } - - ItemStruct *pi; - if ( a != 0 ) { - pi = &p->InvBody[INVLOC_CHEST]; - } else { - pi = &p->InvBody[INVLOC_HEAD]; - } - if ( pi->_iDurability == DUR_INDESTRUCTIBLE ) { - return; - } - - pi->_iDurability--; - if ( pi->_iDurability != 0 ) { - return; - } - - if ( a != 0 ) { - NetSendCmdDelItem(TRUE, INVLOC_CHEST); - } else { - NetSendCmdDelItem(TRUE, INVLOC_HEAD); - } - pi->_itype = ITYPE_NONE; - CalcPlrInv(pnum, TRUE); + if (pnum != myplr) { + return; + } + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ArmorDur: illegal player %d", pnum); + } + + PlayerStruct *p = &plr[pnum]; + if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) { + return; + } + + int a = random(8, 3); + if (p->InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) { + a = 1; + } + if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) { + a = 0; + } + + ItemStruct *pi; + if (a != 0) { + pi = &p->InvBody[INVLOC_CHEST]; + } else { + pi = &p->InvBody[INVLOC_HEAD]; + } + if (pi->_iDurability == DUR_INDESTRUCTIBLE) { + return; + } + + pi->_iDurability--; + if (pi->_iDurability != 0) { + return; + } + + if (a != 0) { + NetSendCmdDelItem(TRUE, INVLOC_CHEST); + } else { + NetSendCmdDelItem(TRUE, INVLOC_HEAD); + } + pi->_itype = ITYPE_NONE; + CalcPlrInv(pnum, TRUE); } BOOL __fastcall PM_DoDeath(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PM_DoDeath: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PM_DoDeath: illegal player %d", pnum); + } - if ( plr[pnum]._pVar8 >= 2 * plr[pnum]._pDFrames ) { - if ( deathdelay > 1 && pnum == myplr ) { - deathdelay--; - if ( deathdelay ) { - deathflag = TRUE; - if ( gbMaxPlayers == 1 ) { - gamemenu_previous(); - } - } - } + if (plr[pnum]._pVar8 >= 2 * plr[pnum]._pDFrames) { + if (deathdelay > 1 && pnum == myplr) { + deathdelay--; + if (deathdelay) { + deathflag = TRUE; + if (gbMaxPlayers == 1) { + gamemenu_previous(); + } + } + } - plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen; - plr[pnum]._pAnimDelay = 10000; - dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; - } + plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen; + plr[pnum]._pAnimDelay = 10000; + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; + } - if ( plr[pnum]._pVar8 < 100 ) { - plr[pnum]._pVar8++; - } + if (plr[pnum]._pVar8 < 100) { + plr[pnum]._pVar8++; + } - return FALSE; + return FALSE; } // 679660: using guessed type char gbMaxPlayers; // 69B7C4: using guessed type int deathdelay; BOOL __fastcall PM_DoNewLvl(int pnum) { - return FALSE; + return FALSE; } void __fastcall CheckNewPath(int pnum) { - int i; - int x; - int y; - int d; - int xvel3; - int xvel; - int yvel; - - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("CheckNewPath: illegal player %d", pnum); - } - - if ( plr[pnum].destAction == ACTION_ATTACKMON ) { - MakePlrPath(pnum, monster[plr[pnum].destParam1]._mfutx, monster[plr[pnum].destParam1]._mfuty, FALSE); - } - - if ( plr[pnum].destAction == ACTION_ATTACKPLR ) { - MakePlrPath(pnum, plr[plr[pnum].destParam1]._px, plr[plr[pnum].destParam1]._py, FALSE); - } - - if ( plr[pnum].walkpath[0] != WALK_NONE) { - if ( plr[pnum]._pmode == PM_STAND ) { - if ( pnum == myplr ) { - if ( plr[pnum].destAction == ACTION_ATTACKMON || plr[pnum].destAction == ACTION_ATTACKPLR ) { - i = plr[pnum].destParam1; - - if ( plr[pnum].destAction == ACTION_ATTACKMON ) { - x = abs(plr[pnum]._px - monster[i]._mfutx); - y = abs(plr[pnum]._py - monster[i]._mfuty); - d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - } else { - x = abs(plr[pnum]._px - plr[i]._px); - y = abs(plr[pnum]._py - plr[i]._py); - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); - } - - if ( x < 2 && y < 2 ) { - ClrPlrPath(pnum); - if ( monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14 ) { - TalktoMonster(i); - } else { - StartAttack(pnum, d); - } - plr[pnum].destAction = ACTION_NONE; - } - } - } - - if ( currlevel != 0 ) { - xvel3 = PWVel[plr[pnum]._pClass][0]; - xvel = PWVel[plr[pnum]._pClass][1]; - yvel = PWVel[plr[pnum]._pClass][2]; - } else { - xvel3 = 2048; - xvel = 1024; - yvel = 512; - } - - switch ( plr[pnum].walkpath[0] ) { - case WALK_N: - StartWalk(pnum, 0, -xvel, -1, -1, DIR_N, SDIR_N); - break; - case WALK_NE: - StartWalk(pnum, xvel, -yvel, 0, -1, DIR_NE, SDIR_NE); - break; - case WALK_E: - StartWalk3(pnum, xvel3, 0, -32, -16, 1, -1, 1, 0, DIR_E, SDIR_E); - break; - case WALK_SE: - StartWalk2(pnum, xvel, yvel, -32, -16, 1, 0, DIR_SE, SDIR_SE); - break; - case WALK_S: - StartWalk2(pnum, 0, xvel, 0, -32, 1, 1, DIR_S, SDIR_S); - break; - case WALK_SW: - StartWalk2(pnum, -xvel, yvel, 32, -16, 0, 1, DIR_SW, SDIR_SW); - break; - case WALK_W: - StartWalk3(pnum, -xvel3, 0, 32, -16, -1, 1, 0, 1, DIR_W, SDIR_W); - break; - case WALK_NW: - StartWalk(pnum, -xvel, -yvel, -1, 0, DIR_NW, SDIR_NW); - break; - } - - for ( i = 1; i < 25; i++ ) { - plr[pnum].walkpath[i - 1] = plr[pnum].walkpath[i]; - } - - plr[pnum].walkpath[24] = WALK_NONE; - - if ( plr[pnum]._pmode == PM_STAND ) { - StartStand(pnum, plr[pnum]._pdir); - plr[pnum].destAction = ACTION_NONE; - } - } - - return; - } - if ( plr[pnum].destAction == ACTION_NONE ) { - return; - } - - if ( plr[pnum]._pmode == PM_STAND ) { - switch ( plr[pnum].destAction ) { - case ACTION_ATTACK: - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartAttack(pnum, d); - break; - case ACTION_ATTACKMON: - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - monster[i]._mfutx); - y = abs(plr[pnum].WorldY - monster[i]._mfuty); - if ( x <= 1 && y <= 1 ) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - if ( monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14 ) { - TalktoMonster(i); - } else { - StartAttack(pnum, d); - } - } - break; - case ACTION_ATTACKPLR: - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - plr[i]._px); - y = abs(plr[pnum].WorldY - plr[i]._py); - if ( x <= 1 && y <= 1 ) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); - StartAttack(pnum, d); - } - break; - case ACTION_RATTACK: - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartRangeAttack(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); - break; - case ACTION_RATTACKMON: - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - if ( monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14 ) { - TalktoMonster(i); - } else { - StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); - } - break; - case ACTION_RATTACKPLR: - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); - StartRangeAttack(pnum, d, plr[i]._px, plr[i]._py); - break; - case ACTION_SPELL: - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartSpell(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); - plr[pnum]._pVar4 = plr[pnum].destParam3; - break; - case ACTION_SPELLWALL: - StartSpell(pnum, plr[pnum].destParam3, plr[pnum].destParam1, plr[pnum].destParam2); - plr[pnum]._pVar3 = plr[pnum].destParam3; - plr[pnum]._pVar4 = plr[pnum].destParam4; - break; - case ACTION_SPELLMON: - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); - StartSpell(pnum, d, monster[i]._mfutx, monster[i]._mfuty); - plr[pnum]._pVar4 = plr[pnum].destParam2; - break; - case ACTION_SPELLPLR: - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); - StartSpell(pnum, d, plr[i]._px, plr[i]._py); - plr[pnum]._pVar4 = plr[pnum].destParam2; - break; - case ACTION_OPERATE: - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - object[i]._ox); - y = abs(plr[pnum].WorldY - object[i]._oy); - if ( y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i ) { - y = abs(plr[pnum].WorldY - object[i]._oy + 1); - } - if ( x <= 1 && y <= 1 ) { - if ( object[i]._oBreak == 1 ) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); - StartAttack(pnum, d); - } else { - OperateObject(pnum, i, FALSE); - } - } - break; - case ACTION_DISARM: - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - object[i]._ox); - y = abs(plr[pnum].WorldY - object[i]._oy); - if ( y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i ) { - y = abs(plr[pnum].WorldY - object[i]._oy + 1); - } - if ( x <= 1 && y <= 1 ) { - if ( object[i]._oBreak == 1 ) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); - StartAttack(pnum, d); - } else { - TryDisarm(pnum, i); - OperateObject(pnum, i, FALSE); - } - } - break; - case ACTION_OPERATETK: - i = plr[pnum].destParam1; - if ( object[i]._oBreak != 1 ) { - OperateObject(pnum, i, TRUE); - } - break; - case ACTION_PICKUPITEM: - if ( pnum == myplr ) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - item[i]._ix); - y = abs(plr[pnum].WorldY - item[i]._iy); - if ( x <= 1 && y <= 1 && pcurs == 1 && !item[i]._iRequest ) { - NetSendCmdGItem(TRUE, CMD_REQUESTGITEM, myplr, myplr, i); - item[i]._iRequest = TRUE; - } - } - break; - case ACTION_PICKUPAITEM: - if ( pnum == myplr ) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - item[i]._ix); - y = abs(plr[pnum].WorldY - item[i]._iy); - if ( x <= 1 && y <= 1 && pcurs == 1 ) { - NetSendCmdGItem(TRUE, CMD_REQUESTAGITEM, myplr, myplr, i); - } - } - break; - case ACTION_TALK: - if ( pnum == myplr ) { - TalkToTowner(pnum, plr[pnum].destParam1); - } - break; - } - - FixPlayerLocation(pnum, plr[pnum]._pdir); - plr[pnum].destAction = ACTION_NONE; - - return; - } - - if ( plr[pnum]._pmode == PM_ATTACK && plr[pnum]._pAnimFrame > plr[myplr]._pAFNum ) { - if ( plr[pnum].destAction == ACTION_ATTACK ) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[pnum].destParam1, plr[pnum].destParam2); - StartAttack(pnum, d); - plr[pnum].destAction = ACTION_NONE; - } else if ( plr[pnum].destAction == ACTION_ATTACKMON ) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - monster[i]._mfutx); - y = abs(plr[pnum].WorldY - monster[i]._mfuty); - if ( x <= 1 && y <= 1 ) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - StartAttack(pnum, d); - } - plr[pnum].destAction = ACTION_NONE; - } else if ( plr[pnum].destAction == ACTION_ATTACKPLR ) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - plr[i]._px); - y = abs(plr[pnum].WorldY - plr[i]._py); - if ( x <= 1 && y <= 1 ) { - d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); - StartAttack(pnum, d); - } - plr[pnum].destAction = ACTION_NONE; - } else if ( plr[pnum].destAction == ACTION_OPERATE ) { - i = plr[pnum].destParam1; - x = abs(plr[pnum].WorldX - object[i]._ox); - y = abs(plr[pnum].WorldY - object[i]._oy); - if ( y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i ) { - y = abs(plr[pnum].WorldY - object[i]._oy + 1); - } - if ( x <= 1 && y <= 1 ) { - if ( object[i]._oBreak == 1 ) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); - StartAttack(pnum, d); - } else { - OperateObject(pnum, i, FALSE); - } - } - } - } - - if ( plr[pnum]._pmode == PM_RATTACK && plr[pnum]._pAnimFrame > plr[myplr]._pAFNum ) { - if ( plr[pnum].destAction == ACTION_RATTACK ) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartRangeAttack(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); - plr[pnum].destAction = ACTION_NONE; - } else if ( plr[pnum].destAction == ACTION_RATTACKMON ) { - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); - StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); - plr[pnum].destAction = ACTION_NONE; - } else if ( plr[pnum].destAction == ACTION_RATTACKPLR ) { - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); - StartRangeAttack(pnum, d, plr[i]._px, plr[i]._py); - plr[pnum].destAction = ACTION_NONE; - } - } - - if ( plr[pnum]._pmode == PM_SPELL && plr[pnum]._pAnimFrame > plr[pnum]._pSFNum ) { - if ( plr[pnum].destAction == ACTION_SPELL ) { - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); - StartSpell(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); - plr[pnum].destAction = ACTION_NONE; - } else if ( plr[pnum].destAction == ACTION_SPELLMON ) { - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); - StartSpell(pnum, d, monster[i]._mfutx, monster[i]._mfuty); - plr[pnum].destAction = ACTION_NONE; - } else if ( plr[pnum].destAction == ACTION_SPELLPLR ) { - i = plr[pnum].destParam1; - d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); - StartSpell(pnum, d, plr[i]._px, plr[i]._py); - plr[pnum].destAction = ACTION_NONE; - } - } + int i; + int x; + int y; + int d; + int xvel3; + int xvel; + int yvel; + + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("CheckNewPath: illegal player %d", pnum); + } + + if (plr[pnum].destAction == ACTION_ATTACKMON) { + MakePlrPath(pnum, monster[plr[pnum].destParam1]._mfutx, monster[plr[pnum].destParam1]._mfuty, FALSE); + } + + if (plr[pnum].destAction == ACTION_ATTACKPLR) { + MakePlrPath(pnum, plr[plr[pnum].destParam1]._px, plr[plr[pnum].destParam1]._py, FALSE); + } + + if (plr[pnum].walkpath[0] != WALK_NONE) { + if (plr[pnum]._pmode == PM_STAND) { + if (pnum == myplr) { + if (plr[pnum].destAction == ACTION_ATTACKMON || plr[pnum].destAction == ACTION_ATTACKPLR) { + i = plr[pnum].destParam1; + + if (plr[pnum].destAction == ACTION_ATTACKMON) { + x = abs(plr[pnum]._px - monster[i]._mfutx); + y = abs(plr[pnum]._py - monster[i]._mfuty); + d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); + } else { + x = abs(plr[pnum]._px - plr[i]._px); + y = abs(plr[pnum]._py - plr[i]._py); + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); + } + + if (x < 2 && y < 2) { + ClrPlrPath(pnum); + if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + TalktoMonster(i); + } else { + StartAttack(pnum, d); + } + plr[pnum].destAction = ACTION_NONE; + } + } + } + + if (currlevel != 0) { + xvel3 = PWVel[plr[pnum]._pClass][0]; + xvel = PWVel[plr[pnum]._pClass][1]; + yvel = PWVel[plr[pnum]._pClass][2]; + } else { + xvel3 = 2048; + xvel = 1024; + yvel = 512; + } + + switch (plr[pnum].walkpath[0]) { + case WALK_N: + StartWalk(pnum, 0, -xvel, -1, -1, DIR_N, SDIR_N); + break; + case WALK_NE: + StartWalk(pnum, xvel, -yvel, 0, -1, DIR_NE, SDIR_NE); + break; + case WALK_E: + StartWalk3(pnum, xvel3, 0, -32, -16, 1, -1, 1, 0, DIR_E, SDIR_E); + break; + case WALK_SE: + StartWalk2(pnum, xvel, yvel, -32, -16, 1, 0, DIR_SE, SDIR_SE); + break; + case WALK_S: + StartWalk2(pnum, 0, xvel, 0, -32, 1, 1, DIR_S, SDIR_S); + break; + case WALK_SW: + StartWalk2(pnum, -xvel, yvel, 32, -16, 0, 1, DIR_SW, SDIR_SW); + break; + case WALK_W: + StartWalk3(pnum, -xvel3, 0, 32, -16, -1, 1, 0, 1, DIR_W, SDIR_W); + break; + case WALK_NW: + StartWalk(pnum, -xvel, -yvel, -1, 0, DIR_NW, SDIR_NW); + break; + } + + for (i = 1; i < 25; i++) { + plr[pnum].walkpath[i - 1] = plr[pnum].walkpath[i]; + } + + plr[pnum].walkpath[24] = WALK_NONE; + + if (plr[pnum]._pmode == PM_STAND) { + StartStand(pnum, plr[pnum]._pdir); + plr[pnum].destAction = ACTION_NONE; + } + } + + return; + } + if (plr[pnum].destAction == ACTION_NONE) { + return; + } + + if (plr[pnum]._pmode == PM_STAND) { + switch (plr[pnum].destAction) { + case ACTION_ATTACK: + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartAttack(pnum, d); + break; + case ACTION_ATTACKMON: + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - monster[i]._mfutx); + y = abs(plr[pnum].WorldY - monster[i]._mfuty); + if (x <= 1 && y <= 1) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); + if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + TalktoMonster(i); + } else { + StartAttack(pnum, d); + } + } + break; + case ACTION_ATTACKPLR: + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - plr[i]._px); + y = abs(plr[pnum].WorldY - plr[i]._py); + if (x <= 1 && y <= 1) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); + StartAttack(pnum, d); + } + break; + case ACTION_RATTACK: + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartRangeAttack(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); + break; + case ACTION_RATTACKMON: + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); + if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + TalktoMonster(i); + } else { + StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); + } + break; + case ACTION_RATTACKPLR: + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); + StartRangeAttack(pnum, d, plr[i]._px, plr[i]._py); + break; + case ACTION_SPELL: + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartSpell(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); + plr[pnum]._pVar4 = plr[pnum].destParam3; + break; + case ACTION_SPELLWALL: + StartSpell(pnum, plr[pnum].destParam3, plr[pnum].destParam1, plr[pnum].destParam2); + plr[pnum]._pVar3 = plr[pnum].destParam3; + plr[pnum]._pVar4 = plr[pnum].destParam4; + break; + case ACTION_SPELLMON: + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); + StartSpell(pnum, d, monster[i]._mfutx, monster[i]._mfuty); + plr[pnum]._pVar4 = plr[pnum].destParam2; + break; + case ACTION_SPELLPLR: + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); + StartSpell(pnum, d, plr[i]._px, plr[i]._py); + plr[pnum]._pVar4 = plr[pnum].destParam2; + break; + case ACTION_OPERATE: + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - object[i]._ox); + y = abs(plr[pnum].WorldY - object[i]._oy); + if (y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i) { + y = abs(plr[pnum].WorldY - object[i]._oy + 1); + } + if (x <= 1 && y <= 1) { + if (object[i]._oBreak == 1) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); + StartAttack(pnum, d); + } else { + OperateObject(pnum, i, FALSE); + } + } + break; + case ACTION_DISARM: + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - object[i]._ox); + y = abs(plr[pnum].WorldY - object[i]._oy); + if (y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i) { + y = abs(plr[pnum].WorldY - object[i]._oy + 1); + } + if (x <= 1 && y <= 1) { + if (object[i]._oBreak == 1) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); + StartAttack(pnum, d); + } else { + TryDisarm(pnum, i); + OperateObject(pnum, i, FALSE); + } + } + break; + case ACTION_OPERATETK: + i = plr[pnum].destParam1; + if (object[i]._oBreak != 1) { + OperateObject(pnum, i, TRUE); + } + break; + case ACTION_PICKUPITEM: + if (pnum == myplr) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - item[i]._ix); + y = abs(plr[pnum].WorldY - item[i]._iy); + if (x <= 1 && y <= 1 && pcurs == 1 && !item[i]._iRequest) { + NetSendCmdGItem(TRUE, CMD_REQUESTGITEM, myplr, myplr, i); + item[i]._iRequest = TRUE; + } + } + break; + case ACTION_PICKUPAITEM: + if (pnum == myplr) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - item[i]._ix); + y = abs(plr[pnum].WorldY - item[i]._iy); + if (x <= 1 && y <= 1 && pcurs == 1) { + NetSendCmdGItem(TRUE, CMD_REQUESTAGITEM, myplr, myplr, i); + } + } + break; + case ACTION_TALK: + if (pnum == myplr) { + TalkToTowner(pnum, plr[pnum].destParam1); + } + break; + } + + FixPlayerLocation(pnum, plr[pnum]._pdir); + plr[pnum].destAction = ACTION_NONE; + + return; + } + + if (plr[pnum]._pmode == PM_ATTACK && plr[pnum]._pAnimFrame > plr[myplr]._pAFNum) { + if (plr[pnum].destAction == ACTION_ATTACK) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[pnum].destParam1, plr[pnum].destParam2); + StartAttack(pnum, d); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_ATTACKMON) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - monster[i]._mfutx); + y = abs(plr[pnum].WorldY - monster[i]._mfuty); + if (x <= 1 && y <= 1) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); + StartAttack(pnum, d); + } + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_ATTACKPLR) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - plr[i]._px); + y = abs(plr[pnum].WorldY - plr[i]._py); + if (x <= 1 && y <= 1) { + d = GetDirection(plr[pnum]._px, plr[pnum]._py, plr[i]._px, plr[i]._py); + StartAttack(pnum, d); + } + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_OPERATE) { + i = plr[pnum].destParam1; + x = abs(plr[pnum].WorldX - object[i]._ox); + y = abs(plr[pnum].WorldY - object[i]._oy); + if (y > 1 && dObject[object[i]._ox][object[i]._oy - 1] == -1 - i) { + y = abs(plr[pnum].WorldY - object[i]._oy + 1); + } + if (x <= 1 && y <= 1) { + if (object[i]._oBreak == 1) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, object[i]._ox, object[i]._oy); + StartAttack(pnum, d); + } else { + OperateObject(pnum, i, FALSE); + } + } + } + } + + if (plr[pnum]._pmode == PM_RATTACK && plr[pnum]._pAnimFrame > plr[myplr]._pAFNum) { + if (plr[pnum].destAction == ACTION_RATTACK) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartRangeAttack(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_RATTACKMON) { + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); + StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_RATTACKPLR) { + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); + StartRangeAttack(pnum, d, plr[i]._px, plr[i]._py); + plr[pnum].destAction = ACTION_NONE; + } + } + + if (plr[pnum]._pmode == PM_SPELL && plr[pnum]._pAnimFrame > plr[pnum]._pSFNum) { + if (plr[pnum].destAction == ACTION_SPELL) { + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum].destParam1, plr[pnum].destParam2); + StartSpell(pnum, d, plr[pnum].destParam1, plr[pnum].destParam2); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_SPELLMON) { + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mfutx, monster[i]._mfuty); + StartSpell(pnum, d, monster[i]._mfutx, monster[i]._mfuty); + plr[pnum].destAction = ACTION_NONE; + } else if (plr[pnum].destAction == ACTION_SPELLPLR) { + i = plr[pnum].destParam1; + d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, plr[i]._px, plr[i]._py); + StartSpell(pnum, d, plr[i]._px, plr[i]._py); + plr[pnum].destAction = ACTION_NONE; + } + } } BOOL __fastcall PlrDeathModeOK(int pnum) { - if ( pnum != myplr ) { - return TRUE; - } + if (pnum != myplr) { + return TRUE; + } - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("PlrDeathModeOK: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("PlrDeathModeOK: illegal player %d", pnum); + } - if (plr[pnum]._pmode == PM_DEATH) { - return TRUE; - } else if (plr[pnum]._pmode == PM_QUIT) { - return TRUE; - } else if (plr[pnum]._pmode == PM_NEWLVL) { - return TRUE; - } + if (plr[pnum]._pmode == PM_DEATH) { + return TRUE; + } else if (plr[pnum]._pmode == PM_QUIT) { + return TRUE; + } else if (plr[pnum]._pmode == PM_NEWLVL) { + return TRUE; + } - return FALSE; + return FALSE; } void __cdecl ValidatePlayer() { - __int64 msk = 0; - - if ( (DWORD)myplr >= MAX_PLRS ) { - TermMsg("ValidatePlayer: illegal player %d", myplr); - } - if ( plr[myplr]._pLevel > 50 ) - plr[myplr]._pLevel = 50; - if ( plr[myplr]._pExperience > plr[myplr]._pNextExper ) - plr[myplr]._pExperience = plr[myplr]._pNextExper; - - int gt = 0; - for ( int i = 0; i < plr[myplr]._pNumInv; i++ ) { - if ( plr[myplr].InvList[i]._itype == ITYPE_GOLD ) { - if ( plr[myplr].InvList[i]._ivalue > 5000 ) { - plr[myplr].InvList[i]._ivalue = 5000; - } - gt += plr[myplr].InvList[i]._ivalue; - } - } - if ( gt != plr[myplr]._pGold ) - plr[myplr]._pGold = gt; - - int pc = plr[myplr]._pClass; - if ( plr[myplr]._pBaseStr > MaxStats[pc][ATTRIB_STR] ) { - plr[myplr]._pBaseStr = MaxStats[pc][ATTRIB_STR]; - } - if ( plr[myplr]._pBaseMag > MaxStats[pc][ATTRIB_MAG] ) { - plr[myplr]._pBaseMag = MaxStats[pc][ATTRIB_MAG]; - } - if ( plr[myplr]._pBaseDex > MaxStats[pc][ATTRIB_DEX] ) { - plr[myplr]._pBaseDex = MaxStats[pc][ATTRIB_DEX]; - } - if ( plr[myplr]._pBaseVit > MaxStats[pc][ATTRIB_VIT] ) { - plr[myplr]._pBaseVit = MaxStats[pc][ATTRIB_VIT]; - } - - for ( int b = 1; b < MAX_SPELLS; b++) { - if ( spelldata[b].sBookLvl != -1 ) { - msk |= (__int64)1 << (b - 1); - if ( plr[myplr]._pSplLvl[b] > 15 ) - plr[myplr]._pSplLvl[b] = 15; - } - } - - plr[myplr]._pMemSpells64 &= msk; + __int64 msk = 0; + + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("ValidatePlayer: illegal player %d", myplr); + } + if (plr[myplr]._pLevel > 50) + plr[myplr]._pLevel = 50; + if (plr[myplr]._pExperience > plr[myplr]._pNextExper) + plr[myplr]._pExperience = plr[myplr]._pNextExper; + + int gt = 0; + for (int i = 0; i < plr[myplr]._pNumInv; i++) { + if (plr[myplr].InvList[i]._itype == ITYPE_GOLD) { + if (plr[myplr].InvList[i]._ivalue > 5000) { + plr[myplr].InvList[i]._ivalue = 5000; + } + gt += plr[myplr].InvList[i]._ivalue; + } + } + if (gt != plr[myplr]._pGold) + plr[myplr]._pGold = gt; + + int pc = plr[myplr]._pClass; + if (plr[myplr]._pBaseStr > MaxStats[pc][ATTRIB_STR]) { + plr[myplr]._pBaseStr = MaxStats[pc][ATTRIB_STR]; + } + if (plr[myplr]._pBaseMag > MaxStats[pc][ATTRIB_MAG]) { + plr[myplr]._pBaseMag = MaxStats[pc][ATTRIB_MAG]; + } + if (plr[myplr]._pBaseDex > MaxStats[pc][ATTRIB_DEX]) { + plr[myplr]._pBaseDex = MaxStats[pc][ATTRIB_DEX]; + } + if (plr[myplr]._pBaseVit > MaxStats[pc][ATTRIB_VIT]) { + plr[myplr]._pBaseVit = MaxStats[pc][ATTRIB_VIT]; + } + + for (int b = 1; b < MAX_SPELLS; b++) { + if (spelldata[b].sBookLvl != -1) { + msk |= (__int64)1 << (b - 1); + if (plr[myplr]._pSplLvl[b] > 15) + plr[myplr]._pSplLvl[b] = 15; + } + } + + plr[myplr]._pMemSpells64 &= msk; } void __cdecl ProcessPlayers() { - if ( (DWORD)myplr >= MAX_PLRS ) { - TermMsg("ProcessPlayers: illegal player %d", myplr); - } - - if ( plr[myplr].pLvlLoad > 0 ) { - plr[myplr].pLvlLoad--; - } - - if ( sfxdelay > 0 ) { - sfxdelay--; - if ( sfxdelay == 0 ) { - PlaySFX(sfxdnum); - } - } - - ValidatePlayer(); - - for ( int pnum = 0; pnum < MAX_PLRS; pnum++ ) { - if ( plr[pnum].plractive && currlevel == plr[pnum].plrlevel && (pnum == myplr || !plr[pnum]._pLvlChanging) ) { - CheckCheatStats(pnum); - - if ( !PlrDeathModeOK(pnum) && (plr[pnum]._pHitPoints >> 6) <= 0 ) { - SyncPlrKill(pnum, -1); - } - - if ( pnum == myplr ) { - if ( (plr[pnum]._pIFlags & ISPL_DRAINLIFE) && currlevel != 0 ) { - plr[pnum]._pHitPoints -= 4; - plr[pnum]._pHPBase -= 4; - if ( (plr[pnum]._pHitPoints >> 6) <= 0 ) { - SyncPlrKill(pnum, 0); - } - drawhpflag = TRUE; - } - if ( plr[pnum]._pIFlags & ISPL_NOMANA && plr[pnum]._pManaBase > 0 ) { - plr[pnum]._pManaBase -= plr[pnum]._pMana; - plr[pnum]._pMana = 0; - drawmanaflag = TRUE; - } - } - - BOOL tplayer = FALSE; - do { - switch ( plr[pnum]._pmode ) { - case PM_STAND: - tplayer = PM_DoStand(pnum); - break; - case PM_WALK: - tplayer = PM_DoWalk(pnum); - break; - case PM_WALK2: - tplayer = PM_DoWalk2(pnum); - break; - case PM_WALK3: - tplayer = PM_DoWalk3(pnum); - break; - case PM_ATTACK: - tplayer = PM_DoAttack(pnum); - break; - case PM_RATTACK: - tplayer = PM_DoRangeAttack(pnum); - break; - case PM_BLOCK: - tplayer = PM_DoBlock(pnum); - break; - case PM_SPELL: - tplayer = PM_DoSpell(pnum); - break; - case PM_GOTHIT: - tplayer = PM_DoGotHit(pnum); - break; - case PM_DEATH: - tplayer = PM_DoDeath(pnum); - break; - case PM_NEWLVL: - tplayer = PM_DoNewLvl(pnum); - break; - } - CheckNewPath(pnum); - } while ( tplayer ); - - plr[pnum]._pAnimCnt++; - if ( plr[pnum]._pAnimCnt > plr[pnum]._pAnimDelay ) { - plr[pnum]._pAnimCnt = 0; - plr[pnum]._pAnimFrame++; - if ( plr[pnum]._pAnimFrame > plr[pnum]._pAnimLen ) { - plr[pnum]._pAnimFrame = 1; - } - } - } - } + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("ProcessPlayers: illegal player %d", myplr); + } + + if (plr[myplr].pLvlLoad > 0) { + plr[myplr].pLvlLoad--; + } + + if (sfxdelay > 0) { + sfxdelay--; + if (sfxdelay == 0) { + PlaySFX(sfxdnum); + } + } + + ValidatePlayer(); + + for (int pnum = 0; pnum < MAX_PLRS; pnum++) { + if (plr[pnum].plractive && currlevel == plr[pnum].plrlevel && (pnum == myplr || !plr[pnum]._pLvlChanging)) { + CheckCheatStats(pnum); + + if (!PlrDeathModeOK(pnum) && (plr[pnum]._pHitPoints >> 6) <= 0) { + SyncPlrKill(pnum, -1); + } + + if (pnum == myplr) { + if ((plr[pnum]._pIFlags & ISPL_DRAINLIFE) && currlevel != 0) { + plr[pnum]._pHitPoints -= 4; + plr[pnum]._pHPBase -= 4; + if ((plr[pnum]._pHitPoints >> 6) <= 0) { + SyncPlrKill(pnum, 0); + } + drawhpflag = TRUE; + } + if (plr[pnum]._pIFlags & ISPL_NOMANA && plr[pnum]._pManaBase > 0) { + plr[pnum]._pManaBase -= plr[pnum]._pMana; + plr[pnum]._pMana = 0; + drawmanaflag = TRUE; + } + } + + BOOL tplayer = FALSE; + do { + switch (plr[pnum]._pmode) { + case PM_STAND: + tplayer = PM_DoStand(pnum); + break; + case PM_WALK: + tplayer = PM_DoWalk(pnum); + break; + case PM_WALK2: + tplayer = PM_DoWalk2(pnum); + break; + case PM_WALK3: + tplayer = PM_DoWalk3(pnum); + break; + case PM_ATTACK: + tplayer = PM_DoAttack(pnum); + break; + case PM_RATTACK: + tplayer = PM_DoRangeAttack(pnum); + break; + case PM_BLOCK: + tplayer = PM_DoBlock(pnum); + break; + case PM_SPELL: + tplayer = PM_DoSpell(pnum); + break; + case PM_GOTHIT: + tplayer = PM_DoGotHit(pnum); + break; + case PM_DEATH: + tplayer = PM_DoDeath(pnum); + break; + case PM_NEWLVL: + tplayer = PM_DoNewLvl(pnum); + break; + } + CheckNewPath(pnum); + } while (tplayer); + + plr[pnum]._pAnimCnt++; + if (plr[pnum]._pAnimCnt > plr[pnum]._pAnimDelay) { + plr[pnum]._pAnimCnt = 0; + plr[pnum]._pAnimFrame++; + if (plr[pnum]._pAnimFrame > plr[pnum]._pAnimLen) { + plr[pnum]._pAnimFrame = 1; + } + } + } + } } // 52A554: using guessed type int sfxdelay; void __fastcall CheckCheatStats(int pnum) { - if ( plr[pnum]._pStrength > 750 ) { - plr[pnum]._pStrength = 750; - } + if (plr[pnum]._pStrength > 750) { + plr[pnum]._pStrength = 750; + } - if ( plr[pnum]._pDexterity > 750 ) { - plr[pnum]._pDexterity = 750; - } + if (plr[pnum]._pDexterity > 750) { + plr[pnum]._pDexterity = 750; + } - if ( plr[pnum]._pMagic > 750 ) { - plr[pnum]._pMagic = 750; - } + if (plr[pnum]._pMagic > 750) { + plr[pnum]._pMagic = 750; + } - if ( plr[pnum]._pVitality > 750 ) { - plr[pnum]._pVitality = 750; - } + if (plr[pnum]._pVitality > 750) { + plr[pnum]._pVitality = 750; + } - if ( plr[pnum]._pHitPoints > 128000 ) { - plr[pnum]._pHitPoints = 128000; - } + if (plr[pnum]._pHitPoints > 128000) { + plr[pnum]._pHitPoints = 128000; + } - if ( plr[pnum]._pMana > 128000 ) { - plr[pnum]._pMana = 128000; - } + if (plr[pnum]._pMana > 128000) { + plr[pnum]._pMana = 128000; + } } void __fastcall ClrPlrPath(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("ClrPlrPath: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ClrPlrPath: illegal player %d", pnum); + } - memset(plr[pnum].walkpath, WALK_NONE, sizeof(plr[pnum].walkpath)); + memset(plr[pnum].walkpath, WALK_NONE, sizeof(plr[pnum].walkpath)); } BOOL __fastcall PosOkPlayer(int pnum, int px, int py) { - BOOL PosOK = FALSE; - if ( px >= 0 && px < MAXDUNX && py >= 0 && py < MAXDUNY && - !SolidLoc(px, py) && dPiece[px][py] ) { - - if ( dPlayer[px][py] ) { - DWORD p; - if ( dPlayer[px][py] > 0 ) { - p = dPlayer[px][py] - 1; - } else { - p = -(dPlayer[px][py] + 1); - } - if ( p != pnum && p < MAX_PLRS && plr[p]._pHitPoints ) { - return FALSE; - } - } - - if ( dMonster[px][py] ) { - if ( currlevel == 0 ) { - return FALSE; - } - if ( dMonster[px][py] <= 0 ) { - return FALSE; - } - if ( (monster[dMonster[px][py] - 1]._mhitpoints >> 6) > 0 ) { - return FALSE; - } - } - - if ( dObject[px][py] ) { - char bv; - if ( dObject[px][py] > 0 ) { - bv = dObject[px][py] - 1; - } else { - bv = -(dObject[px][py] + 1); - } - if ( object[bv]._oSolidFlag ) { - return FALSE; - } - } - - PosOK = TRUE; - } - - if ( !PosOK ) - return FALSE; - return TRUE; + BOOL PosOK = FALSE; + if (px >= 0 && px < MAXDUNX && py >= 0 && py < MAXDUNY && !SolidLoc(px, py) && dPiece[px][py]) { + + if (dPlayer[px][py]) { + DWORD p; + if (dPlayer[px][py] > 0) { + p = dPlayer[px][py] - 1; + } else { + p = -(dPlayer[px][py] + 1); + } + if (p != pnum && p < MAX_PLRS && plr[p]._pHitPoints) { + return FALSE; + } + } + + if (dMonster[px][py]) { + if (currlevel == 0) { + return FALSE; + } + if (dMonster[px][py] <= 0) { + return FALSE; + } + if ((monster[dMonster[px][py] - 1]._mhitpoints >> 6) > 0) { + return FALSE; + } + } + + if (dObject[px][py]) { + char bv; + if (dObject[px][py] > 0) { + bv = dObject[px][py] - 1; + } else { + bv = -(dObject[px][py] + 1); + } + if (object[bv]._oSolidFlag) { + return FALSE; + } + } + + PosOK = TRUE; + } + + if (!PosOK) + return FALSE; + return TRUE; } void __fastcall MakePlrPath(int pnum, int xx, int yy, BOOL endspace) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("MakePlrPath: illegal player %d", pnum); - } - - plr[pnum]._ptargx = xx; - plr[pnum]._ptargy = yy; - if ( plr[pnum]._px == xx && plr[pnum]._py == yy ) { - return; - } - - int path = FindPath(PosOkPlayer, pnum, plr[pnum]._px, plr[pnum]._py, xx, yy, plr[pnum].walkpath); - if ( !path ) { - return; - } - - if ( !endspace ) { - path--; - - switch ( plr[pnum].walkpath[path] ) { - case WALK_NE: - yy++; - break; - case WALK_NW: - xx++; - break; - case WALK_SE: - xx--; - break; - case WALK_SW: - yy--; - break; - case WALK_N: - xx++; - yy++; - break; - case WALK_E: - xx--; - yy++; - break; - case WALK_S: - xx--; - yy--; - break; - case WALK_W: - xx++; - yy--; - break; - } - - plr[pnum]._ptargx = xx; - plr[pnum]._ptargy = yy; - } - - plr[pnum].walkpath[path] = WALK_NONE; + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("MakePlrPath: illegal player %d", pnum); + } + + plr[pnum]._ptargx = xx; + plr[pnum]._ptargy = yy; + if (plr[pnum]._px == xx && plr[pnum]._py == yy) { + return; + } + + int path = FindPath(PosOkPlayer, pnum, plr[pnum]._px, plr[pnum]._py, xx, yy, plr[pnum].walkpath); + if (!path) { + return; + } + + if (!endspace) { + path--; + + switch (plr[pnum].walkpath[path]) { + case WALK_NE: + yy++; + break; + case WALK_NW: + xx++; + break; + case WALK_SE: + xx--; + break; + case WALK_SW: + yy--; + break; + case WALK_N: + xx++; + yy++; + break; + case WALK_E: + xx--; + yy++; + break; + case WALK_S: + xx--; + yy--; + break; + case WALK_W: + xx++; + yy--; + break; + } + + plr[pnum]._ptargx = xx; + plr[pnum]._ptargy = yy; + } + + plr[pnum].walkpath[path] = WALK_NONE; } void __fastcall CheckPlrSpell() { - if ( (DWORD)myplr >= MAX_PLRS ) { - TermMsg("CheckPlrSpell: illegal player %d", myplr); - } - - int rspell = plr[myplr]._pRSpell; - if ( rspell == SPL_INVALID ) { - if ( plr[myplr]._pClass == PC_WARRIOR ) { - PlaySFX(PS_WARR34); - } else if ( plr[myplr]._pClass == PC_ROGUE ) { - PlaySFX(PS_ROGUE34); - } else if ( plr[myplr]._pClass == PC_SORCERER ) { - PlaySFX(PS_MAGE34); - } - return; - } - - if ( leveltype == DTYPE_TOWN && !spelldata[rspell].sTownSpell ) { - if ( plr[myplr]._pClass == PC_WARRIOR ) { - PlaySFX(PS_WARR27); - } else if ( plr[myplr]._pClass == PC_ROGUE ) { - PlaySFX(PS_ROGUE27); - } else if ( plr[myplr]._pClass == PC_SORCERER ) { - PlaySFX(PS_MAGE27); - } - return; - } - - if ( pcurs != CURSOR_HAND - || MouseY >= 352 - || (chrflag && MouseX < 320 || invflag && MouseX > 320) - && rspell != SPL_HEAL - && rspell != SPL_IDENTIFY - && rspell != SPL_REPAIR - && rspell != SPL_INFRA - && rspell != SPL_RECHARGE - ) { - return; - } - - BOOL addflag = FALSE; - switch ( plr[myplr]._pRSplType ) { - case RSPLTYPE_SKILL: - case RSPLTYPE_SPELL: - addflag = CheckSpell(myplr, rspell, plr[myplr]._pRSplType, FALSE); - break; - case RSPLTYPE_SCROLL: - addflag = UseScroll(); - break; - case RSPLTYPE_CHARGES: - addflag = UseStaff(); - break; - } - - if ( addflag ) { - if ( plr[myplr]._pRSpell == SPL_FIREWALL ) { - int sd = GetDirection(plr[myplr].WorldX, plr[myplr].WorldY, cursmx, cursmy); - int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); - NetSendCmdLocParam3(TRUE, CMD_SPELLXYD, cursmx, cursmy, plr[myplr]._pRSpell, sd, sl); - } else if ( pcursmonst != -1 ) { - int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); - NetSendCmdParam3(TRUE, CMD_SPELLID, pcursmonst, plr[myplr]._pRSpell, sl); - } else if ( pcursplr != -1 ) { - int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); - NetSendCmdParam3(TRUE, CMD_SPELLPID, pcursplr, plr[myplr]._pRSpell, sl); - } else {//145 - int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); - NetSendCmdLocParam2(TRUE, CMD_SPELLXY, cursmx, cursmy, plr[myplr]._pRSpell, sl); - } - return; - } - - if ( plr[myplr]._pRSplType == RSPLTYPE_SPELL ) { - if ( plr[myplr]._pClass == PC_WARRIOR ) { - PlaySFX(PS_WARR35); - } else if ( plr[myplr]._pClass == PC_ROGUE ) { - PlaySFX(PS_ROGUE35); - } else if ( plr[myplr]._pClass == PC_SORCERER ) { - PlaySFX(PS_MAGE35); - } - } + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("CheckPlrSpell: illegal player %d", myplr); + } + + int rspell = plr[myplr]._pRSpell; + if (rspell == SPL_INVALID) { + if (plr[myplr]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR34); + } else if (plr[myplr]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE34); + } else if (plr[myplr]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE34); + } + return; + } + + if (leveltype == DTYPE_TOWN && !spelldata[rspell].sTownSpell) { + if (plr[myplr]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR27); + } else if (plr[myplr]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE27); + } else if (plr[myplr]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE27); + } + return; + } + + if (pcurs != CURSOR_HAND + || MouseY >= 352 + || (chrflag && MouseX < 320 || invflag && MouseX > 320) + && rspell != SPL_HEAL + && rspell != SPL_IDENTIFY + && rspell != SPL_REPAIR + && rspell != SPL_INFRA + && rspell != SPL_RECHARGE) { + return; + } + + BOOL addflag = FALSE; + switch (plr[myplr]._pRSplType) { + case RSPLTYPE_SKILL: + case RSPLTYPE_SPELL: + addflag = CheckSpell(myplr, rspell, plr[myplr]._pRSplType, FALSE); + break; + case RSPLTYPE_SCROLL: + addflag = UseScroll(); + break; + case RSPLTYPE_CHARGES: + addflag = UseStaff(); + break; + } + + if (addflag) { + if (plr[myplr]._pRSpell == SPL_FIREWALL) { + int sd = GetDirection(plr[myplr].WorldX, plr[myplr].WorldY, cursmx, cursmy); + int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); + NetSendCmdLocParam3(TRUE, CMD_SPELLXYD, cursmx, cursmy, plr[myplr]._pRSpell, sd, sl); + } else if (pcursmonst != -1) { + int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); + NetSendCmdParam3(TRUE, CMD_SPELLID, pcursmonst, plr[myplr]._pRSpell, sl); + } else if (pcursplr != -1) { + int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); + NetSendCmdParam3(TRUE, CMD_SPELLPID, pcursplr, plr[myplr]._pRSpell, sl); + } else { //145 + int sl = GetSpellLevel(myplr, plr[myplr]._pRSpell); + NetSendCmdLocParam2(TRUE, CMD_SPELLXY, cursmx, cursmy, plr[myplr]._pRSpell, sl); + } + return; + } + + if (plr[myplr]._pRSplType == RSPLTYPE_SPELL) { + if (plr[myplr]._pClass == PC_WARRIOR) { + PlaySFX(PS_WARR35); + } else if (plr[myplr]._pClass == PC_ROGUE) { + PlaySFX(PS_ROGUE35); + } else if (plr[myplr]._pClass == PC_SORCERER) { + PlaySFX(PS_MAGE35); + } + } } // 4B8CC2: using guessed type char pcursplr; // 5BB1ED: using guessed type char leveltype; void __fastcall SyncPlrAnim(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("SyncPlrAnim: illegal player %d", pnum); - } - - int dir = plr[pnum]._pdir; - switch ( plr[pnum]._pmode ) { - case PM_BLOCK: - plr[pnum]._pAnimData = plr[pnum]._pBAnim[dir]; - break; - case PM_GOTHIT: - plr[pnum]._pAnimData = plr[pnum]._pHAnim[dir]; - break; - case PM_DEATH: - plr[pnum]._pAnimData = plr[pnum]._pDAnim[dir]; - break; - case PM_SPELL: - int sType; - if ( pnum == myplr ) { - sType = spelldata[plr[pnum]._pSpell].sType; - } else { - sType = STYPE_FIRE; - } - if ( sType == STYPE_FIRE ) - plr[pnum]._pAnimData = plr[pnum]._pFAnim[dir]; - if ( sType == STYPE_LIGHTNING ) - plr[pnum]._pAnimData = plr[pnum]._pLAnim[dir]; - if ( sType == STYPE_MAGIC ) { - plr[pnum]._pAnimData = plr[pnum]._pTAnim[dir]; - } - break; - case PM_STAND: - case PM_NEWLVL: - case PM_QUIT: - plr[pnum]._pAnimData = plr[pnum]._pNAnim[dir]; - break; - case PM_WALK: - case PM_WALK2: - case PM_WALK3: - plr[pnum]._pAnimData = plr[pnum]._pWAnim[dir]; - break; - case PM_ATTACK: - case PM_RATTACK: - plr[pnum]._pAnimData = plr[pnum]._pAAnim[dir]; - break; - default: - TermMsg("SyncPlrAnim"); - break; - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SyncPlrAnim: illegal player %d", pnum); + } + + int dir = plr[pnum]._pdir; + switch (plr[pnum]._pmode) { + case PM_BLOCK: + plr[pnum]._pAnimData = plr[pnum]._pBAnim[dir]; + break; + case PM_GOTHIT: + plr[pnum]._pAnimData = plr[pnum]._pHAnim[dir]; + break; + case PM_DEATH: + plr[pnum]._pAnimData = plr[pnum]._pDAnim[dir]; + break; + case PM_SPELL: + int sType; + if (pnum == myplr) { + sType = spelldata[plr[pnum]._pSpell].sType; + } else { + sType = STYPE_FIRE; + } + if (sType == STYPE_FIRE) + plr[pnum]._pAnimData = plr[pnum]._pFAnim[dir]; + if (sType == STYPE_LIGHTNING) + plr[pnum]._pAnimData = plr[pnum]._pLAnim[dir]; + if (sType == STYPE_MAGIC) { + plr[pnum]._pAnimData = plr[pnum]._pTAnim[dir]; + } + break; + case PM_STAND: + case PM_NEWLVL: + case PM_QUIT: + plr[pnum]._pAnimData = plr[pnum]._pNAnim[dir]; + break; + case PM_WALK: + case PM_WALK2: + case PM_WALK3: + plr[pnum]._pAnimData = plr[pnum]._pWAnim[dir]; + break; + case PM_ATTACK: + case PM_RATTACK: + plr[pnum]._pAnimData = plr[pnum]._pAAnim[dir]; + break; + default: + TermMsg("SyncPlrAnim"); + break; + } } void __fastcall SyncInitPlrPos(int pnum) { - plr[pnum]._ptargx = plr[pnum].WorldX; - plr[pnum]._ptargy = plr[pnum].WorldY; - - if ( gbMaxPlayers == 1 || plr[pnum].plrlevel != currlevel ) { - return; - } - - int x; - int y; - for ( DWORD i = 0; i < 8; i++ ) { - x = plr[pnum].WorldX + plrxoff2[i]; - y = plr[pnum].WorldY + plryoff2[i]; - if ( PosOkPlayer(pnum, x, y) ) { - break; - } - } - - if ( !PosOkPlayer(pnum, x, y) ) { - BOOL posOk = FALSE; - int xx; - int yy; - for ( int range = 1; range < 50 && !posOk; range++ ) { - for ( yy = -range; yy <= range && !posOk; yy++ ) { - y = yy + plr[pnum].WorldY; - for ( xx = -range; xx <= range && !posOk; xx++ ) { - x = xx + plr[pnum].WorldX; - if ( PosOkPlayer(pnum, x, y) && !PosOkPortal(currlevel, x, y) ) { - posOk = TRUE; - } - } - } - } - } - - plr[pnum].WorldX = x; - plr[pnum].WorldY = y; - dPlayer[x][y] = pnum + 1; - - if ( pnum == myplr ) { - plr[pnum]._px = x; - plr[pnum]._py = y; - plr[pnum]._ptargx = x; - plr[pnum]._ptargy = y; - ViewX = x; - ViewY = y; - } + plr[pnum]._ptargx = plr[pnum].WorldX; + plr[pnum]._ptargy = plr[pnum].WorldY; + + if (gbMaxPlayers == 1 || plr[pnum].plrlevel != currlevel) { + return; + } + + int x; + int y; + for (DWORD i = 0; i < 8; i++) { + x = plr[pnum].WorldX + plrxoff2[i]; + y = plr[pnum].WorldY + plryoff2[i]; + if (PosOkPlayer(pnum, x, y)) { + break; + } + } + + if (!PosOkPlayer(pnum, x, y)) { + BOOL posOk = FALSE; + int xx; + int yy; + for (int range = 1; range < 50 && !posOk; range++) { + for (yy = -range; yy <= range && !posOk; yy++) { + y = yy + plr[pnum].WorldY; + for (xx = -range; xx <= range && !posOk; xx++) { + x = xx + plr[pnum].WorldX; + if (PosOkPlayer(pnum, x, y) && !PosOkPortal(currlevel, x, y)) { + posOk = TRUE; + } + } + } + } + } + + plr[pnum].WorldX = x; + plr[pnum].WorldY = y; + dPlayer[x][y] = pnum + 1; + + if (pnum == myplr) { + plr[pnum]._px = x; + plr[pnum]._py = y; + plr[pnum]._ptargx = x; + plr[pnum]._ptargy = y; + ViewX = x; + ViewY = y; + } } // 679660: using guessed type char gbMaxPlayers; void __fastcall SyncInitPlr(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("SyncInitPlr: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SyncInitPlr: illegal player %d", pnum); + } - SetPlrAnims(pnum); - SyncInitPlrPos(pnum); + SetPlrAnims(pnum); + SyncInitPlrPos(pnum); } void __fastcall CheckStats(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("CheckStats: illegal player %d", pnum); - } - - int c; - if ( plr[pnum]._pClass == PC_WARRIOR ) { - c = PC_WARRIOR; - } else if ( plr[pnum]._pClass == PC_ROGUE ) { - c = PC_ROGUE; - } else if ( plr[pnum]._pClass == PC_SORCERER ) { - c = PC_SORCERER; - } - - for (int i = 0; i < 4; i++ ) { - switch (i) { - case ATTRIB_STR: - if ( plr[pnum]._pBaseStr > MaxStats[c][ATTRIB_STR] ) { - plr[pnum]._pBaseStr = MaxStats[c][ATTRIB_STR]; - } else if ( plr[pnum]._pBaseStr < 0 ) { - plr[pnum]._pBaseStr = 0; - } - break; - case ATTRIB_MAG: - if ( plr[pnum]._pBaseMag > MaxStats[c][ATTRIB_MAG] ) { - plr[pnum]._pBaseMag = MaxStats[c][ATTRIB_MAG]; - } else if ( plr[pnum]._pBaseMag < 0 ) { - plr[pnum]._pBaseMag = 0; - } - break; - case ATTRIB_DEX: - if ( plr[pnum]._pBaseDex > MaxStats[c][ATTRIB_DEX] ) { - plr[pnum]._pBaseDex = MaxStats[c][ATTRIB_DEX]; - } else if ( plr[pnum]._pBaseDex < 0 ) { - plr[pnum]._pBaseDex = 0; - } - break; - case ATTRIB_VIT: - if ( plr[pnum]._pBaseVit > MaxStats[c][ATTRIB_VIT] ) { - plr[pnum]._pBaseVit = MaxStats[c][ATTRIB_VIT]; - } else if ( plr[pnum]._pBaseVit < 0 ) { - plr[pnum]._pBaseVit = 0; - } - break; - } - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("CheckStats: illegal player %d", pnum); + } + + int c; + if (plr[pnum]._pClass == PC_WARRIOR) { + c = PC_WARRIOR; + } else if (plr[pnum]._pClass == PC_ROGUE) { + c = PC_ROGUE; + } else if (plr[pnum]._pClass == PC_SORCERER) { + c = PC_SORCERER; + } + + for (int i = 0; i < 4; i++) { + switch (i) { + case ATTRIB_STR: + if (plr[pnum]._pBaseStr > MaxStats[c][ATTRIB_STR]) { + plr[pnum]._pBaseStr = MaxStats[c][ATTRIB_STR]; + } else if (plr[pnum]._pBaseStr < 0) { + plr[pnum]._pBaseStr = 0; + } + break; + case ATTRIB_MAG: + if (plr[pnum]._pBaseMag > MaxStats[c][ATTRIB_MAG]) { + plr[pnum]._pBaseMag = MaxStats[c][ATTRIB_MAG]; + } else if (plr[pnum]._pBaseMag < 0) { + plr[pnum]._pBaseMag = 0; + } + break; + case ATTRIB_DEX: + if (plr[pnum]._pBaseDex > MaxStats[c][ATTRIB_DEX]) { + plr[pnum]._pBaseDex = MaxStats[c][ATTRIB_DEX]; + } else if (plr[pnum]._pBaseDex < 0) { + plr[pnum]._pBaseDex = 0; + } + break; + case ATTRIB_VIT: + if (plr[pnum]._pBaseVit > MaxStats[c][ATTRIB_VIT]) { + plr[pnum]._pBaseVit = MaxStats[c][ATTRIB_VIT]; + } else if (plr[pnum]._pBaseVit < 0) { + plr[pnum]._pBaseVit = 0; + } + break; + } + } } void __fastcall ModifyPlrStr(int pnum, int l) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("ModifyPlrStr: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ModifyPlrStr: illegal player %d", pnum); + } - int max = MaxStats[plr[pnum]._pClass][ATTRIB_STR]; - if ( plr[pnum]._pBaseStr + l > max ) { - l = max - plr[pnum]._pBaseStr; - } + int max = MaxStats[plr[pnum]._pClass][ATTRIB_STR]; + if (plr[pnum]._pBaseStr + l > max) { + l = max - plr[pnum]._pBaseStr; + } - plr[pnum]._pStrength += l; - plr[pnum]._pBaseStr += l; + plr[pnum]._pStrength += l; + plr[pnum]._pBaseStr += l; - if ( plr[pnum]._pClass == PC_ROGUE ) { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; - } else { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; - } + if (plr[pnum]._pClass == PC_ROGUE) { + plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + } else { + plr[pnum]._pDamageMod = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; + } - CalcPlrInv(pnum, TRUE); + CalcPlrInv(pnum, TRUE); - if ( pnum == myplr ) { - NetSendCmdParam1(FALSE, CMD_SETSTR, plr[pnum]._pBaseStr); //60 - } + if (pnum == myplr) { + NetSendCmdParam1(FALSE, CMD_SETSTR, plr[pnum]._pBaseStr); //60 + } } void __fastcall ModifyPlrMag(int pnum, int l) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("ModifyPlrMag: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ModifyPlrMag: illegal player %d", pnum); + } - int max = MaxStats[plr[pnum]._pClass][ATTRIB_MAG]; - if ( plr[pnum]._pBaseMag + l > max ) { - l = max - plr[pnum]._pBaseMag; - } + int max = MaxStats[plr[pnum]._pClass][ATTRIB_MAG]; + if (plr[pnum]._pBaseMag + l > max) { + l = max - plr[pnum]._pBaseMag; + } - plr[pnum]._pMagic += l; - plr[pnum]._pBaseMag += l; + plr[pnum]._pMagic += l; + plr[pnum]._pBaseMag += l; - int ms = l << 6; - if ( plr[pnum]._pClass == PC_SORCERER ) { - ms *= 2; - } + int ms = l << 6; + if (plr[pnum]._pClass == PC_SORCERER) { + ms *= 2; + } - plr[pnum]._pMaxManaBase += ms; - plr[pnum]._pMaxMana += ms; - if ( !(plr[pnum]._pIFlags & ISPL_NOMANA) ) { - plr[pnum]._pManaBase += ms; - plr[pnum]._pMana += ms; - } + plr[pnum]._pMaxManaBase += ms; + plr[pnum]._pMaxMana += ms; + if (!(plr[pnum]._pIFlags & ISPL_NOMANA)) { + plr[pnum]._pManaBase += ms; + plr[pnum]._pMana += ms; + } - CalcPlrInv(pnum, TRUE); + CalcPlrInv(pnum, TRUE); - if ( pnum == myplr ) { - NetSendCmdParam1(FALSE, CMD_SETMAG, plr[pnum]._pBaseMag); - } + if (pnum == myplr) { + NetSendCmdParam1(FALSE, CMD_SETMAG, plr[pnum]._pBaseMag); + } } void __fastcall ModifyPlrDex(int pnum, int l) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("ModifyPlrDex: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ModifyPlrDex: illegal player %d", pnum); + } - int max = MaxStats[plr[pnum]._pClass][ATTRIB_DEX]; - if ( plr[pnum]._pBaseDex + l > max ) { - l = max - plr[pnum]._pBaseDex; - } + int max = MaxStats[plr[pnum]._pClass][ATTRIB_DEX]; + if (plr[pnum]._pBaseDex + l > max) { + l = max - plr[pnum]._pBaseDex; + } - plr[pnum]._pDexterity += l; - plr[pnum]._pBaseDex += l; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pDexterity += l; + plr[pnum]._pBaseDex += l; + CalcPlrInv(pnum, TRUE); - if ( plr[pnum]._pClass == PC_ROGUE ) { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pDexterity + plr[pnum]._pStrength) / 200; - } + if (plr[pnum]._pClass == PC_ROGUE) { + plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pDexterity + plr[pnum]._pStrength) / 200; + } - if ( pnum == myplr ) { - NetSendCmdParam1(FALSE, CMD_SETDEX, plr[pnum]._pBaseDex); - } + if (pnum == myplr) { + NetSendCmdParam1(FALSE, CMD_SETDEX, plr[pnum]._pBaseDex); + } } void __fastcall ModifyPlrVit(int pnum, int l) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("ModifyPlrVit: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("ModifyPlrVit: illegal player %d", pnum); + } - int max = MaxStats[plr[pnum]._pClass][ATTRIB_VIT]; - if ( plr[pnum]._pBaseVit + l > max ) { - l = max - plr[pnum]._pBaseVit; - } + int max = MaxStats[plr[pnum]._pClass][ATTRIB_VIT]; + if (plr[pnum]._pBaseVit + l > max) { + l = max - plr[pnum]._pBaseVit; + } - plr[pnum]._pVitality += l; - plr[pnum]._pBaseVit += l; + plr[pnum]._pVitality += l; + plr[pnum]._pBaseVit += l; - int ms = l << 6; - if ( plr[pnum]._pClass == PC_WARRIOR ) { - ms *= 2; - } + int ms = l << 6; + if (plr[pnum]._pClass == PC_WARRIOR) { + ms *= 2; + } - plr[pnum]._pHPBase += ms; - plr[pnum]._pMaxHPBase += ms; - plr[pnum]._pHitPoints += ms; - plr[pnum]._pMaxHP += ms; + plr[pnum]._pHPBase += ms; + plr[pnum]._pMaxHPBase += ms; + plr[pnum]._pHitPoints += ms; + plr[pnum]._pMaxHP += ms; - CalcPlrInv(pnum, TRUE); + CalcPlrInv(pnum, TRUE); - if ( pnum == myplr ) { - NetSendCmdParam1(FALSE, CMD_SETVIT, plr[pnum]._pBaseVit); - } + if (pnum == myplr) { + NetSendCmdParam1(FALSE, CMD_SETVIT, plr[pnum]._pBaseVit); + } } void __fastcall SetPlayerHitPoints(int pnum, int newhp) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("SetPlayerHitPoints: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlayerHitPoints: illegal player %d", pnum); + } - plr[pnum]._pHitPoints = newhp; - plr[pnum]._pHPBase = newhp + plr[pnum]._pMaxHPBase - plr[pnum]._pMaxHP; + plr[pnum]._pHitPoints = newhp; + plr[pnum]._pHPBase = newhp + plr[pnum]._pMaxHPBase - plr[pnum]._pMaxHP; - if ( pnum == myplr ) { - drawhpflag = TRUE; - } + if (pnum == myplr) { + drawhpflag = TRUE; + } } void __fastcall SetPlrStr(int pnum, int v) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("SetPlrStr: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrStr: illegal player %d", pnum); + } - plr[pnum]._pBaseStr = v; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pBaseStr = v; + CalcPlrInv(pnum, TRUE); - int dm; - if ( plr[pnum]._pClass == PC_ROGUE ) { - dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; - } else { - dm = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; - } + int dm; + if (plr[pnum]._pClass == PC_ROGUE) { + dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + } else { + dm = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; + } - plr[pnum]._pDamageMod = dm; + plr[pnum]._pDamageMod = dm; } void __fastcall SetPlrMag(int pnum, int v) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("SetPlrMag: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrMag: illegal player %d", pnum); + } - plr[pnum]._pBaseMag = v; + plr[pnum]._pBaseMag = v; - int m = v << 6; - if ( plr[pnum]._pClass == PC_SORCERER ) { - m *= 2; - } + int m = v << 6; + if (plr[pnum]._pClass == PC_SORCERER) { + m *= 2; + } - plr[pnum]._pMaxManaBase = m; - plr[pnum]._pMaxMana = m; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pMaxManaBase = m; + plr[pnum]._pMaxMana = m; + CalcPlrInv(pnum, TRUE); } void __fastcall SetPlrDex(int pnum, int v) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("SetPlrDex: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrDex: illegal player %d", pnum); + } - plr[pnum]._pBaseDex = v; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pBaseDex = v; + CalcPlrInv(pnum, TRUE); - int dm; - if ( plr[pnum]._pClass == PC_ROGUE ) { - dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; - } else { - dm = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; - } + int dm; + if (plr[pnum]._pClass == PC_ROGUE) { + dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + } else { + dm = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; + } - plr[pnum]._pDamageMod = dm; + plr[pnum]._pDamageMod = dm; } void __fastcall SetPlrVit(int pnum, int v) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("SetPlrVit: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("SetPlrVit: illegal player %d", pnum); + } - plr[pnum]._pBaseVit = v; + plr[pnum]._pBaseVit = v; - int hp = v << 6; - if ( plr[pnum]._pClass == PC_WARRIOR ) { - hp *= 2; - } + int hp = v << 6; + if (plr[pnum]._pClass == PC_WARRIOR) { + hp *= 2; + } - plr[pnum]._pHPBase = hp; - plr[pnum]._pMaxHPBase = hp; - CalcPlrInv(pnum, TRUE); + plr[pnum]._pHPBase = hp; + plr[pnum]._pMaxHPBase = hp; + CalcPlrInv(pnum, TRUE); } void __fastcall InitDungMsgs(int pnum) { - if ( (DWORD)pnum >= MAX_PLRS ) { - TermMsg("InitDungMsgs: illegal player %d", pnum); - } + if ((DWORD)pnum >= MAX_PLRS) { + TermMsg("InitDungMsgs: illegal player %d", pnum); + } - plr[pnum].pDungMsgs = 0; + plr[pnum].pDungMsgs = 0; } void __cdecl PlayDungMsgs() { - if ( (DWORD)myplr >= MAX_PLRS ) { - TermMsg("PlayDungMsgs: illegal player %d", myplr); - } - - if ( currlevel == 1 && !plr[myplr]._pLvlVisited[1] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CATHEDRAL) ) { - sfxdelay = 40; - if ( plr[myplr]._pClass == PC_WARRIOR ) { - sfxdnum = PS_WARR97; - } else if ( plr[myplr]._pClass == PC_ROGUE ) { - sfxdnum = PS_ROGUE97; - } else if ( plr[myplr]._pClass == PC_SORCERER ) { - sfxdnum = PS_MAGE97; - } - plr[myplr].pDungMsgs = plr[myplr].pDungMsgs | DMSG_CATHEDRAL; - } else if ( currlevel == 5 && !plr[myplr]._pLvlVisited[5] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CATACOMBS) ) { - sfxdelay = 40; - if ( plr[myplr]._pClass == PC_WARRIOR ) { - sfxdnum = PS_WARR96B; - } else if ( plr[myplr]._pClass == PC_ROGUE ) { - sfxdnum = PS_ROGUE96; - } else if ( plr[myplr]._pClass == PC_SORCERER ) { - sfxdnum = PS_MAGE96; - } - plr[myplr].pDungMsgs |= DMSG_CATACOMBS; - } else if ( currlevel == 9 && !plr[myplr]._pLvlVisited[9] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CAVES) ) { - sfxdelay = 40; - if ( plr[myplr]._pClass == PC_WARRIOR ) { - sfxdnum = PS_WARR98; - } else if ( plr[myplr]._pClass == PC_ROGUE ) { - sfxdnum = PS_ROGUE98; - } else if ( plr[myplr]._pClass == PC_SORCERER ) { - sfxdnum = PS_MAGE98; - } - plr[myplr].pDungMsgs |= DMSG_CAVES; - } else if ( currlevel == 13 && !plr[myplr]._pLvlVisited[13] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_HELL) ) { - sfxdelay = 40; - if ( plr[myplr]._pClass == PC_WARRIOR ) { - sfxdnum = PS_WARR99; - } else if ( plr[myplr]._pClass == PC_ROGUE ) { - sfxdnum = PS_ROGUE99; - } else if ( plr[myplr]._pClass == PC_SORCERER ) { - sfxdnum = PS_MAGE99; - } - plr[myplr].pDungMsgs |= DMSG_HELL; - } else if ( currlevel == 16 && !plr[myplr]._pLvlVisited[15] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_DIABLO) ) { - sfxdelay = 40; - if ( plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_ROGUE || plr[myplr]._pClass == PC_SORCERER ) { - sfxdnum = PS_DIABLVLINT; - } - plr[myplr].pDungMsgs |= DMSG_DIABLO; - } else { - sfxdelay = 0; - } + if ((DWORD)myplr >= MAX_PLRS) { + TermMsg("PlayDungMsgs: illegal player %d", myplr); + } + + if (currlevel == 1 && !plr[myplr]._pLvlVisited[1] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CATHEDRAL)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR97; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE97; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE97; + } + plr[myplr].pDungMsgs = plr[myplr].pDungMsgs | DMSG_CATHEDRAL; + } else if (currlevel == 5 && !plr[myplr]._pLvlVisited[5] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CATACOMBS)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR96B; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE96; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE96; + } + plr[myplr].pDungMsgs |= DMSG_CATACOMBS; + } else if (currlevel == 9 && !plr[myplr]._pLvlVisited[9] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_CAVES)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR98; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE98; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE98; + } + plr[myplr].pDungMsgs |= DMSG_CAVES; + } else if (currlevel == 13 && !plr[myplr]._pLvlVisited[13] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_HELL)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR) { + sfxdnum = PS_WARR99; + } else if (plr[myplr]._pClass == PC_ROGUE) { + sfxdnum = PS_ROGUE99; + } else if (plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_MAGE99; + } + plr[myplr].pDungMsgs |= DMSG_HELL; + } else if (currlevel == 16 && !plr[myplr]._pLvlVisited[15] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs & DMSG_DIABLO)) { + sfxdelay = 40; + if (plr[myplr]._pClass == PC_WARRIOR || plr[myplr]._pClass == PC_ROGUE || plr[myplr]._pClass == PC_SORCERER) { + sfxdnum = PS_DIABLVLINT; + } + plr[myplr].pDungMsgs |= DMSG_DIABLO; + } else { + sfxdelay = 0; + } } // 52A554: using guessed type int sfxdelay; // 679660: using guessed type char gbMaxPlayers; diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index b32b4dded..5dc4422b9 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -5,144 +5,143 @@ static unsigned char plr_msg_slot; _plrmsg plr_msgs[PMSG_COUNT]; -const char text_color_from_player_num[MAX_PLRS+1] = { COL_WHITE, COL_WHITE, COL_WHITE, COL_WHITE, COL_GOLD }; +const char text_color_from_player_num[MAX_PLRS + 1] = { COL_WHITE, COL_WHITE, COL_WHITE, COL_WHITE, COL_GOLD }; void __fastcall plrmsg_delay(BOOL delay) { - int i; - _plrmsg *pMsg; - static DWORD plrmsg_ticks; - - if ( delay ) { - plrmsg_ticks = -GetTickCount(); - return; - } - - plrmsg_ticks += GetTickCount(); - pMsg = plr_msgs; - for ( i = 0; i < PMSG_COUNT; i++, pMsg++ ) - pMsg->time += plrmsg_ticks; + int i; + _plrmsg *pMsg; + static DWORD plrmsg_ticks; + + if (delay) { + plrmsg_ticks = -GetTickCount(); + return; + } + + plrmsg_ticks += GetTickCount(); + pMsg = plr_msgs; + for (i = 0; i < PMSG_COUNT; i++, pMsg++) + pMsg->time += plrmsg_ticks; } char *__fastcall ErrorPlrMsg(const char *pszMsg) { - char *result; - _plrmsg *pMsg = &plr_msgs[plr_msg_slot]; - plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); - pMsg->player = MAX_PLRS; - pMsg->time = GetTickCount(); - result = strncpy(pMsg->str, pszMsg, sizeof(pMsg->str)); - pMsg->str[sizeof(pMsg->str)-1] = '\0'; - return result; + char *result; + _plrmsg *pMsg = &plr_msgs[plr_msg_slot]; + plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); + pMsg->player = MAX_PLRS; + pMsg->time = GetTickCount(); + result = strncpy(pMsg->str, pszMsg, sizeof(pMsg->str)); + pMsg->str[sizeof(pMsg->str) - 1] = '\0'; + return result; } size_t EventPlrMsg(const char *pszFmt, ...) { - _plrmsg *pMsg; - va_list va; - - va_start(va, pszFmt); - pMsg = &plr_msgs[plr_msg_slot]; - plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); - pMsg->player = MAX_PLRS; - pMsg->time = GetTickCount(); - vsprintf(pMsg->str, pszFmt, va); - va_end(va); - return strlen(pMsg->str); + _plrmsg *pMsg; + va_list va; + + va_start(va, pszFmt); + pMsg = &plr_msgs[plr_msg_slot]; + plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); + pMsg->player = MAX_PLRS; + pMsg->time = GetTickCount(); + vsprintf(pMsg->str, pszFmt, va); + va_end(va); + return strlen(pMsg->str); } void __fastcall SendPlrMsg(int pnum, const char *pszStr) { - _plrmsg *pMsg = &plr_msgs[plr_msg_slot]; - plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); - pMsg->player = pnum; - pMsg->time = GetTickCount(); - strlen(plr[pnum]._pName); /* these are used in debug */ - strlen(pszStr); - sprintf(pMsg->str, "%s (lvl %d): %s", plr[pnum]._pName, plr[pnum]._pLevel, pszStr); + _plrmsg *pMsg = &plr_msgs[plr_msg_slot]; + plr_msg_slot = (plr_msg_slot + 1) & (PMSG_COUNT - 1); + pMsg->player = pnum; + pMsg->time = GetTickCount(); + strlen(plr[pnum]._pName); /* these are used in debug */ + strlen(pszStr); + sprintf(pMsg->str, "%s (lvl %d): %s", plr[pnum]._pName, plr[pnum]._pLevel, pszStr); } void __cdecl ClearPlrMsg() { - int i; - _plrmsg *pMsg = plr_msgs; - DWORD tick = GetTickCount(); - - for ( i = 0; i < PMSG_COUNT; i++, pMsg++ ) { - if ((int)(tick - pMsg->time) > 10000 ) - pMsg->str[0] = '\0'; - } + int i; + _plrmsg *pMsg = plr_msgs; + DWORD tick = GetTickCount(); + + for (i = 0; i < PMSG_COUNT; i++, pMsg++) { + if ((int)(tick - pMsg->time) > 10000) + pMsg->str[0] = '\0'; + } } void __cdecl InitPlrMsg() { - memset(plr_msgs, 0, sizeof(plr_msgs)); - plr_msg_slot = 0; + memset(plr_msgs, 0, sizeof(plr_msgs)); + plr_msg_slot = 0; } void __cdecl DrawPlrMsg() { - int i; - int x = 74; - int y = 230; - int width = 620; - _plrmsg *pMsg; - - if ( chrflag || questlog ) { - if ( invflag || sbookflag ) - return; - x = 394; - width = 300; - } - else if ( invflag || sbookflag ) - width = 300; - - pMsg = plr_msgs; - for ( i = 0; i < 8; i++) { - if ( pMsg->str[0] ) - PrintPlrMsg(x, y, width, pMsg->str, text_color_from_player_num[pMsg->player]); - pMsg++; - y += 35; - } + int i; + int x = 74; + int y = 230; + int width = 620; + _plrmsg *pMsg; + + if (chrflag || questlog) { + if (invflag || sbookflag) + return; + x = 394; + width = 300; + } else if (invflag || sbookflag) + width = 300; + + pMsg = plr_msgs; + for (i = 0; i < 8; i++) { + if (pMsg->str[0]) + PrintPlrMsg(x, y, width, pMsg->str, text_color_from_player_num[pMsg->player]); + pMsg++; + y += 35; + } } void __fastcall PrintPlrMsg(unsigned int x, unsigned int y, unsigned int width, const char *str, unsigned char col) { - int line=0; - - while (*str) { - unsigned char c; - int screen = screen_y_times_768[y] + x; - const char *sstr = str; - unsigned int len = 0; - const char *endstr = sstr; - - while ( 1 ) { - if ( *sstr ) { - c = fontidx[(unsigned char)*sstr++]; - c = fontframe[c]; - len += fontkern[c] + 1; - if ( !c ) // allow wordwrap on blank glyph - endstr = sstr; - else if ( len >= width ) - break; - } else { - endstr = sstr; - break; - } - } - - while ( str < endstr ) { - c = fontidx[(unsigned char)*str++]; - c = fontframe[c]; - if ( c ) - CPrintString(screen, c, col); - screen += fontkern[c] + 1; - } - - y += 10; - line++; - if (line == 3) - break; - } + int line = 0; + + while (*str) { + unsigned char c; + int screen = screen_y_times_768[y] + x; + const char *sstr = str; + unsigned int len = 0; + const char *endstr = sstr; + + while (1) { + if (*sstr) { + c = fontidx[(unsigned char)*sstr++]; + c = fontframe[c]; + len += fontkern[c] + 1; + if (!c) // allow wordwrap on blank glyph + endstr = sstr; + else if (len >= width) + break; + } else { + endstr = sstr; + break; + } + } + + while (str < endstr) { + c = fontidx[(unsigned char)*str++]; + c = fontframe[c]; + if (c) + CPrintString(screen, c, col); + screen += fontkern[c] + 1; + } + + y += 10; + line++; + if (line == 3) + break; + } } diff --git a/Source/sound.cpp b/Source/sound.cpp index e08c34662..d34ca4682 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -16,406 +16,403 @@ const int sound_inf = 0x7F800000; // weak /* data */ -UCHAR gbMusicOn = 1; // weak -UCHAR gbSoundOn = 1; // weak +UCHAR gbMusicOn = 1; // weak +UCHAR gbSoundOn = 1; // weak char gbDupSounds = 1; // weak int sgnMusicTrack = 6; -char *sgszMusicTracks[NUM_MUSIC] = -{ - "Music\\DTowne.wav", - "Music\\DLvlA.wav", - "Music\\DLvlB.wav", - "Music\\DLvlC.wav", - "Music\\DLvlD.wav", - "Music\\Dintro.wav" +char *sgszMusicTracks[NUM_MUSIC] = { + "Music\\DTowne.wav", + "Music\\DLvlA.wav", + "Music\\DLvlB.wav", + "Music\\DLvlC.wav", + "Music\\DLvlD.wav", + "Music\\Dintro.wav" }; -char unk_volume[4][2] = -{ - { 15, -16 }, - { 15, -16 }, - { 30, -31 }, - { 30, -31 } +char unk_volume[4][2] = { + { 15, -16 }, + { 15, -16 }, + { 30, -31 }, + { 30, -31 } }; -struct sound_cpp_init -{ - sound_cpp_init() - { - sound_cpp_init_value = sound_inf; - } +struct sound_cpp_init { + sound_cpp_init() + { + sound_cpp_init_value = sound_inf; + } } _sound_cpp_init; // 47F24C: using guessed type int sound_inf; void __fastcall snd_update(BOOL bStopAll) { - DWORD error_code; + DWORD error_code; - for (DWORD i = 0; i < 8; i++) { - if ( !DSBs[i] ) - continue; + for (DWORD i = 0; i < 8; i++) { + if (!DSBs[i]) + continue; - if ( !bStopAll && !DSBs[i]->GetStatus(&error_code) && error_code == DSBSTATUS_PLAYING ) - continue; + if (!bStopAll && !DSBs[i]->GetStatus(&error_code) && error_code == DSBSTATUS_PLAYING) + continue; - DSBs[i]->Stop(); - DSBs[i]->Release(); - DSBs[i] = NULL; - } + DSBs[i]->Stop(); + DSBs[i]->Release(); + DSBs[i] = NULL; + } } void __fastcall snd_stop_snd(TSnd *pSnd) { - if ( pSnd && pSnd->DSB ) - pSnd->DSB->Stop(); + if (pSnd && pSnd->DSB) + pSnd->DSB->Stop(); } BOOL __fastcall snd_playing(TSnd *pSnd) { - DWORD error_code; + DWORD error_code; - if ( !pSnd ) - return FALSE; + if (!pSnd) + return FALSE; - if ( pSnd->DSB == NULL ) - return FALSE; + if (pSnd->DSB == NULL) + return FALSE; - if ( pSnd->DSB->GetStatus(&error_code) ) - return FALSE; + if (pSnd->DSB->GetStatus(&error_code)) + return FALSE; - return error_code == DSBSTATUS_PLAYING; + return error_code == DSBSTATUS_PLAYING; } void __fastcall snd_play_snd(TSnd *pSnd, int lVolume, int lPan) { - if ( !pSnd || !gbSoundOn ) { - return; - } - - LPDIRECTSOUNDBUFFER DSB = pSnd->DSB; - if ( !DSB ) { - return; - } - - DWORD tc = GetTickCount(); - if ( tc - pSnd->start_tc < 80 ) { - pSnd->start_tc = GetTickCount(); - return; - } - - if ( snd_playing(pSnd) ) { - DSB = sound_dup_channel(pSnd->DSB); - if (DSB == 0) { - return; - } - } - - lVolume += sglSoundVolume; - if ( lVolume < VOLUME_MIN ) { - lVolume = VOLUME_MIN; - } else if ( lVolume > VOLUME_MAX ) { - lVolume = VOLUME_MAX; - } - DSB->SetVolume(lVolume); - - DSB->SetPan(lPan); - - HRESULT error_code = DSB->Play(0, 0, 0); - if ( error_code != DSERR_BUFFERLOST) { - if ( error_code != DS_OK ) { - DSErrMsg(error_code, 261, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - } - } else if ( sound_file_reload(pSnd, DSB) ) { - DSB->Play(0, 0, 0); - } - - pSnd->start_tc = tc; + if (!pSnd || !gbSoundOn) { + return; + } + + LPDIRECTSOUNDBUFFER DSB = pSnd->DSB; + if (!DSB) { + return; + } + + DWORD tc = GetTickCount(); + if (tc - pSnd->start_tc < 80) { + pSnd->start_tc = GetTickCount(); + return; + } + + if (snd_playing(pSnd)) { + DSB = sound_dup_channel(pSnd->DSB); + if (DSB == 0) { + return; + } + } + + lVolume += sglSoundVolume; + if (lVolume < VOLUME_MIN) { + lVolume = VOLUME_MIN; + } else if (lVolume > VOLUME_MAX) { + lVolume = VOLUME_MAX; + } + DSB->SetVolume(lVolume); + + DSB->SetPan(lPan); + + HRESULT error_code = DSB->Play(0, 0, 0); + if (error_code != DSERR_BUFFERLOST) { + if (error_code != DS_OK) { + DSErrMsg(error_code, 261, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + } + } else if (sound_file_reload(pSnd, DSB)) { + DSB->Play(0, 0, 0); + } + + pSnd->start_tc = tc; } // 4A22D5: using guessed type char gbSoundOn; LPDIRECTSOUNDBUFFER __fastcall sound_dup_channel(LPDIRECTSOUNDBUFFER DSB) { - if ( !gbDupSounds ) { - return NULL; - } - - for ( DWORD i = 0; i < 8; i++ ) { - if (!DSBs[i]) { - if ( sglpDS->DuplicateSoundBuffer(DSB, &DSBs[i]) != DS_OK ) { - return NULL; - } + if (!gbDupSounds) { + return NULL; + } - return DSBs[i]; - } - } + for (DWORD i = 0; i < 8; i++) { + if (!DSBs[i]) { + if (sglpDS->DuplicateSoundBuffer(DSB, &DSBs[i]) != DS_OK) { + return NULL; + } - return NULL; + return DSBs[i]; + } + } + return NULL; } // 4A22D6: using guessed type char gbDupSounds; BOOL __fastcall sound_file_reload(TSnd *sound_file, LPDIRECTSOUNDBUFFER DSB) { - if ( DSB->Restore() ) - return FALSE; + if (DSB->Restore()) + return FALSE; - HANDLE file; - LPVOID buf1, buf2; - DWORD size1, size2; + HANDLE file; + LPVOID buf1, buf2; + DWORD size1, size2; - BOOL rv = FALSE; + BOOL rv = FALSE; - WOpenFile(sound_file->sound_path, &file, 0); - WSetFilePointer(file, sound_file->offset, 0, 0); - if ( DSB->Lock(0, sound_file->len, &buf1, &size1, &buf2, &size2, 0) == DS_OK ) { - WReadFile(file, buf1, size1); - if ( DSB->Unlock(buf1, size1, buf2, size2) == DS_OK ) { - rv = TRUE; - } - } + WOpenFile(sound_file->sound_path, &file, 0); + WSetFilePointer(file, sound_file->offset, 0, 0); + if (DSB->Lock(0, sound_file->len, &buf1, &size1, &buf2, &size2, 0) == DS_OK) { + WReadFile(file, buf1, size1); + if (DSB->Unlock(buf1, size1, buf2, size2) == DS_OK) { + rv = TRUE; + } + } - WCloseFile(file); + WCloseFile(file); - return rv; + return rv; } TSnd *__fastcall sound_file_load(char *path) { - if ( !sglpDS ) - return NULL; + if (!sglpDS) + return NULL; - void *file, *wave_file; - WOpenFile(path, &file, 0); - TSnd *pSnd = (TSnd *)DiabloAllocPtr(40); - memset(pSnd, 0, sizeof(TSnd)); - pSnd->sound_path = path; - pSnd->start_tc = GetTickCount() - 81; + void *file, *wave_file; + WOpenFile(path, &file, 0); + TSnd *pSnd = (TSnd *)DiabloAllocPtr(40); + memset(pSnd, 0, sizeof(TSnd)); + pSnd->sound_path = path; + pSnd->start_tc = GetTickCount() - 81; - wave_file = LoadWaveFile(file, &pSnd->fmt, &pSnd->len); - if ( !wave_file ) - TermMsg("Invalid sound format on file %s", pSnd->sound_path); + wave_file = LoadWaveFile(file, &pSnd->fmt, &pSnd->len); + if (!wave_file) + TermMsg("Invalid sound format on file %s", pSnd->sound_path); - sound_CreateSoundBuffer(pSnd); + sound_CreateSoundBuffer(pSnd); - LPVOID buf1, buf2; - DWORD size1, size2; - HRESULT error_code = pSnd->DSB->Lock(0, pSnd->len, &buf1, &size1, &buf2, &size2, 0); - if ( error_code != DS_OK ) - DSErrMsg(error_code, 318, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + LPVOID buf1, buf2; + DWORD size1, size2; + HRESULT error_code = pSnd->DSB->Lock(0, pSnd->len, &buf1, &size1, &buf2, &size2, 0); + if (error_code != DS_OK) + DSErrMsg(error_code, 318, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - memcpy(buf1, (char *)wave_file + pSnd->offset, size1); + memcpy(buf1, (char *)wave_file + pSnd->offset, size1); - error_code = pSnd->DSB->Unlock(buf1, size1, buf2, size2); - if ( error_code != DS_OK ) - DSErrMsg(error_code, 325, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + error_code = pSnd->DSB->Unlock(buf1, size1, buf2, size2); + if (error_code != DS_OK) + DSErrMsg(error_code, 325, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - mem_free_dbg(wave_file); - WCloseFile(file); + mem_free_dbg(wave_file); + WCloseFile(file); - return pSnd; + return pSnd; } // 456F07: could not find valid save-restore pair for esi void __fastcall sound_CreateSoundBuffer(TSnd *sound_file) { - DSBUFFERDESC DSB; - memset(&DSB, 0, sizeof(DSBUFFERDESC)); + DSBUFFERDESC DSB; + memset(&DSB, 0, sizeof(DSBUFFERDESC)); - DSB.dwBufferBytes = sound_file->len; - DSB.lpwfxFormat = &sound_file->fmt; - DSB.dwSize = sizeof(DSBUFFERDESC); - DSB.dwFlags = DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN|DSBCAPS_STATIC; + DSB.dwBufferBytes = sound_file->len; + DSB.lpwfxFormat = &sound_file->fmt; + DSB.dwSize = sizeof(DSBUFFERDESC); + DSB.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_STATIC; - HRESULT error_code = sglpDS->CreateSoundBuffer(&DSB, &sound_file->DSB, NULL); - if ( error_code != ERROR_SUCCESS ) - DSErrMsg(error_code, 282, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + HRESULT error_code = sglpDS->CreateSoundBuffer(&DSB, &sound_file->DSB, NULL); + if (error_code != ERROR_SUCCESS) + DSErrMsg(error_code, 282, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); } void __fastcall sound_file_cleanup(TSnd *sound_file) { - if ( sound_file ) { - if ( sound_file->DSB ) { - sound_file->DSB->Stop(); - sound_file->DSB->Release(); - sound_file->DSB = NULL; - } - - mem_free_dbg(sound_file); - } + if (sound_file) { + if (sound_file->DSB) { + sound_file->DSB->Stop(); + sound_file->DSB->Release(); + sound_file->DSB = NULL; + } + + mem_free_dbg(sound_file); + } } void __fastcall snd_init(HWND hWnd) { - sound_load_volume("Sound Volume", &sglSoundVolume); - gbSoundOn = sglSoundVolume > VOLUME_MIN; + sound_load_volume("Sound Volume", &sglSoundVolume); + gbSoundOn = sglSoundVolume > VOLUME_MIN; - sound_load_volume("Music Volume", &sglMusicVolume); - gbMusicOn = sglMusicVolume > VOLUME_MIN; + sound_load_volume("Music Volume", &sglMusicVolume); + gbMusicOn = sglMusicVolume > VOLUME_MIN; - if ( sound_DirectSoundCreate(NULL, &sglpDS, NULL) != DS_OK ) - sglpDS = NULL; + if (sound_DirectSoundCreate(NULL, &sglpDS, NULL) != DS_OK) + sglpDS = NULL; - if ( sglpDS && sglpDS->SetCooperativeLevel(hWnd, DSSCL_EXCLUSIVE) == DS_OK ) - sound_create_primary_buffer(0); + if (sglpDS && sglpDS->SetCooperativeLevel(hWnd, DSSCL_EXCLUSIVE) == DS_OK) + sound_create_primary_buffer(0); - SVidInitialize(sglpDS); - SFileDdaInitialize(sglpDS); + SVidInitialize(sglpDS); + SFileDdaInitialize(sglpDS); - gbSndInited = sglpDS != NULL; + gbSndInited = sglpDS != NULL; } // 4A22D4: using guessed type char gbMusicOn; // 4A22D5: using guessed type char gbSoundOn; void __fastcall sound_load_volume(char *value_name, int *value) { - int v = *value; - if ( !SRegLoadValue("Diablo", value_name, 0, &v) ) { - v = VOLUME_MAX; - } - *value = v; - - if ( *value < VOLUME_MIN ) { - *value = VOLUME_MIN; - } else if ( *value > VOLUME_MAX ) { - *value = VOLUME_MAX; - } - *value -= *value % 100; + int v = *value; + if (!SRegLoadValue("Diablo", value_name, 0, &v)) { + v = VOLUME_MAX; + } + *value = v; + + if (*value < VOLUME_MIN) { + *value = VOLUME_MIN; + } else if (*value > VOLUME_MAX) { + *value = VOLUME_MAX; + } + *value -= *value % 100; } void __fastcall sound_create_primary_buffer(HANDLE music_track) { - HRESULT error_code; - DSBUFFERDESC dsbuf; - WAVEFORMATEX format; - - if ( !music_track ) { - memset(&dsbuf, 0, sizeof(DSBUFFERDESC)); - dsbuf.dwSize = sizeof(DSBUFFERDESC); - dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER; - - error_code = sglpDS->CreateSoundBuffer(&dsbuf, &sglpDSB, NULL); - if ( error_code != DS_OK ) - DSErrMsg(error_code, 375, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - } - - if ( sglpDSB ) { - DSCAPS dsbcaps; - dsbcaps.dwSize = sizeof(DSCAPS); - - error_code = sglpDS->GetCaps(&dsbcaps); - if ( error_code != DS_OK ) - DSErrMsg(error_code, 383, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); - - if ( !music_track || !LoadWaveFormat(music_track, &format) ) { - memset(&format, 0, sizeof(WAVEFORMATEX)); - format.wFormatTag = WAVE_FORMAT_PCM; - format.nSamplesPerSec = 22050; - format.wBitsPerSample = 16; - format.cbSize = 0; - } - - format.nChannels = 2; - format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8; - format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; - - sglpDSB->SetFormat(&format); - } + HRESULT error_code; + DSBUFFERDESC dsbuf; + WAVEFORMATEX format; + + if (!music_track) { + memset(&dsbuf, 0, sizeof(DSBUFFERDESC)); + dsbuf.dwSize = sizeof(DSBUFFERDESC); + dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER; + + error_code = sglpDS->CreateSoundBuffer(&dsbuf, &sglpDSB, NULL); + if (error_code != DS_OK) + DSErrMsg(error_code, 375, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + } + + if (sglpDSB) { + DSCAPS dsbcaps; + dsbcaps.dwSize = sizeof(DSCAPS); + + error_code = sglpDS->GetCaps(&dsbcaps); + if (error_code != DS_OK) + DSErrMsg(error_code, 383, "C:\\Src\\Diablo\\Source\\SOUND.CPP"); + + if (!music_track || !LoadWaveFormat(music_track, &format)) { + memset(&format, 0, sizeof(WAVEFORMATEX)); + format.wFormatTag = WAVE_FORMAT_PCM; + format.nSamplesPerSec = 22050; + format.wBitsPerSample = 16; + format.cbSize = 0; + } + + format.nChannels = 2; + format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8; + format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; + + sglpDSB->SetFormat(&format); + } } // 69F100: using guessed type int sglpDSB; HRESULT __fastcall sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter) { - if ( hDsound_dll == NULL ) { - hDsound_dll = LoadLibrary("dsound.dll"); - if ( hDsound_dll == NULL ) { - ErrDlg(IDD_DIALOG5, GetLastError(), "C:\\Src\\Diablo\\Source\\SOUND.CPP", 422); - } - } - - HRESULT (WINAPI * DirectSoundCreate)(LPGUID lpGuid, LPDIRECTSOUND* ppDS, LPUNKNOWN pUnkOuter); - DirectSoundCreate = (HRESULT(WINAPI*)(LPGUID, LPDIRECTSOUND*, LPUNKNOWN))GetProcAddress(hDsound_dll, "DirectSoundCreate"); - if ( DirectSoundCreate == NULL ) { - ErrDlg(IDD_DIALOG5, GetLastError(), "C:\\Src\\Diablo\\Source\\SOUND.CPP", 427); - } - return DirectSoundCreate(lpGuid, ppDS, pUnkOuter); + if (hDsound_dll == NULL) { + hDsound_dll = LoadLibrary("dsound.dll"); + if (hDsound_dll == NULL) { + ErrDlg(IDD_DIALOG5, GetLastError(), "C:\\Src\\Diablo\\Source\\SOUND.CPP", 422); + } + } + + HRESULT(WINAPI * DirectSoundCreate) + (LPGUID lpGuid, LPDIRECTSOUND * ppDS, LPUNKNOWN pUnkOuter); + DirectSoundCreate = (HRESULT(WINAPI *)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN))GetProcAddress(hDsound_dll, "DirectSoundCreate"); + if (DirectSoundCreate == NULL) { + ErrDlg(IDD_DIALOG5, GetLastError(), "C:\\Src\\Diablo\\Source\\SOUND.CPP", 427); + } + return DirectSoundCreate(lpGuid, ppDS, pUnkOuter); } void __cdecl sound_cleanup() { - snd_update(TRUE); - SVidDestroy(); - SFileDdaDestroy(); - - if ( sglpDS ) { - sglpDS->Release(); - sglpDS = NULL; - } - - if ( gbSndInited ) { - gbSndInited = FALSE; - sound_store_volume("Sound Volume", sglSoundVolume); - sound_store_volume("Music Volume", sglMusicVolume); - } + snd_update(TRUE); + SVidDestroy(); + SFileDdaDestroy(); + + if (sglpDS) { + sglpDS->Release(); + sglpDS = NULL; + } + + if (gbSndInited) { + gbSndInited = FALSE; + sound_store_volume("Sound Volume", sglSoundVolume); + sound_store_volume("Music Volume", sglMusicVolume); + } } void __fastcall sound_store_volume(char *key, int value) { - SRegSaveValue("Diablo", key, 0, value); + SRegSaveValue("Diablo", key, 0, value); } void __cdecl music_stop() { - if ( sgpMusicTrack ) { - SFileDdaEnd(sgpMusicTrack); - SFileCloseFile(sgpMusicTrack); - sgpMusicTrack = 0; - sgnMusicTrack = 6; - } + if (sgpMusicTrack) { + SFileDdaEnd(sgpMusicTrack); + SFileCloseFile(sgpMusicTrack); + sgpMusicTrack = 0; + sgnMusicTrack = 6; + } } void __fastcall music_start(int nTrack) { - music_stop(); - if ( sglpDS && gbMusicOn ) { - BOOL success = SFileOpenFile(sgszMusicTracks[nTrack], &sgpMusicTrack); - sound_create_primary_buffer(sgpMusicTrack); - if ( !success ) { - sgpMusicTrack = 0; - } else { - SFileDdaBeginEx(sgpMusicTrack, 0x40000, 0x40000, 0, sglMusicVolume, 0, 0); - sgnMusicTrack = nTrack; - } - } + music_stop(); + if (sglpDS && gbMusicOn) { + BOOL success = SFileOpenFile(sgszMusicTracks[nTrack], &sgpMusicTrack); + sound_create_primary_buffer(sgpMusicTrack); + if (!success) { + sgpMusicTrack = 0; + } else { + SFileDdaBeginEx(sgpMusicTrack, 0x40000, 0x40000, 0, sglMusicVolume, 0, 0); + sgnMusicTrack = nTrack; + } + } } // 4A22D4: using guessed type char gbMusicOn; void __fastcall sound_disable_music(BOOL disable) { - if ( disable ) { - music_stop(); - } else if ( sgnMusicTrack != 6 ) { - music_start(sgnMusicTrack); - } + if (disable) { + music_stop(); + } else if (sgnMusicTrack != 6) { + music_start(sgnMusicTrack); + } } int __fastcall sound_get_or_set_music_volume(int volume) { - if ( volume == 1 ) - return sglMusicVolume; + if (volume == 1) + return sglMusicVolume; - sglMusicVolume = volume; + sglMusicVolume = volume; - if ( sgpMusicTrack ) - SFileDdaSetVolume(sgpMusicTrack, volume, 0); + if (sgpMusicTrack) + SFileDdaSetVolume(sgpMusicTrack, volume, 0); - return sglMusicVolume; + return sglMusicVolume; } int __fastcall sound_get_or_set_sound_volume(int volume) { - if ( volume == 1 ) - return sglSoundVolume; + if (volume == 1) + return sglSoundVolume; - sglSoundVolume = volume; + sglSoundVolume = volume; - return sglSoundVolume; + return sglSoundVolume; } diff --git a/Source/spells.cpp b/Source/spells.cpp index 9ac298d66..6669dc244 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -2,366 +2,314 @@ #include "../types.h" -SpellData spelldata[MAX_SPELLS] = -{ - { 0, 0, 0, NULL, NULL, 0, 0, FALSE, FALSE, 0, 0, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, - { SPL_FIREBOLT, 6, STYPE_FIRE, "Firebolt", "Firebolt", 1, 1, TRUE, FALSE, 15, IS_CAST2, { MIS_FIREBOLT, 0, 0 }, 1, 3, 40, 80, 1000, 50 }, - { SPL_HEAL, 5, STYPE_MAGIC, "Healing", NULL, 1, 1, FALSE, TRUE, 17, IS_CAST8, { MIS_HEAL, 0, 0 }, 3, 1, 20, 40, 1000, 50 }, - { SPL_LIGHTNING, 10, STYPE_LIGHTNING, "Lightning", NULL, 4, 3, TRUE, FALSE, 20, IS_CAST4, { MIS_LIGHTCTRL, 0, 0 }, 1, 6, 20, 60, 3000, 150 }, - { SPL_FLASH, 30, STYPE_LIGHTNING, "Flash", NULL, 5, 4, FALSE, FALSE, 33, IS_CAST4, { MIS_FLASH, MIS_FLASH2, 0 }, 2, 16, 20, 40, 7500, 500 }, - { SPL_IDENTIFY, 13, STYPE_MAGIC, "Identify", "Identify", -1, -1, FALSE, TRUE, 23, IS_CAST6, { MIS_IDENTIFY, 0, 0 }, 2, 1, 8, 12, 0, 100 }, - { SPL_FIREWALL, 28, STYPE_FIRE, "Fire Wall", NULL, 3, 2, TRUE, FALSE, 27, IS_CAST2, { MIS_FIREWALLC, 0, 0 }, 2, 16, 8, 16, 6000, 400 }, - { SPL_TOWN, 35, STYPE_MAGIC, "Town Portal", NULL, 3, 3, TRUE, FALSE, 20, IS_CAST6, { MIS_TOWN, 0, 0 }, 3, 18, 8, 12, 3000, 200 }, - { SPL_STONE, 60, STYPE_MAGIC, "Stone Curse", NULL, 6, 5, TRUE, FALSE, 51, IS_CAST2, { MIS_STONE, 0, 0 }, 3, 40, 8, 16, 12000, 800 }, - { SPL_INFRA, 40, STYPE_MAGIC, "Infravision", NULL, -1, -1, FALSE, FALSE, 36, IS_CAST8, { MIS_INFRA, 0, 0 }, 5, 20, 0, 0, 0, 600 }, - { SPL_RNDTELEPORT, 12, STYPE_MAGIC, "Phasing", NULL, 7, 6, FALSE, FALSE, 39, IS_CAST2, { MIS_RNDTELEPORT, 0, 0 }, 2, 4, 40, 80, 3500, 200 }, - { SPL_MANASHIELD, 33, STYPE_MAGIC, "Mana Shield", NULL, 6, 5, FALSE, FALSE, 25, IS_CAST2, { MIS_MANASHIELD, 0, 0 }, 0, 33, 4, 10, 16000, 1200 }, - { SPL_FIREBALL, 16, STYPE_FIRE, "Fireball", NULL, 8, 7, TRUE, FALSE, 48, IS_CAST2, { MIS_FIREBALL, 0, 0 }, 1, 10, 40, 80, 8000, 300 }, - { SPL_GUARDIAN, 50, STYPE_FIRE, "Guardian", NULL, 9, 8, TRUE, FALSE, 61, IS_CAST2, { MIS_GUARDIAN, 0, 0 }, 2, 30, 16, 32, 14000, 950 }, - { SPL_CHAIN, 30, STYPE_LIGHTNING, "Chain Lightning", NULL, 8, 7, FALSE, FALSE, 54, IS_CAST2, { MIS_CHAIN, 0, 0 }, 1, 18, 20, 60, 11000, 750 }, - { SPL_WAVE, 35, STYPE_FIRE, "Flame Wave", NULL, 9, 8, TRUE, FALSE, 54, IS_CAST2, { MIS_WAVE, 0, 0 }, 3, 20, 20, 40, 10000, 650 }, - { SPL_DOOMSERP, 0, STYPE_LIGHTNING, "Doom Serpents", NULL, -1, -1, FALSE, FALSE, 0, IS_CAST2, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, - { SPL_BLODRIT, 0, STYPE_MAGIC, "Blood Ritual", NULL, -1, -1, FALSE, FALSE, 0, IS_CAST2, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, - { SPL_NOVA, 60, STYPE_MAGIC, "Nova", NULL, -1, 10, FALSE, FALSE, 87, IS_CAST4, { MIS_NOVA, 0, 0 }, 3, 35, 16, 32, 21000, 1300 }, - { SPL_INVISIBIL, 0, STYPE_MAGIC, "Invisibility", NULL, -1, -1, FALSE, FALSE, 0, IS_CAST2, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, - { SPL_FLAME, 11, STYPE_FIRE, "Inferno", NULL, 3, 2, TRUE, FALSE, 20, IS_CAST2, { MIS_FLAMEC, 0, 0 }, 1, 6, 20, 40, 2000, 100 }, - { SPL_GOLEM, 100, STYPE_FIRE, "Golem", NULL, 11, 9, FALSE, FALSE, 81, IS_CAST2, { MIS_GOLEM, 0, 0 }, 6, 60, 16, 32, 18000, 1100 }, - { SPL_BLODBOIL, 0, STYPE_LIGHTNING, "Blood Boil", NULL, -1, -1, TRUE, FALSE, 0, IS_CAST8, { 0, 0, 0 }, 0, 0, 0, 0, 0, 0 }, - { SPL_TELEPORT, 35, STYPE_MAGIC, "Teleport", NULL, 14, 12, TRUE, FALSE, 105, IS_CAST6, { MIS_TELEPORT, 0, 0 }, 3, 15, 16, 32, 20000, 1250 }, - { SPL_APOCA, 150, STYPE_FIRE, "Apocalypse", NULL, -1, 15, FALSE, FALSE, 149, IS_CAST2, { MIS_APOCA, 0, 0 }, 6, 90, 8, 12, 30000, 2000 }, - { SPL_ETHEREALIZE, 100, STYPE_MAGIC, "Etherealize", NULL, -1, -1, FALSE, FALSE, 93, IS_CAST2, { MIS_ETHEREALIZE, 0, 0 }, 0, 100, 2, 6, 26000, 1600 }, - { SPL_REPAIR, 0, STYPE_MAGIC, "Item Repair", "Item Repair", -1, -1, FALSE, TRUE, -1, IS_CAST6, { MIS_REPAIR, 0, 0 }, 0, 0, 40, 80, 0, 0 }, - { SPL_RECHARGE, 0, STYPE_MAGIC, "Staff Recharge", "Staff Recharge", -1, -1, FALSE, TRUE, -1, IS_CAST6, { MIS_RECHARGE, 0, 0 }, 0, 0, 40, 80, 0, 0 }, - { SPL_DISARM, 0, STYPE_MAGIC, "Trap Disarm", "Trap Disarm", -1, -1, FALSE, FALSE, -1, IS_CAST6, { MIS_DISARM, 0, 0 }, 0, 0, 40, 80, 0, 0 }, - { SPL_ELEMENT, 35, STYPE_FIRE, "Elemental", NULL, 8, 6, FALSE, FALSE, 68, IS_CAST2, { MIS_ELEMENT, 0, 0 }, 2, 20, 20, 60, 10500, 700 }, - { SPL_CBOLT, 6, STYPE_LIGHTNING, "Charged Bolt", NULL, 1, 1, TRUE, FALSE, 25, IS_CAST2, { MIS_CBOLT, 0, 0 }, 1, 6, 40, 80, 1000, 50 }, - { SPL_HBOLT, 7, STYPE_MAGIC, "Holy Bolt", NULL, 1, 1, TRUE, FALSE, 20, IS_CAST2, { MIS_HBOLT, 0, 0 }, 1, 3, 40, 80, 1000, 50 }, - { SPL_RESURRECT, 20, STYPE_MAGIC, "Resurrect", NULL, -1, 5, FALSE, TRUE, 30, IS_CAST8, { MIS_RESURRECT, 0, 0 }, 0, 20, 4, 10, 4000, 250 }, - { SPL_TELEKINESIS, 15, STYPE_MAGIC, "Telekinesis", NULL, 2, 2, FALSE, FALSE, 33, IS_CAST2, { MIS_TELEKINESIS, 0, 0 }, 2, 8, 20, 40, 2500, 200 }, - { SPL_HEALOTHER, 5, STYPE_MAGIC, "Heal Other", NULL, 1, 1, FALSE, TRUE, 17, IS_CAST8, { MIS_HEALOTHER, 0, 0 }, 3, 1, 20, 40, 1000, 50 }, - { SPL_FLARE, 25, STYPE_MAGIC, "Blood Star", NULL, 14, 13, FALSE, FALSE, 70, IS_CAST2, { MIS_FLARE, 0, 0 }, 2, 14, 20, 60, 27500, 1800 }, - { SPL_BONESPIRIT, 24, STYPE_MAGIC, "Bone Spirit", NULL, 9, 7, FALSE, FALSE, 34, IS_CAST2, { MIS_BONESPIRIT, 0, 0 }, 1, 12, 20, 60, 11500, 800 } +SpellData spelldata[MAX_SPELLS] = { + { 0, 0, 0, NULL, NULL, 0, 0, FALSE, FALSE, 0, 0, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, + { SPL_FIREBOLT, 6, STYPE_FIRE, "Firebolt", "Firebolt", 1, 1, TRUE, FALSE, 15, IS_CAST2, { MIS_FIREBOLT, 0, 0 }, 1, 3, 40, 80, 1000, 50 }, + { SPL_HEAL, 5, STYPE_MAGIC, "Healing", NULL, 1, 1, FALSE, TRUE, 17, IS_CAST8, { MIS_HEAL, 0, 0 }, 3, 1, 20, 40, 1000, 50 }, + { SPL_LIGHTNING, 10, STYPE_LIGHTNING, "Lightning", NULL, 4, 3, TRUE, FALSE, 20, IS_CAST4, { MIS_LIGHTCTRL, 0, 0 }, 1, 6, 20, 60, 3000, 150 }, + { SPL_FLASH, 30, STYPE_LIGHTNING, "Flash", NULL, 5, 4, FALSE, FALSE, 33, IS_CAST4, { MIS_FLASH, MIS_FLASH2, 0 }, 2, 16, 20, 40, 7500, 500 }, + { SPL_IDENTIFY, 13, STYPE_MAGIC, "Identify", "Identify", -1, -1, FALSE, TRUE, 23, IS_CAST6, { MIS_IDENTIFY, 0, 0 }, 2, 1, 8, 12, 0, 100 }, + { SPL_FIREWALL, 28, STYPE_FIRE, "Fire Wall", NULL, 3, 2, TRUE, FALSE, 27, IS_CAST2, { MIS_FIREWALLC, 0, 0 }, 2, 16, 8, 16, 6000, 400 }, + { SPL_TOWN, 35, STYPE_MAGIC, "Town Portal", NULL, 3, 3, TRUE, FALSE, 20, IS_CAST6, { MIS_TOWN, 0, 0 }, 3, 18, 8, 12, 3000, 200 }, + { SPL_STONE, 60, STYPE_MAGIC, "Stone Curse", NULL, 6, 5, TRUE, FALSE, 51, IS_CAST2, { MIS_STONE, 0, 0 }, 3, 40, 8, 16, 12000, 800 }, + { SPL_INFRA, 40, STYPE_MAGIC, "Infravision", NULL, -1, -1, FALSE, FALSE, 36, IS_CAST8, { MIS_INFRA, 0, 0 }, 5, 20, 0, 0, 0, 600 }, + { SPL_RNDTELEPORT, 12, STYPE_MAGIC, "Phasing", NULL, 7, 6, FALSE, FALSE, 39, IS_CAST2, { MIS_RNDTELEPORT, 0, 0 }, 2, 4, 40, 80, 3500, 200 }, + { SPL_MANASHIELD, 33, STYPE_MAGIC, "Mana Shield", NULL, 6, 5, FALSE, FALSE, 25, IS_CAST2, { MIS_MANASHIELD, 0, 0 }, 0, 33, 4, 10, 16000, 1200 }, + { SPL_FIREBALL, 16, STYPE_FIRE, "Fireball", NULL, 8, 7, TRUE, FALSE, 48, IS_CAST2, { MIS_FIREBALL, 0, 0 }, 1, 10, 40, 80, 8000, 300 }, + { SPL_GUARDIAN, 50, STYPE_FIRE, "Guardian", NULL, 9, 8, TRUE, FALSE, 61, IS_CAST2, { MIS_GUARDIAN, 0, 0 }, 2, 30, 16, 32, 14000, 950 }, + { SPL_CHAIN, 30, STYPE_LIGHTNING, "Chain Lightning", NULL, 8, 7, FALSE, FALSE, 54, IS_CAST2, { MIS_CHAIN, 0, 0 }, 1, 18, 20, 60, 11000, 750 }, + { SPL_WAVE, 35, STYPE_FIRE, "Flame Wave", NULL, 9, 8, TRUE, FALSE, 54, IS_CAST2, { MIS_WAVE, 0, 0 }, 3, 20, 20, 40, 10000, 650 }, + { SPL_DOOMSERP, 0, STYPE_LIGHTNING, "Doom Serpents", NULL, -1, -1, FALSE, FALSE, 0, IS_CAST2, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, + { SPL_BLODRIT, 0, STYPE_MAGIC, "Blood Ritual", NULL, -1, -1, FALSE, FALSE, 0, IS_CAST2, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, + { SPL_NOVA, 60, STYPE_MAGIC, "Nova", NULL, -1, 10, FALSE, FALSE, 87, IS_CAST4, { MIS_NOVA, 0, 0 }, 3, 35, 16, 32, 21000, 1300 }, + { SPL_INVISIBIL, 0, STYPE_MAGIC, "Invisibility", NULL, -1, -1, FALSE, FALSE, 0, IS_CAST2, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, + { SPL_FLAME, 11, STYPE_FIRE, "Inferno", NULL, 3, 2, TRUE, FALSE, 20, IS_CAST2, { MIS_FLAMEC, 0, 0 }, 1, 6, 20, 40, 2000, 100 }, + { SPL_GOLEM, 100, STYPE_FIRE, "Golem", NULL, 11, 9, FALSE, FALSE, 81, IS_CAST2, { MIS_GOLEM, 0, 0 }, 6, 60, 16, 32, 18000, 1100 }, + { SPL_BLODBOIL, 0, STYPE_LIGHTNING, "Blood Boil", NULL, -1, -1, TRUE, FALSE, 0, IS_CAST8, { 0, 0, 0 }, 0, 0, 0, 0, 0, 0 }, + { SPL_TELEPORT, 35, STYPE_MAGIC, "Teleport", NULL, 14, 12, TRUE, FALSE, 105, IS_CAST6, { MIS_TELEPORT, 0, 0 }, 3, 15, 16, 32, 20000, 1250 }, + { SPL_APOCA, 150, STYPE_FIRE, "Apocalypse", NULL, -1, 15, FALSE, FALSE, 149, IS_CAST2, { MIS_APOCA, 0, 0 }, 6, 90, 8, 12, 30000, 2000 }, + { SPL_ETHEREALIZE, 100, STYPE_MAGIC, "Etherealize", NULL, -1, -1, FALSE, FALSE, 93, IS_CAST2, { MIS_ETHEREALIZE, 0, 0 }, 0, 100, 2, 6, 26000, 1600 }, + { SPL_REPAIR, 0, STYPE_MAGIC, "Item Repair", "Item Repair", -1, -1, FALSE, TRUE, -1, IS_CAST6, { MIS_REPAIR, 0, 0 }, 0, 0, 40, 80, 0, 0 }, + { SPL_RECHARGE, 0, STYPE_MAGIC, "Staff Recharge", "Staff Recharge", -1, -1, FALSE, TRUE, -1, IS_CAST6, { MIS_RECHARGE, 0, 0 }, 0, 0, 40, 80, 0, 0 }, + { SPL_DISARM, 0, STYPE_MAGIC, "Trap Disarm", "Trap Disarm", -1, -1, FALSE, FALSE, -1, IS_CAST6, { MIS_DISARM, 0, 0 }, 0, 0, 40, 80, 0, 0 }, + { SPL_ELEMENT, 35, STYPE_FIRE, "Elemental", NULL, 8, 6, FALSE, FALSE, 68, IS_CAST2, { MIS_ELEMENT, 0, 0 }, 2, 20, 20, 60, 10500, 700 }, + { SPL_CBOLT, 6, STYPE_LIGHTNING, "Charged Bolt", NULL, 1, 1, TRUE, FALSE, 25, IS_CAST2, { MIS_CBOLT, 0, 0 }, 1, 6, 40, 80, 1000, 50 }, + { SPL_HBOLT, 7, STYPE_MAGIC, "Holy Bolt", NULL, 1, 1, TRUE, FALSE, 20, IS_CAST2, { MIS_HBOLT, 0, 0 }, 1, 3, 40, 80, 1000, 50 }, + { SPL_RESURRECT, 20, STYPE_MAGIC, "Resurrect", NULL, -1, 5, FALSE, TRUE, 30, IS_CAST8, { MIS_RESURRECT, 0, 0 }, 0, 20, 4, 10, 4000, 250 }, + { SPL_TELEKINESIS, 15, STYPE_MAGIC, "Telekinesis", NULL, 2, 2, FALSE, FALSE, 33, IS_CAST2, { MIS_TELEKINESIS, 0, 0 }, 2, 8, 20, 40, 2500, 200 }, + { SPL_HEALOTHER, 5, STYPE_MAGIC, "Heal Other", NULL, 1, 1, FALSE, TRUE, 17, IS_CAST8, { MIS_HEALOTHER, 0, 0 }, 3, 1, 20, 40, 1000, 50 }, + { SPL_FLARE, 25, STYPE_MAGIC, "Blood Star", NULL, 14, 13, FALSE, FALSE, 70, IS_CAST2, { MIS_FLARE, 0, 0 }, 2, 14, 20, 60, 27500, 1800 }, + { SPL_BONESPIRIT, 24, STYPE_MAGIC, "Bone Spirit", NULL, 9, 7, FALSE, FALSE, 34, IS_CAST2, { MIS_BONESPIRIT, 0, 0 }, 1, 12, 20, 60, 11500, 800 } }; int __fastcall GetManaAmount(int id, int sn) { - int i; // "raw" mana cost - int ma; // mana amount - - // mana adjust - int adj = 0; - - // spell level - int sl = plr[id]._pSplLvl[sn] + plr[id]._pISplLvlAdd - 1; - - if ( sl < 0 ) - { - sl = 0; - } - - if ( sl > 0 ) - { - adj = sl * spelldata[sn].sManaAdj; - } - if ( sn == SPL_FIREBOLT ) - { - adj >>= 1; - } - if ( sn == SPL_RESURRECT && sl > 0 ) - { - adj = sl * (spelldata[SPL_RESURRECT].sManaCost / 8); - } - - if ( spelldata[sn].sManaCost == 255 ) // TODO: check sign - { - i = (BYTE)plr[id]._pMaxManaBase; - } - else - { - i = spelldata[sn].sManaCost; - } - - ma = (i - adj) << 6; - - if ( sn == SPL_HEAL ) - { - ma = (spelldata[SPL_HEAL].sManaCost + 2 * plr[id]._pLevel - adj) << 6; - } - if ( sn == SPL_HEALOTHER ) - { - ma = (spelldata[SPL_HEAL].sManaCost + 2 * plr[id]._pLevel - adj) << 6; - } - - if ( plr[id]._pClass == PC_ROGUE ) - { - ma -= ma >> 2; - } - - if ( spelldata[sn].sMinMana > ma >> 6 ) - { - ma = spelldata[sn].sMinMana << 6; - } - - return ma * (100 - plr[id]._pISplCost) / 100; + int i; // "raw" mana cost + int ma; // mana amount + + // mana adjust + int adj = 0; + + // spell level + int sl = plr[id]._pSplLvl[sn] + plr[id]._pISplLvlAdd - 1; + + if (sl < 0) { + sl = 0; + } + + if (sl > 0) { + adj = sl * spelldata[sn].sManaAdj; + } + if (sn == SPL_FIREBOLT) { + adj >>= 1; + } + if (sn == SPL_RESURRECT && sl > 0) { + adj = sl * (spelldata[SPL_RESURRECT].sManaCost / 8); + } + + if (spelldata[sn].sManaCost == 255) // TODO: check sign + { + i = (BYTE)plr[id]._pMaxManaBase; + } else { + i = spelldata[sn].sManaCost; + } + + ma = (i - adj) << 6; + + if (sn == SPL_HEAL) { + ma = (spelldata[SPL_HEAL].sManaCost + 2 * plr[id]._pLevel - adj) << 6; + } + if (sn == SPL_HEALOTHER) { + ma = (spelldata[SPL_HEAL].sManaCost + 2 * plr[id]._pLevel - adj) << 6; + } + + if (plr[id]._pClass == PC_ROGUE) { + ma -= ma >> 2; + } + + if (spelldata[sn].sMinMana > ma >> 6) { + ma = spelldata[sn].sMinMana << 6; + } + + return ma * (100 - plr[id]._pISplCost) / 100; } void __fastcall UseMana(int id, int sn) { - int ma; // mana cost + int ma; // mana cost - if ( id == myplr ) - { - switch ( plr[id]._pSplType ) - { - case RSPLTYPE_SPELL: + if (id == myplr) { + switch (plr[id]._pSplType) { + case RSPLTYPE_SPELL: #ifdef _DEBUG - if ( !debug_mode_key_inverted_v ) - { + if (!debug_mode_key_inverted_v) { #endif - ma = GetManaAmount(id, sn); - plr[id]._pMana -= ma; - plr[id]._pManaBase -= ma; - drawmanaflag = TRUE; + ma = GetManaAmount(id, sn); + plr[id]._pMana -= ma; + plr[id]._pManaBase -= ma; + drawmanaflag = TRUE; #ifdef _DEBUG - } + } #endif - break; - case RSPLTYPE_SCROLL: - RemoveScroll(id); - break; - case RSPLTYPE_CHARGES: - UseStaffCharge(id); - break; - } - } + break; + case RSPLTYPE_SCROLL: + RemoveScroll(id); + break; + case RSPLTYPE_CHARGES: + UseStaffCharge(id); + break; + } + } } BOOL __fastcall CheckSpell(int id, int sn, BYTE st, BOOL manaonly) { #ifdef _DEBUG - if ( debug_mode_key_inverted_v ) - return TRUE; + if (debug_mode_key_inverted_v) + return TRUE; #endif - BOOL result = TRUE; - if ( !manaonly && pcurs != 1 ) - { - result = FALSE; - } - else - { - if ( st != RSPLTYPE_SKILL ) - { - if ( GetSpellLevel(id, sn) <= 0 ) - { - result = FALSE; - } - else - { - result = plr[id]._pMana >= GetManaAmount(id, sn); - } - } - } - - return result; + BOOL result = TRUE; + if (!manaonly && pcurs != 1) { + result = FALSE; + } else { + if (st != RSPLTYPE_SKILL) { + if (GetSpellLevel(id, sn) <= 0) { + result = FALSE; + } else { + result = plr[id]._pMana >= GetManaAmount(id, sn); + } + } + } + + return result; } void __fastcall CastSpell(int id, int spl, int sx, int sy, int dx, int dy, BOOL caster, int spllvl) { - int dir; // missile direction - - // ugly switch, but generates the right code - switch ( caster ) - { - case TRUE: - dir = monster[id]._mdir; - break; - case FALSE: - // caster must be 0 already in this case, but oh well, - // it's needed to generate the right code - caster = 0; - dir = plr[id]._pdir; - - if ( spl == SPL_FIREWALL ) - { - dir = plr[id]._pVar3; - } - break; - } - - for ( int i = 0; spelldata[spl].sMissiles[i] != MIS_ARROW && i < 3; i++ ) - { - AddMissile(sx, sy, dx, dy, dir, spelldata[spl].sMissiles[i], caster, id, 0, spllvl); - } - - if ( spelldata[spl].sMissiles[0] == MIS_TOWN ) - { - UseMana(id, SPL_TOWN); - } - if ( spelldata[spl].sMissiles[0] == MIS_CBOLT ) - { - UseMana(id, SPL_CBOLT); - - for ( int i = 0; i < (spllvl >> 1) + 3; i++ ) - { - AddMissile(sx, sy, dx, dy, dir, MIS_CBOLT, caster, id, 0, spllvl); - } - } + int dir; // missile direction + + // ugly switch, but generates the right code + switch (caster) { + case TRUE: + dir = monster[id]._mdir; + break; + case FALSE: + // caster must be 0 already in this case, but oh well, + // it's needed to generate the right code + caster = 0; + dir = plr[id]._pdir; + + if (spl == SPL_FIREWALL) { + dir = plr[id]._pVar3; + } + break; + } + + for (int i = 0; spelldata[spl].sMissiles[i] != MIS_ARROW && i < 3; i++) { + AddMissile(sx, sy, dx, dy, dir, spelldata[spl].sMissiles[i], caster, id, 0, spllvl); + } + + if (spelldata[spl].sMissiles[0] == MIS_TOWN) { + UseMana(id, SPL_TOWN); + } + if (spelldata[spl].sMissiles[0] == MIS_CBOLT) { + UseMana(id, SPL_CBOLT); + + for (int i = 0; i < (spllvl >> 1) + 3; i++) { + AddMissile(sx, sy, dx, dy, dir, MIS_CBOLT, caster, id, 0, spllvl); + } + } } // pnum: player index // rid: target player index void __fastcall DoResurrect(int pnum, int rid) { - if ( (char)rid != -1 ) - { - AddMissile(plr[rid].WorldX, plr[rid].WorldY, plr[rid].WorldX, plr[rid].WorldY, 0, MIS_RESURRECTBEAM, 0, pnum, 0, 0); - } - - if ( pnum == myplr ) - { - NewCursor(CURSOR_HAND); - } - - if ( (char)rid != -1 && plr[rid]._pHitPoints == 0 ) - { - if ( rid == myplr ) - { - deathflag = FALSE; - gamemenu_off(); - drawhpflag = TRUE; - drawmanaflag = TRUE; - } - - ClrPlrPath(rid); - plr[rid].destAction = ACTION_NONE; - plr[rid]._pInvincible = 0; - PlacePlayer(rid); - - int hp = 640; - if ( plr[rid]._pMaxHPBase < 640 ) - { - hp = plr[rid]._pMaxHPBase; - } - SetPlayerHitPoints(rid, hp); - - plr[rid]._pMana = 0; - plr[rid]._pHPBase = plr[rid]._pHitPoints + (plr[rid]._pMaxHPBase - plr[rid]._pMaxHP); - plr[rid]._pManaBase = plr[rid]._pMaxManaBase - plr[rid]._pMaxMana; - - CalcPlrInv(rid, TRUE); - - if ( plr[rid].plrlevel == currlevel ) - { - StartStand(rid, plr[rid]._pdir); - } - else - { - plr[rid]._pmode = 0; - } - } + if ((char)rid != -1) { + AddMissile(plr[rid].WorldX, plr[rid].WorldY, plr[rid].WorldX, plr[rid].WorldY, 0, MIS_RESURRECTBEAM, 0, pnum, 0, 0); + } + + if (pnum == myplr) { + NewCursor(CURSOR_HAND); + } + + if ((char)rid != -1 && plr[rid]._pHitPoints == 0) { + if (rid == myplr) { + deathflag = FALSE; + gamemenu_off(); + drawhpflag = TRUE; + drawmanaflag = TRUE; + } + + ClrPlrPath(rid); + plr[rid].destAction = ACTION_NONE; + plr[rid]._pInvincible = 0; + PlacePlayer(rid); + + int hp = 640; + if (plr[rid]._pMaxHPBase < 640) { + hp = plr[rid]._pMaxHPBase; + } + SetPlayerHitPoints(rid, hp); + + plr[rid]._pMana = 0; + plr[rid]._pHPBase = plr[rid]._pHitPoints + (plr[rid]._pMaxHPBase - plr[rid]._pMaxHP); + plr[rid]._pManaBase = plr[rid]._pMaxManaBase - plr[rid]._pMaxMana; + + CalcPlrInv(rid, TRUE); + + if (plr[rid].plrlevel == currlevel) { + StartStand(rid, plr[rid]._pdir); + } else { + plr[rid]._pmode = 0; + } + } } void __fastcall PlacePlayer(int pnum) { - int nx; - int ny; - - if ( plr[pnum].plrlevel == currlevel ) - { - for ( DWORD i = 0; i < 8; i++ ) - { - nx = plr[pnum].WorldX + plrxoff2[i]; - ny = plr[pnum].WorldY + plryoff2[i]; - - if ( PosOkPlayer(pnum, nx, ny) ) - { - break; - } - } - - if ( !PosOkPlayer(pnum, nx, ny) ) - { - BOOL done = FALSE; - - for ( int max = 1, min = -1; min > -50 && !done; max++, min-- ) - { - for ( int y = min; y <= max && !done; y++ ) - { - ny = plr[pnum].WorldY + y; - - for ( int x = min; x <= max && !done; x++ ) - { - nx = plr[pnum].WorldX + x; - - if ( PosOkPlayer(pnum, nx, ny) ) - { - done = TRUE; - } - } - } - } - } - - plr[pnum].WorldX = nx; - plr[pnum].WorldY = ny; - - dPlayer[nx][ny] = pnum + 1; - - if ( pnum == myplr ) - { - ViewX = nx; - ViewY = ny; - } - } + int nx; + int ny; + + if (plr[pnum].plrlevel == currlevel) { + for (DWORD i = 0; i < 8; i++) { + nx = plr[pnum].WorldX + plrxoff2[i]; + ny = plr[pnum].WorldY + plryoff2[i]; + + if (PosOkPlayer(pnum, nx, ny)) { + break; + } + } + + if (!PosOkPlayer(pnum, nx, ny)) { + BOOL done = FALSE; + + for (int max = 1, min = -1; min > -50 && !done; max++, min--) { + for (int y = min; y <= max && !done; y++) { + ny = plr[pnum].WorldY + y; + + for (int x = min; x <= max && !done; x++) { + nx = plr[pnum].WorldX + x; + + if (PosOkPlayer(pnum, nx, ny)) { + done = TRUE; + } + } + } + } + } + + plr[pnum].WorldX = nx; + plr[pnum].WorldY = ny; + + dPlayer[nx][ny] = pnum + 1; + + if (pnum == myplr) { + ViewX = nx; + ViewY = ny; + } + } } void __fastcall DoHealOther(int pnum, int rid) { - if ( pnum == myplr ) - { - NewCursor(CURSOR_HAND); - } - - if ( (char)rid != -1 && (plr[rid]._pHitPoints >> 6) > 0 ) - { - int hp = (random(57, 10) + 1) << 6; - - for ( int i = 0; i < plr[pnum]._pLevel; i++ ) - { - hp += (random(57, 4) + 1) << 6; - } - - for ( int j = 0; j < GetSpellLevel(pnum, SPL_HEALOTHER); ++j ) - { - hp += (random(57, 6) + 1) << 6; - } - - if ( plr[pnum]._pClass == PC_WARRIOR ) - { - hp <<= 1; - } - - if ( plr[pnum]._pClass == PC_ROGUE ) - { - hp += hp >> 1; - } - - plr[rid]._pHitPoints += hp; - - if ( plr[rid]._pHitPoints > plr[rid]._pMaxHP ) - { - plr[rid]._pHitPoints = plr[rid]._pMaxHP; - } - - plr[rid]._pHPBase += hp; - - if ( plr[rid]._pHPBase > plr[rid]._pMaxHPBase ) - { - plr[rid]._pHPBase = plr[rid]._pMaxHPBase; - } - - drawhpflag = TRUE; - } + if (pnum == myplr) { + NewCursor(CURSOR_HAND); + } + + if ((char)rid != -1 && (plr[rid]._pHitPoints >> 6) > 0) { + int hp = (random(57, 10) + 1) << 6; + + for (int i = 0; i < plr[pnum]._pLevel; i++) { + hp += (random(57, 4) + 1) << 6; + } + + for (int j = 0; j < GetSpellLevel(pnum, SPL_HEALOTHER); ++j) { + hp += (random(57, 6) + 1) << 6; + } + + if (plr[pnum]._pClass == PC_WARRIOR) { + hp <<= 1; + } + + if (plr[pnum]._pClass == PC_ROGUE) { + hp += hp >> 1; + } + + plr[rid]._pHitPoints += hp; + + if (plr[rid]._pHitPoints > plr[rid]._pMaxHP) { + plr[rid]._pHitPoints = plr[rid]._pMaxHP; + } + + plr[rid]._pHPBase += hp; + + if (plr[rid]._pHPBase > plr[rid]._pMaxHPBase) { + plr[rid]._pHPBase = plr[rid]._pMaxHPBase; + } + + drawhpflag = TRUE; + } } diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index f4bc857fa..f997297c2 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -6,44 +6,45 @@ static TMsg *sgpTimedMsgHead; int __fastcall tmsg_get(BYTE *pbMsg, DWORD dwMaxLen) { - int len; - TMsg *head; - - if ( !sgpTimedMsgHead ) - return 0; - - if ( (int)(sgpTimedMsgHead->hdr.dwTime - GetTickCount()) >= 0 ) - return 0; - head = sgpTimedMsgHead; - sgpTimedMsgHead = head->hdr.pNext; - len = head->hdr.bLen; - // BUGFIX: ignores dwMaxLen - memcpy(pbMsg, head->body, len); - mem_free_dbg(head); - return len; + int len; + TMsg *head; + + if (!sgpTimedMsgHead) + return 0; + + if ((int)(sgpTimedMsgHead->hdr.dwTime - GetTickCount()) >= 0) + return 0; + head = sgpTimedMsgHead; + sgpTimedMsgHead = head->hdr.pNext; + len = head->hdr.bLen; + // BUGFIX: ignores dwMaxLen + memcpy(pbMsg, head->body, len); + mem_free_dbg(head); + return len; } void __fastcall tmsg_add(BYTE *pbMsg, BYTE bLen) { - TMsg **tail; - - TMsg *msg = (TMsg*)DiabloAllocPtr(bLen + sizeof(*msg)); - msg->hdr.pNext = NULL; - msg->hdr.dwTime = GetTickCount() + 500; - msg->hdr.bLen = bLen; - memcpy(msg->body, pbMsg, bLen); - for ( tail = &sgpTimedMsgHead; *tail; tail = &(*tail)->hdr.pNext ); - *tail = msg; + TMsg **tail; + + TMsg *msg = (TMsg *)DiabloAllocPtr(bLen + sizeof(*msg)); + msg->hdr.pNext = NULL; + msg->hdr.dwTime = GetTickCount() + 500; + msg->hdr.bLen = bLen; + memcpy(msg->body, pbMsg, bLen); + for (tail = &sgpTimedMsgHead; *tail; tail = &(*tail)->hdr.pNext) + ; + *tail = msg; } -void* __cdecl tmsg_cleanup() +void *__cdecl tmsg_cleanup() { - while ( sgpTimedMsgHead ) { - TMsg *next = sgpTimedMsgHead->hdr.pNext; - TMsg *head = sgpTimedMsgHead; - sgpTimedMsgHead = NULL; - mem_free_dbg(head); - sgpTimedMsgHead = next; - } - return sgpTimedMsgHead; + while (sgpTimedMsgHead) { + TMsg *next = sgpTimedMsgHead->hdr.pNext; + TMsg *head = sgpTimedMsgHead; + sgpTimedMsgHead = NULL; + mem_free_dbg(head); + sgpTimedMsgHead = next; + } + return sgpTimedMsgHead; } diff --git a/enums.h b/enums.h index ccac8b56d..edf590fa1 100644 --- a/enums.h +++ b/enums.h @@ -1,2758 +1,2709 @@ -enum unique_base_item -{ - UITYPE_NONE = 0x0, - UITYPE_SHORTBOW = 0x1, - UITYPE_LONGBOW = 0x2, - UITYPE_HUNTBOW = 0x3, - UITYPE_COMPBOW = 0x4, - UITYPE_WARBOW = 0x5, - UITYPE_BATTLEBOW = 0x6, - UITYPE_DAGGER = 0x7, - UITYPE_FALCHION = 0x8, - UITYPE_CLAYMORE = 0x9, - UITYPE_BROADSWR = 0xA, - UITYPE_SABRE = 0xB, - UITYPE_SCIMITAR = 0xC, - UITYPE_LONGSWR = 0xD, - UITYPE_BASTARDSWR = 0xE, - UITYPE_TWOHANDSWR = 0xF, - UITYPE_GREATSWR = 0x10, - UITYPE_CLEAVER = 0x11, - UITYPE_LARGEAXE = 0x12, - UITYPE_BROADAXE = 0x13, - UITYPE_SMALLAXE = 0x14, - UITYPE_BATTLEAXE = 0x15, - UITYPE_GREATAXE = 0x16, - UITYPE_MACE = 0x17, - UITYPE_MORNSTAR = 0x18, - UITYPE_SPIKCLUB = 0x19, - UITYPE_MAUL = 0x1A, - UITYPE_WARHAMMER = 0x1B, - UITYPE_FLAIL = 0x1C, - UITYPE_LONGSTAFF = 0x1D, - UITYPE_SHORTSTAFF = 0x1E, - UITYPE_COMPSTAFF = 0x1F, - UITYPE_QUARSTAFF = 0x20, - UITYPE_WARSTAFF = 0x21, - UITYPE_SKULLCAP = 0x22, - UITYPE_HELM = 0x23, - UITYPE_GREATHELM = 0x24, - UITYPE_CROWN = 0x25, - UITYPE_38 = 0x26, - UITYPE_RAGS = 0x27, - UITYPE_STUDARMOR = 0x28, - UITYPE_CLOAK = 0x29, - UITYPE_ROBE = 0x2A, - UITYPE_CHAINMAIL = 0x2B, - UITYPE_LEATHARMOR = 0x2C, - UITYPE_BREASTPLATE = 0x2D, - UITYPE_CAPE = 0x2E, - UITYPE_PLATEMAIL = 0x2F, - UITYPE_FULLPLATE = 0x30, - UITYPE_BUCKLER = 0x31, - UITYPE_SMALLSHIELD = 0x32, - UITYPE_LARGESHIELD = 0x33, - UITYPE_KITESHIELD = 0x34, - UITYPE_GOTHSHIELD = 0x35, - UITYPE_RING = 0x36, - UITYPE_55 = 0x37, - UITYPE_AMULET = 0x38, - UITYPE_SKCROWN = 0x39, - UITYPE_INFRARING = 0x3A, - UITYPE_OPTAMULET = 0x3B, - UITYPE_TRING = 0x3C, - UITYPE_HARCREST = 0x3D, - UITYPE_MAPOFDOOM = 0x3E, - UITYPE_ELIXIR = 0x3F, - UITYPE_ARMOFVAL = 0x40, - UITYPE_STEELVEIL = 0x41, - UITYPE_GRISWOLD = 0x42, - UITYPE_LGTFORGE = 0x43, - UITYPE_LAZSTAFF = 0x44, - UITYPE_INVALID = -1, +enum unique_base_item { + UITYPE_NONE = 0x0, + UITYPE_SHORTBOW = 0x1, + UITYPE_LONGBOW = 0x2, + UITYPE_HUNTBOW = 0x3, + UITYPE_COMPBOW = 0x4, + UITYPE_WARBOW = 0x5, + UITYPE_BATTLEBOW = 0x6, + UITYPE_DAGGER = 0x7, + UITYPE_FALCHION = 0x8, + UITYPE_CLAYMORE = 0x9, + UITYPE_BROADSWR = 0xA, + UITYPE_SABRE = 0xB, + UITYPE_SCIMITAR = 0xC, + UITYPE_LONGSWR = 0xD, + UITYPE_BASTARDSWR = 0xE, + UITYPE_TWOHANDSWR = 0xF, + UITYPE_GREATSWR = 0x10, + UITYPE_CLEAVER = 0x11, + UITYPE_LARGEAXE = 0x12, + UITYPE_BROADAXE = 0x13, + UITYPE_SMALLAXE = 0x14, + UITYPE_BATTLEAXE = 0x15, + UITYPE_GREATAXE = 0x16, + UITYPE_MACE = 0x17, + UITYPE_MORNSTAR = 0x18, + UITYPE_SPIKCLUB = 0x19, + UITYPE_MAUL = 0x1A, + UITYPE_WARHAMMER = 0x1B, + UITYPE_FLAIL = 0x1C, + UITYPE_LONGSTAFF = 0x1D, + UITYPE_SHORTSTAFF = 0x1E, + UITYPE_COMPSTAFF = 0x1F, + UITYPE_QUARSTAFF = 0x20, + UITYPE_WARSTAFF = 0x21, + UITYPE_SKULLCAP = 0x22, + UITYPE_HELM = 0x23, + UITYPE_GREATHELM = 0x24, + UITYPE_CROWN = 0x25, + UITYPE_38 = 0x26, + UITYPE_RAGS = 0x27, + UITYPE_STUDARMOR = 0x28, + UITYPE_CLOAK = 0x29, + UITYPE_ROBE = 0x2A, + UITYPE_CHAINMAIL = 0x2B, + UITYPE_LEATHARMOR = 0x2C, + UITYPE_BREASTPLATE = 0x2D, + UITYPE_CAPE = 0x2E, + UITYPE_PLATEMAIL = 0x2F, + UITYPE_FULLPLATE = 0x30, + UITYPE_BUCKLER = 0x31, + UITYPE_SMALLSHIELD = 0x32, + UITYPE_LARGESHIELD = 0x33, + UITYPE_KITESHIELD = 0x34, + UITYPE_GOTHSHIELD = 0x35, + UITYPE_RING = 0x36, + UITYPE_55 = 0x37, + UITYPE_AMULET = 0x38, + UITYPE_SKCROWN = 0x39, + UITYPE_INFRARING = 0x3A, + UITYPE_OPTAMULET = 0x3B, + UITYPE_TRING = 0x3C, + UITYPE_HARCREST = 0x3D, + UITYPE_MAPOFDOOM = 0x3E, + UITYPE_ELIXIR = 0x3F, + UITYPE_ARMOFVAL = 0x40, + UITYPE_STEELVEIL = 0x41, + UITYPE_GRISWOLD = 0x42, + UITYPE_LGTFORGE = 0x43, + UITYPE_LAZSTAFF = 0x44, + UITYPE_INVALID = -1, }; -enum item_effect_type -{ - IPL_TOHIT = 0x0, - IPL_TOHIT_CURSE = 0x1, - IPL_DAMP = 0x2, - IPL_DAMP_CURSE = 0x3, - IPL_TOHIT_DAMP = 0x4, - IPL_TOHIT_DAMP_CURSE = 0x5, - IPL_ACP = 0x6, - IPL_ACP_CURSE = 0x7, - IPL_FIRERES = 0x8, - IPL_LIGHTRES = 0x9, - IPL_MAGICRES = 0xA, - IPL_ALLRES = 0xB, - IPL_SPLLVLADD = 0xE, - IPL_CHARGES = 0xF, - IPL_FIREDAM = 0x10, - IPL_LIGHTDAM = 0x11, - IPL_STR = 0x13, - IPL_STR_CURSE = 0x14, - IPL_MAG = 0x15, - IPL_MAG_CURSE = 0x16, - IPL_DEX = 0x17, - IPL_DEX_CURSE = 0x18, - IPL_VIT = 0x19, - IPL_VIT_CURSE = 0x1A, - IPL_ATTRIBS = 0x1B, - IPL_ATTRIBS_CURSE = 0x1C, - IPL_GETHIT_CURSE = 0x1D, - IPL_GETHIT = 0x1E, - IPL_LIFE = 0x1F, - IPL_LIFE_CURSE = 0x20, - IPL_MANA = 0x21, - IPL_MANA_CURSE = 0x22, - IPL_DUR = 0x23, - IPL_DUR_CURSE = 0x24, - IPL_INDESTRUCTIBLE = 0x25, - IPL_LIGHT = 0x26, - IPL_LIGHT_CURSE = 0x27, - IPL_MULT_ARROWS = 0x29, /* only used in hellfire */ - IPL_FIRE_ARROWS = 0x2A, - IPL_LIGHT_ARROWS = 0x2B, - IPL_INVCURS = 0x2C, - IPL_THORNS = 0x2D, - IPL_NOMANA = 0x2E, - IPL_NOHEALPLR = 0x2F, - IPL_ABSHALFTRAP = 0x34, - IPL_KNOCKBACK = 0x35, - IPL_NOHEALMON = 0x36, - IPL_STEALMANA = 0x37, - IPL_STEALLIFE = 0x38, - IPL_TARGAC = 0x39, - IPL_FASTATTACK = 0x3A, - IPL_FASTRECOVER = 0x3B, - IPL_FASTBLOCK = 0x3C, - IPL_DAMMOD = 0x3D, - IPL_RNDARROWVEL = 0x3E, - IPL_SETDAM = 0x3F, - IPL_SETDUR = 0x40, - IPL_NOMINSTR = 0x41, - IPL_SPELL = 0x42, - IPL_FASTSWING = 0x43, - IPL_ONEHAND = 0x44, - IPL_3XDAMVDEM = 0x45, - IPL_ALLRESZERO = 0x46, - IPL_DRAINLIFE = 0x48, - IPL_RNDSTEALLIFE = 0x49, - IPL_INFRAVISION = 0x4A, - IPL_SETAC = 0x4B, - IPL_ADDACLIFE = 0x4C, - IPL_ADDMANAAC = 0x4D, - IPL_FIRERESCLVL = 0x4E, - IPL_AC_CURSE = 0x4F, - IPL_INVALID = -1, +enum item_effect_type { + IPL_TOHIT = 0x0, + IPL_TOHIT_CURSE = 0x1, + IPL_DAMP = 0x2, + IPL_DAMP_CURSE = 0x3, + IPL_TOHIT_DAMP = 0x4, + IPL_TOHIT_DAMP_CURSE = 0x5, + IPL_ACP = 0x6, + IPL_ACP_CURSE = 0x7, + IPL_FIRERES = 0x8, + IPL_LIGHTRES = 0x9, + IPL_MAGICRES = 0xA, + IPL_ALLRES = 0xB, + IPL_SPLLVLADD = 0xE, + IPL_CHARGES = 0xF, + IPL_FIREDAM = 0x10, + IPL_LIGHTDAM = 0x11, + IPL_STR = 0x13, + IPL_STR_CURSE = 0x14, + IPL_MAG = 0x15, + IPL_MAG_CURSE = 0x16, + IPL_DEX = 0x17, + IPL_DEX_CURSE = 0x18, + IPL_VIT = 0x19, + IPL_VIT_CURSE = 0x1A, + IPL_ATTRIBS = 0x1B, + IPL_ATTRIBS_CURSE = 0x1C, + IPL_GETHIT_CURSE = 0x1D, + IPL_GETHIT = 0x1E, + IPL_LIFE = 0x1F, + IPL_LIFE_CURSE = 0x20, + IPL_MANA = 0x21, + IPL_MANA_CURSE = 0x22, + IPL_DUR = 0x23, + IPL_DUR_CURSE = 0x24, + IPL_INDESTRUCTIBLE = 0x25, + IPL_LIGHT = 0x26, + IPL_LIGHT_CURSE = 0x27, + IPL_MULT_ARROWS = 0x29, /* only used in hellfire */ + IPL_FIRE_ARROWS = 0x2A, + IPL_LIGHT_ARROWS = 0x2B, + IPL_INVCURS = 0x2C, + IPL_THORNS = 0x2D, + IPL_NOMANA = 0x2E, + IPL_NOHEALPLR = 0x2F, + IPL_ABSHALFTRAP = 0x34, + IPL_KNOCKBACK = 0x35, + IPL_NOHEALMON = 0x36, + IPL_STEALMANA = 0x37, + IPL_STEALLIFE = 0x38, + IPL_TARGAC = 0x39, + IPL_FASTATTACK = 0x3A, + IPL_FASTRECOVER = 0x3B, + IPL_FASTBLOCK = 0x3C, + IPL_DAMMOD = 0x3D, + IPL_RNDARROWVEL = 0x3E, + IPL_SETDAM = 0x3F, + IPL_SETDUR = 0x40, + IPL_NOMINSTR = 0x41, + IPL_SPELL = 0x42, + IPL_FASTSWING = 0x43, + IPL_ONEHAND = 0x44, + IPL_3XDAMVDEM = 0x45, + IPL_ALLRESZERO = 0x46, + IPL_DRAINLIFE = 0x48, + IPL_RNDSTEALLIFE = 0x49, + IPL_INFRAVISION = 0x4A, + IPL_SETAC = 0x4B, + IPL_ADDACLIFE = 0x4C, + IPL_ADDMANAAC = 0x4D, + IPL_FIRERESCLVL = 0x4E, + IPL_AC_CURSE = 0x4F, + IPL_INVALID = -1, }; -enum affix_item_type -{ - PLT_MISC = 0x1, - PLT_BOW = 0x10, - PLT_STAFF = 0x100, - PLT_WEAP = 0x1000, - PLT_SHLD = 0x10000, - PLT_ARMO = 0x100000, +enum affix_item_type { + PLT_MISC = 0x1, + PLT_BOW = 0x10, + PLT_STAFF = 0x100, + PLT_WEAP = 0x1000, + PLT_SHLD = 0x10000, + PLT_ARMO = 0x100000, }; /// Item graphic IDs; frame_num-11 of objcurs.cel. enum item_cursor_graphic { - ICURS_POTION_OF_FULL_MANA = 0, - ICURS_SCROLL_OF = 1, - ICURS_GOLD_SMALL = 4, - ICURS_GOLD_MEDIUM = 5, - ICURS_GOLD_LARGE = 6, - ICURS_RING_OF_TRUTH = 10, - ICURS_RING = 12, - ICURS_SPECTRAL_ELIXIR = 15, - ICURS_GOLDEN_ELIXIR = 17, - ICURS_EMPYREAN_BAND = 18, - ICURS_EAR_SORCEROR = 19, - ICURS_EAR_WARRIOR = 20, - ICURS_EAR_ROGUE = 21, - ICURS_BLOOD_STONE = 25, - ICURS_ELIXIR_OF_VITALITY = 31, - ICURS_POTION_OF_HEALING = 32, - ICURS_POTION_OF_FULL_REJUVENATION = 33, - ICURS_ELIXIR_OF_MAGIC = 34, - ICURS_POTION_OF_FULL_HEALING = 35, - ICURS_ELIXIR_OF_DEXTERITY = 36, - ICURS_POTION_OF_REJUVENATION = 37, - ICURS_ELIXIR_OF_STRENGTH = 38, - ICURS_POTION_OF_MANA = 39, - ICURS_BRAIN = 40, - ICURS_OPTIC_AMULET = 44, - ICURS_AMULET = 45, - ICURS_DAGGER = 51, - ICURS_BLADE = 56, - ICURS_BASTARD_SWORD = 57, - ICURS_MACE = 59, - ICURS_LONG_SWORD = 60, - ICURS_BROAD_SWORD = 61, - ICURS_FALCHION = 62, - ICURS_MORNING_STAR = 63, - ICURS_SHORT_SWORD = 64, - ICURS_CLAYMORE = 65, - ICURS_CLUB = 66, - ICURS_SABRE = 67, - ICURS_SPIKED_CLUB = 70, - ICURS_SCIMITAR = 72, - ICURS_FULL_HELM = 75, - ICURS_MAGIC_ROCK = 76, - ICURS_THE_UNDEAD_CROWN = 78, - ICURS_HELM = 82, - ICURS_BUCKLER = 83, - ICURS_VIEL_OF_STEEL = 85, - ICURS_BOOK_GREY = 86, - ICURS_BOOK_RED = 87, - ICURS_BOOK_BLUE = 88, - ICURS_BLACK_MUSHROOM = 89, - ICURS_SKULL_CAP = 90, - ICURS_CAP = 91, - ICURS_HARLEQUIN_CREST = 93, - ICURS_CROWN = 95, - ICURS_MAP_OF_THE_STARS = 96, - ICURS_FUNGAL_TOME = 97, - ICURS_GREAT_HELM = 98, - ICURS_BATTLE_AXE = 101, - ICURS_HUNTERS_BOW = 102, - ICURS_FIELD_PLATE = 103, - ICURS_SMALL_SHIELD = 105, - ICURS_CLEAVER = 106, - ICURS_STUDDED_LEATHER_ARMOR = 107, - ICURS_SHORT_STAFF = 109, - ICURS_TWO_HANDED_SWORD = 110, - ICURS_CHAIN_MAIL = 111, - ICURS_SMALL_AXE = 112, - ICURS_KITE_SHIELD = 113, - ICURS_SCALE_MAIL = 114, - ICURS_SHORT_BOW = 118, - ICURS_LONG_WAR_BOW = 119, - ICURS_WAR_HAMMER = 121, - ICURS_MAUL = 122, - ICURS_LONG_STAFF = 123, - ICURS_WAR_STAFF = 124, - ICURS_TAVERN_SIGN = 126, - ICURS_HARD_LEATHER_ARMOR = 127, - ICURS_RAGS = 128, - ICURS_QUILTED_ARMOR = 129, - ICURS_FLAIL = 131, - ICURS_TOWER_SHIELD = 132, - ICURS_COMPOSITE_BOW = 133, - ICURS_GREAT_SWORD = 134, - ICURS_LEATHER_ARMOR = 135, - ICURS_SPLINT_MAIL = 136, - ICURS_ROBE = 137, - ICURS_ANVIL_OF_FURY = 140, - ICURS_BROAD_AXE = 141, - ICURS_LARGE_AXE = 142, - ICURS_GREAT_AXE = 143, - ICURS_AXE = 144, - ICURS_LARGE_SHIELD = 147, - ICURS_GOTHIC_SHIELD = 148, - ICURS_CLOAK = 149, - ICURS_CAPE = 150, - ICURS_FULL_PLATE_MAIL = 151, - ICURS_GOTHIC_PLATE = 152, - ICURS_BREAST_PLATE = 153, - ICURS_RING_MAIL = 154, - ICURS_STAFF_OF_LAZARUS = 155, - ICURS_ARKAINES_VALOR = 157, - ICURS_SHORT_WAR_BOW = 165, - ICURS_COMPOSITE_STAFF = 166, - ICURS_SHORT_BATTLE_BOW = 167, - ICURS_GOLD = 168, + ICURS_POTION_OF_FULL_MANA = 0, + ICURS_SCROLL_OF = 1, + ICURS_GOLD_SMALL = 4, + ICURS_GOLD_MEDIUM = 5, + ICURS_GOLD_LARGE = 6, + ICURS_RING_OF_TRUTH = 10, + ICURS_RING = 12, + ICURS_SPECTRAL_ELIXIR = 15, + ICURS_GOLDEN_ELIXIR = 17, + ICURS_EMPYREAN_BAND = 18, + ICURS_EAR_SORCEROR = 19, + ICURS_EAR_WARRIOR = 20, + ICURS_EAR_ROGUE = 21, + ICURS_BLOOD_STONE = 25, + ICURS_ELIXIR_OF_VITALITY = 31, + ICURS_POTION_OF_HEALING = 32, + ICURS_POTION_OF_FULL_REJUVENATION = 33, + ICURS_ELIXIR_OF_MAGIC = 34, + ICURS_POTION_OF_FULL_HEALING = 35, + ICURS_ELIXIR_OF_DEXTERITY = 36, + ICURS_POTION_OF_REJUVENATION = 37, + ICURS_ELIXIR_OF_STRENGTH = 38, + ICURS_POTION_OF_MANA = 39, + ICURS_BRAIN = 40, + ICURS_OPTIC_AMULET = 44, + ICURS_AMULET = 45, + ICURS_DAGGER = 51, + ICURS_BLADE = 56, + ICURS_BASTARD_SWORD = 57, + ICURS_MACE = 59, + ICURS_LONG_SWORD = 60, + ICURS_BROAD_SWORD = 61, + ICURS_FALCHION = 62, + ICURS_MORNING_STAR = 63, + ICURS_SHORT_SWORD = 64, + ICURS_CLAYMORE = 65, + ICURS_CLUB = 66, + ICURS_SABRE = 67, + ICURS_SPIKED_CLUB = 70, + ICURS_SCIMITAR = 72, + ICURS_FULL_HELM = 75, + ICURS_MAGIC_ROCK = 76, + ICURS_THE_UNDEAD_CROWN = 78, + ICURS_HELM = 82, + ICURS_BUCKLER = 83, + ICURS_VIEL_OF_STEEL = 85, + ICURS_BOOK_GREY = 86, + ICURS_BOOK_RED = 87, + ICURS_BOOK_BLUE = 88, + ICURS_BLACK_MUSHROOM = 89, + ICURS_SKULL_CAP = 90, + ICURS_CAP = 91, + ICURS_HARLEQUIN_CREST = 93, + ICURS_CROWN = 95, + ICURS_MAP_OF_THE_STARS = 96, + ICURS_FUNGAL_TOME = 97, + ICURS_GREAT_HELM = 98, + ICURS_BATTLE_AXE = 101, + ICURS_HUNTERS_BOW = 102, + ICURS_FIELD_PLATE = 103, + ICURS_SMALL_SHIELD = 105, + ICURS_CLEAVER = 106, + ICURS_STUDDED_LEATHER_ARMOR = 107, + ICURS_SHORT_STAFF = 109, + ICURS_TWO_HANDED_SWORD = 110, + ICURS_CHAIN_MAIL = 111, + ICURS_SMALL_AXE = 112, + ICURS_KITE_SHIELD = 113, + ICURS_SCALE_MAIL = 114, + ICURS_SHORT_BOW = 118, + ICURS_LONG_WAR_BOW = 119, + ICURS_WAR_HAMMER = 121, + ICURS_MAUL = 122, + ICURS_LONG_STAFF = 123, + ICURS_WAR_STAFF = 124, + ICURS_TAVERN_SIGN = 126, + ICURS_HARD_LEATHER_ARMOR = 127, + ICURS_RAGS = 128, + ICURS_QUILTED_ARMOR = 129, + ICURS_FLAIL = 131, + ICURS_TOWER_SHIELD = 132, + ICURS_COMPOSITE_BOW = 133, + ICURS_GREAT_SWORD = 134, + ICURS_LEATHER_ARMOR = 135, + ICURS_SPLINT_MAIL = 136, + ICURS_ROBE = 137, + ICURS_ANVIL_OF_FURY = 140, + ICURS_BROAD_AXE = 141, + ICURS_LARGE_AXE = 142, + ICURS_GREAT_AXE = 143, + ICURS_AXE = 144, + ICURS_LARGE_SHIELD = 147, + ICURS_GOTHIC_SHIELD = 148, + ICURS_CLOAK = 149, + ICURS_CAPE = 150, + ICURS_FULL_PLATE_MAIL = 151, + ICURS_GOTHIC_PLATE = 152, + ICURS_BREAST_PLATE = 153, + ICURS_RING_MAIL = 154, + ICURS_STAFF_OF_LAZARUS = 155, + ICURS_ARKAINES_VALOR = 157, + ICURS_SHORT_WAR_BOW = 165, + ICURS_COMPOSITE_STAFF = 166, + ICURS_SHORT_BATTLE_BOW = 167, + ICURS_GOLD = 168, }; -enum _sfx_id -{ - PS_WALK1 = 0x0, - PS_WALK2 = 0x1, - PS_WALK3 = 0x2, - PS_WALK4 = 0x3, - PS_BFIRE = 0x4, - PS_FMAG = 0x5, - PS_TMAG = 0x6, - PS_LGHIT = 0x7, - PS_LGHIT1 = 0x8, - PS_SWING = 0x9, - PS_SWING2 = 0xA, - PS_DEAD = 0xB, - IS_QUESTDN = 0xC, - IS_ARMRFKD = 0xD, - IS_BARLFIRE = 0xE, - IS_BARREL = 0xF, - IS_BHIT = 0x10, - IS_BHIT1 = 0x11, - IS_CHEST = 0x12, - IS_DOORCLOS = 0x13, - IS_DOOROPEN = 0x14, - IS_FANVL = 0x15, - IS_FAXE = 0x16, - IS_FBLST = 0x17, - IS_FBODY = 0x18, - IS_FBOOK = 0x19, - IS_FBOW = 0x1A, - IS_FCAP = 0x1B, - IS_FHARM = 0x1C, - IS_FLARM = 0x1D, - IS_FMAG = 0x1E, - IS_FMAG1 = 0x1F, - IS_FMUSH = 0x20, - IS_FPOT = 0x21, - IS_FRING = 0x22, - IS_FROCK = 0x23, - IS_FSCRL = 0x24, - IS_FSHLD = 0x25, - IS_FSIGN = 0x26, - IS_FSTAF = 0x27, - IS_FSWOR = 0x28, - IS_GOLD = 0x29, - IS_HLMTFKD = 0x2A, - IS_IANVL = 0x2B, - IS_IAXE = 0x2C, - IS_IBLST = 0x2D, - IS_IBODY = 0x2E, - IS_IBOOK = 0x2F, - IS_IBOW = 0x30, - IS_ICAP = 0x31, - IS_IGRAB = 0x32, - IS_IHARM = 0x33, - IS_ILARM = 0x34, - IS_IMUSH = 0x35, - IS_IPOT = 0x36, - IS_IRING = 0x37, - IS_IROCK = 0x38, - IS_ISCROL = 0x39, - IS_ISHIEL = 0x3A, - IS_ISIGN = 0x3B, - IS_ISTAF = 0x3C, - IS_ISWORD = 0x3D, - IS_LEVER = 0x3E, - IS_MAGIC = 0x3F, - IS_MAGIC1 = 0x40, - IS_RBOOK = 0x41, - IS_SARC = 0x42, - IS_SHLDFKD = 0x43, - IS_SWRDFKD = 0x44, - IS_TITLEMOV = 0x45, - IS_TITLSLCT = 0x46, - SFX_SILENCE = 0x47, - IS_TRAP = 0x48, - IS_CAST1 = 0x49, - IS_CAST10 = 0x4A, - IS_CAST12 = 0x4B, - IS_CAST2 = 0x4C, - IS_CAST3 = 0x4D, - IS_CAST4 = 0x4E, - IS_CAST5 = 0x4F, - IS_CAST6 = 0x50, - IS_CAST7 = 0x51, - IS_CAST8 = 0x52, - IS_CAST9 = 0x53, - LS_HEALING = 0x54, - IS_REPAIR = 0x55, - LS_ACID = 0x56, - LS_ACIDS = 0x57, - LS_APOC = 0x58, - LS_ARROWALL = 0x59, - LS_BLODBOIL = 0x5A, - LS_BLODSTAR = 0x5B, - LS_BLSIMPT = 0x5C, - LS_BONESP = 0x5D, - LS_BSIMPCT = 0x5E, - LS_CALDRON = 0x5F, - LS_CBOLT = 0x60, - LS_CHLTNING = 0x61, - LS_DSERP = 0x62, - LS_ELECIMP1 = 0x63, - LS_ELEMENTL = 0x64, - LS_ETHEREAL = 0x65, - LS_FBALL = 0x66, - LS_FBOLT1 = 0x67, - LS_FBOLT2 = 0x68, - LS_FIRIMP1 = 0x69, - LS_FIRIMP2 = 0x6A, - LS_FLAMWAVE = 0x6B, - LS_FLASH = 0x6C, - LS_FOUNTAIN = 0x6D, - LS_GOLUM = 0x6E, - LS_GOLUMDED = 0x6F, - LS_GSHRINE = 0x70, - LS_GUARD = 0x71, - LS_GUARDLAN = 0x72, - LS_HOLYBOLT = 0x73, - LS_HYPER = 0x74, - LS_INFRAVIS = 0x75, - LS_INVISIBL = 0x76, - LS_INVPOT = 0x77, - LS_LNING1 = 0x78, - LS_LTNING = 0x79, - LS_MSHIELD = 0x7A, - LS_NOVA = 0x7B, - LS_PORTAL = 0x7C, - LS_PUDDLE = 0x7D, - LS_RESUR = 0x7E, - LS_SCURSE = 0x7F, - LS_SCURIMP = 0x80, - LS_SENTINEL = 0x81, - LS_SHATTER = 0x82, - LS_SOULFIRE = 0x83, - LS_SPOUTLOP = 0x84, - LS_SPOUTSTR = 0x85, - LS_STORM = 0x86, - LS_TRAPDIS = 0x87, - LS_TELEPORT = 0x88, - LS_VTHEFT = 0x89, - LS_WALLLOOP = 0x8A, - LS_WALLSTRT = 0x8B, - TSFX_BMAID1 = 0x8C, - TSFX_BMAID2 = 0x8D, - TSFX_BMAID3 = 0x8E, - TSFX_BMAID4 = 0x8F, - TSFX_BMAID5 = 0x90, - TSFX_BMAID6 = 0x91, - TSFX_BMAID7 = 0x92, - TSFX_BMAID8 = 0x93, - TSFX_BMAID9 = 0x94, - TSFX_BMAID10 = 0x95, - TSFX_BMAID11 = 0x96, - TSFX_BMAID12 = 0x97, - TSFX_BMAID13 = 0x98, - TSFX_BMAID14 = 0x99, - TSFX_BMAID15 = 0x9A, - TSFX_BMAID16 = 0x9B, - TSFX_BMAID17 = 0x9C, - TSFX_BMAID18 = 0x9D, - TSFX_BMAID19 = 0x9E, - TSFX_BMAID20 = 0x9F, - TSFX_BMAID21 = 0xA0, - TSFX_BMAID22 = 0xA1, - TSFX_BMAID23 = 0xA2, - TSFX_BMAID24 = 0xA3, - TSFX_BMAID25 = 0xA4, - TSFX_BMAID26 = 0xA5, - TSFX_BMAID27 = 0xA6, - TSFX_BMAID28 = 0xA7, - TSFX_BMAID29 = 0xA8, - TSFX_BMAID30 = 0xA9, - TSFX_BMAID31 = 0xAA, - TSFX_BMAID32 = 0xAB, - TSFX_BMAID33 = 0xAC, - TSFX_BMAID34 = 0xAD, - TSFX_BMAID35 = 0xAE, - TSFX_BMAID36 = 0xAF, - TSFX_BMAID37 = 0xB0, - TSFX_BMAID38 = 0xB1, - TSFX_BMAID39 = 0xB2, - TSFX_BMAID40 = 0xB3, - TSFX_SMITH1 = 0xB4, - TSFX_SMITH2 = 0xB5, - TSFX_SMITH3 = 0xB6, - TSFX_SMITH4 = 0xB7, - TSFX_SMITH5 = 0xB8, - TSFX_SMITH6 = 0xB9, - TSFX_SMITH7 = 0xBA, - TSFX_SMITH8 = 0xBB, - TSFX_SMITH9 = 0xBC, - TSFX_SMITH10 = 0xBD, - TSFX_SMITH11 = 0xBE, - TSFX_SMITH12 = 0xBF, - TSFX_SMITH13 = 0xC0, - TSFX_SMITH14 = 0xC1, - TSFX_SMITH15 = 0xC2, - TSFX_SMITH16 = 0xC3, - TSFX_SMITH17 = 0xC4, - TSFX_SMITH18 = 0xC5, - TSFX_SMITH19 = 0xC6, - TSFX_SMITH20 = 0xC7, - TSFX_SMITH21 = 0xC8, - TSFX_SMITH22 = 0xC9, - TSFX_SMITH23 = 0xCA, - TSFX_SMITH24 = 0xCB, - TSFX_SMITH25 = 0xCC, - TSFX_SMITH26 = 0xCD, - TSFX_SMITH27 = 0xCE, - TSFX_SMITH28 = 0xCF, - TSFX_SMITH29 = 0xD0, - TSFX_SMITH30 = 0xD1, - TSFX_SMITH31 = 0xD2, - TSFX_SMITH32 = 0xD3, - TSFX_SMITH33 = 0xD4, - TSFX_SMITH34 = 0xD5, - TSFX_SMITH35 = 0xD6, - TSFX_SMITH36 = 0xD7, - TSFX_SMITH37 = 0xD8, - TSFX_SMITH38 = 0xD9, - TSFX_SMITH39 = 0xDA, - TSFX_SMITH40 = 0xDB, - TSFX_SMITH41 = 0xDC, - TSFX_SMITH42 = 0xDD, - TSFX_SMITH43 = 0xDE, - TSFX_SMITH44 = 0xDF, - TSFX_SMITH45 = 0xE0, - TSFX_SMITH46 = 0xE1, - TSFX_SMITH47 = 0xE2, - TSFX_SMITH48 = 0xE3, - TSFX_SMITH49 = 0xE4, - TSFX_SMITH50 = 0xE5, - TSFX_SMITH51 = 0xE6, - TSFX_SMITH52 = 0xE7, - TSFX_SMITH53 = 0xE8, - TSFX_SMITH54 = 0xE9, - TSFX_SMITH55 = 0xEA, - TSFX_SMITH56 = 0xEB, - TSFX_COW1 = 0xEC, - TSFX_COW2 = 0xED, - TSFX_DEADGUY = 0xEE, - TSFX_DRUNK1 = 0xEF, - TSFX_DRUNK2 = 0xF0, - TSFX_DRUNK3 = 0xF1, - TSFX_DRUNK4 = 0xF2, - TSFX_DRUNK5 = 0xF3, - TSFX_DRUNK6 = 0xF4, - TSFX_DRUNK7 = 0xF5, - TSFX_DRUNK8 = 0xF6, - TSFX_DRUNK9 = 0xF7, - TSFX_DRUNK10 = 0xF8, - TSFX_DRUNK11 = 0xF9, - TSFX_DRUNK12 = 0xFA, - TSFX_DRUNK13 = 0xFB, - TSFX_DRUNK14 = 0xFC, - TSFX_DRUNK15 = 0xFD, - TSFX_DRUNK16 = 0xFE, - TSFX_DRUNK17 = 0xFF, - TSFX_DRUNK18 = 0x100, - TSFX_DRUNK19 = 0x101, - TSFX_DRUNK20 = 0x102, - TSFX_DRUNK21 = 0x103, - TSFX_DRUNK22 = 0x104, - TSFX_DRUNK23 = 0x105, - TSFX_DRUNK24 = 0x106, - TSFX_DRUNK25 = 0x107, - TSFX_DRUNK26 = 0x108, - TSFX_DRUNK27 = 0x109, - TSFX_DRUNK28 = 0x10A, - TSFX_DRUNK29 = 0x10B, - TSFX_DRUNK30 = 0x10C, - TSFX_DRUNK31 = 0x10D, - TSFX_DRUNK32 = 0x10E, - TSFX_DRUNK33 = 0x10F, - TSFX_DRUNK34 = 0x110, - TSFX_DRUNK35 = 0x111, - TSFX_HEALER1 = 0x112, - TSFX_HEALER2 = 0x113, - TSFX_HEALER3 = 0x114, - TSFX_HEALER4 = 0x115, - TSFX_HEALER5 = 0x116, - TSFX_HEALER6 = 0x117, - TSFX_HEALER7 = 0x118, - TSFX_HEALER8 = 0x119, - TSFX_HEALER9 = 0x11A, - TSFX_HEALER10 = 0x11B, - TSFX_HEALER11 = 0x11C, - TSFX_HEALER12 = 0x11D, - TSFX_HEALER13 = 0x11E, - TSFX_HEALER14 = 0x11F, - TSFX_HEALER15 = 0x120, - TSFX_HEALER16 = 0x121, - TSFX_HEALER17 = 0x122, - TSFX_HEALER18 = 0x123, - TSFX_HEALER19 = 0x124, - TSFX_HEALER20 = 0x125, - TSFX_HEALER21 = 0x126, - TSFX_HEALER22 = 0x127, - TSFX_HEALER23 = 0x128, - TSFX_HEALER24 = 0x129, - TSFX_HEALER25 = 0x12A, - TSFX_HEALER26 = 0x12B, - TSFX_HEALER27 = 0x12C, - TSFX_HEALER28 = 0x12D, - TSFX_HEALER29 = 0x12E, - TSFX_HEALER30 = 0x12F, - TSFX_HEALER31 = 0x130, - TSFX_HEALER32 = 0x131, - TSFX_HEALER33 = 0x132, - TSFX_HEALER34 = 0x133, - TSFX_HEALER35 = 0x134, - TSFX_HEALER36 = 0x135, - TSFX_HEALER37 = 0x136, - TSFX_HEALER38 = 0x137, - TSFX_HEALER39 = 0x138, - TSFX_HEALER40 = 0x139, - TSFX_HEALER41 = 0x13A, - TSFX_HEALER42 = 0x13B, - TSFX_HEALER43 = 0x13C, - TSFX_HEALER44 = 0x13D, - TSFX_HEALER45 = 0x13E, - TSFX_HEALER46 = 0x13F, - TSFX_HEALER47 = 0x140, - TSFX_PEGBOY1 = 0x141, - TSFX_PEGBOY2 = 0x142, - TSFX_PEGBOY3 = 0x143, - TSFX_PEGBOY4 = 0x144, - TSFX_PEGBOY5 = 0x145, - TSFX_PEGBOY6 = 0x146, - TSFX_PEGBOY7 = 0x147, - TSFX_PEGBOY8 = 0x148, - TSFX_PEGBOY9 = 0x149, - TSFX_PEGBOY10 = 0x14A, - TSFX_PEGBOY11 = 0x14B, - TSFX_PEGBOY12 = 0x14C, - TSFX_PEGBOY13 = 0x14D, - TSFX_PEGBOY14 = 0x14E, - TSFX_PEGBOY15 = 0x14F, - TSFX_PEGBOY16 = 0x150, - TSFX_PEGBOY17 = 0x151, - TSFX_PEGBOY18 = 0x152, - TSFX_PEGBOY19 = 0x153, - TSFX_PEGBOY20 = 0x154, - TSFX_PEGBOY21 = 0x155, - TSFX_PEGBOY22 = 0x156, - TSFX_PEGBOY23 = 0x157, - TSFX_PEGBOY24 = 0x158, - TSFX_PEGBOY25 = 0x159, - TSFX_PEGBOY26 = 0x15A, - TSFX_PEGBOY27 = 0x15B, - TSFX_PEGBOY28 = 0x15C, - TSFX_PEGBOY29 = 0x15D, - TSFX_PEGBOY30 = 0x15E, - TSFX_PEGBOY31 = 0x15F, - TSFX_PEGBOY32 = 0x160, - TSFX_PEGBOY33 = 0x161, - TSFX_PEGBOY34 = 0x162, - TSFX_PEGBOY35 = 0x163, - TSFX_PEGBOY36 = 0x164, - TSFX_PEGBOY37 = 0x165, - TSFX_PEGBOY38 = 0x166, - TSFX_PEGBOY39 = 0x167, - TSFX_PEGBOY40 = 0x168, - TSFX_PEGBOY41 = 0x169, - TSFX_PEGBOY42 = 0x16A, - TSFX_PEGBOY43 = 0x16B, - TSFX_PRIEST0 = 0x16C, - TSFX_PRIEST1 = 0x16D, - TSFX_PRIEST2 = 0x16E, - TSFX_PRIEST3 = 0x16F, - TSFX_PRIEST4 = 0x170, - TSFX_PRIEST5 = 0x171, - TSFX_PRIEST6 = 0x172, - TSFX_PRIEST7 = 0x173, - TSFX_STORY0 = 0x174, - TSFX_STORY1 = 0x175, - TSFX_STORY2 = 0x176, - TSFX_STORY3 = 0x177, - TSFX_STORY4 = 0x178, - TSFX_STORY5 = 0x179, - TSFX_STORY6 = 0x17A, - TSFX_STORY7 = 0x17B, - TSFX_STORY8 = 0x17C, - TSFX_STORY9 = 0x17D, - TSFX_STORY10 = 0x17E, - TSFX_STORY11 = 0x17F, - TSFX_STORY12 = 0x180, - TSFX_STORY13 = 0x181, - TSFX_STORY14 = 0x182, - TSFX_STORY15 = 0x183, - TSFX_STORY16 = 0x184, - TSFX_STORY17 = 0x185, - TSFX_STORY18 = 0x186, - TSFX_STORY19 = 0x187, - TSFX_STORY20 = 0x188, - TSFX_STORY21 = 0x189, - TSFX_STORY22 = 0x18A, - TSFX_STORY23 = 0x18B, - TSFX_STORY24 = 0x18C, - TSFX_STORY25 = 0x18D, - TSFX_STORY26 = 0x18E, - TSFX_STORY27 = 0x18F, - TSFX_STORY28 = 0x190, - TSFX_STORY29 = 0x191, - TSFX_STORY30 = 0x192, - TSFX_STORY31 = 0x193, - TSFX_STORY32 = 0x194, - TSFX_STORY33 = 0x195, - TSFX_STORY34 = 0x196, - TSFX_STORY35 = 0x197, - TSFX_STORY36 = 0x198, - TSFX_STORY37 = 0x199, - TSFX_STORY38 = 0x19A, - TSFX_TAVERN0 = 0x19B, - TSFX_TAVERN1 = 0x19C, - TSFX_TAVERN2 = 0x19D, - TSFX_TAVERN3 = 0x19E, - TSFX_TAVERN4 = 0x19F, - TSFX_TAVERN5 = 0x1A0, - TSFX_TAVERN6 = 0x1A1, - TSFX_TAVERN7 = 0x1A2, - TSFX_TAVERN8 = 0x1A3, - TSFX_TAVERN9 = 0x1A4, - TSFX_TAVERN10 = 0x1A5, - TSFX_TAVERN11 = 0x1A6, - TSFX_TAVERN12 = 0x1A7, - TSFX_TAVERN13 = 0x1A8, - TSFX_TAVERN14 = 0x1A9, - TSFX_TAVERN15 = 0x1AA, - TSFX_TAVERN16 = 0x1AB, - TSFX_TAVERN17 = 0x1AC, - TSFX_TAVERN18 = 0x1AD, - TSFX_TAVERN19 = 0x1AE, - TSFX_TAVERN20 = 0x1AF, - TSFX_TAVERN21 = 0x1B0, - TSFX_TAVERN22 = 0x1B1, - TSFX_TAVERN23 = 0x1B2, - TSFX_TAVERN24 = 0x1B3, - TSFX_TAVERN25 = 0x1B4, - TSFX_TAVERN26 = 0x1B5, - TSFX_TAVERN27 = 0x1B6, - TSFX_TAVERN28 = 0x1B7, - TSFX_TAVERN29 = 0x1B8, - TSFX_TAVERN30 = 0x1B9, - TSFX_TAVERN31 = 0x1BA, - TSFX_TAVERN32 = 0x1BB, - TSFX_TAVERN33 = 0x1BC, - TSFX_TAVERN34 = 0x1BD, - TSFX_TAVERN35 = 0x1BE, - TSFX_TAVERN36 = 0x1BF, - TSFX_TAVERN37 = 0x1C0, - TSFX_TAVERN38 = 0x1C1, - TSFX_TAVERN39 = 0x1C2, - TSFX_TAVERN40 = 0x1C3, - TSFX_TAVERN41 = 0x1C4, - TSFX_TAVERN42 = 0x1C5, - TSFX_TAVERN43 = 0x1C6, - TSFX_TAVERN44 = 0x1C7, - TSFX_TAVERN45 = 0x1C8, - TSFX_WITCH1 = 0x1C9, - TSFX_WITCH2 = 0x1CA, - TSFX_WITCH3 = 0x1CB, - TSFX_WITCH4 = 0x1CC, - TSFX_WITCH5 = 0x1CD, - TSFX_WITCH6 = 0x1CE, - TSFX_WITCH7 = 0x1CF, - TSFX_WITCH8 = 0x1D0, - TSFX_WITCH9 = 0x1D1, - TSFX_WITCH10 = 0x1D2, - TSFX_WITCH11 = 0x1D3, - TSFX_WITCH12 = 0x1D4, - TSFX_WITCH13 = 0x1D5, - TSFX_WITCH14 = 0x1D6, - TSFX_WITCH15 = 0x1D7, - TSFX_WITCH16 = 0x1D8, - TSFX_WITCH17 = 0x1D9, - TSFX_WITCH18 = 0x1DA, - TSFX_WITCH19 = 0x1DB, - TSFX_WITCH20 = 0x1DC, - TSFX_WITCH21 = 0x1DD, - TSFX_WITCH22 = 0x1DE, - TSFX_WITCH23 = 0x1DF, - TSFX_WITCH24 = 0x1E0, - TSFX_WITCH25 = 0x1E1, - TSFX_WITCH26 = 0x1E2, - TSFX_WITCH27 = 0x1E3, - TSFX_WITCH28 = 0x1E4, - TSFX_WITCH29 = 0x1E5, - TSFX_WITCH30 = 0x1E6, - TSFX_WITCH31 = 0x1E7, - TSFX_WITCH32 = 0x1E8, - TSFX_WITCH33 = 0x1E9, - TSFX_WITCH34 = 0x1EA, - TSFX_WITCH35 = 0x1EB, - TSFX_WITCH36 = 0x1EC, - TSFX_WITCH37 = 0x1ED, - TSFX_WITCH38 = 0x1EE, - TSFX_WITCH39 = 0x1EF, - TSFX_WITCH40 = 0x1F0, - TSFX_WITCH41 = 0x1F1, - TSFX_WITCH42 = 0x1F2, - TSFX_WITCH43 = 0x1F3, - TSFX_WITCH44 = 0x1F4, - TSFX_WITCH45 = 0x1F5, - TSFX_WITCH46 = 0x1F6, - TSFX_WITCH47 = 0x1F7, - TSFX_WITCH48 = 0x1F8, - TSFX_WITCH49 = 0x1F9, - TSFX_WITCH50 = 0x1FA, - TSFX_WOUND = 0x1FB, - PS_MAGE1 = 0x1FC, - PS_MAGE2 = 0x1FD, - PS_MAGE3 = 0x1FE, - PS_MAGE4 = 0x1FF, - PS_MAGE5 = 0x200, - PS_MAGE6 = 0x201, - PS_MAGE7 = 0x202, - PS_MAGE8 = 0x203, - PS_MAGE9 = 0x204, - PS_MAGE10 = 0x205, - PS_MAGE11 = 0x206, - PS_MAGE12 = 0x207, - PS_MAGE13 = 0x208, - PS_MAGE14 = 0x209, - PS_MAGE15 = 0x20A, - PS_MAGE16 = 0x20B, - PS_MAGE17 = 0x20C, - PS_MAGE18 = 0x20D, - PS_MAGE19 = 0x20E, - PS_MAGE20 = 0x20F, - PS_MAGE21 = 0x210, - PS_MAGE22 = 0x211, - PS_MAGE23 = 0x212, - PS_MAGE24 = 0x213, - PS_MAGE25 = 0x214, - PS_MAGE26 = 0x215, - PS_MAGE27 = 0x216, - PS_MAGE28 = 0x217, - PS_MAGE29 = 0x218, - PS_MAGE30 = 0x219, - PS_MAGE31 = 0x21A, - PS_MAGE32 = 0x21B, - PS_MAGE33 = 0x21C, - PS_MAGE34 = 0x21D, - PS_MAGE35 = 0x21E, - PS_MAGE36 = 0x21F, - PS_MAGE37 = 0x220, - PS_MAGE38 = 0x221, - PS_MAGE39 = 0x222, - PS_MAGE40 = 0x223, - PS_MAGE41 = 0x224, - PS_MAGE42 = 0x225, - PS_MAGE43 = 0x226, - PS_MAGE44 = 0x227, - PS_MAGE45 = 0x228, - PS_MAGE46 = 0x229, - PS_MAGE47 = 0x22A, - PS_MAGE48 = 0x22B, - PS_MAGE49 = 0x22C, - PS_MAGE50 = 0x22D, - PS_MAGE51 = 0x22E, - PS_MAGE52 = 0x22F, - PS_MAGE53 = 0x230, - PS_MAGE54 = 0x231, - PS_MAGE55 = 0x232, - PS_MAGE56 = 0x233, - PS_MAGE57 = 0x234, - PS_MAGE58 = 0x235, - PS_MAGE59 = 0x236, - PS_MAGE60 = 0x237, - PS_MAGE61 = 0x238, - PS_MAGE62 = 0x239, - PS_MAGE63 = 0x23A, - PS_MAGE64 = 0x23B, - PS_MAGE65 = 0x23C, - PS_MAGE66 = 0x23D, - PS_MAGE67 = 0x23E, - PS_MAGE68 = 0x23F, - PS_MAGE69 = 0x240, - PS_MAGE69B = 0x241, - PS_MAGE70 = 0x242, - PS_MAGE71 = 0x243, - PS_MAGE72 = 0x244, - PS_MAGE73 = 0x245, - PS_MAGE74 = 0x246, - PS_MAGE75 = 0x247, - PS_MAGE76 = 0x248, - PS_MAGE77 = 0x249, - PS_MAGE78 = 0x24A, - PS_MAGE79 = 0x24B, - PS_MAGE80 = 0x24C, - PS_MAGE81 = 0x24D, - PS_MAGE82 = 0x24E, - PS_MAGE83 = 0x24F, - PS_MAGE84 = 0x250, - PS_MAGE85 = 0x251, - PS_MAGE86 = 0x252, - PS_MAGE87 = 0x253, - PS_MAGE88 = 0x254, - PS_MAGE89 = 0x255, - PS_MAGE90 = 0x256, - PS_MAGE91 = 0x257, - PS_MAGE92 = 0x258, - PS_MAGE93 = 0x259, - PS_MAGE94 = 0x25A, - PS_MAGE95 = 0x25B, - PS_MAGE96 = 0x25C, - PS_MAGE97 = 0x25D, - PS_MAGE98 = 0x25E, - PS_MAGE99 = 0x25F, - PS_MAGE100 = 0x260, - PS_MAGE101 = 0x261, - PS_MAGE102 = 0x262, - PS_ROGUE1 = 0x263, - PS_ROGUE2 = 0x264, - PS_ROGUE3 = 0x265, - PS_ROGUE4 = 0x266, - PS_ROGUE5 = 0x267, - PS_ROGUE6 = 0x268, - PS_ROGUE7 = 0x269, - PS_ROGUE8 = 0x26A, - PS_ROGUE9 = 0x26B, - PS_ROGUE10 = 0x26C, - PS_ROGUE11 = 0x26D, - PS_ROGUE12 = 0x26E, - PS_ROGUE13 = 0x26F, - PS_ROGUE14 = 0x270, - PS_ROGUE15 = 0x271, - PS_ROGUE16 = 0x272, - PS_ROGUE17 = 0x273, - PS_ROGUE18 = 0x274, - PS_ROGUE19 = 0x275, - PS_ROGUE20 = 0x276, - PS_ROGUE21 = 0x277, - PS_ROGUE22 = 0x278, - PS_ROGUE23 = 0x279, - PS_ROGUE24 = 0x27A, - PS_ROGUE25 = 0x27B, - PS_ROGUE26 = 0x27C, - PS_ROGUE27 = 0x27D, - PS_ROGUE28 = 0x27E, - PS_ROGUE29 = 0x27F, - PS_ROGUE30 = 0x280, - PS_ROGUE31 = 0x281, - PS_ROGUE32 = 0x282, - PS_ROGUE33 = 0x283, - PS_ROGUE34 = 0x284, - PS_ROGUE35 = 0x285, - PS_ROGUE36 = 0x286, - PS_ROGUE37 = 0x287, - PS_ROGUE38 = 0x288, - PS_ROGUE39 = 0x289, - PS_ROGUE40 = 0x28A, - PS_ROGUE41 = 0x28B, - PS_ROGUE42 = 0x28C, - PS_ROGUE43 = 0x28D, - PS_ROGUE44 = 0x28E, - PS_ROGUE45 = 0x28F, - PS_ROGUE46 = 0x290, - PS_ROGUE47 = 0x291, - PS_ROGUE48 = 0x292, - PS_ROGUE49 = 0x293, - PS_ROGUE50 = 0x294, - PS_ROGUE51 = 0x295, - PS_ROGUE52 = 0x296, - PS_ROGUE53 = 0x297, - PS_ROGUE54 = 0x298, - PS_ROGUE55 = 0x299, - PS_ROGUE56 = 0x29A, - PS_ROGUE57 = 0x29B, - PS_ROGUE58 = 0x29C, - PS_ROGUE59 = 0x29D, - PS_ROGUE60 = 0x29E, - PS_ROGUE61 = 0x29F, - PS_ROGUE62 = 0x2A0, - PS_ROGUE63 = 0x2A1, - PS_ROGUE64 = 0x2A2, - PS_ROGUE65 = 0x2A3, - PS_ROGUE66 = 0x2A4, - PS_ROGUE67 = 0x2A5, - PS_ROGUE68 = 0x2A6, - PS_ROGUE69 = 0x2A7, - PS_ROGUE69B = 0x2A8, - PS_ROGUE70 = 0x2A9, - PS_ROGUE71 = 0x2AA, - PS_ROGUE72 = 0x2AB, - PS_ROGUE73 = 0x2AC, - PS_ROGUE74 = 0x2AD, - PS_ROGUE75 = 0x2AE, - PS_ROGUE76 = 0x2AF, - PS_ROGUE77 = 0x2B0, - PS_ROGUE78 = 0x2B1, - PS_ROGUE79 = 0x2B2, - PS_ROGUE80 = 0x2B3, - PS_ROGUE81 = 0x2B4, - PS_ROGUE82 = 0x2B5, - PS_ROGUE83 = 0x2B6, - PS_ROGUE84 = 0x2B7, - PS_ROGUE85 = 0x2B8, - PS_ROGUE86 = 0x2B9, - PS_ROGUE87 = 0x2BA, - PS_ROGUE88 = 0x2BB, - PS_ROGUE89 = 0x2BC, - PS_ROGUE90 = 0x2BD, - PS_ROGUE91 = 0x2BE, - PS_ROGUE92 = 0x2BF, - PS_ROGUE93 = 0x2C0, - PS_ROGUE94 = 0x2C1, - PS_ROGUE95 = 0x2C2, - PS_ROGUE96 = 0x2C3, - PS_ROGUE97 = 0x2C4, - PS_ROGUE98 = 0x2C5, - PS_ROGUE99 = 0x2C6, - PS_ROGUE100 = 0x2C7, - PS_ROGUE101 = 0x2C8, - PS_ROGUE102 = 0x2C9, - PS_WARR1 = 0x2CA, - PS_WARR2 = 0x2CB, - PS_WARR3 = 0x2CC, - PS_WARR4 = 0x2CD, - PS_WARR5 = 0x2CE, - PS_WARR6 = 0x2CF, - PS_WARR7 = 0x2D0, - PS_WARR8 = 0x2D1, - PS_WARR9 = 0x2D2, - PS_WARR10 = 0x2D3, - PS_WARR11 = 0x2D4, - PS_WARR12 = 0x2D5, - PS_WARR13 = 0x2D6, - PS_WARR14 = 0x2D7, - PS_WARR14B = 0x2D8, - PS_WARR14C = 0x2D9, - PS_WARR15 = 0x2DA, - PS_WARR15B = 0x2DB, - PS_WARR15C = 0x2DC, - PS_WARR16 = 0x2DD, - PS_WARR16B = 0x2DE, - PS_WARR16C = 0x2DF, - PS_WARR17 = 0x2E0, - PS_WARR18 = 0x2E1, - PS_WARR19 = 0x2E2, - PS_WARR20 = 0x2E3, - PS_WARR21 = 0x2E4, - PS_WARR22 = 0x2E5, - PS_WARR23 = 0x2E6, - PS_WARR24 = 0x2E7, - PS_WARR25 = 0x2E8, - PS_WARR26 = 0x2E9, - PS_WARR27 = 0x2EA, - PS_WARR28 = 0x2EB, - PS_WARR29 = 0x2EC, - PS_WARR30 = 0x2ED, - PS_WARR31 = 0x2EE, - PS_WARR32 = 0x2EF, - PS_WARR33 = 0x2F0, - PS_WARR34 = 0x2F1, - PS_WARR35 = 0x2F2, - PS_WARR36 = 0x2F3, - PS_WARR37 = 0x2F4, - PS_WARR38 = 0x2F5, - PS_WARR39 = 0x2F6, - PS_WARR40 = 0x2F7, - PS_WARR41 = 0x2F8, - PS_WARR42 = 0x2F9, - PS_WARR43 = 0x2FA, - PS_WARR44 = 0x2FB, - PS_WARR45 = 0x2FC, - PS_WARR46 = 0x2FD, - PS_WARR47 = 0x2FE, - PS_WARR48 = 0x2FF, - PS_WARR49 = 0x300, - PS_WARR50 = 0x301, - PS_WARR51 = 0x302, - PS_WARR52 = 0x303, - PS_WARR53 = 0x304, - PS_WARR54 = 0x305, - PS_WARR55 = 0x306, - PS_WARR56 = 0x307, - PS_WARR57 = 0x308, - PS_WARR58 = 0x309, - PS_WARR59 = 0x30A, - PS_WARR60 = 0x30B, - PS_WARR61 = 0x30C, - PS_WARR62 = 0x30D, - PS_WARR63 = 0x30E, - PS_WARR64 = 0x30F, - PS_WARR65 = 0x310, - PS_WARR66 = 0x311, - PS_WARR67 = 0x312, - PS_WARR68 = 0x313, - PS_WARR69 = 0x314, - PS_WARR69B = 0x315, - PS_WARR70 = 0x316, - PS_WARR71 = 0x317, - PS_WARR72 = 0x318, - PS_WARR73 = 0x319, - PS_WARR74 = 0x31A, - PS_WARR75 = 0x31B, - PS_WARR76 = 0x31C, - PS_WARR77 = 0x31D, - PS_WARR78 = 0x31E, - PS_WARR79 = 0x31F, - PS_WARR80 = 0x320, - PS_WARR81 = 0x321, - PS_WARR82 = 0x322, - PS_WARR83 = 0x323, - PS_WARR84 = 0x324, - PS_WARR85 = 0x325, - PS_WARR86 = 0x326, - PS_WARR87 = 0x327, - PS_WARR88 = 0x328, - PS_WARR89 = 0x329, - PS_WARR90 = 0x32A, - PS_WARR91 = 0x32B, - PS_WARR92 = 0x32C, - PS_WARR93 = 0x32D, - PS_WARR94 = 0x32E, - PS_WARR95 = 0x32F, - PS_WARR95B = 0x330, - PS_WARR95C = 0x331, - PS_WARR95D = 0x332, - PS_WARR95E = 0x333, - PS_WARR95F = 0x334, - PS_WARR96B = 0x335, - PS_WARR97 = 0x336, - PS_WARR98 = 0x337, - PS_WARR99 = 0x338, - PS_WARR100 = 0x339, - PS_WARR101 = 0x33A, - PS_WARR102 = 0x33B, - PS_NAR1 = 0x33C, - PS_NAR2 = 0x33D, - PS_NAR3 = 0x33E, - PS_NAR4 = 0x33F, - PS_NAR5 = 0x340, - PS_NAR6 = 0x341, - PS_NAR7 = 0x342, - PS_NAR8 = 0x343, - PS_NAR9 = 0x344, - PS_DIABLVLINT = 0x345, - USFX_CLEAVER = 0x346, - USFX_GARBUD1 = 0x347, - USFX_GARBUD2 = 0x348, - USFX_GARBUD3 = 0x349, - USFX_GARBUD4 = 0x34A, - USFX_IZUAL1 = 0x34B, - USFX_LACH1 = 0x34C, - USFX_LACH2 = 0x34D, - USFX_LACH3 = 0x34E, - USFX_LAZ1 = 0x34F, - USFX_LAZ2 = 0x350, - USFX_SKING1 = 0x351, - USFX_SNOT1 = 0x352, - USFX_SNOT2 = 0x353, - USFX_SNOT3 = 0x354, - USFX_WARLRD1 = 0x355, - USFX_WLOCK1 = 0x356, - USFX_ZHAR1 = 0x357, - USFX_ZHAR2 = 0x358, - USFX_DIABLOD = 0x359, +enum _sfx_id { + PS_WALK1 = 0x0, + PS_WALK2 = 0x1, + PS_WALK3 = 0x2, + PS_WALK4 = 0x3, + PS_BFIRE = 0x4, + PS_FMAG = 0x5, + PS_TMAG = 0x6, + PS_LGHIT = 0x7, + PS_LGHIT1 = 0x8, + PS_SWING = 0x9, + PS_SWING2 = 0xA, + PS_DEAD = 0xB, + IS_QUESTDN = 0xC, + IS_ARMRFKD = 0xD, + IS_BARLFIRE = 0xE, + IS_BARREL = 0xF, + IS_BHIT = 0x10, + IS_BHIT1 = 0x11, + IS_CHEST = 0x12, + IS_DOORCLOS = 0x13, + IS_DOOROPEN = 0x14, + IS_FANVL = 0x15, + IS_FAXE = 0x16, + IS_FBLST = 0x17, + IS_FBODY = 0x18, + IS_FBOOK = 0x19, + IS_FBOW = 0x1A, + IS_FCAP = 0x1B, + IS_FHARM = 0x1C, + IS_FLARM = 0x1D, + IS_FMAG = 0x1E, + IS_FMAG1 = 0x1F, + IS_FMUSH = 0x20, + IS_FPOT = 0x21, + IS_FRING = 0x22, + IS_FROCK = 0x23, + IS_FSCRL = 0x24, + IS_FSHLD = 0x25, + IS_FSIGN = 0x26, + IS_FSTAF = 0x27, + IS_FSWOR = 0x28, + IS_GOLD = 0x29, + IS_HLMTFKD = 0x2A, + IS_IANVL = 0x2B, + IS_IAXE = 0x2C, + IS_IBLST = 0x2D, + IS_IBODY = 0x2E, + IS_IBOOK = 0x2F, + IS_IBOW = 0x30, + IS_ICAP = 0x31, + IS_IGRAB = 0x32, + IS_IHARM = 0x33, + IS_ILARM = 0x34, + IS_IMUSH = 0x35, + IS_IPOT = 0x36, + IS_IRING = 0x37, + IS_IROCK = 0x38, + IS_ISCROL = 0x39, + IS_ISHIEL = 0x3A, + IS_ISIGN = 0x3B, + IS_ISTAF = 0x3C, + IS_ISWORD = 0x3D, + IS_LEVER = 0x3E, + IS_MAGIC = 0x3F, + IS_MAGIC1 = 0x40, + IS_RBOOK = 0x41, + IS_SARC = 0x42, + IS_SHLDFKD = 0x43, + IS_SWRDFKD = 0x44, + IS_TITLEMOV = 0x45, + IS_TITLSLCT = 0x46, + SFX_SILENCE = 0x47, + IS_TRAP = 0x48, + IS_CAST1 = 0x49, + IS_CAST10 = 0x4A, + IS_CAST12 = 0x4B, + IS_CAST2 = 0x4C, + IS_CAST3 = 0x4D, + IS_CAST4 = 0x4E, + IS_CAST5 = 0x4F, + IS_CAST6 = 0x50, + IS_CAST7 = 0x51, + IS_CAST8 = 0x52, + IS_CAST9 = 0x53, + LS_HEALING = 0x54, + IS_REPAIR = 0x55, + LS_ACID = 0x56, + LS_ACIDS = 0x57, + LS_APOC = 0x58, + LS_ARROWALL = 0x59, + LS_BLODBOIL = 0x5A, + LS_BLODSTAR = 0x5B, + LS_BLSIMPT = 0x5C, + LS_BONESP = 0x5D, + LS_BSIMPCT = 0x5E, + LS_CALDRON = 0x5F, + LS_CBOLT = 0x60, + LS_CHLTNING = 0x61, + LS_DSERP = 0x62, + LS_ELECIMP1 = 0x63, + LS_ELEMENTL = 0x64, + LS_ETHEREAL = 0x65, + LS_FBALL = 0x66, + LS_FBOLT1 = 0x67, + LS_FBOLT2 = 0x68, + LS_FIRIMP1 = 0x69, + LS_FIRIMP2 = 0x6A, + LS_FLAMWAVE = 0x6B, + LS_FLASH = 0x6C, + LS_FOUNTAIN = 0x6D, + LS_GOLUM = 0x6E, + LS_GOLUMDED = 0x6F, + LS_GSHRINE = 0x70, + LS_GUARD = 0x71, + LS_GUARDLAN = 0x72, + LS_HOLYBOLT = 0x73, + LS_HYPER = 0x74, + LS_INFRAVIS = 0x75, + LS_INVISIBL = 0x76, + LS_INVPOT = 0x77, + LS_LNING1 = 0x78, + LS_LTNING = 0x79, + LS_MSHIELD = 0x7A, + LS_NOVA = 0x7B, + LS_PORTAL = 0x7C, + LS_PUDDLE = 0x7D, + LS_RESUR = 0x7E, + LS_SCURSE = 0x7F, + LS_SCURIMP = 0x80, + LS_SENTINEL = 0x81, + LS_SHATTER = 0x82, + LS_SOULFIRE = 0x83, + LS_SPOUTLOP = 0x84, + LS_SPOUTSTR = 0x85, + LS_STORM = 0x86, + LS_TRAPDIS = 0x87, + LS_TELEPORT = 0x88, + LS_VTHEFT = 0x89, + LS_WALLLOOP = 0x8A, + LS_WALLSTRT = 0x8B, + TSFX_BMAID1 = 0x8C, + TSFX_BMAID2 = 0x8D, + TSFX_BMAID3 = 0x8E, + TSFX_BMAID4 = 0x8F, + TSFX_BMAID5 = 0x90, + TSFX_BMAID6 = 0x91, + TSFX_BMAID7 = 0x92, + TSFX_BMAID8 = 0x93, + TSFX_BMAID9 = 0x94, + TSFX_BMAID10 = 0x95, + TSFX_BMAID11 = 0x96, + TSFX_BMAID12 = 0x97, + TSFX_BMAID13 = 0x98, + TSFX_BMAID14 = 0x99, + TSFX_BMAID15 = 0x9A, + TSFX_BMAID16 = 0x9B, + TSFX_BMAID17 = 0x9C, + TSFX_BMAID18 = 0x9D, + TSFX_BMAID19 = 0x9E, + TSFX_BMAID20 = 0x9F, + TSFX_BMAID21 = 0xA0, + TSFX_BMAID22 = 0xA1, + TSFX_BMAID23 = 0xA2, + TSFX_BMAID24 = 0xA3, + TSFX_BMAID25 = 0xA4, + TSFX_BMAID26 = 0xA5, + TSFX_BMAID27 = 0xA6, + TSFX_BMAID28 = 0xA7, + TSFX_BMAID29 = 0xA8, + TSFX_BMAID30 = 0xA9, + TSFX_BMAID31 = 0xAA, + TSFX_BMAID32 = 0xAB, + TSFX_BMAID33 = 0xAC, + TSFX_BMAID34 = 0xAD, + TSFX_BMAID35 = 0xAE, + TSFX_BMAID36 = 0xAF, + TSFX_BMAID37 = 0xB0, + TSFX_BMAID38 = 0xB1, + TSFX_BMAID39 = 0xB2, + TSFX_BMAID40 = 0xB3, + TSFX_SMITH1 = 0xB4, + TSFX_SMITH2 = 0xB5, + TSFX_SMITH3 = 0xB6, + TSFX_SMITH4 = 0xB7, + TSFX_SMITH5 = 0xB8, + TSFX_SMITH6 = 0xB9, + TSFX_SMITH7 = 0xBA, + TSFX_SMITH8 = 0xBB, + TSFX_SMITH9 = 0xBC, + TSFX_SMITH10 = 0xBD, + TSFX_SMITH11 = 0xBE, + TSFX_SMITH12 = 0xBF, + TSFX_SMITH13 = 0xC0, + TSFX_SMITH14 = 0xC1, + TSFX_SMITH15 = 0xC2, + TSFX_SMITH16 = 0xC3, + TSFX_SMITH17 = 0xC4, + TSFX_SMITH18 = 0xC5, + TSFX_SMITH19 = 0xC6, + TSFX_SMITH20 = 0xC7, + TSFX_SMITH21 = 0xC8, + TSFX_SMITH22 = 0xC9, + TSFX_SMITH23 = 0xCA, + TSFX_SMITH24 = 0xCB, + TSFX_SMITH25 = 0xCC, + TSFX_SMITH26 = 0xCD, + TSFX_SMITH27 = 0xCE, + TSFX_SMITH28 = 0xCF, + TSFX_SMITH29 = 0xD0, + TSFX_SMITH30 = 0xD1, + TSFX_SMITH31 = 0xD2, + TSFX_SMITH32 = 0xD3, + TSFX_SMITH33 = 0xD4, + TSFX_SMITH34 = 0xD5, + TSFX_SMITH35 = 0xD6, + TSFX_SMITH36 = 0xD7, + TSFX_SMITH37 = 0xD8, + TSFX_SMITH38 = 0xD9, + TSFX_SMITH39 = 0xDA, + TSFX_SMITH40 = 0xDB, + TSFX_SMITH41 = 0xDC, + TSFX_SMITH42 = 0xDD, + TSFX_SMITH43 = 0xDE, + TSFX_SMITH44 = 0xDF, + TSFX_SMITH45 = 0xE0, + TSFX_SMITH46 = 0xE1, + TSFX_SMITH47 = 0xE2, + TSFX_SMITH48 = 0xE3, + TSFX_SMITH49 = 0xE4, + TSFX_SMITH50 = 0xE5, + TSFX_SMITH51 = 0xE6, + TSFX_SMITH52 = 0xE7, + TSFX_SMITH53 = 0xE8, + TSFX_SMITH54 = 0xE9, + TSFX_SMITH55 = 0xEA, + TSFX_SMITH56 = 0xEB, + TSFX_COW1 = 0xEC, + TSFX_COW2 = 0xED, + TSFX_DEADGUY = 0xEE, + TSFX_DRUNK1 = 0xEF, + TSFX_DRUNK2 = 0xF0, + TSFX_DRUNK3 = 0xF1, + TSFX_DRUNK4 = 0xF2, + TSFX_DRUNK5 = 0xF3, + TSFX_DRUNK6 = 0xF4, + TSFX_DRUNK7 = 0xF5, + TSFX_DRUNK8 = 0xF6, + TSFX_DRUNK9 = 0xF7, + TSFX_DRUNK10 = 0xF8, + TSFX_DRUNK11 = 0xF9, + TSFX_DRUNK12 = 0xFA, + TSFX_DRUNK13 = 0xFB, + TSFX_DRUNK14 = 0xFC, + TSFX_DRUNK15 = 0xFD, + TSFX_DRUNK16 = 0xFE, + TSFX_DRUNK17 = 0xFF, + TSFX_DRUNK18 = 0x100, + TSFX_DRUNK19 = 0x101, + TSFX_DRUNK20 = 0x102, + TSFX_DRUNK21 = 0x103, + TSFX_DRUNK22 = 0x104, + TSFX_DRUNK23 = 0x105, + TSFX_DRUNK24 = 0x106, + TSFX_DRUNK25 = 0x107, + TSFX_DRUNK26 = 0x108, + TSFX_DRUNK27 = 0x109, + TSFX_DRUNK28 = 0x10A, + TSFX_DRUNK29 = 0x10B, + TSFX_DRUNK30 = 0x10C, + TSFX_DRUNK31 = 0x10D, + TSFX_DRUNK32 = 0x10E, + TSFX_DRUNK33 = 0x10F, + TSFX_DRUNK34 = 0x110, + TSFX_DRUNK35 = 0x111, + TSFX_HEALER1 = 0x112, + TSFX_HEALER2 = 0x113, + TSFX_HEALER3 = 0x114, + TSFX_HEALER4 = 0x115, + TSFX_HEALER5 = 0x116, + TSFX_HEALER6 = 0x117, + TSFX_HEALER7 = 0x118, + TSFX_HEALER8 = 0x119, + TSFX_HEALER9 = 0x11A, + TSFX_HEALER10 = 0x11B, + TSFX_HEALER11 = 0x11C, + TSFX_HEALER12 = 0x11D, + TSFX_HEALER13 = 0x11E, + TSFX_HEALER14 = 0x11F, + TSFX_HEALER15 = 0x120, + TSFX_HEALER16 = 0x121, + TSFX_HEALER17 = 0x122, + TSFX_HEALER18 = 0x123, + TSFX_HEALER19 = 0x124, + TSFX_HEALER20 = 0x125, + TSFX_HEALER21 = 0x126, + TSFX_HEALER22 = 0x127, + TSFX_HEALER23 = 0x128, + TSFX_HEALER24 = 0x129, + TSFX_HEALER25 = 0x12A, + TSFX_HEALER26 = 0x12B, + TSFX_HEALER27 = 0x12C, + TSFX_HEALER28 = 0x12D, + TSFX_HEALER29 = 0x12E, + TSFX_HEALER30 = 0x12F, + TSFX_HEALER31 = 0x130, + TSFX_HEALER32 = 0x131, + TSFX_HEALER33 = 0x132, + TSFX_HEALER34 = 0x133, + TSFX_HEALER35 = 0x134, + TSFX_HEALER36 = 0x135, + TSFX_HEALER37 = 0x136, + TSFX_HEALER38 = 0x137, + TSFX_HEALER39 = 0x138, + TSFX_HEALER40 = 0x139, + TSFX_HEALER41 = 0x13A, + TSFX_HEALER42 = 0x13B, + TSFX_HEALER43 = 0x13C, + TSFX_HEALER44 = 0x13D, + TSFX_HEALER45 = 0x13E, + TSFX_HEALER46 = 0x13F, + TSFX_HEALER47 = 0x140, + TSFX_PEGBOY1 = 0x141, + TSFX_PEGBOY2 = 0x142, + TSFX_PEGBOY3 = 0x143, + TSFX_PEGBOY4 = 0x144, + TSFX_PEGBOY5 = 0x145, + TSFX_PEGBOY6 = 0x146, + TSFX_PEGBOY7 = 0x147, + TSFX_PEGBOY8 = 0x148, + TSFX_PEGBOY9 = 0x149, + TSFX_PEGBOY10 = 0x14A, + TSFX_PEGBOY11 = 0x14B, + TSFX_PEGBOY12 = 0x14C, + TSFX_PEGBOY13 = 0x14D, + TSFX_PEGBOY14 = 0x14E, + TSFX_PEGBOY15 = 0x14F, + TSFX_PEGBOY16 = 0x150, + TSFX_PEGBOY17 = 0x151, + TSFX_PEGBOY18 = 0x152, + TSFX_PEGBOY19 = 0x153, + TSFX_PEGBOY20 = 0x154, + TSFX_PEGBOY21 = 0x155, + TSFX_PEGBOY22 = 0x156, + TSFX_PEGBOY23 = 0x157, + TSFX_PEGBOY24 = 0x158, + TSFX_PEGBOY25 = 0x159, + TSFX_PEGBOY26 = 0x15A, + TSFX_PEGBOY27 = 0x15B, + TSFX_PEGBOY28 = 0x15C, + TSFX_PEGBOY29 = 0x15D, + TSFX_PEGBOY30 = 0x15E, + TSFX_PEGBOY31 = 0x15F, + TSFX_PEGBOY32 = 0x160, + TSFX_PEGBOY33 = 0x161, + TSFX_PEGBOY34 = 0x162, + TSFX_PEGBOY35 = 0x163, + TSFX_PEGBOY36 = 0x164, + TSFX_PEGBOY37 = 0x165, + TSFX_PEGBOY38 = 0x166, + TSFX_PEGBOY39 = 0x167, + TSFX_PEGBOY40 = 0x168, + TSFX_PEGBOY41 = 0x169, + TSFX_PEGBOY42 = 0x16A, + TSFX_PEGBOY43 = 0x16B, + TSFX_PRIEST0 = 0x16C, + TSFX_PRIEST1 = 0x16D, + TSFX_PRIEST2 = 0x16E, + TSFX_PRIEST3 = 0x16F, + TSFX_PRIEST4 = 0x170, + TSFX_PRIEST5 = 0x171, + TSFX_PRIEST6 = 0x172, + TSFX_PRIEST7 = 0x173, + TSFX_STORY0 = 0x174, + TSFX_STORY1 = 0x175, + TSFX_STORY2 = 0x176, + TSFX_STORY3 = 0x177, + TSFX_STORY4 = 0x178, + TSFX_STORY5 = 0x179, + TSFX_STORY6 = 0x17A, + TSFX_STORY7 = 0x17B, + TSFX_STORY8 = 0x17C, + TSFX_STORY9 = 0x17D, + TSFX_STORY10 = 0x17E, + TSFX_STORY11 = 0x17F, + TSFX_STORY12 = 0x180, + TSFX_STORY13 = 0x181, + TSFX_STORY14 = 0x182, + TSFX_STORY15 = 0x183, + TSFX_STORY16 = 0x184, + TSFX_STORY17 = 0x185, + TSFX_STORY18 = 0x186, + TSFX_STORY19 = 0x187, + TSFX_STORY20 = 0x188, + TSFX_STORY21 = 0x189, + TSFX_STORY22 = 0x18A, + TSFX_STORY23 = 0x18B, + TSFX_STORY24 = 0x18C, + TSFX_STORY25 = 0x18D, + TSFX_STORY26 = 0x18E, + TSFX_STORY27 = 0x18F, + TSFX_STORY28 = 0x190, + TSFX_STORY29 = 0x191, + TSFX_STORY30 = 0x192, + TSFX_STORY31 = 0x193, + TSFX_STORY32 = 0x194, + TSFX_STORY33 = 0x195, + TSFX_STORY34 = 0x196, + TSFX_STORY35 = 0x197, + TSFX_STORY36 = 0x198, + TSFX_STORY37 = 0x199, + TSFX_STORY38 = 0x19A, + TSFX_TAVERN0 = 0x19B, + TSFX_TAVERN1 = 0x19C, + TSFX_TAVERN2 = 0x19D, + TSFX_TAVERN3 = 0x19E, + TSFX_TAVERN4 = 0x19F, + TSFX_TAVERN5 = 0x1A0, + TSFX_TAVERN6 = 0x1A1, + TSFX_TAVERN7 = 0x1A2, + TSFX_TAVERN8 = 0x1A3, + TSFX_TAVERN9 = 0x1A4, + TSFX_TAVERN10 = 0x1A5, + TSFX_TAVERN11 = 0x1A6, + TSFX_TAVERN12 = 0x1A7, + TSFX_TAVERN13 = 0x1A8, + TSFX_TAVERN14 = 0x1A9, + TSFX_TAVERN15 = 0x1AA, + TSFX_TAVERN16 = 0x1AB, + TSFX_TAVERN17 = 0x1AC, + TSFX_TAVERN18 = 0x1AD, + TSFX_TAVERN19 = 0x1AE, + TSFX_TAVERN20 = 0x1AF, + TSFX_TAVERN21 = 0x1B0, + TSFX_TAVERN22 = 0x1B1, + TSFX_TAVERN23 = 0x1B2, + TSFX_TAVERN24 = 0x1B3, + TSFX_TAVERN25 = 0x1B4, + TSFX_TAVERN26 = 0x1B5, + TSFX_TAVERN27 = 0x1B6, + TSFX_TAVERN28 = 0x1B7, + TSFX_TAVERN29 = 0x1B8, + TSFX_TAVERN30 = 0x1B9, + TSFX_TAVERN31 = 0x1BA, + TSFX_TAVERN32 = 0x1BB, + TSFX_TAVERN33 = 0x1BC, + TSFX_TAVERN34 = 0x1BD, + TSFX_TAVERN35 = 0x1BE, + TSFX_TAVERN36 = 0x1BF, + TSFX_TAVERN37 = 0x1C0, + TSFX_TAVERN38 = 0x1C1, + TSFX_TAVERN39 = 0x1C2, + TSFX_TAVERN40 = 0x1C3, + TSFX_TAVERN41 = 0x1C4, + TSFX_TAVERN42 = 0x1C5, + TSFX_TAVERN43 = 0x1C6, + TSFX_TAVERN44 = 0x1C7, + TSFX_TAVERN45 = 0x1C8, + TSFX_WITCH1 = 0x1C9, + TSFX_WITCH2 = 0x1CA, + TSFX_WITCH3 = 0x1CB, + TSFX_WITCH4 = 0x1CC, + TSFX_WITCH5 = 0x1CD, + TSFX_WITCH6 = 0x1CE, + TSFX_WITCH7 = 0x1CF, + TSFX_WITCH8 = 0x1D0, + TSFX_WITCH9 = 0x1D1, + TSFX_WITCH10 = 0x1D2, + TSFX_WITCH11 = 0x1D3, + TSFX_WITCH12 = 0x1D4, + TSFX_WITCH13 = 0x1D5, + TSFX_WITCH14 = 0x1D6, + TSFX_WITCH15 = 0x1D7, + TSFX_WITCH16 = 0x1D8, + TSFX_WITCH17 = 0x1D9, + TSFX_WITCH18 = 0x1DA, + TSFX_WITCH19 = 0x1DB, + TSFX_WITCH20 = 0x1DC, + TSFX_WITCH21 = 0x1DD, + TSFX_WITCH22 = 0x1DE, + TSFX_WITCH23 = 0x1DF, + TSFX_WITCH24 = 0x1E0, + TSFX_WITCH25 = 0x1E1, + TSFX_WITCH26 = 0x1E2, + TSFX_WITCH27 = 0x1E3, + TSFX_WITCH28 = 0x1E4, + TSFX_WITCH29 = 0x1E5, + TSFX_WITCH30 = 0x1E6, + TSFX_WITCH31 = 0x1E7, + TSFX_WITCH32 = 0x1E8, + TSFX_WITCH33 = 0x1E9, + TSFX_WITCH34 = 0x1EA, + TSFX_WITCH35 = 0x1EB, + TSFX_WITCH36 = 0x1EC, + TSFX_WITCH37 = 0x1ED, + TSFX_WITCH38 = 0x1EE, + TSFX_WITCH39 = 0x1EF, + TSFX_WITCH40 = 0x1F0, + TSFX_WITCH41 = 0x1F1, + TSFX_WITCH42 = 0x1F2, + TSFX_WITCH43 = 0x1F3, + TSFX_WITCH44 = 0x1F4, + TSFX_WITCH45 = 0x1F5, + TSFX_WITCH46 = 0x1F6, + TSFX_WITCH47 = 0x1F7, + TSFX_WITCH48 = 0x1F8, + TSFX_WITCH49 = 0x1F9, + TSFX_WITCH50 = 0x1FA, + TSFX_WOUND = 0x1FB, + PS_MAGE1 = 0x1FC, + PS_MAGE2 = 0x1FD, + PS_MAGE3 = 0x1FE, + PS_MAGE4 = 0x1FF, + PS_MAGE5 = 0x200, + PS_MAGE6 = 0x201, + PS_MAGE7 = 0x202, + PS_MAGE8 = 0x203, + PS_MAGE9 = 0x204, + PS_MAGE10 = 0x205, + PS_MAGE11 = 0x206, + PS_MAGE12 = 0x207, + PS_MAGE13 = 0x208, + PS_MAGE14 = 0x209, + PS_MAGE15 = 0x20A, + PS_MAGE16 = 0x20B, + PS_MAGE17 = 0x20C, + PS_MAGE18 = 0x20D, + PS_MAGE19 = 0x20E, + PS_MAGE20 = 0x20F, + PS_MAGE21 = 0x210, + PS_MAGE22 = 0x211, + PS_MAGE23 = 0x212, + PS_MAGE24 = 0x213, + PS_MAGE25 = 0x214, + PS_MAGE26 = 0x215, + PS_MAGE27 = 0x216, + PS_MAGE28 = 0x217, + PS_MAGE29 = 0x218, + PS_MAGE30 = 0x219, + PS_MAGE31 = 0x21A, + PS_MAGE32 = 0x21B, + PS_MAGE33 = 0x21C, + PS_MAGE34 = 0x21D, + PS_MAGE35 = 0x21E, + PS_MAGE36 = 0x21F, + PS_MAGE37 = 0x220, + PS_MAGE38 = 0x221, + PS_MAGE39 = 0x222, + PS_MAGE40 = 0x223, + PS_MAGE41 = 0x224, + PS_MAGE42 = 0x225, + PS_MAGE43 = 0x226, + PS_MAGE44 = 0x227, + PS_MAGE45 = 0x228, + PS_MAGE46 = 0x229, + PS_MAGE47 = 0x22A, + PS_MAGE48 = 0x22B, + PS_MAGE49 = 0x22C, + PS_MAGE50 = 0x22D, + PS_MAGE51 = 0x22E, + PS_MAGE52 = 0x22F, + PS_MAGE53 = 0x230, + PS_MAGE54 = 0x231, + PS_MAGE55 = 0x232, + PS_MAGE56 = 0x233, + PS_MAGE57 = 0x234, + PS_MAGE58 = 0x235, + PS_MAGE59 = 0x236, + PS_MAGE60 = 0x237, + PS_MAGE61 = 0x238, + PS_MAGE62 = 0x239, + PS_MAGE63 = 0x23A, + PS_MAGE64 = 0x23B, + PS_MAGE65 = 0x23C, + PS_MAGE66 = 0x23D, + PS_MAGE67 = 0x23E, + PS_MAGE68 = 0x23F, + PS_MAGE69 = 0x240, + PS_MAGE69B = 0x241, + PS_MAGE70 = 0x242, + PS_MAGE71 = 0x243, + PS_MAGE72 = 0x244, + PS_MAGE73 = 0x245, + PS_MAGE74 = 0x246, + PS_MAGE75 = 0x247, + PS_MAGE76 = 0x248, + PS_MAGE77 = 0x249, + PS_MAGE78 = 0x24A, + PS_MAGE79 = 0x24B, + PS_MAGE80 = 0x24C, + PS_MAGE81 = 0x24D, + PS_MAGE82 = 0x24E, + PS_MAGE83 = 0x24F, + PS_MAGE84 = 0x250, + PS_MAGE85 = 0x251, + PS_MAGE86 = 0x252, + PS_MAGE87 = 0x253, + PS_MAGE88 = 0x254, + PS_MAGE89 = 0x255, + PS_MAGE90 = 0x256, + PS_MAGE91 = 0x257, + PS_MAGE92 = 0x258, + PS_MAGE93 = 0x259, + PS_MAGE94 = 0x25A, + PS_MAGE95 = 0x25B, + PS_MAGE96 = 0x25C, + PS_MAGE97 = 0x25D, + PS_MAGE98 = 0x25E, + PS_MAGE99 = 0x25F, + PS_MAGE100 = 0x260, + PS_MAGE101 = 0x261, + PS_MAGE102 = 0x262, + PS_ROGUE1 = 0x263, + PS_ROGUE2 = 0x264, + PS_ROGUE3 = 0x265, + PS_ROGUE4 = 0x266, + PS_ROGUE5 = 0x267, + PS_ROGUE6 = 0x268, + PS_ROGUE7 = 0x269, + PS_ROGUE8 = 0x26A, + PS_ROGUE9 = 0x26B, + PS_ROGUE10 = 0x26C, + PS_ROGUE11 = 0x26D, + PS_ROGUE12 = 0x26E, + PS_ROGUE13 = 0x26F, + PS_ROGUE14 = 0x270, + PS_ROGUE15 = 0x271, + PS_ROGUE16 = 0x272, + PS_ROGUE17 = 0x273, + PS_ROGUE18 = 0x274, + PS_ROGUE19 = 0x275, + PS_ROGUE20 = 0x276, + PS_ROGUE21 = 0x277, + PS_ROGUE22 = 0x278, + PS_ROGUE23 = 0x279, + PS_ROGUE24 = 0x27A, + PS_ROGUE25 = 0x27B, + PS_ROGUE26 = 0x27C, + PS_ROGUE27 = 0x27D, + PS_ROGUE28 = 0x27E, + PS_ROGUE29 = 0x27F, + PS_ROGUE30 = 0x280, + PS_ROGUE31 = 0x281, + PS_ROGUE32 = 0x282, + PS_ROGUE33 = 0x283, + PS_ROGUE34 = 0x284, + PS_ROGUE35 = 0x285, + PS_ROGUE36 = 0x286, + PS_ROGUE37 = 0x287, + PS_ROGUE38 = 0x288, + PS_ROGUE39 = 0x289, + PS_ROGUE40 = 0x28A, + PS_ROGUE41 = 0x28B, + PS_ROGUE42 = 0x28C, + PS_ROGUE43 = 0x28D, + PS_ROGUE44 = 0x28E, + PS_ROGUE45 = 0x28F, + PS_ROGUE46 = 0x290, + PS_ROGUE47 = 0x291, + PS_ROGUE48 = 0x292, + PS_ROGUE49 = 0x293, + PS_ROGUE50 = 0x294, + PS_ROGUE51 = 0x295, + PS_ROGUE52 = 0x296, + PS_ROGUE53 = 0x297, + PS_ROGUE54 = 0x298, + PS_ROGUE55 = 0x299, + PS_ROGUE56 = 0x29A, + PS_ROGUE57 = 0x29B, + PS_ROGUE58 = 0x29C, + PS_ROGUE59 = 0x29D, + PS_ROGUE60 = 0x29E, + PS_ROGUE61 = 0x29F, + PS_ROGUE62 = 0x2A0, + PS_ROGUE63 = 0x2A1, + PS_ROGUE64 = 0x2A2, + PS_ROGUE65 = 0x2A3, + PS_ROGUE66 = 0x2A4, + PS_ROGUE67 = 0x2A5, + PS_ROGUE68 = 0x2A6, + PS_ROGUE69 = 0x2A7, + PS_ROGUE69B = 0x2A8, + PS_ROGUE70 = 0x2A9, + PS_ROGUE71 = 0x2AA, + PS_ROGUE72 = 0x2AB, + PS_ROGUE73 = 0x2AC, + PS_ROGUE74 = 0x2AD, + PS_ROGUE75 = 0x2AE, + PS_ROGUE76 = 0x2AF, + PS_ROGUE77 = 0x2B0, + PS_ROGUE78 = 0x2B1, + PS_ROGUE79 = 0x2B2, + PS_ROGUE80 = 0x2B3, + PS_ROGUE81 = 0x2B4, + PS_ROGUE82 = 0x2B5, + PS_ROGUE83 = 0x2B6, + PS_ROGUE84 = 0x2B7, + PS_ROGUE85 = 0x2B8, + PS_ROGUE86 = 0x2B9, + PS_ROGUE87 = 0x2BA, + PS_ROGUE88 = 0x2BB, + PS_ROGUE89 = 0x2BC, + PS_ROGUE90 = 0x2BD, + PS_ROGUE91 = 0x2BE, + PS_ROGUE92 = 0x2BF, + PS_ROGUE93 = 0x2C0, + PS_ROGUE94 = 0x2C1, + PS_ROGUE95 = 0x2C2, + PS_ROGUE96 = 0x2C3, + PS_ROGUE97 = 0x2C4, + PS_ROGUE98 = 0x2C5, + PS_ROGUE99 = 0x2C6, + PS_ROGUE100 = 0x2C7, + PS_ROGUE101 = 0x2C8, + PS_ROGUE102 = 0x2C9, + PS_WARR1 = 0x2CA, + PS_WARR2 = 0x2CB, + PS_WARR3 = 0x2CC, + PS_WARR4 = 0x2CD, + PS_WARR5 = 0x2CE, + PS_WARR6 = 0x2CF, + PS_WARR7 = 0x2D0, + PS_WARR8 = 0x2D1, + PS_WARR9 = 0x2D2, + PS_WARR10 = 0x2D3, + PS_WARR11 = 0x2D4, + PS_WARR12 = 0x2D5, + PS_WARR13 = 0x2D6, + PS_WARR14 = 0x2D7, + PS_WARR14B = 0x2D8, + PS_WARR14C = 0x2D9, + PS_WARR15 = 0x2DA, + PS_WARR15B = 0x2DB, + PS_WARR15C = 0x2DC, + PS_WARR16 = 0x2DD, + PS_WARR16B = 0x2DE, + PS_WARR16C = 0x2DF, + PS_WARR17 = 0x2E0, + PS_WARR18 = 0x2E1, + PS_WARR19 = 0x2E2, + PS_WARR20 = 0x2E3, + PS_WARR21 = 0x2E4, + PS_WARR22 = 0x2E5, + PS_WARR23 = 0x2E6, + PS_WARR24 = 0x2E7, + PS_WARR25 = 0x2E8, + PS_WARR26 = 0x2E9, + PS_WARR27 = 0x2EA, + PS_WARR28 = 0x2EB, + PS_WARR29 = 0x2EC, + PS_WARR30 = 0x2ED, + PS_WARR31 = 0x2EE, + PS_WARR32 = 0x2EF, + PS_WARR33 = 0x2F0, + PS_WARR34 = 0x2F1, + PS_WARR35 = 0x2F2, + PS_WARR36 = 0x2F3, + PS_WARR37 = 0x2F4, + PS_WARR38 = 0x2F5, + PS_WARR39 = 0x2F6, + PS_WARR40 = 0x2F7, + PS_WARR41 = 0x2F8, + PS_WARR42 = 0x2F9, + PS_WARR43 = 0x2FA, + PS_WARR44 = 0x2FB, + PS_WARR45 = 0x2FC, + PS_WARR46 = 0x2FD, + PS_WARR47 = 0x2FE, + PS_WARR48 = 0x2FF, + PS_WARR49 = 0x300, + PS_WARR50 = 0x301, + PS_WARR51 = 0x302, + PS_WARR52 = 0x303, + PS_WARR53 = 0x304, + PS_WARR54 = 0x305, + PS_WARR55 = 0x306, + PS_WARR56 = 0x307, + PS_WARR57 = 0x308, + PS_WARR58 = 0x309, + PS_WARR59 = 0x30A, + PS_WARR60 = 0x30B, + PS_WARR61 = 0x30C, + PS_WARR62 = 0x30D, + PS_WARR63 = 0x30E, + PS_WARR64 = 0x30F, + PS_WARR65 = 0x310, + PS_WARR66 = 0x311, + PS_WARR67 = 0x312, + PS_WARR68 = 0x313, + PS_WARR69 = 0x314, + PS_WARR69B = 0x315, + PS_WARR70 = 0x316, + PS_WARR71 = 0x317, + PS_WARR72 = 0x318, + PS_WARR73 = 0x319, + PS_WARR74 = 0x31A, + PS_WARR75 = 0x31B, + PS_WARR76 = 0x31C, + PS_WARR77 = 0x31D, + PS_WARR78 = 0x31E, + PS_WARR79 = 0x31F, + PS_WARR80 = 0x320, + PS_WARR81 = 0x321, + PS_WARR82 = 0x322, + PS_WARR83 = 0x323, + PS_WARR84 = 0x324, + PS_WARR85 = 0x325, + PS_WARR86 = 0x326, + PS_WARR87 = 0x327, + PS_WARR88 = 0x328, + PS_WARR89 = 0x329, + PS_WARR90 = 0x32A, + PS_WARR91 = 0x32B, + PS_WARR92 = 0x32C, + PS_WARR93 = 0x32D, + PS_WARR94 = 0x32E, + PS_WARR95 = 0x32F, + PS_WARR95B = 0x330, + PS_WARR95C = 0x331, + PS_WARR95D = 0x332, + PS_WARR95E = 0x333, + PS_WARR95F = 0x334, + PS_WARR96B = 0x335, + PS_WARR97 = 0x336, + PS_WARR98 = 0x337, + PS_WARR99 = 0x338, + PS_WARR100 = 0x339, + PS_WARR101 = 0x33A, + PS_WARR102 = 0x33B, + PS_NAR1 = 0x33C, + PS_NAR2 = 0x33D, + PS_NAR3 = 0x33E, + PS_NAR4 = 0x33F, + PS_NAR5 = 0x340, + PS_NAR6 = 0x341, + PS_NAR7 = 0x342, + PS_NAR8 = 0x343, + PS_NAR9 = 0x344, + PS_DIABLVLINT = 0x345, + USFX_CLEAVER = 0x346, + USFX_GARBUD1 = 0x347, + USFX_GARBUD2 = 0x348, + USFX_GARBUD3 = 0x349, + USFX_GARBUD4 = 0x34A, + USFX_IZUAL1 = 0x34B, + USFX_LACH1 = 0x34C, + USFX_LACH2 = 0x34D, + USFX_LACH3 = 0x34E, + USFX_LAZ1 = 0x34F, + USFX_LAZ2 = 0x350, + USFX_SKING1 = 0x351, + USFX_SNOT1 = 0x352, + USFX_SNOT2 = 0x353, + USFX_SNOT3 = 0x354, + USFX_WARLRD1 = 0x355, + USFX_WLOCK1 = 0x356, + USFX_ZHAR1 = 0x357, + USFX_ZHAR2 = 0x358, + USFX_DIABLOD = 0x359, }; enum sfx_flag { - SFX_STREAM = 0x01, - SFX_MISC = 0x02, - SFX_UI = 0x04, - SFX_08 = 0x08, - SFX_ROGUE = 0x10, - SFX_WARRIOR = 0x20, - SFX_SORCEROR = 0x40, - SFX_LOADED = 0x80, + SFX_STREAM = 0x01, + SFX_MISC = 0x02, + SFX_UI = 0x04, + SFX_08 = 0x08, + SFX_ROGUE = 0x10, + SFX_WARRIOR = 0x20, + SFX_SORCEROR = 0x40, + SFX_LOADED = 0x80, }; -enum item_equip_type -{ - ILOC_NONE = 0x0, - ILOC_ONEHAND = 0x1, - ILOC_TWOHAND = 0x2, - ILOC_ARMOR = 0x3, - ILOC_HELM = 0x4, - ILOC_RING = 0x5, - ILOC_AMULET = 0x6, - ILOC_UNEQUIPABLE = 0x7, - ILOC_BELT = 0x8, - ILOC_INVALID = -1, +enum item_equip_type { + ILOC_NONE = 0x0, + ILOC_ONEHAND = 0x1, + ILOC_TWOHAND = 0x2, + ILOC_ARMOR = 0x3, + ILOC_HELM = 0x4, + ILOC_RING = 0x5, + ILOC_AMULET = 0x6, + ILOC_UNEQUIPABLE = 0x7, + ILOC_BELT = 0x8, + ILOC_INVALID = -1, }; -enum missile_id -{ - MIS_ARROW = 0x0, - MIS_FIREBOLT = 0x1, - MIS_GUARDIAN = 0x2, - MIS_RNDTELEPORT = 0x3, - MIS_LIGHTBALL = 0x4, - MIS_FIREWALL = 0x5, - MIS_FIREBALL = 0x6, - MIS_LIGHTCTRL = 0x7, - MIS_LIGHTNING = 0x8, - MIS_MISEXP = 0x9, - MIS_TOWN = 0xA, - MIS_FLASH = 0xB, - MIS_FLASH2 = 0xC, - MIS_MANASHIELD = 0xD, - MIS_FIREMOVE = 0xE, - MIS_CHAIN = 0xF, - MIS_NULL_10 = 0x10, // sentinal? - MIS_NULL_11 = 0x11, - MIS_NULL_12 = 0x12, - MIS_NULL_13 = 0x13, - MIS_RHINO = 0x14, - MIS_MAGMABALL = 0x15, - MIS_LIGHTCTRL2 = 0x16, - MIS_LIGHTNING2 = 0x17, - MIS_FLARE = 0x18, - MIS_MISEXP2 = 0x19, - MIS_TELEPORT = 0x1A, - MIS_FARROW = 0x1B, - MIS_DOOMSERP = 0x1C, - MIS_NULL_1D = 0x1D, - MIS_STONE = 0x1E, - MIS_NULL_1F = 0x1F, - MIS_INVISIBL = 0x20, - MIS_GOLEM = 0x21, - MIS_ETHEREALIZE = 0x22, - MIS_NULL_23 = 0x23, - MIS_BOOM = 0x24, - MIS_HEAL = 0x25, - MIS_FIREWALLC = 0x26, - MIS_INFRA = 0x27, - MIS_IDENTIFY = 0x28, - MIS_WAVE = 0x29, - MIS_NOVA = 0x2A, - MIS_BLODBOIL = 0x2B, - MIS_APOCA = 0x2C, - MIS_REPAIR = 0x2D, - MIS_RECHARGE = 0x2E, - MIS_DISARM = 0x2F, - MIS_FLAME = 0x30, - MIS_FLAMEC = 0x31, - MIS_NULL_32 = 0x32, - MIS_NULL_33 = 0x33, - MIS_CBOLT = 0x34, - MIS_HBOLT = 0x35, - MIS_RESURRECT = 0x36, - MIS_TELEKINESIS = 0x37, - MIS_LARROW = 0x38, - MIS_ACID = 0x39, - MIS_MISEXP3 = 0x3A, - MIS_ACIDPUD = 0x3B, - MIS_HEALOTHER = 0x3C, - MIS_ELEMENT = 0x3D, - MIS_RESURRECTBEAM = 0x3E, - MIS_BONESPIRIT = 0x3F, - MIS_WEAPEXP = 0x40, - MIS_RPORTAL = 0x41, - MIS_BOOM2 = 0x42, - MIS_DIABAPOCA = 0x43, +enum missile_id { + MIS_ARROW = 0x0, + MIS_FIREBOLT = 0x1, + MIS_GUARDIAN = 0x2, + MIS_RNDTELEPORT = 0x3, + MIS_LIGHTBALL = 0x4, + MIS_FIREWALL = 0x5, + MIS_FIREBALL = 0x6, + MIS_LIGHTCTRL = 0x7, + MIS_LIGHTNING = 0x8, + MIS_MISEXP = 0x9, + MIS_TOWN = 0xA, + MIS_FLASH = 0xB, + MIS_FLASH2 = 0xC, + MIS_MANASHIELD = 0xD, + MIS_FIREMOVE = 0xE, + MIS_CHAIN = 0xF, + MIS_NULL_10 = 0x10, // sentinal? + MIS_NULL_11 = 0x11, + MIS_NULL_12 = 0x12, + MIS_NULL_13 = 0x13, + MIS_RHINO = 0x14, + MIS_MAGMABALL = 0x15, + MIS_LIGHTCTRL2 = 0x16, + MIS_LIGHTNING2 = 0x17, + MIS_FLARE = 0x18, + MIS_MISEXP2 = 0x19, + MIS_TELEPORT = 0x1A, + MIS_FARROW = 0x1B, + MIS_DOOMSERP = 0x1C, + MIS_NULL_1D = 0x1D, + MIS_STONE = 0x1E, + MIS_NULL_1F = 0x1F, + MIS_INVISIBL = 0x20, + MIS_GOLEM = 0x21, + MIS_ETHEREALIZE = 0x22, + MIS_NULL_23 = 0x23, + MIS_BOOM = 0x24, + MIS_HEAL = 0x25, + MIS_FIREWALLC = 0x26, + MIS_INFRA = 0x27, + MIS_IDENTIFY = 0x28, + MIS_WAVE = 0x29, + MIS_NOVA = 0x2A, + MIS_BLODBOIL = 0x2B, + MIS_APOCA = 0x2C, + MIS_REPAIR = 0x2D, + MIS_RECHARGE = 0x2E, + MIS_DISARM = 0x2F, + MIS_FLAME = 0x30, + MIS_FLAMEC = 0x31, + MIS_NULL_32 = 0x32, + MIS_NULL_33 = 0x33, + MIS_CBOLT = 0x34, + MIS_HBOLT = 0x35, + MIS_RESURRECT = 0x36, + MIS_TELEKINESIS = 0x37, + MIS_LARROW = 0x38, + MIS_ACID = 0x39, + MIS_MISEXP3 = 0x3A, + MIS_ACIDPUD = 0x3B, + MIS_HEALOTHER = 0x3C, + MIS_ELEMENT = 0x3D, + MIS_RESURRECTBEAM = 0x3E, + MIS_BONESPIRIT = 0x3F, + MIS_WEAPEXP = 0x40, + MIS_RPORTAL = 0x41, + MIS_BOOM2 = 0x42, + MIS_DIABAPOCA = 0x43, }; -enum missile_graphic_id -{ - MFILE_ARROWS = 0x0, - MFILE_FIREBA = 0x1, - MFILE_GUARD = 0x2, - MFILE_LGHNING = 0x3, - MFILE_FIREWAL = 0x4, - MFILE_MAGBLOS = 0x5, - MFILE_PORTAL = 0x6, - MFILE_BLUEXFR = 0x7, - MFILE_BLUEXBK = 0x8, - MFILE_MANASHLD = 0x9, - MFILE_BLOOD = 0xA, - MFILE_BONE = 0xB, - MFILE_METLHIT = 0xC, - MFILE_FARROW = 0xD, - MFILE_DOOM = 0xE, - MFILE_0F = 0xF, - MFILE_BLODBUR = 0x10, - MFILE_NEWEXP = 0x11, - MFILE_SHATTER1 = 0x12, - MFILE_BIGEXP = 0x13, - MFILE_INFERNO = 0x14, - MFILE_THINLGHT = 0x15, - MFILE_FLARE = 0x16, - MFILE_FLAREEXP = 0x17, - MFILE_MAGBALL = 0x18, - MFILE_KRULL = 0x19, - MFILE_MINILTNG = 0x1A, - MFILE_HOLY = 0x1B, - MFILE_HOLYEXPL = 0x1C, - MFILE_LARROW = 0x1D, - MFILE_FIRARWEX = 0x1E, - MFILE_ACIDBF = 0x1F, - MFILE_ACIDSPLA = 0x20, - MFILE_ACIDPUD = 0x21, - MFILE_ETHRSHLD = 0x22, - MFILE_FIRERUN = 0x23, - MFILE_RESSUR1 = 0x24, - MFILE_SKLBALL = 0x25, - MFILE_RPORTAL = 0x26, - MFILE_FIREPLAR = 0x27, - MFILE_SCUBMISB = 0x28, - MFILE_SCBSEXPB = 0x29, - MFILE_SCUBMISC = 0x2A, - MFILE_SCBSEXPC = 0x2B, - MFILE_SCUBMISD = 0x2C, - MFILE_SCBSEXPD = 0x2D, - MFILE_NULL = 0x2E, - MFILE_INVALID = 0x2F, - MFILE_NONE = 0xFF, +enum missile_graphic_id { + MFILE_ARROWS = 0x0, + MFILE_FIREBA = 0x1, + MFILE_GUARD = 0x2, + MFILE_LGHNING = 0x3, + MFILE_FIREWAL = 0x4, + MFILE_MAGBLOS = 0x5, + MFILE_PORTAL = 0x6, + MFILE_BLUEXFR = 0x7, + MFILE_BLUEXBK = 0x8, + MFILE_MANASHLD = 0x9, + MFILE_BLOOD = 0xA, + MFILE_BONE = 0xB, + MFILE_METLHIT = 0xC, + MFILE_FARROW = 0xD, + MFILE_DOOM = 0xE, + MFILE_0F = 0xF, + MFILE_BLODBUR = 0x10, + MFILE_NEWEXP = 0x11, + MFILE_SHATTER1 = 0x12, + MFILE_BIGEXP = 0x13, + MFILE_INFERNO = 0x14, + MFILE_THINLGHT = 0x15, + MFILE_FLARE = 0x16, + MFILE_FLAREEXP = 0x17, + MFILE_MAGBALL = 0x18, + MFILE_KRULL = 0x19, + MFILE_MINILTNG = 0x1A, + MFILE_HOLY = 0x1B, + MFILE_HOLYEXPL = 0x1C, + MFILE_LARROW = 0x1D, + MFILE_FIRARWEX = 0x1E, + MFILE_ACIDBF = 0x1F, + MFILE_ACIDSPLA = 0x20, + MFILE_ACIDPUD = 0x21, + MFILE_ETHRSHLD = 0x22, + MFILE_FIRERUN = 0x23, + MFILE_RESSUR1 = 0x24, + MFILE_SKLBALL = 0x25, + MFILE_RPORTAL = 0x26, + MFILE_FIREPLAR = 0x27, + MFILE_SCUBMISB = 0x28, + MFILE_SCBSEXPB = 0x29, + MFILE_SCUBMISC = 0x2A, + MFILE_SCBSEXPC = 0x2B, + MFILE_SCUBMISD = 0x2C, + MFILE_SCBSEXPD = 0x2D, + MFILE_NULL = 0x2E, + MFILE_INVALID = 0x2F, + MFILE_NONE = 0xFF, }; -enum _mai_id -{ - AI_ZOMBIE = 0, - AI_FAT = 1, - AI_SKELSD = 2, - AI_SKELBOW = 3, - AI_SCAV = 4, - AI_RHINO = 5, - AI_GOATMC = 6, - AI_GOATBOW = 7, - AI_FALLEN = 8, - AI_MAGMA = 9, - AI_SKELKING = 10, - AI_BAT = 11, - AI_GARG = 12, - AI_CLEAVER = 13, - AI_SUCC = 14, - AI_SNEAK = 15, - AI_STORM = 16, - AI_FIREMAN = 17, - AI_GARBUD = 18, - AI_ACID = 19, - AI_ACIDUNIQ = 20, - AI_GOLUM = 21, - AI_ZHAR = 22, - AI_SNOTSPIL = 23, - AI_SNAKE = 24, - AI_COUNSLR = 25, - AI_MEGA = 26, - AI_DIABLO = 27, - AI_LAZURUS = 28, - AI_LAZHELP = 29, - AI_LACHDAN = 30, - AI_WARLORD = 31, +enum _mai_id { + AI_ZOMBIE = 0, + AI_FAT = 1, + AI_SKELSD = 2, + AI_SKELBOW = 3, + AI_SCAV = 4, + AI_RHINO = 5, + AI_GOATMC = 6, + AI_GOATBOW = 7, + AI_FALLEN = 8, + AI_MAGMA = 9, + AI_SKELKING = 10, + AI_BAT = 11, + AI_GARG = 12, + AI_CLEAVER = 13, + AI_SUCC = 14, + AI_SNEAK = 15, + AI_STORM = 16, + AI_FIREMAN = 17, + AI_GARBUD = 18, + AI_ACID = 19, + AI_ACIDUNIQ = 20, + AI_GOLUM = 21, + AI_ZHAR = 22, + AI_SNOTSPIL = 23, + AI_SNAKE = 24, + AI_COUNSLR = 25, + AI_MEGA = 26, + AI_DIABLO = 27, + AI_LAZURUS = 28, + AI_LAZHELP = 29, + AI_LACHDAN = 30, + AI_WARLORD = 31, }; -enum _mc_id -{ - MC_UNDEAD = 0, - MC_DEMON = 1, - MC_ANIMAL = 2, +enum _mc_id { + MC_UNDEAD = 0, + MC_DEMON = 1, + MC_ANIMAL = 2, }; -enum _monster_id -{ - MT_NZOMBIE = 0x0, - MT_BZOMBIE = 0x1, - MT_GZOMBIE = 0x2, - MT_YZOMBIE = 0x3, - MT_RFALLSP = 0x4, - MT_DFALLSP = 0x5, - MT_YFALLSP = 0x6, - MT_BFALLSP = 0x7, - MT_WSKELAX = 0x8, - MT_TSKELAX = 0x9, - MT_RSKELAX = 0xA, - MT_XSKELAX = 0xB, - MT_RFALLSD = 0xC, - MT_DFALLSD = 0xD, - MT_YFALLSD = 0xE, - MT_BFALLSD = 0xF, - MT_NSCAV = 0x10, - MT_BSCAV = 0x11, - MT_WSCAV = 0x12, - MT_YSCAV = 0x13, - MT_WSKELBW = 0x14, - MT_TSKELBW = 0x15, - MT_RSKELBW = 0x16, - MT_XSKELBW = 0x17, - MT_WSKELSD = 0x18, - MT_TSKELSD = 0x19, - MT_RSKELSD = 0x1A, - MT_XSKELSD = 0x1B, - MT_INVILORD = 0x1C, - MT_SNEAK = 0x1D, - MT_STALKER = 0x1E, - MT_UNSEEN = 0x1F, - MT_ILLWEAV = 0x20, - MT_LRDSAYTR = 0x21, - MT_NGOATMC = 0x22, - MT_BGOATMC = 0x23, - MT_RGOATMC = 0x24, - MT_GGOATMC = 0x25, - MT_FIEND = 0x26, - MT_BLINK = 0x27, - MT_GLOOM = 0x28, - MT_FAMILIAR = 0x29, - MT_NGOATBW = 0x2A, - MT_BGOATBW = 0x2B, - MT_RGOATBW = 0x2C, - MT_GGOATBW = 0x2D, - MT_NACID = 0x2E, - MT_RACID = 0x2F, - MT_BACID = 0x30, - MT_XACID = 0x31, - MT_SKING = 0x32, - MT_CLEAVER = 0x33, - MT_FAT = 0x34, - MT_MUDMAN = 0x35, - MT_TOAD = 0x36, - MT_FLAYED = 0x37, - MT_WYRM = 0x38, - MT_CAVSLUG = 0x39, - MT_DVLWYRM = 0x3A, - MT_DEVOUR = 0x3B, - MT_NMAGMA = 0x3C, - MT_YMAGMA = 0x3D, - MT_BMAGMA = 0x3E, - MT_WMAGMA = 0x3F, - MT_HORNED = 0x40, - MT_MUDRUN = 0x41, - MT_FROSTC = 0x42, - MT_OBLORD = 0x43, - MT_BONEDMN = 0x44, - MT_REDDTH = 0x45, - MT_LTCHDMN = 0x46, - MT_UDEDBLRG = 0x47, - MT_INCIN = 0x48, - MT_FLAMLRD = 0x49, - MT_DOOMFIRE = 0x4A, - MT_HELLBURN = 0x4B, - MT_STORM = 0x4C, - MT_RSTORM = 0x4D, - MT_STORML = 0x4E, - MT_MAEL = 0x4F, - MT_BIGFALL = 0x50, - MT_WINGED = 0x51, - MT_GARGOYLE = 0x52, - MT_BLOODCLW = 0x53, - MT_DEATHW = 0x54, - MT_MEGA = 0x55, - MT_GUARD = 0x56, - MT_VTEXLRD = 0x57, - MT_BALROG = 0x58, - MT_NSNAKE = 0x59, - MT_RSNAKE = 0x5A, - MT_BSNAKE = 0x5B, - MT_GSNAKE = 0x5C, - MT_NBLACK = 0x5D, - MT_RTBLACK = 0x5E, - MT_BTBLACK = 0x5F, - MT_RBLACK = 0x60, - MT_UNRAV = 0x61, - MT_HOLOWONE = 0x62, - MT_PAINMSTR = 0x63, - MT_REALWEAV = 0x64, - MT_SUCCUBUS = 0x65, - MT_SNOWWICH = 0x66, - MT_HLSPWN = 0x67, - MT_SOLBRNR = 0x68, - MT_COUNSLR = 0x69, - MT_MAGISTR = 0x6A, - MT_CABALIST = 0x6B, - MT_ADVOCATE = 0x6C, - MT_GOLEM = 0x6D, - MT_DIABLO = 0x6E, - MT_DARKMAGE = 0x6F, - NUM_MTYPES +enum _monster_id { + MT_NZOMBIE = 0x0, + MT_BZOMBIE = 0x1, + MT_GZOMBIE = 0x2, + MT_YZOMBIE = 0x3, + MT_RFALLSP = 0x4, + MT_DFALLSP = 0x5, + MT_YFALLSP = 0x6, + MT_BFALLSP = 0x7, + MT_WSKELAX = 0x8, + MT_TSKELAX = 0x9, + MT_RSKELAX = 0xA, + MT_XSKELAX = 0xB, + MT_RFALLSD = 0xC, + MT_DFALLSD = 0xD, + MT_YFALLSD = 0xE, + MT_BFALLSD = 0xF, + MT_NSCAV = 0x10, + MT_BSCAV = 0x11, + MT_WSCAV = 0x12, + MT_YSCAV = 0x13, + MT_WSKELBW = 0x14, + MT_TSKELBW = 0x15, + MT_RSKELBW = 0x16, + MT_XSKELBW = 0x17, + MT_WSKELSD = 0x18, + MT_TSKELSD = 0x19, + MT_RSKELSD = 0x1A, + MT_XSKELSD = 0x1B, + MT_INVILORD = 0x1C, + MT_SNEAK = 0x1D, + MT_STALKER = 0x1E, + MT_UNSEEN = 0x1F, + MT_ILLWEAV = 0x20, + MT_LRDSAYTR = 0x21, + MT_NGOATMC = 0x22, + MT_BGOATMC = 0x23, + MT_RGOATMC = 0x24, + MT_GGOATMC = 0x25, + MT_FIEND = 0x26, + MT_BLINK = 0x27, + MT_GLOOM = 0x28, + MT_FAMILIAR = 0x29, + MT_NGOATBW = 0x2A, + MT_BGOATBW = 0x2B, + MT_RGOATBW = 0x2C, + MT_GGOATBW = 0x2D, + MT_NACID = 0x2E, + MT_RACID = 0x2F, + MT_BACID = 0x30, + MT_XACID = 0x31, + MT_SKING = 0x32, + MT_CLEAVER = 0x33, + MT_FAT = 0x34, + MT_MUDMAN = 0x35, + MT_TOAD = 0x36, + MT_FLAYED = 0x37, + MT_WYRM = 0x38, + MT_CAVSLUG = 0x39, + MT_DVLWYRM = 0x3A, + MT_DEVOUR = 0x3B, + MT_NMAGMA = 0x3C, + MT_YMAGMA = 0x3D, + MT_BMAGMA = 0x3E, + MT_WMAGMA = 0x3F, + MT_HORNED = 0x40, + MT_MUDRUN = 0x41, + MT_FROSTC = 0x42, + MT_OBLORD = 0x43, + MT_BONEDMN = 0x44, + MT_REDDTH = 0x45, + MT_LTCHDMN = 0x46, + MT_UDEDBLRG = 0x47, + MT_INCIN = 0x48, + MT_FLAMLRD = 0x49, + MT_DOOMFIRE = 0x4A, + MT_HELLBURN = 0x4B, + MT_STORM = 0x4C, + MT_RSTORM = 0x4D, + MT_STORML = 0x4E, + MT_MAEL = 0x4F, + MT_BIGFALL = 0x50, + MT_WINGED = 0x51, + MT_GARGOYLE = 0x52, + MT_BLOODCLW = 0x53, + MT_DEATHW = 0x54, + MT_MEGA = 0x55, + MT_GUARD = 0x56, + MT_VTEXLRD = 0x57, + MT_BALROG = 0x58, + MT_NSNAKE = 0x59, + MT_RSNAKE = 0x5A, + MT_BSNAKE = 0x5B, + MT_GSNAKE = 0x5C, + MT_NBLACK = 0x5D, + MT_RTBLACK = 0x5E, + MT_BTBLACK = 0x5F, + MT_RBLACK = 0x60, + MT_UNRAV = 0x61, + MT_HOLOWONE = 0x62, + MT_PAINMSTR = 0x63, + MT_REALWEAV = 0x64, + MT_SUCCUBUS = 0x65, + MT_SNOWWICH = 0x66, + MT_HLSPWN = 0x67, + MT_SOLBRNR = 0x68, + MT_COUNSLR = 0x69, + MT_MAGISTR = 0x6A, + MT_CABALIST = 0x6B, + MT_ADVOCATE = 0x6C, + MT_GOLEM = 0x6D, + MT_DIABLO = 0x6E, + MT_DARKMAGE = 0x6F, + NUM_MTYPES }; -enum _speech_id -{ - QUEST_KING1 = 0x0, - QUEST_KING2 = 0x1, - QUEST_KING3 = 0x2, - QUEST_KING4 = 0x3, - QUEST_KING5 = 0x4, - QUEST_KING6 = 0x5, - QUEST_KING7 = 0x6, - QUEST_KING8 = 0x7, - QUEST_KING9 = 0x8, - QUEST_KING10 = 0x9, - QUEST_KING11 = 0xA, - QUEST_BANNER1 = 0xB, - QUEST_BANNER2 = 0xC, - QUEST_BANNER3 = 0xD, - QUEST_BANNER4 = 0xE, - QUEST_BANNER5 = 0xF, - QUEST_BANNER6 = 0x10, - QUEST_BANNER7 = 0x11, - QUEST_BANNER8 = 0x12, - QUEST_BANNER9 = 0x13, - QUEST_BANNER10 = 0x14, - QUEST_BANNER11 = 0x15, - QUEST_BANNER12 = 0x16, - QUEST_VILE1 = 0x17, - QUEST_VILE2 = 0x18, - QUEST_VILE3 = 0x19, - QUEST_VILE4 = 0x1A, - QUEST_VILE5 = 0x1B, - QUEST_VILE6 = 0x1C, - QUEST_VILE7 = 0x1D, - QUEST_VILE8 = 0x1E, - QUEST_VILE9 = 0x1F, - QUEST_VILE10 = 0x20, - QUEST_VILE11 = 0x21, - QUEST_VILE12 = 0x22, - QUEST_VILE13 = 0x23, - QUEST_VILE14 = 0x24, - QUEST_POISON1 = 0x25, - QUEST_POISON2 = 0x26, - QUEST_POISON3 = 0x27, - QUEST_POISON4 = 0x28, - QUEST_POISON5 = 0x29, - QUEST_POISON6 = 0x2A, - QUEST_POISON7 = 0x2B, - QUEST_POISON8 = 0x2C, - QUEST_POISON9 = 0x2D, - QUEST_POISON10 = 0x2E, - QUEST_BONE1 = 0x2F, - QUEST_BONE2 = 0x30, - QUEST_BONE3 = 0x31, - QUEST_BONE4 = 0x32, - QUEST_BONE5 = 0x33, - QUEST_BONE6 = 0x34, - QUEST_BONE7 = 0x35, - QUEST_BONE8 = 0x36, - QUEST_BUTCH1 = 0x37, - QUEST_BUTCH2 = 0x38, - QUEST_BUTCH3 = 0x39, - QUEST_BUTCH4 = 0x3A, - QUEST_BUTCH5 = 0x3B, - QUEST_BUTCH6 = 0x3C, - QUEST_BUTCH7 = 0x3D, - QUEST_BUTCH8 = 0x3E, - QUEST_BUTCH9 = 0x3F, - QUEST_BUTCH10 = 0x40, - QUEST_BLIND1 = 0x41, - QUEST_BLIND2 = 0x42, - QUEST_BLIND3 = 0x43, - QUEST_BLIND4 = 0x44, - QUEST_BLIND5 = 0x45, - QUEST_BLIND6 = 0x46, - QUEST_BLIND7 = 0x47, - QUEST_BLIND8 = 0x48, - QUEST_VEIL1 = 0x49, - QUEST_VEIL2 = 0x4A, - QUEST_VEIL3 = 0x4B, - QUEST_VEIL4 = 0x4C, - QUEST_VEIL5 = 0x4D, - QUEST_VEIL6 = 0x4E, - QUEST_VEIL7 = 0x4F, - QUEST_VEIL8 = 0x50, - QUEST_VEIL9 = 0x51, - QUEST_VEIL10 = 0x52, - QUEST_VEIL11 = 0x53, - QUEST_ANVIL1 = 0x54, - QUEST_ANVIL2 = 0x55, - QUEST_ANVIL3 = 0x56, - QUEST_ANVIL4 = 0x57, - QUEST_ANVIL5 = 0x58, - QUEST_ANVIL6 = 0x59, - QUEST_ANVIL7 = 0x5A, - QUEST_ANVIL8 = 0x5B, - QUEST_ANVIL9 = 0x5C, - QUEST_ANVIL10 = 0x5D, - QUEST_BLOOD1 = 0x5E, - QUEST_BLOOD2 = 0x5F, - QUEST_BLOOD3 = 0x60, - QUEST_BLOOD4 = 0x61, - QUEST_BLOOD5 = 0x62, - QUEST_BLOOD6 = 0x63, - QUEST_BLOOD7 = 0x64, - QUEST_BLOOD8 = 0x65, - QUEST_WARLRD1 = 0x66, - QUEST_WARLRD2 = 0x67, - QUEST_WARLRD3 = 0x68, - QUEST_WARLRD4 = 0x69, - QUEST_WARLRD5 = 0x6A, - QUEST_WARLRD6 = 0x6B, - QUEST_WARLRD7 = 0x6C, - QUEST_WARLRD8 = 0x6D, - QUEST_WARLRD9 = 0x6E, - QUEST_INFRA1 = 0x6F, - QUEST_INFRA2 = 0x70, - QUEST_INFRA3 = 0x71, - QUEST_INFRA4 = 0x72, - QUEST_INFRA5 = 0x73, - QUEST_INFRA6 = 0x74, - QUEST_INFRA7 = 0x75, - QUEST_INFRA8 = 0x76, - QUEST_INFRA9 = 0x77, - QUEST_INFRA10 = 0x78, - QUEST_MUSH1 = 0x79, - QUEST_MUSH2 = 0x7A, - QUEST_MUSH3 = 0x7B, - QUEST_MUSH4 = 0x7C, - QUEST_MUSH5 = 0x7D, - QUEST_MUSH6 = 0x7E, - QUEST_MUSH7 = 0x7F, - QUEST_MUSH8 = 0x80, - QUEST_MUSH9 = 0x81, - QUEST_MUSH10 = 0x82, - QUEST_MUSH11 = 0x83, - QUEST_MUSH12 = 0x84, - QUEST_MUSH13 = 0x85, - QUEST_DOOM1 = 0x86, - QUEST_DOOM2 = 0x87, - QUEST_DOOM3 = 0x88, - QUEST_DOOM4 = 0x89, - QUEST_DOOM5 = 0x8A, - QUEST_DOOM6 = 0x8B, - QUEST_DOOM7 = 0x8C, - QUEST_DOOM8 = 0x8D, - QUEST_DOOM9 = 0x8E, - QUEST_DOOM10 = 0x8F, - QUEST_GARBUD1 = 0x90, - QUEST_GARBUD2 = 0x91, - QUEST_GARBUD3 = 0x92, - QUEST_GARBUD4 = 0x93, - QUEST_ZHAR1 = 0x94, - QUEST_ZHAR2 = 0x95, - QUEST_STORY1 = 0x96, - QUEST_STORY2 = 0x97, - QUEST_STORY3 = 0x98, - QUEST_STORY4 = 0x99, - QUEST_STORY5 = 0x9A, - QUEST_STORY6 = 0x9B, - QUEST_STORY7 = 0x9C, - QUEST_STORY9 = 0x9D, - QUEST_STORY10 = 0x9E, - QUEST_STORY11 = 0x9F, - QUEST_OGDEN1 = 0xA0, - QUEST_OGDEN2 = 0xA1, - QUEST_OGDEN3 = 0xA2, - QUEST_OGDEN4 = 0xA3, - QUEST_OGDEN5 = 0xA4, - QUEST_OGDEN6 = 0xA5, - QUEST_OGDEN8 = 0xA6, - QUEST_OGDEN9 = 0xA7, - QUEST_OGDEN10 = 0xA8, - QUEST_PEPIN1 = 0xA9, - QUEST_PEPIN2 = 0xAA, - QUEST_PEPIN3 = 0xAB, - QUEST_PEPIN4 = 0xAC, - QUEST_PEPIN5 = 0xAD, - QUEST_PEPIN6 = 0xAE, - QUEST_PEPIN7 = 0xAF, - QUEST_PEPIN9 = 0xB0, - QUEST_PEPIN10 = 0xB1, - QUEST_PEPIN11 = 0xB2, - QUEST_GILLIAN1 = 0xB3, - QUEST_GILLIAN2 = 0xB4, - QUEST_GILLIAN3 = 0xB5, - QUEST_GILLIAN4 = 0xB6, - QUEST_GILLIAN5 = 0xB7, - QUEST_GILLIAN6 = 0xB8, - QUEST_GILLIAN7 = 0xB9, - QUEST_GILLIAN9 = 0xBA, - QUEST_GILLIAN10 = 0xBB, - QUEST_GRISWOLD1 = 0xBC, - QUEST_GRISWOLD2 = 0xBD, - QUEST_GRISWOLD3 = 0xBE, - QUEST_GRISWOLD4 = 0xBF, - QUEST_GRISWOLD5 = 0xC0, - QUEST_GRISWOLD6 = 0xC1, - QUEST_GRISWOLD7 = 0xC2, - QUEST_GRISWOLD8 = 0xC3, - QUEST_GRISWOLD9 = 0xC4, - QUEST_GRISWOLD10 = 0xC5, - QUEST_GRISWOLD12 = 0xC6, - QUEST_GRISWOLD13 = 0xC7, - QUEST_FARNHAM1 = 0xC8, - QUEST_FARNHAM2 = 0xC9, - QUEST_FARNHAM3 = 0xCA, - QUEST_FARNHAM4 = 0xCB, - QUEST_FARNHAM5 = 0xCC, - QUEST_FARNHAM6 = 0xCD, - QUEST_FARNHAM8 = 0xCE, - QUEST_FARNHAM9 = 0xCF, - QUEST_FARNHAM10 = 0xD0, - QUEST_FARNHAM11 = 0xD1, - QUEST_FARNHAM12 = 0xD2, - QUEST_FARNHAM13 = 0xD3, - QUEST_ADRIA1 = 0xD4, - QUEST_ADRIA2 = 0xD5, - QUEST_ADRIA3 = 0xD6, - QUEST_ADRIA4 = 0xD7, - QUEST_ADRIA5 = 0xD8, - QUEST_ADRIA6 = 0xD9, - QUEST_ADRIA7 = 0xDA, - QUEST_ADRIA8 = 0xDB, - QUEST_ADRIA9 = 0xDC, - QUEST_ADRIA10 = 0xDD, - QUEST_ADRIA12 = 0xDE, - QUEST_ADRIA13 = 0xDF, - QUEST_WIRT1 = 0xE0, - QUEST_WIRT2 = 0xE1, - QUEST_WIRT3 = 0xE2, - QUEST_WIRT4 = 0xE3, - QUEST_WIRT5 = 0xE4, - QUEST_WIRT6 = 0xE5, - QUEST_WIRT7 = 0xE6, - QUEST_WIRT8 = 0xE7, - QUEST_WIRT9 = 0xE8, - QUEST_WIRT11 = 0xE9, - QUEST_WIRT12 = 0xEA, - QUEST_BONER = 0xEB, - QUEST_BLOODY = 0xEC, - QUEST_BLINDING = 0xED, - QUEST_BLOODWAR = 0xEE, - QUEST_MBONER = 0xEF, - QUEST_MBLOODY = 0xF0, - QUEST_MBLINDING = 0xF1, - QUEST_MBLOODWAR = 0xF2, - QUEST_RBONER = 0xF3, - QUEST_RBLOODY = 0xF4, - QUEST_RBLINDING = 0xF5, - QUEST_RBLOODWAR = 0xF6, - QUEST_COW1 = 0xF7, - QUEST_COW2 = 0xF8, - QUEST_BOOK11 = 0xF9, - QUEST_BOOK12 = 0xFA, - QUEST_BOOK13 = 0xFB, - QUEST_BOOK21 = 0xFC, - QUEST_BOOK22 = 0xFD, - QUEST_BOOK23 = 0xFE, - QUEST_BOOK31 = 0xFF, - QUEST_BOOK32 = 0x100, - QUEST_BOOK33 = 0x101, - QUEST_INTRO = 0x102 +enum _speech_id { + QUEST_KING1 = 0x0, + QUEST_KING2 = 0x1, + QUEST_KING3 = 0x2, + QUEST_KING4 = 0x3, + QUEST_KING5 = 0x4, + QUEST_KING6 = 0x5, + QUEST_KING7 = 0x6, + QUEST_KING8 = 0x7, + QUEST_KING9 = 0x8, + QUEST_KING10 = 0x9, + QUEST_KING11 = 0xA, + QUEST_BANNER1 = 0xB, + QUEST_BANNER2 = 0xC, + QUEST_BANNER3 = 0xD, + QUEST_BANNER4 = 0xE, + QUEST_BANNER5 = 0xF, + QUEST_BANNER6 = 0x10, + QUEST_BANNER7 = 0x11, + QUEST_BANNER8 = 0x12, + QUEST_BANNER9 = 0x13, + QUEST_BANNER10 = 0x14, + QUEST_BANNER11 = 0x15, + QUEST_BANNER12 = 0x16, + QUEST_VILE1 = 0x17, + QUEST_VILE2 = 0x18, + QUEST_VILE3 = 0x19, + QUEST_VILE4 = 0x1A, + QUEST_VILE5 = 0x1B, + QUEST_VILE6 = 0x1C, + QUEST_VILE7 = 0x1D, + QUEST_VILE8 = 0x1E, + QUEST_VILE9 = 0x1F, + QUEST_VILE10 = 0x20, + QUEST_VILE11 = 0x21, + QUEST_VILE12 = 0x22, + QUEST_VILE13 = 0x23, + QUEST_VILE14 = 0x24, + QUEST_POISON1 = 0x25, + QUEST_POISON2 = 0x26, + QUEST_POISON3 = 0x27, + QUEST_POISON4 = 0x28, + QUEST_POISON5 = 0x29, + QUEST_POISON6 = 0x2A, + QUEST_POISON7 = 0x2B, + QUEST_POISON8 = 0x2C, + QUEST_POISON9 = 0x2D, + QUEST_POISON10 = 0x2E, + QUEST_BONE1 = 0x2F, + QUEST_BONE2 = 0x30, + QUEST_BONE3 = 0x31, + QUEST_BONE4 = 0x32, + QUEST_BONE5 = 0x33, + QUEST_BONE6 = 0x34, + QUEST_BONE7 = 0x35, + QUEST_BONE8 = 0x36, + QUEST_BUTCH1 = 0x37, + QUEST_BUTCH2 = 0x38, + QUEST_BUTCH3 = 0x39, + QUEST_BUTCH4 = 0x3A, + QUEST_BUTCH5 = 0x3B, + QUEST_BUTCH6 = 0x3C, + QUEST_BUTCH7 = 0x3D, + QUEST_BUTCH8 = 0x3E, + QUEST_BUTCH9 = 0x3F, + QUEST_BUTCH10 = 0x40, + QUEST_BLIND1 = 0x41, + QUEST_BLIND2 = 0x42, + QUEST_BLIND3 = 0x43, + QUEST_BLIND4 = 0x44, + QUEST_BLIND5 = 0x45, + QUEST_BLIND6 = 0x46, + QUEST_BLIND7 = 0x47, + QUEST_BLIND8 = 0x48, + QUEST_VEIL1 = 0x49, + QUEST_VEIL2 = 0x4A, + QUEST_VEIL3 = 0x4B, + QUEST_VEIL4 = 0x4C, + QUEST_VEIL5 = 0x4D, + QUEST_VEIL6 = 0x4E, + QUEST_VEIL7 = 0x4F, + QUEST_VEIL8 = 0x50, + QUEST_VEIL9 = 0x51, + QUEST_VEIL10 = 0x52, + QUEST_VEIL11 = 0x53, + QUEST_ANVIL1 = 0x54, + QUEST_ANVIL2 = 0x55, + QUEST_ANVIL3 = 0x56, + QUEST_ANVIL4 = 0x57, + QUEST_ANVIL5 = 0x58, + QUEST_ANVIL6 = 0x59, + QUEST_ANVIL7 = 0x5A, + QUEST_ANVIL8 = 0x5B, + QUEST_ANVIL9 = 0x5C, + QUEST_ANVIL10 = 0x5D, + QUEST_BLOOD1 = 0x5E, + QUEST_BLOOD2 = 0x5F, + QUEST_BLOOD3 = 0x60, + QUEST_BLOOD4 = 0x61, + QUEST_BLOOD5 = 0x62, + QUEST_BLOOD6 = 0x63, + QUEST_BLOOD7 = 0x64, + QUEST_BLOOD8 = 0x65, + QUEST_WARLRD1 = 0x66, + QUEST_WARLRD2 = 0x67, + QUEST_WARLRD3 = 0x68, + QUEST_WARLRD4 = 0x69, + QUEST_WARLRD5 = 0x6A, + QUEST_WARLRD6 = 0x6B, + QUEST_WARLRD7 = 0x6C, + QUEST_WARLRD8 = 0x6D, + QUEST_WARLRD9 = 0x6E, + QUEST_INFRA1 = 0x6F, + QUEST_INFRA2 = 0x70, + QUEST_INFRA3 = 0x71, + QUEST_INFRA4 = 0x72, + QUEST_INFRA5 = 0x73, + QUEST_INFRA6 = 0x74, + QUEST_INFRA7 = 0x75, + QUEST_INFRA8 = 0x76, + QUEST_INFRA9 = 0x77, + QUEST_INFRA10 = 0x78, + QUEST_MUSH1 = 0x79, + QUEST_MUSH2 = 0x7A, + QUEST_MUSH3 = 0x7B, + QUEST_MUSH4 = 0x7C, + QUEST_MUSH5 = 0x7D, + QUEST_MUSH6 = 0x7E, + QUEST_MUSH7 = 0x7F, + QUEST_MUSH8 = 0x80, + QUEST_MUSH9 = 0x81, + QUEST_MUSH10 = 0x82, + QUEST_MUSH11 = 0x83, + QUEST_MUSH12 = 0x84, + QUEST_MUSH13 = 0x85, + QUEST_DOOM1 = 0x86, + QUEST_DOOM2 = 0x87, + QUEST_DOOM3 = 0x88, + QUEST_DOOM4 = 0x89, + QUEST_DOOM5 = 0x8A, + QUEST_DOOM6 = 0x8B, + QUEST_DOOM7 = 0x8C, + QUEST_DOOM8 = 0x8D, + QUEST_DOOM9 = 0x8E, + QUEST_DOOM10 = 0x8F, + QUEST_GARBUD1 = 0x90, + QUEST_GARBUD2 = 0x91, + QUEST_GARBUD3 = 0x92, + QUEST_GARBUD4 = 0x93, + QUEST_ZHAR1 = 0x94, + QUEST_ZHAR2 = 0x95, + QUEST_STORY1 = 0x96, + QUEST_STORY2 = 0x97, + QUEST_STORY3 = 0x98, + QUEST_STORY4 = 0x99, + QUEST_STORY5 = 0x9A, + QUEST_STORY6 = 0x9B, + QUEST_STORY7 = 0x9C, + QUEST_STORY9 = 0x9D, + QUEST_STORY10 = 0x9E, + QUEST_STORY11 = 0x9F, + QUEST_OGDEN1 = 0xA0, + QUEST_OGDEN2 = 0xA1, + QUEST_OGDEN3 = 0xA2, + QUEST_OGDEN4 = 0xA3, + QUEST_OGDEN5 = 0xA4, + QUEST_OGDEN6 = 0xA5, + QUEST_OGDEN8 = 0xA6, + QUEST_OGDEN9 = 0xA7, + QUEST_OGDEN10 = 0xA8, + QUEST_PEPIN1 = 0xA9, + QUEST_PEPIN2 = 0xAA, + QUEST_PEPIN3 = 0xAB, + QUEST_PEPIN4 = 0xAC, + QUEST_PEPIN5 = 0xAD, + QUEST_PEPIN6 = 0xAE, + QUEST_PEPIN7 = 0xAF, + QUEST_PEPIN9 = 0xB0, + QUEST_PEPIN10 = 0xB1, + QUEST_PEPIN11 = 0xB2, + QUEST_GILLIAN1 = 0xB3, + QUEST_GILLIAN2 = 0xB4, + QUEST_GILLIAN3 = 0xB5, + QUEST_GILLIAN4 = 0xB6, + QUEST_GILLIAN5 = 0xB7, + QUEST_GILLIAN6 = 0xB8, + QUEST_GILLIAN7 = 0xB9, + QUEST_GILLIAN9 = 0xBA, + QUEST_GILLIAN10 = 0xBB, + QUEST_GRISWOLD1 = 0xBC, + QUEST_GRISWOLD2 = 0xBD, + QUEST_GRISWOLD3 = 0xBE, + QUEST_GRISWOLD4 = 0xBF, + QUEST_GRISWOLD5 = 0xC0, + QUEST_GRISWOLD6 = 0xC1, + QUEST_GRISWOLD7 = 0xC2, + QUEST_GRISWOLD8 = 0xC3, + QUEST_GRISWOLD9 = 0xC4, + QUEST_GRISWOLD10 = 0xC5, + QUEST_GRISWOLD12 = 0xC6, + QUEST_GRISWOLD13 = 0xC7, + QUEST_FARNHAM1 = 0xC8, + QUEST_FARNHAM2 = 0xC9, + QUEST_FARNHAM3 = 0xCA, + QUEST_FARNHAM4 = 0xCB, + QUEST_FARNHAM5 = 0xCC, + QUEST_FARNHAM6 = 0xCD, + QUEST_FARNHAM8 = 0xCE, + QUEST_FARNHAM9 = 0xCF, + QUEST_FARNHAM10 = 0xD0, + QUEST_FARNHAM11 = 0xD1, + QUEST_FARNHAM12 = 0xD2, + QUEST_FARNHAM13 = 0xD3, + QUEST_ADRIA1 = 0xD4, + QUEST_ADRIA2 = 0xD5, + QUEST_ADRIA3 = 0xD6, + QUEST_ADRIA4 = 0xD7, + QUEST_ADRIA5 = 0xD8, + QUEST_ADRIA6 = 0xD9, + QUEST_ADRIA7 = 0xDA, + QUEST_ADRIA8 = 0xDB, + QUEST_ADRIA9 = 0xDC, + QUEST_ADRIA10 = 0xDD, + QUEST_ADRIA12 = 0xDE, + QUEST_ADRIA13 = 0xDF, + QUEST_WIRT1 = 0xE0, + QUEST_WIRT2 = 0xE1, + QUEST_WIRT3 = 0xE2, + QUEST_WIRT4 = 0xE3, + QUEST_WIRT5 = 0xE4, + QUEST_WIRT6 = 0xE5, + QUEST_WIRT7 = 0xE6, + QUEST_WIRT8 = 0xE7, + QUEST_WIRT9 = 0xE8, + QUEST_WIRT11 = 0xE9, + QUEST_WIRT12 = 0xEA, + QUEST_BONER = 0xEB, + QUEST_BLOODY = 0xEC, + QUEST_BLINDING = 0xED, + QUEST_BLOODWAR = 0xEE, + QUEST_MBONER = 0xEF, + QUEST_MBLOODY = 0xF0, + QUEST_MBLINDING = 0xF1, + QUEST_MBLOODWAR = 0xF2, + QUEST_RBONER = 0xF3, + QUEST_RBLOODY = 0xF4, + QUEST_RBLINDING = 0xF5, + QUEST_RBLOODWAR = 0xF6, + QUEST_COW1 = 0xF7, + QUEST_COW2 = 0xF8, + QUEST_BOOK11 = 0xF9, + QUEST_BOOK12 = 0xFA, + QUEST_BOOK13 = 0xFB, + QUEST_BOOK21 = 0xFC, + QUEST_BOOK22 = 0xFD, + QUEST_BOOK23 = 0xFE, + QUEST_BOOK31 = 0xFF, + QUEST_BOOK32 = 0x100, + QUEST_BOOK33 = 0x101, + QUEST_INTRO = 0x102 }; -enum object_graphic_id -{ - OFILE_L1BRAZ = 0x0, - OFILE_L1DOORS = 0x1, - OFILE_LEVER = 0x2, - OFILE_CHEST1 = 0x3, - OFILE_CHEST2 = 0x4, - OFILE_BANNER = 0x5, - OFILE_SKULPILE = 0x6, - OFILE_SKULFIRE = 0x7, - OFILE_SKULSTIK = 0x8, - OFILE_CRUXSK1 = 0x9, - OFILE_CRUXSK2 = 0xA, - OFILE_CRUXSK3 = 0xB, - OFILE_BOOK1 = 0xC, - OFILE_BOOK2 = 0xD, - OFILE_ROCKSTAN = 0xE, - OFILE_ANGEL = 0xF, - OFILE_CHEST3 = 0x10, - OFILE_BURNCROS = 0x11, - OFILE_CANDLE2 = 0x12, - OFILE_NUDE2 = 0x13, - OFILE_SWITCH4 = 0x14, - OFILE_TNUDEM = 0x15, - OFILE_TNUDEW = 0x16, - OFILE_TSOUL = 0x17, - OFILE_L2DOORS = 0x18, - OFILE_WTORCH4 = 0x19, - OFILE_WTORCH3 = 0x1A, - OFILE_SARC = 0x1B, - OFILE_FLAME1 = 0x1C, - OFILE_PRSRPLT1 = 0x1D, - OFILE_TRAPHOLE = 0x1E, - OFILE_MINIWATR = 0x1F, - OFILE_WTORCH2 = 0x20, - OFILE_WTORCH1 = 0x21, - OFILE_BCASE = 0x22, - OFILE_BSHELF = 0x23, - OFILE_WEAPSTND = 0x24, - OFILE_BARREL = 0x25, - OFILE_BARRELEX = 0x26, - OFILE_LSHRINEG = 0x27, - OFILE_RSHRINEG = 0x28, - OFILE_BLOODFNT = 0x29, - OFILE_DECAP = 0x2A, - OFILE_PEDISTL = 0x2B, - OFILE_L3DOORS = 0x2C, - OFILE_PFOUNTN = 0x2D, - OFILE_ARMSTAND = 0x2E, - OFILE_GOATSHRN = 0x2F, - OFILE_CAULDREN = 0x30, - OFILE_MFOUNTN = 0x31, - OFILE_TFOUNTN = 0x32, - OFILE_ALTBOY = 0x33, - OFILE_MCIRL = 0x34, - OFILE_BKSLBRNT = 0x35, - OFILE_MUSHPTCH = 0x36, - OFILE_LZSTAND = 0x37, +enum object_graphic_id { + OFILE_L1BRAZ = 0x0, + OFILE_L1DOORS = 0x1, + OFILE_LEVER = 0x2, + OFILE_CHEST1 = 0x3, + OFILE_CHEST2 = 0x4, + OFILE_BANNER = 0x5, + OFILE_SKULPILE = 0x6, + OFILE_SKULFIRE = 0x7, + OFILE_SKULSTIK = 0x8, + OFILE_CRUXSK1 = 0x9, + OFILE_CRUXSK2 = 0xA, + OFILE_CRUXSK3 = 0xB, + OFILE_BOOK1 = 0xC, + OFILE_BOOK2 = 0xD, + OFILE_ROCKSTAN = 0xE, + OFILE_ANGEL = 0xF, + OFILE_CHEST3 = 0x10, + OFILE_BURNCROS = 0x11, + OFILE_CANDLE2 = 0x12, + OFILE_NUDE2 = 0x13, + OFILE_SWITCH4 = 0x14, + OFILE_TNUDEM = 0x15, + OFILE_TNUDEW = 0x16, + OFILE_TSOUL = 0x17, + OFILE_L2DOORS = 0x18, + OFILE_WTORCH4 = 0x19, + OFILE_WTORCH3 = 0x1A, + OFILE_SARC = 0x1B, + OFILE_FLAME1 = 0x1C, + OFILE_PRSRPLT1 = 0x1D, + OFILE_TRAPHOLE = 0x1E, + OFILE_MINIWATR = 0x1F, + OFILE_WTORCH2 = 0x20, + OFILE_WTORCH1 = 0x21, + OFILE_BCASE = 0x22, + OFILE_BSHELF = 0x23, + OFILE_WEAPSTND = 0x24, + OFILE_BARREL = 0x25, + OFILE_BARRELEX = 0x26, + OFILE_LSHRINEG = 0x27, + OFILE_RSHRINEG = 0x28, + OFILE_BLOODFNT = 0x29, + OFILE_DECAP = 0x2A, + OFILE_PEDISTL = 0x2B, + OFILE_L3DOORS = 0x2C, + OFILE_PFOUNTN = 0x2D, + OFILE_ARMSTAND = 0x2E, + OFILE_GOATSHRN = 0x2F, + OFILE_CAULDREN = 0x30, + OFILE_MFOUNTN = 0x31, + OFILE_TFOUNTN = 0x32, + OFILE_ALTBOY = 0x33, + OFILE_MCIRL = 0x34, + OFILE_BKSLBRNT = 0x35, + OFILE_MUSHPTCH = 0x36, + OFILE_LZSTAND = 0x37, }; -enum dungeon_type -{ - DTYPE_TOWN = 0x0, - DTYPE_CATHEDRAL = 0x1, - DTYPE_CATACOMBS = 0x2, - DTYPE_CAVES = 0x3, - DTYPE_HELL = 0x4, - DTYPE_NONE = 0xFF, +enum dungeon_type { + DTYPE_TOWN = 0x0, + DTYPE_CATHEDRAL = 0x1, + DTYPE_CATACOMBS = 0x2, + DTYPE_CAVES = 0x3, + DTYPE_HELL = 0x4, + DTYPE_NONE = 0xFF, }; -enum dflag -{ - DFLAG_MISSILE = 0x01, - DFLAG_VISIBLE = 0x02, - DFLAG_DEAD_PLAYER = 0x04, - DFLAG_POPULATED = 0x08, - DFLAG_MONSTER = 0x10, - DFLAG_PLAYER = 0x20, - DFLAG_LIT = 0x40, - DFLAG_EXPLORED = 0x80, +enum dflag { + DFLAG_MISSILE = 0x01, + DFLAG_VISIBLE = 0x02, + DFLAG_DEAD_PLAYER = 0x04, + DFLAG_POPULATED = 0x08, + DFLAG_MONSTER = 0x10, + DFLAG_PLAYER = 0x20, + DFLAG_LIT = 0x40, + DFLAG_EXPLORED = 0x80, }; -enum dungeon_message -{ - DMSG_CATHEDRAL = 1 << 0, - DMSG_CATACOMBS = 1 << 1, - DMSG_CAVES = 1 << 2, - DMSG_HELL = 1 << 3, - DMSG_DIABLO = 1 << 4, +enum dungeon_message { + DMSG_CATHEDRAL = 1 << 0, + DMSG_CATACOMBS = 1 << 1, + DMSG_CAVES = 1 << 2, + DMSG_HELL = 1 << 3, + DMSG_DIABLO = 1 << 4, }; -enum magic_type -{ - STYPE_FIRE = 0x0, - STYPE_LIGHTNING = 0x1, - STYPE_MAGIC = 0x2, +enum magic_type { + STYPE_FIRE = 0x0, + STYPE_LIGHTNING = 0x1, + STYPE_MAGIC = 0x2, }; -enum theme_id -{ - THEME_BARREL = 0x0, - THEME_SHRINE = 0x1, - THEME_MONSTPIT = 0x2, - THEME_SKELROOM = 0x3, - THEME_TREASURE = 0x4, - THEME_LIBRARY = 0x5, - THEME_TORTURE = 0x6, - THEME_BLOODFOUNTAIN = 0x7, - THEME_DECAPITATED = 0x8, - THEME_PURIFYINGFOUNTAIN = 0x9, - THEME_ARMORSTAND = 0xA, - THEME_GOATSHRINE = 0xB, - THEME_CAULDRON = 0xC, - THEME_MURKYFOUNTAIN = 0xD, - THEME_TEARFOUNTAIN = 0xE, - THEME_BRNCROSS = 0xF, - THEME_WEAPONRACK = 0x10, - THEME_NONE = 0xFF, +enum theme_id { + THEME_BARREL = 0x0, + THEME_SHRINE = 0x1, + THEME_MONSTPIT = 0x2, + THEME_SKELROOM = 0x3, + THEME_TREASURE = 0x4, + THEME_LIBRARY = 0x5, + THEME_TORTURE = 0x6, + THEME_BLOODFOUNTAIN = 0x7, + THEME_DECAPITATED = 0x8, + THEME_PURIFYINGFOUNTAIN = 0x9, + THEME_ARMORSTAND = 0xA, + THEME_GOATSHRINE = 0xB, + THEME_CAULDRON = 0xC, + THEME_MURKYFOUNTAIN = 0xD, + THEME_TEARFOUNTAIN = 0xE, + THEME_BRNCROSS = 0xF, + THEME_WEAPONRACK = 0x10, + THEME_NONE = 0xFF, }; -enum event_type -{ - EVENT_TYPE_PLAYER_CREATE_GAME = 1, - EVENT_TYPE_2 = 2, - EVENT_TYPE_PLAYER_LEAVE_GAME = 3, - EVENT_TYPE_PLAYER_MESSAGE = 4, - EVENT_TYPE_5 = 5, - EVENT_TYPE_6 = 6, - EVENT_TYPE_7 = 7, - EVENT_TYPE_8 = 8, - EVENT_TYPE_9 = 9, - EVENT_TYPE_10 = 10, - EVENT_TYPE_11 = 11, - EVENT_TYPE_12 = 12, - EVENT_TYPE_13 = 13, - EVENT_TYPE_14 = 14, - EVENT_TYPE_15 = 15, +enum event_type { + EVENT_TYPE_PLAYER_CREATE_GAME = 1, + EVENT_TYPE_2 = 2, + EVENT_TYPE_PLAYER_LEAVE_GAME = 3, + EVENT_TYPE_PLAYER_MESSAGE = 4, + EVENT_TYPE_5 = 5, + EVENT_TYPE_6 = 6, + EVENT_TYPE_7 = 7, + EVENT_TYPE_8 = 8, + EVENT_TYPE_9 = 9, + EVENT_TYPE_10 = 10, + EVENT_TYPE_11 = 11, + EVENT_TYPE_12 = 12, + EVENT_TYPE_13 = 13, + EVENT_TYPE_14 = 14, + EVENT_TYPE_15 = 15, }; -enum _copyprot_results -{ - COPYPROT_OK = 1, - COPYPROT_CANCEL = 2, +enum _copyprot_results { + COPYPROT_OK = 1, + COPYPROT_CANCEL = 2, }; -enum text_color -{ - COL_WHITE = 0x0, - COL_BLUE = 0x1, - COL_RED = 0x2, - COL_GOLD = 0x3, +enum text_color { + COL_WHITE = 0x0, + COL_BLUE = 0x1, + COL_RED = 0x2, + COL_GOLD = 0x3, }; -enum _difficulty -{ - DIFF_NORMAL = 0x0, - DIFF_NIGHTMARE = 0x1, - DIFF_HELL = 0x2, - NUM_DIFFICULTIES = 0x3, +enum _difficulty { + DIFF_NORMAL = 0x0, + DIFF_NIGHTMARE = 0x1, + DIFF_HELL = 0x2, + NUM_DIFFICULTIES = 0x3, }; -enum MON_MODE -{ - MM_STAND = 0, - MM_WALK = 1, - MM_WALK2 = 2, - MM_WALK3 = 3, - MM_ATTACK = 4, - MM_GOTHIT = 5, - MM_DEATH = 6, - MM_SATTACK = 7, - MM_FADEIN = 8, - MM_FADEOUT = 9, - MM_RATTACK = 10, - MM_SPSTAND = 11, - MM_RSPATTACK = 12, - MM_DELAY = 13, - MM_CHARGE = 14, - MM_STONE = 15, - MM_HEAL = 16, - MM_TALK = 17, +enum MON_MODE { + MM_STAND = 0, + MM_WALK = 1, + MM_WALK2 = 2, + MM_WALK3 = 3, + MM_ATTACK = 4, + MM_GOTHIT = 5, + MM_DEATH = 6, + MM_SATTACK = 7, + MM_FADEIN = 8, + MM_FADEOUT = 9, + MM_RATTACK = 10, + MM_SPSTAND = 11, + MM_RSPATTACK = 12, + MM_DELAY = 13, + MM_CHARGE = 14, + MM_STONE = 15, + MM_HEAL = 16, + MM_TALK = 17, }; -enum PLR_MODE -{ - PM_STAND = 0, - PM_WALK = 1, - PM_WALK2 = 2, - PM_WALK3 = 3, - PM_ATTACK = 4, - PM_RATTACK = 5, - PM_BLOCK = 6, - PM_GOTHIT = 7, - PM_DEATH = 8, - PM_SPELL = 9, - PM_NEWLVL = 10, - PM_QUIT = 11, +enum PLR_MODE { + PM_STAND = 0, + PM_WALK = 1, + PM_WALK2 = 2, + PM_WALK3 = 3, + PM_ATTACK = 4, + PM_RATTACK = 5, + PM_BLOCK = 6, + PM_GOTHIT = 7, + PM_DEATH = 8, + PM_SPELL = 9, + PM_NEWLVL = 10, + PM_QUIT = 11, }; -enum spell_type -{ - RSPLTYPE_SKILL = 0x0, - RSPLTYPE_SPELL = 0x1, - RSPLTYPE_SCROLL = 0x2, - RSPLTYPE_CHARGES = 0x3, - RSPLTYPE_INVALID = 0x4, +enum spell_type { + RSPLTYPE_SKILL = 0x0, + RSPLTYPE_SPELL = 0x1, + RSPLTYPE_SCROLL = 0x2, + RSPLTYPE_CHARGES = 0x3, + RSPLTYPE_INVALID = 0x4, }; -enum cursor_id -{ - CURSOR_NONE = 0x0, - CURSOR_HAND = 0x1, - CURSOR_IDENTIFY = 0x2, - CURSOR_REPAIR = 0x3, - CURSOR_RECHARGE = 0x4, - CURSOR_DISARM = 0x5, - CURSOR_OIL = 0x6, - CURSOR_TELEKINESIS = 0x7, - CURSOR_RESURRECT = 0x8, - CURSOR_TELEPORT = 0x9, - CURSOR_HEALOTHER = 0xA, - CURSOR_HOURGLASS = 0xB, - CURSOR_FIRSTITEM = 0xC, +enum cursor_id { + CURSOR_NONE = 0x0, + CURSOR_HAND = 0x1, + CURSOR_IDENTIFY = 0x2, + CURSOR_REPAIR = 0x3, + CURSOR_RECHARGE = 0x4, + CURSOR_DISARM = 0x5, + CURSOR_OIL = 0x6, + CURSOR_TELEKINESIS = 0x7, + CURSOR_RESURRECT = 0x8, + CURSOR_TELEPORT = 0x9, + CURSOR_HEALOTHER = 0xA, + CURSOR_HOURGLASS = 0xB, + CURSOR_FIRSTITEM = 0xC, }; -enum direction -{ - DIR_S = 0x0, - DIR_SW = 0x1, - DIR_W = 0x2, - DIR_NW = 0x3, - DIR_N = 0x4, - DIR_NE = 0x5, - DIR_E = 0x6, - DIR_SE = 0x7, - DIR_OMNI = 0x8, +enum direction { + DIR_S = 0x0, + DIR_SW = 0x1, + DIR_W = 0x2, + DIR_NW = 0x3, + DIR_N = 0x4, + DIR_NE = 0x5, + DIR_E = 0x6, + DIR_SE = 0x7, + DIR_OMNI = 0x8, }; -enum _scroll_direction -{ - SDIR_NONE = 0x0, - SDIR_N = 0x1, - SDIR_NE = 0x2, - SDIR_E = 0x3, - SDIR_SE = 0x4, - SDIR_S = 0x5, - SDIR_SW = 0x6, - SDIR_W = 0x7, - SDIR_NW = 0x8, +enum _scroll_direction { + SDIR_NONE = 0x0, + SDIR_N = 0x1, + SDIR_NE = 0x2, + SDIR_E = 0x3, + SDIR_SE = 0x4, + SDIR_S = 0x5, + SDIR_SW = 0x6, + SDIR_W = 0x7, + SDIR_NW = 0x8, }; -enum interface_mode -{ - WM_DIAB = 0x401, - WM_DIABNEXTLVL = 0x402, // WM_USER+2 - WM_DIABPREVLVL = 0x403, - WM_DIABRTNLVL = 0x404, - WM_DIABSETLVL = 0x405, - WM_DIABWARPLVL = 0x406, - WM_DIABTOWNWARP = 0x407, - WM_DIABTWARPUP = 0x408, - WM_DIABRETOWN = 0x409, - WM_DIABNEWGAME = 0x40A, - WM_DIABLOADGAME = 0x40B - // WM_LEIGHSKIP = 0x40C, // psx only - // WM_DIAVNEWLVL = 0x40D, // psx only +enum interface_mode { + WM_DIAB = 0x401, + WM_DIABNEXTLVL = 0x402, // WM_USER+2 + WM_DIABPREVLVL = 0x403, + WM_DIABRTNLVL = 0x404, + WM_DIABSETLVL = 0x405, + WM_DIABWARPLVL = 0x406, + WM_DIABTOWNWARP = 0x407, + WM_DIABTWARPUP = 0x408, + WM_DIABRETOWN = 0x409, + WM_DIABNEWGAME = 0x40A, + WM_DIABLOADGAME = 0x40B + // WM_LEIGHSKIP = 0x40C, // psx only + // WM_DIAVNEWLVL = 0x40D, // psx only }; -enum game_info -{ - GAMEINFO_NAME = 1, - GAMEINFO_PASSWORD = 2, - GAMEINFO_STATS = 3, - GAMEINFO_MODEFLAG = 4, - GAMEINFO_GAMETEMPLATE = 5, - GAMEINFO_PLAYERS = 6, +enum game_info { + GAMEINFO_NAME = 1, + GAMEINFO_PASSWORD = 2, + GAMEINFO_STATS = 3, + GAMEINFO_MODEFLAG = 4, + GAMEINFO_GAMETEMPLATE = 5, + GAMEINFO_PLAYERS = 6, }; -enum spell_id -{ - SPL_NULL = 0x0, - SPL_FIREBOLT = 0x1, - SPL_HEAL = 0x2, - SPL_LIGHTNING = 0x3, - SPL_FLASH = 0x4, - SPL_IDENTIFY = 0x5, - SPL_FIREWALL = 0x6, - SPL_TOWN = 0x7, - SPL_STONE = 0x8, - SPL_INFRA = 0x9, - SPL_RNDTELEPORT = 0xA, - SPL_MANASHIELD = 0xB, - SPL_FIREBALL = 0xC, - SPL_GUARDIAN = 0xD, - SPL_CHAIN = 0xE, - SPL_WAVE = 0xF, - SPL_DOOMSERP = 0x10, - SPL_BLODRIT = 0x11, - SPL_NOVA = 0x12, - SPL_INVISIBIL = 0x13, - SPL_FLAME = 0x14, - SPL_GOLEM = 0x15, - SPL_BLODBOIL = 0x16, - SPL_TELEPORT = 0x17, - SPL_APOCA = 0x18, - SPL_ETHEREALIZE = 0x19, - SPL_REPAIR = 0x1A, - SPL_RECHARGE = 0x1B, - SPL_DISARM = 0x1C, - SPL_ELEMENT = 0x1D, - SPL_CBOLT = 0x1E, - SPL_HBOLT = 0x1F, - SPL_RESURRECT = 0x20, - SPL_TELEKINESIS = 0x21, - SPL_HEALOTHER = 0x22, - SPL_FLARE = 0x23, - SPL_BONESPIRIT = 0x24, - SPL_INVALID = 0xFFFFFFFF, +enum spell_id { + SPL_NULL = 0x0, + SPL_FIREBOLT = 0x1, + SPL_HEAL = 0x2, + SPL_LIGHTNING = 0x3, + SPL_FLASH = 0x4, + SPL_IDENTIFY = 0x5, + SPL_FIREWALL = 0x6, + SPL_TOWN = 0x7, + SPL_STONE = 0x8, + SPL_INFRA = 0x9, + SPL_RNDTELEPORT = 0xA, + SPL_MANASHIELD = 0xB, + SPL_FIREBALL = 0xC, + SPL_GUARDIAN = 0xD, + SPL_CHAIN = 0xE, + SPL_WAVE = 0xF, + SPL_DOOMSERP = 0x10, + SPL_BLODRIT = 0x11, + SPL_NOVA = 0x12, + SPL_INVISIBIL = 0x13, + SPL_FLAME = 0x14, + SPL_GOLEM = 0x15, + SPL_BLODBOIL = 0x16, + SPL_TELEPORT = 0x17, + SPL_APOCA = 0x18, + SPL_ETHEREALIZE = 0x19, + SPL_REPAIR = 0x1A, + SPL_RECHARGE = 0x1B, + SPL_DISARM = 0x1C, + SPL_ELEMENT = 0x1D, + SPL_CBOLT = 0x1E, + SPL_HBOLT = 0x1F, + SPL_RESURRECT = 0x20, + SPL_TELEKINESIS = 0x21, + SPL_HEALOTHER = 0x22, + SPL_FLARE = 0x23, + SPL_BONESPIRIT = 0x24, + SPL_INVALID = 0xFFFFFFFF, }; -enum _cmd_id -{ - CMD_STAND = 0, - CMD_WALKXY = 1, - CMD_ACK_PLRINFO = 2, - CMD_ADDSTR = 3, - CMD_ADDMAG = 4, - CMD_ADDDEX = 5, - CMD_ADDVIT = 6, - CMD_SBSPELL = 7, - CMD_GETITEM = 8, - CMD_AGETITEM = 9, - CMD_PUTITEM = 10, - CMD_RESPAWNITEM = 11, - CMD_ATTACKXY = 12, - CMD_RATTACKXY = 13, - CMD_SPELLXY = 14, - CMD_TSPELLXY = 15, - CMD_OPOBJXY = 16, - CMD_DISARMXY = 17, - CMD_ATTACKID = 18, - CMD_ATTACKPID = 19, - CMD_RATTACKID = 20, - CMD_RATTACKPID = 21, - CMD_SPELLID = 22, - CMD_SPELLPID = 23, - CMD_TSPELLID = 24, - CMD_TSPELLPID = 25, - CMD_RESURRECT = 26, - CMD_OPOBJT = 27, - CMD_KNOCKBACK = 28, - CMD_TALKXY = 29, - CMD_NEWLVL = 30, - CMD_WARP = 31, - CMD_CHEAT_EXPERIENCE = 32, - CMD_CHEAT_SPELL_LEVEL = 33, - CMD_DEBUG = 34, - CMD_SYNCDATA = 35, - CMD_MONSTDEATH = 36, - CMD_MONSTDAMAGE = 37, - CMD_PLRDEAD = 38, - CMD_REQUESTGITEM = 39, - CMD_REQUESTAGITEM = 40, - CMD_GOTOGETITEM = 41, - CMD_GOTOAGETITEM = 42, - CMD_OPENDOOR = 43, - CMD_CLOSEDOOR = 44, - CMD_OPERATEOBJ = 45, - CMD_PLROPOBJ = 46, - CMD_BREAKOBJ = 47, - CMD_CHANGEPLRITEMS = 48, - CMD_DELPLRITEMS = 49, - CMD_PLRDAMAGE = 50, - CMD_PLRLEVEL = 51, - CMD_DROPITEM = 52, - CMD_PLAYER_JOINLEVEL = 53, - CMD_SEND_PLRINFO = 54, - CMD_SATTACKXY = 55, - CMD_ACTIVATEPORTAL = 56, - CMD_DEACTIVATEPORTAL = 57, - CMD_DLEVEL_0 = 58, - CMD_DLEVEL_1 = 59, - CMD_DLEVEL_2 = 60, - CMD_DLEVEL_3 = 61, - CMD_DLEVEL_4 = 62, - CMD_DLEVEL_5 = 63, - CMD_DLEVEL_6 = 64, - CMD_DLEVEL_7 = 65, - CMD_DLEVEL_8 = 66, - CMD_DLEVEL_9 = 67, - CMD_DLEVEL_10 = 68, - CMD_DLEVEL_11 = 69, - CMD_DLEVEL_12 = 70, - CMD_DLEVEL_13 = 71, - CMD_DLEVEL_14 = 72, - CMD_DLEVEL_15 = 73, - CMD_DLEVEL_16 = 74, - CMD_DLEVEL_JUNK = 75, - CMD_DLEVEL_END = 76, - CMD_HEALOTHER = 77, - CMD_STRING = 78, - CMD_SETSTR = 79, - CMD_SETMAG = 80, - CMD_SETDEX = 81, - CMD_SETVIT = 82, - CMD_RETOWN = 83, - CMD_SPELLXYD = 84, - CMD_ITEMEXTRA = 85, - CMD_SYNCPUTITEM = 86, - CMD_KILLGOLEM = 87, - CMD_SYNCQUEST = 88, - CMD_ENDSHIELD = 89, - CMD_AWAKEGOLEM = 90, - CMD_NOVA = 91, - CMD_SETSHIELD = 92, - CMD_REMSHIELD = 93, - FAKE_CMD_SETID = 94, - FAKE_CMD_DROPID = 95, - NUM_CMDS = 96, +enum _cmd_id { + CMD_STAND = 0, + CMD_WALKXY = 1, + CMD_ACK_PLRINFO = 2, + CMD_ADDSTR = 3, + CMD_ADDMAG = 4, + CMD_ADDDEX = 5, + CMD_ADDVIT = 6, + CMD_SBSPELL = 7, + CMD_GETITEM = 8, + CMD_AGETITEM = 9, + CMD_PUTITEM = 10, + CMD_RESPAWNITEM = 11, + CMD_ATTACKXY = 12, + CMD_RATTACKXY = 13, + CMD_SPELLXY = 14, + CMD_TSPELLXY = 15, + CMD_OPOBJXY = 16, + CMD_DISARMXY = 17, + CMD_ATTACKID = 18, + CMD_ATTACKPID = 19, + CMD_RATTACKID = 20, + CMD_RATTACKPID = 21, + CMD_SPELLID = 22, + CMD_SPELLPID = 23, + CMD_TSPELLID = 24, + CMD_TSPELLPID = 25, + CMD_RESURRECT = 26, + CMD_OPOBJT = 27, + CMD_KNOCKBACK = 28, + CMD_TALKXY = 29, + CMD_NEWLVL = 30, + CMD_WARP = 31, + CMD_CHEAT_EXPERIENCE = 32, + CMD_CHEAT_SPELL_LEVEL = 33, + CMD_DEBUG = 34, + CMD_SYNCDATA = 35, + CMD_MONSTDEATH = 36, + CMD_MONSTDAMAGE = 37, + CMD_PLRDEAD = 38, + CMD_REQUESTGITEM = 39, + CMD_REQUESTAGITEM = 40, + CMD_GOTOGETITEM = 41, + CMD_GOTOAGETITEM = 42, + CMD_OPENDOOR = 43, + CMD_CLOSEDOOR = 44, + CMD_OPERATEOBJ = 45, + CMD_PLROPOBJ = 46, + CMD_BREAKOBJ = 47, + CMD_CHANGEPLRITEMS = 48, + CMD_DELPLRITEMS = 49, + CMD_PLRDAMAGE = 50, + CMD_PLRLEVEL = 51, + CMD_DROPITEM = 52, + CMD_PLAYER_JOINLEVEL = 53, + CMD_SEND_PLRINFO = 54, + CMD_SATTACKXY = 55, + CMD_ACTIVATEPORTAL = 56, + CMD_DEACTIVATEPORTAL = 57, + CMD_DLEVEL_0 = 58, + CMD_DLEVEL_1 = 59, + CMD_DLEVEL_2 = 60, + CMD_DLEVEL_3 = 61, + CMD_DLEVEL_4 = 62, + CMD_DLEVEL_5 = 63, + CMD_DLEVEL_6 = 64, + CMD_DLEVEL_7 = 65, + CMD_DLEVEL_8 = 66, + CMD_DLEVEL_9 = 67, + CMD_DLEVEL_10 = 68, + CMD_DLEVEL_11 = 69, + CMD_DLEVEL_12 = 70, + CMD_DLEVEL_13 = 71, + CMD_DLEVEL_14 = 72, + CMD_DLEVEL_15 = 73, + CMD_DLEVEL_16 = 74, + CMD_DLEVEL_JUNK = 75, + CMD_DLEVEL_END = 76, + CMD_HEALOTHER = 77, + CMD_STRING = 78, + CMD_SETSTR = 79, + CMD_SETMAG = 80, + CMD_SETDEX = 81, + CMD_SETVIT = 82, + CMD_RETOWN = 83, + CMD_SPELLXYD = 84, + CMD_ITEMEXTRA = 85, + CMD_SYNCPUTITEM = 86, + CMD_KILLGOLEM = 87, + CMD_SYNCQUEST = 88, + CMD_ENDSHIELD = 89, + CMD_AWAKEGOLEM = 90, + CMD_NOVA = 91, + CMD_SETSHIELD = 92, + CMD_REMSHIELD = 93, + FAKE_CMD_SETID = 94, + FAKE_CMD_DROPID = 95, + NUM_CMDS = 96, }; -enum _talker_id -{ - TOWN_SMITH = 0x0, - TOWN_HEALER = 0x1, - TOWN_DEADGUY = 0x2, - TOWN_TAVERN = 0x3, - TOWN_STORY = 0x4, - TOWN_DRUNK = 0x5, - TOWN_WITCH = 0x6, - TOWN_BMAID = 0x7, - TOWN_PEGBOY = 0x8, - TOWN_COW = 0x9, - TOWN_PRIEST = 0xA, +enum _talker_id { + TOWN_SMITH = 0x0, + TOWN_HEALER = 0x1, + TOWN_DEADGUY = 0x2, + TOWN_TAVERN = 0x3, + TOWN_STORY = 0x4, + TOWN_DRUNK = 0x5, + TOWN_WITCH = 0x6, + TOWN_BMAID = 0x7, + TOWN_PEGBOY = 0x8, + TOWN_COW = 0x9, + TOWN_PRIEST = 0xA, }; -enum _music_id -{ - TMUSIC_TOWN = 0, - TMUSIC_L1 = 1, - TMUSIC_L2 = 2, - TMUSIC_L3 = 3, - TMUSIC_L4 = 4, - TMUSIC_INTRO = 5, - NUM_MUSIC = 6, +enum _music_id { + TMUSIC_TOWN = 0, + TMUSIC_L1 = 1, + TMUSIC_L2 = 2, + TMUSIC_L3 = 3, + TMUSIC_L4 = 4, + TMUSIC_INTRO = 5, + NUM_MUSIC = 6, }; -enum _mainmenu_selections -{ - MAINMENU_SINGLE_PLAYER = 1, - MAINMENU_MULTIPLAYER = 2, - MAINMENU_REPLAY_INTRO = 3, - MAINMENU_SHOW_CREDITS = 4, - MAINMENU_EXIT_DIABLO = 5, - MAINMENU_ATTRACT_MODE = 6, +enum _mainmenu_selections { + MAINMENU_SINGLE_PLAYER = 1, + MAINMENU_MULTIPLAYER = 2, + MAINMENU_REPLAY_INTRO = 3, + MAINMENU_SHOW_CREDITS = 4, + MAINMENU_EXIT_DIABLO = 5, + MAINMENU_ATTRACT_MODE = 6, }; -enum panel_button_id -{ - PANBTN_CHARINFO = 0, - PANBTN_QLOG = 1, - PANBTN_AUTOMAP = 2, - PANBTN_MAINMENU = 3, - PANBTN_INVENTORY = 4, - PANBTN_SPELLBOOK = 5, - PANBTN_SENDMSG = 6, - PANBTN_FRIENDLY = 7, +enum panel_button_id { + PANBTN_CHARINFO = 0, + PANBTN_QLOG = 1, + PANBTN_AUTOMAP = 2, + PANBTN_MAINMENU = 3, + PANBTN_INVENTORY = 4, + PANBTN_SPELLBOOK = 5, + PANBTN_SENDMSG = 6, + PANBTN_FRIENDLY = 7, }; -enum attribute_id -{ - ATTRIB_STR = 0, - ATTRIB_MAG = 1, - ATTRIB_DEX = 2, - ATTRIB_VIT = 3, +enum attribute_id { + ATTRIB_STR = 0, + ATTRIB_MAG = 1, + ATTRIB_DEX = 2, + ATTRIB_VIT = 3, }; -enum _object_id -{ - OBJ_L1LIGHT = 0x0, - OBJ_L1LDOOR = 0x1, - OBJ_L1RDOOR = 0x2, - OBJ_SKFIRE = 0x3, - OBJ_LEVER = 0x4, - OBJ_CHEST1 = 0x5, - OBJ_CHEST2 = 0x6, - OBJ_CHEST3 = 0x7, - OBJ_CANDLE1 = 0x8, - OBJ_CANDLE2 = 0x9, - OBJ_CANDLEO = 0xA, - OBJ_BANNERL = 0xB, - OBJ_BANNERM = 0xC, - OBJ_BANNERR = 0xD, - OBJ_SKPILE = 0xE, - OBJ_SKSTICK1 = 0xF, - OBJ_SKSTICK2 = 0x10, - OBJ_SKSTICK3 = 0x11, - OBJ_SKSTICK4 = 0x12, - OBJ_SKSTICK5 = 0x13, - OBJ_CRUX1 = 0x14, - OBJ_CRUX2 = 0x15, - OBJ_CRUX3 = 0x16, - OBJ_STAND = 0x17, - OBJ_ANGEL = 0x18, - OBJ_BOOK2L = 0x19, - OBJ_BCROSS = 0x1A, - OBJ_NUDEW2R = 0x1B, - OBJ_SWITCHSKL = 0x1C, - OBJ_TNUDEM1 = 0x1D, - OBJ_TNUDEM2 = 0x1E, - OBJ_TNUDEM3 = 0x1F, - OBJ_TNUDEM4 = 0x20, - OBJ_TNUDEW1 = 0x21, - OBJ_TNUDEW2 = 0x22, - OBJ_TNUDEW3 = 0x23, - OBJ_TORTURE1 = 0x24, - OBJ_TORTURE2 = 0x25, - OBJ_TORTURE3 = 0x26, - OBJ_TORTURE4 = 0x27, - OBJ_TORTURE5 = 0x28, - OBJ_BOOK2R = 0x29, - OBJ_L2LDOOR = 0x2A, - OBJ_L2RDOOR = 0x2B, - OBJ_TORCHL = 0x2C, - OBJ_TORCHR = 0x2D, - OBJ_TORCHL2 = 0x2E, - OBJ_TORCHR2 = 0x2F, - OBJ_SARC = 0x30, - OBJ_FLAMEHOLE = 0x31, - OBJ_FLAMELVR = 0x32, - OBJ_WATER = 0x33, - OBJ_BOOKLVR = 0x34, - OBJ_TRAPL = 0x35, - OBJ_TRAPR = 0x36, - OBJ_BOOKSHELF = 0x37, - OBJ_WEAPRACK = 0x38, - OBJ_BARREL = 0x39, - OBJ_BARRELEX = 0x3A, - OBJ_SHRINEL = 0x3B, - OBJ_SHRINER = 0x3C, - OBJ_SKELBOOK = 0x3D, - OBJ_BOOKCASEL = 0x3E, - OBJ_BOOKCASER = 0x3F, - OBJ_BOOKSTAND = 0x40, - OBJ_BOOKCANDLE = 0x41, - OBJ_BLOODFTN = 0x42, - OBJ_DECAP = 0x43, - OBJ_TCHEST1 = 0x44, - OBJ_TCHEST2 = 0x45, - OBJ_TCHEST3 = 0x46, - OBJ_BLINDBOOK = 0x47, - OBJ_BLOODBOOK = 0x48, - OBJ_PEDISTAL = 0x49, - OBJ_L3LDOOR = 0x4A, - OBJ_L3RDOOR = 0x4B, - OBJ_PURIFYINGFTN = 0x4C, - OBJ_ARMORSTAND = 0x4D, - OBJ_ARMORSTANDN = 0x4E, - OBJ_GOATSHRINE = 0x4F, - OBJ_CAULDRON = 0x50, - OBJ_MURKYFTN = 0x51, - OBJ_TEARFTN = 0x52, - OBJ_ALTBOY = 0x53, - OBJ_MCIRCLE1 = 0x54, - OBJ_MCIRCLE2 = 0x55, - OBJ_STORYBOOK = 0x56, - OBJ_STORYCANDLE = 0x57, - OBJ_STEELTOME = 0x58, - OBJ_WARARMOR = 0x59, - OBJ_WARWEAP = 0x5A, - OBJ_TBCROSS = 0x5B, - OBJ_WEAPONRACK = 0x5C, - OBJ_WEAPONRACKN = 0x5D, - OBJ_MUSHPATCH = 0x5E, - OBJ_LAZSTAND = 0x5F, - OBJ_SLAINHERO = 0x60, - OBJ_SIGNCHEST = 0x61, - OBJ_NULL_98 = 0x62, +enum _object_id { + OBJ_L1LIGHT = 0x0, + OBJ_L1LDOOR = 0x1, + OBJ_L1RDOOR = 0x2, + OBJ_SKFIRE = 0x3, + OBJ_LEVER = 0x4, + OBJ_CHEST1 = 0x5, + OBJ_CHEST2 = 0x6, + OBJ_CHEST3 = 0x7, + OBJ_CANDLE1 = 0x8, + OBJ_CANDLE2 = 0x9, + OBJ_CANDLEO = 0xA, + OBJ_BANNERL = 0xB, + OBJ_BANNERM = 0xC, + OBJ_BANNERR = 0xD, + OBJ_SKPILE = 0xE, + OBJ_SKSTICK1 = 0xF, + OBJ_SKSTICK2 = 0x10, + OBJ_SKSTICK3 = 0x11, + OBJ_SKSTICK4 = 0x12, + OBJ_SKSTICK5 = 0x13, + OBJ_CRUX1 = 0x14, + OBJ_CRUX2 = 0x15, + OBJ_CRUX3 = 0x16, + OBJ_STAND = 0x17, + OBJ_ANGEL = 0x18, + OBJ_BOOK2L = 0x19, + OBJ_BCROSS = 0x1A, + OBJ_NUDEW2R = 0x1B, + OBJ_SWITCHSKL = 0x1C, + OBJ_TNUDEM1 = 0x1D, + OBJ_TNUDEM2 = 0x1E, + OBJ_TNUDEM3 = 0x1F, + OBJ_TNUDEM4 = 0x20, + OBJ_TNUDEW1 = 0x21, + OBJ_TNUDEW2 = 0x22, + OBJ_TNUDEW3 = 0x23, + OBJ_TORTURE1 = 0x24, + OBJ_TORTURE2 = 0x25, + OBJ_TORTURE3 = 0x26, + OBJ_TORTURE4 = 0x27, + OBJ_TORTURE5 = 0x28, + OBJ_BOOK2R = 0x29, + OBJ_L2LDOOR = 0x2A, + OBJ_L2RDOOR = 0x2B, + OBJ_TORCHL = 0x2C, + OBJ_TORCHR = 0x2D, + OBJ_TORCHL2 = 0x2E, + OBJ_TORCHR2 = 0x2F, + OBJ_SARC = 0x30, + OBJ_FLAMEHOLE = 0x31, + OBJ_FLAMELVR = 0x32, + OBJ_WATER = 0x33, + OBJ_BOOKLVR = 0x34, + OBJ_TRAPL = 0x35, + OBJ_TRAPR = 0x36, + OBJ_BOOKSHELF = 0x37, + OBJ_WEAPRACK = 0x38, + OBJ_BARREL = 0x39, + OBJ_BARRELEX = 0x3A, + OBJ_SHRINEL = 0x3B, + OBJ_SHRINER = 0x3C, + OBJ_SKELBOOK = 0x3D, + OBJ_BOOKCASEL = 0x3E, + OBJ_BOOKCASER = 0x3F, + OBJ_BOOKSTAND = 0x40, + OBJ_BOOKCANDLE = 0x41, + OBJ_BLOODFTN = 0x42, + OBJ_DECAP = 0x43, + OBJ_TCHEST1 = 0x44, + OBJ_TCHEST2 = 0x45, + OBJ_TCHEST3 = 0x46, + OBJ_BLINDBOOK = 0x47, + OBJ_BLOODBOOK = 0x48, + OBJ_PEDISTAL = 0x49, + OBJ_L3LDOOR = 0x4A, + OBJ_L3RDOOR = 0x4B, + OBJ_PURIFYINGFTN = 0x4C, + OBJ_ARMORSTAND = 0x4D, + OBJ_ARMORSTANDN = 0x4E, + OBJ_GOATSHRINE = 0x4F, + OBJ_CAULDRON = 0x50, + OBJ_MURKYFTN = 0x51, + OBJ_TEARFTN = 0x52, + OBJ_ALTBOY = 0x53, + OBJ_MCIRCLE1 = 0x54, + OBJ_MCIRCLE2 = 0x55, + OBJ_STORYBOOK = 0x56, + OBJ_STORYCANDLE = 0x57, + OBJ_STEELTOME = 0x58, + OBJ_WARARMOR = 0x59, + OBJ_WARWEAP = 0x5A, + OBJ_TBCROSS = 0x5B, + OBJ_WEAPONRACK = 0x5C, + OBJ_WEAPONRACKN = 0x5D, + OBJ_MUSHPATCH = 0x5E, + OBJ_LAZSTAND = 0x5F, + OBJ_SLAINHERO = 0x60, + OBJ_SIGNCHEST = 0x61, + OBJ_NULL_98 = 0x62, }; -enum item_misc_id -{ - IMISC_NONE = 0x0, - IMISC_USEFIRST = 0x1, - IMISC_FULLHEAL = 0x2, - IMISC_HEAL = 0x3, - IMISC_OLDHEAL = 0x4, - IMISC_DEADHEAL = 0x5, - IMISC_MANA = 0x6, - IMISC_FULLMANA = 0x7, - IMISC_POTEXP = 0x8, /* add experience */ - IMISC_POTFORG = 0x9, /* remove experience */ - IMISC_ELIXSTR = 0xA, - IMISC_ELIXMAG = 0xB, - IMISC_ELIXDEX = 0xC, - IMISC_ELIXVIT = 0xD, - IMISC_ELIXWEAK = 0xE, /* double check with alpha */ - IMISC_ELIXDIS = 0xF, - IMISC_ELIXCLUM = 0x10, - IMISC_ELIXSICK = 0x11, - IMISC_REJUV = 0x12, - IMISC_FULLREJUV = 0x13, - IMISC_USELAST = 0x14, - IMISC_SCROLL = 0x15, - IMISC_SCROLLT = 0x16, - IMISC_STAFF = 0x17, - IMISC_BOOK = 0x18, - IMISC_RING = 0x19, - IMISC_AMULET = 0x1A, - IMISC_UNIQUE = 0x1B, - IMISC_HEAL_1C = 0x1C, - IMISC_OILFIRST = 0x1D, - IMISC_OILOF = 0x1E, /* oils are beta or hellfire only */ - IMISC_OILACC = 0x1F, - IMISC_OILMAST = 0x20, - IMISC_OILSHARP = 0x21, - IMISC_OILDEATH = 0x22, - IMISC_OILSKILL = 0x23, - IMISC_OILBSMTH = 0x24, - IMISC_OILFORT = 0x25, - IMISC_OILPERM = 0x26, - IMISC_OILHARD = 0x27, - IMISC_OILIMP = 0x28, - IMISC_OILLAST = 0x29, - IMISC_MAPOFDOOM = 0x2A, - IMISC_EAR = 0x2B, - IMISC_SPECELIX = 0x2C, - IMISC_INVALID = 0xFFFFFFFF, +enum item_misc_id { + IMISC_NONE = 0x0, + IMISC_USEFIRST = 0x1, + IMISC_FULLHEAL = 0x2, + IMISC_HEAL = 0x3, + IMISC_OLDHEAL = 0x4, + IMISC_DEADHEAL = 0x5, + IMISC_MANA = 0x6, + IMISC_FULLMANA = 0x7, + IMISC_POTEXP = 0x8, /* add experience */ + IMISC_POTFORG = 0x9, /* remove experience */ + IMISC_ELIXSTR = 0xA, + IMISC_ELIXMAG = 0xB, + IMISC_ELIXDEX = 0xC, + IMISC_ELIXVIT = 0xD, + IMISC_ELIXWEAK = 0xE, /* double check with alpha */ + IMISC_ELIXDIS = 0xF, + IMISC_ELIXCLUM = 0x10, + IMISC_ELIXSICK = 0x11, + IMISC_REJUV = 0x12, + IMISC_FULLREJUV = 0x13, + IMISC_USELAST = 0x14, + IMISC_SCROLL = 0x15, + IMISC_SCROLLT = 0x16, + IMISC_STAFF = 0x17, + IMISC_BOOK = 0x18, + IMISC_RING = 0x19, + IMISC_AMULET = 0x1A, + IMISC_UNIQUE = 0x1B, + IMISC_HEAL_1C = 0x1C, + IMISC_OILFIRST = 0x1D, + IMISC_OILOF = 0x1E, /* oils are beta or hellfire only */ + IMISC_OILACC = 0x1F, + IMISC_OILMAST = 0x20, + IMISC_OILSHARP = 0x21, + IMISC_OILDEATH = 0x22, + IMISC_OILSKILL = 0x23, + IMISC_OILBSMTH = 0x24, + IMISC_OILFORT = 0x25, + IMISC_OILPERM = 0x26, + IMISC_OILHARD = 0x27, + IMISC_OILIMP = 0x28, + IMISC_OILLAST = 0x29, + IMISC_MAPOFDOOM = 0x2A, + IMISC_EAR = 0x2B, + IMISC_SPECELIX = 0x2C, + IMISC_INVALID = 0xFFFFFFFF, }; -enum item_type -{ - ITYPE_MISC = 0x0, - ITYPE_SWORD = 0x1, - ITYPE_AXE = 0x2, - ITYPE_BOW = 0x3, - ITYPE_MACE = 0x4, - ITYPE_SHIELD = 0x5, - ITYPE_LARMOR = 0x6, - ITYPE_HELM = 0x7, - ITYPE_MARMOR = 0x8, - ITYPE_HARMOR = 0x9, - ITYPE_STAFF = 0xA, - ITYPE_GOLD = 0xB, - ITYPE_RING = 0xC, - ITYPE_AMULET = 0xD, - ITYPE_0E = 0xE, - ITYPE_NONE = 0xFFFFFFFF, +enum item_type { + ITYPE_MISC = 0x0, + ITYPE_SWORD = 0x1, + ITYPE_AXE = 0x2, + ITYPE_BOW = 0x3, + ITYPE_MACE = 0x4, + ITYPE_SHIELD = 0x5, + ITYPE_LARMOR = 0x6, + ITYPE_HELM = 0x7, + ITYPE_MARMOR = 0x8, + ITYPE_HARMOR = 0x9, + ITYPE_STAFF = 0xA, + ITYPE_GOLD = 0xB, + ITYPE_RING = 0xC, + ITYPE_AMULET = 0xD, + ITYPE_0E = 0xE, + ITYPE_NONE = 0xFFFFFFFF, }; -enum _item_indexes -{ - IDI_GOLD = 0x0, - IDI_WARRIOR = 0x1, - IDI_WARRSHLD = 0x2, - IDI_WARRCLUB = 0x3, - IDI_ROGUE = 0x4, - IDI_SORCEROR = 0x5, - IDI_CLEAVER = 0x6, - IDI_FIRSTQUEST = 0x6, - IDI_SKCROWN = 0x7, - IDI_INFRARING = 0x8, - IDI_ROCK = 0x9, - IDI_OPTAMULET = 0xA, - IDI_TRING = 0xB, - IDI_BANNER = 0xC, - IDI_HARCREST = 0xD, - IDI_STEELVEIL = 0xE, - IDI_GLDNELIX = 0xF, - IDI_ANVIL = 0x10, - IDI_MUSHROOM = 0x11, - IDI_BRAIN = 0x12, - IDI_FUNGALTM = 0x13, - IDI_SPECELIX = 0x14, - IDI_BLDSTONE = 0x15, - IDI_LASTQUEST = 0x16, - IDI_MAPOFDOOM = 0x16, - IDI_EAR = 0x17, - IDI_HEAL = 0x18, - IDI_MANA = 0x19, - IDI_IDENTIFY = 0x1A, - IDI_PORTAL = 0x1B, - IDI_ARMOFVAL = 0x1C, - IDI_FULLHEAL = 0x1D, - IDI_FULLMANA = 0x1E, - IDI_GRISWOLD = 0x1F, - IDI_LGTFORGE = 0x20, - IDI_LAZSTAFF = 0x21, - IDI_RESURRECT = 0x22, +enum _item_indexes { + IDI_GOLD = 0x0, + IDI_WARRIOR = 0x1, + IDI_WARRSHLD = 0x2, + IDI_WARRCLUB = 0x3, + IDI_ROGUE = 0x4, + IDI_SORCEROR = 0x5, + IDI_CLEAVER = 0x6, + IDI_FIRSTQUEST = 0x6, + IDI_SKCROWN = 0x7, + IDI_INFRARING = 0x8, + IDI_ROCK = 0x9, + IDI_OPTAMULET = 0xA, + IDI_TRING = 0xB, + IDI_BANNER = 0xC, + IDI_HARCREST = 0xD, + IDI_STEELVEIL = 0xE, + IDI_GLDNELIX = 0xF, + IDI_ANVIL = 0x10, + IDI_MUSHROOM = 0x11, + IDI_BRAIN = 0x12, + IDI_FUNGALTM = 0x13, + IDI_SPECELIX = 0x14, + IDI_BLDSTONE = 0x15, + IDI_LASTQUEST = 0x16, + IDI_MAPOFDOOM = 0x16, + IDI_EAR = 0x17, + IDI_HEAL = 0x18, + IDI_MANA = 0x19, + IDI_IDENTIFY = 0x1A, + IDI_PORTAL = 0x1B, + IDI_ARMOFVAL = 0x1C, + IDI_FULLHEAL = 0x1D, + IDI_FULLMANA = 0x1E, + IDI_GRISWOLD = 0x1F, + IDI_LGTFORGE = 0x20, + IDI_LAZSTAFF = 0x21, + IDI_RESURRECT = 0x22, }; -enum _setlevels -{ - //SL_BUTCHCHAMB = 0x0, - SL_SKELKING = 0x1, - SL_BONECHAMB = 0x2, - SL_MAZE = 0x3, - SL_POISONWATER = 0x4, - SL_VILEBETRAYER = 0x5, +enum _setlevels { + //SL_BUTCHCHAMB = 0x0, + SL_SKELKING = 0x1, + SL_BONECHAMB = 0x2, + SL_MAZE = 0x3, + SL_POISONWATER = 0x4, + SL_VILEBETRAYER = 0x5, }; -enum quest_id -{ - QTYPE_INFRA = 0x0, - QTYPE_BLKM = 0x1, - QTYPE_GARB = 0x2, - QTYPE_ZHAR = 0x3, - QTYPE_VEIL = 0x4, - QTYPE_MOD = 0x5, - QTYPE_BUTCH = 0x6, - QTYPE_BOL = 0x7, - QTYPE_BLIND = 0x8, - QTYPE_BLOOD = 0x9, - QTYPE_ANVIL = 0xA, - QTYPE_WARLRD = 0xB, - QTYPE_KING = 0xC, - QTYPE_PW = 0xD, - QTYPE_BONE = 0xE, - QTYPE_VB = 0xF, - QTYPE_INVALID = 0xFFFFFFFF, +enum quest_id { + QTYPE_INFRA = 0x0, + QTYPE_BLKM = 0x1, + QTYPE_GARB = 0x2, + QTYPE_ZHAR = 0x3, + QTYPE_VEIL = 0x4, + QTYPE_MOD = 0x5, + QTYPE_BUTCH = 0x6, + QTYPE_BOL = 0x7, + QTYPE_BLIND = 0x8, + QTYPE_BLOOD = 0x9, + QTYPE_ANVIL = 0xA, + QTYPE_WARLRD = 0xB, + QTYPE_KING = 0xC, + QTYPE_PW = 0xD, + QTYPE_BONE = 0xE, + QTYPE_VB = 0xF, + QTYPE_INVALID = 0xFFFFFFFF, }; -enum quest_mush_state -{ - QS_INIT = 0, - QS_TOMESPAWNED = 1, - QS_TOMEGIVEN = 2, - QS_MUSHSPAWNED = 3, - QS_MUSHPICKED = 4, - QS_MUSHGIVEN = 5, - QS_BRAINSPAWNED = 6, - QS_BRAINGIVEN = 7 +enum quest_mush_state { + QS_INIT = 0, + QS_TOMESPAWNED = 1, + QS_TOMEGIVEN = 2, + QS_MUSHSPAWNED = 3, + QS_MUSHPICKED = 4, + QS_MUSHGIVEN = 5, + QS_BRAINSPAWNED = 6, + QS_BRAINGIVEN = 7 }; -enum talk_id -{ - STORE_NONE = 0x0, - STORE_SMITH = 0x1, - STORE_SBUY = 0x2, - STORE_SSELL = 0x3, - STORE_SREPAIR = 0x4, - STORE_WITCH = 0x5, - STORE_WBUY = 0x6, - STORE_WSELL = 0x7, - STORE_WRECHARGE = 0x8, - STORE_NOMONEY = 0x9, - STORE_NOROOM = 0xA, - STORE_CONFIRM = 0xB, - STORE_BOY = 0xC, - STORE_BBOY = 0xD, - STORE_HEALER = 0xE, - STORE_STORY = 0xF, - STORE_HBUY = 0x10, - STORE_SIDENTIFY = 0x11, - STORE_SPBUY = 0x12, - STORE_GOSSIP = 0x13, - STORE_IDSHOW = 0x14, - STORE_TAVERN = 0x15, - STORE_DRUNK = 0x16, - STORE_BARMAID = 0x17, +enum talk_id { + STORE_NONE = 0x0, + STORE_SMITH = 0x1, + STORE_SBUY = 0x2, + STORE_SSELL = 0x3, + STORE_SREPAIR = 0x4, + STORE_WITCH = 0x5, + STORE_WBUY = 0x6, + STORE_WSELL = 0x7, + STORE_WRECHARGE = 0x8, + STORE_NOMONEY = 0x9, + STORE_NOROOM = 0xA, + STORE_CONFIRM = 0xB, + STORE_BOY = 0xC, + STORE_BBOY = 0xD, + STORE_HEALER = 0xE, + STORE_STORY = 0xF, + STORE_HBUY = 0x10, + STORE_SIDENTIFY = 0x11, + STORE_SPBUY = 0x12, + STORE_GOSSIP = 0x13, + STORE_IDSHOW = 0x14, + STORE_TAVERN = 0x15, + STORE_DRUNK = 0x16, + STORE_BARMAID = 0x17, }; -enum _unique_items -{ - UITEM_CLEAVER = 0x0, - UITEM_SKCROWN = 0x1, - UITEM_INFRARING = 0x2, - UITEM_OPTAMULET = 0x3, - UITEM_TRING = 0x4, - UITEM_HARCREST = 0x5, - UITEM_STEELVEIL = 0x6, - UITEM_ARMOFVAL = 0x7, - UITEM_GRISWOLD = 0x8, - UITEM_LGTFORGE = 0x9, - UITEM_RIFTBOW = 0xA, - UITEM_NEEDLER = 0xB, - UITEM_CELESTBOW = 0xC, - UITEM_DEADLYHUNT = 0xD, - UITEM_BOWOFDEAD = 0xE, - UITEM_BLKOAKBOW = 0xF, - UITEM_FLAMEDART = 0x10, - UITEM_FLESHSTING = 0x11, - UITEM_WINDFORCE = 0x12, - UITEM_EAGLEHORN = 0x13, - UITEM_GONNAGALDIRK = 0x14, - UITEM_DEFENDER = 0x15, - UITEM_GRYPHONCLAW = 0x16, - UITEM_BLACKRAZOR = 0x17, - UITEM_GIBBOUSMOON = 0x18, - UITEM_ICESHANK = 0x19, - UITEM_EXECUTIONER = 0x1A, - UITEM_BONESAW = 0x1B, - UITEM_SHADHAWK = 0x1C, - UITEM_WIZSPIKE = 0x1D, - UITEM_LGTSABRE = 0x1E, - UITEM_FALCONTALON = 0x1F, - UITEM_INFERNO = 0x20, - UITEM_DOOMBRINGER = 0x21, - UITEM_GRIZZLY = 0x22, - UITEM_GRANDFATHER = 0x23, - UITEM_MANGLER = 0x24, - UITEM_SHARPBEAK = 0x25, - UITEM_BLOODLSLAYER = 0x26, - UITEM_CELESTAXE = 0x27, - UITEM_WICKEDAXE = 0x28, - UITEM_STONECLEAV = 0x29, - UITEM_AGUHATCHET = 0x2A, - UITEM_HELLSLAYER = 0x2B, - UITEM_MESSERREAVER = 0x2C, - UITEM_CRACKRUST = 0x2D, - UITEM_JHOLMHAMM = 0x2E, - UITEM_CIVERBS = 0x2F, - UITEM_CELESTSTAR = 0x30, - UITEM_BARANSTAR = 0x31, - UITEM_GNARLROOT = 0x32, - UITEM_CRANBASH = 0x33, - UITEM_SCHAEFHAMM = 0x34, - UITEM_DREAMFLANGE = 0x35, - UITEM_STAFFOFSHAD = 0x36, - UITEM_IMMOLATOR = 0x37, - UITEM_STORMSPIRE = 0x38, - UITEM_GLEAMSONG = 0x39, - UITEM_THUNDERCALL = 0x3A, - UITEM_PROTECTOR = 0x3B, - UITEM_NAJPUZZLE = 0x3C, - UITEM_MINDCRY = 0x3D, - UITEM_RODOFONAN = 0x3E, - UITEM_SPIRITSHELM = 0x3F, - UITEM_THINKINGCAP = 0x40, - UITEM_OVERLORDHELM = 0x41, - UITEM_FOOLSCREST = 0x42, - UITEM_GOTTERDAM = 0x43, - UITEM_ROYCIRCLET = 0x44, - UITEM_TORNFLESH = 0x45, - UITEM_GLADBANE = 0x46, - UITEM_RAINCLOAK = 0x47, - UITEM_LEATHAUT = 0x48, - UITEM_WISDWRAP = 0x49, - UITEM_SPARKMAIL = 0x4A, - UITEM_SCAVCARAP = 0x4B, - UITEM_NIGHTSCAPE = 0x4C, - UITEM_NAJPLATE = 0x4D, - UITEM_DEMONSPIKE = 0x4E, - UITEM_DEFLECTOR = 0x4F, - UITEM_SKULLSHLD = 0x50, - UITEM_DRAGONBRCH = 0x51, - UITEM_BLKOAKSHLD = 0x52, - UITEM_HOLYDEF = 0x53, - UITEM_STORMSHLD = 0x54, - UITEM_BRAMBLE = 0x55, - UITEM_REGHA = 0x56, - UITEM_BLEEDER = 0x57, - UITEM_CONSTRICT = 0x58, - UITEM_ENGAGE = 0x59, - UITEM_INVALID = 0x5A, +enum _unique_items { + UITEM_CLEAVER = 0x0, + UITEM_SKCROWN = 0x1, + UITEM_INFRARING = 0x2, + UITEM_OPTAMULET = 0x3, + UITEM_TRING = 0x4, + UITEM_HARCREST = 0x5, + UITEM_STEELVEIL = 0x6, + UITEM_ARMOFVAL = 0x7, + UITEM_GRISWOLD = 0x8, + UITEM_LGTFORGE = 0x9, + UITEM_RIFTBOW = 0xA, + UITEM_NEEDLER = 0xB, + UITEM_CELESTBOW = 0xC, + UITEM_DEADLYHUNT = 0xD, + UITEM_BOWOFDEAD = 0xE, + UITEM_BLKOAKBOW = 0xF, + UITEM_FLAMEDART = 0x10, + UITEM_FLESHSTING = 0x11, + UITEM_WINDFORCE = 0x12, + UITEM_EAGLEHORN = 0x13, + UITEM_GONNAGALDIRK = 0x14, + UITEM_DEFENDER = 0x15, + UITEM_GRYPHONCLAW = 0x16, + UITEM_BLACKRAZOR = 0x17, + UITEM_GIBBOUSMOON = 0x18, + UITEM_ICESHANK = 0x19, + UITEM_EXECUTIONER = 0x1A, + UITEM_BONESAW = 0x1B, + UITEM_SHADHAWK = 0x1C, + UITEM_WIZSPIKE = 0x1D, + UITEM_LGTSABRE = 0x1E, + UITEM_FALCONTALON = 0x1F, + UITEM_INFERNO = 0x20, + UITEM_DOOMBRINGER = 0x21, + UITEM_GRIZZLY = 0x22, + UITEM_GRANDFATHER = 0x23, + UITEM_MANGLER = 0x24, + UITEM_SHARPBEAK = 0x25, + UITEM_BLOODLSLAYER = 0x26, + UITEM_CELESTAXE = 0x27, + UITEM_WICKEDAXE = 0x28, + UITEM_STONECLEAV = 0x29, + UITEM_AGUHATCHET = 0x2A, + UITEM_HELLSLAYER = 0x2B, + UITEM_MESSERREAVER = 0x2C, + UITEM_CRACKRUST = 0x2D, + UITEM_JHOLMHAMM = 0x2E, + UITEM_CIVERBS = 0x2F, + UITEM_CELESTSTAR = 0x30, + UITEM_BARANSTAR = 0x31, + UITEM_GNARLROOT = 0x32, + UITEM_CRANBASH = 0x33, + UITEM_SCHAEFHAMM = 0x34, + UITEM_DREAMFLANGE = 0x35, + UITEM_STAFFOFSHAD = 0x36, + UITEM_IMMOLATOR = 0x37, + UITEM_STORMSPIRE = 0x38, + UITEM_GLEAMSONG = 0x39, + UITEM_THUNDERCALL = 0x3A, + UITEM_PROTECTOR = 0x3B, + UITEM_NAJPUZZLE = 0x3C, + UITEM_MINDCRY = 0x3D, + UITEM_RODOFONAN = 0x3E, + UITEM_SPIRITSHELM = 0x3F, + UITEM_THINKINGCAP = 0x40, + UITEM_OVERLORDHELM = 0x41, + UITEM_FOOLSCREST = 0x42, + UITEM_GOTTERDAM = 0x43, + UITEM_ROYCIRCLET = 0x44, + UITEM_TORNFLESH = 0x45, + UITEM_GLADBANE = 0x46, + UITEM_RAINCLOAK = 0x47, + UITEM_LEATHAUT = 0x48, + UITEM_WISDWRAP = 0x49, + UITEM_SPARKMAIL = 0x4A, + UITEM_SCAVCARAP = 0x4B, + UITEM_NIGHTSCAPE = 0x4C, + UITEM_NAJPLATE = 0x4D, + UITEM_DEMONSPIKE = 0x4E, + UITEM_DEFLECTOR = 0x4F, + UITEM_SKULLSHLD = 0x50, + UITEM_DRAGONBRCH = 0x51, + UITEM_BLKOAKSHLD = 0x52, + UITEM_HOLYDEF = 0x53, + UITEM_STORMSHLD = 0x54, + UITEM_BRAMBLE = 0x55, + UITEM_REGHA = 0x56, + UITEM_BLEEDER = 0x57, + UITEM_CONSTRICT = 0x58, + UITEM_ENGAGE = 0x59, + UITEM_INVALID = 0x5A, }; -enum plr_class -{ - PC_WARRIOR = 0x0, - PC_ROGUE = 0x1, - PC_SORCERER = 0x2, - NUM_CLASSES +enum plr_class { + PC_WARRIOR = 0x0, + PC_ROGUE = 0x1, + PC_SORCERER = 0x2, + NUM_CLASSES }; -enum _ui_classes -{ - UI_WARRIOR = 0x0, - UI_ROGUE = 0x1, - UI_SORCERER = 0x2, - UI_NUM_CLASSES = 0x3, +enum _ui_classes { + UI_WARRIOR = 0x0, + UI_ROGUE = 0x1, + UI_SORCERER = 0x2, + UI_NUM_CLASSES = 0x3, }; -enum _walk_path -{ - WALK_NE = 0x1, - WALK_NW = 0x2, - WALK_SE = 0x3, - WALK_SW = 0x4, - WALK_N = 0x5, - WALK_E = 0x6, - WALK_S = 0x7, - WALK_W = 0x8, - WALK_NONE = -1, +enum _walk_path { + WALK_NE = 0x1, + WALK_NW = 0x2, + WALK_SE = 0x3, + WALK_SW = 0x4, + WALK_N = 0x5, + WALK_E = 0x6, + WALK_S = 0x7, + WALK_W = 0x8, + WALK_NONE = -1, }; enum item_class { - ICLASS_NONE = 0, - ICLASS_WEAPON = 1, - ICLASS_ARMOR = 2, - ICLASS_MISC = 3, - ICLASS_GOLD = 4, - ICLASS_QUEST = 5, + ICLASS_NONE = 0, + ICLASS_WEAPON = 1, + ICLASS_ARMOR = 2, + ICLASS_MISC = 3, + ICLASS_GOLD = 4, + ICLASS_QUEST = 5, }; enum item_drop_rate { - IDROP_NEVER = 0, - IDROP_REGULAR = 1, - IDROP_DOUBLE = 2, + IDROP_NEVER = 0, + IDROP_REGULAR = 1, + IDROP_DOUBLE = 2, }; enum item_special_effect { - ISPL_NONE = 0x00000000, - ISPL_INFRAVISION = 0x00000001, - ISPL_RNDSTEALLIFE = 0x00000002, - ISPL_RNDARROWVEL = 0x00000004, - ISPL_FIRE_ARROWS = 0x00000008, - ISPL_FIREDAM = 0x00000010, - ISPL_LIGHTDAM = 0x00000020, - ISPL_DRAINLIFE = 0x00000040, - ISPL_UNKNOWN_1 = 0x00000080, - ISPL_NOHEALPLR = 0x00000100, - ISPL_UNKNOWN_2 = 0x00000200, - ISPL_UNKNOWN_3 = 0x00000400, - ISPL_KNOCKBACK = 0x00000800, - ISPL_NOHEALMON = 0x00001000, - ISPL_STEALMANA_3 = 0x00002000, - ISPL_STEALMANA_5 = 0x00004000, - ISPL_STEALLIFE_3 = 0x00008000, - ISPL_STEALLIFE_5 = 0x00010000, - ISPL_QUICKATTACK = 0x00020000, - ISPL_FASTATTACK = 0x00040000, - ISPL_FASTERATTACK = 0x00080000, - ISPL_FASTESTATTACK = 0x00100000, - ISPL_FASTRECOVER = 0x00200000, - ISPL_FASTERRECOVER = 0x00400000, - ISPL_FASTESTRECOVER = 0x00800000, - ISPL_FASTBLOCK = 0x01000000, - ISPL_LIGHT_ARROWS = 0x02000000, - ISPL_THORNS = 0x04000000, - ISPL_NOMANA = 0x08000000, - ISPL_ABSHALFTRAP = 0x10000000, - ISPL_UNKNOWN_4 = 0x20000000, - ISPL_3XDAMVDEM = 0x40000000, - ISPL_ALLRESZERO = 0x80000000, + ISPL_NONE = 0x00000000, + ISPL_INFRAVISION = 0x00000001, + ISPL_RNDSTEALLIFE = 0x00000002, + ISPL_RNDARROWVEL = 0x00000004, + ISPL_FIRE_ARROWS = 0x00000008, + ISPL_FIREDAM = 0x00000010, + ISPL_LIGHTDAM = 0x00000020, + ISPL_DRAINLIFE = 0x00000040, + ISPL_UNKNOWN_1 = 0x00000080, + ISPL_NOHEALPLR = 0x00000100, + ISPL_UNKNOWN_2 = 0x00000200, + ISPL_UNKNOWN_3 = 0x00000400, + ISPL_KNOCKBACK = 0x00000800, + ISPL_NOHEALMON = 0x00001000, + ISPL_STEALMANA_3 = 0x00002000, + ISPL_STEALMANA_5 = 0x00004000, + ISPL_STEALLIFE_3 = 0x00008000, + ISPL_STEALLIFE_5 = 0x00010000, + ISPL_QUICKATTACK = 0x00020000, + ISPL_FASTATTACK = 0x00040000, + ISPL_FASTERATTACK = 0x00080000, + ISPL_FASTESTATTACK = 0x00100000, + ISPL_FASTRECOVER = 0x00200000, + ISPL_FASTERRECOVER = 0x00400000, + ISPL_FASTESTRECOVER = 0x00800000, + ISPL_FASTBLOCK = 0x01000000, + ISPL_LIGHT_ARROWS = 0x02000000, + ISPL_THORNS = 0x04000000, + ISPL_NOMANA = 0x08000000, + ISPL_ABSHALFTRAP = 0x10000000, + ISPL_UNKNOWN_4 = 0x20000000, + ISPL_3XDAMVDEM = 0x40000000, + ISPL_ALLRESZERO = 0x80000000, }; // Logical equipment locations enum inv_body_loc { - INVLOC_HEAD = 0, - INVLOC_RING_LEFT = 1, - INVLOC_RING_RIGHT = 2, - INVLOC_AMULET = 3, - INVLOC_HAND_LEFT = 4, - INVLOC_HAND_RIGHT = 5, - INVLOC_CHEST = 6, - NUM_INVLOC, + INVLOC_HEAD = 0, + INVLOC_RING_LEFT = 1, + INVLOC_RING_RIGHT = 2, + INVLOC_AMULET = 3, + INVLOC_HAND_LEFT = 4, + INVLOC_HAND_RIGHT = 5, + INVLOC_CHEST = 6, + NUM_INVLOC, }; enum inv_item { - INVITEM_HEAD = 0, - INVITEM_RING_LEFT = 1, - INVITEM_RING_RIGHT = 2, - INVITEM_AMULET = 3, - INVITEM_HAND_LEFT = 4, - INVITEM_HAND_RIGHT = 5, - INVITEM_CHEST = 6, - INVITEM_INV_FIRST = 7, - INVITEM_INV_LAST = 46, - INVITEM_BELT_FIRST = 47, - INVITEM_BELT_LAST = 54, - NUM_INVELEM + INVITEM_HEAD = 0, + INVITEM_RING_LEFT = 1, + INVITEM_RING_RIGHT = 2, + INVITEM_AMULET = 3, + INVITEM_HAND_LEFT = 4, + INVITEM_HAND_RIGHT = 5, + INVITEM_CHEST = 6, + INVITEM_INV_FIRST = 7, + INVITEM_INV_LAST = 46, + INVITEM_BELT_FIRST = 47, + INVITEM_BELT_LAST = 54, + NUM_INVELEM }; // identifiers for each of the inventory squares // see https://github.com/sanctuary/graphics/blob/master/inventory.png enum inv_xy_slot { - SLOTXY_HEAD_FIRST = 0, - SLOTXY_HEAD_LAST = 3, - SLOTXY_RING_LEFT = 4, - SLOTXY_RING_RIGHT = 5, - SLOTXY_AMULET = 6, - SLOTXY_HAND_LEFT_FIRST = 7, - SLOTXY_HAND_LEFT_LAST = 12, - SLOTXY_HAND_RIGHT_FIRST = 13, - SLOTXY_HAND_RIGHT_LAST = 18, - SLOTXY_CHEST_FIRST = 19, - SLOTXY_CHEST_LAST = 24, + SLOTXY_HEAD_FIRST = 0, + SLOTXY_HEAD_LAST = 3, + SLOTXY_RING_LEFT = 4, + SLOTXY_RING_RIGHT = 5, + SLOTXY_AMULET = 6, + SLOTXY_HAND_LEFT_FIRST = 7, + SLOTXY_HAND_LEFT_LAST = 12, + SLOTXY_HAND_RIGHT_FIRST = 13, + SLOTXY_HAND_RIGHT_LAST = 18, + SLOTXY_CHEST_FIRST = 19, + SLOTXY_CHEST_LAST = 24, - // regular inventory - SLOTXY_INV_FIRST = 25, - SLOTXY_INV_LAST = 64, + // regular inventory + SLOTXY_INV_FIRST = 25, + SLOTXY_INV_LAST = 64, - // belt items - SLOTXY_BELT_FIRST = 65, - SLOTXY_BELT_LAST = 72, - NUM_XY_SLOTS = 73 + // belt items + SLOTXY_BELT_FIRST = 65, + SLOTXY_BELT_LAST = 72, + NUM_XY_SLOTS = 73 }; -enum player_graphic -{ - PFILE_STAND = 1 << 0, - PFILE_WALK = 1 << 1, - PFILE_ATTACK = 1 << 2, - PFILE_HIT = 1 << 3, - PFILE_LIGHTNING = 1 << 4, - PFILE_FIRE = 1 << 5, - PFILE_MAGIC = 1 << 6, - PFILE_DEATH = 1 << 7, - PFILE_BLOCK = 1 << 8, - // everything except PFILE_DEATH - // 0b1_0111_1111 - PFILE_NONDEATH = 0x17F +enum player_graphic { + PFILE_STAND = 1 << 0, + PFILE_WALK = 1 << 1, + PFILE_ATTACK = 1 << 2, + PFILE_HIT = 1 << 3, + PFILE_LIGHTNING = 1 << 4, + PFILE_FIRE = 1 << 5, + PFILE_MAGIC = 1 << 6, + PFILE_DEATH = 1 << 7, + PFILE_BLOCK = 1 << 8, + // everything except PFILE_DEATH + // 0b1_0111_1111 + PFILE_NONDEATH = 0x17F }; enum shrine_type { - SHRINE_MYSTERIOUS = 0, - SHRINE_HIDDEN = 1, - SHRINE_GLOOMY = 2, - SHRINE_WEIRD = 3, - SHRINE_MAGICAL = 4, - SHRINE_STONE = 5, - SHRINE_RELIGIOUS = 6, - SHRINE_ENCHANTED = 7, - SHRINE_THAUMATURGIC = 8, - SHRINE_FASCINATING = 9, - SHRINE_CRYPTIC = 10, - SHRINE_MAGICAL2 = 11, - SHRINE_ELDRITCH = 12, - SHRINE_EERIE = 13, - SHRINE_DIVINE = 14, - SHRINE_HOLY = 15, - SHRINE_SACRED = 16, - SHRINE_SPIRITUAL = 17, - SHRINE_SPOOKY = 18, - SHRINE_ABANDONED = 19, - SHRINE_CREEPY = 20, - SHRINE_QUIET = 21, - SHRINE_SECLUDED = 22, - SHRINE_ORNATE = 23, - SHRINE_GLIMMERING = 24, - SHRINE_TAINTED = 25, - NUM_SHRINETYPE + SHRINE_MYSTERIOUS = 0, + SHRINE_HIDDEN = 1, + SHRINE_GLOOMY = 2, + SHRINE_WEIRD = 3, + SHRINE_MAGICAL = 4, + SHRINE_STONE = 5, + SHRINE_RELIGIOUS = 6, + SHRINE_ENCHANTED = 7, + SHRINE_THAUMATURGIC = 8, + SHRINE_FASCINATING = 9, + SHRINE_CRYPTIC = 10, + SHRINE_MAGICAL2 = 11, + SHRINE_ELDRITCH = 12, + SHRINE_EERIE = 13, + SHRINE_DIVINE = 14, + SHRINE_HOLY = 15, + SHRINE_SACRED = 16, + SHRINE_SPIRITUAL = 17, + SHRINE_SPOOKY = 18, + SHRINE_ABANDONED = 19, + SHRINE_CREEPY = 20, + SHRINE_QUIET = 21, + SHRINE_SECLUDED = 22, + SHRINE_ORNATE = 23, + SHRINE_GLIMMERING = 24, + SHRINE_TAINTED = 25, + NUM_SHRINETYPE }; enum action_id { - ACTION_NONE = -1, - ACTION_ATTACK = 9, - ACTION_RATTACK = 10, - ACTION_SPELL = 12, - ACTION_OPERATE = 13, - ACTION_DISARM = 14, - ACTION_PICKUPITEM = 15, // put item in hand (inventory screen open) - ACTION_PICKUPAITEM = 16, // put item in inventory - ACTION_TALK = 17, - ACTION_OPERATETK = 18, // operate via telekinesis - ACTION_ATTACKMON = 20, - ACTION_ATTACKPLR = 21, - ACTION_RATTACKMON = 22, - ACTION_RATTACKPLR = 23, - ACTION_SPELLMON = 24, - ACTION_SPELLPLR = 25, - ACTION_SPELLWALL = 26, + ACTION_NONE = -1, + ACTION_ATTACK = 9, + ACTION_RATTACK = 10, + ACTION_SPELL = 12, + ACTION_OPERATE = 13, + ACTION_DISARM = 14, + ACTION_PICKUPITEM = 15, // put item in hand (inventory screen open) + ACTION_PICKUPAITEM = 16, // put item in inventory + ACTION_TALK = 17, + ACTION_OPERATETK = 18, // operate via telekinesis + ACTION_ATTACKMON = 20, + ACTION_ATTACKPLR = 21, + ACTION_RATTACKMON = 22, + ACTION_RATTACKPLR = 23, + ACTION_SPELLMON = 24, + ACTION_SPELLPLR = 25, + ACTION_SPELLWALL = 26, }; diff --git a/structs.h b/structs.h index 70941f98f..929fbe5a5 100644 --- a/structs.h +++ b/structs.h @@ -2,371 +2,364 @@ // items ////////////////////////////////////////////////// -struct PLStruct -{ - const char *PLName; - char PLPower; - int PLParam1; - int PLParam2; - int PLMinLvl; - int PLIType; - int PLGOE; - int PLDouble; - int PLOk; - int PLMinVal; - int PLMaxVal; - int PLMultVal; -}; - -struct UItemStruct -{ - char *UIName; - char UIItemId; - char UIMinLvl; - char UINumPL; - int UIValue; - char UIPower1; - int UIParam1; - int UIParam2; - char UIPower2; - int UIParam3; - int UIParam4; - char UIPower3; - int UIParam5; - int UIParam6; - char UIPower4; - int UIParam7; - int UIParam8; - char UIPower5; - int UIParam9; - int UIParam10; - char UIPower6; - int UIParam11; - int UIParam12; -}; - -struct ItemDataStruct -{ - int iRnd; - char iClass; - char iLoc; - int iCurs; - char itype; - char iItemId; - char *iName; - char *iSName; - int iMinMLvl; - int iDurability; - int iMinDam; - int iMaxDam; - int iMinAC; - int iMaxAC; - char iMinStr; - char iMinMag; - char iMinDex; - // item_special_effect - int iFlags; - // item_misc_id - int iMiscId; - // spell_id - int iSpell; - int iUsable; - int iValue; - int iMaxValue; -}; - -struct ItemGetRecordStruct -{ - int nSeed; - unsigned short wCI; - int nIndex; - int dwTimestamp; -}; - -struct ItemStruct -{ - int _iSeed; - unsigned short _iCreateInfo; - int _itype; - int _ix; - int _iy; - int _iAnimFlag; - unsigned char *_iAnimData; // PSX name -> ItemFrame - int _iAnimLen; - int _iAnimFrame; - int _iAnimWidth; - int _iAnimWidth2; // width 2? - int _isin; // set when item is flagged for deletion, deprecated in 1.02 - char _iSelFlag; - int _iPostDraw; - BOOL _iIdentified; - char _iMagical; - char _iName[64]; - char _iIName[64]; - char _iLoc; - // item_class enum - char _iClass; - int _iCurs; - int _ivalue; - int _iIvalue; - int _iMinDam; - int _iMaxDam; - int _iAC; - // item_special_effect - int _iFlags; - // item_misc_id - int _iMiscId; - // spell_id - int _iSpell; - int _iCharges; - int _iMaxCharges; - int _iDurability; - int _iMaxDur; - int _iPLDam; - int _iPLToHit; - int _iPLAC; - int _iPLStr; - int _iPLMag; - int _iPLDex; - int _iPLVit; - int _iPLFR; - int _iPLLR; - int _iPLMR; - int _iPLMana; - int _iPLHP; - int _iPLDamMod; - int _iPLGetHit; - int _iPLLight; - char _iSplLvlAdd; - char _iRequest; - int _iUid; - int _iFMinDam; - int _iFMaxDam; - int _iLMinDam; - int _iLMaxDam; - int _iPLEnAc; - char _iPrePower; - char _iSufPower; - int _iVAdd1; - int _iVMult1; - int _iVAdd2; - int _iVMult2; - char _iMinStr; - unsigned char _iMinMag; - char _iMinDex; - BOOL _iStatFlag; - int IDidx; - int offs016C; // _oldlight or _iInvalid +struct PLStruct { + const char *PLName; + char PLPower; + int PLParam1; + int PLParam2; + int PLMinLvl; + int PLIType; + int PLGOE; + int PLDouble; + int PLOk; + int PLMinVal; + int PLMaxVal; + int PLMultVal; +}; + +struct UItemStruct { + char *UIName; + char UIItemId; + char UIMinLvl; + char UINumPL; + int UIValue; + char UIPower1; + int UIParam1; + int UIParam2; + char UIPower2; + int UIParam3; + int UIParam4; + char UIPower3; + int UIParam5; + int UIParam6; + char UIPower4; + int UIParam7; + int UIParam8; + char UIPower5; + int UIParam9; + int UIParam10; + char UIPower6; + int UIParam11; + int UIParam12; +}; + +struct ItemDataStruct { + int iRnd; + char iClass; + char iLoc; + int iCurs; + char itype; + char iItemId; + char *iName; + char *iSName; + int iMinMLvl; + int iDurability; + int iMinDam; + int iMaxDam; + int iMinAC; + int iMaxAC; + char iMinStr; + char iMinMag; + char iMinDex; + // item_special_effect + int iFlags; + // item_misc_id + int iMiscId; + // spell_id + int iSpell; + int iUsable; + int iValue; + int iMaxValue; +}; + +struct ItemGetRecordStruct { + int nSeed; + unsigned short wCI; + int nIndex; + int dwTimestamp; +}; + +struct ItemStruct { + int _iSeed; + unsigned short _iCreateInfo; + int _itype; + int _ix; + int _iy; + int _iAnimFlag; + unsigned char *_iAnimData; // PSX name -> ItemFrame + int _iAnimLen; + int _iAnimFrame; + int _iAnimWidth; + int _iAnimWidth2; // width 2? + int _isin; // set when item is flagged for deletion, deprecated in 1.02 + char _iSelFlag; + int _iPostDraw; + BOOL _iIdentified; + char _iMagical; + char _iName[64]; + char _iIName[64]; + char _iLoc; + // item_class enum + char _iClass; + int _iCurs; + int _ivalue; + int _iIvalue; + int _iMinDam; + int _iMaxDam; + int _iAC; + // item_special_effect + int _iFlags; + // item_misc_id + int _iMiscId; + // spell_id + int _iSpell; + int _iCharges; + int _iMaxCharges; + int _iDurability; + int _iMaxDur; + int _iPLDam; + int _iPLToHit; + int _iPLAC; + int _iPLStr; + int _iPLMag; + int _iPLDex; + int _iPLVit; + int _iPLFR; + int _iPLLR; + int _iPLMR; + int _iPLMana; + int _iPLHP; + int _iPLDamMod; + int _iPLGetHit; + int _iPLLight; + char _iSplLvlAdd; + char _iRequest; + int _iUid; + int _iFMinDam; + int _iFMaxDam; + int _iLMinDam; + int _iLMaxDam; + int _iPLEnAc; + char _iPrePower; + char _iSufPower; + int _iVAdd1; + int _iVMult1; + int _iVAdd2; + int _iVMult2; + char _iMinStr; + unsigned char _iMinMag; + char _iMinDex; + BOOL _iStatFlag; + int IDidx; + int offs016C; // _oldlight or _iInvalid }; ////////////////////////////////////////////////// // player ////////////////////////////////////////////////// -struct PlayerStruct -{ - int _pmode; - char walkpath[25]; - unsigned char plractive; - int destAction; - int destParam1; - int destParam2; - int destParam3; - int destParam4; - int plrlevel; - int WorldX; - int WorldY; - int _px; - int _py; - int _ptargx; - int _ptargy; - int _pownerx; - int _pownery; - int _poldx; - int _poldy; - int _pxoff; - int _pyoff; - int _pxvel; - int _pyvel; - int _pdir; - int _nextdir; - int _pgfxnum; - unsigned char *_pAnimData; - int _pAnimDelay; - int _pAnimCnt; - int _pAnimLen; - int _pAnimFrame; - int _pAnimWidth; - int _pAnimWidth2; - int _peflag; - int _plid; - int _pvid; - int _pSpell; - char _pSplType; - char _pSplFrom; - int _pTSpell; - int _pTSplType; - int _pRSpell; - // enum spell_type - char _pRSplType; - int _pSBkSpell; - char _pSBkSplType; - char _pSplLvl[64]; - union { - unsigned __int64 _pMemSpells64; - int _pMemSpells[2]; - }; - union { - unsigned __int64 _pAblSpells64; - int _pAblSpells[2]; - }; - union { - unsigned __int64 _pScrlSpells64; - int _pScrlSpells[2]; - }; - UCHAR _pSpellFlags; - int _pSplHotKey[4]; - char _pSplTHotKey[4]; - int _pwtype; - unsigned char _pBlockFlag; - unsigned char _pInvincible; - char _pLightRad; - unsigned char _pLvlChanging; - char _pName[32]; - // plr_class enum value. - // TODO: this could very well be `enum plr_class _pClass` - // since there are 3 bytes of alingment after this field. - // it could just be that the compiler optimized away all accesses to - // the higher bytes by using byte instructions, since all possible values - // of plr_class fit into one byte. - char _pClass; - int _pStrength; - int _pBaseStr; - int _pMagic; - int _pBaseMag; - int _pDexterity; - int _pBaseDex; - int _pVitality; - int _pBaseVit; - int _pStatPts; - int _pDamageMod; - int _pBaseToBlk; - int _pHPBase; - int _pMaxHPBase; - int _pHitPoints; - int _pMaxHP; - int _pHPPer; - int _pManaBase; - int _pMaxManaBase; - int _pMana; - int _pMaxMana; - int _pManaPer; - char _pLevel; - char _pMaxLvl; - int _pExperience; - int _pMaxExp; - int _pNextExper; - char _pArmorClass; - char _pMagResist; - char _pFireResist; - char _pLghtResist; - int _pGold; - int _pInfraFlag; - int _pVar1; - int _pVar2; - int _pVar3; - int _pVar4; - int _pVar5; - int _pVar6; - int _pVar7; - int _pVar8; - unsigned char _pLvlVisited[NUMLEVELS]; - unsigned char _pSLvlVisited[NUMLEVELS]; // only 10 used - int _pGFXLoad; - unsigned char *_pNAnim[8]; - int _pNFrames; - int _pNWidth; - unsigned char *_pWAnim[8]; - int _pWFrames; - int _pWWidth; - unsigned char *_pAAnim[8]; - int _pAFrames; - int _pAWidth; - int _pAFNum; - unsigned char *_pLAnim[8]; - unsigned char *_pFAnim[8]; - unsigned char *_pTAnim[8]; - int _pSFrames; - int _pSWidth; - int _pSFNum; - unsigned char *_pHAnim[8]; - int _pHFrames; - int _pHWidth; - unsigned char *_pDAnim[8]; - int _pDFrames; - int _pDWidth; - unsigned char *_pBAnim[8]; - int _pBFrames; - int _pBWidth; - ItemStruct InvBody[NUM_INVLOC]; - ItemStruct InvList[NUM_INV_GRID_ELEM]; - int _pNumInv; - char InvGrid[NUM_INV_GRID_ELEM]; - ItemStruct SpdList[MAXBELTITEMS]; - ItemStruct HoldItem; - int _pIMinDam; - int _pIMaxDam; - int _pIAC; - int _pIBonusDam; - int _pIBonusToHit; - int _pIBonusAC; - int _pIBonusDamMod; - union { - unsigned __int64 _pISpells64; - int _pISpells[2]; - }; - int _pIFlags; - int _pIGetHit; - char _pISplLvlAdd; - char _pISplCost; - int _pISplDur; - int _pIEnAc; - int _pIFMinDam; - int _pIFMaxDam; - int _pILMinDam; - int _pILMaxDam; - int _pOilType; - unsigned char pTownWarps; - unsigned char pDungMsgs; - unsigned char pLvlLoad; - unsigned char pBattleNet; - unsigned char pManaShield; - char bReserved[3]; - short wReserved[8]; - int pDiabloKillLevel; - int dwReserved[7]; - unsigned char *_pNData; - unsigned char *_pWData; - unsigned char *_pAData; - unsigned char *_pLData; - unsigned char *_pFData; - unsigned char *_pTData; - unsigned char *_pHData; - unsigned char *_pDData; - unsigned char *_pBData; - void *pReserved; +struct PlayerStruct { + int _pmode; + char walkpath[25]; + unsigned char plractive; + int destAction; + int destParam1; + int destParam2; + int destParam3; + int destParam4; + int plrlevel; + int WorldX; + int WorldY; + int _px; + int _py; + int _ptargx; + int _ptargy; + int _pownerx; + int _pownery; + int _poldx; + int _poldy; + int _pxoff; + int _pyoff; + int _pxvel; + int _pyvel; + int _pdir; + int _nextdir; + int _pgfxnum; + unsigned char *_pAnimData; + int _pAnimDelay; + int _pAnimCnt; + int _pAnimLen; + int _pAnimFrame; + int _pAnimWidth; + int _pAnimWidth2; + int _peflag; + int _plid; + int _pvid; + int _pSpell; + char _pSplType; + char _pSplFrom; + int _pTSpell; + int _pTSplType; + int _pRSpell; + // enum spell_type + char _pRSplType; + int _pSBkSpell; + char _pSBkSplType; + char _pSplLvl[64]; + union { + unsigned __int64 _pMemSpells64; + int _pMemSpells[2]; + }; + union { + unsigned __int64 _pAblSpells64; + int _pAblSpells[2]; + }; + union { + unsigned __int64 _pScrlSpells64; + int _pScrlSpells[2]; + }; + UCHAR _pSpellFlags; + int _pSplHotKey[4]; + char _pSplTHotKey[4]; + int _pwtype; + unsigned char _pBlockFlag; + unsigned char _pInvincible; + char _pLightRad; + unsigned char _pLvlChanging; + char _pName[32]; + // plr_class enum value. + // TODO: this could very well be `enum plr_class _pClass` + // since there are 3 bytes of alingment after this field. + // it could just be that the compiler optimized away all accesses to + // the higher bytes by using byte instructions, since all possible values + // of plr_class fit into one byte. + char _pClass; + int _pStrength; + int _pBaseStr; + int _pMagic; + int _pBaseMag; + int _pDexterity; + int _pBaseDex; + int _pVitality; + int _pBaseVit; + int _pStatPts; + int _pDamageMod; + int _pBaseToBlk; + int _pHPBase; + int _pMaxHPBase; + int _pHitPoints; + int _pMaxHP; + int _pHPPer; + int _pManaBase; + int _pMaxManaBase; + int _pMana; + int _pMaxMana; + int _pManaPer; + char _pLevel; + char _pMaxLvl; + int _pExperience; + int _pMaxExp; + int _pNextExper; + char _pArmorClass; + char _pMagResist; + char _pFireResist; + char _pLghtResist; + int _pGold; + int _pInfraFlag; + int _pVar1; + int _pVar2; + int _pVar3; + int _pVar4; + int _pVar5; + int _pVar6; + int _pVar7; + int _pVar8; + unsigned char _pLvlVisited[NUMLEVELS]; + unsigned char _pSLvlVisited[NUMLEVELS]; // only 10 used + int _pGFXLoad; + unsigned char *_pNAnim[8]; + int _pNFrames; + int _pNWidth; + unsigned char *_pWAnim[8]; + int _pWFrames; + int _pWWidth; + unsigned char *_pAAnim[8]; + int _pAFrames; + int _pAWidth; + int _pAFNum; + unsigned char *_pLAnim[8]; + unsigned char *_pFAnim[8]; + unsigned char *_pTAnim[8]; + int _pSFrames; + int _pSWidth; + int _pSFNum; + unsigned char *_pHAnim[8]; + int _pHFrames; + int _pHWidth; + unsigned char *_pDAnim[8]; + int _pDFrames; + int _pDWidth; + unsigned char *_pBAnim[8]; + int _pBFrames; + int _pBWidth; + ItemStruct InvBody[NUM_INVLOC]; + ItemStruct InvList[NUM_INV_GRID_ELEM]; + int _pNumInv; + char InvGrid[NUM_INV_GRID_ELEM]; + ItemStruct SpdList[MAXBELTITEMS]; + ItemStruct HoldItem; + int _pIMinDam; + int _pIMaxDam; + int _pIAC; + int _pIBonusDam; + int _pIBonusToHit; + int _pIBonusAC; + int _pIBonusDamMod; + union { + unsigned __int64 _pISpells64; + int _pISpells[2]; + }; + int _pIFlags; + int _pIGetHit; + char _pISplLvlAdd; + char _pISplCost; + int _pISplDur; + int _pIEnAc; + int _pIFMinDam; + int _pIFMaxDam; + int _pILMinDam; + int _pILMaxDam; + int _pOilType; + unsigned char pTownWarps; + unsigned char pDungMsgs; + unsigned char pLvlLoad; + unsigned char pBattleNet; + unsigned char pManaShield; + char bReserved[3]; + short wReserved[8]; + int pDiabloKillLevel; + int dwReserved[7]; + unsigned char *_pNData; + unsigned char *_pWData; + unsigned char *_pAData; + unsigned char *_pLData; + unsigned char *_pFData; + unsigned char *_pTData; + unsigned char *_pHData; + unsigned char *_pDData; + unsigned char *_pBData; + void *pReserved; }; ////////////////////////////////////////////////// // textdat ////////////////////////////////////////////////// -struct TextDataStruct -{ - char *txtstr; - int scrlltxt; - int txtspd; - int sfxnr; +struct TextDataStruct { + char *txtstr; + int scrlltxt; + int txtspd; + int sfxnr; }; ////////////////////////////////////////////////// @@ -376,107 +369,101 @@ struct TextDataStruct // TPDEF PTR FCN VOID MIADDPRC // TPDEF PTR FCN VOID MIPROC -struct MissileData -{ - unsigned char mName; - void (__fastcall *mAddProc)(int, int, int, int, int, int, int, int, int); - void (__fastcall *mProc)(int); - int mDraw; - unsigned char mType; - unsigned char mResist; - unsigned char mFileNum; - int mlSFX; - int miSFX; -}; - -struct MisFileData -{ - unsigned char mAnimName; - unsigned char mAnimFAmt; - char *mName; - int mFlags; - unsigned char *mAnimData[16]; - unsigned char mAnimDelay[16]; - unsigned char mAnimLen[16]; - int mAnimWidth[16]; - int mAnimWidth2[16]; -}; - -struct ChainStruct -{ - int idx; - int _mitype; - int _mirange; -}; - -struct MissileStruct -{ - int _mitype; - int _mix; - int _miy; - int _mixoff; - int _miyoff; - int _mixvel; - int _miyvel; - int _misx; - int _misy; - int _mitxoff; - int _mityoff; - int _mimfnum; - int _mispllvl; - int _miDelFlag; - int _miAnimType; - int _miAnimFlags; - unsigned char *_miAnimData; - int _miAnimDelay; - int _miAnimLen; - int _miAnimWidth; - int _miAnimWidth2; - int _miAnimCnt; - int _miAnimAdd; - int _miAnimFrame; - int _miDrawFlag; - int _miLightFlag; - int _miPreFlag; - int _miUniqTrans; - int _mirange; - int _misource; - int _micaster; - int _midam; - int _miHitFlag; - int _midist; - int _mlid; - int _mirnd; - int _miVar1; - int _miVar2; - int _miVar3; - int _miVar4; - int _miVar5; - int _miVar6; - int _miVar7; - int _miVar8; +struct MissileData { + unsigned char mName; + void(__fastcall *mAddProc)(int, int, int, int, int, int, int, int, int); + void(__fastcall *mProc)(int); + int mDraw; + unsigned char mType; + unsigned char mResist; + unsigned char mFileNum; + int mlSFX; + int miSFX; +}; + +struct MisFileData { + unsigned char mAnimName; + unsigned char mAnimFAmt; + char *mName; + int mFlags; + unsigned char *mAnimData[16]; + unsigned char mAnimDelay[16]; + unsigned char mAnimLen[16]; + int mAnimWidth[16]; + int mAnimWidth2[16]; +}; + +struct ChainStruct { + int idx; + int _mitype; + int _mirange; +}; + +struct MissileStruct { + int _mitype; + int _mix; + int _miy; + int _mixoff; + int _miyoff; + int _mixvel; + int _miyvel; + int _misx; + int _misy; + int _mitxoff; + int _mityoff; + int _mimfnum; + int _mispllvl; + int _miDelFlag; + int _miAnimType; + int _miAnimFlags; + unsigned char *_miAnimData; + int _miAnimDelay; + int _miAnimLen; + int _miAnimWidth; + int _miAnimWidth2; + int _miAnimCnt; + int _miAnimAdd; + int _miAnimFrame; + int _miDrawFlag; + int _miLightFlag; + int _miPreFlag; + int _miUniqTrans; + int _mirange; + int _misource; + int _micaster; + int _midam; + int _miHitFlag; + int _midist; + int _mlid; + int _mirnd; + int _miVar1; + int _miVar2; + int _miVar3; + int _miVar4; + int _miVar5; + int _miVar6; + int _miVar7; + int _miVar8; }; ////////////////////////////////////////////////// // effects/sound ////////////////////////////////////////////////// -struct TSnd -{ - WAVEFORMATEX fmt; - int len; - int offset; - char *sound_path; - LPDIRECTSOUNDBUFFER DSB; - int start_tc; +struct TSnd { + WAVEFORMATEX fmt; + int len; + int offset; + char *sound_path; + LPDIRECTSOUNDBUFFER DSB; + int start_tc; }; #pragma pack(push, 1) -struct TSFX -{ - unsigned char bFlags; - char *pszName; - TSnd *pSnd; +struct TSFX { + unsigned char bFlags; + char *pszName; + TSnd *pSnd; }; #pragma pack(pop) @@ -486,237 +473,231 @@ struct TSFX struct AnimStruct // note: wrong names { - unsigned char *CMem; - unsigned char *Frames[8]; // probably Data[8] - int Rate; - int Delay; -}; - -struct MonsterData -{ - int flags; // width? - int mType; - char *GraphicType; - BOOL has_special; - char *sndfile; - int snd_special; - int has_trans; - char *TransFile; - int Frames[6]; - int Rate[6]; - char *mName; - char mMinDLvl; - char mMaxDLvl; - char mLevel; - int mMinHP; - int mMaxHP; - char mAi; - int mFlags; - unsigned char mInt; - unsigned char mHit; - unsigned char mAFNum; - unsigned char mMinDamage; - unsigned char mMaxDamage; - unsigned char mHit2; - unsigned char mAFNum2; - unsigned char mMinDamage2; - unsigned char mMaxDamage2; - unsigned char mArmorClass; - char mMonstClass; - unsigned short mMagicRes; - unsigned short mMagicRes2; - unsigned short mTreasure; - char mSelFlag; - unsigned short mExp; -}; - -struct CMonster -{ - unsigned char mtype; - // TODO: Add enum for place flags - unsigned char mPlaceFlags; - AnimStruct Anims[6]; - TSnd *Snds[4][2]; - int flags_1; // width - int flags_2; // width 2 - unsigned char mMinHP; - unsigned char mMaxHP; - int has_special; - unsigned char mAFNum; - char mdeadval; - MonsterData *MData; - // A TRN file contains a sequence of colour transitions, represented - // as indexes into a palette. (a 256 byte array of palette indices) - unsigned char *trans_file; + unsigned char *CMem; + unsigned char *Frames[8]; // probably Data[8] + int Rate; + int Delay; +}; + +struct MonsterData { + int flags; // width? + int mType; + char *GraphicType; + BOOL has_special; + char *sndfile; + int snd_special; + int has_trans; + char *TransFile; + int Frames[6]; + int Rate[6]; + char *mName; + char mMinDLvl; + char mMaxDLvl; + char mLevel; + int mMinHP; + int mMaxHP; + char mAi; + int mFlags; + unsigned char mInt; + unsigned char mHit; + unsigned char mAFNum; + unsigned char mMinDamage; + unsigned char mMaxDamage; + unsigned char mHit2; + unsigned char mAFNum2; + unsigned char mMinDamage2; + unsigned char mMaxDamage2; + unsigned char mArmorClass; + char mMonstClass; + unsigned short mMagicRes; + unsigned short mMagicRes2; + unsigned short mTreasure; + char mSelFlag; + unsigned short mExp; +}; + +struct CMonster { + unsigned char mtype; + // TODO: Add enum for place flags + unsigned char mPlaceFlags; + AnimStruct Anims[6]; + TSnd *Snds[4][2]; + int flags_1; // width + int flags_2; // width 2 + unsigned char mMinHP; + unsigned char mMaxHP; + int has_special; + unsigned char mAFNum; + char mdeadval; + MonsterData *MData; + // A TRN file contains a sequence of colour transitions, represented + // as indexes into a palette. (a 256 byte array of palette indices) + unsigned char *trans_file; }; struct MonsterStruct // note: missing field _mAFNum { - int _mMTidx; - int _mmode; /* MON_MODE */ - unsigned char _mgoal; - int _mgoalvar1; - int _mgoalvar2; - int _mgoalvar3; - int field_18; - unsigned char _pathcount; - int _mx; - int _my; - int _mfutx; - int _mfuty; - int _moldx; - int _moldy; - int _mxoff; - int _myoff; - int _mxvel; - int _myvel; - int _mdir; - int _menemy; - unsigned char _menemyx; - unsigned char _menemyy; - short falign_52; - unsigned char *_mAnimData; - int _mAnimDelay; - int _mAnimCnt; - int _mAnimLen; - int _mAnimFrame; - int _meflag; - BOOL _mDelFlag; - int _mVar1; - int _mVar2; - int _mVar3; - int _mVar4; - int _mVar5; - int _mVar6; - int _mVar7; - int _mVar8; - int _mmaxhp; - int _mhitpoints; - unsigned char _mAi; - unsigned char _mint; - short falign_9A; - int _mFlags; - char _msquelch; /* unsigned char */ - int falign_A4; - int _lastx; - int _lasty; - int _mRndSeed; - int _mAISeed; - int falign_B8; - unsigned char _uniqtype; - unsigned char _uniqtrans; - char _udeadval; - char mWhoHit; - char mLevel; - unsigned short mExp; - unsigned char mHit; - unsigned char mMinDamage; - unsigned char mMaxDamage; - unsigned char mHit2; - unsigned char mMinDamage2; - unsigned char mMaxDamage2; - unsigned char mArmorClass; - char falign_CB; - unsigned short mMagicRes; - int mtalkmsg; - unsigned char leader; - unsigned char leaderflag; - unsigned char unpackfilesize; - unsigned char mlid; - char *mName; - CMonster *MType; - MonsterData *MData; -}; - -struct UniqMonstStruct -{ - char mtype; - char *mName; - char *mMode; - unsigned char mlevel; - unsigned short mmaxhp; - unsigned char mAi; - unsigned char mint; - unsigned char mMinDamage; - unsigned char mMaxDamage; - unsigned short mMagicRes; - unsigned short mUnqAttr; - unsigned char mUnqVar1; - unsigned char mUnqVar2; - int mtalkmsg; + int _mMTidx; + int _mmode; /* MON_MODE */ + unsigned char _mgoal; + int _mgoalvar1; + int _mgoalvar2; + int _mgoalvar3; + int field_18; + unsigned char _pathcount; + int _mx; + int _my; + int _mfutx; + int _mfuty; + int _moldx; + int _moldy; + int _mxoff; + int _myoff; + int _mxvel; + int _myvel; + int _mdir; + int _menemy; + unsigned char _menemyx; + unsigned char _menemyy; + short falign_52; + unsigned char *_mAnimData; + int _mAnimDelay; + int _mAnimCnt; + int _mAnimLen; + int _mAnimFrame; + int _meflag; + BOOL _mDelFlag; + int _mVar1; + int _mVar2; + int _mVar3; + int _mVar4; + int _mVar5; + int _mVar6; + int _mVar7; + int _mVar8; + int _mmaxhp; + int _mhitpoints; + unsigned char _mAi; + unsigned char _mint; + short falign_9A; + int _mFlags; + char _msquelch; /* unsigned char */ + int falign_A4; + int _lastx; + int _lasty; + int _mRndSeed; + int _mAISeed; + int falign_B8; + unsigned char _uniqtype; + unsigned char _uniqtrans; + char _udeadval; + char mWhoHit; + char mLevel; + unsigned short mExp; + unsigned char mHit; + unsigned char mMinDamage; + unsigned char mMaxDamage; + unsigned char mHit2; + unsigned char mMinDamage2; + unsigned char mMaxDamage2; + unsigned char mArmorClass; + char falign_CB; + unsigned short mMagicRes; + int mtalkmsg; + unsigned char leader; + unsigned char leaderflag; + unsigned char unpackfilesize; + unsigned char mlid; + char *mName; + CMonster *MType; + MonsterData *MData; +}; + +struct UniqMonstStruct { + char mtype; + char *mName; + char *mMode; + unsigned char mlevel; + unsigned short mmaxhp; + unsigned char mAi; + unsigned char mint; + unsigned char mMinDamage; + unsigned char mMaxDamage; + unsigned short mMagicRes; + unsigned short mUnqAttr; + unsigned char mUnqVar1; + unsigned char mUnqVar2; + int mtalkmsg; }; ////////////////////////////////////////////////// // objects ////////////////////////////////////////////////// -struct ObjDataStruct -{ - char oload; - char ofindex; - char ominlvl; - char omaxlvl; - char olvltype; - char otheme; - char oquest; - int oAnimFlag; - int oAnimDelay; - int oAnimLen; - int oAnimWidth; - BOOL oSolidFlag; - int oMissFlag; - int oLightFlag; - char oBreak; - char oSelFlag; - int oTrapFlag; -}; - -struct ObjectStruct -{ - int _otype; - int _ox; - int _oy; - int _oLight; - int _oAnimFlag; - unsigned char *_oAnimData; - int _oAnimDelay; - int _oAnimCnt; - int _oAnimLen; - int _oAnimFrame; - int _oAnimWidth; - int _oAnimWidth2; - int _oDelFlag; - char _oBreak; // check - BOOL _oSolidFlag; - int _oMissFlag; - char _oSelFlag; // check - int _oPreFlag; - int _oTrapFlag; - int _oDoorFlag; - int _olid; - int _oRndSeed; - int _oVar1; - int _oVar2; - int _oVar3; - int _oVar4; - int _oVar5; - int _oVar6; - int _oVar7; - int _oVar8; +struct ObjDataStruct { + char oload; + char ofindex; + char ominlvl; + char omaxlvl; + char olvltype; + char otheme; + char oquest; + int oAnimFlag; + int oAnimDelay; + int oAnimLen; + int oAnimWidth; + BOOL oSolidFlag; + int oMissFlag; + int oLightFlag; + char oBreak; + char oSelFlag; + int oTrapFlag; +}; + +struct ObjectStruct { + int _otype; + int _ox; + int _oy; + int _oLight; + int _oAnimFlag; + unsigned char *_oAnimData; + int _oAnimDelay; + int _oAnimCnt; + int _oAnimLen; + int _oAnimFrame; + int _oAnimWidth; + int _oAnimWidth2; + int _oDelFlag; + char _oBreak; // check + BOOL _oSolidFlag; + int _oMissFlag; + char _oSelFlag; // check + int _oPreFlag; + int _oTrapFlag; + int _oDoorFlag; + int _olid; + int _oRndSeed; + int _oVar1; + int _oVar2; + int _oVar3; + int _oVar4; + int _oVar5; + int _oVar6; + int _oVar7; + int _oVar8; }; ////////////////////////////////////////////////// // portal ////////////////////////////////////////////////// -struct PortalStruct -{ - int open; - int x; - int y; - int level; - int ltype; - int setlvl; +struct PortalStruct { + int open; + int x; + int y; + int level; + int ltype; + int setlvl; }; ////////////////////////////////////////////////// @@ -724,319 +705,286 @@ struct PortalStruct ////////////////////////////////////////////////// #pragma pack(push, 1) -struct TCmd -{ - unsigned char bCmd; -}; - -struct TCmdLoc -{ - unsigned char bCmd; - unsigned char x; - unsigned char y; -}; - -struct TCmdLocParam1 -{ - unsigned char bCmd; - unsigned char x; - unsigned char y; - unsigned short wParam1; -}; - -struct TCmdLocParam2 -{ - unsigned char bCmd; - unsigned char x; - unsigned char y; - unsigned short wParam1; - unsigned short wParam2; -}; - -struct TCmdLocParam3 -{ - unsigned char bCmd; - unsigned char x; - unsigned char y; - unsigned short wParam1; - unsigned short wParam2; - unsigned short wParam3; -}; - -struct TCmdParam1 -{ - unsigned char bCmd; - unsigned short wParam1; -}; - -struct TCmdParam2 -{ - unsigned char bCmd; - unsigned short wParam1; - unsigned short wParam2; -}; - -struct TCmdParam3 -{ - unsigned char bCmd; - unsigned short wParam1; - unsigned short wParam2; - unsigned short wParam3; -}; - -struct TCmdGolem -{ - unsigned char bCmd; - unsigned char _mx; - unsigned char _my; - unsigned char _mdir; - unsigned char _menemy; - int _mhitpoints; - unsigned char _currlevel; -}; - -struct TCmdQuest -{ - unsigned char bCmd; - unsigned char q; - unsigned char qstate; - unsigned char qlog; - unsigned char qvar1; -}; - -struct TCmdGItem -{ - unsigned char bCmd; - unsigned char bMaster; - unsigned char bPnum; - unsigned char bCursitem; - unsigned char bLevel; - unsigned char x; - unsigned char y; - unsigned short wIndx; - unsigned short wCI; - int dwSeed; - unsigned char bId; - unsigned char bDur; - unsigned char bMDur; - unsigned char bCh; - unsigned char bMCh; - unsigned short wValue; - int dwBuff; - int dwTime; -}; - -struct TCmdPItem -{ - char bCmd; /* unsigned */ - unsigned char x; - unsigned char y; - unsigned short wIndx; - unsigned short wCI; - int dwSeed; - unsigned char bId; - unsigned char bDur; - unsigned char bMDur; - unsigned char bCh; - unsigned char bMCh; - unsigned short wValue; - int dwBuff; -}; - -struct TCmdChItem -{ - unsigned char bCmd; - unsigned char bLoc; - unsigned short wIndx; - unsigned short wCI; - int dwSeed; - unsigned char bId; -}; - -struct TCmdDelItem -{ - unsigned char bCmd; - unsigned char bLoc; -}; - -struct TCmdDamage -{ - unsigned char bCmd; - unsigned char bPlr; - int dwDam; -}; - -struct TCmdPlrInfoHdr -{ - unsigned char bCmd; - unsigned short wOffset; - unsigned short wBytes; -}; - -struct TCmdString -{ - unsigned char bCmd; - char str[80]; +struct TCmd { + unsigned char bCmd; +}; + +struct TCmdLoc { + unsigned char bCmd; + unsigned char x; + unsigned char y; +}; + +struct TCmdLocParam1 { + unsigned char bCmd; + unsigned char x; + unsigned char y; + unsigned short wParam1; +}; + +struct TCmdLocParam2 { + unsigned char bCmd; + unsigned char x; + unsigned char y; + unsigned short wParam1; + unsigned short wParam2; +}; + +struct TCmdLocParam3 { + unsigned char bCmd; + unsigned char x; + unsigned char y; + unsigned short wParam1; + unsigned short wParam2; + unsigned short wParam3; +}; + +struct TCmdParam1 { + unsigned char bCmd; + unsigned short wParam1; }; -struct TFakeCmdPlr -{ - unsigned char bCmd; - unsigned char bPlr; +struct TCmdParam2 { + unsigned char bCmd; + unsigned short wParam1; + unsigned short wParam2; }; -struct TFakeDropPlr -{ - unsigned char bCmd; - unsigned char bPlr; - int dwReason; +struct TCmdParam3 { + unsigned char bCmd; + unsigned short wParam1; + unsigned short wParam2; + unsigned short wParam3; }; -struct TSyncHeader -{ - unsigned char bCmd; - unsigned char bLevel; - unsigned short wLen; - unsigned char bObjId; - unsigned char bObjCmd; - unsigned char bItemI; - unsigned char bItemX; - unsigned char bItemY; - unsigned short wItemIndx; - unsigned short wItemCI; - int dwItemSeed; - unsigned char bItemId; - unsigned char bItemDur; - unsigned char bItemMDur; - unsigned char bItemCh; - unsigned char bItemMCh; - unsigned short wItemVal; - unsigned int dwItemBuff; - unsigned char bPInvLoc; - unsigned short wPInvIndx; - unsigned short wPInvCI; - int dwPInvSeed; - unsigned char bPInvId; -}; - -struct TSyncMonster -{ - unsigned char _mndx; - unsigned char _mx; - unsigned char _my; - unsigned char _menemy; - unsigned char _mdelta; +struct TCmdGolem { + unsigned char bCmd; + unsigned char _mx; + unsigned char _my; + unsigned char _mdir; + unsigned char _menemy; + int _mhitpoints; + unsigned char _currlevel; +}; + +struct TCmdQuest { + unsigned char bCmd; + unsigned char q; + unsigned char qstate; + unsigned char qlog; + unsigned char qvar1; +}; + +struct TCmdGItem { + unsigned char bCmd; + unsigned char bMaster; + unsigned char bPnum; + unsigned char bCursitem; + unsigned char bLevel; + unsigned char x; + unsigned char y; + unsigned short wIndx; + unsigned short wCI; + int dwSeed; + unsigned char bId; + unsigned char bDur; + unsigned char bMDur; + unsigned char bCh; + unsigned char bMCh; + unsigned short wValue; + int dwBuff; + int dwTime; +}; + +struct TCmdPItem { + char bCmd; /* unsigned */ + unsigned char x; + unsigned char y; + unsigned short wIndx; + unsigned short wCI; + int dwSeed; + unsigned char bId; + unsigned char bDur; + unsigned char bMDur; + unsigned char bCh; + unsigned char bMCh; + unsigned short wValue; + int dwBuff; +}; + +struct TCmdChItem { + unsigned char bCmd; + unsigned char bLoc; + unsigned short wIndx; + unsigned short wCI; + int dwSeed; + unsigned char bId; +}; + +struct TCmdDelItem { + unsigned char bCmd; + unsigned char bLoc; +}; + +struct TCmdDamage { + unsigned char bCmd; + unsigned char bPlr; + int dwDam; +}; + +struct TCmdPlrInfoHdr { + unsigned char bCmd; + unsigned short wOffset; + unsigned short wBytes; +}; + +struct TCmdString { + unsigned char bCmd; + char str[80]; +}; + +struct TFakeCmdPlr { + unsigned char bCmd; + unsigned char bPlr; +}; + +struct TFakeDropPlr { + unsigned char bCmd; + unsigned char bPlr; + int dwReason; +}; + +struct TSyncHeader { + unsigned char bCmd; + unsigned char bLevel; + unsigned short wLen; + unsigned char bObjId; + unsigned char bObjCmd; + unsigned char bItemI; + unsigned char bItemX; + unsigned char bItemY; + unsigned short wItemIndx; + unsigned short wItemCI; + int dwItemSeed; + unsigned char bItemId; + unsigned char bItemDur; + unsigned char bItemMDur; + unsigned char bItemCh; + unsigned char bItemMCh; + unsigned short wItemVal; + unsigned int dwItemBuff; + unsigned char bPInvLoc; + unsigned short wPInvIndx; + unsigned short wPInvCI; + int dwPInvSeed; + unsigned char bPInvId; +}; + +struct TSyncMonster { + unsigned char _mndx; + unsigned char _mx; + unsigned char _my; + unsigned char _menemy; + unsigned char _mdelta; +}; + +struct TPktHdr { + unsigned char px; + unsigned char py; + unsigned char targx; + unsigned char targy; + int php; + int pmhp; + unsigned char bstr; + unsigned char bmag; + unsigned char bdex; + unsigned short wCheck; + unsigned short wLen; }; -struct TPktHdr -{ - unsigned char px; - unsigned char py; - unsigned char targx; - unsigned char targy; - int php; - int pmhp; - unsigned char bstr; - unsigned char bmag; - unsigned char bdex; - unsigned short wCheck; - unsigned short wLen; -}; - -struct TPkt -{ - TPktHdr hdr; - unsigned char body[493]; +struct TPkt { + TPktHdr hdr; + unsigned char body[493]; }; -struct DMonsterStr -{ - char _mx; /* these might be unsigned */ - char _my; - char _mdir; - char _menemy; - char _mactive; - int _mhitpoints; +struct DMonsterStr { + char _mx; /* these might be unsigned */ + char _my; + char _mdir; + char _menemy; + char _mactive; + int _mhitpoints; }; -struct DObjectStr -{ - unsigned char bCmd; +struct DObjectStr { + unsigned char bCmd; }; -struct DLevel -{ - TCmdPItem item[MAXITEMS]; - DObjectStr object[MAXOBJECTS]; - DMonsterStr monster[MAXMONSTERS]; +struct DLevel { + TCmdPItem item[MAXITEMS]; + DObjectStr object[MAXOBJECTS]; + DMonsterStr monster[MAXMONSTERS]; }; -struct LocalLevel -{ - unsigned char automapsv[40][40]; +struct LocalLevel { + unsigned char automapsv[40][40]; }; -struct DPortal -{ - unsigned char x; - unsigned char y; - unsigned char level; - unsigned char ltype; - unsigned char setlvl; +struct DPortal { + unsigned char x; + unsigned char y; + unsigned char level; + unsigned char ltype; + unsigned char setlvl; }; -struct MultiQuests -{ - unsigned char qstate; - unsigned char qlog; - unsigned char qvar1; +struct MultiQuests { + unsigned char qstate; + unsigned char qlog; + unsigned char qvar1; }; - -struct DJunk -{ - DPortal portal[MAXPORTAL]; - MultiQuests quests[MAXMULTIQUESTS]; + +struct DJunk { + DPortal portal[MAXPORTAL]; + MultiQuests quests[MAXMULTIQUESTS]; }; #pragma pack(pop) -struct TMegaPkt -{ - TMegaPkt *pNext; - int dwSpaceLeft; - unsigned char data[32000]; +struct TMegaPkt { + TMegaPkt *pNext; + int dwSpaceLeft; + unsigned char data[32000]; }; ////////////////////////////////////////////////// // quests ////////////////////////////////////////////////// -struct QuestStruct -{ - unsigned char _qlevel; - unsigned char _qtype; - unsigned char _qactive; - unsigned char _qlvltype; - int _qtx; - int _qty; - unsigned char _qslvl; - unsigned char _qidx; - unsigned char _qmsg; - unsigned char _qvar1; - unsigned char _qvar2; - int _qlog; /* char */ -}; - -struct QuestData -{ - unsigned char _qdlvl; - char _qdmultlvl; - unsigned char _qlvlt; - unsigned char _qdtype; - unsigned char _qdrnd; - unsigned char _qslvl; - int _qflags; /* unsigned char */ - int _qdmsg; - char *_qlstr; +struct QuestStruct { + unsigned char _qlevel; + unsigned char _qtype; + unsigned char _qactive; + unsigned char _qlvltype; + int _qtx; + int _qty; + unsigned char _qslvl; + unsigned char _qidx; + unsigned char _qmsg; + unsigned char _qvar1; + unsigned char _qvar2; + int _qlog; /* char */ +}; + +struct QuestData { + unsigned char _qdlvl; + char _qdmultlvl; + unsigned char _qlvlt; + unsigned char _qdtype; + unsigned char _qdrnd; + unsigned char _qslvl; + int _qflags; /* unsigned char */ + int _qdmsg; + char *_qlstr; }; ////////////////////////////////////////////////// @@ -1045,11 +993,10 @@ struct QuestData // TPDEF PTR FCN VOID TMenuFcn -struct TMenuItem -{ - unsigned int dwFlags; - char *pszStr; - void (__cdecl *fnMenu)(); /* fix, should have one arg */ +struct TMenuItem { + unsigned int dwFlags; + char *pszStr; + void(__cdecl *fnMenu)(); /* fix, should have one arg */ }; // TPDEF PTR FCN VOID TMenuUpdateFcn @@ -1058,222 +1005,208 @@ struct TMenuItem // spells ////////////////////////////////////////////////// -struct SpellData -{ - unsigned char sName; - unsigned char sManaCost; - unsigned char sType; - char *sNameText; - char *sSkillText; - int sBookLvl; - int sStaffLvl; - BOOL sTargeted; - BOOL sTownSpell; - int sMinInt; - unsigned char sSFX; - unsigned char sMissiles[3]; - unsigned char sManaAdj; - unsigned char sMinMana; - int sStaffMin; - int sStaffMax; - int sBookCost; - int sStaffCost; +struct SpellData { + unsigned char sName; + unsigned char sManaCost; + unsigned char sType; + char *sNameText; + char *sSkillText; + int sBookLvl; + int sStaffLvl; + BOOL sTargeted; + BOOL sTownSpell; + int sMinInt; + unsigned char sSFX; + unsigned char sMissiles[3]; + unsigned char sManaAdj; + unsigned char sMinMana; + int sStaffMin; + int sStaffMax; + int sBookCost; + int sStaffCost; }; ////////////////////////////////////////////////// // towners ////////////////////////////////////////////////// -struct TNQ -{ - unsigned char _qsttype; - unsigned char _qstmsg; - unsigned char _qstmsgact; -}; - -struct TownerStruct -{ - int _tmode; - int _ttype; - int _tx; - int _ty; - int _txoff; - int _tyoff; - int _txvel; - int _tyvel; - int _tdir; - unsigned char *_tAnimData; - int _tAnimDelay; - int _tAnimCnt; - int _tAnimLen; - int _tAnimFrame; - int _tAnimFrameCnt; - int _tAnimOrder; - int _tAnimWidth; - int _tAnimWidth2; - int _tTenPer; - int _teflag; - int _tbtcnt; - int _tSelFlag; - int _tMsgSaid; - TNQ qsts[16]; - int _tSeed; - int _tVar1; - int _tVar2; - int _tVar3; - int _tVar4; - char _tName[32]; - unsigned char *_tNAnim[8]; - int _tNFrames; - unsigned char *_tNData; -}; - -struct QuestTalkData -{ - int _qinfra; - int _qblkm; - int _qgarb; - int _qzhar; - int _qveil; - int _qmod; - int _qbutch; - int _qbol; - int _qblind; - int _qblood; - int _qanvil; - int _qwarlrd; - int _qking; - int _qpw; - int _qbone; - int _qvb; +struct TNQ { + unsigned char _qsttype; + unsigned char _qstmsg; + unsigned char _qstmsgact; +}; + +struct TownerStruct { + int _tmode; + int _ttype; + int _tx; + int _ty; + int _txoff; + int _tyoff; + int _txvel; + int _tyvel; + int _tdir; + unsigned char *_tAnimData; + int _tAnimDelay; + int _tAnimCnt; + int _tAnimLen; + int _tAnimFrame; + int _tAnimFrameCnt; + int _tAnimOrder; + int _tAnimWidth; + int _tAnimWidth2; + int _tTenPer; + int _teflag; + int _tbtcnt; + int _tSelFlag; + int _tMsgSaid; + TNQ qsts[16]; + int _tSeed; + int _tVar1; + int _tVar2; + int _tVar3; + int _tVar4; + char _tName[32]; + unsigned char *_tNAnim[8]; + int _tNFrames; + unsigned char *_tNData; +}; + +struct QuestTalkData { + int _qinfra; + int _qblkm; + int _qgarb; + int _qzhar; + int _qveil; + int _qmod; + int _qbutch; + int _qbol; + int _qblind; + int _qblood; + int _qanvil; + int _qwarlrd; + int _qking; + int _qpw; + int _qbone; + int _qvb; }; ////////////////////////////////////////////////// // gendung ////////////////////////////////////////////////// -struct ScrollStruct -{ - int _sxoff; - int _syoff; - int _sdx; - int _sdy; - int _sdir; +struct ScrollStruct { + int _sxoff; + int _syoff; + int _sdx; + int _sdy; + int _sdir; }; -struct THEME_LOC -{ - int x; - int y; - int ttval; - int width; - int height; +struct THEME_LOC { + int x; + int y; + int ttval; + int width; + int height; }; ////////////////////////////////////////////////// // drlg ////////////////////////////////////////////////// -struct ShadowStruct -{ - unsigned char strig; - unsigned char s1; - unsigned char s2; - unsigned char s3; - unsigned char nv1; - unsigned char nv2; - unsigned char nv3; +struct ShadowStruct { + unsigned char strig; + unsigned char s1; + unsigned char s2; + unsigned char s3; + unsigned char nv1; + unsigned char nv2; + unsigned char nv3; }; -struct HALLNODE -{ - int nHallx1; - int nHally1; - int nHallx2; - int nHally2; - int nHalldir; - HALLNODE *pNext; +struct HALLNODE { + int nHallx1; + int nHally1; + int nHallx2; + int nHally2; + int nHalldir; + HALLNODE *pNext; }; -struct ROOMNODE -{ - int nRoomx1; - int nRoomy1; - int nRoomx2; - int nRoomy2; - int nRoomDest; +struct ROOMNODE { + int nRoomx1; + int nRoomy1; + int nRoomx2; + int nRoomy2; + int nRoomDest; }; ////////////////////////////////////////////////// // themes ////////////////////////////////////////////////// -struct ThemeStruct -{ - char ttype; /* aligned 4 */ - int ttval; +struct ThemeStruct { + char ttype; /* aligned 4 */ + int ttval; }; ////////////////////////////////////////////////// // inv ////////////////////////////////////////////////// -struct InvXY -{ - int X; - int Y; +struct InvXY { + int X; + int Y; }; ////////////////////////////////////////////////// // lighting ////////////////////////////////////////////////// -struct LightListStruct -{ - int _lx; - int _ly; - int _lradius; - int _lid; - int _ldel; - int _lunflag; - int field_18; - int _lunx; - int _luny; - int _lunr; - int _xoff; - int _yoff; - int _lflags; +struct LightListStruct { + int _lx; + int _ly; + int _lradius; + int _lid; + int _ldel; + int _lunflag; + int field_18; + int _lunx; + int _luny; + int _lunr; + int _xoff; + int _yoff; + int _lflags; }; ////////////////////////////////////////////////// // dead ////////////////////////////////////////////////// -struct DeadStruct -{ - unsigned char *_deadData[8]; - int _deadFrame; - int _deadWidth; - int _deadWidth2; - char _deadtrans; +struct DeadStruct { + unsigned char *_deadData[8]; + int _deadFrame; + int _deadWidth; + int _deadWidth2; + char _deadtrans; }; ////////////////////////////////////////////////// // dx ////////////////////////////////////////////////// -struct ScreenRow -{ - char col_unused_1[64]; - char pixels[640]; - char col_unused_2[64]; +struct ScreenRow { + char col_unused_1[64]; + char pixels[640]; + char col_unused_2[64]; }; struct Screen /* create union for work data vs visible data */ { - ScreenRow row_unused_1[160]; - ScreenRow row[480]; - ScreenRow row_unused_2[16]; + ScreenRow row_unused_1[160]; + ScreenRow row[480]; + ScreenRow row_unused_2[16]; }; ////////////////////////////////////////////////// @@ -1285,25 +1218,23 @@ struct Screen /* create union for work data vs visible data */ // TPDEF PTR FCN UCHAR SMSGIDLEPROC // TPDEF PTR FCN VOID SMSGHANDLER -struct _SNETCAPS -{ - int size; - int flags; - int maxmessagesize; - int maxqueuesize; - int maxplayers; - int bytessec; - int latencyms; - int defaultturnssec; - int defaultturnsintransit; -}; - -struct _SNETEVENT -{ - int eventid; - int playerid; - void *data; - int databytes; +struct _SNETCAPS { + int size; + int flags; + int maxmessagesize; + int maxqueuesize; + int maxplayers; + int bytessec; + int latencyms; + int defaultturnssec; + int defaultturnsintransit; +}; + +struct _SNETEVENT { + int eventid; + int playerid; + void *data; + int databytes; }; // TPDEF PTR FCN UCHAR SNETABORTPROC @@ -1322,64 +1253,60 @@ struct _SNETEVENT // TPDEF PTR FCN UCHAR SNETSELECTEDPROC // TPDEF PTR FCN UCHAR SNETSTATUSPROC -struct _SNETPLAYERDATA -{ - int size; - char *playername; - char *playerdescription; - int reserved; -}; - -struct _SNETPROGRAMDATA -{ - int size; - char *programname; - char *programdescription; - int programid; - int versionid; - int reserved1; - int maxplayers; - void *initdata; - int initdatabytes; - void *reserved2; - int optcategorybits; - char *cdkey; - char *registereduser; - int spawned; - int lcid; -}; - -struct _SNETUIDATA -{ - int size; - int uiflags; - HWND parentwindow; - void (__cdecl *artcallback)(); - void (__cdecl *authcallback)(); - void (__cdecl *createcallback)(); - void (__cdecl *drawdesccallback)(); - void (__cdecl *selectedcallback)(); - void (__cdecl *messageboxcallback)(); - void (__cdecl *soundcallback)(); - void (__cdecl *statuscallback)(); - void (__cdecl *getdatacallback)(); - void (__cdecl *categorycallback)(); - void (__cdecl *categorylistcallback)(); - void (__cdecl *newaccountcallback)(); - void (__cdecl *profilecallback)(); - int profilefields; - void (__cdecl *profilebitmapcallback)(); - void (__cdecl *selectnamecallback)(); - void (__cdecl *changenamecallback)(); -}; - -struct _SNETVERSIONDATA -{ - int size; - char *versionstring; - char *executablefile; - char *originalarchivefile; - char *patcharchivefile; +struct _SNETPLAYERDATA { + int size; + char *playername; + char *playerdescription; + int reserved; +}; + +struct _SNETPROGRAMDATA { + int size; + char *programname; + char *programdescription; + int programid; + int versionid; + int reserved1; + int maxplayers; + void *initdata; + int initdatabytes; + void *reserved2; + int optcategorybits; + char *cdkey; + char *registereduser; + int spawned; + int lcid; +}; + +struct _SNETUIDATA { + int size; + int uiflags; + HWND parentwindow; + void(__cdecl *artcallback)(); + void(__cdecl *authcallback)(); + void(__cdecl *createcallback)(); + void(__cdecl *drawdesccallback)(); + void(__cdecl *selectedcallback)(); + void(__cdecl *messageboxcallback)(); + void(__cdecl *soundcallback)(); + void(__cdecl *statuscallback)(); + void(__cdecl *getdatacallback)(); + void(__cdecl *categorycallback)(); + void(__cdecl *categorylistcallback)(); + void(__cdecl *newaccountcallback)(); + void(__cdecl *profilecallback)(); + int profilefields; + void(__cdecl *profilebitmapcallback)(); + void(__cdecl *selectnamecallback)(); + void(__cdecl *changenamecallback)(); +}; + +struct _SNETVERSIONDATA { + int size; + char *versionstring; + char *executablefile; + char *originalarchivefile; + char *patcharchivefile; }; // TPDEF PTR FCN UCHAR SNETSPIBIND @@ -1391,34 +1318,31 @@ struct _SNETVERSIONDATA // TPDEF PTR FCN VOID PLAYSND -struct _gamedata -{ - int dwSeed; - unsigned char bDiff; +struct _gamedata { + int dwSeed; + unsigned char bDiff; }; -struct _uidefaultstats -{ - unsigned short strength; - unsigned short magic; - unsigned short dexterity; - unsigned short vitality; +struct _uidefaultstats { + unsigned short strength; + unsigned short magic; + unsigned short dexterity; + unsigned short vitality; }; -struct _uiheroinfo -{ - _uiheroinfo *next; - char name[16]; - unsigned short level; - unsigned char heroclass; - unsigned char herorank; - unsigned short strength; - unsigned short magic; - unsigned short dexterity; - unsigned short vitality; - int gold; - int hassaved; - int spawned; +struct _uiheroinfo { + _uiheroinfo *next; + char name[16]; + unsigned short level; + unsigned char heroclass; + unsigned char herorank; + unsigned short strength; + unsigned short magic; + unsigned short dexterity; + unsigned short vitality; + int gold; + int hassaved; + int spawned; }; // TPDEF PTR FCN UCHAR ENUMHEROPROC @@ -1434,62 +1358,60 @@ struct _uiheroinfo ////////////////////////////////////////////////// #pragma pack(push, 1) -struct PkItemStruct -{ - int iSeed; - short iCreateInfo; - short idx; - char bId; - char bDur; - char bMDur; - char bCh; - char bMCh; - short wValue; - int dwBuff; -}; - -struct PkPlayerStruct -{ - FILETIME archiveTime; - char destAction; - char destParam1; - char destParam2; - char plrlevel; - char px; - char py; - char targx; - char targy; - char pName[32]; - char pClass; - char pBaseStr; - char pBaseMag; - char pBaseDex; - char pBaseVit; - char pLevel; - char pStatPts; - int pExperience; - int pGold; - int pHPBase; - int pMaxHPBase; - int pManaBase; - int pMaxManaBase; - char pSplLvl[MAX_SPELLS]; - int pMemSpells; /* __int64 */ - int pMemSpells2; - PkItemStruct InvBody[7]; - PkItemStruct InvList[40]; - char InvGrid[40]; - char _pNumInv; - PkItemStruct SpdList[MAXBELTITEMS]; - char pTownWarps; - char pDungMsgs; - char pLvlLoad; - char pBattleNet; - char pManaShield; - char bReserved[3]; - short wReserved[8]; - int pDiabloKillLevel; - int dwReserved[7]; +struct PkItemStruct { + int iSeed; + short iCreateInfo; + short idx; + char bId; + char bDur; + char bMDur; + char bCh; + char bMCh; + short wValue; + int dwBuff; +}; + +struct PkPlayerStruct { + FILETIME archiveTime; + char destAction; + char destParam1; + char destParam2; + char plrlevel; + char px; + char py; + char targx; + char targy; + char pName[32]; + char pClass; + char pBaseStr; + char pBaseMag; + char pBaseDex; + char pBaseVit; + char pLevel; + char pStatPts; + int pExperience; + int pGold; + int pHPBase; + int pMaxHPBase; + int pManaBase; + int pMaxManaBase; + char pSplLvl[MAX_SPELLS]; + int pMemSpells; /* __int64 */ + int pMemSpells2; + PkItemStruct InvBody[7]; + PkItemStruct InvList[40]; + char InvGrid[40]; + char _pNumInv; + PkItemStruct SpdList[MAXBELTITEMS]; + char pTownWarps; + char pDungMsgs; + char pLvlLoad; + char pBattleNet; + char pManaShield; + char bReserved[3]; + short wReserved[8]; + int pDiabloKillLevel; + int dwReserved[7]; }; #pragma pack(pop) @@ -1497,16 +1419,15 @@ struct PkPlayerStruct // path ////////////////////////////////////////////////// -struct PATHNODE -{ - char f; - char h; - short g; - int x; - int y; - struct PATHNODE *Parent; - struct PATHNODE *Child[8]; - struct PATHNODE *NextNode; +struct PATHNODE { + char f; + char h; + short g; + int x; + int y; + struct PATHNODE *Parent; + struct PATHNODE *Child[8]; + struct PATHNODE *NextNode; }; // TPDEF PTR FCN UCHAR CHECKFUNC1 @@ -1517,11 +1438,10 @@ struct PATHNODE // sha ////////////////////////////////////////////////// -struct SHA1Context -{ - int state[5]; - int count[2]; - char buffer[64]; +struct SHA1Context { + int state[5]; + int count[2]; + char buffer[64]; }; ////////////////////////////////////////////////// @@ -1531,19 +1451,17 @@ struct SHA1Context #pragma pack(push, 1) struct TMsg; -struct TMsgHdr -{ - TMsg *pNext; - DWORD dwTime; - BYTE bLen; +struct TMsgHdr { + TMsg *pNext; + DWORD dwTime; + BYTE bLen; }; -struct TMsg -{ - TMsgHdr hdr; - // this is actually alignment padding, but the message body is appended to the struct - // so it's convenient to use byte-alignment and name it "body" - unsigned char body[3]; +struct TMsg { + TMsgHdr hdr; + // this is actually alignment padding, but the message body is appended to the struct + // so it's convenient to use byte-alignment and name it "body" + unsigned char body[3]; }; #pragma pack(pop) @@ -1551,33 +1469,30 @@ struct TMsg // mpqapi ////////////////////////////////////////////////// -struct _FILEHEADER -{ - int signature; - int headersize; - int filesize; - short version; - short sectorsizeid; - int hashoffset; - int blockoffset; - int hashcount; - int blockcount; - char pad[72]; -}; - -struct _HASHENTRY -{ - int hashcheck[2]; - int lcid; - int block; +struct _FILEHEADER { + int signature; + int headersize; + int filesize; + short version; + short sectorsizeid; + int hashoffset; + int blockoffset; + int hashcount; + int blockcount; + char pad[72]; }; -struct _BLOCKENTRY -{ - int offset; - int sizealloc; - int sizefile; - int flags; +struct _HASHENTRY { + int hashcheck[2]; + int lcid; + int block; +}; + +struct _BLOCKENTRY { + int offset; + int sizealloc; + int sizefile; + int flags; }; // TPDEF PTR FCN UCHAR TGetNameFcn @@ -1588,104 +1503,96 @@ struct _BLOCKENTRY // trigs ////////////////////////////////////////////////// -struct TriggerStruct -{ - int _tx; - int _ty; - int _tmsg; - int _tlvl; +struct TriggerStruct { + int _tx; + int _ty; + int _tmsg; + int _tlvl; }; ////////////////////////////////////////////////// // stores ////////////////////////////////////////////////// -struct STextStruct -{ - int _sx; - int _syoff; - char _sstr[128]; - int _sjust; - int _sclr; - int _sline; - int _ssel; - int _sval; +struct STextStruct { + int _sx; + int _syoff; + char _sstr[128]; + int _sjust; + int _sclr; + int _sline; + int _ssel; + int _sval; }; ////////////////////////////////////////////////// // wave ////////////////////////////////////////////////// -struct MEMFILE -{ - int end; - int offset; - int buf_len; - int dist; - int bytes_to_read; - char *buf; - int file; +struct MEMFILE { + int end; + int offset; + int buf_len; + int dist; + int bytes_to_read; + char *buf; + int file; }; ////////////////////////////////////////////////// // plrmsg ////////////////////////////////////////////////// -struct _plrmsg -{ - DWORD time; - unsigned char player; - char str[144]; +struct _plrmsg { + DWORD time; + unsigned char player; + char str[144]; }; ////////////////////////////////////////////////// // capture ////////////////////////////////////////////////// -struct PCXHeader -{ - char manufacturer; - char version; - char encoding; - char bitsPerPixel; - short xmin, ymin; - short xmax, ymax; - short horzRes, vertRes; - char palette[48]; - char reserved; - char numColorPlanes; - short bytesPerScanLine; - short paletteType; - short horzSize, vertSize; - char padding[54]; +struct PCXHeader { + char manufacturer; + char version; + char encoding; + char bitsPerPixel; + short xmin, ymin; + short xmax, ymax; + short horzRes, vertRes; + char palette[48]; + char reserved; + char numColorPlanes; + short bytesPerScanLine; + short paletteType; + short horzSize, vertSize; + char padding[54]; }; ////////////////////////////////////////////////// // encrypt ////////////////////////////////////////////////// -struct TDataInfo -{ - unsigned char *pbInBuff; - unsigned char *pbInBuffEnd; - unsigned char *pbOutBuff; - unsigned char *pbOutBuffEnd; - unsigned char *pbSize; +struct TDataInfo { + unsigned char *pbInBuff; + unsigned char *pbInBuffEnd; + unsigned char *pbOutBuff; + unsigned char *pbOutBuffEnd; + unsigned char *pbSize; }; ////////////////////////////////////////////////// // msgcmd ////////////////////////////////////////////////// -struct ServerCommand -{ - int field_0; - int field_4; - char command[128]; +struct ServerCommand { + int field_0; + int field_4; + char command[128]; }; -struct ChatCmd -{ - struct ChatCmd *next; - ServerCommand *extern_msgs[2]; +struct ChatCmd { + struct ChatCmd *next; + ServerCommand *extern_msgs[2]; }; From 68c0f33ef08f29c0db6e933d93e43ec4c9a6bfcc Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 6 Oct 2018 20:18:39 +0200 Subject: [PATCH 3/6] Add default clang-format config for WebKit. Generated as follows: $ clang-format --version clang-format version 7.0.0 (tags/RELEASE_700/final) $ clang-format -style=webkit -dump-config > .clang-format --- .clang-format | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..43d5bcb90 --- /dev/null +++ b/.clang-format @@ -0,0 +1,118 @@ +--- +Language: Cpp +# BasedOnStyle: WebKit +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: false +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: WebKit +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never +... + From e41cf1a6f7b74c893920b066157b6838e8ff71e9 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 6 Oct 2018 20:20:18 +0200 Subject: [PATCH 4/6] Add Devilution specific config values for clang-format. * AlignTrailingComments: true * AllowShortBlocksOnASingleLine: true * AllowShortFunctionsOnASingleLine: None * PointerAlignment: Right Note, currently, the format.sh script uses the config file for .cpp files. The `AlignConsecutiveAssignments: true` setting is specifically added for .h files. I could not find a way to specify what config file to use for clang-format. So, for now, the config file is used for .cpp. --- .clang-format | 14 +++++++------- format.sh | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.clang-format b/.clang-format index 43d5bcb90..f9837cc7f 100644 --- a/.clang-format +++ b/.clang-format @@ -7,11 +7,11 @@ AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Right AlignOperands: false -AlignTrailingComments: false +AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false +AllowShortBlocksOnASingleLine: true AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: All +AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None @@ -20,7 +20,7 @@ AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: MultiLine BinPackArguments: true BinPackParameters: true -BraceWrapping: +BraceWrapping: AfterClass: false AfterControlStatement: false AfterEnum: false @@ -56,12 +56,12 @@ DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false FixNamespaceComments: false -ForEachMacros: +ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH IncludeBlocks: Preserve -IncludeCategories: +IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 - Regex: '^(<|"(gtest|gmock|isl|json)/)' @@ -92,7 +92,7 @@ PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left +PointerAlignment: Right ReflowComments: true SortIncludes: true SortUsingDeclarations: true diff --git a/format.sh b/format.sh index 66c6de538..5ea8eeed9 100755 --- a/format.sh +++ b/format.sh @@ -4,7 +4,7 @@ CPP_DONE="Source/doom.cpp Source/movie.cpp Source/pfile.cpp Source/player.cpp So for f in $CPP_DONE; do echo "Formatting $f" - clang-format -style="{BasedOnStyle: webkit, AlignTrailingComments: true, AllowShortBlocksOnASingleLine: true, AllowShortFunctionsOnASingleLine: None, PointerAlignment: Right}" -i $f + clang-format -style=file -i $f done H_DONE="enums.h structs.h" From d5672d046141102ea9b83bff721846c7b643af78 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 6 Oct 2018 20:35:24 +0200 Subject: [PATCH 5/6] Use .clang-format config instead of -style command line settings. The Source/.clang-format config is used for *.cpp files. The root .clang-format config is used for *.h files. --- .clang-format | 2 +- Source/.clang-format | 118 +++++++++++++++++++++++++++++++++++++++++++ format.sh | 8 ++- 3 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 Source/.clang-format diff --git a/.clang-format b/.clang-format index f9837cc7f..12bd5df28 100644 --- a/.clang-format +++ b/.clang-format @@ -3,7 +3,7 @@ Language: Cpp # BasedOnStyle: WebKit AccessModifierOffset: -4 AlignAfterOpenBracket: DontAlign -AlignConsecutiveAssignments: false +AlignConsecutiveAssignments: true AlignConsecutiveDeclarations: false AlignEscapedNewlines: Right AlignOperands: false diff --git a/Source/.clang-format b/Source/.clang-format new file mode 100644 index 000000000..f9837cc7f --- /dev/null +++ b/Source/.clang-format @@ -0,0 +1,118 @@ +--- +Language: Cpp +# BasedOnStyle: WebKit +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: false +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: WebKit +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never +... + diff --git a/format.sh b/format.sh index 5ea8eeed9..8c5a8e365 100755 --- a/format.sh +++ b/format.sh @@ -1,7 +1,10 @@ #!/bin/bash -CPP_DONE="Source/doom.cpp Source/movie.cpp Source/pfile.cpp Source/player.cpp Source/plrmsg.cpp Source/sound.cpp Source/spells.cpp Source/tmsg.cpp" +ROOT=`pwd` +CPP_DONE="doom.cpp movie.cpp pfile.cpp player.cpp plrmsg.cpp sound.cpp spells.cpp tmsg.cpp" + +cd ${ROOT}/Source for f in $CPP_DONE; do echo "Formatting $f" clang-format -style=file -i $f @@ -9,7 +12,8 @@ done H_DONE="enums.h structs.h" +cd ${ROOT} for f in $H_DONE; do echo "Formatting $f" - clang-format -style="{BasedOnStyle: webkit, AlignTrailingComments: true, AllowShortBlocksOnASingleLine: true, AllowShortFunctionsOnASingleLine: None, PointerAlignment: Right, AlignConsecutiveAssignments: true}" -i $f + clang-format -style=file -i $f done From e7c7e8de46cdb3b829f4e9b05d13e48b4c5cdf2b Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sat, 6 Oct 2018 20:44:14 +0200 Subject: [PATCH 6/6] Put braces around for loop with empty body. --- Source/tmsg.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index f997297c2..5ede9ca4a 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -32,8 +32,9 @@ void __fastcall tmsg_add(BYTE *pbMsg, BYTE bLen) msg->hdr.dwTime = GetTickCount() + 500; msg->hdr.bLen = bLen; memcpy(msg->body, pbMsg, bLen); - for (tail = &sgpTimedMsgHead; *tail; tail = &(*tail)->hdr.pNext) + for (tail = &sgpTimedMsgHead; *tail; tail = &(*tail)->hdr.pNext) { ; + } *tail = msg; }