Skip to content

Commit

Permalink
Always check entity handles in spell End methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli2 committed Dec 29, 2016
1 parent de119b5 commit 75e8040
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 20 deletions.
5 changes: 4 additions & 1 deletion src/game/magic/spells/SpellsLvl01.cpp
Expand Up @@ -66,7 +66,10 @@ void MagicSightSpell::End()
player.m_improve = false;
ARX_SOUND_Stop(m_snd_loop);
}
ARX_SOUND_PlaySFX(SND_SPELL_VISION_START, &entities[m_caster]->pos);

if(ValidIONum(m_caster)) {
ARX_SOUND_PlaySFX(SND_SPELL_VISION_START, &entities[m_caster]->pos);
}
}

void MagicSightSpell::Update() {
Expand Down
10 changes: 6 additions & 4 deletions src/game/magic/spells/SpellsLvl02.cpp
Expand Up @@ -238,9 +238,9 @@ void ArmorSpell::Launch()
void ArmorSpell::End()
{
ARX_SOUND_Stop(m_snd_loop);
ARX_SOUND_PlaySFX(SND_SPELL_ARMOR_END, &entities[m_target]->pos);

if(ValidIONum(m_target)) {
ARX_SOUND_PlaySFX(SND_SPELL_ARMOR_END, &entities[m_target]->pos);
ARX_HALO_SetToNative(entities[m_target]);
}

Expand Down Expand Up @@ -308,11 +308,13 @@ void LowerArmorSpell::Launch()
void LowerArmorSpell::End()
{
ARX_SOUND_PlaySFX(SND_SPELL_LOWER_ARMOR_END);
Entity *io = entities[m_target];

if(m_haloCreated) {
io->halo.flags &= ~HALO_ACTIVE;
ARX_HALO_SetToNative(io);
if(ValidIONum(m_target)) {
Entity *io = entities[m_target];
io->halo.flags &= ~HALO_ACTIVE;
ARX_HALO_SetToNative(io);
}
}

m_targets.clear();
Expand Down
4 changes: 3 additions & 1 deletion src/game/magic/spells/SpellsLvl03.cpp
Expand Up @@ -99,7 +99,9 @@ void SpeedSpell::End() {
if(m_caster == EntityHandle_Player)
ARX_SOUND_Stop(m_snd_loop);

ARX_SOUND_PlaySFX(SND_SPELL_SPEED_END, &entities[m_target]->pos);
if(ValidIONum(m_target)) {
ARX_SOUND_PlaySFX(SND_SPELL_SPEED_END, &entities[m_target]->pos);
}

for(size_t i = 0; i < m_trails.size(); i++) {
delete m_trails[i].trail;
Expand Down
20 changes: 13 additions & 7 deletions src/game/magic/spells/SpellsLvl04.cpp
Expand Up @@ -266,11 +266,13 @@ void FireProtectionSpell::Launch()
void FireProtectionSpell::End()
{
ARX_SOUND_Stop(m_snd_loop);
ARX_SOUND_PlaySFX(SND_SPELL_FIRE_PROTECTION_END, &entities[m_target]->pos);
m_targets.clear();

if(ValidIONum(m_target))
if(ValidIONum(m_target)) {
ARX_SOUND_PlaySFX(SND_SPELL_FIRE_PROTECTION_END, &entities[m_target]->pos);
ARX_HALO_SetToNative(entities[m_target]);
}

m_targets.clear();
}

void FireProtectionSpell::Update() {
Expand Down Expand Up @@ -325,11 +327,13 @@ void ColdProtectionSpell::Launch()
void ColdProtectionSpell::End()
{
ARX_SOUND_Stop(m_snd_loop);
ARX_SOUND_PlaySFX(SND_SPELL_COLD_PROTECTION_END, &entities[m_target]->pos);
m_targets.clear();

if(ValidIONum(m_target))
if(ValidIONum(m_target)) {
ARX_SOUND_PlaySFX(SND_SPELL_COLD_PROTECTION_END, &entities[m_target]->pos);
ARX_HALO_SetToNative(entities[m_target]);
}

m_targets.clear();
}

void ColdProtectionSpell::Update() {
Expand Down Expand Up @@ -371,7 +375,9 @@ void TelekinesisSpell::End()
if(m_caster == EntityHandle_Player)
player.m_telekinesis = false;

ARX_SOUND_PlaySFX(SND_SPELL_TELEKINESIS_END, &entities[m_caster]->pos);
if(ValidIONum(m_caster)) {
ARX_SOUND_PlaySFX(SND_SPELL_TELEKINESIS_END, &entities[m_caster]->pos);
}
}


Expand Down
6 changes: 5 additions & 1 deletion src/game/magic/spells/SpellsLvl05.cpp
Expand Up @@ -203,7 +203,11 @@ void LevitateSpell::Launch()
void LevitateSpell::End()
{
ARX_SOUND_Stop(m_snd_loop);
ARX_SOUND_PlaySFX(SND_SPELL_LEVITATE_END, &entities[m_target]->pos);

if(ValidIONum(m_target)) {
ARX_SOUND_PlaySFX(SND_SPELL_LEVITATE_END, &entities[m_target]->pos);
}

m_targets.clear();

if(m_target == EntityHandle_Player)
Expand Down
5 changes: 4 additions & 1 deletion src/game/magic/spells/SpellsLvl06.cpp
Expand Up @@ -247,7 +247,10 @@ void ParalyseSpell::Launch()
void ParalyseSpell::End()
{
m_targets.clear();
entities[m_target]->ioflags &= ~IO_FREEZESCRIPT;

if(ValidIONum(m_target)) {
entities[m_target]->ioflags &= ~IO_FREEZESCRIPT;
}

ARX_SOUND_PlaySFX(SND_SPELL_PARALYSE_END);
}
Expand Down
12 changes: 8 additions & 4 deletions src/game/magic/spells/SpellsLvl07.cpp
Expand Up @@ -115,7 +115,9 @@ void FlyingEyeSpell::Launch()

void FlyingEyeSpell::End()
{
ARX_SOUND_PlaySFX(SND_MAGIC_FIZZLE, &entities[m_caster]->pos);
if(ValidIONum(m_caster)) {
ARX_SOUND_PlaySFX(SND_MAGIC_FIZZLE, &entities[m_caster]->pos);
}

static TextureContainer * tc4=TextureContainer::Load("graph/particles/smoke");

Expand Down Expand Up @@ -552,10 +554,12 @@ void LightningStrikeSpell::Launch() {

void LightningStrikeSpell::End()
{
ARX_SOUND_PlaySFX(SND_SPELL_ELECTRIC, &entities[m_caster]->pos);

ARX_SOUND_Stop(m_snd_loop);
ARX_SOUND_PlaySFX(SND_SPELL_LIGHTNING_END, &entities[m_caster]->pos);

if(ValidIONum(m_caster)) {
ARX_SOUND_PlaySFX(SND_SPELL_ELECTRIC, &entities[m_caster]->pos);
ARX_SOUND_PlaySFX(SND_SPELL_LIGHTNING_END, &entities[m_caster]->pos);
}
}

static Vec3f GetChestPos(EntityHandle num) {
Expand Down
5 changes: 4 additions & 1 deletion src/game/magic/spells/SpellsLvl10.cpp
Expand Up @@ -377,7 +377,10 @@ void FreezeTimeSpell::Launch()
void FreezeTimeSpell::End()
{
GLOBAL_SLOWDOWN += m_slowdown;
ARX_SOUND_PlaySFX(SND_SPELL_TELEKINESIS_END, &entities[m_caster]->pos);

if(ValidIONum(m_caster)) {
ARX_SOUND_PlaySFX(SND_SPELL_TELEKINESIS_END, &entities[m_caster]->pos);
}
}

void MassIncinerateSpell::Launch()
Expand Down

0 comments on commit 75e8040

Please sign in to comment.