2001-09-05 21:40:40 +02:00
|
|
|
/* vi: set ts=2:
|
|
|
|
*
|
|
|
|
*
|
2003-07-29 11:48:03 +02:00
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
2001-09-05 21:40:40 +02:00
|
|
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
|
|
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
|
|
|
* Henning Peters (faroul@beyond.kn-bremen.de)
|
2007-09-02 20:11:17 +02:00
|
|
|
* Enno Rehling (enno@eressea.de)
|
2001-09-05 21:40:40 +02:00
|
|
|
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
|
|
|
*
|
|
|
|
* This program may not be used, modified or distributed without
|
|
|
|
* prior permission by the authors of Eressea.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2008-04-20 16:48:15 +02:00
|
|
|
#include <kernel/eressea.h>
|
2001-09-05 21:40:40 +02:00
|
|
|
#include "clonedied.h"
|
|
|
|
|
|
|
|
/* kernel includes */
|
2008-04-20 16:48:15 +02:00
|
|
|
#include <kernel/spell.h>
|
|
|
|
#include <kernel/magic.h>
|
|
|
|
#include <kernel/unit.h>
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
|
|
/* util includes */
|
2007-06-20 02:34:02 +02:00
|
|
|
#include <util/attrib.h>
|
|
|
|
#include <util/event.h>
|
2007-08-05 14:19:56 +02:00
|
|
|
#include <util/log.h>
|
2007-06-20 02:34:02 +02:00
|
|
|
#include <util/resolve.h>
|
2008-04-26 16:55:22 +02:00
|
|
|
#include <util/storage.h>
|
2007-06-20 02:34:02 +02:00
|
|
|
#include <util/base36.h>
|
2001-09-05 21:40:40 +02:00
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
clonedied.
|
|
|
|
|
|
|
|
This trigger ist called when a clone of a mage dies.
|
|
|
|
It simply removes the clone-attribute from the mage.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
clonedied_handle(trigger * t, void * data)
|
|
|
|
{
|
|
|
|
/* destroy the unit */
|
|
|
|
unit * u = (unit*)t->data.v;
|
2008-05-24 19:38:38 +02:00
|
|
|
if (u) {
|
2001-09-05 21:40:40 +02:00
|
|
|
attrib *a = a_find(u->attribs, &at_clone);
|
|
|
|
if(a) a_remove(&u->attribs, a);
|
|
|
|
} else
|
|
|
|
log_error(("could not perform clonedied::handle()\n"));
|
|
|
|
unused(data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-04-26 16:55:22 +02:00
|
|
|
clonedied_write(const trigger * t, struct storage * store)
|
2001-09-05 21:40:40 +02:00
|
|
|
{
|
2008-05-17 17:21:17 +02:00
|
|
|
unit * u = (unit*)t->data.v;
|
|
|
|
write_unit_reference(u, store);
|
2001-09-05 21:40:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-04-26 16:55:22 +02:00
|
|
|
clonedied_read(trigger * t, struct storage * store)
|
2001-09-05 21:40:40 +02:00
|
|
|
{
|
2008-05-24 02:20:00 +02:00
|
|
|
int result = read_reference(&t->data.v, store, read_unit_reference, resolve_unit);
|
|
|
|
if (result==0 && t->data.v==NULL) {
|
|
|
|
return AT_READ_FAIL;
|
|
|
|
}
|
|
|
|
return AT_READ_OK;
|
2001-09-05 21:40:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
trigger_type tt_clonedied = {
|
|
|
|
"clonedied",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
clonedied_handle,
|
|
|
|
clonedied_write,
|
|
|
|
clonedied_read
|
|
|
|
};
|
|
|
|
|
|
|
|
trigger *
|
|
|
|
trigger_clonedied(unit * u)
|
|
|
|
{
|
|
|
|
trigger * t = t_new(&tt_clonedied);
|
|
|
|
t->data.v = (void*)u;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|