server/core/src/modules/xmas.c

79 lines
1.7 KiB
C
Raw Normal View History

2010-08-08 10:06:34 +02:00
/* vi: set ts=2:
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
| | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
+-------------------+ Stefan Reich <reich@halbling.de>
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
#include <platform.h>
#include <kernel/config.h>
#include "xmas.h"
/* kernel includes */
#include <kernel/building.h>
#include <kernel/faction.h>
#include <kernel/item.h>
#include <kernel/move.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/unit.h>
/* util includes */
#include <util/attrib.h>
#include <util/base36.h>
#include <util/event.h>
#include <util/goodies.h>
#include <util/storage.h>
#include <util/resolve.h>
/* libc includes */
#include <stdlib.h>
2011-03-07 08:02:35 +01:00
static int xmasgate_handle(trigger * t, void *data)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
return -1;
2010-08-08 10:06:34 +02:00
}
2011-03-07 08:02:35 +01:00
static void xmasgate_write(const trigger * t, struct storage *store)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
building *b = (building *) t->data.v;
2010-08-08 10:06:34 +02:00
store->w_tok(store, itoa36(b->no));
}
2011-03-07 08:02:35 +01:00
static int xmasgate_read(trigger * t, struct storage *store)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
int bc =
read_reference(&t->data.v, store, read_building_reference,
resolve_building);
if (bc == 0 && !t->data.v) {
2010-08-08 10:06:34 +02:00
return AT_READ_FAIL;
}
return AT_READ_OK;
}
struct trigger_type tt_xmasgate = {
2011-03-07 08:02:35 +01:00
"xmasgate",
NULL,
NULL,
xmasgate_handle,
xmasgate_write,
xmasgate_read
2010-08-08 10:06:34 +02:00
};
2011-03-07 08:02:35 +01:00
trigger *trigger_xmasgate(building * b)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
trigger *t = t_new(&tt_xmasgate);
t->data.v = b;
return t;
2010-08-08 10:06:34 +02:00
}
2011-03-07 08:02:35 +01:00
void register_xmas(void)
2010-08-08 10:06:34 +02:00
{
2011-03-07 08:02:35 +01:00
tt_register(&tt_xmasgate);
2010-08-08 10:06:34 +02:00
}