forked from github/server
Merge pull request #511 from ennorehling/master
Fix 55 NMR abort, E2 turn 978
This commit is contained in:
commit
0639e2ef1f
|
@ -1,3 +1,3 @@
|
||||||
#define VERSION_MAJOR 3
|
#define VERSION_MAJOR 3
|
||||||
#define VERSION_MINOR 8
|
#define VERSION_MINOR 8
|
||||||
#define VERSION_BUILD 12
|
#define VERSION_BUILD 13
|
||||||
|
|
|
@ -230,7 +230,7 @@ static faction *factionorders(void)
|
||||||
const char *pass = gettoken(token, sizeof(token));
|
const char *pass = gettoken(token, sizeof(token));
|
||||||
|
|
||||||
if (!checkpasswd(f, (const char *)pass)) {
|
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",
|
ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password",
|
||||||
f->no, pass));
|
f->no, pass));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -244,7 +244,7 @@ static faction *factionorders(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_debug("orders for invalid faction %s\n", itoa36(fid));
|
log_debug("orders for invalid faction %s", itoa36(fid));
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -403,14 +403,14 @@ void read_items(struct storage *store, item ** ilist)
|
||||||
itype = it_find(ibuf);
|
itype = it_find(ibuf);
|
||||||
READ_INT(store, &i);
|
READ_INT(store, &i);
|
||||||
if (i <= 0) {
|
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 {
|
else {
|
||||||
if (itype && itype->rtype) {
|
if (itype && itype->rtype) {
|
||||||
i_change(ilist, itype, i);
|
i_change(ilist, itype, i);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error("data contains unknown item type %s.\n", ibuf);
|
log_error("data contains unknown item type %s.", ibuf);
|
||||||
}
|
}
|
||||||
assert(itype && itype->rtype);
|
assert(itype && itype->rtype);
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,7 @@ static int resolve_owner(variant id, void *address)
|
||||||
if (id.i != 0) {
|
if (id.i != 0) {
|
||||||
f = findfaction(id.i);
|
f = findfaction(id.i);
|
||||||
if (f == NULL) {
|
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;
|
owner->owner = f;
|
||||||
|
@ -594,13 +594,13 @@ unit *read_unit(struct gamedata *data)
|
||||||
|
|
||||||
READ_INT(data->store, &n);
|
READ_INT(data->store, &n);
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
log_error("data contains invalid unit %d.\n", n);
|
log_error("data contains invalid unit %d.", n);
|
||||||
assert(n > 0);
|
assert(n > 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
u = findunit(n);
|
u = findunit(n);
|
||||||
if (u) {
|
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) {
|
while (u->attribs) {
|
||||||
a_remove(&u->attribs, u->attribs);
|
a_remove(&u->attribs, u->attribs);
|
||||||
}
|
}
|
||||||
|
@ -627,7 +627,7 @@ unit *read_unit(struct gamedata *data)
|
||||||
++u->faction->no_units;
|
++u->faction->no_units;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error("unit %s has faction == NULL\n", itoa36(u->no));
|
log_error("unit %s has faction == NULL", itoa36(u->no));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,7 +676,7 @@ unit *read_unit(struct gamedata *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error("read_unit: unit in unkown building '%s'\n", itoa36(n));
|
log_error("read_unit: unit in unkown building '%s'", itoa36(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ unit *read_unit(struct gamedata *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error("read_unit: unit in unkown ship '%s'\n", itoa36(n));
|
log_error("read_unit: unit in unkown ship '%s'", itoa36(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ unit *read_unit(struct gamedata *data)
|
||||||
if ((u->flags & UFL_ANON_FACTION) && !rule_stealth_anon()) {
|
if ((u->flags & UFL_ANON_FACTION) && !rule_stealth_anon()) {
|
||||||
/* if this rule is broken, then fix broken units */
|
/* if this rule is broken, then fix broken units */
|
||||||
u->flags -= UFL_ANON_FACTION;
|
u->flags -= UFL_ANON_FACTION;
|
||||||
log_warning("%s was anonymous.\n", unitname(u));
|
log_warning("%s was anonymous.", unitname(u));
|
||||||
}
|
}
|
||||||
/* Persistente Befehle einlesen */
|
/* Persistente Befehle einlesen */
|
||||||
free_orders(&u->orders);
|
free_orders(&u->orders);
|
||||||
|
@ -719,11 +719,11 @@ unit *read_unit(struct gamedata *data)
|
||||||
ord = NULL;
|
ord = NULL;
|
||||||
}
|
}
|
||||||
else if (p == MAXPERSISTENT) {
|
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) {
|
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)
|
if (ord != NULL)
|
||||||
free_order(ord);
|
free_order(ord);
|
||||||
|
@ -751,7 +751,7 @@ unit *read_unit(struct gamedata *data)
|
||||||
read_items(data->store, &u->items);
|
read_items(data->store, &u->items);
|
||||||
READ_INT(data->store, &u->hp);
|
READ_INT(data->store, &u->hp);
|
||||||
if (u->hp < u->number) {
|
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;
|
u->hp = u->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -787,7 +787,7 @@ void write_unit(struct gamedata *data, const unit * u)
|
||||||
writeorder(data, ord, u->faction->locale);
|
writeorder(data, ord, u->faction->locale);
|
||||||
}
|
}
|
||||||
else {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -800,7 +800,7 @@ void write_unit(struct gamedata *data, const unit * u)
|
||||||
writeorder(data, ord, u->faction->locale);
|
writeorder(data, ord, u->faction->locale);
|
||||||
}
|
}
|
||||||
else {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -825,7 +825,7 @@ void write_unit(struct gamedata *data, const unit * u)
|
||||||
write_items(data->store, u->items);
|
write_items(data->store, u->items);
|
||||||
WRITE_SECTION(data->store);
|
WRITE_SECTION(data->store);
|
||||||
if (u->hp == 0 && u_race(u)!= get_race(RC_SPELL)) {
|
if (u->hp == 0 && u_race(u)!= get_race(RC_SPELL)) {
|
||||||
log_error("unit %s has 0 hitpoints, adjusting.\n", itoa36(u->no));
|
log_error("unit %s has 0 hitpoints, adjusting.", itoa36(u->no));
|
||||||
((unit *)u)->hp = u->number;
|
((unit *)u)->hp = u->number;
|
||||||
}
|
}
|
||||||
WRITE_INT(data->store, u->hp);
|
WRITE_INT(data->store, u->hp);
|
||||||
|
@ -876,7 +876,7 @@ static region *readregion(struct gamedata *data, int x, int y)
|
||||||
READ_STR(data->store, name, sizeof(name));
|
READ_STR(data->store, name, sizeof(name));
|
||||||
terrain = get_terrain(name);
|
terrain = get_terrain(name);
|
||||||
if (terrain == NULL) {
|
if (terrain == NULL) {
|
||||||
log_error("Unknown terrain '%s'\n", name);
|
log_error("Unknown terrain '%s'", name);
|
||||||
assert(!"unknown terrain");
|
assert(!"unknown terrain");
|
||||||
}
|
}
|
||||||
r->terrain = terrain;
|
r->terrain = terrain;
|
||||||
|
@ -895,19 +895,19 @@ static region *readregion(struct gamedata *data, int x, int y)
|
||||||
|
|
||||||
READ_INT(data->store, &i);
|
READ_INT(data->store, &i);
|
||||||
if (i < 0) {
|
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;
|
i = 0;
|
||||||
}
|
}
|
||||||
rsettrees(r, 0, i);
|
rsettrees(r, 0, i);
|
||||||
READ_INT(data->store, &i);
|
READ_INT(data->store, &i);
|
||||||
if (i < 0) {
|
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;
|
i = 0;
|
||||||
}
|
}
|
||||||
rsettrees(r, 1, i);
|
rsettrees(r, 1, i);
|
||||||
READ_INT(data->store, &i);
|
READ_INT(data->store, &i);
|
||||||
if (i < 0) {
|
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;
|
i = 0;
|
||||||
}
|
}
|
||||||
rsettrees(r, 2, i);
|
rsettrees(r, 2, i);
|
||||||
|
@ -923,7 +923,7 @@ static region *readregion(struct gamedata *data, int x, int y)
|
||||||
res = malloc(sizeof(rawmaterial));
|
res = malloc(sizeof(rawmaterial));
|
||||||
res->type = rmt_find(name);
|
res->type = rmt_find(name);
|
||||||
if (res->type == NULL) {
|
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);
|
assert(res->type != NULL);
|
||||||
READ_INT(data->store, &n);
|
READ_INT(data->store, &n);
|
||||||
|
@ -1124,7 +1124,7 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co
|
||||||
if (bookp) {
|
if (bookp) {
|
||||||
sp = find_spell(spname);
|
sp = find_spell(spname);
|
||||||
if (!sp) {
|
if (!sp) {
|
||||||
log_error("read_spells: could not find spell '%s'\n", spname);
|
log_error("read_spells: could not find spell '%s'", spname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (global.data_version >= SPELLBOOK_VERSION) {
|
if (global.data_version >= SPELLBOOK_VERSION) {
|
||||||
|
@ -1185,7 +1185,7 @@ static char * getpasswd(int fno) {
|
||||||
static void read_password(gamedata *data, faction *f) {
|
static void read_password(gamedata *data, faction *f) {
|
||||||
char name[128];
|
char name[128];
|
||||||
READ_STR(data->store, name, sizeof(name));
|
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);
|
char * pass = getpasswd(f->no);
|
||||||
if (pass) {
|
if (pass) {
|
||||||
faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT));
|
faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT));
|
||||||
|
@ -1274,7 +1274,7 @@ faction *readfaction(struct gamedata * data)
|
||||||
|
|
||||||
READ_STR(data->store, name, sizeof(name));
|
READ_STR(data->store, name, sizeof(name));
|
||||||
if (set_email(&f->email, name) != 0) {
|
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, "");
|
set_email(&f->email, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1291,7 +1291,7 @@ faction *readfaction(struct gamedata * data)
|
||||||
READ_STR(data->store, name, sizeof(name));
|
READ_STR(data->store, name, sizeof(name));
|
||||||
f->race = rc_find(name);
|
f->race = rc_find(name);
|
||||||
if (!f->race) {
|
if (!f->race) {
|
||||||
log_error("unknown race in data: %s\n", name);
|
log_error("unknown race in data: %s", name);
|
||||||
}
|
}
|
||||||
assert(f->race);
|
assert(f->race);
|
||||||
READ_INT(data->store, &n);
|
READ_INT(data->store, &n);
|
||||||
|
@ -1456,7 +1456,7 @@ int readgame(const char *filename, bool backup)
|
||||||
size_t sz;
|
size_t sz;
|
||||||
|
|
||||||
init_locales();
|
init_locales();
|
||||||
log_debug("- reading game data from %s\n", filename);
|
log_debug("- reading game data from %s", filename);
|
||||||
sprintf(path, "%s/%s", datapath(), filename);
|
sprintf(path, "%s/%s", datapath(), filename);
|
||||||
|
|
||||||
if (backup) {
|
if (backup) {
|
||||||
|
@ -1509,7 +1509,7 @@ int readgame(const char *filename, bool backup)
|
||||||
a_read(&store, &global.attribs, NULL);
|
a_read(&store, &global.attribs, NULL);
|
||||||
READ_INT(&store, &turn);
|
READ_INT(&store, &turn);
|
||||||
global.data_turn = turn;
|
global.data_turn = turn;
|
||||||
log_debug(" - reading turn %d\n", turn);
|
log_debug(" - reading turn %d", turn);
|
||||||
rng_init(turn);
|
rng_init(turn);
|
||||||
READ_INT(&store, &nread); /* max_unique_id = ignore */
|
READ_INT(&store, &nread); /* max_unique_id = ignore */
|
||||||
READ_INT(&store, &nextborder);
|
READ_INT(&store, &nextborder);
|
||||||
|
@ -1528,7 +1528,7 @@ int readgame(const char *filename, bool backup)
|
||||||
pl = calloc(1, sizeof(plane));
|
pl = calloc(1, sizeof(plane));
|
||||||
}
|
}
|
||||||
else {
|
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;
|
pl->id = id;
|
||||||
READ_STR(&store, name, sizeof(name));
|
READ_STR(&store, name, sizeof(name));
|
||||||
|
@ -1550,7 +1550,7 @@ int readgame(const char *filename, bool backup)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error(
|
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."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1711,10 +1711,10 @@ int readgame(const char *filename, bool backup)
|
||||||
binstore_done(&store);
|
binstore_done(&store);
|
||||||
fstream_done(&strm);
|
fstream_done(&strm);
|
||||||
/* Unaufgeloeste Zeiger initialisieren */
|
/* Unaufgeloeste Zeiger initialisieren */
|
||||||
log_debug("fixing unresolved references.\n");
|
log_debug("fixing unresolved references.");
|
||||||
resolve();
|
resolve();
|
||||||
|
|
||||||
log_debug("updating area information for lighthouses.\n");
|
log_debug("updating area information for lighthouses.");
|
||||||
for (r = regions; r; r = r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
if (r->flags & RF_LIGHTHOUSE) {
|
if (r->flags & RF_LIGHTHOUSE) {
|
||||||
building *b;
|
building *b;
|
||||||
|
@ -1722,7 +1722,7 @@ int readgame(const char *filename, bool backup)
|
||||||
update_lighthouse(b);
|
update_lighthouse(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log_debug("marking factions as alive.\n");
|
log_debug("marking factions as alive.");
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
if (f->flags & FFL_NPC) {
|
if (f->flags & FFL_NPC) {
|
||||||
f->_alive = true;
|
f->_alive = true;
|
||||||
|
@ -1731,7 +1731,7 @@ int readgame(const char *filename, bool backup)
|
||||||
int no = 666;
|
int no = 666;
|
||||||
while (findfaction(no))
|
while (findfaction(no))
|
||||||
++no;
|
++no;
|
||||||
log_warning("renum(monsters, %d)\n", no);
|
log_warning("renum(monsters, %d)", no);
|
||||||
renumber_faction(f, no);
|
renumber_faction(f, no);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1743,7 +1743,7 @@ int readgame(const char *filename, bool backup)
|
||||||
faction *f = u->faction;
|
faction *f = u->faction;
|
||||||
int skl = effskill(u, SK_MAGIC, 0);
|
int skl = effskill(u, SK_MAGIC, 0);
|
||||||
if (f->magiegebiet == M_GRAY) {
|
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;
|
f->magiegebiet = mage->magietyp;
|
||||||
}
|
}
|
||||||
if (f->max_spelllevel < skl) {
|
if (f->max_spelllevel < skl) {
|
||||||
|
@ -1769,7 +1769,7 @@ int readgame(const char *filename, bool backup)
|
||||||
if (loadplane || maxregions >= 0) {
|
if (loadplane || maxregions >= 0) {
|
||||||
remove_empty_factions();
|
remove_empty_factions();
|
||||||
}
|
}
|
||||||
log_debug("Done loading turn %d.\n", turn);
|
log_debug("Done loading turn %d.", turn);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1861,7 +1861,7 @@ int writegame(const char *filename)
|
||||||
WRITE_INT(&store, n);
|
WRITE_INT(&store, n);
|
||||||
WRITE_SECTION(&store);
|
WRITE_SECTION(&store);
|
||||||
|
|
||||||
log_debug(" - Schreibe %d Parteien...\n", n);
|
log_debug(" - Schreibe %d Parteien...", n);
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
if (fval(f, FFL_NPC)) {
|
if (fval(f, FFL_NPC)) {
|
||||||
clear_npc_orders(f);
|
clear_npc_orders(f);
|
||||||
|
|
|
@ -89,13 +89,16 @@ int update_nmrs(void)
|
||||||
if (fval(f, FFL_ISNEW)) {
|
if (fval(f, FFL_ISNEW)) {
|
||||||
++newplayers;
|
++newplayers;
|
||||||
}
|
}
|
||||||
else if (!fval(f, FFL_NOIDLEOUT)) {
|
else if (!fval(f, FFL_NOIDLEOUT|FFL_CURSED)) {
|
||||||
int nmr = turn - f->lastorders + 1;
|
int nmr = turn - f->lastorders + 1;
|
||||||
if (nmr < 0 || nmr > NMRTimeout()) {
|
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 = _max(0, nmr);
|
||||||
nmr = _min(nmr, NMRTimeout());
|
nmr = _min(nmr, NMRTimeout());
|
||||||
}
|
}
|
||||||
|
if (nmr > 0) {
|
||||||
|
log_debug("faction %s has %d NMR", factionid(f), nmr);
|
||||||
|
}
|
||||||
++nmrs[nmr];
|
++nmrs[nmr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
void log_string(void *data, int level, const char *module, const char *format, va_list args) {
|
void log_string(void *data, int level, const char *module, const char *format, va_list args) {
|
||||||
char *str = (char *)data;
|
char *str = (char *)data;
|
||||||
const char *arg = va_arg(args, const char *);
|
const char *arg = va_arg(args, const char *);
|
||||||
|
unused_arg(format);
|
||||||
|
unused_arg(module);
|
||||||
|
unused_arg(level);
|
||||||
strncpy(str, arg, 32);
|
strncpy(str, arg, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue