From 5fce9c514546a3489e770bd3eab868cad3ffe143 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Mon, 11 Nov 2024 20:24:37 -0500 Subject: [PATCH] Optimize --- Source/player.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Source/player.cpp b/Source/player.cpp index f69246456b4..c10df6bcf37 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3123,18 +3123,6 @@ void CheckPlrSpell(bool isShiftHeld, SpellID spellID, SpellType spellType) return; } - Point targetedTile = cursPosition; - - if (spellID == SpellID::Teleport && myPlayer.executedSpell.spellId == SpellID::Teleport) { - // Check if the player is attempting to queue Teleport onto a tile that is currently being targeted with Teleport, or a nearby tile - if (cursPosition.WalkingDistance(myPlayer.position.temp) <= 1) { - // Get the relative displacement from the player's current position to the cursor position - WorldTileDisplacement relativeMove = cursPosition - static_cast(myPlayer.position.tile); - // Target the tile the relative distance away from the player's targeted Teleport tile - targetedTile = myPlayer.position.temp + relativeMove; - } - } - if (!addflag) { if (spellType == SpellType::Spell) { switch (spellcheck) { @@ -3166,6 +3154,16 @@ void CheckPlrSpell(bool isShiftHeld, SpellID spellID, SpellType spellType) LastMouseButtonAction = MouseActionType::SpellPlayerTarget; NetSendCmdParam5(true, CMD_SPELLPID, PlayerUnderCursor->getId(), static_cast(spellID), static_cast(spellType), spellLevel, spellFrom); } else { + Point targetedTile = cursPosition; + if (spellID == SpellID::Teleport && myPlayer.executedSpell.spellId == SpellID::Teleport) { + // Check if the player is attempting to queue Teleport onto a tile that is currently being targeted with Teleport, or a nearby tile + if (cursPosition.WalkingDistance(myPlayer.position.temp) <= 1) { + // Get the relative displacement from the player's current position to the cursor position + WorldTileDisplacement relativeMove = cursPosition - static_cast(myPlayer.position.tile); + // Target the tile the relative distance away from the player's targeted Teleport tile + targetedTile = myPlayer.position.temp + relativeMove; + } + } LastMouseButtonAction = MouseActionType::Spell; NetSendCmdLocParam4(true, CMD_SPELLXY, targetedTile, static_cast(spellID), static_cast(spellType), spellLevel, spellFrom); }