diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index c5449d6c5..3549c1481 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -552,7 +552,8 @@ cr_output_unit(FILE * F, const region * r, const group * g = (const group*)a->data.v; ap = a_find(g->attribs, &at_raceprefix); fprintf(F, "%d;gruppe\n", g->gid); - } else { + } + if (ap==NULL) { ap = a_find(u->faction->attribs, &at_raceprefix); } if (ap) { @@ -579,6 +580,9 @@ cr_output_unit(FILE * F, const region * r, } if (a) { const attrib *agrp = a_find(((const group*)a->data.v)->attribs, &at_raceprefix); + if (agrp==NULL) { + agrp = a_find(u->faction->attribs, &at_raceprefix); + } if (agrp) { const char * name = (const char*)agrp->data.v; fprintf(F, "\"%s\";typprefix\n", add_translation(name, LOC(f->locale, name))); @@ -902,7 +906,7 @@ report_computer(FILE * F, faction * f, const seen_region * seen, fprintf(F, "\"%s\";Typ\n", add_translation(zRace, LOC(f->locale, zRace))); } a = a_find(f->attribs, &at_raceprefix); - if(a) { + if (a) { const char * name = (const char*)a->data.v; fprintf(F, "\"%s\";typprefix\n", add_translation(name, LOC(f->locale, name))); } diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index da4d7afdd..58395c9aa 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -2350,9 +2350,9 @@ remove_empty_factions(void) faction **fp, *f3; FILE *dofp; char zText[MAX_PATH]; - sprintf(zText, "%s/dropouts", basepath()); + sprintf(zText, "%s/dropouts.%d", basepath(), turn); - dofp = fopen(zText, "a"); + dofp = fopen(zText, "w"); for (fp = &factions; *fp;) { faction * f = *fp; @@ -2361,11 +2361,13 @@ remove_empty_factions(void) * haben. */ if (f->alive == 0 && f->no != MONSTER_FACTION) { + ursprung * ur = f->ursprung; + while (ur && ur->id!=0) ur=ur->next; if (!quiet) printf("\t%s\n", factionname(f)); /* Einfach in eine Datei schreiben und später vermailen */ - fprintf(dofp, "%s\n", f->email); + fprintf(dofp, "%s %s %d %d %d\n", f->email, rc_name(f->race, 0), f->age, ur?ur->x:0, ur?ur->y:0); if (updatelog) fprintf(updatelog, "dropout %s\n", itoa36(f->no)); for (f3 = factions; f3; f3 = f3->next) { diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 74aa0b2f2..af8cc300a 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -1060,9 +1060,6 @@ void changeblockchaos(void); struct region *firstregion(struct faction * f); struct region *lastregion(struct faction * f); -#define f_koor_x(x) x-f->ursprung[0] -#define f_koor_y(y) y-f->ursprung[1] - void inituhash(void); void uhash(struct unit * u); void uunhash(struct unit * u); diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c index 007ee641d..fd052e7a4 100644 --- a/src/mapper/map_partei.c +++ b/src/mapper/map_partei.c @@ -150,8 +150,65 @@ give_latestart_bonus(region *r, unit *u, int b) } } +typedef struct dropout { + struct dropout * next; + const struct race * race; + int x, y; +} dropout; + +static dropout * dropouts; static newfaction * newfactions; +void +read_dropouts(const char * filename) +{ + FILE * F = fopen(filename, "r"); + if (F==NULL) return; + for (;;) { + char email[64], race[20]; + int age, x, y; + dropout * drop; + if (fscanf(F, "%s %s %d %d %d", email, race, &age, &x, &y)<=0) break; + if (age<=1) { + drop = calloc(sizeof(dropout), 1); + drop->race = rc_find(race); + drop->x = x; + drop->y = y; + drop->next = dropouts; + dropouts = drop; + } + } +} + +void +seed_dropouts(void) +{ + dropout ** dropp = &dropouts; + while (*dropp) { + dropout *drop = *dropp; + region * r = findregion(drop->x, drop->y); + if (r && r->units==NULL) { + boolean found = false; + newfaction **nfp = &newfactions; + while (*nfp) { + newfaction * nf = *nfp; + if (nf->race==drop->race) { + unit * u = addplayer(r, nf->email, nf->race, nf->lang); + if (nf->bonus) give_latestart_bonus(r, u, nf->bonus); + *nfp = nf->next; + *dropp = drop->next; + found=true; + break; + } + nfp = &nf->next; + } + if (found) dropp=&drop->next; + } else { + *dropp = drop->next; + } + } +} + void read_newfactions(const char * filename) { @@ -235,6 +292,7 @@ NeuePartei(region * r) strcpy(email, nf->email); } else { int locale_nr; + faction * f; WINDOW *win = openwin(SX - 10, 12, "< Neue Partei einfügen >"); strcpy(buf, my_input(win, 2, 1, "EMail-Adresse (Leer->Ende): ", NULL)); @@ -244,6 +302,13 @@ NeuePartei(region * r) } strcpy(email, buf); + for (f=factions;f;f=f->next) { + if (strcmp(email, f->email)==0 && f->age==0) { + warnung(0, "Neue Partei mit dieser Adresse existiert bereits."); + delwin(win); + return; + } + } y = 3; q = 0; diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index f34b7fcab..54be379e0 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -383,8 +383,11 @@ drawmap(boolean maponly) { case -8: addstr("Godcurse "); break; + case -9: + addstr("Anfänger "); + break; default: - printw((NCURSES_CONST char*)"Partei %d ",hl); + printw((NCURSES_CONST char*)"Partei %d ", hl); } } switch(politkarte) { @@ -435,6 +438,7 @@ drawmap(boolean maponly) { (hl == -6 && fval(r, RF_MALLORN)) || (hl == -7 && fval(r, RF_CHAOTIC)) || (hl == -8 && is_cursed_internal(r->attribs, C_CURSED_BY_THE_GODS, 0)) || + (hl == -9 && r->units && r->units->faction->age==0) || (hl >= 0 && factionhere(r, hl)) || (x==tx && y1==ty)) addch(rs | A_REVERSE); @@ -648,7 +652,7 @@ SetHighlight(void) wmove(win, 1, 2); wAddstr("Regionen mit P)artei, E)inheiten, B)urgen, S)chiffen,"); wmove(win, 2, 2); - wAddstr(" L)aen, C)haos, G)odcurse oder N)icht Highlighten?"); + wAddstr(" A)nfängern, L)aen, C)haos, G)odcurse oder N)ichts?"); wrefresh(win); c = tolower(getch()); switch (c) { @@ -677,6 +681,9 @@ SetHighlight(void) case 'g': hl = -8; break; + case 'a': + hl = -9; + break; case 'n': default: hl = -1; @@ -1022,6 +1029,9 @@ movearound(int rx, int ry) { make_ocean_block(rx, ry); ch = -9; break; + case 's': + seed_dropouts(); + break; case 'S': if (modified) if (yes_no(0, "Daten abspeichern?", 'j')) { @@ -1517,6 +1527,8 @@ main(int argc, char *argv[]) sprintf(buf, "%s/newfactions.%d", basepath(), turn); read_newfactions(buf); + sprintf(buf, "%s/dropouts.%d", basepath(), turn); + read_dropouts(buf); if (findfaction(MONSTER_FACTION)==NULL) { makemonsters(); diff --git a/src/mapper/mapper.h b/src/mapper/mapper.h index 646412fed..22a9cbe8f 100644 --- a/src/mapper/mapper.h +++ b/src/mapper/mapper.h @@ -132,7 +132,8 @@ struct selection ** push_selection(struct selection ** p_sel, char * str, void * void insert_selection(struct selection ** p_sel, struct selection * prev, char * str, void * payload); extern void read_newfactions(const char * filename); - +extern void read_dropouts(const char *filename); +extern void seed_dropouts(); #define sncat(b, s, size) strncat ((b), s, size - strlen (b))