refactor and kill dead code.

indentation normalization, copyright update.
This commit is contained in:
Enno Rehling 2014-10-18 18:37:44 +02:00
parent a58afb9d15
commit 5626abd8dc
3 changed files with 493 additions and 515 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Copyright (c) 1998-2014, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
@ -251,7 +251,7 @@ extern "C" {
bool is_cursed_internal(struct attrib *ap, const curse_type * ctype);
/* ignoriert CURSE_ISNEW */
extern void remove_curse(struct attrib **ap, const struct curse *c);
bool remove_curse(struct attrib **ap, const struct curse *c);
/* löscht einen konkreten Spruch auf einem Objekt.
*/
@ -280,11 +280,6 @@ extern "C" {
* unterschiedlich gewünscht sein
* */
extern struct curse *get_cursex(struct attrib *ap, const curse_type * ctype,
variant data, bool(*compare) (const struct curse *, variant));
/* gibt pointer auf die erste curse-struct zurück, deren Typ ctype ist,
* und für die compare() true liefert, oder einen NULL-pointer.
* */
extern struct curse *get_curse(struct attrib *ap, const curse_type * ctype);
/* gibt pointer auf die erste curse-struct zurück, deren Typ ctype ist,
* oder einen NULL-pointer
@ -303,9 +298,6 @@ extern "C" {
extern void curse_done(struct attrib *a);
extern int curse_age(struct attrib *a);
extern bool cmp_curse(const struct attrib *a, const void *data);
extern bool cmp_cursetype(const struct attrib *a, const void *data);
extern float destr_curse(struct curse *c, int cast_level, float force);
extern int resolve_curse(variant data, void *address);

View File

@ -1,7 +1,7 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Copyright (c) 1998-2014, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@ -41,68 +41,66 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdio.h>
typedef struct removecurse_data {
curse *curse;
unit *target;
curse *curse;
unit *target;
} removecurse_data;
static void removecurse_init(trigger * t)
{
t->data.v = calloc(sizeof(removecurse_data), 1);
t->data.v = calloc(sizeof(removecurse_data), 1);
}
static void removecurse_free(trigger * t)
{
free(t->data.v);
free(t->data.v);
}
static int removecurse_handle(trigger * t, void *data)
{
/* call an event handler on removecurse.
* data.v -> ( variant event, int timer )
*/
removecurse_data *td = (removecurse_data *) t->data.v;
if (td->curse && td->target) {
attrib *a = a_select(td->target->attribs, td->curse, cmp_curse);
if (a) {
a_remove(&td->target->attribs, a);
} else
log_error("could not perform removecurse::handle()\n");
}
unused_arg(data);
return 0;
/* call an event handler on removecurse.
* data.v -> ( variant event, int timer )
*/
removecurse_data *td = (removecurse_data *)t->data.v;
if (td->curse && td->target) {
if (!remove_curse(&td->target->attribs, td->curse)) {
log_error("could not perform removecurse::handle()\n");
}
}
unused_arg(data);
return 0;
}
static void removecurse_write(const trigger * t, struct storage *store)
{
removecurse_data *td = (removecurse_data *) t->data.v;
WRITE_TOK(store, td->target ? itoa36(td->target->no) : 0);
WRITE_INT(store, td->curse ? td->curse->no : 0);
removecurse_data *td = (removecurse_data *)t->data.v;
WRITE_TOK(store, td->target ? itoa36(td->target->no) : 0);
WRITE_INT(store, td->curse ? td->curse->no : 0);
}
static int removecurse_read(trigger * t, struct storage *store)
{
removecurse_data *td = (removecurse_data *) t->data.v;
removecurse_data *td = (removecurse_data *)t->data.v;
read_reference(&td->target, store, read_unit_reference, resolve_unit);
read_reference(&td->curse, store, read_int, resolve_curse);
read_reference(&td->target, store, read_unit_reference, resolve_unit);
read_reference(&td->curse, store, read_int, resolve_curse);
return AT_READ_OK;
return AT_READ_OK;
}
trigger_type tt_removecurse = {
"removecurse",
removecurse_init,
removecurse_free,
removecurse_handle,
removecurse_write,
removecurse_read
"removecurse",
removecurse_init,
removecurse_free,
removecurse_handle,
removecurse_write,
removecurse_read
};
trigger *trigger_removecurse(curse * c, unit * target)
{
trigger *t = t_new(&tt_removecurse);
removecurse_data *td = (removecurse_data *) t->data.v;
td->curse = c;
td->target = target;
return t;
trigger *t = t_new(&tt_removecurse);
removecurse_data *td = (removecurse_data *)t->data.v;
td->curse = c;
td->target = target;
return t;
}