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;
|
||||
|
||||
while (ta.index--) {
|
||||
af->person[ta.index].hp += effskill(au, SK_STAMINA);
|
||||
af->person[ta.index].hp = _min(unit_max_hp(au), af->person[ta.index].hp);
|
||||
struct person *p = af->person + ta.index;
|
||||
p->hp += effskill(au, SK_STAMINA);
|
||||
p->hp = _min(unit_max_hp(au), p->hp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -179,18 +179,6 @@ extern "C" {
|
|||
/* ------------------------------------------------------------- */
|
||||
/* 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)
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
@ -200,17 +188,29 @@ extern "C" {
|
|||
int typ;
|
||||
int flags;
|
||||
int mergeflags;
|
||||
struct message *(*curseinfo) (const void *, objtype_t, const struct curse *,
|
||||
int);
|
||||
void(*change_vigour) (curse *, double);
|
||||
int(*read) (struct storage * store, curse * c, void *target);
|
||||
int(*write) (struct storage * store, const struct curse * c,
|
||||
struct message *(*curseinfo) (const void *, objtype_t,
|
||||
const struct curse *, int);
|
||||
void(*change_vigour) (struct curse *, double);
|
||||
int(*read) (struct storage * store, struct curse *, void *target);
|
||||
int(*write) (struct storage * store, const struct curse *,
|
||||
const void *target);
|
||||
int(*cansee) (const struct faction *, const void *, objtype_t,
|
||||
const struct curse *, int);
|
||||
int(*age) (curse *);
|
||||
int(*age) (struct curse *);
|
||||
} 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;
|
||||
void curse_write(const struct attrib *a, const void *owner,
|
||||
struct storage *store);
|
||||
|
|
12
src/magic.c
12
src/magic.c
|
@ -2560,7 +2560,7 @@ static castorder *cast_cmd(unit * u, order * ord)
|
|||
}
|
||||
s = gettoken(token, sizeof(token));
|
||||
}
|
||||
if (!s || !s[0] || strlen(s) == 0) {
|
||||
if (!s || !s[0]) {
|
||||
/* Fehler "Es wurde kein Zauber angegeben" */
|
||||
cmistake(u, ord, 172, MSG_MAGIC);
|
||||
return 0;
|
||||
|
@ -2695,8 +2695,16 @@ static castorder *cast_cmd(unit * u, order * ord)
|
|||
if (!s || *s == 0)
|
||||
break;
|
||||
if (p + 1 >= size) {
|
||||
char ** tmp;
|
||||
tmp = (char**)realloc(params, sizeof(char *) * size * 2);
|
||||
if (tmp) {
|
||||
size *= 2;
|
||||
params = (char**)realloc(params, sizeof(char *) * size);
|
||||
params = tmp;
|
||||
}
|
||||
else {
|
||||
log_error("error allocationg %d bytes: %s", size * 2, strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
params[p++] = _strdup(s);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue