diff --git a/src/battle.c b/src/battle.c index a0e03f1f9..6a89a7a6e 100644 --- a/src/battle.c +++ b/src/battle.c @@ -2933,7 +2933,7 @@ static void print_stats(battle * b) header = LOC(f->locale, "battle_helpers"); for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) { - if (friendly(s2, s)) { + if (s2 != s && friendly(s2, s)) { const char *abbrev = seematrix(f, s2) ? sideabkz(s2, false) : "-?-"; rsize = slprintf(bufp, size, "%s %s %d(%s)", komma++ ? "," : (const char *)header, loc_army, army_index(s2), diff --git a/src/creport.c b/src/creport.c index f9bffd177..e49a96448 100644 --- a/src/creport.c +++ b/src/creport.c @@ -84,7 +84,7 @@ static char g_bigbuf[BUFFERSIZE]; bool opt_cr_absolute_coords = false; /* globals */ -#define C_REPORT_VERSION 67 +#define C_REPORT_VERSION 68 struct locale *crtag_locale(void) { static struct locale * lang; @@ -495,38 +495,6 @@ static int cr_curse(variant var, char *buffer, const void *userdata) /*static int msgno; */ -#define MTMAXHASH 1021 - -static struct known_mtype { - const struct message_type *mtype; - struct known_mtype *nexthash; -} *mtypehash[MTMAXHASH]; - -static void report_crtypes(FILE * F, const struct locale *lang) -{ - int i; - for (i = 0; i != MTMAXHASH; ++i) { - struct known_mtype *kmt; - for (kmt = mtypehash[i]; kmt; kmt = kmt->nexthash) { - char buffer[DISPLAYSIZE]; - int hash = (int)kmt->mtype->key; - assert(hash > 0); - fprintf(F, "MESSAGETYPE %d\n", hash); - fputc('\"', F); - fputs(crescape(nrt_string(kmt->mtype, lang), buffer, sizeof(buffer)), F); - fputs("\";text\n", F); - if (kmt->mtype->section) { - fprintf(F, "\"%s\";section\n", kmt->mtype->section); - } - } - while (mtypehash[i]) { - kmt = mtypehash[i]; - mtypehash[i] = mtypehash[i]->nexthash; - free(kmt); - } - } -} - static int message_id(const struct message *msg) { variant var; @@ -594,19 +562,6 @@ static void render_messages(FILE * F, faction * f, message_list * msgs) else { log_error("could not render cr-message %p: %s\n", m->msg, m->msg->type->name); } - if (printed) { - unsigned int ihash = hash % MTMAXHASH; - struct known_mtype *kmt = mtypehash[ihash]; - while (kmt && kmt->mtype != mtype) - kmt = kmt->nexthash; - if (kmt == NULL) { - kmt = (struct known_mtype *)malloc(sizeof(struct known_mtype)); - if (!kmt) abort(); - kmt->nexthash = mtypehash[ihash]; - kmt->mtype = mtype; - mtypehash[ihash] = kmt; - } - } m = m->next; } } @@ -1714,7 +1669,6 @@ report_computer(const char *filename, report_context * ctx, const char *bom) cr_output_region(F, ctx, r); } } - report_crtypes(F, f->locale); if (f->locale != crtag_locale()) { report_translations(F); } diff --git a/src/laws.c b/src/laws.c index d3912abac..00fa600af 100644 --- a/src/laws.c +++ b/src/laws.c @@ -591,11 +591,11 @@ growing_trees_e3(region * r, const int current_season, } } -static short cap_short(int i) { - if (i > SHRT_MIN) { - return ((i < SHRT_MAX) ? (short)i : SHRT_MAX); +static int cap_int(int i, int imin, int imax) { + if (i > imin) { + return ((i < imax) ? i : imax); } - return SHRT_MIN; + return imin; } static void @@ -681,8 +681,12 @@ growing_trees(region * r, const season_t current_season, const season_t last_wee a = a_find(r->attribs, &at_germs); if (!a) { a = a_add(&r->attribs, a_new(&at_germs)); - a->data.sa[0] = cap_short(rtrees(r, 0)); - a->data.sa[1] = cap_short(rtrees(r, 1)); + a->data.sa[0] = (short)cap_int(rtrees(r, 0), 0, SHRT_MAX); + a->data.sa[1] = (short)cap_int(rtrees(r, 1), 0, SHRT_MAX); + } + else if (a->data.sa[0] < 0 || a->data.sa[1] << 0) { + a->data.sa[0] = (short)cap_int(a->data.sa[0], 0, SHRT_MAX); + a->data.sa[1] = (short)cap_int(a->data.sa[1], 0, SHRT_MAX); } /* Baumwachstum */