Browse Source

🚚 Rename 'direction' enum to 'Direction'

pull/2040/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
d55cd99dd5
  1. 4
      Source/controls/plrctrls.cpp
  2. 2
      Source/dead.cpp
  3. 2
      Source/dead.h
  4. 4
      Source/engine.cpp
  5. 4
      Source/engine.h
  6. 12
      Source/inv.cpp
  7. 8
      Source/loadsave.cpp
  8. 30
      Source/missiles.cpp
  9. 136
      Source/monster.cpp
  10. 20
      Source/monster.h
  11. 8
      Source/msg.cpp
  12. 6
      Source/msg.h
  13. 4
      Source/objects.cpp
  14. 22
      Source/player.cpp
  15. 14
      Source/player.h
  16. 4
      Source/scrollrt.cpp
  17. 2
      Source/scrollrt.h
  18. 2
      Source/spells.cpp
  19. 4
      Source/sync.cpp
  20. 2
      Source/themes.cpp
  21. 4
      Source/towners.cpp
  22. 2
      test/player_test.cpp

4
Source/controls/plrctrls.cpp

@ -1015,7 +1015,7 @@ void SpellBookMove(AxisDirection dir)
}
}
static const direction FaceDir[3][3] = {
static const Direction FaceDir[3][3] = {
// NONE UP DOWN
{ DIR_OMNI, DIR_N, DIR_S }, // NONE
{ DIR_W, DIR_NW, DIR_SW }, // LEFT
@ -1102,7 +1102,7 @@ void WalkInDir(int playerId, AxisDirection dir)
return;
}
const direction pdir = FaceDir[static_cast<std::size_t>(dir.x)][static_cast<std::size_t>(dir.y)];
const Direction pdir = FaceDir[static_cast<std::size_t>(dir.x)][static_cast<std::size_t>(dir.y)];
const int dx = x + Offsets[pdir][0];
const int dy = y + Offsets[pdir][1];

2
Source/dead.cpp

@ -68,7 +68,7 @@ void InitDead()
assert(static_cast<unsigned>(nd) <= MaxDead);
}
void AddDead(Point tilePosition, int8_t dv, direction ddir)
void AddDead(Point tilePosition, int8_t dv, Direction ddir)
{
dDead[tilePosition.x][tilePosition.y] = (dv & 0x1F) + (ddir << 5);
}

2
Source/dead.h

@ -25,7 +25,7 @@ extern DeadStruct dead[MaxDead];
extern int8_t stonendx;
void InitDead();
void AddDead(Point tilePosition, int8_t dv, direction ddir);
void AddDead(Point tilePosition, int8_t dv, Direction ddir);
void SetDead();
} // namespace devilution

4
Source/engine.cpp

@ -140,9 +140,9 @@ void DrawHalfTransparentRectTo(const CelOutputBuffer &out, int sx, int sy, int w
* @param y2 the y coordinate of p2
* @return the direction of the p1->p2 vector
*/
direction GetDirection(Point start, Point destination)
Direction GetDirection(Point start, Point destination)
{
direction md = DIR_S;
Direction md = DIR_S;
int mx = destination.x - start.x;
int my = destination.y - start.y;

4
Source/engine.h

@ -58,7 +58,7 @@ constexpr const T &clamp(const T &x, const T &lower, const T &upper)
}
#endif
enum direction : uint8_t {
enum Direction : uint8_t {
DIR_S,
DIR_SW,
DIR_W,
@ -463,7 +463,7 @@ void DrawHalfTransparentRectTo(const CelOutputBuffer &out, int sx, int sy, int w
* @param destination Tile coordinate
* @return A value from the direction enum
*/
direction GetDirection(Point start, Point destination);
Direction GetDirection(Point start, Point destination);
/**
* @brief Calculate Width2 from the orginal Width

12
Source/inv.cpp

@ -1808,17 +1808,17 @@ bool TryInvPut()
if (numitems >= MAXITEMS)
return false;
direction dir = GetDirection(plr[myplr].position.tile, { cursmx, cursmy });
Direction dir = GetDirection(plr[myplr].position.tile, { cursmx, cursmy });
if (CanPut(plr[myplr].position.tile.x + offset_x[dir], plr[myplr].position.tile.y + offset_y[dir])) {
return true;
}
direction dirLeft = left[dir];
Direction dirLeft = left[dir];
if (CanPut(plr[myplr].position.tile.x + offset_x[dirLeft], plr[myplr].position.tile.y + offset_y[dirLeft])) {
return true;
}
direction dirRight = right[dir];
Direction dirRight = right[dir];
if (CanPut(plr[myplr].position.tile.x + offset_x[dirRight], plr[myplr].position.tile.y + offset_y[dirRight])) {
return true;
}
@ -1844,7 +1844,7 @@ static bool PutItem(int pnum, Point &position)
auto relativePosition = position - plr[pnum].position.tile;
direction d = GetDirection(plr[pnum].position.tile, position);
Direction d = GetDirection(plr[pnum].position.tile, position);
if (abs(relativePosition.x) > 1 || abs(relativePosition.y) > 1) {
position.x = plr[pnum].position.tile.x + offset_x[d];
@ -1853,13 +1853,13 @@ static bool PutItem(int pnum, Point &position)
if (CanPut(position.x, position.y))
return true;
direction dLeft = left[d];
Direction dLeft = left[d];
position.x = plr[pnum].position.tile.x + offset_x[dLeft];
position.y = plr[pnum].position.tile.y + offset_y[dLeft];
if (CanPut(position.x, position.y))
return true;
direction dRight = right[d];
Direction dRight = right[d];
position.x = plr[pnum].position.tile.x + offset_x[dRight];
position.y = plr[pnum].position.tile.y + offset_y[dRight];
if (CanPut(position.x, position.y))

8
Source/loadsave.cpp

@ -314,7 +314,7 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->destAction = static_cast<action_id>(file->nextLE<int32_t>());
pPlayer->destParam1 = file->nextLE<int32_t>();
pPlayer->destParam2 = file->nextLE<int32_t>();
pPlayer->destParam3 = static_cast<direction>(file->nextLE<int32_t>());
pPlayer->destParam3 = static_cast<Direction>(file->nextLE<int32_t>());
pPlayer->destParam4 = file->nextLE<int32_t>();
pPlayer->plrlevel = file->nextLE<int32_t>();
pPlayer->position.tile.x = file->nextLE<int32_t>();
@ -330,7 +330,7 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->position.offset.y = file->nextLE<int32_t>();
pPlayer->position.velocity.x = file->nextLE<int32_t>();
pPlayer->position.velocity.y = file->nextLE<int32_t>();
pPlayer->_pdir = static_cast<direction>(file->nextLE<int32_t>());
pPlayer->_pdir = static_cast<Direction>(file->nextLE<int32_t>());
file->skip(4); // Unused
pPlayer->_pgfxnum = file->nextLE<int32_t>();
file->skip(4); // Skip pointer pData
@ -417,7 +417,7 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->_pInfraFlag = file->nextBool32();
pPlayer->position.temp.x = file->nextLE<int32_t>();
pPlayer->position.temp.y = file->nextLE<int32_t>();
pPlayer->tempDirection = static_cast<direction>(file->nextLE<int32_t>());
pPlayer->tempDirection = static_cast<Direction>(file->nextLE<int32_t>());
pPlayer->_pVar4 = file->nextLE<int32_t>();
pPlayer->_pVar5 = file->nextLE<int32_t>();
pPlayer->position.offset2.x = file->nextLE<int32_t>();
@ -554,7 +554,7 @@ static void LoadMonster(LoadHelper *file, int i)
pMonster->position.offset.y = file->nextLE<int32_t>();
pMonster->position.velocity.x = file->nextLE<int32_t>();
pMonster->position.velocity.y = file->nextLE<int32_t>();
pMonster->_mdir = static_cast<direction>(file->nextLE<int32_t>());
pMonster->_mdir = static_cast<Direction>(file->nextLE<int32_t>());
pMonster->_menemy = file->nextLE<int32_t>();
pMonster->enemyPosition.x = file->nextLE<uint8_t>();
pMonster->enemyPosition.y = file->nextLE<uint8_t>();

30
Source/missiles.cpp

@ -229,7 +229,7 @@ void GetDamageAmt(int i, int *mind, int *maxd)
bool CheckBlock(int fx, int fy, int tx, int ty)
{
while (fx != tx || fy != ty) {
direction pn = GetDirection({ fx, fy }, { tx, ty });
Direction pn = GetDirection({ fx, fy }, { tx, ty });
fx += XDirAdd[pn];
fy += YDirAdd[pn];
if (nSolidTable[dPiece[fx][fy]])
@ -794,7 +794,7 @@ bool PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, bool s
dam = 64;
}
if ((resper <= 0 || gbIsHellfire) && blk < blkper) {
direction dir = plr[pnum]._pdir;
Direction dir = plr[pnum]._pdir;
if (m != -1) {
dir = GetDirection(plr[pnum].position.tile, monster[m].position.tile);
}
@ -3232,7 +3232,7 @@ int Sentfire(int i, int sx, int sy)
int ex = 0;
if (LineClearMissile(missile[i].position.tile.x, missile[i].position.tile.y, sx, sy)) {
if (dMonster[sx][sy] > 0 && monster[dMonster[sx][sy] - 1]._mhitpoints >> 6 > 0 && dMonster[sx][sy] - 1 > MAX_PLRS - 1) {
direction dir = GetDirection(missile[i].position.tile, { sx, sy });
Direction dir = GetDirection(missile[i].position.tile, { sx, sy });
missile[i]._miVar3 = missileavail[0];
AddMissile(missile[i].position.tile.x, missile[i].position.tile.y, sx, sy, dir, MIS_FIREBOLT, TARGET_MONSTERS, missile[i]._misource, missile[i]._midam, GetSpellLevel(missile[i]._misource, SPL_FIREBOLT));
ex = -1;
@ -3672,7 +3672,7 @@ void MI_HorkSpawn(int i)
dp = dPiece[tx][ty];
if (!nSolidTable[dp] && dMonster[tx][ty] == 0 && dPlayer[tx][ty] == 0 && dObject[tx][ty] == 0) {
j = 6;
auto md = static_cast<direction>(missile[i]._miVar1);
auto md = static_cast<Direction>(missile[i]._miVar1);
int mon = AddMonster(tx, ty, md, 1, true);
M_StartStand(mon, md);
break;
@ -3691,7 +3691,7 @@ void MI_HorkSpawn(int i)
void MI_Rune(int i)
{
int mid, pid, mx, my;
direction dir;
Direction dir;
mx = missile[i].position.tile.x;
my = missile[i].position.tile.y;
@ -4009,7 +4009,7 @@ void MI_FireNova(int i)
int dam = missile[i]._midam;
int sx = missile[i].position.tile.x;
int sy = missile[i].position.tile.y;
direction dir = DIR_S;
Direction dir = DIR_S;
mienemy_type en = TARGET_PLAYERS;
if (id != -1) {
dir = plr[id]._pdir;
@ -4040,7 +4040,7 @@ void MI_SpecArrow(int i)
int dy = missile[i]._miVar2;
int spllvl = missile[i]._miVar3;
int mitype = 0;
direction dir = DIR_S;
Direction dir = DIR_S;
mienemy_type micaster = TARGET_PLAYERS;
if (src != -1) {
dir = plr[src]._pdir;
@ -4422,7 +4422,7 @@ void MI_Chain(int i)
id = missile[i]._misource;
sx = missile[i].position.tile.x;
sy = missile[i].position.tile.y;
direction dir = GetDirection({ sx, sy }, { missile[i]._miVar1, missile[i]._miVar2 });
Direction dir = GetDirection({ sx, sy }, { missile[i]._miVar1, missile[i]._miVar2 });
AddMissile(sx, sy, missile[i]._miVar1, missile[i]._miVar2, dir, MIS_LIGHTCTRL, TARGET_MONSTERS, id, 1, missile[i]._mispllvl);
rad = missile[i]._mispllvl + 3;
if (rad > 19)
@ -4762,9 +4762,9 @@ void MI_Wave(int i)
sy = missile[i].position.tile.y;
v1 = missile[i]._miVar1;
v2 = missile[i]._miVar2;
direction sd = GetDirection({ sx, sy }, { v1, v2 });
direction dira = left[left[sd]];
direction dirb = right[right[sd]];
Direction sd = GetDirection({ sx, sy }, { v1, v2 });
Direction dira = left[left[sd]];
Direction dirb = right[right[sd]];
nxa = sx + XDirAdd[sd];
nya = sy + YDirAdd[sd];
pn = dPiece[nxa][nya];
@ -4809,7 +4809,7 @@ void MI_Nova(int i)
int dam = missile[i]._midam;
int sx = missile[i].position.tile.x;
int sy = missile[i].position.tile.y;
direction dir = DIR_S;
Direction dir = DIR_S;
mienemy_type en = TARGET_PLAYERS;
if (id != -1) {
dir = plr[id]._pdir;
@ -5039,11 +5039,11 @@ void MI_Element(int i)
missile[i]._mirange = 255;
mid = FindClosest(cx, cy, 19);
if (mid > 0) {
direction sd = GetDirection({ cx, cy }, monster[mid].position.tile);
Direction sd = GetDirection({ cx, cy }, monster[mid].position.tile);
SetMissDir(i, sd);
GetMissileVel(i, cx, cy, monster[mid].position.tile.x, monster[mid].position.tile.y, 16);
} else {
direction sd = plr[id]._pdir;
Direction sd = plr[id]._pdir;
SetMissDir(i, sd);
GetMissileVel(i, cx, cy, cx + XDirAdd[sd], cy + YDirAdd[sd], 16);
}
@ -5094,7 +5094,7 @@ void MI_Bonespirit(int i)
SetMissDir(i, GetDirection({ cx, cy }, monster[mid].position.tile));
GetMissileVel(i, cx, cy, monster[mid].position.tile.x, monster[mid].position.tile.y, 16);
} else {
direction sd = plr[id]._pdir;
Direction sd = plr[id]._pdir;
SetMissDir(i, sd);
GetMissileVel(i, cx, cy, cx + XDirAdd[sd], cy + YDirAdd[sd], 16);
}

136
Source/monster.cpp

@ -92,11 +92,11 @@ int MWVel[24][3] = {
/** Maps from monster action to monster animation letter. */
char animletter[7] = "nwahds";
/** Maps from direction to a left turn from the direction. */
direction left[8] = { DIR_SE, DIR_S, DIR_SW, DIR_W, DIR_NW, DIR_N, DIR_NE, DIR_E };
Direction left[8] = { DIR_SE, DIR_S, DIR_SW, DIR_W, DIR_NW, DIR_N, DIR_NE, DIR_E };
/** Maps from direction to a right turn from the direction. */
direction right[8] = { DIR_SW, DIR_W, DIR_NW, DIR_N, DIR_NE, DIR_E, DIR_SE, DIR_S };
Direction right[8] = { DIR_SW, DIR_W, DIR_NW, DIR_N, DIR_NE, DIR_E, DIR_SE, DIR_S };
/** Maps from direction to the opposite direction. */
direction opposite[8] = { DIR_N, DIR_NE, DIR_E, DIR_SE, DIR_S, DIR_SW, DIR_W, DIR_NW };
Direction opposite[8] = { DIR_N, DIR_NE, DIR_E, DIR_SE, DIR_S, DIR_SW, DIR_W, DIR_NW };
/** Maps from direction to delta X-offset. */
int offset_x[8] = { 1, 0, -1, -1, -1, 0, 1, 1 };
/** Maps from direction to delta Y-offset. */
@ -472,7 +472,7 @@ void ClearMVars(int i)
monster[i].actionFrame = 0;
}
void InitMonster(int i, direction rd, int mtype, int x, int y)
void InitMonster(int i, Direction rd, int mtype, int x, int y)
{
CMonster *monst = &Monsters[mtype];
@ -593,7 +593,7 @@ void ClrAllMonsters()
Monst->position.tile = { 0, 0 };
Monst->position.future = { 0, 0 };
Monst->position.old = { 0, 0 };
Monst->_mdir = static_cast<direction>(GenerateRnd(8));
Monst->_mdir = static_cast<Direction>(GenerateRnd(8));
Monst->position.velocity = { 0, 0 };
Monst->_mAnimData = nullptr;
Monst->_mAnimDelay = 0;
@ -662,7 +662,7 @@ void PlaceMonster(int i, int mtype, int x, int y)
}
dMonster[x][y] = i + 1;
auto rd = static_cast<direction>(GenerateRnd(8));
auto rd = static_cast<Direction>(GenerateRnd(8));
InitMonster(i, rd, mtype, x, y);
}
@ -1226,7 +1226,7 @@ void DeleteMonster(int i)
monstactive[i] = temp;
}
int AddMonster(int x, int y, direction dir, int mtype, bool InMap)
int AddMonster(int x, int y, Direction dir, int mtype, bool InMap)
{
if (nummonsters < MAXMONSTERS) {
int i = monstactive[nummonsters++];
@ -1246,7 +1246,7 @@ void monster_43C785(int i)
if (monster[i].MType) {
mx = monster[i].position.tile.x;
my = monster[i].position.tile.y;
direction dir = monster[i]._mdir;
Direction dir = monster[i]._mdir;
for (d = 0; d < 8; d++) {
x = mx + offset_x[d];
y = my + offset_y[d];
@ -1271,7 +1271,7 @@ void monster_43C785(int i)
}
}
void NewMonsterAnim(int i, AnimStruct *anim, direction md)
void NewMonsterAnim(int i, AnimStruct *anim, Direction md)
{
MonsterStruct *Monst = &monster[i];
Monst->_mAnimData = anim->Data[md];
@ -1378,12 +1378,12 @@ void M_Enemy(int i)
}
}
direction M_GetDir(int i)
Direction M_GetDir(int i)
{
return GetDirection(monster[i].position.tile, monster[i].enemyPosition);
}
void M_StartStand(int i, direction md)
void M_StartStand(int i, Direction md)
{
ClearMVars(i);
if (monster[i].MType->mtype == MT_GOLEM)
@ -1412,7 +1412,7 @@ void M_StartDelay(int i, int len)
}
}
void M_StartSpStand(int i, direction md)
void M_StartSpStand(int i, Direction md)
{
NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md);
monster[i]._mmode = MM_SPSTAND;
@ -1422,7 +1422,7 @@ void M_StartSpStand(int i, direction md)
monster[i]._mdir = md;
}
void M_StartWalk(int i, int xvel, int yvel, int xadd, int yadd, direction EndDir)
void M_StartWalk(int i, int xvel, int yvel, int xadd, int yadd, Direction EndDir)
{
int fx = xadd + monster[i].position.tile.x;
int fy = yadd + monster[i].position.tile.y;
@ -1441,7 +1441,7 @@ void M_StartWalk(int i, int xvel, int yvel, int xadd, int yadd, direction EndDir
monster[i].actionFrame = 0;
}
void M_StartWalk2(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, direction EndDir)
void M_StartWalk2(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, Direction EndDir)
{
int fx = xadd + monster[i].position.tile.x;
int fy = yadd + monster[i].position.tile.y;
@ -1465,7 +1465,7 @@ void M_StartWalk2(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int y
monster[i].actionFrame = 0;
}
void M_StartWalk3(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, direction EndDir)
void M_StartWalk3(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, Direction EndDir)
{
int fx = xadd + monster[i].position.tile.x;
int fy = yadd + monster[i].position.tile.y;
@ -1495,7 +1495,7 @@ void M_StartWalk3(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int y
void M_StartAttack(int i)
{
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
NewMonsterAnim(i, &monster[i].MType->Anims[MA_ATTACK], md);
monster[i]._mmode = MM_ATTACK;
monster[i].position.offset = { 0, 0 };
@ -1506,7 +1506,7 @@ void M_StartAttack(int i)
void M_StartRAttack(int i, int missile_type, int dam)
{
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
NewMonsterAnim(i, &monster[i].MType->Anims[MA_ATTACK], md);
monster[i]._mmode = MM_RATTACK;
monster[i]._mVar1 = missile_type;
@ -1519,7 +1519,7 @@ void M_StartRAttack(int i, int missile_type, int dam)
void M_StartRSpAttack(int i, int missile_type, int dam)
{
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md);
monster[i]._mmode = MM_RSPATTACK;
monster[i]._mVar1 = missile_type;
@ -1533,7 +1533,7 @@ void M_StartRSpAttack(int i, int missile_type, int dam)
void M_StartSpAttack(int i)
{
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
NewMonsterAnim(i, &monster[i].MType->Anims[MA_SPECIAL], md);
monster[i]._mmode = MM_SATTACK;
monster[i].position.offset = { 0, 0 };
@ -1577,7 +1577,7 @@ void M_ClearSquares(int i)
void M_GetKnockback(int i)
{
direction d = opposite[monster[i]._mdir];
Direction d = opposite[monster[i]._mdir];
if (DirOK(i, d)) {
M_ClearSquares(i);
monster[i].position.old.x += offset_x[d];
@ -1765,7 +1765,7 @@ void MonstStartKill(int i, int pnum, bool sendmsg)
else
PlayEffect(i, 2);
direction md = pnum >= 0 ? M_GetDir(i) : Monst->_mdir;
Direction md = pnum >= 0 ? M_GetDir(i) : Monst->_mdir;
Monst->_mdir = md;
NewMonsterAnim(i, &Monst->MType->Anims[MA_DEATH], md);
Monst->_mmode = MM_DEATH;
@ -1808,7 +1808,7 @@ void M2MStartKill(int i, int mid)
else
PlayEffect(mid, 2);
direction md = opposite[monster[i]._mdir];
Direction md = opposite[monster[i]._mdir];
if (monster[mid].MType->mtype == MT_GOLEM)
md = DIR_S;
@ -1867,7 +1867,7 @@ void M_SyncStartKill(int i, int x, int y, int pnum)
}
}
void M_StartFadein(int i, direction md, bool backwards)
void M_StartFadein(int i, Direction md, bool backwards)
{
assurance((DWORD)i < MAXMONSTERS, i);
assurance(monster[i].MType != nullptr, i);
@ -1885,7 +1885,7 @@ void M_StartFadein(int i, direction md, bool backwards)
}
}
void M_StartFadeout(int i, direction md, bool backwards)
void M_StartFadeout(int i, Direction md, bool backwards)
{
assurance((DWORD)i < MAXMONSTERS, i);
assurance(monster[i].MType != nullptr, i);
@ -2112,7 +2112,7 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
if (hper >= hit)
return;
if (blkper < blk) {
direction dir = GetDirection(plr[pnum].position.tile, monster[i].position.tile);
Direction dir = GetDirection(plr[pnum].position.tile, monster[i].position.tile);
StartPlrBlock(pnum, dir);
if (pnum == myplr && plr[pnum].wReflections > 0) {
plr[pnum].wReflections--;
@ -2695,7 +2695,7 @@ bool M_DoStone(int i)
return false;
}
void M_WalkDir(int i, direction md)
void M_WalkDir(int i, Direction md)
{
assurance((DWORD)i < MAXMONSTERS, i);
@ -2786,9 +2786,9 @@ void GroupUnity(int i)
}
}
bool M_CallWalk(int i, direction md)
bool M_CallWalk(int i, Direction md)
{
direction mdtemp = md;
Direction mdtemp = md;
bool ok = DirOK(i, md);
if (GenerateRnd(2) != 0)
ok = ok || (md = left[mdtemp], DirOK(i, md)) || (md = right[mdtemp], DirOK(i, md));
@ -2814,7 +2814,7 @@ bool M_PathWalk(int i)
bool (*Check)(int, int, int);
/** Maps from walking path step to facing direction. */
const direction plr2monst[9] = { DIR_S, DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_N, DIR_E, DIR_S, DIR_W };
const Direction plr2monst[9] = { DIR_S, DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_N, DIR_E, DIR_S, DIR_W };
commitment((DWORD)i < MAXMONSTERS, i);
@ -2830,9 +2830,9 @@ bool M_PathWalk(int i)
return false;
}
bool M_CallWalk2(int i, direction md)
bool M_CallWalk2(int i, Direction md)
{
direction mdtemp = md;
Direction mdtemp = md;
bool ok = DirOK(i, md); // Can we continue in the same direction
if (GenerateRnd(2) != 0) { // Randomly go left or right
ok = ok || (mdtemp = left[md], DirOK(i, left[md])) || (mdtemp = right[md], DirOK(i, right[md]));
@ -2846,7 +2846,7 @@ bool M_CallWalk2(int i, direction md)
return ok;
}
bool M_DumbWalk(int i, direction md)
bool M_DumbWalk(int i, Direction md)
{
bool ok = DirOK(i, md);
if (ok)
@ -2855,14 +2855,14 @@ bool M_DumbWalk(int i, direction md)
return ok;
}
bool M_RoundWalk(int i, direction md, int *dir)
bool M_RoundWalk(int i, Direction md, int *dir)
{
if (*dir)
md = left[left[md]];
else
md = right[right[md]];
direction mdtemp = md;
Direction mdtemp = md;
bool ok = DirOK(i, md);
if (!ok) {
if (*dir) {
@ -2904,9 +2904,9 @@ void MAI_Zombie(int i)
int dist = std::max(abs(mx - Monst->enemyPosition.x), abs(my - Monst->enemyPosition.y));
if (dist >= 2) {
if (dist >= 2 * Monst->_mint + 4) {
direction md = Monst->_mdir;
Direction md = Monst->_mdir;
if (GenerateRnd(100) < 2 * Monst->_mint + 20) {
md = static_cast<direction>(GenerateRnd(8));
md = static_cast<Direction>(GenerateRnd(8));
}
M_DumbWalk(i, md);
} else {
@ -2932,7 +2932,7 @@ void MAI_SkelSd(int i)
int x = Monst->position.tile.x - Monst->enemyPosition.x;
int y = Monst->position.tile.y - Monst->enemyPosition.y;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
Monst->_mdir = md;
if (abs(x) >= 2 || abs(y) >= 2) {
if (Monst->_mVar1 == MM_DELAY || (GenerateRnd(100) >= 35 - 4 * Monst->_mint)) {
@ -3010,7 +3010,7 @@ void MAI_Snake(int i)
fy = Monst->enemyPosition.y;
mx = Monst->position.tile.x - fx;
my = Monst->position.tile.y - fy;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
Monst->_mdir = md;
if (abs(mx) >= 2 || abs(my) >= 2) {
if (abs(mx) < 3 && abs(my) < 3 && LineClear(PosOkMonst, i, Monst->position.tile.x, Monst->position.tile.y, fx, fy) && Monst->_mVar1 != MM_CHARGE) {
@ -3074,7 +3074,7 @@ void MAI_Bat(int i)
xd = Monst->position.tile.x - Monst->enemyPosition.x;
yd = Monst->position.tile.y - Monst->enemyPosition.y;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
Monst->_mdir = md;
v = GenerateRnd(100);
if (Monst->_mgoal == MGOAL_RETREAT) {
@ -3138,7 +3138,7 @@ void MAI_SkelBow(int i)
mx = Monst->position.tile.x - Monst->enemyPosition.x;
my = Monst->position.tile.y - Monst->enemyPosition.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
Monst->_mdir = md;
v = GenerateRnd(100);
@ -3178,7 +3178,7 @@ void MAI_Fat(int i)
mx = Monst->position.tile.x - Monst->enemyPosition.x;
my = Monst->position.tile.y - Monst->enemyPosition.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
Monst->_mdir = md;
v = GenerateRnd(100);
if (abs(mx) >= 2 || abs(my) >= 2) {
@ -3214,7 +3214,7 @@ void MAI_Sneak(int i)
mx -= Monst->enemyPosition.x;
my -= Monst->enemyPosition.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
dist = 5 - Monst->_mint;
if (Monst->_mVar1 == MM_GOTHIT) {
Monst->_mgoal = MGOAL_RETREAT;
@ -3282,7 +3282,7 @@ void MAI_Fireman(int i)
xd = monster[i].position.tile.x - fx;
yd = monster[i].position.tile.y - fy;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (Monst->_mgoal == MGOAL_NORMAL) {
if (LineClearMissile(Monst->position.tile.x, Monst->position.tile.y, fx, fy)
&& AddMissile(Monst->position.tile.x, Monst->position.tile.y, fx, fy, md, MIS_FIREMAN, pnum, i, 0, 0) != -1) {
@ -3407,7 +3407,7 @@ void MAI_Cleaver(int i)
x = mx - Monst->enemyPosition.x;
y = my - Monst->enemyPosition.y;
direction md = GetDirection({ mx, my }, Monst->position.last);
Direction md = GetDirection({ mx, my }, Monst->position.last);
Monst->_mdir = md;
if (abs(x) >= 2 || abs(y) >= 2)
@ -3433,7 +3433,7 @@ void MAI_Round(int i, bool special)
fx = Monst->enemyPosition.x;
mx = Monst->position.tile.x - fx;
my = Monst->position.tile.y - fy;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
if (Monst->_msquelch < UINT8_MAX)
MonstCheckDoors(i);
v = GenerateRnd(100);
@ -3499,7 +3499,7 @@ void MAI_Ranged(int i, int missile_type, bool special)
fy = Monst->enemyPosition.y;
mx = Monst->position.tile.x - fx;
my = Monst->position.tile.y - fy;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (Monst->_msquelch < UINT8_MAX)
MonstCheckDoors(i);
Monst->_mdir = md;
@ -3522,7 +3522,7 @@ void MAI_Ranged(int i, int missile_type, bool special)
} else if (Monst->_msquelch != 0) {
fx = Monst->position.last.x;
fy = Monst->position.last.y;
direction md = GetDirection(Monst->position.tile, { fx, fy });
Direction md = GetDirection(Monst->position.tile, { fx, fy });
M_CallWalk(i, md);
}
}
@ -3678,7 +3678,7 @@ void MAI_Garg(int i)
Monst = &monster[i];
dx = Monst->position.tile.x - Monst->position.last.x;
dy = Monst->position.tile.y - Monst->position.last.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (Monst->_msquelch != 0 && Monst->_mFlags & MFLAG_ALLOW_SPECIAL) {
M_Enemy(i);
mx = Monst->position.tile.x - Monst->enemyPosition.x;
@ -3721,7 +3721,7 @@ void MAI_RoundRanged(int i, int missile_type, bool checkdoors, int dam, int less
fy = Monst->enemyPosition.y;
mx = Monst->position.tile.x - fx;
my = Monst->position.tile.y - fy;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
if (checkdoors && Monst->_msquelch < UINT8_MAX)
MonstCheckDoors(i);
v = GenerateRnd(10000);
@ -3813,7 +3813,7 @@ void MAI_RR2(int i, int mistype, int dam)
fy = Monst->enemyPosition.y;
mx = Monst->position.tile.x - fx;
my = Monst->position.tile.y - fy;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
if (Monst->_msquelch < UINT8_MAX)
MonstCheckDoors(i);
v = GenerateRnd(100);
@ -3895,7 +3895,7 @@ void MAI_Golum(int i)
int _mex = monster[i].position.tile.x - monster[_menemy].position.future.x;
int _mey = monster[i].position.tile.y - monster[_menemy].position.future.y;
direction md = GetDirection(monster[i].position.tile, monster[_menemy].position.tile);
Direction md = GetDirection(monster[i].position.tile, monster[_menemy].position.tile);
monster[i]._mdir = md;
if (abs(_mex) < 2 && abs(_mey) < 2 && have_enemy) {
_menemy = monster[i]._menemy;
@ -3948,7 +3948,7 @@ void MAI_SkelKing(int i)
fy = Monst->enemyPosition.y;
mx = Monst->position.tile.x - fx;
my = Monst->position.tile.y - fy;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
if (Monst->_msquelch < UINT8_MAX)
MonstCheckDoors(i);
v = GenerateRnd(100);
@ -4011,7 +4011,7 @@ void MAI_Rhino(int i)
fy = Monst->enemyPosition.y;
mx = Monst->position.tile.x - fx;
my = Monst->position.tile.y - fy;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
if (Monst->_msquelch < UINT8_MAX)
MonstCheckDoors(i);
v = GenerateRnd(100);
@ -4081,7 +4081,7 @@ void MAI_HorkDemon(int i)
fy = Monst->enemyPosition.y;
mx = Monst->position.tile.x - fx;
my = Monst->position.tile.y - fy;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
if (Monst->_msquelch < 255) {
MonstCheckDoors(i);
@ -4148,7 +4148,7 @@ void MAI_Counselor(int i)
fy = Monst->enemyPosition.y;
mx = Monst->position.tile.x - fx;
my = Monst->position.tile.y - fy;
direction md = GetDirection(Monst->position.tile, Monst->position.last);
Direction md = GetDirection(Monst->position.tile, Monst->position.last);
if (Monst->_msquelch < UINT8_MAX)
MonstCheckDoors(i);
v = GenerateRnd(100);
@ -4217,7 +4217,7 @@ void MAI_Garbud(int i)
_mx = Monst->position.tile.x;
_my = Monst->position.tile.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (Monst->mtalkmsg >= TEXT_GARBUD1
&& Monst->mtalkmsg <= TEXT_GARBUD3
@ -4272,7 +4272,7 @@ void MAI_Zhar(int i)
mx = Monst->position.tile.x;
my = Monst->position.tile.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (Monst->mtalkmsg == TEXT_ZHAR1 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) {
Monst->mtalkmsg = TEXT_ZHAR2;
Monst->_mgoal = MGOAL_INQUIRING;
@ -4311,7 +4311,7 @@ void MAI_SnotSpil(int i)
mx = Monst->position.tile.x;
my = Monst->position.tile.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (Monst->mtalkmsg == TEXT_BANNER10 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) {
Monst->mtalkmsg = TEXT_BANNER11;
@ -4360,7 +4360,7 @@ void MAI_Lazurus(int i)
mx = Monst->position.tile.x;
my = Monst->position.tile.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (dFlags[mx][my] & BFLAG_VISIBLE) {
if (!gbIsMultiplayer) {
if (Monst->mtalkmsg == TEXT_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr].position.tile.x == 35 && plr[myplr].position.tile.y == 46) {
@ -4412,7 +4412,7 @@ void MAI_Lazhelp(int i)
Monst = &monster[i];
_mx = Monst->position.tile.x;
_my = Monst->position.tile.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (dFlags[_mx][_my] & BFLAG_VISIBLE) {
if (!gbIsMultiplayer) {
@ -4446,7 +4446,7 @@ void MAI_Lachdanan(int i)
_mx = Monst->position.tile.x;
_my = Monst->position.tile.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (Monst->mtalkmsg == TEXT_VEIL9 && !(dFlags[_mx][_my] & BFLAG_VISIBLE) && monster[i]._mgoal == MGOAL_TALKING) {
Monst->mtalkmsg = TEXT_VEIL10;
@ -4483,7 +4483,7 @@ void MAI_Warlord(int i)
mx = Monst->position.tile.x;
my = Monst->position.tile.y;
direction md = M_GetDir(i);
Direction md = M_GetDir(i);
if (dFlags[mx][my] & BFLAG_VISIBLE) {
if (Monst->mtalkmsg == TEXT_WARLRD9 && Monst->_mgoal == MGOAL_INQUIRING)
Monst->_mmode = MM_TALK;
@ -4689,7 +4689,7 @@ void FreeMonsters()
FreeMissiles2();
}
bool DirOK(int i, direction mdir)
bool DirOK(int i, Direction mdir)
{
int fx, fy;
int x, y;
@ -5089,7 +5089,7 @@ void MissToMonst(int i, int x, int y)
oldx = Miss->position.tile.x;
oldy = Miss->position.tile.y;
dMonster[x][y] = m + 1;
Monst->_mdir = static_cast<direction>(Miss->_mimfnum);
Monst->_mdir = static_cast<Direction>(Miss->_mimfnum);
Monst->position.tile = { x, y };
M_StartStand(m, Monst->_mdir);
if (Monst->MType->mtype < MT_INCIN || Monst->MType->mtype > MT_HELLBURN) {
@ -5256,7 +5256,7 @@ bool IsGoat(int mt)
|| (mt >= MT_NGOATBW && mt <= MT_GGOATBW);
}
int M_SpawnSkel(int x, int y, direction dir)
int M_SpawnSkel(int x, int y, Direction dir)
{
int i, j, skeltypes, skel;
@ -5283,7 +5283,7 @@ int M_SpawnSkel(int x, int y, direction dir)
return -1;
}
void ActivateSpawn(int i, int x, int y, direction dir)
void ActivateSpawn(int i, int x, int y, Direction dir)
{
dMonster[x][y] = i + 1;
monster[i].position.tile = { x, y };
@ -5302,7 +5302,7 @@ bool SpawnSkeleton(int ii, int x, int y)
return false;
if (PosOkMonst(-1, x, y)) {
direction dir = GetDirection({ x, y }, { x, y }); // TODO useless calculation
Direction dir = GetDirection({ x, y }, { x, y }); // TODO useless calculation
ActivateSpawn(ii, x, y, dir);
return true;
}
@ -5341,7 +5341,7 @@ bool SpawnSkeleton(int ii, int x, int y)
dx = x - 1 + xx;
dy = y - 1 + yy;
direction dir = GetDirection({ dx, dy }, { x, y });
Direction dir = GetDirection({ dx, dy }, { x, y });
ActivateSpawn(ii, dx, dy, dir);
return true;

20
Source/monster.h

@ -143,7 +143,7 @@ struct MonsterStruct { // note: missing field _mAFNum
uint8_t _pathcount;
ActorPosition position;
/** Direction faced by monster (direction enum) */
direction _mdir;
Direction _mdir;
/** The current target of the mosnter. An index in to either the plr or monster array based on the _meflag value. */
int _menemy;
/** Usually correspond's to the enemy's future position */
@ -206,17 +206,17 @@ extern int nummtypes;
void InitLevelMonsters();
void GetLevelMTypes();
void InitMonsterGFX(int monst);
void InitMonster(int i, direction rd, int mtype, int x, int y);
void InitMonster(int i, Direction rd, int mtype, int x, int y);
void ClrAllMonsters();
void monster_some_crypt();
void PlaceGroup(int mtype, int num, int leaderf, int leader);
void InitMonsters();
void SetMapMonsters(const uint16_t *dunData, int startx, int starty);
void DeleteMonster(int i);
int AddMonster(int x, int y, direction dir, int mtype, bool InMap);
int AddMonster(int x, int y, Direction dir, int mtype, bool InMap);
void monster_43C785(int i);
bool M_Talker(int i);
void M_StartStand(int i, direction md);
void M_StartStand(int i, Direction md);
void M_ClearSquares(int i);
void M_GetKnockback(int i);
void M_StartHit(int i, int pnum, int dam);
@ -226,7 +226,7 @@ void M_Teleport(int i);
void M_UpdateLeader(int i);
void DoEnding();
void PrepDoEnding();
void M_WalkDir(int i, direction md);
void M_WalkDir(int i, Direction md);
void MAI_Zombie(int i);
void MAI_SkelSd(int i);
void MAI_Snake(int i);
@ -273,7 +273,7 @@ void MAI_Warlord(int i);
void DeleteMonsterList();
void ProcessMonsters();
void FreeMonsters();
bool DirOK(int i, direction mdir);
bool DirOK(int i, Direction mdir);
bool PosOkMissile(int entity, int x, int y);
bool LineClearSolid(int x1, int y1, int x2, int y2);
bool LineClearMissile(int x1, int y1, int x2, int y2);
@ -290,7 +290,7 @@ bool PosOkMonst2(int i, int x, int y);
bool PosOkMonst3(int i, int x, int y);
bool IsSkel(int mt);
bool IsGoat(int mt);
int M_SpawnSkel(int x, int y, direction dir);
int M_SpawnSkel(int x, int y, Direction dir);
bool SpawnSkeleton(int ii, int x, int y);
int PreSpawnSkeleton();
void TalktoMonster(int i);
@ -302,9 +302,9 @@ void decode_enemy(int m, int enemy);
/* data */
extern direction left[8];
extern direction right[8];
extern direction opposite[8];
extern Direction left[8];
extern Direction right[8];
extern Direction opposite[8];
extern int offset_x[8];
extern int offset_y[8];

8
Source/msg.cpp

@ -865,7 +865,7 @@ void NetSendCmd(bool bHiPri, _cmd_id bCmd)
NetSendLoPri(myplr, (byte *)&cmd, sizeof(cmd));
}
void NetSendCmdGolem(BYTE mx, BYTE my, direction dir, BYTE menemy, int hp, BYTE cl)
void NetSendCmdGolem(BYTE mx, BYTE my, Direction dir, BYTE menemy, int hp, BYTE cl)
{
TCmdGolem cmd;
@ -1658,7 +1658,7 @@ static DWORD On_SPELLXYD(TCmd *pCmd, int pnum)
plr[pnum].destAction = ACTION_SPELLWALL;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
plr[pnum].destParam3 = static_cast<direction>(p->wParam2);
plr[pnum].destParam3 = static_cast<Direction>(p->wParam2);
plr[pnum].destParam4 = p->wParam3;
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pRSplType;
@ -1681,7 +1681,7 @@ static DWORD On_SPELLXY(TCmd *pCmd, int pnum)
plr[pnum].destAction = ACTION_SPELL;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
plr[pnum].destParam3 = static_cast<direction>(p->wParam2);
plr[pnum].destParam3 = static_cast<Direction>(p->wParam2);
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pRSplType;
plr[pnum]._pSplFrom = 0;
@ -1703,7 +1703,7 @@ static DWORD On_TSPELLXY(TCmd *pCmd, int pnum)
plr[pnum].destAction = ACTION_SPELL;
plr[pnum].destParam1 = p->x;
plr[pnum].destParam2 = p->y;
plr[pnum].destParam3 = static_cast<direction>(p->wParam2);
plr[pnum].destParam3 = static_cast<Direction>(p->wParam2);
plr[pnum]._pSpell = spell;
plr[pnum]._pSplType = plr[pnum]._pTSplType;
plr[pnum]._pSplFrom = 2;

6
Source/msg.h

@ -188,7 +188,7 @@ struct TCmdGolem {
_cmd_id bCmd;
uint8_t _mx;
uint8_t _my;
direction _mdir;
Direction _mdir;
int8_t _menemy;
int32_t _mhitpoints;
uint8_t _currlevel;
@ -362,7 +362,7 @@ struct TPkt {
struct DMonsterStr {
uint8_t _mx;
uint8_t _my;
direction _mdir;
Direction _mdir;
uint8_t _menemy;
uint8_t _mactive;
int32_t _mhitpoints;
@ -433,7 +433,7 @@ void DeltaAddItem(int ii);
void DeltaSaveLevel();
void DeltaLoadLevel();
void NetSendCmd(bool bHiPri, _cmd_id bCmd);
void NetSendCmdGolem(BYTE mx, BYTE my, direction dir, BYTE menemy, int hp, BYTE cl);
void NetSendCmdGolem(BYTE mx, BYTE my, Direction dir, BYTE menemy, int hp, BYTE cl);
void NetSendCmdLoc(int playerId, bool bHiPri, _cmd_id bCmd, Point position);
void NetSendCmdLocParam1(bool bHiPri, _cmd_id bCmd, Point position, uint16_t wParam1);
void NetSendCmdLocParam2(bool bHiPri, _cmd_id bCmd, Point position, uint16_t wParam1, uint16_t wParam2);

4
Source/objects.cpp

@ -2118,7 +2118,7 @@ void Obj_Trap(int i)
}
}
if (!deltaload) {
direction dir = GetDirection(object[i].position, object[oti].position);
Direction dir = GetDirection(object[i].position, object[oti].position);
int sx = object[i].position.x;
int sy = object[i].position.y;
AddMissile(sx, sy, dx, dy, dir, object[i]._oVar3, TARGET_PLAYERS, -1, 0, 0);
@ -3098,7 +3098,7 @@ void OperateChest(int pnum, int i, bool sendmsg)
}
}
if (object[i]._oTrapFlag && object[i]._otype >= OBJ_TCHEST1 && object[i]._otype <= OBJ_TCHEST3) {
direction mdir = GetDirection(object[i].position, plr[pnum].position.tile);
Direction mdir = GetDirection(object[i].position, plr[pnum].position.tile);
switch (object[i]._oVar4) {
case 0:
mtype = MIS_ARROW;

22
Source/player.cpp

@ -1284,7 +1284,7 @@ void SetPlayerOld(PlayerStruct &player)
player.position.old = player.position.tile;
}
void FixPlayerLocation(int pnum, direction bDir)
void FixPlayerLocation(int pnum, Direction bDir)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("FixPlayerLocation: illegal player %i", pnum);
@ -1304,7 +1304,7 @@ void FixPlayerLocation(int pnum, direction bDir)
ChangeVisionXY(player._pvid, player.position.tile.x, player.position.tile.y);
}
void StartStand(int pnum, direction dir)
void StartStand(int pnum, Direction dir)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("StartStand: illegal player %i", pnum);
@ -1400,7 +1400,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, direction EndDir, _scroll_direction sdir, int variant, bool pmWillBeCalled)
void StartWalk(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int yadd, int mapx, int mapy, Direction EndDir, _scroll_direction sdir, int variant, bool pmWillBeCalled)
{
auto &player = plr[pnum];
@ -1508,7 +1508,7 @@ void StartWalk(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int y
}
}
void StartAttack(int pnum, direction d)
void StartAttack(int pnum, Direction d)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("StartAttack: illegal player %i", pnum);
@ -1544,7 +1544,7 @@ void StartAttack(int pnum, direction d)
SetPlayerOld(player);
}
void StartRangeAttack(int pnum, direction 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 %i", pnum);
@ -1578,7 +1578,7 @@ void StartRangeAttack(int pnum, direction d, int cx, int cy)
player.position.temp = { cx, cy };
}
void StartPlrBlock(int pnum, direction dir)
void StartPlrBlock(int pnum, Direction dir)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal("StartPlrBlock: illegal player %i", pnum);
@ -1608,7 +1608,7 @@ void StartPlrBlock(int pnum, direction dir)
SetPlayerOld(player);
}
void StartSpell(int pnum, direction 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 %i", pnum);
@ -1736,7 +1736,7 @@ void StartPlrHit(int pnum, int dam, bool forcehit)
return;
}
direction pd = player._pdir;
Direction pd = player._pdir;
if ((player._pGFXLoad & PFILE_HIT) == 0) {
LoadPlrGFX(pnum, PFILE_HIT);
@ -2743,7 +2743,7 @@ bool PlrHitPlr(int pnum, int8_t p)
if (hit < hper) {
if (blk < blkper) {
direction dir = GetDirection(target.position.tile, attacker.position.tile);
Direction dir = GetDirection(target.position.tile, attacker.position.tile);
StartPlrBlock(p, dir);
} else {
mind = attacker._pIMinDam;
@ -3179,7 +3179,7 @@ void CheckNewPath(int pnum, bool pmWillBeCalled)
MakePlrPath(pnum, target.position.future.x, target.position.future.y, false);
}
direction d;
Direction d;
if (player.walkpath[0] != WALK_NONE) {
if (player._pmode == PM_STAND) {
if (pnum == myplr) {
@ -3859,7 +3859,7 @@ void CheckPlrSpell()
if (addflag) {
if (myPlayer._pRSpell == SPL_FIREWALL || myPlayer._pRSpell == SPL_LIGHTWALL) {
direction sd = GetDirection(myPlayer.position.tile, { cursmx, cursmy });
Direction sd = GetDirection(myPlayer.position.tile, { cursmx, cursmy });
sl = GetSpellLevel(myplr, myPlayer._pRSpell);
NetSendCmdLocParam3(true, CMD_SPELLXYD, { cursmx, cursmy }, myPlayer._pRSpell, sd, sl);
} else if (pcursmonst != -1) {

14
Source/player.h

@ -155,11 +155,11 @@ struct PlayerStruct {
action_id destAction;
int destParam1;
int destParam2;
direction destParam3;
Direction destParam3;
int destParam4;
int plrlevel;
ActorPosition position;
direction _pdir; // Direction faced by player (direction enum)
Direction _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)
/*
* @brief Contains Information for current Animation
@ -224,7 +224,7 @@ struct PlayerStruct {
int _pGold;
bool _pInfraFlag;
/** Player's direction when ending movement. Also used for casting direction of SPL_FIREWALL. */
direction tempDirection;
Direction tempDirection;
/** Used for spell level, and X component of _pVar5 */
int _pVar4;
/** Used for storing 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) */
@ -433,10 +433,10 @@ bool SolidLoc(int x, int y);
void PlrClrTrans(int x, int y);
void PlrDoTrans(int x, int y);
void SetPlayerOld(PlayerStruct &player);
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 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);

4
Source/scrollrt.cpp

@ -124,7 +124,7 @@ const char *const szPlrModeAssert[] = {
"quitting"
};
Point GetOffsetForWalking(const AnimationInfo &animationInfo, const direction dir, bool cameraMode /*= false*/)
Point GetOffsetForWalking(const AnimationInfo &animationInfo, const Direction dir, bool cameraMode /*= false*/)
{
// clang-format off
// DIR_S, DIR_SW, DIR_W, DIR_NW, DIR_N, DIR_NE, DIR_E, DIR_SE,
@ -766,7 +766,7 @@ static void scrollrt_draw_dungeon(const CelOutputBuffer &out, int sx, int sy, in
if (light_table_index < lightmax && bDead != 0) {
do {
DeadStruct *pDeadGuy = &dead[(bDead & 0x1F) - 1];
auto dd = static_cast<direction>((bDead >> 5) & 7);
auto dd = static_cast<Direction>((bDead >> 5) & 7);
int px = dx - CalculateWidth2(pDeadGuy->_deadWidth);
byte *pCelBuff = pDeadGuy->_deadData[dd];
assert(pCelBuff != nullptr);

2
Source/scrollrt.h

@ -42,7 +42,7 @@ extern bool AutoMapShowItems;
* @param dir walking direction
* @param cameraMode Adjusts the offset relative to the camera
*/
Point GetOffsetForWalking(const AnimationInfo &animationInfo, const direction dir, bool cameraMode = false);
Point GetOffsetForWalking(const AnimationInfo &animationInfo, const Direction dir, bool cameraMode = false);
void ClearCursor();
void ShiftGrid(int *x, int *y, int horizontal, int vertical);

2
Source/spells.cpp

@ -190,7 +190,7 @@ bool CheckSpell(int id, spell_id sn, spell_type st, bool manaonly)
void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int spllvl)
{
direction dir = plr[id]._pdir;
Direction dir = plr[id]._pdir;
if (spl == SPL_FIREWALL || spl == SPL_LIGHTWALL) {
dir = plr[id].tempDirection;
}

4
Source/sync.cpp

@ -231,7 +231,7 @@ static void sync_monster(int pnum, const TSyncMonster *p)
mdy = abs(monster[ndx].position.tile.y - p->_my);
if (mdx <= 2 && mdy <= 2) {
if (monster[ndx]._mmode < MM_WALK || monster[ndx]._mmode > MM_WALK3) {
direction md = GetDirection(monster[ndx].position.tile, { p->_mx, p->_my });
Direction md = GetDirection(monster[ndx].position.tile, { p->_mx, p->_my });
if (DirOK(ndx, md)) {
M_ClearSquares(ndx);
dMonster[monster[ndx].position.tile.x][monster[ndx].position.tile.y] = ndx + 1;
@ -244,7 +244,7 @@ static void sync_monster(int pnum, const TSyncMonster *p)
dMonster[p->_mx][p->_my] = ndx + 1;
monster[ndx].position.tile = { p->_mx, p->_my };
decode_enemy(ndx, p->_menemy);
direction md = GetDirection({ p->_mx, p->_my }, monster[ndx].enemyPosition);
Direction md = GetDirection({ p->_mx, p->_my }, monster[ndx].enemyPosition);
M_StartStand(ndx, md);
monster[ndx]._msquelch = UINT8_MAX;
}

2
Source/themes.cpp

@ -511,7 +511,7 @@ void PlaceThemeMonsts(int t, int f)
for (xp = 0; xp < MAXDUNX; xp++) {
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]] && dItem[xp][yp] == 0 && dObject[xp][yp] == 0) {
if (GenerateRnd(f) == 0) {
AddMonster(xp, yp, static_cast<direction>(GenerateRnd(8)), mtype, true);
AddMonster(xp, yp, static_cast<Direction>(GenerateRnd(8)), mtype, true);
}
}
}

4
Source/towners.cpp

@ -26,7 +26,7 @@ _sfx_id CowPlaying = SFX_NONE;
struct TownerInit {
_talker_id type;
Point position;
direction dir;
Direction dir;
void (*init)(TownerStruct &towner, const TownerInit &initData);
void (*talk)(PlayerStruct &player, TownerStruct &towner);
};
@ -63,7 +63,7 @@ void InitQstSnds(TownerStruct &towner, _talker_id type)
}
}
void LoadTownerAnimations(TownerStruct &towner, const char *path, int frames, direction dir, int delay)
void LoadTownerAnimations(TownerStruct &towner, const char *path, int frames, Direction dir, int delay)
{
towner._tNData = LoadFileInMem(path);
for (auto &animation : towner._tNAnim) {

2
test/player_test.cpp

@ -14,7 +14,7 @@ int RunBlockTest(int frames, int flags)
plr[pnum]._pHFrames = frames;
plr[pnum]._pIFlags = flags;
plr[pnum]._pGFXLoad = -1;
StartPlrHit(pnum, 5, direction::DIR_S);
StartPlrHit(pnum, 5, Direction::DIR_S);
int i = 1;
for (; i < 100; i++) {

Loading…
Cancel
Save