forked from github/server
* Korrektur (aber noch kein Bugfix) für doppelte GM-permissions
* Bugfix (fehlender Code) für Mistelzweig und andere Funktionsdefinitionen in XML-items
This commit is contained in:
parent
b06c464e4f
commit
d7ee16f0f2
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue