Merge branch 'master' into develop

Conflicts:
	src/buildno.h
	src/kernel/save.c
This commit is contained in:
Enno Rehling 2016-05-29 11:13:19 +02:00
commit 5535beed61
3 changed files with 46 additions and 40 deletions

View File

@ -232,7 +232,7 @@ static faction *factionorders(void)
const char *pass = gettoken(token, sizeof(token));
if (!checkpasswd(f, (const char *)pass)) {
log_debug("Invalid password for faction %s\n", itoa36(fid));
log_debug("Invalid password for faction %s", itoa36(fid));
ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password",
f->no, pass));
return 0;
@ -246,7 +246,7 @@ static faction *factionorders(void)
}
else {
log_debug("orders for invalid faction %s\n", itoa36(fid));
log_debug("orders for invalid faction %s", itoa36(fid));
}
return f;
}
@ -405,14 +405,14 @@ void read_items(struct storage *store, item ** ilist)
itype = it_find(ibuf);
READ_INT(store, &i);
if (i <= 0) {
log_error("data contains an entry with %d %s\n", i, resourcename(itype->rtype, NMF_PLURAL));
log_error("data contains an entry with %d %s", i, resourcename(itype->rtype, NMF_PLURAL));
}
else {
if (itype && itype->rtype) {
i_change(ilist, itype, i);
}
else {
log_error("data contains unknown item type %s.\n", ibuf);
log_error("data contains unknown item type %s.", ibuf);
}
assert(itype && itype->rtype);
}
@ -490,7 +490,7 @@ static int resolve_owner(variant id, void *address)
if (id.i != 0) {
f = findfaction(id.i);
if (f == NULL) {
log_error("region has an invalid owner (%s)\n", itoa36(id.i));
log_error("region has an invalid owner (%s)", itoa36(id.i));
}
}
owner->owner = f;
@ -625,13 +625,13 @@ unit *read_unit(struct gamedata *data)
READ_INT(data->store, &n);
if (n <= 0) {
log_error("data contains invalid unit %d.\n", n);
log_error("data contains invalid unit %d.", n);
assert(n > 0);
return 0;
}
u = findunit(n);
if (u) {
log_error("reading unit %s that already exists.\n", unitname(u));
log_error("reading unit %s that already exists.", unitname(u));
while (u->attribs) {
a_remove(&u->attribs, u->attribs);
}
@ -658,7 +658,7 @@ unit *read_unit(struct gamedata *data)
++u->faction->no_units;
}
else {
log_error("unit %s has faction == NULL\n", itoa36(u->no));
log_error("unit %s has faction == NULL", itoa36(u->no));
return 0;
}
@ -707,7 +707,7 @@ unit *read_unit(struct gamedata *data)
}
}
else {
log_error("read_unit: unit in unkown building '%s'\n", itoa36(n));
log_error("read_unit: unit in unkown building '%s'", itoa36(n));
}
}
@ -721,7 +721,7 @@ unit *read_unit(struct gamedata *data)
}
}
else {
log_error("read_unit: unit in unkown ship '%s'\n", itoa36(n));
log_error("read_unit: unit in unkown ship '%s'", itoa36(n));
}
}
@ -732,7 +732,7 @@ unit *read_unit(struct gamedata *data)
if ((u->flags & UFL_ANON_FACTION) && !rule_stealth_anon()) {
/* if this rule is broken, then fix broken units */
u->flags -= UFL_ANON_FACTION;
log_warning("%s was anonymous.\n", unitname(u));
log_warning("%s was anonymous.", unitname(u));
}
/* Persistente Befehle einlesen */
free_orders(&u->orders);
@ -750,11 +750,11 @@ unit *read_unit(struct gamedata *data)
ord = NULL;
}
else if (p == MAXPERSISTENT) {
log_info("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT);
log_info("%s had %d or more persistent orders", unitname(u), MAXPERSISTENT);
}
}
else if (n == MAXORDERS) {
log_info("%s had %d or more orders\n", unitname(u), MAXORDERS);
log_info("%s had %d or more orders", unitname(u), MAXORDERS);
}
if (ord != NULL)
free_order(ord);
@ -782,7 +782,7 @@ unit *read_unit(struct gamedata *data)
read_items(data->store, &u->items);
READ_INT(data->store, &u->hp);
if (u->hp < u->number) {
log_error("Einheit %s hat %u Personen, und %u Trefferpunkte\n", itoa36(u->no), u->number, u->hp);
log_error("Einheit %s hat %u Personen, und %u Trefferpunkte", itoa36(u->no), u->number, u->hp);
u->hp = u->number;
}
read_attribs(data, &u->attribs, u);
@ -817,7 +817,7 @@ void write_unit(struct gamedata *data, const unit * u)
writeorder(data, ord, u->faction->locale);
}
else {
log_info("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT);
log_info("%s had %d or more persistent orders", unitname(u), MAXPERSISTENT);
break;
}
}
@ -830,7 +830,7 @@ void write_unit(struct gamedata *data, const unit * u)
writeorder(data, ord, u->faction->locale);
}
else {
log_info("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT);
log_info("%s had %d or more persistent orders", unitname(u), MAXPERSISTENT);
break;
}
}
@ -854,8 +854,8 @@ void write_unit(struct gamedata *data, const unit * u)
WRITE_SECTION(data->store);
write_items(data->store, u->items);
WRITE_SECTION(data->store);
if (u->hp == 0 && u_race(u) != get_race(RC_SPELL)) {
log_error("unit %s has 0 hitpoints, adjusting.\n", itoa36(u->no));
if (u->hp == 0 && u_race(u)!= get_race(RC_SPELL)) {
log_error("unit %s has 0 hitpoints, adjusting.", itoa36(u->no));
((unit *)u)->hp = u->number;
}
WRITE_INT(data->store, u->hp);
@ -906,7 +906,7 @@ static region *readregion(struct gamedata *data, int x, int y)
READ_STR(data->store, name, sizeof(name));
terrain = get_terrain(name);
if (terrain == NULL) {
log_error("Unknown terrain '%s'\n", name);
log_error("Unknown terrain '%s'", name);
assert(!"unknown terrain");
}
r->terrain = terrain;
@ -925,19 +925,19 @@ static region *readregion(struct gamedata *data, int x, int y)
READ_INT(data->store, &i);
if (i < 0) {
log_error("number of trees in %s is %d.\n", regionname(r, NULL), i);
log_error("number of trees in %s is %d.", regionname(r, NULL), i);
i = 0;
}
rsettrees(r, 0, i);
READ_INT(data->store, &i);
if (i < 0) {
log_error("number of young trees in %s is %d.\n", regionname(r, NULL), i);
log_error("number of young trees in %s is %d.", regionname(r, NULL), i);
i = 0;
}
rsettrees(r, 1, i);
READ_INT(data->store, &i);
if (i < 0) {
log_error("number of seeds in %s is %d.\n", regionname(r, NULL), i);
log_error("number of seeds in %s is %d.", regionname(r, NULL), i);
i = 0;
}
rsettrees(r, 2, i);
@ -953,7 +953,7 @@ static region *readregion(struct gamedata *data, int x, int y)
res = malloc(sizeof(rawmaterial));
res->type = rmt_find(name);
if (res->type == NULL) {
log_error("invalid resourcetype %s in data.\n", name);
log_error("invalid resourcetype %s in data.", name);
}
assert(res->type != NULL);
READ_INT(data->store, &n);
@ -1154,7 +1154,7 @@ void read_spellbook(spellbook **bookp, gamedata *data, int(*get_level)(const spe
if (bookp) {
sp = find_spell(spname);
if (!sp) {
log_error("read_spells: could not find spell '%s'\n", spname);
log_error("read_spells: could not find spell '%s'", spname);
}
}
if (data->version >= SPELLBOOK_VERSION) {
@ -1215,7 +1215,7 @@ static char * getpasswd(int fno) {
static void read_password(gamedata *data, faction *f) {
char name[128];
READ_STR(data->store, name, sizeof(name));
if (name[0]=='$' && data->version == BADCRYPT_VERSION) {
if (name[0] == '$' && data->version == BADCRYPT_VERSION) {
char * pass = getpasswd(f->no);
if (pass) {
faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT));
@ -1305,7 +1305,7 @@ faction *readfaction(struct gamedata * data)
READ_STR(data->store, name, sizeof(name));
if (set_email(&f->email, name) != 0) {
log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), name);
log_warning("Invalid email address for faction %s: %s", itoa36(f->no), name);
set_email(&f->email, "");
}
@ -1322,7 +1322,7 @@ faction *readfaction(struct gamedata * data)
READ_STR(data->store, name, sizeof(name));
f->race = rc_find(name);
if (!f->race) {
log_error("unknown race in data: %s\n", name);
log_error("unknown race in data: %s", name);
}
assert(f->race);
READ_INT(data->store, &n);
@ -1481,7 +1481,7 @@ int readgame(const char *filename, bool backup)
size_t sz;
init_locales();
log_debug("- reading game data from %s\n", filename);
log_debug("- reading game data from %s", filename);
join_path(datapath(), filename, path, sizeof(path));
if (backup) {
@ -1549,7 +1549,7 @@ int read_game(gamedata *data) {
read_attribs(data, &global.attribs, NULL);
READ_INT(store, &turn);
global.data_turn = turn;
log_debug(" - reading turn %d\n", turn);
log_debug(" - reading turn %d", turn);
rng_init(turn);
READ_INT(store, NULL); /* max_unique_id = ignore */
READ_INT(store, &nextborder);
@ -1569,7 +1569,7 @@ int read_game(gamedata *data) {
pl = calloc(1, sizeof(plane));
}
else {
log_warning("the plane with id=%d already exists.\n", id);
log_warning("the plane with id=%d already exists.", id);
}
pl->id = id;
READ_STR(store, name, sizeof(name));
@ -1591,7 +1591,7 @@ int read_game(gamedata *data) {
}
else {
log_error(
("This datafile contains watchers, but we are unable to read them\n"));
("This datafile contains watchers, but we are unable to read them."));
}
}
}
@ -1750,10 +1750,10 @@ int read_game(gamedata *data) {
read_borders(data);
/* Unaufgeloeste Zeiger initialisieren */
log_debug("fixing unresolved references.\n");
log_debug("fixing unresolved references.");
resolve();
log_debug("updating area information for lighthouses.\n");
log_debug("updating area information for lighthouses.");
for (r = regions; r; r = r->next) {
if (r->flags & RF_LIGHTHOUSE) {
building *b;
@ -1761,7 +1761,7 @@ int read_game(gamedata *data) {
update_lighthouse(b);
}
}
log_debug("marking factions as alive.\n");
log_debug("marking factions as alive.");
for (f = factions; f; f = f->next) {
if (f->flags & FFL_NPC) {
f->_alive = true;
@ -1770,7 +1770,7 @@ int read_game(gamedata *data) {
int no = 666;
while (findfaction(no))
++no;
log_warning("renum(monsters, %d)\n", no);
log_warning("renum(monsters, %d)", no);
renumber_faction(f, no);
}
}
@ -1782,7 +1782,7 @@ int read_game(gamedata *data) {
faction *f = u->faction;
int skl = effskill(u, SK_MAGIC, 0);
if (f->magiegebiet == M_GRAY) {
log_error("faction %s had magic=gray, fixing (%s)\n", factionname(f), magic_school[mage->magietyp]);
log_error("faction %s had magic=gray, fixing (%s)", factionname(f), magic_school[mage->magietyp]);
f->magiegebiet = mage->magietyp;
}
if (f->max_spelllevel < skl) {
@ -1808,7 +1808,7 @@ int read_game(gamedata *data) {
if (loadplane || maxregions >= 0) {
remove_empty_factions();
}
log_debug("Done loading turn %d.\n", turn);
log_debug("Done loading turn %d.", turn);
return 0;
}
@ -1908,7 +1908,7 @@ int write_game(gamedata *data) {
WRITE_INT(store, n);
WRITE_SECTION(store);
log_debug(" - Schreibe %d Parteien...\n", n);
log_debug(" - Schreibe %d Parteien...", n);
for (f = factions; f; f = f->next) {
if (fval(f, FFL_NPC)) {
clear_npc_orders(f);

View File

@ -89,13 +89,16 @@ int update_nmrs(void)
if (fval(f, FFL_ISNEW)) {
++newplayers;
}
else if (!fval(f, FFL_NOIDLEOUT)) {
else if (!fval(f, FFL_NOIDLEOUT|FFL_CURSED)) {
int nmr = turn - f->lastorders + 1;
if (nmr < 0 || nmr > NMRTimeout()) {
log_error("faction %s has %d NMRS\n", factionid(f), nmr);
log_error("faction %s has %d NMR", factionid(f), nmr);
nmr = _max(0, nmr);
nmr = _min(nmr, NMRTimeout());
}
if (nmr > 0) {
log_debug("faction %s has %d NMR", factionid(f), nmr);
}
++nmrs[nmr];
}
}

View File

@ -9,6 +9,9 @@
void log_string(void *data, int level, const char *module, const char *format, va_list args) {
char *str = (char *)data;
const char *arg = va_arg(args, const char *);
unused_arg(format);
unused_arg(module);
unused_arg(level);
strncpy(str, arg, 32);
}