Browse Source

Use a pointer to a player instance instead of network id for cursor hovering

pull/5220/head
ephphatha 2 years ago committed by Anders Jenbo
parent
commit
3b458376bb
  1. 4
      Source/control.cpp
  2. 27
      Source/controls/plrctrls.cpp
  3. 29
      Source/cursor.cpp
  4. 3
      Source/cursor.h
  5. 24
      Source/diablo.cpp
  6. 2
      Source/engine/render/scrollrt.cpp
  7. 4
      Source/player.cpp
  8. 12
      Source/track.cpp

4
Source/control.cpp

@ -1229,9 +1229,9 @@ void DrawInfoBox(const Surface &out)
InfoString = std::string_view(Towners[pcursmonst].name); InfoString = std::string_view(Towners[pcursmonst].name);
} }
} }
if (pcursplr != -1) { if (PlayerUnderCursor != nullptr) {
InfoColor = UiFlags::ColorWhitegold; InfoColor = UiFlags::ColorWhitegold;
auto &target = Players[pcursplr]; auto &target = *PlayerUnderCursor;
InfoString = std::string_view(target._pName); InfoString = std::string_view(target._pName);
AddPanelString(fmt::format(fmt::runtime(_("{:s}, Level: {:d}")), target.getClassName(), target.getCharacterLevel())); AddPanelString(fmt::format(fmt::runtime(_("{:s}, Level: {:d}")), target.getClassName(), target.getCharacterLevel()));
AddPanelString(fmt::format(fmt::runtime(_("Hit Points {:d} of {:d}")), target._pHitPoints >> 6, target._pMaxHP >> 6)); AddPanelString(fmt::format(fmt::runtime(_("Hit Points {:d} of {:d}")), target._pHitPoints >> 6, target._pMaxHP >> 6));

27
Source/controls/plrctrls.cpp

@ -382,8 +382,7 @@ void CheckPlayerNearby()
if (myPlayer.friendlyMode && spl != SpellID::Resurrect && spl != SpellID::HealOther) if (myPlayer.friendlyMode && spl != SpellID::Resurrect && spl != SpellID::HealOther)
return; return;
for (size_t i = 0; i < Players.size(); i++) { for (const Player &player : Players) {
const Player &player = Players[i];
if (&player == MyPlayer) if (&player == MyPlayer)
continue; continue;
const int mx = player.position.future.x; const int mx = player.position.future.x;
@ -401,15 +400,15 @@ void CheckPlayerNearby()
continue; continue;
} }
if (pcursplr != -1 && distance < newDdistance) if (PlayerUnderCursor != nullptr && distance < newDdistance)
continue; continue;
const int newRotations = GetRotaryDistance(player.position.future); const int newRotations = GetRotaryDistance(player.position.future);
if (pcursplr != -1 && distance == newDdistance && rotations < newRotations) if (PlayerUnderCursor != nullptr && distance == newDdistance && rotations < newRotations)
continue; continue;
distance = newDdistance; distance = newDdistance;
rotations = newRotations; rotations = newRotations;
pcursplr = i; PlayerUnderCursor = &player;
} }
} }
@ -475,7 +474,7 @@ void FindTrigger()
} }
} }
if (pcursmonst != -1 || pcursplr != -1 || cursPosition.x == -1 || cursPosition.y == -1) if (pcursmonst != -1 || PlayerUnderCursor != nullptr || cursPosition.x == -1 || cursPosition.y == -1)
return; // Prefer monster/player info text return; // Prefer monster/player info text
CheckTrigForce(); CheckTrigForce();
@ -534,8 +533,8 @@ void Interact()
return; return;
} }
if (leveltype != DTYPE_TOWN && pcursplr != -1 && !myPlayer.friendlyMode) { if (leveltype != DTYPE_TOWN && PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) {
NetSendCmdParam1(true, myPlayer.UsesRangedWeapon() ? CMD_RATTACKPID : CMD_ATTACKPID, pcursplr); NetSendCmdParam1(true, myPlayer.UsesRangedWeapon() ? CMD_RATTACKPID : CMD_ATTACKPID, PlayerUnderCursor->getId());
LastMouseButtonAction = MouseActionType::AttackPlayerTarget; LastMouseButtonAction = MouseActionType::AttackPlayerTarget;
return; return;
} }
@ -1742,14 +1741,14 @@ void plrctrls_after_check_curs_move()
if (ControllerActionHeld != GameActionType_NONE && IsNoneOf(LastMouseButtonAction, MouseActionType::None, MouseActionType::Attack, MouseActionType::Spell)) { if (ControllerActionHeld != GameActionType_NONE && IsNoneOf(LastMouseButtonAction, MouseActionType::None, MouseActionType::Attack, MouseActionType::Spell)) {
InvalidateTargets(); InvalidateTargets();
if (pcursmonst == -1 && ObjectUnderCursor == nullptr && pcursitem == -1 && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && pcursplr == -1) { if (pcursmonst == -1 && ObjectUnderCursor == nullptr && pcursitem == -1 && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && PlayerUnderCursor == nullptr) {
FindTrigger(); FindTrigger();
} }
return; return;
} }
// Clear focuse set by cursor // Clear focuse set by cursor
pcursplr = -1; PlayerUnderCursor = nullptr;
pcursmonst = -1; pcursmonst = -1;
pcursitem = -1; pcursitem = -1;
ObjectUnderCursor = nullptr; ObjectUnderCursor = nullptr;
@ -1914,7 +1913,7 @@ bool SpellHasActorTarget()
cursPosition = Monsters[pcursmonst].position.tile; cursPosition = Monsters[pcursmonst].position.tile;
} }
return pcursplr != -1 || pcursmonst != -1; return PlayerUnderCursor != nullptr || pcursmonst != -1;
} }
void UpdateSpellTarget(SpellID spell) void UpdateSpellTarget(SpellID spell)
@ -1922,7 +1921,7 @@ void UpdateSpellTarget(SpellID spell)
if (SpellHasActorTarget()) if (SpellHasActorTarget())
return; return;
pcursplr = -1; PlayerUnderCursor = nullptr;
pcursmonst = -1; pcursmonst = -1;
Player &myPlayer = *MyPlayer; Player &myPlayer = *MyPlayer;
@ -2002,7 +2001,7 @@ void PerformSpellAction()
const Player &myPlayer = *MyPlayer; const Player &myPlayer = *MyPlayer;
SpellID spl = myPlayer._pRSpell; SpellID spl = myPlayer._pRSpell;
if ((pcursplr == -1 && (spl == SpellID::Resurrect || spl == SpellID::HealOther)) if ((PlayerUnderCursor == nullptr && (spl == SpellID::Resurrect || spl == SpellID::HealOther))
|| (ObjectUnderCursor == nullptr && spl == SpellID::TrapDisarm)) { || (ObjectUnderCursor == nullptr && spl == SpellID::TrapDisarm)) {
myPlayer.Say(HeroSpeech::ICantCastThatHere); myPlayer.Say(HeroSpeech::ICantCastThatHere);
return; return;
@ -2010,7 +2009,7 @@ void PerformSpellAction()
UpdateSpellTarget(myPlayer._pRSpell); UpdateSpellTarget(myPlayer._pRSpell);
CheckPlrSpell(false); CheckPlrSpell(false);
if (pcursplr != -1) if (PlayerUnderCursor != nullptr)
LastMouseButtonAction = MouseActionType::SpellPlayerTarget; LastMouseButtonAction = MouseActionType::SpellPlayerTarget;
else if (pcursmonst != -1) else if (pcursmonst != -1)
LastMouseButtonAction = MouseActionType::SpellMonsterTarget; LastMouseButtonAction = MouseActionType::SpellMonsterTarget;

29
Source/cursor.cpp

@ -183,7 +183,7 @@ bool TrySelectPlayer(bool flipflag, int mx, int my)
Player &player = Players[playerId]; Player &player = Players[playerId];
if (&player != MyPlayer && player._pHitPoints != 0) { if (&player != MyPlayer && player._pHitPoints != 0) {
cursPosition = Point { mx, my } + Displacement { 1, 0 }; cursPosition = Point { mx, my } + Displacement { 1, 0 };
pcursplr = static_cast<int8_t>(playerId); PlayerUnderCursor = &player;
} }
} }
if (flipflag && my + 1 < MAXDUNY && dPlayer[mx][my + 1] != 0) { if (flipflag && my + 1 < MAXDUNY && dPlayer[mx][my + 1] != 0) {
@ -191,21 +191,22 @@ bool TrySelectPlayer(bool flipflag, int mx, int my)
Player &player = Players[playerId]; Player &player = Players[playerId];
if (&player != MyPlayer && player._pHitPoints != 0) { if (&player != MyPlayer && player._pHitPoints != 0) {
cursPosition = Point { mx, my } + Displacement { 0, 1 }; cursPosition = Point { mx, my } + Displacement { 0, 1 };
pcursplr = static_cast<int8_t>(playerId); PlayerUnderCursor = &player;
} }
} }
if (dPlayer[mx][my] != 0) { if (dPlayer[mx][my] != 0) {
const uint8_t playerId = std::abs(dPlayer[mx][my]) - 1; const uint8_t playerId = std::abs(dPlayer[mx][my]) - 1;
if (playerId != MyPlayerId) { Player &player = Players[playerId];
if (&player != MyPlayer) {
cursPosition = { mx, my }; cursPosition = { mx, my };
pcursplr = static_cast<int8_t>(playerId); PlayerUnderCursor = &player;
} }
} }
if (TileContainsDeadPlayer({ mx, my })) { if (TileContainsDeadPlayer({ mx, my })) {
for (const Player &player : Players) { for (const Player &player : Players) {
if (player.position.tile == Point { mx, my } && &player != MyPlayer) { if (player.position.tile == Point { mx, my } && &player != MyPlayer) {
cursPosition = { mx, my }; cursPosition = { mx, my };
pcursplr = static_cast<int8_t>(player.getId()); PlayerUnderCursor = &player;
} }
} }
} }
@ -216,7 +217,7 @@ bool TrySelectPlayer(bool flipflag, int mx, int my)
for (const Player &player : Players) { for (const Player &player : Players) {
if (player.position.tile.x == mx + xx && player.position.tile.y == my + yy && &player != MyPlayer) { if (player.position.tile.x == mx + xx && player.position.tile.y == my + yy && &player != MyPlayer) {
cursPosition = Point { mx, my } + Displacement { xx, yy }; cursPosition = Point { mx, my } + Displacement { xx, yy };
pcursplr = static_cast<int8_t>(player.getId()); PlayerUnderCursor = &player;
} }
} }
} }
@ -228,11 +229,11 @@ bool TrySelectPlayer(bool flipflag, int mx, int my)
const Player &player = Players[playerId]; const Player &player = Players[playerId];
if (&player != MyPlayer && player._pHitPoints != 0) { if (&player != MyPlayer && player._pHitPoints != 0) {
cursPosition = Point { mx, my } + Displacement { 1, 1 }; cursPosition = Point { mx, my } + Displacement { 1, 1 };
pcursplr = static_cast<int8_t>(playerId); PlayerUnderCursor = &player;
} }
} }
return pcursplr != -1; return PlayerUnderCursor != nullptr;
} }
bool TrySelectObject(bool flipflag, Point tile) bool TrySelectObject(bool flipflag, Point tile)
@ -382,7 +383,7 @@ bool TrySelectPixelBased(Point tile)
Displacement renderingOffset = player.getRenderingOffset(sprite); Displacement renderingOffset = player.getRenderingOffset(sprite);
if (checkSprite(adjacentTile, sprite, renderingOffset)) { if (checkSprite(adjacentTile, sprite, renderingOffset)) {
cursPosition = adjacentTile; cursPosition = adjacentTile;
pcursplr = playerId; PlayerUnderCursor = &player;
return true; return true;
} }
} }
@ -394,7 +395,7 @@ bool TrySelectPixelBased(Point tile)
Displacement renderingOffset = player.getRenderingOffset(sprite); Displacement renderingOffset = player.getRenderingOffset(sprite);
if (checkSprite(adjacentTile, sprite, renderingOffset)) { if (checkSprite(adjacentTile, sprite, renderingOffset)) {
cursPosition = adjacentTile; cursPosition = adjacentTile;
pcursplr = static_cast<int8_t>(player.getId()); PlayerUnderCursor = &player;
return true; return true;
} }
} }
@ -443,7 +444,7 @@ int8_t pcursitem;
/** Current highlighted object */ /** Current highlighted object */
Object *ObjectUnderCursor; Object *ObjectUnderCursor;
/** Current highlighted player */ /** Current highlighted player */
int8_t pcursplr; const Player *PlayerUnderCursor;
/** Current highlighted tile position */ /** Current highlighted tile position */
Point cursPosition; Point cursPosition;
/** Previously highlighted monster */ /** Previously highlighted monster */
@ -627,7 +628,7 @@ void InitLevelCursor()
ObjectUnderCursor = nullptr; ObjectUnderCursor = nullptr;
pcursitem = -1; pcursitem = -1;
pcursstashitem = StashStruct::EmptyCell; pcursstashitem = StashStruct::EmptyCell;
pcursplr = -1; PlayerUnderCursor = nullptr;
ClearCursor(); ClearCursor();
} }
@ -762,7 +763,7 @@ void CheckCursMove()
if ((sgbMouseDown != CLICK_NONE || ControllerActionHeld != GameActionType_NONE) && IsNoneOf(LastMouseButtonAction, MouseActionType::None, MouseActionType::Attack, MouseActionType::Spell)) { if ((sgbMouseDown != CLICK_NONE || ControllerActionHeld != GameActionType_NONE) && IsNoneOf(LastMouseButtonAction, MouseActionType::None, MouseActionType::Attack, MouseActionType::Spell)) {
InvalidateTargets(); InvalidateTargets();
if (pcursmonst == -1 && ObjectUnderCursor == nullptr && pcursitem == -1 && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && pcursplr == -1) { if (pcursmonst == -1 && ObjectUnderCursor == nullptr && pcursitem == -1 && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && PlayerUnderCursor == nullptr) {
cursPosition = { mx, my }; cursPosition = { mx, my };
CheckTrigForce(); CheckTrigForce();
CheckTown(); CheckTown();
@ -782,7 +783,7 @@ void CheckCursMove()
} }
pcursinvitem = -1; pcursinvitem = -1;
pcursstashitem = StashStruct::EmptyCell; pcursstashitem = StashStruct::EmptyCell;
pcursplr = -1; PlayerUnderCursor = nullptr;
ShowUniqueItemInfoBox = false; ShowUniqueItemInfoBox = false;
panelflag = false; panelflag = false;
trigflag = false; trigflag = false;

3
Source/cursor.h

@ -39,7 +39,8 @@ extern int8_t pcursitem;
struct Object; // Defined in objects.h struct Object; // Defined in objects.h
extern Object *ObjectUnderCursor; extern Object *ObjectUnderCursor;
extern int8_t pcursplr; struct Player; // Defined in player.h
extern const Player *PlayerUnderCursor;
extern Point cursPosition; extern Point cursPosition;
extern DVL_API_FOR_TEST int pcurs; extern DVL_API_FOR_TEST int pcurs;

24
Source/diablo.cpp

@ -245,7 +245,7 @@ void LeftMouseCmd(bool bShift)
NetSendCmdLocParam1(true, invflag ? CMD_GOTOGETITEM : CMD_GOTOAGETITEM, cursPosition, pcursitem); NetSendCmdLocParam1(true, invflag ? CMD_GOTOGETITEM : CMD_GOTOAGETITEM, cursPosition, pcursitem);
if (pcursmonst != -1) if (pcursmonst != -1)
NetSendCmdLocParam1(true, CMD_TALKXY, cursPosition, pcursmonst); NetSendCmdLocParam1(true, CMD_TALKXY, cursPosition, pcursmonst);
if (pcursitem == -1 && pcursmonst == -1 && pcursplr == -1) { if (pcursitem == -1 && pcursmonst == -1 && PlayerUnderCursor == nullptr) {
LastMouseButtonAction = MouseActionType::Walk; LastMouseButtonAction = MouseActionType::Walk;
NetSendCmdLoc(MyPlayerId, true, CMD_WALKXY, cursPosition); NetSendCmdLoc(MyPlayerId, true, CMD_WALKXY, cursPosition);
} }
@ -270,9 +270,9 @@ void LeftMouseCmd(bool bShift)
LastMouseButtonAction = MouseActionType::AttackMonsterTarget; LastMouseButtonAction = MouseActionType::AttackMonsterTarget;
NetSendCmdParam1(true, CMD_RATTACKID, pcursmonst); NetSendCmdParam1(true, CMD_RATTACKID, pcursmonst);
} }
} else if (pcursplr != -1 && !myPlayer.friendlyMode) { } else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) {
LastMouseButtonAction = MouseActionType::AttackPlayerTarget; LastMouseButtonAction = MouseActionType::AttackPlayerTarget;
NetSendCmdParam1(true, CMD_RATTACKPID, pcursplr); NetSendCmdParam1(true, CMD_RATTACKPID, PlayerUnderCursor->getId());
} }
} else { } else {
if (bShift) { if (bShift) {
@ -290,12 +290,12 @@ void LeftMouseCmd(bool bShift)
} else if (pcursmonst != -1) { } else if (pcursmonst != -1) {
LastMouseButtonAction = MouseActionType::AttackMonsterTarget; LastMouseButtonAction = MouseActionType::AttackMonsterTarget;
NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst); NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst);
} else if (pcursplr != -1 && !myPlayer.friendlyMode) { } else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) {
LastMouseButtonAction = MouseActionType::AttackPlayerTarget; LastMouseButtonAction = MouseActionType::AttackPlayerTarget;
NetSendCmdParam1(true, CMD_ATTACKPID, pcursplr); NetSendCmdParam1(true, CMD_ATTACKPID, PlayerUnderCursor->getId());
} }
} }
if (!bShift && pcursitem == -1 && ObjectUnderCursor == nullptr && pcursmonst == -1 && pcursplr == -1) { if (!bShift && pcursitem == -1 && ObjectUnderCursor == nullptr && pcursmonst == -1 && PlayerUnderCursor == nullptr) {
LastMouseButtonAction = MouseActionType::Walk; LastMouseButtonAction = MouseActionType::Walk;
NetSendCmdLoc(MyPlayerId, true, CMD_WALKXY, cursPosition); NetSendCmdLoc(MyPlayerId, true, CMD_WALKXY, cursPosition);
} }
@ -2490,8 +2490,8 @@ int DiabloMain(int argc, char **argv)
bool TryIconCurs() bool TryIconCurs()
{ {
if (pcurs == CURSOR_RESURRECT) { if (pcurs == CURSOR_RESURRECT) {
if (pcursplr != -1) { if (PlayerUnderCursor != nullptr) {
NetSendCmdParam1(true, CMD_RESURRECT, pcursplr); NetSendCmdParam1(true, CMD_RESURRECT, PlayerUnderCursor->getId());
NewCursor(CURSOR_HAND); NewCursor(CURSOR_HAND);
return true; return true;
} }
@ -2500,8 +2500,8 @@ bool TryIconCurs()
} }
if (pcurs == CURSOR_HEALOTHER) { if (pcurs == CURSOR_HEALOTHER) {
if (pcursplr != -1) { if (PlayerUnderCursor != nullptr) {
NetSendCmdParam1(true, CMD_HEALOTHER, pcursplr); NetSendCmdParam1(true, CMD_HEALOTHER, PlayerUnderCursor->getId());
NewCursor(CURSOR_HAND); NewCursor(CURSOR_HAND);
return true; return true;
} }
@ -2572,8 +2572,8 @@ bool TryIconCurs()
NetSendCmdLocParam5(true, CMD_SPELLXYD, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), static_cast<uint16_t>(sd), spellLevel, spellFrom); NetSendCmdLocParam5(true, CMD_SPELLXYD, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), static_cast<uint16_t>(sd), spellLevel, spellFrom);
} else if (pcursmonst != -1) { } else if (pcursmonst != -1) {
NetSendCmdParam5(true, CMD_SPELLID, pcursmonst, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom); NetSendCmdParam5(true, CMD_SPELLID, pcursmonst, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
} else if (pcursplr != -1 && !myPlayer.friendlyMode) { } else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) {
NetSendCmdParam5(true, CMD_SPELLPID, pcursplr, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom); NetSendCmdParam5(true, CMD_SPELLPID, PlayerUnderCursor->getId(), static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
} else { } else {
NetSendCmdLocParam4(true, CMD_SPELLXY, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom); NetSendCmdLocParam4(true, CMD_SPELLXY, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
} }

2
Source/engine/render/scrollrt.cpp

@ -384,7 +384,7 @@ void DrawPlayer(const Surface &out, const Player &player, Point tilePosition, Po
const ClxSprite sprite = player.currentSprite(); const ClxSprite sprite = player.currentSprite();
Point spriteBufferPosition = targetBufferPosition + player.getRenderingOffset(sprite); Point spriteBufferPosition = targetBufferPosition + player.getRenderingOffset(sprite);
if (static_cast<size_t>(pcursplr) < Players.size() && &player == &Players[pcursplr]) if (&player == PlayerUnderCursor)
ClxDrawOutlineSkipColorZero(out, 165, spriteBufferPosition, sprite); ClxDrawOutlineSkipColorZero(out, 165, spriteBufferPosition, sprite);
if (&player == MyPlayer && IsNoneOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) { if (&player == MyPlayer && IsNoneOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) {

4
Source/player.cpp

@ -3206,9 +3206,9 @@ void CheckPlrSpell(bool isShiftHeld, SpellID spellID, SpellType spellType)
} else if (pcursmonst != -1 && !isShiftHeld) { } else if (pcursmonst != -1 && !isShiftHeld) {
LastMouseButtonAction = MouseActionType::SpellMonsterTarget; LastMouseButtonAction = MouseActionType::SpellMonsterTarget;
NetSendCmdParam5(true, CMD_SPELLID, pcursmonst, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom); NetSendCmdParam5(true, CMD_SPELLID, pcursmonst, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
} else if (pcursplr != -1 && !isShiftHeld && !myPlayer.friendlyMode) { } else if (PlayerUnderCursor != nullptr && !isShiftHeld && !myPlayer.friendlyMode) {
LastMouseButtonAction = MouseActionType::SpellPlayerTarget; LastMouseButtonAction = MouseActionType::SpellPlayerTarget;
NetSendCmdParam5(true, CMD_SPELLPID, pcursplr, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom); NetSendCmdParam5(true, CMD_SPELLPID, PlayerUnderCursor->getId(), static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);
} else { } else {
LastMouseButtonAction = MouseActionType::Spell; LastMouseButtonAction = MouseActionType::Spell;
NetSendCmdLocParam4(true, CMD_SPELLXY, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom); NetSendCmdLocParam4(true, CMD_SPELLXY, cursPosition, static_cast<int8_t>(spellID), static_cast<uint8_t>(spellType), spellLevel, spellFrom);

12
Source/track.cpp

@ -49,12 +49,12 @@ void InvalidateTargets()
if (ObjectUnderCursor != nullptr && ObjectUnderCursor->_oSelFlag < 1) if (ObjectUnderCursor != nullptr && ObjectUnderCursor->_oSelFlag < 1)
ObjectUnderCursor = nullptr; ObjectUnderCursor = nullptr;
if (pcursplr != -1) { if (PlayerUnderCursor != nullptr) {
Player &targetPlayer = Players[pcursplr]; const Player &targetPlayer = *PlayerUnderCursor;
if (targetPlayer._pmode == PM_DEATH || targetPlayer._pmode == PM_QUIT || !targetPlayer.plractive if (targetPlayer._pmode == PM_DEATH || targetPlayer._pmode == PM_QUIT || !targetPlayer.plractive
|| !targetPlayer.isOnActiveLevel() || targetPlayer._pHitPoints >> 6 <= 0 || !targetPlayer.isOnActiveLevel() || targetPlayer._pHitPoints >> 6 <= 0
|| !IsTileLit(targetPlayer.position.tile)) || !IsTileLit(targetPlayer.position.tile))
pcursplr = -1; PlayerUnderCursor = nullptr;
} }
} }
@ -91,8 +91,8 @@ void RepeatMouseAction()
NetSendCmdParam1(true, rangedAttack ? CMD_RATTACKID : CMD_ATTACKID, pcursmonst); NetSendCmdParam1(true, rangedAttack ? CMD_RATTACKID : CMD_ATTACKID, pcursmonst);
break; break;
case MouseActionType::AttackPlayerTarget: case MouseActionType::AttackPlayerTarget:
if (pcursplr != -1 && !myPlayer.friendlyMode) if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode)
NetSendCmdParam1(true, rangedAttack ? CMD_RATTACKPID : CMD_ATTACKPID, pcursplr); NetSendCmdParam1(true, rangedAttack ? CMD_RATTACKPID : CMD_ATTACKPID, PlayerUnderCursor->getId());
break; break;
case MouseActionType::Spell: case MouseActionType::Spell:
if (ControlMode != ControlTypes::KeyboardAndMouse) { if (ControlMode != ControlTypes::KeyboardAndMouse) {
@ -105,7 +105,7 @@ void RepeatMouseAction()
CheckPlrSpell(false); CheckPlrSpell(false);
break; break;
case MouseActionType::SpellPlayerTarget: case MouseActionType::SpellPlayerTarget:
if (pcursplr != -1 && !myPlayer.friendlyMode) if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode)
CheckPlrSpell(false); CheckPlrSpell(false);
break; break;
case MouseActionType::OperateObject: case MouseActionType::OperateObject:

Loading…
Cancel
Save