forked from github/server
turn maxsize assert into an error
fix log rotation on windows
This commit is contained in:
parent
ba6f75df3e
commit
36e1060fc7
|
@ -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
|
* (enno): Nein, das ist für Dinge, bei denen die nächste Ausbaustufe
|
||||||
* die gleiche wie die vorherige ist. z.b. gegenstände.
|
* die gleiche wie die vorherige ist. z.b. gegenstände.
|
||||||
*/
|
*/
|
||||||
if (type->maxsize > 1) {
|
if (type->maxsize > 0) {
|
||||||
completed = completed % type->maxsize;
|
completed = completed % type->maxsize;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -848,7 +848,10 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
||||||
}
|
}
|
||||||
|
|
||||||
b->size += built;
|
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);
|
fset(b, BLD_EXPANDED);
|
||||||
|
|
||||||
update_lighthouse(b);
|
update_lighthouse(b);
|
||||||
|
|
|
@ -97,21 +97,20 @@ void log_rotate(const char *filename, int maxindex)
|
||||||
assert(strlen(filename) < sizeof(buffer[0]) - 4);
|
assert(strlen(filename) < sizeof(buffer[0]) - 4);
|
||||||
|
|
||||||
sprintf(buffer[dst], "%s.%d", filename, maxindex);
|
sprintf(buffer[dst], "%s.%d", filename, maxindex);
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
/* make sure we don't overwrite an existing file (hard links) */
|
/* make sure we don't overwrite an existing file (hard links) */
|
||||||
unlink(buffer[dst]);
|
remove(buffer[dst]);
|
||||||
#endif
|
|
||||||
while (maxindex > 0) {
|
while (maxindex > 0) {
|
||||||
int err, src = 1 - dst;
|
int err, src = 1 - dst;
|
||||||
sprintf(buffer[src], "%s.%d", filename, --maxindex);
|
sprintf(buffer[src], "%s.%d", filename, --maxindex);
|
||||||
err = rename(buffer[src], buffer[dst]);
|
err = rename(buffer[src], buffer[dst]);
|
||||||
if (err != 0) {
|
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;
|
dst = src;
|
||||||
}
|
}
|
||||||
if (rename(filename, buffer[dst]) != 0) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue