Browse Source

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.
pull/3268/head
Anders Jenbo 4 years ago
parent
commit
96e1d5caba
  1. 2
      Source/loadsave.cpp
  2. 10
      Source/msg.cpp
  3. 6
      Source/player.cpp
  4. 2
      Source/player.h

2
Source/loadsave.cpp

@ -309,7 +309,7 @@ void LoadPlayer(LoadHelper &file, Player &player)
player.destAction = static_cast<action_id>(file.NextLE<int32_t>());
player.destParam1 = file.NextLE<int32_t>();
player.destParam2 = file.NextLE<int32_t>();
player.destParam3 = static_cast<Direction>(file.NextLE<int32_t>());
player.destParam3 = file.NextLE<int32_t>();
player.destParam4 = file.NextLE<int32_t>();
player.plrlevel = file.NextLE<uint32_t>();
player.position.tile.x = file.NextLE<int32_t>();

10
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<int>(Direction::SouthEast))
return sizeof(message);
auto spell = static_cast<spell_id>(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<Direction>(message.wParam3);
player.destParam3 = message.wParam3;
player.destParam4 = message.wParam4;
player._pSpell = spell;
player._pSplType = static_cast<spell_type>(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<spell_type>(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<int>(Direction::SouthEast))
return sizeof(message);
auto spell = static_cast<spell_id>(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<Direction>(message.wParam2);
player.destParam3 = message.wParam2;
player._pSpell = spell;
player._pSplType = RSPLTYPE_INVALID;
player._pSplFrom = 2;

6
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<Direction>(player.destParam3), player.destParam1, player.destParam2);
player.tempDirection = static_cast<Direction>(player.destParam3);
player.spellLevel = player.destParam4;
break;
case ACTION_SPELLMON:

2
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;

Loading…
Cancel
Save