From d7ee16f0f2a37e9e2a3ab9a446724885e2d90aec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 9 May 2002 11:01:15 +0000 Subject: [PATCH] =?UTF-8?q?*=20Korrektur=20(aber=20noch=20kein=20Bugfix)?= =?UTF-8?q?=20f=C3=BCr=20doppelte=20GM-permissions=20*=20Bugfix=20(fehlend?= =?UTF-8?q?er=20Code)=20f=C3=BCr=20Mistelzweig=20und=20andere=20Funktionsd?= =?UTF-8?q?efinitionen=20in=20XML-items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/kernel/item.c | 22 ++++++++++++++++++++++ src/common/modules/gmcmd.c | 21 +++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 88de85d51..c7dedc47e 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -2150,6 +2150,28 @@ tagbegin(struct xml_stack * stack) if (xml_bvalue(tag, "animal")) flags |= ITF_ANIMAL; state->rtype->flags |= RTF_ITEM; state->itype = new_itemtype(state->rtype, flags, weight, capacity); + } else if (strcmp(tag->name, "function")==0) { + const char * semi = xml_value(tag, "name"); + const char * s = xml_value(tag, "value"); + item_type * it = state->itype; + int i = atoi(s); + switch (semi[0]) { + case 'c': + if (!strcmp(semi, "capacity")) it->capacity=i; + break; + case 'f': + if (!strcmp(semi, "flags")) it->flags=i; + break; + case 'g': + if (!strcmp(semi, "give")) it->give = (int (*)(const unit*, const unit*, const struct item_type *, int, const char *))get_function(s); + break; + case 'u': + if (!strcmp(semi, "use")) it->use = (int (*)(unit *, const struct item_type *, int, const char *))get_function(s); + break; + case 'w': + if (!strcmp(semi, "weight")) it->weight=i; + break; + } } else if (strcmp(tag->name, "weapon")==0) { skill_t sk = sk_find(xml_value(tag, "skill")); int minskill = xml_ivalue(tag, "minskill"); diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index 00eed9ae2..27d6983dc 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -53,10 +53,27 @@ write_permissions(const attrib * a, FILE * F) } static int -read_permissions(attrib * a, FILE * F) +read_permissions(attrib * at, FILE * F) { - attrib ** p_a = (attrib**)&a->data.v; + attrib ** p_a = (attrib**)&at->data.v; a_read(F, p_a); + /* eliminate duplicates: */ + while (*p_a) { + attrib * a = (*p_a)->next; + while (a) { + attrib * nexta = a->next; + if (a->type == (*p_a)->type && a->data.v==(*p_a)->data.v) { + static int print = 0; + a_remove((attrib**)&at->data.v, a); + if (!print) { + log_error(("duplicated entries in permission structure\n")); + print = 1; + } + } + a = nexta; + } + p_a = &(*p_a)->next; + } return AT_READ_OK; }