forked from github/server
minor optimizations, error checking (static analysis)
This commit is contained in:
parent
6ea859ecea
commit
758f4a592d
|
@ -2339,8 +2339,9 @@ void do_regenerate(fighter * af)
|
||||||
ta.index = af->fighting;
|
ta.index = af->fighting;
|
||||||
|
|
||||||
while (ta.index--) {
|
while (ta.index--) {
|
||||||
af->person[ta.index].hp += effskill(au, SK_STAMINA);
|
struct person *p = af->person + ta.index;
|
||||||
af->person[ta.index].hp = _min(unit_max_hp(au), af->person[ta.index].hp);
|
p->hp += effskill(au, SK_STAMINA);
|
||||||
|
p->hp = _min(unit_max_hp(au), p->hp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,18 +179,6 @@ extern "C" {
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
/* Allgemeine Zauberwirkungen */
|
/* Allgemeine Zauberwirkungen */
|
||||||
|
|
||||||
typedef struct curse {
|
|
||||||
struct curse *nexthash;
|
|
||||||
int no; /* 'Einheitennummer' dieses Curse */
|
|
||||||
const struct curse_type *type; /* Zeiger auf ein curse_type-struct */
|
|
||||||
int flags; /* WARNING: these are XORed with type->flags! */
|
|
||||||
int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */
|
|
||||||
double vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */
|
|
||||||
struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */
|
|
||||||
double effect;
|
|
||||||
variant data; /* pointer auf spezielle curse-unterstructs */
|
|
||||||
} curse;
|
|
||||||
|
|
||||||
#define c_flags(c) ((c)->type->flags ^ (c)->flags)
|
#define c_flags(c) ((c)->type->flags ^ (c)->flags)
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
@ -200,17 +188,29 @@ extern "C" {
|
||||||
int typ;
|
int typ;
|
||||||
int flags;
|
int flags;
|
||||||
int mergeflags;
|
int mergeflags;
|
||||||
struct message *(*curseinfo) (const void *, objtype_t, const struct curse *,
|
struct message *(*curseinfo) (const void *, objtype_t,
|
||||||
int);
|
const struct curse *, int);
|
||||||
void(*change_vigour) (curse *, double);
|
void(*change_vigour) (struct curse *, double);
|
||||||
int(*read) (struct storage * store, curse * c, void *target);
|
int(*read) (struct storage * store, struct curse *, void *target);
|
||||||
int(*write) (struct storage * store, const struct curse * c,
|
int(*write) (struct storage * store, const struct curse *,
|
||||||
const void *target);
|
const void *target);
|
||||||
int(*cansee) (const struct faction *, const void *, objtype_t,
|
int(*cansee) (const struct faction *, const void *, objtype_t,
|
||||||
const struct curse *, int);
|
const struct curse *, int);
|
||||||
int(*age) (curse *);
|
int(*age) (struct curse *);
|
||||||
} curse_type;
|
} curse_type;
|
||||||
|
|
||||||
|
typedef struct curse {
|
||||||
|
variant data; /* pointer auf spezielle curse-unterstructs */
|
||||||
|
struct curse *nexthash;
|
||||||
|
const curse_type *type; /* Zeiger auf ein curse_type-struct */
|
||||||
|
struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */
|
||||||
|
double vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */
|
||||||
|
double effect;
|
||||||
|
int no; /* 'Einheitennummer' dieses Curse */
|
||||||
|
int flags; /* WARNING: these are XORed with type->flags! */
|
||||||
|
int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */
|
||||||
|
} curse;
|
||||||
|
|
||||||
extern struct attrib_type at_curse;
|
extern struct attrib_type at_curse;
|
||||||
void curse_write(const struct attrib *a, const void *owner,
|
void curse_write(const struct attrib *a, const void *owner,
|
||||||
struct storage *store);
|
struct storage *store);
|
||||||
|
|
16
src/magic.c
16
src/magic.c
|
@ -2560,7 +2560,7 @@ static castorder *cast_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
s = gettoken(token, sizeof(token));
|
s = gettoken(token, sizeof(token));
|
||||||
}
|
}
|
||||||
if (!s || !s[0] || strlen(s) == 0) {
|
if (!s || !s[0]) {
|
||||||
/* Fehler "Es wurde kein Zauber angegeben" */
|
/* Fehler "Es wurde kein Zauber angegeben" */
|
||||||
cmistake(u, ord, 172, MSG_MAGIC);
|
cmistake(u, ord, 172, MSG_MAGIC);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2571,7 +2571,7 @@ static castorder *cast_cmd(unit * u, order * ord)
|
||||||
/* Vertraute können auch Zauber sprechen, die sie selbst nicht
|
/* Vertraute können auch Zauber sprechen, die sie selbst nicht
|
||||||
* können. unit_getspell findet aber nur jene Sprüche, die
|
* können. unit_getspell findet aber nur jene Sprüche, die
|
||||||
* die Einheit beherrscht. */
|
* die Einheit beherrscht. */
|
||||||
if (!sp && is_familiar(u)) {
|
if (!sp && is_familiar(u)) {
|
||||||
caster = get_familiar_mage(u);
|
caster = get_familiar_mage(u);
|
||||||
if (caster) {
|
if (caster) {
|
||||||
familiar = u;
|
familiar = u;
|
||||||
|
@ -2695,8 +2695,16 @@ static castorder *cast_cmd(unit * u, order * ord)
|
||||||
if (!s || *s == 0)
|
if (!s || *s == 0)
|
||||||
break;
|
break;
|
||||||
if (p + 1 >= size) {
|
if (p + 1 >= size) {
|
||||||
size *= 2;
|
char ** tmp;
|
||||||
params = (char**)realloc(params, sizeof(char *) * size);
|
tmp = (char**)realloc(params, sizeof(char *) * size * 2);
|
||||||
|
if (tmp) {
|
||||||
|
size *= 2;
|
||||||
|
params = tmp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log_error("error allocationg %d bytes: %s", size * 2, strerror(errno));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
params[p++] = _strdup(s);
|
params[p++] = _strdup(s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue