Browse Source

Remove redundant code from CastSpell

pull/986/head
Anders Jenbo 5 years ago
parent
commit
fdf5d514b6
  1. 1
      Source/player.cpp
  2. 35
      Source/spells.cpp
  3. 2
      Source/spells.h

1
Source/player.cpp

@ -3244,7 +3244,6 @@ BOOL PM_DoSpell(int pnum)
plr[pnum]._py, plr[pnum]._py,
plr[pnum]._pVar1, plr[pnum]._pVar1,
plr[pnum]._pVar2, plr[pnum]._pVar2,
0,
plr[pnum]._pVar4); plr[pnum]._pVar4);
if (plr[pnum]._pSplFrom == 0) { if (plr[pnum]._pSplFrom == 0) {

35
Source/spells.cpp

@ -185,39 +185,24 @@ BOOL CheckSpell(int id, int sn, char st, BOOL manaonly)
return result; return result;
} }
void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int caster, int spllvl) void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int spllvl)
{ {
int i; int dir = plr[id]._pdir;
int dir; // missile direction if (spl == SPL_FIREWALL || spl == SPL_LIGHTWALL) {
dir = plr[id]._pVar3;
switch (caster) {
case TARGET_PLAYERS:
dir = monster[id]._mdir;
break;
case TARGET_MONSTERS:
// caster must be 0 already in this case, but oh well,
// it's needed to generate the right code
caster = TARGET_MONSTERS;
dir = plr[id]._pdir;
if (spl == SPL_FIREWALL || spl == SPL_LIGHTWALL) {
dir = plr[id]._pVar3;
}
break;
} }
for (i = 0; spelldata[spl].sMissiles[i] != MIS_ARROW && i < 3; i++) { for (int i = 0; spelldata[spl].sMissiles[i] != 0 && i < 3; i++) {
AddMissile(sx, sy, dx, dy, dir, spelldata[spl].sMissiles[i], caster, id, 0, spllvl); AddMissile(sx, sy, dx, dy, dir, spelldata[spl].sMissiles[i], TARGET_MONSTERS, id, 0, spllvl);
} }
if (spelldata[spl].sMissiles[0] == MIS_TOWN) { if (spl == SPL_TOWN) {
UseMana(id, SPL_TOWN); UseMana(id, SPL_TOWN);
} } else if (spl == SPL_CBOLT) {
if (spelldata[spl].sMissiles[0] == MIS_CBOLT) {
UseMana(id, SPL_CBOLT); UseMana(id, SPL_CBOLT);
for (i = (spllvl >> 1) + 3; i > 0; i--) { for (int i = (spllvl >> 1) + 3; i > 0; i--) {
AddMissile(sx, sy, dx, dy, dir, MIS_CBOLT, caster, id, 0, spllvl); AddMissile(sx, sy, dx, dy, dir, MIS_CBOLT, TARGET_MONSTERS, id, 0, spllvl);
} }
} }
} }

2
Source/spells.h

@ -16,7 +16,7 @@ int GetManaAmount(int id, int sn);
void UseMana(int id, int sn); void UseMana(int id, int sn);
BOOL CheckSpell(int id, int sn, char st, BOOL manaonly); BOOL CheckSpell(int id, int sn, char st, BOOL manaonly);
void EnsureValidReadiedSpell(PlayerStruct &player); void EnsureValidReadiedSpell(PlayerStruct &player);
void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int caster, int spllvl); void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int spllvl);
void DoResurrect(int pnum, int rid); void DoResurrect(int pnum, int rid);
void DoHealOther(int pnum, int rid); void DoHealOther(int pnum, int rid);
int GetSpellBookLevel(int s); int GetSpellBookLevel(int s);

Loading…
Cancel
Save