in the report, calculate max size of ships correctly.
This commit is contained in:
Enno Rehling 2019-10-20 18:04:49 +02:00
parent d9cbbd9052
commit d04fe741a9
3 changed files with 15 additions and 10 deletions

View File

@ -373,10 +373,15 @@ const char *shipname(const ship * sh)
return write_shipname(sh, ibuf, sizeof(idbuf[0]));
}
int ship_maxsize(const ship *sh)
{
return sh->number * sh->type->construction->maxsize;
}
bool ship_finished(const ship *sh)
{
if (sh->type->construction) {
return (sh->size >= sh->number * sh->type->construction->maxsize);
return (sh->size >= ship_maxsize(sh));
}
return true;
}

View File

@ -93,20 +93,20 @@ extern "C" {
const char *shipname(const struct ship *self);
int ship_capacity(const struct ship *sh);
int ship_cabins(const struct ship *sh);
int ship_maxsize(const struct ship *sh);
bool ship_finished(const struct ship *sh);
extern void getshipweight(const struct ship *sh, int *weight, int *cabins);
void getshipweight(const struct ship *sh, int *weight, int *cabins);
extern ship *new_ship(const struct ship_type *stype, struct region *r,
ship *new_ship(const struct ship_type *stype, struct region *r,
const struct locale *lang);
extern const char *write_shipname(const struct ship *sh, char *buffer,
const char *write_shipname(const struct ship *sh, char *buffer,
size_t size);
extern struct ship *findship(int n);
extern struct ship *findshipr(const struct region *r, int n);
struct ship *findship(int n);
extern const struct ship_type *findshiptype(const char *s,
const struct ship_type *findshiptype(const char *s,
const struct locale *lang);
extern void write_ship_reference(const struct ship *sh,
void write_ship_reference(const struct ship *sh,
struct storage *store);
void remove_ship(struct ship **slist, struct ship *s);

View File

@ -1737,10 +1737,10 @@ nr_ship(struct stream *out, const region *r, const ship * sh, const faction * f,
sbs_printf(&sbs, "%s, %s", shipname(sh), LOC(f->locale, sh->type->_name));
}
if (sh->size != sh->type->construction->maxsize) {
if (!ship_finished(sh)) {
sbs_printf(&sbs, ", %s (%d/%d)",
LOC(f->locale, "nr_undercons"), sh->size,
sh->type->construction->maxsize);
ship_maxsize(sh));
}
if (sh->damage) {
int percent = ship_damage_percent(sh);