summaryrefslogtreecommitdiff
path: root/src/map/magic-stmt.c
diff options
context:
space:
mode:
authorFate <fate-tmw@googlemail.com>2009-01-31 00:01:57 -0700
committerFate <fate-tmw@googlemail.com>2009-01-31 00:01:57 -0700
commita08a3b1a6a1b11240e67d2eb91687fcb290adbb2 (patch)
tree498f0b703591c7b4cb3c30bc3b7964d1e36f084a /src/map/magic-stmt.c
parentee9035cc12fec70f062a0a7c3c1597e5e63f93f7 (diff)
downloadtmwa-a08a3b1a6a1b11240e67d2eb91687fcb290adbb2.tar.gz
tmwa-a08a3b1a6a1b11240e67d2eb91687fcb290adbb2.tar.bz2
tmwa-a08a3b1a6a1b11240e67d2eb91687fcb290adbb2.tar.xz
tmwa-a08a3b1a6a1b11240e67d2eb91687fcb290adbb2.zip
Misc. fixes and attempted fixes to extant bugs
Diffstat (limited to 'src/map/magic-stmt.c')
-rw-r--r--src/map/magic-stmt.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/map/magic-stmt.c b/src/map/magic-stmt.c
index 782f560..d9ba86e 100644
--- a/src/map/magic-stmt.c
+++ b/src/map/magic-stmt.c
@@ -105,6 +105,15 @@ magic_stop_completely(character_t *c)
{
while (c->active_spells)
free_invocation(c->active_spells);
+
+ if (c->attack_spell_override) {
+ invocation_t *attack_spell = (invocation_t *)map_id2bl(c->attack_spell_override);
+ if (attack_spell)
+ free_invocation(attack_spell);
+ c->attack_spell_override = 0;
+ char_set_weapon_icon(caster, 0, 0, 0);
+ char_set_attack_info(caster, 0, 0);
+ }
}
/* Spell execution has finished normally or we have been notified by a finished skill timer */
@@ -197,7 +206,9 @@ char_update(character_t *character)
static int
timer_callback_effect(int _, unsigned int __, int id, int data)
{
- clif_misceffect(map_id2bl(id), data);
+ entity_t *target = map_id2bl(id);
+ if (target)
+ clif_misceffect(target, data);
return 0;
}
@@ -1375,7 +1386,12 @@ int
spell_attack(int caster_id, int target_id)
{
character_t *caster = (character_t *)map_id2bl(caster_id);
- invocation_t *invocation = (invocation_t *)map_id2bl(caster->attack_spell_override);
+ invocation_t *invocation;
+
+ if (!caster)
+ return 1;
+
+ invocation = (invocation_t *)map_id2bl(caster->attack_spell_override);
if (invocation
&& caster->attack_spell_charges > 0) {
@@ -1398,7 +1414,7 @@ spell_attack(int caster_id, int target_id)
if (invocation
&& caster->attack_spell_override != invocation->bl.id) {
/* Attack spell changed / was refreshed */
- free_invocation(invocation);
+ // free_invocation(invocation); // [Fate] This would be a double free.
} else if (!invocation
|| caster->attack_spell_charges <= 0) {
caster->attack_spell_override = 0;