From 36e1060fc77c8c63cc91f4e9f1f3c4b28e34c375 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 31 Jul 2016 18:48:27 +0200 Subject: [PATCH] turn maxsize assert into an error fix log rotation on windows --- src/kernel/build.c | 7 +++++-- src/util/log.c | 9 ++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/kernel/build.c b/src/kernel/build.c index 1c284b3f9..f3c74bf95 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -514,7 +514,7 @@ int build(unit * u, const construction * ctype, int completed, int want) * (enno): Nein, das ist für Dinge, bei denen die nächste Ausbaustufe * die gleiche wie die vorherige ist. z.b. gegenstände. */ - if (type->maxsize > 1) { + if (type->maxsize > 0) { completed = completed % type->maxsize; } else { @@ -848,7 +848,10 @@ build_building(unit * u, const building_type * btype, int id, int want, order * } b->size += built; - assert(b->type->maxsize <= 0 || b->size <= b->type->maxsize); + if (b->type->maxsize > 0 && b->size > b->type->maxsize) { + // this seems to be okay for a watch, but is not okay for an academy or harbour + log_error("build: %s has size=%d, maxsize=%d", buildingname(b), b->size, b->type->maxsize); + } fset(b, BLD_EXPANDED); update_lighthouse(b); diff --git a/src/util/log.c b/src/util/log.c index 7be2f9a06..1399ce562 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -97,21 +97,20 @@ void log_rotate(const char *filename, int maxindex) assert(strlen(filename) < sizeof(buffer[0]) - 4); sprintf(buffer[dst], "%s.%d", filename, maxindex); -#ifdef HAVE_UNISTD_H /* make sure we don't overwrite an existing file (hard links) */ - unlink(buffer[dst]); -#endif + remove(buffer[dst]); + while (maxindex > 0) { int err, src = 1 - dst; sprintf(buffer[src], "%s.%d", filename, --maxindex); err = rename(buffer[src], buffer[dst]); if (err != 0) { - log_debug("log rotate %s: %s", buffer[dst], strerror(errno)); + fprintf(stderr, "log rotate %s: %s", buffer[dst], strerror(errno)); } dst = src; } if (rename(filename, buffer[dst]) != 0) { - log_debug("log rotate %s: %s", buffer[dst], strerror(errno)); + fprintf(stderr, "log rotate %s: %s", buffer[dst], strerror(errno)); } }