bugfix monsterfaction

This commit is contained in:
Enno Rehling 2008-05-12 09:44:01 +00:00
parent dcf3292467
commit 76497abc92
3 changed files with 25 additions and 11 deletions

View File

@ -341,7 +341,8 @@ set_alliance(faction * a, faction * b, int status)
(*sfp)->status |= status;
}
void renumber_faction(faction * f, int no)
void
renumber_faction(faction * f, int no)
{
if (f->subscription) {
sql_print(("UPDATE subscriptions set faction='%s' where id=%u;\n",

View File

@ -145,7 +145,7 @@ extern void remove_enemy(struct faction * f, struct faction * enemy);
extern void write_faction_reference(const struct faction * f, struct storage * store);
extern int read_faction_reference(struct faction ** f, struct storage * store);
void renumber_faction(faction * f, int no);
extern void renumber_faction(faction * f, int no);
#ifdef SMART_INTERVALS
extern void update_interval(struct faction * f, struct region * r);

View File

@ -1419,6 +1419,9 @@ readfaction(struct storage * store)
#endif /* KARMA_MODULE */
f->flags = store->r_int(store);
if (f->no==0) {
f->flags |= FFL_NPC;
}
a_read(store, &f->attribs);
if (store->version>=CLAIM_VERSION) {
@ -1769,32 +1772,42 @@ readgame(const char * filename, int mode, int backup)
store->close(store);
/* Unaufgeloeste Zeiger initialisieren */
log_info((1, "\n - Referenzen initialisieren...\n"));
log_info((1, "fixing unresolved references.\n"));
resolve();
log_info((1, "updating area information for lighthouses.\n"));
for (r=regions;r;r=r->next) {
if (r->flags & RF_LIGHTHOUSE) {
building * b;
for (b=r->buildings;b;b=b->next) update_lighthouse(b);
}
}
log_info((1, " - Regionen initialisieren & verbinden...\n"));
log_info((1, "marking factions as alive.\n"));
for (f = factions; f; f = f->next) {
for (u = f->units; u; u = u->nextF) {
if (u->number>0) {
f->alive = 1;
break;
if (f->flags & FFL_NPC) {
f->alive = 1;
if (f->no==0) {
int no=666;
while (findfaction(no)) ++no;
log_warning(("renum(monsters, %d)\n", no));
renumber_faction(f, no);
}
} else {
for (u = f->units; u; u = u->nextF) {
if (u->number>0) {
f->alive = 1;
break;
}
}
}
}
if (findfaction(0)) {
findfaction(0)->alive = 1;
}
if (loadplane || maxregions>=0) {
remove_empty_factions(false);
}
log_info((1, "Done loading turn %d.\n", turn));
return 0;
}
int
writegame(const char *filename, int mode)
{