From b3ec79af4f0642b1d36413a4e4a2ddb8a329459a Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Mon, 24 May 2021 12:28:52 -0300 Subject: [PATCH] Leverage 'Point' in Lighting and Player functions (#2048) --- Source/controls/plrctrls.cpp | 6 +- Source/dead.cpp | 2 +- Source/diablo.cpp | 2 +- Source/drlg_l3.cpp | 18 +++--- Source/lighting.cpp | 121 +++++++++++++++++------------------ Source/lighting.h | 18 +++--- Source/loadsave.cpp | 2 +- Source/missiles.cpp | 110 +++++++++++++++---------------- Source/monster.cpp | 18 +++--- Source/msg.cpp | 24 +++---- Source/multi.cpp | 2 +- Source/objects.cpp | 8 +-- Source/player.cpp | 75 +++++++--------------- Source/player.h | 6 +- Source/portal.cpp | 2 +- 15 files changed, 191 insertions(+), 223 deletions(-) diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 6dc8b083f..c6c2cb3a5 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -1540,13 +1540,13 @@ void PerformSecondaryAction() } else if (pcursobj != -1) { NetSendCmdLocParam1(true, CMD_OPOBJXY, { cursmx, cursmy }, pcursobj); } else if (pcursmissile != -1) { - MakePlrPath(myplr, missile[pcursmissile].position.tile.x, missile[pcursmissile].position.tile.y, true); + MakePlrPath(myplr, missile[pcursmissile].position.tile, true); plr[myplr].destAction = ACTION_WALK; } else if (pcurstrig != -1) { - MakePlrPath(myplr, trigs[pcurstrig].position.x, trigs[pcurstrig].position.y, true); + MakePlrPath(myplr, trigs[pcurstrig].position, true); plr[myplr].destAction = ACTION_WALK; } else if (pcursquest != -1) { - MakePlrPath(myplr, quests[pcursquest].position.x, quests[pcursquest].position.y, true); + MakePlrPath(myplr, quests[pcursquest].position, true); plr[myplr].destAction = ACTION_WALK; } } diff --git a/Source/dead.cpp b/Source/dead.cpp index 3d18ac885..2f83c008f 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -82,7 +82,7 @@ void SetDead() for (int dx = 0; dx < MAXDUNX; dx++) { for (int dy = 0; dy < MAXDUNY; dy++) { if ((dDead[dx][dy] & 0x1F) == monster[mi]._udeadval) - ChangeLightXY(monster[mi].mlid, dx, dy); + ChangeLightXY(monster[mi].mlid, { dx, dy }); } } } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index db8103ec0..bbd9cca9c 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1629,7 +1629,7 @@ static void UpdateMonsterLights() LightListStruct *lid = &LightList[mon->mlid]; if (mon->position.tile != lid->position.tile) { - ChangeLightXY(mon->mlid, mon->position.tile.x, mon->position.tile.y); + ChangeLightXY(mon->mlid, mon->position.tile); } } } diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 2e1ffcddb..13f671fb3 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -2596,13 +2596,13 @@ void CreateL3Dungeon(uint32_t rseed, lvl_entry entry) for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { if (dPiece[i][j] >= 56 && dPiece[i][j] <= 147) { - DoLighting(i, j, 7, -1); + DoLighting({ i, j }, 7, -1); } else if (dPiece[i][j] >= 154 && dPiece[i][j] <= 161) { - DoLighting(i, j, 7, -1); + DoLighting({ i, j }, 7, -1); } else if (dPiece[i][j] == 150) { - DoLighting(i, j, 7, -1); + DoLighting({ i, j }, 7, -1); } else if (dPiece[i][j] == 152) { - DoLighting(i, j, 7, -1); + DoLighting({ i, j }, 7, -1); } } } @@ -2610,7 +2610,7 @@ void CreateL3Dungeon(uint32_t rseed, lvl_entry entry) for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { if (dPiece[i][j] >= 382 && dPiece[i][j] <= 457) { - DoLighting(i, j, 9, -1); + DoLighting({ i, j }, 9, -1); } } } @@ -2663,13 +2663,13 @@ void LoadL3Dungeon(const char *path, int vx, int vy) for (int j = 0; j < MAXDUNY; j++) { for (int i = 0; i < MAXDUNX; i++) { if (dPiece[i][j] >= 56 && dPiece[i][j] <= 147) { - DoLighting(i, j, 7, -1); + DoLighting({ i, j }, 7, -1); } else if (dPiece[i][j] >= 154 && dPiece[i][j] <= 161) { - DoLighting(i, j, 7, -1); + DoLighting({ i, j }, 7, -1); } else if (dPiece[i][j] == 150) { - DoLighting(i, j, 7, -1); + DoLighting({ i, j }, 7, -1); } else if (dPiece[i][j] == 152) { - DoLighting(i, j, 7, -1); + DoLighting({ i, j }, 7, -1); } } } diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 1e323c23b..da6f1ad02 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -490,7 +490,7 @@ char GetLight(int x, int y) return dLight[x][y]; } -void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) +void DoLighting(Point position, int nRadius, int Lnum) { int x, y, v, mult, radius_block; int min_x, max_x, min_y, max_y; @@ -508,43 +508,43 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) yoff = LightList[Lnum].position.offset.y; if (xoff < 0) { xoff += 8; - nXPos--; + position -= { 1, 0 }; } if (yoff < 0) { yoff += 8; - nYPos--; + position -= { 0, 1 }; } } dist_x = xoff; dist_y = yoff; - if (nXPos - 15 < 0) { - min_x = nXPos + 1; + if (position.x - 15 < 0) { + min_x = position.x + 1; } else { min_x = 15; } - if (nXPos + 15 > MAXDUNX) { - max_x = MAXDUNX - nXPos; + if (position.x + 15 > MAXDUNX) { + max_x = MAXDUNX - position.x; } else { max_x = 15; } - if (nYPos - 15 < 0) { - min_y = nYPos + 1; + if (position.y - 15 < 0) { + min_y = position.y + 1; } else { min_y = 15; } - if (nYPos + 15 > MAXDUNY) { - max_y = MAXDUNY - nYPos; + if (position.y + 15 > MAXDUNY) { + max_y = MAXDUNY - position.y; } else { max_y = 15; } - if (nXPos >= 0 && nXPos < MAXDUNX && nYPos >= 0 && nYPos < MAXDUNY) { + if (position.x >= 0 && position.x < MAXDUNX && position.y >= 0 && position.y < MAXDUNY) { if (currlevel < 17) { - SetLight(nXPos, nYPos, 0); - } else if (GetLight(nXPos, nYPos) > lightradius[nRadius][0]) { - SetLight(nXPos, nYPos, lightradius[nRadius][0]); + SetLight(position.x, position.y, 0); + } else if (GetLight(position.x, position.y) > lightradius[nRadius][0]) { + SetLight(position.x, position.y, lightradius[nRadius][0]); } } @@ -553,8 +553,8 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) for (x = 1; x < max_x; x++) { radius_block = lightblock[mult][y][x]; if (radius_block < 128) { - temp_x = nXPos + x; - temp_y = nYPos + y; + temp_x = position.x + x; + temp_y = position.y + y; v = lightradius[nRadius][radius_block]; if (temp_x >= 0 && temp_x < MAXDUNX && temp_y >= 0 && temp_y < MAXDUNY) if (v < GetLight(temp_x, temp_y)) @@ -568,8 +568,8 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) for (x = 1; x < max_x; x++) { radius_block = lightblock[mult][y + block_y][x + block_x]; if (radius_block < 128) { - temp_x = nXPos + y; - temp_y = nYPos - x; + temp_x = position.x + y; + temp_y = position.y - x; v = lightradius[nRadius][radius_block]; if (temp_x >= 0 && temp_x < MAXDUNX && temp_y >= 0 && temp_y < MAXDUNY) if (v < GetLight(temp_x, temp_y)) @@ -583,8 +583,8 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) for (x = 1; x < min_x; x++) { radius_block = lightblock[mult][y + block_y][x + block_x]; if (radius_block < 128) { - temp_x = nXPos - x; - temp_y = nYPos - y; + temp_x = position.x - x; + temp_y = position.y - y; v = lightradius[nRadius][radius_block]; if (temp_x >= 0 && temp_x < MAXDUNX && temp_y >= 0 && temp_y < MAXDUNY) if (v < GetLight(temp_x, temp_y)) @@ -598,8 +598,8 @@ void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum) for (x = 1; x < min_x; x++) { radius_block = lightblock[mult][y + block_y][x + block_x]; if (radius_block < 128) { - temp_x = nXPos - y; - temp_y = nYPos + x; + temp_x = position.x - y; + temp_y = position.y + x; v = lightradius[nRadius][radius_block]; if (temp_x >= 0 && temp_x < MAXDUNX && temp_y >= 0 && temp_y < MAXDUNY) if (v < GetLight(temp_x, temp_y)) @@ -631,14 +631,14 @@ void DoUnLight(int nXPos, int nYPos, int nRadius) } } -void DoUnVision(int nXPos, int nYPos, int nRadius) +void DoUnVision(Point position, int nRadius) { nRadius++; nRadius++; // increasing the radius even further here prevents leaving stray vision tiles behind and doesn't seem to affect monster AI - applying new vision happens in the same tick - int y1 = nYPos - nRadius; - int y2 = nYPos + nRadius; - int x1 = nXPos - nRadius; - int x2 = nXPos + nRadius; + int y1 = position.y - nRadius; + int y2 = position.y + nRadius; + int x1 = position.x - nRadius; + int x2 = position.x + nRadius; if (y1 < 0) { y1 = 0; @@ -660,23 +660,23 @@ void DoUnVision(int nXPos, int nYPos, int nRadius) } } -void DoVision(int nXPos, int nYPos, int nRadius, bool doautomap, bool visible) +void DoVision(Point position, int nRadius, bool doautomap, bool visible) { bool nBlockerFlag; int nCrawlX, nCrawlY, nLineLen, nTrans; int j, k, v, x1adj, x2adj, y1adj, y2adj; - if (nXPos >= 0 && nXPos <= MAXDUNX && nYPos >= 0 && nYPos <= MAXDUNY) { + if (position.x >= 0 && position.x<= MAXDUNX && position.y >= 0 && position.y <= MAXDUNY) { if (doautomap) { - if (dFlags[nXPos][nYPos] != 0) { - SetAutomapView({ nXPos, nYPos }); + if (dFlags[position.x][position.y] != 0) { + SetAutomapView(position); } - dFlags[nXPos][nYPos] |= BFLAG_EXPLORED; + dFlags[position.x][position.y] |= BFLAG_EXPLORED; } if (visible) { - dFlags[nXPos][nYPos] |= BFLAG_LIT; + dFlags[position.x][position.y] |= BFLAG_LIT; } - dFlags[nXPos][nYPos] |= BFLAG_VISIBLE; + dFlags[position.x][position.y] |= BFLAG_VISIBLE; } for (v = 0; v < 4; v++) { @@ -690,32 +690,32 @@ void DoVision(int nXPos, int nYPos, int nRadius, bool doautomap, bool visible) y2adj = 0; switch (v) { case 0: - nCrawlX = nXPos + vCrawlTable[j][k]; - nCrawlY = nYPos + vCrawlTable[j][k + 1]; + nCrawlX = position.x + vCrawlTable[j][k]; + nCrawlY = position.y + vCrawlTable[j][k + 1]; if (vCrawlTable[j][k] > 0 && vCrawlTable[j][k + 1] > 0) { x1adj = -1; y2adj = -1; } break; case 1: - nCrawlX = nXPos - vCrawlTable[j][k]; - nCrawlY = nYPos - vCrawlTable[j][k + 1]; + nCrawlX = position.x - vCrawlTable[j][k]; + nCrawlY = position.y - vCrawlTable[j][k + 1]; if (vCrawlTable[j][k] > 0 && vCrawlTable[j][k + 1] > 0) { y1adj = 1; x2adj = 1; } break; case 2: - nCrawlX = nXPos + vCrawlTable[j][k]; - nCrawlY = nYPos - vCrawlTable[j][k + 1]; + nCrawlX = position.x + vCrawlTable[j][k]; + nCrawlY = position.y - vCrawlTable[j][k + 1]; if (vCrawlTable[j][k] > 0 && vCrawlTable[j][k + 1] > 0) { x1adj = -1; y2adj = 1; } break; case 3: - nCrawlX = nXPos - vCrawlTable[j][k]; - nCrawlY = nYPos + vCrawlTable[j][k + 1]; + nCrawlX = position.x - vCrawlTable[j][k]; + nCrawlY = position.y + vCrawlTable[j][k + 1]; if (vCrawlTable[j][k] > 0 && vCrawlTable[j][k + 1] > 0) { y1adj = -1; x2adj = 1; @@ -950,7 +950,7 @@ void ToggleLighting() memcpy(dLight, dPreLight, sizeof(dLight)); for (const auto &player : plr) { if (player.plractive && player.plrlevel == currlevel) { - DoLighting(player.position.tile.x, player.position.tile.y, player._pLightRad, -1); + DoLighting(player.position.tile, player._pLightRad, -1); } } } @@ -972,7 +972,7 @@ void InitLighting() } } -int AddLight(int x, int y, int r) +int AddLight(Point position, int r) { int lid; @@ -984,7 +984,7 @@ int AddLight(int x, int y, int r) if (numlights < MAXLIGHTS) { lid = lightactive[numlights++]; - LightList[lid].position.tile = { x, y }; + LightList[lid].position.tile = position; LightList[lid]._lradius = r; LightList[lid].position.offset = { 0, 0 }; LightList[lid]._ldel = false; @@ -1018,7 +1018,7 @@ void ChangeLightRadius(int i, int r) dolighting = true; } -void ChangeLightXY(int i, int x, int y) +void ChangeLightXY(int i, Point position) { if (lightflag || i == NO_LIGHT) { return; @@ -1027,11 +1027,11 @@ void ChangeLightXY(int i, int x, int y) LightList[i]._lunflag = true; LightList[i].position.old = LightList[i].position.tile; LightList[i].oldRadious = LightList[i]._lradius; - LightList[i].position.tile = { x, y }; + LightList[i].position.tile = position; dolighting = true; } -void ChangeLightOff(int i, int x, int y) +void ChangeLightOff(int i, Point position) { if (lightflag || i == NO_LIGHT) { return; @@ -1040,11 +1040,11 @@ void ChangeLightOff(int i, int x, int y) LightList[i]._lunflag = true; LightList[i].position.old = LightList[i].position.tile; LightList[i].oldRadious = LightList[i]._lradius; - LightList[i].position.offset = { x, y }; + LightList[i].position.offset = position; dolighting = true; } -void ChangeLight(int i, int x, int y, int r) +void ChangeLight(int i, Point position, int r) { if (lightflag || i == NO_LIGHT) { return; @@ -1053,7 +1053,7 @@ void ChangeLight(int i, int x, int y, int r) LightList[i]._lunflag = true; LightList[i].position.old = LightList[i].position.tile; LightList[i].oldRadious = LightList[i]._lradius; - LightList[i].position.tile = { x, y }; + LightList[i].position.tile = position; LightList[i]._lradius = r; dolighting = true; } @@ -1078,7 +1078,7 @@ void ProcessLightList() for (int i = 0; i < numlights; i++) { int j = lightactive[i]; if (!LightList[j]._ldel) { - DoLighting(LightList[j].position.tile.x, LightList[j].position.tile.y, LightList[j]._lradius, j); + DoLighting(LightList[j].position.tile, LightList[j]._lradius, j); } } int i = 0; @@ -1113,12 +1113,12 @@ void InitVision() } } -int AddVision(int x, int y, int r, bool mine) +int AddVision(Point position, int r, bool mine) { int vid = -1; // BUGFIX: if numvision >= MAXVISION behavior is undefined (fixed) if (numvision < MAXVISION) { - VisionList[numvision].position.tile = { x, y }; + VisionList[numvision].position.tile = position; VisionList[numvision]._lradius = r; vid = visionid++; VisionList[numvision]._lid = vid; @@ -1145,14 +1145,14 @@ void ChangeVisionRadius(int id, int r) } } -void ChangeVisionXY(int id, int x, int y) +void ChangeVisionXY(int id, Point position) { for (int i = 0; i < numvision; i++) { if (VisionList[i]._lid == id) { VisionList[i]._lunflag = true; VisionList[i].position.old = VisionList[i].position.tile; VisionList[i].oldRadious = VisionList[i]._lradius; - VisionList[i].position.tile = { x, y }; + VisionList[i].position.tile = position; dovision = true; } } @@ -1163,10 +1163,10 @@ void ProcessVisionList() if (dovision) { for (int i = 0; i < numvision; i++) { if (VisionList[i]._ldel) { - DoUnVision(VisionList[i].position.tile.x, VisionList[i].position.tile.y, VisionList[i]._lradius); + DoUnVision(VisionList[i].position.tile, VisionList[i]._lradius); } if (VisionList[i]._lunflag) { - DoUnVision(VisionList[i].position.old.x, VisionList[i].position.old.y, VisionList[i].oldRadious); + DoUnVision(VisionList[i].position.old, VisionList[i].oldRadious); VisionList[i]._lunflag = false; } } @@ -1176,8 +1176,7 @@ void ProcessVisionList() for (int i = 0; i < numvision; i++) { if (!VisionList[i]._ldel) { DoVision( - VisionList[i].position.tile.x, - VisionList[i].position.tile.y, + VisionList[i].position.tile, VisionList[i]._lradius, VisionList[i]._lflags, VisionList[i]._lflags); diff --git a/Source/lighting.h b/Source/lighting.h index 8313ca65d..8fa47f9be 100644 --- a/Source/lighting.h +++ b/Source/lighting.h @@ -46,9 +46,9 @@ extern int visionid; extern std::array pLightTbl; extern bool lightflag; -void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum); -void DoUnVision(int nXPos, int nYPos, int nRadius); -void DoVision(int nXPos, int nYPos, int nRadius, bool doautomap, bool visible); +void DoLighting(Point position, int nRadius, int Lnum); +void DoUnVision(Point position, int nRadius); +void DoVision(Point position, int nRadius, bool doautomap, bool visible); void FreeLightTable(); void InitLightTable(); void MakeLightTable(); @@ -57,18 +57,18 @@ void ToggleLighting(); #endif void InitLightMax(); void InitLighting(); -int AddLight(int x, int y, int r); +int AddLight(Point position, int r); void AddUnLight(int i); void ChangeLightRadius(int i, int r); -void ChangeLightXY(int i, int x, int y); -void ChangeLightOff(int i, int x, int y); -void ChangeLight(int i, int x, int y, int r); +void ChangeLightXY(int i, Point position); +void ChangeLightOff(int i, Point position); +void ChangeLight(int i, Point position, int r); void ProcessLightList(); void SavePreLighting(); void InitVision(); -int AddVision(int x, int y, int r, bool mine); +int AddVision(Point position, int r, bool mine); void ChangeVisionRadius(int id, int r); -void ChangeVisionXY(int id, int x, int y); +void ChangeVisionXY(int id, Point position); void ProcessVisionList(); void lighting_color_cycling(); diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 3b2e65c1f..6fb5d081e 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -1936,7 +1936,7 @@ void SaveLevel() { PFileScopedArchiveWriter scoped_writer; - DoUnVision(plr[myplr].position.tile.x, plr[myplr].position.tile.y, plr[myplr]._pLightRad); // fix for vision staying on the level + DoUnVision(plr[myplr].position.tile, plr[myplr]._pLightRad); // fix for vision staying on the level if (currlevel == 0) glSeedTbl[0] = AdvanceRndSeed(); diff --git a/Source/missiles.cpp b/Source/missiles.cpp index cd95097a8..85a035fe8 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -427,7 +427,7 @@ void GetMissilePos(int i) missile[i].position.tile.y = dy + missile[i].position.start.y; missile[i].position.offset.x = mx + (dy * 32) - (dx * 32); missile[i].position.offset.y = my - (dx * 16) - (dy * 16); - ChangeLightOff(missile[i]._mlid, lx - (dx * 8), ly - (dy * 8)); + ChangeLightOff(missile[i]._mlid, { lx - (dx * 8), ly - (dy * 8) }); } void MoveMissilePos(int i) @@ -1309,7 +1309,7 @@ void AddFireRune(int mi, int sx, int sy, int dx, int dy, int midir, int8_t miene if (missiles_found_target(mi, &dx, &dy, 10)) { missile[mi]._miVar1 = MIS_HIVEEXP; missile[mi]._miDelFlag = false; - missile[mi]._mlid = AddLight(dx, dy, 8); + missile[mi]._mlid = AddLight({ dx, dy }, 8); } else { missile[mi]._miDelFlag = true; } @@ -1326,7 +1326,7 @@ void AddLightningRune(int mi, int sx, int sy, int dx, int dy, int midir, int8_t if (missiles_found_target(mi, &dx, &dy, 10)) { missile[mi]._miVar1 = MIS_LIGHTBALL; missile[mi]._miDelFlag = false; - missile[mi]._mlid = AddLight(dx, dy, 8); + missile[mi]._mlid = AddLight({ dx, dy }, 8); } else { missile[mi]._miDelFlag = true; } @@ -1343,7 +1343,7 @@ void AddGreatLightningRune(int mi, int sx, int sy, int dx, int dy, int midir, in if (missiles_found_target(mi, &dx, &dy, 10)) { missile[mi]._miVar1 = MIS_NOVA; missile[mi]._miDelFlag = false; - missile[mi]._mlid = AddLight(dx, dy, 8); + missile[mi]._mlid = AddLight({ dx, dy }, 8); } else { missile[mi]._miDelFlag = true; } @@ -1360,7 +1360,7 @@ void AddImmolationRune(int mi, int sx, int sy, int dx, int dy, int midir, int8_t if (missiles_found_target(mi, &dx, &dy, 10)) { missile[mi]._miVar1 = MIS_IMMOLATION; missile[mi]._miDelFlag = false; - missile[mi]._mlid = AddLight(dx, dy, 8); + missile[mi]._mlid = AddLight({ dx, dy }, 8); } else { missile[mi]._miDelFlag = true; } @@ -1377,7 +1377,7 @@ void AddStoneRune(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mien if (missiles_found_target(mi, &dx, &dy, 10)) { missile[mi]._miVar1 = MIS_STONE; missile[mi]._miDelFlag = false; - missile[mi]._mlid = AddLight(dx, dy, 8); + missile[mi]._mlid = AddLight({ dx, dy }, 8); } else { missile[mi]._miDelFlag = true; } @@ -1432,7 +1432,7 @@ void AddBerserk(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienem r = 3; else r = 9; - monster[dm].mlid = AddLight(monster[dm].position.tile.x, monster[dm].position.tile.y, r); + monster[dm].mlid = AddLight(monster[dm].position.tile, r); UseMana(id, SPL_BERSERK); break; } @@ -1709,7 +1709,7 @@ void AddRuneExplosion(int mi, int sx, int sy, int dx, int dy, int midir, int8_t CheckMissileCol(mi, dmg, dmg, false, missile[mi].position.tile.x, missile[mi].position.tile.y + 1, true); CheckMissileCol(mi, dmg, dmg, false, missile[mi].position.tile.x + 1, missile[mi].position.tile.y + 1, true); } - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); SetMissDir(mi, 0); missile[mi]._miDelFlag = false; missile[mi]._mirange = missile[mi]._miAnimLen - 1; @@ -1745,7 +1745,7 @@ void AddImmolation(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mie missile[mi]._miVar5 = sy; missile[mi]._miVar6 = 2; missile[mi]._miVar7 = 2; - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); } void AddFireNova(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy, int id, int dam) @@ -1772,7 +1772,7 @@ void AddFireNova(int mi, int sx, int sy, int dx, int dy, int midir, int8_t miene missile[mi]._miVar3 = 0; missile[mi]._miVar4 = sx; missile[mi]._miVar5 = sy; - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); } void AddLightningArrow(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy, int id, int dam) @@ -1901,7 +1901,7 @@ void AddCboltArrow(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mie dy += YDirAdd[midir]; } missile[mi]._miAnimFrame = GenerateRnd(8) + 1; - missile[mi]._mlid = AddLight(sx, sy, 5); + missile[mi]._mlid = AddLight({ sx, sy }, 5); GetMissileVel(mi, sx, sy, dx, dy, 8); missile[mi]._miVar1 = 5; missile[mi]._miVar2 = midir; @@ -1945,7 +1945,7 @@ void AddLArrow(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy missile[mi]._mirange = 256; missile[mi]._miVar1 = sx; missile[mi]._miVar2 = sy; - missile[mi]._mlid = AddLight(sx, sy, 5); + missile[mi]._mlid = AddLight({ sx, sy }, 5); } void AddArrow(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy, int id, int dam) @@ -2076,7 +2076,7 @@ void AddFirebolt(int mi, int sx, int sy, int dx, int dy, int midir, int8_t micas missile[mi]._mirange = 256; missile[mi]._miVar1 = sx; missile[mi]._miVar2 = sy; - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); } void AddMagmaball(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy, int id, int dam) @@ -2091,7 +2091,7 @@ void AddMagmaball(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mien missile[mi]._mirange = 1; missile[mi]._miVar1 = sx; missile[mi]._miVar2 = sy; - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); } void AddKrull(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy, int id, int dam) @@ -2197,7 +2197,7 @@ void AddFireball(int mi, int sx, int sy, int dx, int dy, int midir, int8_t miene missile[mi]._miVar3 = 0; missile[mi]._miVar4 = sx; missile[mi]._miVar5 = sy; - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); } void AddLightctrl(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy, int id, int dam) @@ -2228,7 +2228,7 @@ void AddLightning(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mien } else { missile[mi]._mirange = (missile[mi]._mispllvl / 2) + 6; } - missile[mi]._mlid = AddLight(missile[mi].position.tile.x, missile[mi].position.tile.y, 4); + missile[mi]._mlid = AddLight(missile[mi].position.tile, 4); } void AddMisexp(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy, int id, int dam) @@ -2441,7 +2441,7 @@ void AddGuardian(int mi, int sx, int sy, int dx, int dy, int midir, int8_t miene if (!missile[mi]._miDelFlag) { missile[mi]._misource = id; - missile[mi]._mlid = AddLight(missile[mi].position.tile.x, missile[mi].position.tile.y, 1); + missile[mi]._mlid = AddLight(missile[mi].position.tile, 1); missile[mi]._mirange = missile[mi]._mispllvl + (plr[id]._pLevel / 2); missile[mi]._mirange += (missile[mi]._mirange * plr[id]._pISplDur) / 128; @@ -2564,7 +2564,7 @@ void AddFlare(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy, missile[mi]._mirange = 256; missile[mi]._miVar1 = sx; missile[mi]._miVar2 = sy; - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); if (mienemy == TARGET_MONSTERS) { UseMana(id, SPL_FLARE); ApplyPlrDamage(id, 5); @@ -2796,7 +2796,7 @@ void AddElement(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienem missile[mi]._miVar3 = 0; missile[mi]._miVar4 = dx; missile[mi]._miVar5 = dy; - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); UseMana(id, SPL_ELEMENT); } @@ -3008,7 +3008,7 @@ void AddFlame(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mienemy, missile[mi].position.offset = missile[midir].position.offset; missile[mi].position.traveled = missile[midir].position.traveled; missile[mi]._mirange = missile[mi]._miVar2 + 20; - missile[mi]._mlid = AddLight(sx, sy, 1); + missile[mi]._mlid = AddLight({ sx, sy }, 1); if (mienemy == TARGET_MONSTERS) { i = GenerateRnd(plr[id]._pLevel) + GenerateRnd(2); missile[mi]._midam = 8 * i + 16 + ((8 * i + 16) / 2); @@ -3055,7 +3055,7 @@ void AddCbolt(int mi, int sx, int sy, int dx, int dy, int midir, int8_t micaster } missile[mi]._miAnimFrame = GenerateRnd(8) + 1; - missile[mi]._mlid = AddLight(sx, sy, 5); + missile[mi]._mlid = AddLight({ sx, sy }, 5); GetMissileVel(mi, sx, sy, dx, dy, 8); missile[mi]._miVar1 = 5; @@ -3085,7 +3085,7 @@ void AddHbolt(int mi, int sx, int sy, int dx, int dy, int midir, int8_t micaster missile[mi]._mirange = 256; missile[mi]._miVar1 = sx; missile[mi]._miVar2 = sy; - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); missile[mi]._midam = GenerateRnd(10) + plr[id]._pLevel + 9; UseMana(id, SPL_HBOLT); } @@ -3132,7 +3132,7 @@ void AddBoneSpirit(int mi, int sx, int sy, int dx, int dy, int midir, int8_t mie missile[mi]._miVar3 = 0; missile[mi]._miVar4 = dx; missile[mi]._miVar5 = dy; - missile[mi]._mlid = AddLight(sx, sy, 8); + missile[mi]._mlid = AddLight({ sx, sy }, 8); if (mienemy == TARGET_MONSTERS) { UseMana(id, SPL_BONESPIRIT); ApplyPlrDamage(id, 6); @@ -3289,7 +3289,7 @@ void MI_LArrow(int i) missile[i]._mirange--; p = missile[i]._misource; if (missile[i]._miAnimType == MFILE_MINILTNG || missile[i]._miAnimType == MFILE_MAGBLOS) { - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, missile[i]._miAnimFrame + 5); + ChangeLight(missile[i]._mlid, missile[i].position.tile, missile[i]._miAnimFrame + 5); missile_resistance rst = missiledata[missile[i]._mitype].mResist; if (missile[i]._mitype == MIS_LARROW) { if (p != -1) { @@ -3352,7 +3352,7 @@ void MI_LArrow(int i) if (missile[i].position.tile.x != missile[i]._miVar1 || missile[i].position.tile.y != missile[i]._miVar2) { missile[i]._miVar1 = missile[i].position.tile.x; missile[i]._miVar2 = missile[i].position.tile.y; - ChangeLight(missile[i]._mlid, missile[i]._miVar1, missile[i]._miVar2, 5); + ChangeLight(missile[i]._mlid, { missile[i]._miVar1, missile[i]._miVar2 }, 5); } } } @@ -3470,7 +3470,7 @@ void MI_Firebolt(int i) missile[i]._miVar1 = missile[i].position.tile.x; missile[i]._miVar2 = missile[i].position.tile.y; if (missile[i]._mlid != NO_LIGHT) - ChangeLight(missile[i]._mlid, missile[i]._miVar1, missile[i]._miVar2, 8); + ChangeLight(missile[i]._mlid, { missile[i]._miVar1, missile[i]._miVar2 }, 8); } PutMissile(i); } @@ -3564,8 +3564,8 @@ void MI_Firewall(int i) } if (missile[i]._mimfnum != 0 && missile[i]._mirange != 0 && missile[i]._miAnimAdd != -1 && missile[i]._miVar2 < 12) { if (missile[i]._miVar2 == 0) - missile[i]._mlid = AddLight(missile[i].position.tile.x, missile[i].position.tile.y, ExpLight[0]); - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, ExpLight[missile[i]._miVar2]); + missile[i]._mlid = AddLight(missile[i].position.tile, ExpLight[0]); + ChangeLight(missile[i]._mlid, missile[i].position.tile, ExpLight[missile[i]._miVar2]); missile[i]._miVar2++; } PutMissile(i); @@ -3600,7 +3600,7 @@ void FireballUpdate(int i, int xof, int yof, bool alwaysDelete) if (missile[i]._mirange == 0) { int mx = missile[i].position.tile.x; int my = missile[i].position.tile.y; - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, my, missile[i]._miAnimFrame); + ChangeLight(missile[i]._mlid, missile[i].position.tile, missile[i]._miAnimFrame); if (!CheckBlock(px, py, mx, my)) CheckMissileCol(i, dam, dam, false, mx, my, true); if (!CheckBlock(px, py, mx, my + 1)) @@ -3641,7 +3641,7 @@ void FireballUpdate(int i, int xof, int yof, bool alwaysDelete) } else if (missile[i].position.tile.x != missile[i]._miVar1 || missile[i].position.tile.y != missile[i]._miVar2) { missile[i]._miVar1 = missile[i].position.tile.x; missile[i]._miVar2 = missile[i].position.tile.y; - ChangeLight(missile[i]._mlid, missile[i]._miVar1, missile[i]._miVar2, 8); + ChangeLight(missile[i]._mlid, { missile[i]._miVar1, missile[i]._miVar2 }, 8); } if (alwaysDelete) missile[i]._miDelFlag = true; @@ -4186,8 +4186,8 @@ void MI_Town(int i) SetMissDir(i, 1); if (currlevel != 0 && missile[i]._mimfnum != 1 && missile[i]._mirange != 0) { if (missile[i]._miVar2 == 0) - missile[i]._mlid = AddLight(missile[i].position.tile.x, missile[i].position.tile.y, 1); - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, ExpLight[missile[i]._miVar2]); + missile[i]._mlid = AddLight(missile[i].position.tile, 1); + ChangeLight(missile[i]._mlid, missile[i].position.tile, ExpLight[missile[i]._miVar2]); missile[i]._miVar2++; } @@ -4325,12 +4325,12 @@ void MI_Firemove(int i) if (missile[i].position.tile.x != missile[i]._miVar3 || missile[i].position.tile.y != missile[i]._miVar4) { missile[i]._miVar3 = missile[i].position.tile.x; missile[i]._miVar4 = missile[i].position.tile.y; - ChangeLight(missile[i]._mlid, missile[i]._miVar3, missile[i]._miVar4, 8); + ChangeLight(missile[i]._mlid, { missile[i]._miVar3, missile[i]._miVar4 }, 8); } } else { if (missile[i]._miVar2 == 0) - missile[i]._mlid = AddLight(missile[i].position.tile.x, missile[i].position.tile.y, ExpLight[0]); - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, ExpLight[missile[i]._miVar2]); + missile[i]._mlid = AddLight(missile[i].position.tile, ExpLight[0]); + ChangeLight(missile[i]._mlid, missile[i].position.tile, ExpLight[missile[i]._miVar2]); missile[i]._miVar2++; } missile[i].position.tile.x++; @@ -4404,7 +4404,7 @@ void MI_Guardian(int i) if (missile[i]._miVar3 > 15) { missile[i]._miVar3 = 15; } else if (missile[i]._miVar3 > 0) { - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, missile[i]._miVar3); + ChangeLight(missile[i]._mlid, missile[i].position.tile, missile[i]._miVar3); } if (missile[i]._mirange == 0) { @@ -4473,10 +4473,10 @@ void MI_Weapexp(int i) } CheckMissileCol(i, mind, maxd, false, missile[i].position.tile.x, missile[i].position.tile.y, false); if (missile[i]._miVar1 == 0) { - missile[i]._mlid = AddLight(missile[i].position.tile.x, missile[i].position.tile.y, 9); + missile[i]._mlid = AddLight(missile[i].position.tile, 9); } else { if (missile[i]._mirange != 0) - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, ExpLight[missile[i]._miVar1]); + ChangeLight(missile[i]._mlid, missile[i].position.tile, ExpLight[missile[i]._miVar1]); } missile[i]._miVar1++; if (missile[i]._mirange == 0) { @@ -4497,9 +4497,9 @@ void MI_Misexp(int i) AddUnLight(missile[i]._mlid); } else { if (missile[i]._miVar1 == 0) - missile[i]._mlid = AddLight(missile[i].position.tile.x, missile[i].position.tile.y, 9); + missile[i]._mlid = AddLight(missile[i].position.tile, 9); else - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, ExpLight[missile[i]._miVar1]); + ChangeLight(missile[i]._mlid, missile[i].position.tile, ExpLight[missile[i]._miVar1]); missile[i]._miVar1++; PutMissile(i); } @@ -4535,16 +4535,16 @@ void MI_Teleport(int i) missile[i]._miDelFlag = true; } else { dPlayer[plr[id].position.tile.x][plr[id].position.tile.y] = 0; - PlrClrTrans(plr[id].position.tile.x, plr[id].position.tile.y); + PlrClrTrans(plr[id].position.tile); plr[id].position.tile = { missile[i].position.tile.x, missile[i].position.tile.y }; plr[id].position.future = plr[id].position.tile; plr[id].position.old = plr[id].position.tile; - PlrDoTrans(plr[id].position.tile.x, plr[id].position.tile.y); + PlrDoTrans(plr[id].position.tile); missile[i]._miVar1 = 1; dPlayer[plr[id].position.tile.x][plr[id].position.tile.y] = id + 1; if (leveltype != DTYPE_TOWN) { - ChangeLightXY(plr[id]._plid, plr[id].position.tile.x, plr[id].position.tile.y); - ChangeVisionXY(plr[id]._pvid, plr[id].position.tile.x, plr[id].position.tile.y); + ChangeLightXY(plr[id]._plid, plr[id].position.tile); + ChangeVisionXY(plr[id]._pvid, plr[id].position.tile); } if (id == myplr) { ViewX = plr[id].position.tile.x - ScrollInfo.tile.x; @@ -4630,7 +4630,7 @@ void MI_Rhino(int i) monster[monst].position.tile = { omx, omy }; dMonster[omx][omy] = -(monst + 1); if (monster[monst]._uniqtype != 0) - ChangeLightXY(missile[i]._mlid, omx, omy); + ChangeLightXY(missile[i]._mlid, { omx, omy }); MoveMissilePos(i); PutMissile(i); } @@ -4877,7 +4877,7 @@ void MI_Flame(int i) k = missile[i]._miAnimFrame; if (k > 11) k = 24 - k; - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, k); + ChangeLight(missile[i]._mlid, missile[i].position.tile, k); } if (missile[i]._mirange == 0) { missile[i]._miDelFlag = true; @@ -4946,7 +4946,7 @@ void MI_Cbolt(int i) missile[i]._mirange = missile[i]._miAnimLen; GetMissilePos(i); } - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, missile[i]._miVar1); + ChangeLight(missile[i]._mlid, missile[i].position.tile, missile[i]._miVar1); } if (missile[i]._mirange == 0) { missile[i]._miDelFlag = true; @@ -4978,11 +4978,11 @@ void MI_Hbolt(int i) if (missile[i].position.tile.x != missile[i]._miVar1 || missile[i].position.tile.y != missile[i]._miVar2) { missile[i]._miVar1 = missile[i].position.tile.x; missile[i]._miVar2 = missile[i].position.tile.y; - ChangeLight(missile[i]._mlid, missile[i]._miVar1, missile[i]._miVar2, 8); + ChangeLight(missile[i]._mlid, { missile[i]._miVar1, missile[i]._miVar2 }, 8); } } } else { - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, missile[i]._miAnimFrame + 7); + ChangeLight(missile[i]._mlid, missile[i].position.tile, missile[i]._miAnimFrame + 7); if (missile[i]._mirange == 0) { missile[i]._miDelFlag = true; AddUnLight(missile[i]._mlid); @@ -5003,7 +5003,7 @@ void MI_Element(int i) cy = missile[i].position.tile.y; px = plr[id].position.tile.x; py = plr[id].position.tile.y; - ChangeLight(missile[i]._mlid, cx, cy, missile[i]._miAnimFrame); + ChangeLight(missile[i]._mlid, missile[i].position.tile, missile[i]._miAnimFrame); if (!CheckBlock(px, py, cx, cy)) CheckMissileCol(i, dam, dam, true, cx, cy, true); if (!CheckBlock(px, py, cx, cy + 1)) @@ -5051,7 +5051,7 @@ void MI_Element(int i) if (cx != missile[i]._miVar1 || cy != missile[i]._miVar2) { missile[i]._miVar1 = cx; missile[i]._miVar2 = cy; - ChangeLight(missile[i]._mlid, cx, cy, 8); + ChangeLight(missile[i]._mlid, { cx, cy }, 8); } if (missile[i]._mirange == 0) { missile[i]._mimfnum = 0; @@ -5071,7 +5071,7 @@ void MI_Bonespirit(int i) dam = missile[i]._midam; id = missile[i]._misource; if (missile[i]._mimfnum == DIR_OMNI) { - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, missile[i]._miAnimFrame); + ChangeLight(missile[i]._mlid, missile[i].position.tile, missile[i]._miAnimFrame); if (missile[i]._mirange == 0) { missile[i]._miDelFlag = true; AddUnLight(missile[i]._mlid); @@ -5102,7 +5102,7 @@ void MI_Bonespirit(int i) if (cx != missile[i]._miVar1 || cy != missile[i]._miVar2) { missile[i]._miVar1 = cx; missile[i]._miVar2 = cy; - ChangeLight(missile[i]._mlid, cx, cy, 8); + ChangeLight(missile[i]._mlid, { cx, cy }, 8); } if (missile[i]._mirange == 0) { SetMissDir(i, DIR_OMNI); @@ -5131,8 +5131,8 @@ void MI_Rportal(int i) if (currlevel != 0 && missile[i]._mimfnum != 1 && missile[i]._mirange != 0) { if (missile[i]._miVar2 == 0) - missile[i]._mlid = AddLight(missile[i].position.tile.x, missile[i].position.tile.y, 1); - ChangeLight(missile[i]._mlid, missile[i].position.tile.x, missile[i].position.tile.y, ExpLight[missile[i]._miVar2]); + missile[i]._mlid = AddLight(missile[i].position.tile, 1); + ChangeLight(missile[i]._mlid, missile[i].position.tile, ExpLight[missile[i]._miVar2]); missile[i]._miVar2++; } if (missile[i]._mirange == 0) { diff --git a/Source/monster.cpp b/Source/monster.cpp index bf9b011f5..d5256ec14 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -810,7 +810,7 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int bosspacksize) if (uniqindex == UMT_HORKDMN) Monst->mlid = NO_LIGHT; // BUGFIX monsters initial light id should be -1 (fixed) else - Monst->mlid = AddLight(Monst->position.tile.x, Monst->position.tile.y, 3); + Monst->mlid = AddLight(Monst->position.tile, 3); if (gbIsMultiplayer) { if (Monst->_mAi == AI_LAZHELP) @@ -1129,7 +1129,7 @@ void InitMonsters() for (i = 0; i < nt; i++) { for (s = -2; s < 2; s++) { for (t = -2; t < 2; t++) - DoVision(s + trigs[i].position.x, t + trigs[i].position.y, 15, false, false); + DoVision(Point { s, t } + trigs[i].position, 15, false, false); } } if (!gbIsSpawn) @@ -1170,7 +1170,7 @@ void InitMonsters() for (i = 0; i < nt; i++) { for (s = -2; s < 2; s++) { for (t = -2; t < 2; t++) - DoUnVision(s + trigs[i].position.x, t + trigs[i].position.y, 15); + DoUnVision(Point { s, t } + trigs[i].position, 15); } } } @@ -1448,7 +1448,7 @@ void M_StartWalk2(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int y monster[i].position.future = { fx, fy }; dMonster[fx][fy] = i + 1; if (monster[i].mlid != NO_LIGHT) - ChangeLightXY(monster[i].mlid, monster[i].position.tile.x, monster[i].position.tile.y); + ChangeLightXY(monster[i].mlid, monster[i].position.tile); monster[i].position.offset = { xoff, yoff }; monster[i]._mmode = MM_WALK2; monster[i].position.velocity = { xvel, yvel }; @@ -1467,7 +1467,7 @@ void M_StartWalk3(int i, int xvel, int yvel, int xoff, int yoff, int xadd, int y int y = mapy + monster[i].position.tile.y; if (monster[i].mlid != NO_LIGHT) - ChangeLightXY(monster[i].mlid, x, y); + ChangeLightXY(monster[i].mlid, { x, y }); dMonster[monster[i].position.tile.x][monster[i].position.tile.y] = -(i + 1); dMonster[fx][fy] = -(i + 1); @@ -1648,8 +1648,8 @@ void M_DiabloDeath(int i, bool sendmsg) M_ClearSquares(k); dMonster[monster[k].position.tile.x][monster[k].position.tile.y] = k + 1; } - AddLight(Monst->position.tile.x, Monst->position.tile.y, 8); - DoVision(Monst->position.tile.x, Monst->position.tile.y, 8, false, true); + AddLight(Monst->position.tile, 8); + DoVision(Monst->position.tile, 8, false, true); dist = std::max(abs(ViewX - Monst->position.tile.x), abs(ViewY - Monst->position.tile.y)); if (dist > 20) dist = 20; @@ -1937,7 +1937,7 @@ void M_ChangeLightOffset(int monst) _myoff *= (ly / 8); if (monster[monst].mlid != NO_LIGHT) - ChangeLightOff(monster[monst].mlid, _mxoff, _myoff); + ChangeLightOff(monster[monst].mlid, { _mxoff, _myoff }); } bool M_DoStand(int i) @@ -1991,7 +1991,7 @@ bool M_DoWalk(int i, int variant) break; } if (monster[i].mlid != NO_LIGHT) - ChangeLightXY(monster[i].mlid, monster[i].position.tile.x, monster[i].position.tile.y); + ChangeLightXY(monster[i].mlid, monster[i].position.tile); M_StartStand(i, monster[i]._mdir); returnValue = true; } else { //We didn't reach new tile so update monster's "sub-tile" position diff --git a/Source/msg.cpp b/Source/msg.cpp index 713b188a2..6b3021724 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1326,7 +1326,7 @@ static DWORD On_WALKXY(TCmd *pCmd, int pnum) if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { ClrPlrPath(plr[pnum]); - MakePlrPath(pnum, p->x, p->y, true); + MakePlrPath(pnum, { p->x, p->y }, true); plr[pnum].destAction = ACTION_NONE; } @@ -1404,7 +1404,7 @@ static DWORD On_GOTOGETITEM(TCmd *pCmd, int pnum) auto *p = (TCmdLocParam1 *)pCmd; if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, p->x, p->y, false); + MakePlrPath(pnum, { p->x, p->y }, false); plr[pnum].destAction = ACTION_PICKUPITEM; plr[pnum].destParam1 = p->wParam1; } @@ -1466,7 +1466,7 @@ static DWORD On_GOTOAGETITEM(TCmd *pCmd, int pnum) auto *p = (TCmdLocParam1 *)pCmd; if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, p->x, p->y, false); + MakePlrPath(pnum, { p->x, p->y }, false); plr[pnum].destAction = ACTION_PICKUPAITEM; plr[pnum].destParam1 = p->wParam1; } @@ -1610,7 +1610,7 @@ static DWORD On_ATTACKXY(TCmd *pCmd, int pnum) auto *p = (TCmdLoc *)pCmd; if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, p->x, p->y, false); + MakePlrPath(pnum, { p->x, p->y }, false); plr[pnum].destAction = ACTION_ATTACK; plr[pnum].destParam1 = p->x; plr[pnum].destParam2 = p->y; @@ -1720,9 +1720,9 @@ static DWORD On_OPOBJXY(TCmd *pCmd, int pnum) if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { if (object[p->wParam1]._oSolidFlag || object[p->wParam1]._oDoorFlag) - MakePlrPath(pnum, p->x, p->y, false); + MakePlrPath(pnum, { p->x, p->y }, false); else - MakePlrPath(pnum, p->x, p->y, true); + MakePlrPath(pnum, { p->x, p->y }, true); plr[pnum].destAction = ACTION_OPERATE; plr[pnum].destParam1 = p->wParam1; } @@ -1736,9 +1736,9 @@ static DWORD On_DISARMXY(TCmd *pCmd, int pnum) if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { if (object[p->wParam1]._oSolidFlag || object[p->wParam1]._oDoorFlag) - MakePlrPath(pnum, p->x, p->y, false); + MakePlrPath(pnum, { p->x, p->y }, false); else - MakePlrPath(pnum, p->x, p->y, true); + MakePlrPath(pnum, { p->x, p->y }, true); plr[pnum].destAction = ACTION_DISARM; plr[pnum].destParam1 = p->wParam1; } @@ -1766,7 +1766,7 @@ static DWORD On_ATTACKID(TCmd *pCmd, int pnum) int distx = abs(plr[pnum].position.tile.x - monster[p->wParam1].position.future.x); int disty = abs(plr[pnum].position.tile.y - monster[p->wParam1].position.future.y); if (distx > 1 || disty > 1) - MakePlrPath(pnum, monster[p->wParam1].position.future.x, monster[p->wParam1].position.future.y, false); + MakePlrPath(pnum, monster[p->wParam1].position.future, false); plr[pnum].destAction = ACTION_ATTACKMON; plr[pnum].destParam1 = p->wParam1; } @@ -1779,7 +1779,7 @@ static DWORD On_ATTACKPID(TCmd *pCmd, int pnum) auto *p = (TCmdParam1 *)pCmd; if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, plr[p->wParam1].position.future.x, plr[p->wParam1].position.future.y, false); + MakePlrPath(pnum, plr[p->wParam1].position.future, false); plr[pnum].destAction = ACTION_ATTACKPLR; plr[pnum].destParam1 = p->wParam1; } @@ -1938,7 +1938,7 @@ static DWORD On_TALKXY(TCmd *pCmd, int pnum) auto *p = (TCmdLocParam1 *)pCmd; if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, p->x, p->y, false); + MakePlrPath(pnum, { p->x, p->y }, false); plr[pnum].destAction = ACTION_TALK; plr[pnum].destParam1 = p->wParam1; } @@ -2248,7 +2248,7 @@ static DWORD On_PLAYER_JOINLEVEL(TCmd *pCmd, int pnum) dFlags[plr[pnum].position.tile.x][plr[pnum].position.tile.y] |= BFLAG_DEAD_PLAYER; } - plr[pnum]._pvid = AddVision(plr[pnum].position.tile.x, plr[pnum].position.tile.y, plr[pnum]._pLightRad, pnum == myplr); + plr[pnum]._pvid = AddVision(plr[pnum].position.tile, plr[pnum]._pLightRad, pnum == myplr); plr[pnum]._plid = NO_LIGHT; } } diff --git a/Source/multi.cpp b/Source/multi.cpp index 5513e3d05..27288ba10 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -497,7 +497,7 @@ void multi_process_network_packets() if (dx > 1 || dy > 1) { plr[dwID].position.future = plr[dwID].position.tile; } - MakePlrPath(dwID, pkt->targx, pkt->targy, true); + MakePlrPath(dwID, { pkt->targx, pkt->targy }, true); } else { plr[dwID].position.tile = { pkt->px, pkt->py }; plr[dwID].position.future = { pkt->px, pkt->py }; diff --git a/Source/objects.cpp b/Source/objects.cpp index c044edab4..ac8068e7a 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1433,7 +1433,7 @@ void AddTrap(int i) void AddObjLight(int i, int r) { if (InitObjFlag) { - DoLighting(object[i].position.x, object[i].position.y, r, -1); + DoLighting(object[i].position, r, -1); object[i]._oVar1 = -1; } else { object[i]._oVar1 = 0; @@ -1920,7 +1920,7 @@ void Obj_Light(int i, int lr) } if (turnon) { if (object[i]._oVar1 == 0) - object[i]._olid = AddLight(ox, oy, lr); + object[i]._olid = AddLight(object[i].position, lr); object[i]._oVar1 = 1; } else { if (object[i]._oVar1 == 1) @@ -2015,7 +2015,7 @@ void ActivateTrapLine(int ttype, int tid) object[oi]._oVar4 = 1; object[oi]._oAnimFlag = 1; object[oi]._oAnimDelay = 1; - object[oi]._olid = AddLight(object[oi].position.x, object[oi].position.y, 1); + object[oi]._olid = AddLight(object[oi].position, 1); } } } @@ -2431,7 +2431,7 @@ void RedoPlayerVision() for (p = 0; p < MAX_PLRS; p++) { if (plr[p].plractive && currlevel == plr[p].plrlevel) { - ChangeVisionXY(plr[p]._pvid, plr[p].position.tile.x, plr[p].position.tile.y); + ChangeVisionXY(plr[p]._pvid, plr[p].position.tile); } } } diff --git a/Source/player.cpp b/Source/player.cpp index d04248e25..7d514a34a 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -1157,12 +1157,12 @@ void InitPlayer(int pnum, bool FirstTime) player.destAction = ACTION_NONE; if (pnum == myplr) { - player._plid = AddLight(player.position.tile.x, player.position.tile.y, player._pLightRad); - ChangeLightXY(myPlayer._plid, myPlayer.position.tile.x, myPlayer.position.tile.y); // fix for a bug where old light is still visible at the entrance after reentering level + player._plid = AddLight(player.position.tile, player._pLightRad); + ChangeLightXY(myPlayer._plid, myPlayer.position.tile); // fix for a bug where old light is still visible at the entrance after reentering level } else { player._plid = NO_LIGHT; } - player._pvid = AddVision(player.position.tile.x, player.position.tile.y, player._pLightRad, pnum == myplr); + player._pvid = AddVision(player.position.tile, player._pLightRad, pnum == myplr); } if (player._pClass == HeroClass::Warrior) { @@ -1248,26 +1248,26 @@ bool PlrDirOK(int pnum, Direction dir) return isOk; } -void PlrClrTrans(int x, int y) +void PlrClrTrans(Point position) { int i, j; - for (i = y - 1; i <= y + 1; i++) { - for (j = x - 1; j <= x + 1; j++) { + for (i = position.y - 1; i <= position.y + 1; i++) { + for (j = position.x - 1; j <= position.x + 1; j++) { TransList[dTransVal[j][i]] = false; } } } -void PlrDoTrans(int x, int y) +void PlrDoTrans(Point position) { int i, j; if (leveltype != DTYPE_CATHEDRAL && leveltype != DTYPE_CATACOMBS) { TransList[1] = true; } else { - for (i = y - 1; i <= y + 1; i++) { - for (j = x - 1; j <= x + 1; j++) { + for (i = position.y - 1; i <= position.y + 1; i++) { + for (j = position.x - 1; j <= position.x + 1; j++) { if (!nSolidTable[dPiece[j][i]] && dTransVal[j][i]) { TransList[dTransVal[j][i]] = true; } @@ -1297,8 +1297,8 @@ void FixPlayerLocation(int pnum, Direction bDir) ViewX = player.position.tile.x; ViewY = player.position.tile.y; } - ChangeLightXY(player._plid, player.position.tile.x, player.position.tile.y); - ChangeVisionXY(player._pvid, player.position.tile.x, player.position.tile.y); + ChangeLightXY(player._plid, player.position.tile); + ChangeVisionXY(player._pvid, player.position.tile); } void StartStand(int pnum, Direction dir) @@ -1362,7 +1362,7 @@ static void PM_ChangeLightOff(PlayerStruct &player) if (abs(lx - offx) < 3 && abs(ly - offy) < 3) return; - ChangeLightOff(player._plid, x, y); + ChangeLightOff(player._plid, { x, y }); } void PM_ChangeOffset(int pnum) @@ -1441,7 +1441,7 @@ void StartWalk(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int y dPlayer[player.position.tile.x][player.position.tile.y] = pnum + 1; player.position.offset = { xoff, yoff }; // Offset player sprite to align with their previous tile position - ChangeLightXY(player._plid, player.position.tile.x, player.position.tile.y); + ChangeLightXY(player._plid, player.position.tile); PM_ChangeLightOff(player); player._pmode = PM_WALK2; @@ -1461,7 +1461,7 @@ void StartWalk(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int y player.position.offset = { xoff, yoff }; // Offset player sprite to align with their previous tile position if (leveltype != DTYPE_TOWN) { - ChangeLightXY(player._plid, x, y); + ChangeLightXY(player._plid, { x, y }); PM_ChangeLightOff(player); } @@ -2320,8 +2320,8 @@ bool PM_DoWalk(int pnum, int variant) //Update the coordinates for lighting and vision entries for the player if (leveltype != DTYPE_TOWN) { - ChangeLightXY(player._plid, player.position.tile.x, player.position.tile.y); - ChangeVisionXY(player._pvid, player.position.tile.x, player.position.tile.y); + ChangeLightXY(player._plid, player.position.tile); + ChangeVisionXY(player._pvid, player.position.tile); } //Update the "camera" tile position @@ -2340,7 +2340,7 @@ bool PM_DoWalk(int pnum, int variant) //Reset the "sub-tile" position of the player's light entry to 0 if (leveltype != DTYPE_TOWN) { - ChangeLightOff(player._plid, 0, 0); + ChangeLightOff(player._plid, { 0, 0 }); } AutoGoldPickup(pnum); @@ -3173,12 +3173,12 @@ void CheckNewPath(int pnum, bool pmWillBeCalled) if (player.destAction == ACTION_ATTACKMON) { i = player.destParam1; - MakePlrPath(pnum, monster[i].position.future.x, monster[i].position.future.y, false); + MakePlrPath(pnum, monster[i].position.future, false); } if (player.destAction == ACTION_ATTACKPLR) { auto &target = plr[player.destParam1]; - MakePlrPath(pnum, target.position.future.x, target.position.future.y, false); + MakePlrPath(pnum, target.position.future, false); } Direction d; @@ -3747,7 +3747,7 @@ bool PosOkPlayer(int pnum, int x, int y) return true; } -void MakePlrPath(int pnum, int xx, int yy, bool endspace) +void MakePlrPath(int pnum, Point targetPosition, bool endspace) { int path; @@ -3756,48 +3756,17 @@ void MakePlrPath(int pnum, int xx, int yy, bool endspace) } auto &player = plr[pnum]; - if (player.position.future.x == xx && player.position.future.y == yy) { + if (player.position.future == targetPosition) { return; } - path = FindPath(PosOkPlayer, pnum, player.position.future.x, player.position.future.y, xx, yy, player.walkpath); + path = FindPath(PosOkPlayer, pnum, player.position.future.x, player.position.future.y, targetPosition.x, targetPosition.y, player.walkpath); if (!path) { return; } if (!endspace) { path--; - - switch (player.walkpath[path]) { - case WALK_NE: - yy++; - break; - case WALK_NW: - xx++; - break; - case WALK_SE: - xx--; - break; - case WALK_SW: - yy--; - break; - case WALK_N: - xx++; - yy++; - break; - case WALK_E: - xx--; - yy++; - break; - case WALK_S: - xx--; - yy--; - break; - case WALK_W: - xx++; - yy--; - break; - } } player.walkpath[path] = WALK_NONE; diff --git a/Source/player.h b/Source/player.h index af4b8d3a6..90661aaf5 100644 --- a/Source/player.h +++ b/Source/player.h @@ -430,8 +430,8 @@ void ApplyPlrDamage(int pnum, int dam, int minHP = 0, int frac = 0, int earflag void InitPlayer(int pnum, bool FirstTime); void InitMultiView(); bool SolidLoc(int x, int y); -void PlrClrTrans(int x, int y); -void PlrDoTrans(int x, int y); +void PlrClrTrans(Point position); +void PlrDoTrans(Point position); void SetPlayerOld(PlayerStruct &player); void FixPlayerLocation(int pnum, Direction bDir); void StartStand(int pnum, Direction dir); @@ -451,7 +451,7 @@ void StartWarpLvl(int pnum, int pidx); void ProcessPlayers(); void ClrPlrPath(PlayerStruct &player); bool PosOkPlayer(int pnum, int x, int y); -void MakePlrPath(int pnum, int xx, int yy, bool endspace); +void MakePlrPath(int pnum, Point targetPosition, bool endspace); void CheckPlrSpell(); void SyncPlrAnim(int pnum); void SyncInitPlrPos(int pnum); diff --git a/Source/portal.cpp b/Source/portal.cpp index c246152bf..f98ce7c29 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -54,7 +54,7 @@ void AddWarpMissile(int i, int x, int y) SetMissDir(mi, 1); if (currlevel != 0) - missile[mi]._mlid = AddLight(missile[mi].position.tile.x, missile[mi].position.tile.y, 15); + missile[mi]._mlid = AddLight(missile[mi].position.tile, 15); missiledata[MIS_TOWN].mlSFX = LS_SENTINEL; }