* Mapper liest dropouts der letzten Runde ein

* Mapper besetzt mit 's' die dropouts automatisch mit age<=1 mit neuen Parteien.
* Mapper verhindert doppelte emails für newbies
* Parteiprefix wird auch an der Einheit angezeigt.
This commit is contained in:
Enno Rehling 2002-03-10 08:34:43 +00:00
parent 824b0818c3
commit b4196f0945
6 changed files with 92 additions and 11 deletions

View File

@ -552,7 +552,8 @@ cr_output_unit(FILE * F, const region * r,
const group * g = (const group*)a->data.v; const group * g = (const group*)a->data.v;
ap = a_find(g->attribs, &at_raceprefix); ap = a_find(g->attribs, &at_raceprefix);
fprintf(F, "%d;gruppe\n", g->gid); fprintf(F, "%d;gruppe\n", g->gid);
} else { }
if (ap==NULL) {
ap = a_find(u->faction->attribs, &at_raceprefix); ap = a_find(u->faction->attribs, &at_raceprefix);
} }
if (ap) { if (ap) {
@ -579,6 +580,9 @@ cr_output_unit(FILE * F, const region * r,
} }
if (a) { if (a) {
const attrib *agrp = a_find(((const group*)a->data.v)->attribs, &at_raceprefix); 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) { if (agrp) {
const char * name = (const char*)agrp->data.v; const char * name = (const char*)agrp->data.v;
fprintf(F, "\"%s\";typprefix\n", add_translation(name, LOC(f->locale, name))); 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))); fprintf(F, "\"%s\";Typ\n", add_translation(zRace, LOC(f->locale, zRace)));
} }
a = a_find(f->attribs, &at_raceprefix); a = a_find(f->attribs, &at_raceprefix);
if(a) { if (a) {
const char * name = (const char*)a->data.v; const char * name = (const char*)a->data.v;
fprintf(F, "\"%s\";typprefix\n", add_translation(name, LOC(f->locale, name))); fprintf(F, "\"%s\";typprefix\n", add_translation(name, LOC(f->locale, name)));
} }

View File

@ -2350,9 +2350,9 @@ remove_empty_factions(void)
faction **fp, *f3; faction **fp, *f3;
FILE *dofp; FILE *dofp;
char zText[MAX_PATH]; 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;) { for (fp = &factions; *fp;) {
faction * f = *fp; faction * f = *fp;
@ -2361,11 +2361,13 @@ remove_empty_factions(void)
* haben. */ * haben. */
if (f->alive == 0 && f->no != MONSTER_FACTION) { 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)); if (!quiet) printf("\t%s\n", factionname(f));
/* Einfach in eine Datei schreiben und später vermailen */ /* 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)); if (updatelog) fprintf(updatelog, "dropout %s\n", itoa36(f->no));
for (f3 = factions; f3; f3 = f3->next) { for (f3 = factions; f3; f3 = f3->next) {

View File

@ -1060,9 +1060,6 @@ void changeblockchaos(void);
struct region *firstregion(struct faction * f); struct region *firstregion(struct faction * f);
struct region *lastregion(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 inituhash(void);
void uhash(struct unit * u); void uhash(struct unit * u);
void uunhash(struct unit * u); void uunhash(struct unit * u);

View File

@ -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; 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 void
read_newfactions(const char * filename) read_newfactions(const char * filename)
{ {
@ -235,6 +292,7 @@ NeuePartei(region * r)
strcpy(email, nf->email); strcpy(email, nf->email);
} else { } else {
int locale_nr; int locale_nr;
faction * f;
WINDOW *win = openwin(SX - 10, 12, "< Neue Partei einfügen >"); WINDOW *win = openwin(SX - 10, 12, "< Neue Partei einfügen >");
strcpy(buf, my_input(win, 2, 1, "EMail-Adresse (Leer->Ende): ", NULL)); strcpy(buf, my_input(win, 2, 1, "EMail-Adresse (Leer->Ende): ", NULL));
@ -244,6 +302,13 @@ NeuePartei(region * r)
} }
strcpy(email, buf); 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; y = 3;
q = 0; q = 0;

View File

@ -383,8 +383,11 @@ drawmap(boolean maponly) {
case -8: case -8:
addstr("Godcurse "); addstr("Godcurse ");
break; break;
case -9:
addstr("Anfänger ");
break;
default: default:
printw((NCURSES_CONST char*)"Partei %d ",hl); printw((NCURSES_CONST char*)"Partei %d ", hl);
} }
} }
switch(politkarte) { switch(politkarte) {
@ -435,6 +438,7 @@ drawmap(boolean maponly) {
(hl == -6 && fval(r, RF_MALLORN)) || (hl == -6 && fval(r, RF_MALLORN)) ||
(hl == -7 && fval(r, RF_CHAOTIC)) || (hl == -7 && fval(r, RF_CHAOTIC)) ||
(hl == -8 && is_cursed_internal(r->attribs, C_CURSED_BY_THE_GODS, 0)) || (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)) || (hl >= 0 && factionhere(r, hl)) ||
(x==tx && y1==ty)) (x==tx && y1==ty))
addch(rs | A_REVERSE); addch(rs | A_REVERSE);
@ -648,7 +652,7 @@ SetHighlight(void)
wmove(win, 1, 2); wmove(win, 1, 2);
wAddstr("Regionen mit P)artei, E)inheiten, B)urgen, S)chiffen,"); wAddstr("Regionen mit P)artei, E)inheiten, B)urgen, S)chiffen,");
wmove(win, 2, 2); 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); wrefresh(win);
c = tolower(getch()); c = tolower(getch());
switch (c) { switch (c) {
@ -677,6 +681,9 @@ SetHighlight(void)
case 'g': case 'g':
hl = -8; hl = -8;
break; break;
case 'a':
hl = -9;
break;
case 'n': case 'n':
default: default:
hl = -1; hl = -1;
@ -1022,6 +1029,9 @@ movearound(int rx, int ry) {
make_ocean_block(rx, ry); make_ocean_block(rx, ry);
ch = -9; ch = -9;
break; break;
case 's':
seed_dropouts();
break;
case 'S': case 'S':
if (modified) if (modified)
if (yes_no(0, "Daten abspeichern?", 'j')) { if (yes_no(0, "Daten abspeichern?", 'j')) {
@ -1517,6 +1527,8 @@ main(int argc, char *argv[])
sprintf(buf, "%s/newfactions.%d", basepath(), turn); sprintf(buf, "%s/newfactions.%d", basepath(), turn);
read_newfactions(buf); read_newfactions(buf);
sprintf(buf, "%s/dropouts.%d", basepath(), turn);
read_dropouts(buf);
if (findfaction(MONSTER_FACTION)==NULL) { if (findfaction(MONSTER_FACTION)==NULL) {
makemonsters(); makemonsters();

View File

@ -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); void insert_selection(struct selection ** p_sel, struct selection * prev, char * str, void * payload);
extern void read_newfactions(const char * filename); 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)) #define sncat(b, s, size) strncat ((b), s, size - strlen (b))