/* vi: set ts=2: * * * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) * Henning Peters (faroul@beyond.kn-bremen.de) * Enno Rehling (enno@eressea-pbem.de) * 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 #include #include "shock.h" /* kernel includes */ #include #include /* util includes */ #include #include #include /* libc includes */ #include #include /*** ** shock **/ static int shock_handle(trigger * t, void * data) { /* destroy the unit */ unit * u = (unit*)t->data.v; if (u!=NULL) { do_shock(u, "trigger"); } else log_error(("could not perform shock::handle()\n")); unused(data); return 0; } static void shock_write(const trigger * t, FILE * F) { unit * u = (unit*)t->data.v; trigger * next = t->next; while (next) { /* make sure it is unique! */ if (next->type==t->type && next->data.v==t->data.v) break; next=next->next; } if (next && u) { log_error(("more than one shock-attribut for %s on a unit. FIXED.\n", unitid(u))); write_unit_reference(NULL, F); } else { write_unit_reference(u, F); } } static int shock_read(trigger * t, FILE * F) { return read_unit_reference((unit**)&t->data.v, F); } trigger_type tt_shock = { "shock", NULL, NULL, shock_handle, shock_write, shock_read }; trigger * trigger_shock(unit * u) { trigger * t = t_new(&tt_shock); t->data.v = (void*)u; return t; }