From 96e1d5cabab36e48ebbe5c66bac611529b3d3d33 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 25 Oct 2021 20:17:21 +0200 Subject: [PATCH] Fix spell properties incorrectly being capped at 8 Fixes #3187 Revert #3021 destParam3 had been typed ad Direction, but is also sometimes used for other values. --- Source/loadsave.cpp | 2 +- Source/msg.cpp | 10 +++------- Source/player.cpp | 6 +++--- Source/player.h | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 35cb28044..87f885f2c 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -309,7 +309,7 @@ void LoadPlayer(LoadHelper &file, Player &player) player.destAction = static_cast(file.NextLE()); player.destParam1 = file.NextLE(); player.destParam2 = file.NextLE(); - player.destParam3 = static_cast(file.NextLE()); + player.destParam3 = file.NextLE(); player.destParam4 = file.NextLE(); player.plrlevel = file.NextLE(); player.position.tile.x = file.NextLE(); diff --git a/Source/msg.cpp b/Source/msg.cpp index f55919b76..018f9cb98 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -976,8 +976,6 @@ DWORD OnSpellWall(const TCmd *pCmd, Player &player) return sizeof(message); if (message.wParam2 > RSPLTYPE_INVALID) return sizeof(message); - if (message.wParam3 > static_cast(Direction::SouthEast)) - return sizeof(message); auto spell = static_cast(message.wParam1); if (currlevel == 0 && !spelldata[spell].sTownSpell) { @@ -989,7 +987,7 @@ DWORD OnSpellWall(const TCmd *pCmd, Player &player) player.destAction = ACTION_SPELLWALL; player.destParam1 = position.x; player.destParam2 = position.y; - player.destParam3 = static_cast(message.wParam3); + player.destParam3 = message.wParam3; player.destParam4 = message.wParam4; player._pSpell = spell; player._pSplType = static_cast(message.wParam2); @@ -1024,7 +1022,7 @@ DWORD OnSpellTile(const TCmd *pCmd, Player &player) player.destAction = ACTION_SPELL; player.destParam1 = position.x; player.destParam2 = position.y; - player.destParam4 = message.wParam3; + player.destParam3 = message.wParam3; player._pSpell = spell; player._pSplType = static_cast(message.wParam2); @@ -1044,8 +1042,6 @@ DWORD OnTargetSpellTile(const TCmd *pCmd, Player &player) return sizeof(message); if (message.wParam1 > SPL_LAST) return sizeof(message); - if (message.wParam2 > static_cast(Direction::SouthEast)) - return sizeof(message); auto spell = static_cast(message.wParam1); if (currlevel == 0 && !spelldata[spell].sTownSpell) { @@ -1057,7 +1053,7 @@ DWORD OnTargetSpellTile(const TCmd *pCmd, Player &player) player.destAction = ACTION_SPELL; player.destParam1 = position.x; player.destParam2 = position.y; - player.destParam3 = static_cast(message.wParam2); + player.destParam3 = message.wParam2; player._pSpell = spell; player._pSplType = RSPLTYPE_INVALID; player._pSplFrom = 2; diff --git a/Source/player.cpp b/Source/player.cpp index 4d4acacb1..91154b979 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -1701,11 +1701,11 @@ void CheckNewPath(int pnum, bool pmWillBeCalled) case ACTION_SPELL: d = GetDirection(player.position.tile, { player.destParam1, player.destParam2 }); StartSpell(pnum, d, player.destParam1, player.destParam2); - player.spellLevel = player.destParam4; + player.spellLevel = player.destParam3; break; case ACTION_SPELLWALL: - StartSpell(pnum, player.destParam3, player.destParam1, player.destParam2); - player.tempDirection = player.destParam3; + StartSpell(pnum, static_cast(player.destParam3), player.destParam1, player.destParam2); + player.tempDirection = static_cast(player.destParam3); player.spellLevel = player.destParam4; break; case ACTION_SPELLMON: diff --git a/Source/player.h b/Source/player.h index 85f7f40fe..2b41d9ce6 100644 --- a/Source/player.h +++ b/Source/player.h @@ -177,7 +177,7 @@ struct Player { action_id destAction; int destParam1; int destParam2; - Direction destParam3; + int destParam3; int destParam4; uint8_t plrlevel; ActorPosition position;