forked from github/server
Merge pull request #216 from badgerman/feature/issue-198
issue #198: gmtool makes invalid demand
This commit is contained in:
commit
70967fc041
40
src/battle.c
40
src/battle.c
|
@ -431,7 +431,7 @@ static int get_row(const side * s, int row, const side * vs)
|
|||
return result;
|
||||
}
|
||||
|
||||
int get_unitrow(const fighter * af, const side * vs)
|
||||
static int get_unitrow(const fighter * af, const side * vs)
|
||||
{
|
||||
int row = statusrow(af->status);
|
||||
if (vs == NULL) {
|
||||
|
@ -3661,6 +3661,24 @@ static void free_fighter(fighter * fig)
|
|||
|
||||
}
|
||||
|
||||
static void battle_free(battle * b) {
|
||||
side *s;
|
||||
|
||||
assert(b);
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fnext = s->fighters;
|
||||
while (fnext) {
|
||||
fighter *fig = fnext;
|
||||
fnext = fig->next;
|
||||
free_fighter(fig);
|
||||
free(fig);
|
||||
}
|
||||
free_side(s);
|
||||
}
|
||||
free(b);
|
||||
}
|
||||
|
||||
void free_battle(battle * b)
|
||||
{
|
||||
int max_fac_no = 0;
|
||||
|
@ -3740,7 +3758,7 @@ static int battle_report(battle * b)
|
|||
char buffer[32];
|
||||
|
||||
if (komma) {
|
||||
bytes = strlcpy(bufp, ", ", size);
|
||||
strlcpy(bufp, ", ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
|
@ -4295,21 +4313,3 @@ void do_battle(region * r)
|
|||
}
|
||||
}
|
||||
|
||||
void battle_free(battle * b) {
|
||||
side *s;
|
||||
|
||||
assert(b);
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fnext = s->fighters;
|
||||
while (fnext) {
|
||||
fighter *fig = fnext;
|
||||
fnext = fig->next;
|
||||
free_fighter(fig);
|
||||
free(fig);
|
||||
}
|
||||
free_side(s);
|
||||
}
|
||||
free(b);
|
||||
}
|
||||
|
||||
|
|
|
@ -225,8 +225,6 @@ extern "C" {
|
|||
extern const troop no_troop;
|
||||
|
||||
/* BEGIN battle interface */
|
||||
void battle_init(battle * b);
|
||||
void battle_free(battle * b);
|
||||
side * find_side(battle * b, const struct faction * f, const struct group * g, unsigned int flags, const struct faction * stealthfaction);
|
||||
side * get_side(battle * b, const struct unit * u);
|
||||
fighter * get_fighter(battle * b, const struct unit * u);
|
||||
|
@ -251,11 +249,10 @@ extern "C" {
|
|||
extern int hits(troop at, troop dt, weapon * awp);
|
||||
extern void damage_building(struct battle *b, struct building *bldg,
|
||||
int damage_abs);
|
||||
extern struct quicklist *fighters(struct battle *b, const struct side *vs,
|
||||
struct quicklist *fighters(struct battle *b, const struct side *vs,
|
||||
int minrow, int maxrow, int mask);
|
||||
extern int count_allies(const struct side *as, int minrow, int maxrow,
|
||||
int count_allies(const struct side *as, int minrow, int maxrow,
|
||||
int select, int allytype);
|
||||
extern int get_unitrow(const struct fighter *af, const struct side *vs);
|
||||
extern bool helping(const struct side *as, const struct side *ds);
|
||||
extern void rmfighter(fighter * df, int i);
|
||||
extern struct fighter *select_corpse(struct battle *b, struct fighter *af);
|
||||
|
|
|
@ -956,8 +956,10 @@ void setluxuries(region * r, const luxury_type * sale)
|
|||
|
||||
assert(r->land);
|
||||
|
||||
if (r->land->demands)
|
||||
if (r->land->demands) {
|
||||
freelist(r->land->demands);
|
||||
r->land->demands = 0;
|
||||
}
|
||||
|
||||
for (ltype = luxurytypes; ltype; ltype = ltype->next) {
|
||||
struct demand *dmd = malloc(sizeof(struct demand));
|
||||
|
|
|
@ -20,7 +20,7 @@ int wrptr(char **ptr, size_t * size, size_t bytes)
|
|||
|
||||
*ptr += *size;
|
||||
*size = 0;
|
||||
return ENAMETOOLONG;
|
||||
return ERANGE;
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
|
|
Loading…
Reference in New Issue