Browse Source

♻️ Apply proper types to PlayerStruct

pull/1188/head
Anders Jenbo 5 years ago
parent
commit
17803d5923
  1. 39
      Source/control.cpp
  2. 4
      Source/control.h
  3. 6
      Source/engine.cpp
  4. 2
      Source/engine.h
  5. 4
      Source/items.cpp
  6. 2
      Source/items.h
  7. 48
      Source/loadsave.cpp
  8. 5
      Source/missiles.cpp
  9. 11
      Source/monster.cpp
  10. 40
      Source/msg.cpp
  11. 2
      Source/multi.cpp
  12. 2
      Source/objects.cpp
  13. 2
      Source/pack.cpp
  14. 6
      Source/path.cpp
  15. 2
      Source/path.h
  16. 45
      Source/player.cpp
  17. 386
      Source/player.h
  18. 12
      Source/spells.cpp
  19. 4
      SourceT/player_test.cpp
  20. 2
      SourceX/DiabloUI/selhero.cpp
  21. 4
      SourceX/controls/plrctrls.cpp
  22. 2
      SourceX/miniwin/misc_msg.cpp
  23. 53
      enums.h
  24. 2
      structs.h

39
Source/control.cpp

@ -40,7 +40,7 @@ BOOL pstrjust[4];
int pnumlines;
BOOL pinfoflag;
BOOL talkbtndown[3];
int pSpell;
spell_id pSpell;
char infoclr;
int sgbPlrTalkTbl;
BYTE *pGBoxBuff;
@ -48,7 +48,7 @@ BYTE *pSBkBtnCel;
char tempstr[256];
BOOLEAN whisper[MAX_PLRS];
int sbooktab;
int pSplType;
spell_type pSplType;
int initialDropGoldIndex;
BOOL talkflag;
BYTE *pSBkIconCels;
@ -221,13 +221,13 @@ RECT32 ChrBtnsRect[4] = {
};
/** Maps from spellbook page number and position to spell_id. */
int SpellPages[6][7] = {
spell_id SpellPages[6][7] = {
{ SPL_NULL, SPL_FIREBOLT, SPL_CBOLT, SPL_HBOLT, SPL_HEAL, SPL_HEALOTHER, SPL_FLAME },
{ SPL_RESURRECT, SPL_FIREWALL, SPL_TELEKINESIS, SPL_LIGHTNING, SPL_TOWN, SPL_FLASH, SPL_STONE },
{ SPL_RNDTELEPORT, SPL_MANASHIELD, SPL_ELEMENT, SPL_FIREBALL, SPL_WAVE, SPL_CHAIN, SPL_GUARDIAN },
{ SPL_NOVA, SPL_GOLEM, SPL_TELEPORT, SPL_APOCA, SPL_BONESPIRIT, SPL_FLARE, SPL_ETHEREALIZE },
{ SPL_LIGHTWALL, SPL_IMMOLAT, SPL_WARP, SPL_REFLECT, SPL_BERSERK, SPL_FIRERING, SPL_SEARCH },
{ -1, -1, -1, -1, -1, -1, -1 }
{ SPL_INVALID, SPL_INVALID, SPL_INVALID, SPL_INVALID, SPL_INVALID, SPL_INVALID, SPL_INVALID }
};
#define SPLICONLENGTH 56
@ -337,7 +337,7 @@ static void DrawSpell(CelOutputBuffer out)
void DrawSpellList(CelOutputBuffer out)
{
int i, j, x, y, c, s, t, v, lx, ly, trans;
int x, y, c, s, t, v, lx, ly, trans;
unsigned __int64 mask, spl;
pSpell = SPL_INVALID;
@ -346,7 +346,7 @@ void DrawSpellList(CelOutputBuffer out)
y = PANEL_Y - 17;
ClearPanel();
for (i = 0; i < 4; i++) {
for (Sint32 i = RSPLTYPE_SKILL; i < RSPLTYPE_INVALID; i++) {
switch ((spell_type)i) {
case RSPLTYPE_SKILL:
SetSpellTrans(RSPLTYPE_SKILL);
@ -368,7 +368,8 @@ void DrawSpellList(CelOutputBuffer out)
c = SPLICONLAST + 2;
break;
}
for (spl = 1, j = 1; j < MAX_SPELLS; spl <<= 1, j++) {
Sint32 j = SPL_FIREBOLT;
for (spl = 1; j < MAX_SPELLS; spl <<= 1, j++) {
if (!(mask & spl))
continue;
if (i == RSPLTYPE_SPELL) {
@ -387,8 +388,8 @@ void DrawSpellList(CelOutputBuffer out)
lx = x - BORDER_LEFT;
ly = y - BORDER_TOP - SPLICONLENGTH;
if (MouseX >= lx && MouseX < lx + SPLICONLENGTH && MouseY >= ly && MouseY < ly + SPLICONLENGTH) {
pSpell = j;
pSplType = i;
pSpell = (spell_id)j;
pSplType = (spell_type)i;
if (plr[myplr]._pClass == PC_MONK && j == SPL_SEARCH)
pSplType = RSPLTYPE_SKILL;
DrawSpellCel(out, x, y, pSpellCels, c, SPLICONLENGTH);
@ -1368,7 +1369,7 @@ void DrawChr(CelOutputBuffer out)
{
char col;
char chrstr[64];
int pc, mindam, maxdam;
int mindam, maxdam;
CelDrawTo(out, SCREEN_X, 351 + SCREEN_Y, pChrPanel, 1, SPANEL_WIDTH);
ADD_PlrStringXY(out, 20, 32, 151, plr[myplr]._pName, COL_WHITE);
@ -1542,7 +1543,7 @@ void DrawChr(CelOutputBuffer out)
if (plr[myplr]._pStatPts > 0) {
sprintf(chrstr, "%i", plr[myplr]._pStatPts);
ADD_PlrStringXY(out, 95, 266, 126, chrstr, COL_RED);
pc = plr[myplr]._pClass;
plr_class pc = plr[myplr]._pClass;
if (plr[myplr]._pBaseStr < MaxStats[pc][ATTRIB_STR])
CelDrawTo(out, 137 + SCREEN_X, 159 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41);
if (plr[myplr]._pBaseMag < MaxStats[pc][ATTRIB_MAG])
@ -1602,10 +1603,10 @@ void DrawLevelUpIcon(CelOutputBuffer out)
void CheckChrBtns()
{
int pc, i, x, y;
int i, x, y;
if (!chrbtnactive && plr[myplr]._pStatPts) {
pc = plr[myplr]._pClass;
plr_class pc = plr[myplr]._pClass;
for (i = 0; i < 4; i++) {
switch (i) {
case ATTRIB_STR:
@ -1895,15 +1896,11 @@ void DrawSpellBook(CelOutputBuffer out)
void CheckSBook()
{
int sn;
char st;
unsigned __int64 spl;
if (MouseX >= RIGHT_PANEL + 11 && MouseX < RIGHT_PANEL + 48 && MouseY >= 18 && MouseY < 314) {
sn = SpellPages[sbooktab][(MouseY - 18) / 43];
spl = plr[myplr]._pMemSpells | plr[myplr]._pISpells | plr[myplr]._pAblSpells;
if (sn != -1 && spl & SPELLBIT(sn)) {
st = RSPLTYPE_SPELL;
spell_id sn = SpellPages[sbooktab][(MouseY - 18) / 43];
Uint64 spl = plr[myplr]._pMemSpells | plr[myplr]._pISpells | plr[myplr]._pAblSpells;
if (sn != SPL_INVALID && spl & SPELLBIT(sn)) {
spell_type st = RSPLTYPE_SPELL;
if (plr[myplr]._pISpells & SPELLBIT(sn)) {
st = RSPLTYPE_CHARGES;
}

4
Source/control.h

@ -31,11 +31,11 @@ extern BOOL chrbtnactive;
extern BYTE *pPanelText;
extern int pnumlines;
extern BOOL pinfoflag;
extern int pSpell;
extern spell_id pSpell;
extern char infoclr;
extern char tempstr[256];
extern int sbooktab;
extern int pSplType;
extern spell_type pSplType;
extern int initialDropGoldIndex;
extern BOOL talkflag;
extern BOOL sbookflag;

6
Source/engine.cpp

@ -571,10 +571,10 @@ void DrawHalfTransparentRectTo(CelOutputBuffer out, int sx, int sy, int width, i
}
}
int GetDirection(int x1, int y1, int x2, int y2)
direction GetDirection(int x1, int y1, int x2, int y2)
{
int mx, my;
int md, ny;
int mx, my, ny;
direction md;
mx = x2 - x1;
my = y2 - y1;

2
Source/engine.h

@ -386,7 +386,7 @@ void DrawHalfTransparentRectTo(CelOutputBuffer out, int sx, int sy, int width, i
* @param y2 Tile coordinate
* @return A value from the direction enum
*/
int GetDirection(int x1, int y1, int x2, int y2);
direction GetDirection(int x1, int y1, int x2, int y2);
void SetRndSeed(Sint32 s);
Sint32 AdvanceRndSeed();

4
Source/items.cpp

@ -4193,7 +4193,7 @@ void PrintItemDur(ItemStruct *x)
PrintItemInfo(x);
}
void UseItem(int p, int Mid, int spl)
void UseItem(int p, item_misc_id Mid, spell_id spl)
{
int l, j;
@ -4942,7 +4942,7 @@ void SpawnBoy(int lvl)
int strength = get_max_strength(plr[myplr]._pClass);
int dexterity = get_max_dexterity(plr[myplr]._pClass);
int magic = get_max_magic(plr[myplr]._pClass);
int pc = plr[myplr]._pClass;
plr_class pc = plr[myplr]._pClass;
if (strength < plr[myplr]._pStrength) {
strength = plr[myplr]._pStrength;

2
Source/items.h

@ -313,7 +313,7 @@ void PrintItemPower(char plidx, ItemStruct *x);
void DrawUniqueInfo(CelOutputBuffer out);
void PrintItemDetails(ItemStruct *x);
void PrintItemDur(ItemStruct *x);
void UseItem(int p, int Mid, int spl);
void UseItem(int p, item_misc_id Mid, spell_id spl);
BOOL StoreStatOk(ItemStruct *h);
void SpawnSmith(int lvl);
void SpawnPremium(int pnum);

48
Source/loadsave.cpp

@ -284,17 +284,17 @@ static void LoadPlayer(LoadHelper *file, int p)
{
PlayerStruct *pPlayer = &plr[p];
pPlayer->_pmode = file->nextLE<Sint32>();
pPlayer->_pmode = (PLR_MODE)file->nextLE<Sint32>();
for (int i = 0; i < MAX_PATH_LENGTH; i++) {
pPlayer->walkpath[i] = file->nextLE<Sint8>();
}
pPlayer->plractive = file->nextBool8();
file->skip(2); // Alignment
pPlayer->destAction = file->nextLE<Sint32>();
pPlayer->destAction = (action_id)file->nextLE<Sint32>();
pPlayer->destParam1 = file->nextLE<Sint32>();
pPlayer->destParam2 = file->nextLE<Sint32>();
pPlayer->destParam3 = file->nextLE<Sint32>();
pPlayer->destParam3 = (direction)file->nextLE<Sint32>();
pPlayer->destParam4 = file->nextLE<Sint32>();
pPlayer->plrlevel = file->nextLE<Sint32>();
pPlayer->_px = file->nextLE<Sint32>();
@ -311,7 +311,7 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->_pyoff = file->nextLE<Sint32>();
pPlayer->_pxvel = file->nextLE<Sint32>();
pPlayer->_pyvel = file->nextLE<Sint32>();
pPlayer->_pdir = file->nextLE<Sint32>();
pPlayer->_pdir = (direction)file->nextLE<Sint32>();
file->skip(4); // Unused
pPlayer->_pgfxnum = file->nextLE<Sint32>();
file->skip(4); // Skip pointer _pAnimData
@ -325,18 +325,18 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->_plid = file->nextLE<Sint32>();
pPlayer->_pvid = file->nextLE<Sint32>();
pPlayer->_pSpell = file->nextLE<Sint32>();
pPlayer->_pSplType = file->nextLE<Sint8>();
pPlayer->_pSpell = (spell_id)file->nextLE<Sint32>();
pPlayer->_pSplType = (spell_type)file->nextLE<Sint8>();
pPlayer->_pSplFrom = file->nextLE<Sint8>();
file->skip(2); // Alignment
pPlayer->_pTSpell = file->nextLE<Sint32>();
pPlayer->_pTSplType = file->nextLE<Sint8>();
pPlayer->_pTSpell = (spell_id)file->nextLE<Sint32>();
pPlayer->_pTSplType = (spell_type)file->nextLE<Sint8>();
file->skip(3); // Alignment
pPlayer->_pRSpell = file->nextLE<Sint32>();
pPlayer->_pRSplType = file->nextLE<Sint8>();
pPlayer->_pRSpell = (spell_id)file->nextLE<Sint32>();
pPlayer->_pRSplType = (spell_type)file->nextLE<Sint8>();
file->skip(3); // Alignment
pPlayer->_pSBkSpell = file->nextLE<Sint32>();
pPlayer->_pSBkSplType = file->nextLE<Sint8>();
pPlayer->_pSBkSpell = (spell_id)file->nextLE<Sint32>();
pPlayer->_pSBkSplType = (spell_type)file->nextLE<Sint8>();
for (int i = 0; i < 64; i++)
pPlayer->_pSplLvl[i] = file->nextLE<Sint8>();
file->skip(7); // Alignment
@ -346,18 +346,18 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->_pSpellFlags = file->nextLE<Uint8>();
file->skip(3); // Alignment
for (int i = 0; i < 4; i++)
pPlayer->_pSplHotKey[i] = file->nextLE<Sint32>();
pPlayer->_pSplHotKey[i] = (spell_id)file->nextLE<Sint32>();
for (int i = 0; i < 4; i++)
pPlayer->_pSplTHotKey[i] = file->nextLE<Sint8>();
pPlayer->_pSplTHotKey[i] = (spell_type)file->nextLE<Sint8>();
pPlayer->_pwtype = file->nextLE<Sint32>();
pPlayer->_pwtype = (player_weapon_type)file->nextLE<Sint32>();
pPlayer->_pBlockFlag = file->nextBool8();
pPlayer->_pInvincible = file->nextBool8();
pPlayer->_pLightRad = file->nextLE<Sint8>();
pPlayer->_pLvlChanging = file->nextBool8();
file->nextBytes(pPlayer->_pName, PLR_NAME_LEN);
pPlayer->_pClass = file->nextLE<Sint8>();
pPlayer->_pClass = (plr_class)file->nextLE<Sint8>();
file->skip(3); // Alignment
pPlayer->_pStrength = file->nextLE<Sint32>();
pPlayer->_pBaseStr = file->nextLE<Sint32>();
@ -397,7 +397,7 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->_pInfraFlag = file->nextBool32();
pPlayer->_pVar1 = file->nextLE<Sint32>();
pPlayer->_pVar2 = file->nextLE<Sint32>();
pPlayer->_pVar3 = file->nextLE<Sint32>();
pPlayer->_pVar3 = (direction)file->nextLE<Sint32>();
pPlayer->_pVar4 = file->nextLE<Sint32>();
pPlayer->_pVar5 = file->nextLE<Sint32>();
pPlayer->_pVar6 = file->nextLE<Sint32>();
@ -458,7 +458,7 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->_pIFlags = file->nextLE<Sint32>();
pPlayer->_pIGetHit = file->nextLE<Sint32>();
pPlayer->_pISplLvlAdd = file->nextLE<Sint8>();
pPlayer->_pISplCost = file->nextLE<Sint8>();
file->skip(1); // Unused
file->skip(2); // Alignment
pPlayer->_pISplDur = file->nextLE<Sint32>();
pPlayer->_pIEnAc = file->nextLE<Sint32>();
@ -466,7 +466,7 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->_pIFMaxDam = file->nextLE<Sint32>();
pPlayer->_pILMinDam = file->nextLE<Sint32>();
pPlayer->_pILMaxDam = file->nextLE<Sint32>();
pPlayer->_pOilType = file->nextLE<Sint32>();
pPlayer->_pOilType = (item_misc_id)file->nextLE<Sint32>();
pPlayer->pTownWarps = file->nextLE<Uint8>();
pPlayer->pDungMsgs = file->nextLE<Uint8>();
pPlayer->pLvlLoad = file->nextLE<Uint8>();
@ -884,13 +884,13 @@ void LoadHotkeys()
const size_t nHotkeySpells = sizeof(plr[myplr]._pSplTHotKey) / sizeof(plr[myplr]._pSplTHotKey[0]);
for (size_t i = 0; i < nHotkeyTypes; i++) {
plr[myplr]._pSplHotKey[i] = file.nextLE<Sint32>();
plr[myplr]._pSplHotKey[i] = (spell_id)file.nextLE<Sint32>();
}
for (size_t i = 0; i < nHotkeySpells; i++) {
plr[myplr]._pSplTHotKey[i] = file.nextLE<Sint8>();
plr[myplr]._pSplTHotKey[i] = (spell_type)file.nextLE<Sint8>();
}
plr[myplr]._pRSpell = file.nextLE<Sint32>();
plr[myplr]._pRSplType = file.nextLE<Sint8>();
plr[myplr]._pRSpell = (spell_id)file.nextLE<Sint32>();
plr[myplr]._pRSplType = (spell_type)file.nextLE<Sint8>();
}
void SaveHotkeys()
@ -1380,7 +1380,7 @@ static void SavePlayer(SaveHelper *file, int p)
file->writeLE<Sint32>(pPlayer->_pIGetHit);
file->writeLE<Sint8>(pPlayer->_pISplLvlAdd);
file->writeLE<Sint8>(pPlayer->_pISplCost);
file->skip(1); // Unused
file->skip(2); // Alignment
file->writeLE<Sint32>(pPlayer->_pISplDur);
file->writeLE<Sint32>(pPlayer->_pIEnAc);

5
Source/missiles.cpp

@ -809,13 +809,12 @@ BOOL PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, BOOLEA
dam = 64;
}
if ((resper <= 0 || gbIsHellfire) && blk < blkper) {
direction dir = plr[pnum]._pdir;
if (m != -1) {
tac = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[m]._mx, monster[m]._my);
} else {
tac = plr[pnum]._pdir;
}
*blocked = true;
StartPlrBlock(pnum, tac);
StartPlrBlock(pnum, dir);
return TRUE;
}
if (resper > 0) {

11
Source/monster.cpp

@ -26,8 +26,6 @@ int monstimgtot;
int uniquetrans;
int nummtypes;
/** Maps from walking path step to facing direction. */
const char plr2monst[9] = { 0, 5, 3, 7, 1, 4, 6, 0, 2 };
/** Maps from monster intelligence factor to missile type. */
const BYTE counsmiss[4] = { MIS_FIREBOLT, MIS_CBOLT, MIS_LIGHTCTRL, MIS_FIREBALL };
@ -2179,7 +2177,7 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
if (hper >= hit)
return;
if (blkper < blk) {
dir = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mx, monster[i]._my);
direction dir = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mx, monster[i]._my);
StartPlrBlock(pnum, dir);
if (pnum == myplr && plr[pnum].wReflections > 0) {
plr[pnum].wReflections--;
@ -2899,10 +2897,13 @@ BOOL M_CallWalk(int i, int md)
BOOL M_PathWalk(int i)
{
char path[MAX_PATH_LENGTH];
Sint8 path[MAX_PATH_LENGTH];
BOOL(*Check)
(int, int, int);
/** Maps from walking path step to facing direction. */
const Sint8 plr2monst[9] = { 0, 5, 3, 7, 1, 4, 6, 0, 2 };
commitment((DWORD)i < MAXMONSTERS, i);
Check = PosOkMonst3;
@ -2910,7 +2911,7 @@ BOOL M_PathWalk(int i)
Check = PosOkMonst;
if (FindPath(Check, i, monster[i]._mx, monster[i]._my, monster[i]._menemyx, monster[i]._menemyy, path)) {
M_CallWalk(i, plr2monst[path[0]]); /* plr2monst is local */
M_CallWalk(i, plr2monst[path[0]]);
return TRUE;
}

40
Source/msg.cpp

@ -1354,9 +1354,9 @@ static DWORD On_SBSPELL(TCmd *pCmd, int pnum)
TCmdParam1 *p = (TCmdParam1 *)pCmd;
if (gbBufferMsgs != 1) {
int spell = p->wParam1;
spell_id spell = (spell_id)p->wParam1;
if (currlevel != 0 || spelldata[spell].sTownSpell) {
plr[pnum]._pSpell = p->wParam1;
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pSBkSplType;
plr[pnum]._pSplFrom = 1;
plr[pnum].destAction = ACTION_SPELL;
@ -1620,15 +1620,15 @@ static DWORD On_SPELLXYD(TCmd *pCmd, int pnum)
TCmdLocParam3 *p = (TCmdLocParam3 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
int spell = p->wParam1;
spell_id spell = (spell_id)p->wParam1;
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
plr[pnum].destAction = ACTION_SPELLWALL;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
plr[pnum].destParam3 = p->wParam2;
plr[pnum].destParam3 = (direction)p->wParam2;
plr[pnum].destParam4 = p->wParam3;
plr[pnum]._pSpell = p->wParam1;
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pRSplType;
plr[pnum]._pSplFrom = 0;
} else
@ -1643,14 +1643,14 @@ static DWORD On_SPELLXY(TCmd *pCmd, int pnum)
TCmdLocParam2 *p = (TCmdLocParam2 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
int spell = p->wParam1;
spell_id spell = (spell_id)p->wParam1;
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
plr[pnum].destAction = ACTION_SPELL;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
plr[pnum].destParam3 = p->wParam2;
plr[pnum]._pSpell = p->wParam1;
plr[pnum].destParam3 = (direction)p->wParam2;
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pRSplType;
plr[pnum]._pSplFrom = 0;
} else
@ -1665,14 +1665,14 @@ static DWORD On_TSPELLXY(TCmd *pCmd, int pnum)
TCmdLocParam2 *p = (TCmdLocParam2 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
int spell = p->wParam1;
spell_id spell = (spell_id)p->wParam1;
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
plr[pnum].destAction = ACTION_SPELL;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
plr[pnum].destParam3 = p->wParam2;
plr[pnum]._pSpell = p->wParam1;
plr[pnum].destParam3 = (direction)p->wParam2;
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pTSplType;
plr[pnum]._pSplFrom = 2;
} else
@ -1786,13 +1786,13 @@ static DWORD On_SPELLID(TCmd *pCmd, int pnum)
TCmdParam3 *p = (TCmdParam3 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
int spell = p->wParam2;
spell_id spell = (spell_id)p->wParam2;
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
plr[pnum].destAction = ACTION_SPELLMON;
plr[pnum].destParam1 = p->wParam1;
plr[pnum].destParam2 = p->wParam3;
plr[pnum]._pSpell = p->wParam2;
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pRSplType;
plr[pnum]._pSplFrom = 0;
} else
@ -1807,13 +1807,13 @@ static DWORD On_SPELLPID(TCmd *pCmd, int pnum)
TCmdParam3 *p = (TCmdParam3 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
int spell = p->wParam2;
spell_id spell = (spell_id)p->wParam2;
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
plr[pnum].destAction = ACTION_SPELLPLR;
plr[pnum].destParam1 = p->wParam1;
plr[pnum].destParam2 = p->wParam3;
plr[pnum]._pSpell = p->wParam2;
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pRSplType;
plr[pnum]._pSplFrom = 0;
} else
@ -1828,13 +1828,13 @@ static DWORD On_TSPELLID(TCmd *pCmd, int pnum)
TCmdParam3 *p = (TCmdParam3 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
int spell = p->wParam2;
spell_id spell = (spell_id)p->wParam2;
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
plr[pnum].destAction = ACTION_SPELLMON;
plr[pnum].destParam1 = p->wParam1;
plr[pnum].destParam2 = p->wParam3;
plr[pnum]._pSpell = p->wParam2;
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pTSplType;
plr[pnum]._pSplFrom = 2;
} else
@ -1849,13 +1849,13 @@ static DWORD On_TSPELLPID(TCmd *pCmd, int pnum)
TCmdParam3 *p = (TCmdParam3 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
int spell = p->wParam2;
spell_id spell = (spell_id)p->wParam2;
if (currlevel != 0 || spelldata[spell].sTownSpell) {
ClrPlrPath(pnum);
plr[pnum].destAction = ACTION_SPELLPLR;
plr[pnum].destParam1 = p->wParam1;
plr[pnum].destParam2 = p->wParam3;
plr[pnum]._pSpell = p->wParam2;
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pTSplType;
plr[pnum]._pSplFrom = 2;
} else
@ -2215,7 +2215,7 @@ static DWORD On_PLAYER_JOINLEVEL(TCmd *pCmd, int pnum)
LoadPlrGFX(pnum, PFILE_STAND);
SyncInitPlr(pnum);
if ((plr[pnum]._pHitPoints >> 6) > 0)
StartStand(pnum, 0);
StartStand(pnum, DIR_S);
else {
plr[pnum]._pgfxnum = 0;
LoadPlrGFX(pnum, PFILE_DEATH);

2
Source/multi.cpp

@ -924,7 +924,7 @@ void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv)
if (plr[pnum].plrlevel == currlevel) {
if (plr[pnum]._pHitPoints >> 6 > 0) {
StartStand(pnum, 0);
StartStand(pnum, DIR_S);
} else {
plr[pnum]._pgfxnum = 0;
LoadPlrGFX(pnum, PFILE_DEATH);

2
Source/objects.cpp

@ -1870,7 +1870,7 @@ void Obj_Circle(int i)
track_repeat_walk(FALSE);
sgbMouseDown = CLICK_NONE;
ClrPlrPath(myplr);
StartStand(myplr, 0);
StartStand(myplr, DIR_S);
}
} else {
if (object[i]._otype == OBJ_MCIRCLE1)

2
Source/pack.cpp

@ -209,7 +209,7 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok)
ClrPlrPath(pnum);
pPlayer->destAction = ACTION_NONE;
strcpy(pPlayer->_pName, pPack->pName);
pPlayer->_pClass = pPack->pClass;
pPlayer->_pClass = (plr_class)pPack->pClass;
InitPlayer(pnum, TRUE);
pPlayer->_pBaseStr = pPack->pBaseStr;
pPlayer->_pStrength = pPack->pBaseStr;

6
Source/path.cpp

@ -16,7 +16,7 @@ int gdwCurNodes;
* for reconstructing the path after the A* search is done. The longest
* possible path is actually 24 steps, even though we can fit 25
*/
int pnode_vals[MAX_PATH_LENGTH];
Sint8 pnode_vals[MAX_PATH_LENGTH];
/** A linked list of all visited nodes */
PATHNODE *pnode_ptr;
/** A stack for recursively searching nodes */
@ -39,14 +39,14 @@ const char pathydir[8] = { -1, 1, -1, 1, 0, -1, 0, 1 };
* dy 0|2 0 3
* 1|8 4 7
*/
char path_directions[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 };
Sint8 path_directions[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 };
/**
* find the shortest path from (sx,sy) to (dx,dy), using PosOk(PosOkArg,x,y) to
* check that each step is a valid position. Store the step directions (see
* path_directions) in path, which must have room for 24 steps
*/
int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path)
int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, Sint8 path[MAX_PATH_LENGTH])
{
PATHNODE *path_start, *next_node, *current;
int path_length, i;

2
Source/path.h

@ -23,7 +23,7 @@ typedef struct PATHNODE {
struct PATHNODE *NextNode;
} PATHNODE;
int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path);
int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, Sint8 path[MAX_PATH_LENGTH]);
int path_get_h_cost(int sx, int sy, int dx, int dy);
PATHNODE *GetNextPath();
BOOL path_solid_pieces(PATHNODE *pPath, int dx, int dy);

45
Source/player.cpp

@ -513,7 +513,7 @@ void ClearPlrPVars(int pnum)
plr[pnum]._pVar1 = 0;
plr[pnum]._pVar2 = 0;
plr[pnum]._pVar3 = 0;
plr[pnum]._pVar3 = DIR_S;
plr[pnum]._pVar4 = 0;
plr[pnum]._pVar5 = 0;
plr[pnum]._pVar6 = 0;
@ -523,7 +523,7 @@ void ClearPlrPVars(int pnum)
void SetPlrAnims(int pnum)
{
int pc, gn;
int gn;
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("SetPlrAnims: illegal player %d", pnum);
@ -537,7 +537,7 @@ void SetPlrAnims(int pnum)
plr[pnum]._pDWidth = 128;
plr[pnum]._pBWidth = 96;
pc = plr[pnum]._pClass;
plr_class pc = plr[pnum]._pClass;
if (leveltype == DTYPE_TOWN) {
plr[pnum]._pNFrames = PlrGFXAnimLens[pc][7];
@ -658,7 +658,7 @@ void SetPlrAnims(int pnum)
/**
* @param c plr_classes value
*/
void CreatePlayer(int pnum, char c)
void CreatePlayer(int pnum, plr_class c)
{
char val;
int hp, mana;
@ -781,7 +781,7 @@ void CreatePlayer(int pnum, char c)
// 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;
plr[pnum]._pSplHotKey[i] = SPL_INVALID;
}
if (c == PC_WARRIOR) {
@ -821,9 +821,7 @@ void CreatePlayer(int pnum, char c)
int CalcStatDiff(int pnum)
{
int c;
c = plr[pnum]._pClass;
plr_class c = plr[pnum]._pClass;
return MaxStats[c][ATTRIB_STR]
- plr[pnum]._pBaseStr
+ MaxStats[c][ATTRIB_MAG]
@ -1179,7 +1177,7 @@ void SetPlayerOld(int pnum)
plr[pnum]._poldy = plr[pnum]._py;
}
void FixPlayerLocation(int pnum, int bDir)
void FixPlayerLocation(int pnum, direction bDir)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("FixPlayerLocation: illegal player %d", pnum);
@ -1203,7 +1201,7 @@ void FixPlayerLocation(int pnum, int bDir)
ChangeVisionXY(plr[pnum]._pvid, plr[pnum]._px, plr[pnum]._py);
}
void StartStand(int pnum, int dir)
void StartStand(int pnum, direction dir)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("StartStand: illegal player %d", pnum);
@ -1327,7 +1325,7 @@ void PM_ChangeOffset(int pnum)
/**
* @brief Start moving a player to a new tile
*/
void StartWalk(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, int EndDir, int sdir, int variant)
void StartWalk(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, direction EndDir, int sdir, int variant)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("StartWalk: illegal player %d", pnum);
@ -1447,7 +1445,7 @@ void StartWalk(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int y
}
}
void StartAttack(int pnum, int d)
void StartAttack(int pnum, direction d)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("StartAttack: illegal player %d", pnum);
@ -1468,7 +1466,7 @@ void StartAttack(int pnum, int d)
SetPlayerOld(pnum);
}
void StartRangeAttack(int pnum, int d, int cx, int cy)
void StartRangeAttack(int pnum, direction d, int cx, int cy)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("StartRangeAttack: illegal player %d", pnum);
@ -1491,7 +1489,7 @@ void StartRangeAttack(int pnum, int d, int cx, int cy)
plr[pnum]._pVar2 = cy;
}
void StartPlrBlock(int pnum, int dir)
void StartPlrBlock(int pnum, direction dir)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("StartPlrBlock: illegal player %d", pnum);
@ -1514,7 +1512,7 @@ void StartPlrBlock(int pnum, int dir)
SetPlayerOld(pnum);
}
void StartSpell(int pnum, int d, int cx, int cy)
void StartSpell(int pnum, direction d, int cx, int cy)
{
if ((DWORD)pnum >= MAX_PLRS)
app_fatal("StartSpell: illegal player %d", pnum);
@ -1609,8 +1607,6 @@ void RemovePlrFromMap(int pnum)
void StartPlrHit(int pnum, int dam, BOOL forcehit)
{
int pd;
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("StartPlrHit: illegal player %d", pnum);
}
@ -1643,7 +1639,7 @@ void StartPlrHit(int pnum, int dam, BOOL forcehit)
return;
}
pd = plr[pnum]._pdir;
direction pd = plr[pnum]._pdir;
if (!(plr[pnum]._pGFXLoad & PFILE_HIT)) {
LoadPlrGFX(pnum, PFILE_HIT);
@ -2223,7 +2219,7 @@ bool PM_DoWalk(int pnum, int variant)
if (plr[pnum].walkpath[0] != WALK_NONE) {
StartWalkStand(pnum);
} else {
StartStand(pnum, plr[pnum]._pVar3);
StartStand(pnum, (direction)plr[pnum]._pVar3);
}
ClearPlrPVars(pnum);
@ -2581,7 +2577,7 @@ BOOL PlrHitMonst(int pnum, int m)
BOOL PlrHitPlr(int pnum, char p)
{
BOOL rv;
int hit, hper, blk, blkper, dir, mind, maxd, dam, lvl, skdam, tac;
int hit, hper, blk, blkper, mind, maxd, dam, lvl, skdam, tac;
if ((DWORD)p >= MAX_PLRS) {
app_fatal("PlrHitPlr: illegal target player %d", p);
@ -2632,7 +2628,7 @@ BOOL PlrHitPlr(int pnum, char p)
if (hit < hper) {
if (blk < blkper) {
dir = GetDirection(plr[p]._px, plr[p]._py, plr[pnum]._px, plr[pnum]._py);
direction dir = GetDirection(plr[p]._px, plr[p]._py, plr[pnum]._px, plr[pnum]._py);
StartPlrBlock(p, dir);
} else {
mind = plr[pnum]._pIMinDam;
@ -3071,7 +3067,7 @@ BOOL PM_DoNewLvl(int pnum)
void CheckNewPath(int pnum)
{
int i, x, y, d;
int i, x, y;
int xvel3, xvel, yvel;
if ((DWORD)pnum >= MAX_PLRS) {
@ -3088,6 +3084,7 @@ void CheckNewPath(int pnum)
MakePlrPath(pnum, plr[i]._pfutx, plr[i]._pfuty, FALSE);
}
direction d;
if (plr[pnum].walkpath[0] != WALK_NONE) {
if (plr[pnum]._pmode == PM_STAND) {
if (pnum == myplr) {
@ -3414,7 +3411,7 @@ BOOL PlrDeathModeOK(int p)
void ValidatePlayer()
{
__int64 msk;
int gt, pc, i, b;
int gt, i, b;
msk = 0;
@ -3439,7 +3436,7 @@ void ValidatePlayer()
if (gt != plr[myplr]._pGold)
plr[myplr]._pGold = gt;
pc = plr[myplr]._pClass;
plr_class pc = plr[myplr]._pClass;
if (plr[myplr]._pBaseStr > MaxStats[pc][ATTRIB_STR]) {
plr[myplr]._pBaseStr = MaxStats[pc][ATTRIB_STR];
}

386
Source/player.h

@ -8,185 +8,223 @@
DEVILUTION_BEGIN_NAMESPACE
typedef enum PLR_MODE {
PM_STAND,
PM_WALK, //Movement towards N, NW, or NE
PM_WALK2, //Movement towards S, SW, or SE
PM_WALK3, //Movement towards W or E
PM_ATTACK,
PM_RATTACK,
PM_BLOCK,
PM_GOTHIT,
PM_DEATH,
PM_SPELL,
PM_NEWLVL,
PM_QUIT,
} PLR_MODE;
typedef enum action_id {
// clang-format off
ACTION_WALK = -2, // Automatic walk when using gamepad
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,
// clang-format on
} action_id;
typedef enum player_weapon_type {
WT_MELEE,
WT_RANGED,
} player_weapon_type;
typedef struct PlayerStruct {
int _pmode;
char walkpath[MAX_PATH_LENGTH];
BOOLEAN plractive;
int destAction;
int destParam1;
int destParam2;
int destParam3;
int destParam4;
int plrlevel;
int _px; // Tile X-position of player
int _py; // Tile Y-position of player
int _pfutx; // Future tile X-position of player. Set at start of walking animation
int _pfuty; // Future tile Y-position of player. Set at start of walking animation
int _ptargx; // Target tile X-position for player movment. Set during pathfinding
int _ptargy; // Target tile Y-position for player movment. Set during pathfinding
int _pownerx; // Tile X-position of player. Set via network on player input
int _pownery; // Tile X-position of player. Set via network on player input
int _poldx; // Most recent X-position in dPlayer.
int _poldy; // Most recent Y-position in dPlayer.
int _pxoff; // Player sprite's pixel X-offset from tile.
int _pyoff; // Player sprite's pixel Y-offset from tile.
int _pxvel; // Pixel X-velocity while walking. Indirectly applied to _pxoff via _pvar6
int _pyvel; // Pixel Y-velocity while walking. Indirectly applied to _pyoff via _pvar7
int _pdir; // Direction faced by player (direction enum)
int _pgfxnum; // Bitmask indicating what variant of the sprite the player is using. Lower byte define weapon (anim_weapon_id) and higher values define armour (starting with anim_armor_id)
unsigned char *_pAnimData;
int _pAnimDelay; // Tick length of each frame in the current animation
int _pAnimCnt; // Increases by one each game tick, counting how close we are to _pAnimDelay
int _pAnimLen; // Number of frames in current animation
int _pAnimFrame; // Current frame of animation.
int _pAnimWidth;
int _pAnimWidth2;
int _peflag;
int _plid;
int _pvid;
int _pSpell;
char _pSplType;
char _pSplFrom;
int _pTSpell;
char _pTSplType;
int _pRSpell;
PLR_MODE _pmode;
Sint8 walkpath[MAX_PATH_LENGTH];
bool plractive;
action_id destAction;
Sint32 destParam1;
Sint32 destParam2;
direction destParam3;
Sint32 destParam4;
Sint32 plrlevel;
Sint32 _px; // Tile X-position of player
Sint32 _py; // Tile Y-position of player
Sint32 _pfutx; // Future tile X-position of player. Set at start of walking animation
Sint32 _pfuty; // Future tile Y-position of player. Set at start of walking animation
Sint32 _ptargx; // Target tile X-position for player movment. Set during pathfinding
Sint32 _ptargy; // Target tile Y-position for player movment. Set during pathfinding
Sint32 _pownerx; // Tile X-position of player. Set via network on player input
Sint32 _pownery; // Tile X-position of player. Set via network on player input
Sint32 _poldx; // Most recent X-position in dPlayer.
Sint32 _poldy; // Most recent Y-position in dPlayer.
Sint32 _pxoff; // Player sprite's pixel X-offset from tile.
Sint32 _pyoff; // Player sprite's pixel Y-offset from tile.
Sint32 _pxvel; // Pixel X-velocity while walking. Indirectly applied to _pxoff via _pvar6
Sint32 _pyvel; // Pixel Y-velocity while walking. Indirectly applied to _pyoff via _pvar7
direction _pdir; // Direction faced by player (direction enum)
Sint32 _pgfxnum; // Bitmask indicating what variant of the sprite the player is using. Lower byte define weapon (anim_weapon_id) and higher values define armour (starting with anim_armor_id)
Uint8 *_pAnimData;
Sint32 _pAnimDelay; // Tick length of each frame in the current animation
Sint32 _pAnimCnt; // Increases by one each game tick, counting how close we are to _pAnimDelay
Sint32 _pAnimLen; // Number of frames in current animation
Sint32 _pAnimFrame; // Current frame of animation.
Sint32 _pAnimWidth;
Sint32 _pAnimWidth2;
Sint32 _plid;
Sint32 _pvid;
spell_id _pSpell;
spell_type _pSplType;
Sint8 _pSplFrom; // TODO Create enum
spell_id _pTSpell;
spell_type _pTSplType;
spell_id _pRSpell;
// enum spell_type
char _pRSplType;
int _pSBkSpell;
char _pSBkSplType;
char _pSplLvl[64];
uint64_t _pMemSpells; // Bitmask of learned spells
uint64_t _pAblSpells; // Bitmask of abilities
uint64_t _pScrlSpells; // Bitmask of spells available via scrolls
UCHAR _pSpellFlags;
int _pSplHotKey[4];
char _pSplTHotKey[4];
int _pwtype;
BOOLEAN _pBlockFlag;
BOOLEAN _pInvincible;
char _pLightRad;
BOOLEAN _pLvlChanging; // True when the player is transitioning between levels
spell_type _pRSplType;
spell_id _pSBkSpell;
spell_type _pSBkSplType;
Sint8 _pSplLvl[64];
Uint64 _pMemSpells; // Bitmask of learned spells
Uint64 _pAblSpells; // Bitmask of abilities
Uint64 _pScrlSpells; // Bitmask of spells available via scrolls
Uint8 _pSpellFlags;
spell_id _pSplHotKey[4];
spell_type _pSplTHotKey[4];
player_weapon_type _pwtype;
bool _pBlockFlag;
bool _pInvincible;
Sint8 _pLightRad;
bool _pLvlChanging; // True when the player is transitioning between levels
char _pName[PLR_NAME_LEN];
// 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;
BOOL _pInfraFlag;
int _pVar1; // Used for referring to X-position of player when finishing moving one tile (also used to define target coordinates for spells and ranged attacks)
int _pVar2; // Used for referring to Y-position of player when finishing moving one tile (also used to define target coordinates for spells and ranged attacks)
int _pVar3; // Player's direction when ending movement. Also used for casting direction of SPL_FIREWALL.
int _pVar4; // Used for storing X-position of a tile which should have its BFLAG_PLAYERLR flag removed after walking. When starting to walk the game places the player in the dPlayer array -1 in the Y coordinate, and uses BFLAG_PLAYERLR to check if it should be using -1 to the Y coordinate when rendering the player (also used for storing the level of a spell when the player casts it)
int _pVar5; // Used for storing Y-position of a tile which should have its BFLAG_PLAYERLR flag removed after walking. When starting to walk the game places the player in the dPlayer array -1 in the Y coordinate, and uses BFLAG_PLAYERLR to check if it should be using -1 to the Y coordinate when rendering the player (also used for storing the level of a spell when the player casts it)
int _pVar6; // Same as _pxoff but contains the value in a higher range
int _pVar7; // Same as _pyoff but contains the value in a higher range
int _pVar8; // Used for counting how close we are to reaching the next tile when walking (usually counts to 8, which is equal to the walk animation length). Also used for stalling the appearance of the options screen after dying in singleplayer
BOOLEAN _pLvlVisited[NUMLEVELS];
BOOLEAN _pSLvlVisited[NUMLEVELS]; // only 10 used
int _pGFXLoad;
unsigned char *_pNAnim[8]; // Stand animations
int _pNFrames;
int _pNWidth;
unsigned char *_pWAnim[8]; // Walk animations
int _pWFrames;
int _pWWidth;
unsigned char *_pAAnim[8]; // Attack animations
int _pAFrames;
int _pAWidth;
int _pAFNum;
unsigned char *_pLAnim[8]; // Lightning spell cast animations
unsigned char *_pFAnim[8]; // Fire spell cast animations
unsigned char *_pTAnim[8]; // Generic spell cast animations
int _pSFrames;
int _pSWidth;
int _pSFNum;
unsigned char *_pHAnim[8]; // Getting hit animations
int _pHFrames;
int _pHWidth;
unsigned char *_pDAnim[8]; // Death animations
int _pDFrames;
int _pDWidth;
unsigned char *_pBAnim[8]; // Block animations
int _pBFrames;
int _pBWidth;
plr_class _pClass;
Sint32 _pStrength;
Sint32 _pBaseStr;
Sint32 _pMagic;
Sint32 _pBaseMag;
Sint32 _pDexterity;
Sint32 _pBaseDex;
Sint32 _pVitality;
Sint32 _pBaseVit;
Sint32 _pStatPts;
Sint32 _pDamageMod;
Sint32 _pBaseToBlk;
Sint32 _pHPBase;
Sint32 _pMaxHPBase;
Sint32 _pHitPoints;
Sint32 _pMaxHP;
Sint32 _pHPPer;
Sint32 _pManaBase;
Sint32 _pMaxManaBase;
Sint32 _pMana;
Sint32 _pMaxMana;
Sint32 _pManaPer;
Sint8 _pLevel;
Sint8 _pMaxLvl;
Sint32 _pExperience;
Sint32 _pMaxExp;
Sint32 _pNextExper;
Sint8 _pArmorClass;
Sint8 _pMagResist;
Sint8 _pFireResist;
Sint8 _pLghtResist;
Sint32 _pGold;
bool _pInfraFlag;
Sint32 _pVar1; // Used for referring to X-position of player when finishing moving one tile (also used to define target coordinates for spells and ranged attacks)
Sint32 _pVar2; // Used for referring to Y-position of player when finishing moving one tile (also used to define target coordinates for spells and ranged attacks)
direction _pVar3; // Player's direction when ending movement. Also used for casting direction of SPL_FIREWALL.
Sint32 _pVar4; // Used for storing X-position of a tile which should have its BFLAG_PLAYERLR flag removed after walking. When starting to walk the game places the player in the dPlayer array -1 in the Y coordinate, and uses BFLAG_PLAYERLR to check if it should be using -1 to the Y coordinate when rendering the player (also used for storing the level of a spell when the player casts it)
Sint32 _pVar5; // Used for storing Y-position of a tile which should have its BFLAG_PLAYERLR flag removed after walking. When starting to walk the game places the player in the dPlayer array -1 in the Y coordinate, and uses BFLAG_PLAYERLR to check if it should be using -1 to the Y coordinate when rendering the player (also used for storing the level of a spell when the player casts it)
Sint32 _pVar6; // Same as _pxoff but contains the value in a higher range
Sint32 _pVar7; // Same as _pyoff but contains the value in a higher range
Sint32 _pVar8; // Used for counting how close we are to reaching the next tile when walking (usually counts to 8, which is equal to the walk animation length). Also used for stalling the appearance of the options screen after dying in singleplayer
bool _pLvlVisited[NUMLEVELS];
bool _pSLvlVisited[NUMLEVELS]; // only 10 used
/** Using player_graphic as bitflags */
Sint32 _pGFXLoad;
Uint8 *_pNAnim[8]; // Stand animations
Sint32 _pNFrames;
Sint32 _pNWidth;
Uint8 *_pWAnim[8]; // Walk animations
Sint32 _pWFrames;
Sint32 _pWWidth;
Uint8 *_pAAnim[8]; // Attack animations
Sint32 _pAFrames;
Sint32 _pAWidth;
Sint32 _pAFNum;
Uint8 *_pLAnim[8]; // Lightning spell cast animations
Uint8 *_pFAnim[8]; // Fire spell cast animations
Uint8 *_pTAnim[8]; // Generic spell cast animations
Sint32 _pSFrames;
Sint32 _pSWidth;
Sint32 _pSFNum;
Uint8 *_pHAnim[8]; // Getting hit animations
Sint32 _pHFrames;
Sint32 _pHWidth;
Uint8 *_pDAnim[8]; // Death animations
Sint32 _pDFrames;
Sint32 _pDWidth;
Uint8 *_pBAnim[8]; // Block animations
Sint32 _pBFrames;
Sint32 _pBWidth;
ItemStruct InvBody[NUM_INVLOC];
ItemStruct InvList[NUM_INV_GRID_ELEM];
int _pNumInv;
char InvGrid[NUM_INV_GRID_ELEM];
Sint32 _pNumInv;
Sint8 InvGrid[NUM_INV_GRID_ELEM];
ItemStruct SpdList[MAXBELTITEMS];
ItemStruct HoldItem;
int _pIMinDam;
int _pIMaxDam;
int _pIAC;
int _pIBonusDam;
int _pIBonusToHit;
int _pIBonusAC;
int _pIBonusDamMod;
uint64_t _pISpells; // Bitmask of staff spell
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;
Sint32 _pIMinDam;
Sint32 _pIMaxDam;
Sint32 _pIAC;
Sint32 _pIBonusDam;
Sint32 _pIBonusToHit;
Sint32 _pIBonusAC;
Sint32 _pIBonusDamMod;
/** Bitmask of staff spell */
Uint64 _pISpells;
/** Bitmask using item_special_effect */
Sint32 _pIFlags;
Sint32 _pIGetHit;
Sint8 _pISplLvlAdd;
Sint32 _pISplDur;
Sint32 _pIEnAc;
Sint32 _pIFMinDam;
Sint32 _pIFMaxDam;
Sint32 _pILMinDam;
Sint32 _pILMaxDam;
item_misc_id _pOilType;
Uint8 pTownWarps;
Uint8 pDungMsgs;
Uint8 pLvlLoad;
bool pBattleNet;
BOOLEAN pManaShield;
unsigned char pDungMsgs2;
BOOLEAN pOriginalCathedral;
WORD wReflections;
DWORD pDiabloKillLevel;
bool pManaShield;
Uint8 pDungMsgs2;
bool pOriginalCathedral;
Uint16 wReflections;
Uint32 pDiabloKillLevel;
Uint32 pDifficulty;
Uint32 pDamAcFlags;
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;
Uint8 *_pNData;
Uint8 *_pWData;
Uint8 *_pAData;
Uint8 *_pLData;
Uint8 *_pFData;
Uint8 *_pTData;
Uint8 *_pHData;
Uint8 *_pDData;
Uint8 *_pBData;
} PlayerStruct;
#ifdef __cplusplus
@ -204,7 +242,7 @@ void InitPlrGFXMem(int pnum);
void FreePlayerGFX(int pnum);
void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width);
void SetPlrAnims(int pnum);
void CreatePlayer(int pnum, char c);
void CreatePlayer(int pnum, plr_class c);
int CalcStatDiff(int pnum);
#ifdef _DEBUG
void NextPlrLevel(int pnum);
@ -217,10 +255,10 @@ BOOL SolidLoc(int x, int y);
void PlrClrTrans(int x, int y);
void PlrDoTrans(int x, int y);
void SetPlayerOld(int pnum);
void FixPlayerLocation(int pnum, int bDir);
void StartStand(int pnum, int dir);
void StartAttack(int pnum, int d);
void StartPlrBlock(int pnum, int dir);
void FixPlayerLocation(int pnum, direction bDir);
void StartStand(int pnum, direction dir);
void StartAttack(int pnum, direction d);
void StartPlrBlock(int pnum, direction dir);
void FixPlrWalkTags(int pnum);
void RemovePlrFromMap(int pnum);
void StartPlrHit(int pnum, int dam, BOOL forcehit);

12
Source/spells.cpp

@ -53,7 +53,7 @@ int GetManaAmount(int id, int sn)
ma = spelldata[sn].sMinMana << 6;
}
return ma * (100 - plr[id]._pISplCost) / 100;
return ma;
}
void UseMana(int id, int sn)
@ -133,15 +133,13 @@ bool IsReadiedSpellValid(const PlayerStruct &player)
*/
void ClearReadiedSpell(PlayerStruct &player)
{
int &readiedSpell = player._pRSpell;
if (readiedSpell != SPL_INVALID) {
readiedSpell = SPL_INVALID;
if (player._pRSpell != SPL_INVALID) {
player._pRSpell = SPL_INVALID;
force_redraw = 255;
}
char &readiedSpellType = player._pRSplType;
if (readiedSpellType != RSPLTYPE_INVALID) {
readiedSpellType = RSPLTYPE_INVALID;
if (player._pRSplType != RSPLTYPE_INVALID) {
player._pRSplType = RSPLTYPE_INVALID;
force_redraw = 255;
}
}

4
SourceT/player_test.cpp

@ -14,13 +14,13 @@ int RunBlockTest(bool hellfire, int frames, int flags)
dvl::plr[pnum]._pHFrames = frames;
dvl::plr[pnum]._pVar8 = 1;
dvl::plr[pnum]._pIFlags = flags;
dvl::plr[pnum]._pmode = 7;
dvl::plr[pnum]._pmode = dvl::PM_GOTHIT;
dvl::plr[pnum]._pGFXLoad = -1;
int i = 1;
for (; i < 100; i++) {
dvl::PM_DoGotHit(pnum);
if (dvl::plr[pnum]._pmode != 7)
if (dvl::plr[pnum]._pmode != dvl::PM_GOTHIT)
break;
dvl::plr[pnum]._pAnimFrame++;
}

2
SourceX/DiabloUI/selhero.cpp

@ -339,7 +339,7 @@ void selhero_ClassSelector_Focus(int value)
gfnHeroStats(value, &defaults);
selhero_heroInfo.level = 1;
selhero_heroInfo.heroclass = vecSelHeroDlgItems[value]->m_value;
selhero_heroInfo.heroclass = (plr_class)vecSelHeroDlgItems[value]->m_value;
selhero_heroInfo.strength = defaults.strength;
selhero_heroInfo.magic = defaults.magic;
selhero_heroInfo.dexterity = defaults.dexterity;

4
SourceX/controls/plrctrls.cpp

@ -82,7 +82,7 @@ int GetDistance(int dx, int dy, int maxDistance)
return 0;
}
char walkpath[MAX_PATH_LENGTH];
Sint8 walkpath[MAX_PATH_LENGTH];
int steps = FindPath(PosOkPlayer, myplr, plr[myplr]._pfutx, plr[myplr]._pfuty, dx, dy, walkpath);
if (steps > maxDistance)
return 0;
@ -838,7 +838,7 @@ void WalkInDir(MoveDirection dir)
return;
}
const int pdir = kFaceDir[static_cast<std::size_t>(dir.x)][static_cast<std::size_t>(dir.y)];
const direction pdir = kFaceDir[static_cast<std::size_t>(dir.x)][static_cast<std::size_t>(dir.y)];
const int dx = x + kOffsets[pdir][0];
const int dy = y + kOffsets[pdir][1];
plr[myplr]._pdir = pdir;

2
SourceX/miniwin/misc_msg.cpp

@ -47,7 +47,7 @@ void FocusOnCharInfo()
return;
// Find the first incrementable stat.
int pc = plr[myplr]._pClass;
plr_class pc = plr[myplr]._pClass;
int stat = -1;
for (int i = 4; i >= 0; --i) {
switch (i) {

53
enums.h

@ -1892,21 +1892,6 @@ typedef enum MON_ANIM {
MA_SPECIAL = 5,
} MON_ANIM;
typedef enum PLR_MODE {
PM_STAND = 0,
PM_WALK = 1, //Movement towards N, NW, or NE
PM_WALK2 = 2, //Movement towards S, SW, or SE
PM_WALK3 = 3, //Movement towards W or E
PM_ATTACK = 4,
PM_RATTACK = 5,
PM_BLOCK = 6,
PM_GOTHIT = 7,
PM_DEATH = 8,
PM_SPELL = 9,
PM_NEWLVL = 10,
PM_QUIT = 11,
} PLR_MODE;
typedef enum spell_type {
RSPLTYPE_SKILL = 0x0,
RSPLTYPE_SPELL = 0x1,
@ -2516,12 +2501,12 @@ typedef enum _unique_items {
} _unique_items;
typedef enum plr_class {
PC_WARRIOR = 0x0,
PC_ROGUE = 0x1,
PC_SORCERER = 0x2,
PC_MONK = 0x3,
PC_BARD = 0x4,
PC_BARBARIAN = 0x5,
PC_WARRIOR,
PC_ROGUE,
PC_SORCERER,
PC_MONK,
PC_BARD,
PC_BARBARIAN,
NUM_CLASSES
} plr_class;
@ -2537,11 +2522,6 @@ typedef enum _walk_path {
WALK_NONE = -1,
} _walk_path;
typedef enum player_weapon_type {
WT_MELEE = 0,
WT_RANGED = 1,
} player_weapon_type;
// Logical equipment locations
typedef enum inv_body_loc {
INVLOC_HEAD = 0,
@ -2671,27 +2651,6 @@ typedef enum shrine_type {
NUM_SHRINETYPE
} shrine_type;
typedef enum action_id {
ACTION_WALK = -2, // Automatic walk when using gamepad
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_id;
typedef enum dlrg_flag {
DLRG_HDOOR = 0x01,
DLRG_VDOOR = 0x02,

2
structs.h

@ -219,7 +219,7 @@ typedef struct _uiheroinfo {
struct _uiheroinfo *next;
char name[16];
WORD level;
BYTE heroclass;
plr_class heroclass;
BYTE herorank;
WORD strength;
WORD magic;

Loading…
Cancel
Save