From 5f5b5e1f095819ead5bd61f98ccc634dce295eb8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 17 Mar 2002 12:31:54 +0000 Subject: [PATCH] Mapper ezigt jetzt an, was man ausgesetzt hat, bzw. wieviel noch zu tun ist. Highlighting von Dropout-Regionen. --- src/mapper/autoseed.c | 3 +++ src/mapper/map_partei.c | 47 +++++++++++++++++++++-------------------- src/mapper/map_region.c | 2 +- src/mapper/mapper.c | 47 +++++++++++++++++++++++++++++++++-------- src/mapper/mapper.h | 8 +++++++ 5 files changed, 74 insertions(+), 33 deletions(-) diff --git a/src/mapper/autoseed.c b/src/mapper/autoseed.c index 03a032b3a..580d46111 100644 --- a/src/mapper/autoseed.c +++ b/src/mapper/autoseed.c @@ -181,6 +181,8 @@ recalc(seed_t * seeds, int nseeds, int nplayers) return quality + q; } +extern int numnewbies; + void autoseed(struct regionlist * rlist) { @@ -252,6 +254,7 @@ autoseed(struct regionlist * rlist) newfaction ** nfp = &newfactions; while (*nfp!=nf) nfp=&(*nfp)->next; addplayer(seeds[i].region, nf->email, nf->race, nf->lang); + ++numnewbies; *nfp = nf->next; free(nf); } diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c index 8bdcdb257..454a52ddf 100644 --- a/src/mapper/map_partei.c +++ b/src/mapper/map_partei.c @@ -155,13 +155,7 @@ give_latestart_bonus(region *r, unit *u, int b) } } -typedef struct dropout { - struct dropout * next; - const struct race * race; - int x, y, fno; -} dropout; - -static dropout * dropouts; +dropout * dropouts = NULL; void read_orders(const char * filename) @@ -195,13 +189,16 @@ read_orders(const char * filename) ursprung * ur = f->ursprung; while (ur && ur->id!=0) ur=ur->next; if (ur) { - dropout * drop = calloc(sizeof(dropout), 1); - drop->x = ur->x; - drop->y = ur->y; - drop->fno = f->no; - drop->race = f->race; - drop->next = dropouts; - dropouts = drop; + region * r = findregion(ur->x, ur->y); + if (r) { + dropout * drop = calloc(sizeof(dropout), 1); + drop->x = ur->x; + drop->y = ur->y; + drop->fno = f->no; + drop->race = f->race; + drop->next = dropouts; + dropouts = drop; + } } } freset(f, FL_MARK); @@ -216,17 +213,19 @@ read_dropouts(const char * filename) 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); - if (drop->race==NULL) drop->race = findrace(race, default_locale); - drop->x = x; - drop->y = y; - drop->fno = -1; - drop->next = dropouts; - dropouts = drop; + region * r = findregion(x, y); + if (r) { + dropout * drop = calloc(sizeof(dropout), 1); + drop->race = rc_find(race); + if (drop->race==NULL) drop->race = findrace(race, default_locale); + drop->x = x; + drop->y = y; + drop->fno = -1; + drop->next = dropouts; + dropouts = drop; + } } } fclose(F); @@ -248,6 +247,7 @@ seed_dropouts(void) newfaction * nf = *nfp; if (nf->race==drop->race && !nf->bonus) { unit * u = addplayer(r, nf->email, nf->race, nf->lang); + ++numnewbies; if (nf->bonus) give_latestart_bonus(r, u, nf->bonus); found=true; *dropp = drop->next; @@ -447,6 +447,7 @@ NeuePartei(region * r) } modified = 1; u = addplayer(r, email, frace, lang); + ++numnewbies; if(late) give_latestart_bonus(r, u, late); diff --git a/src/mapper/map_region.c b/src/mapper/map_region.c index 77f7b4ba4..d28c494d3 100644 --- a/src/mapper/map_region.c +++ b/src/mapper/map_region.c @@ -48,7 +48,7 @@ incat(char *buf, const int n, const size_t bufsize) int rbottom; dbllist *reglist = NULL; static dbllist *runten = NULL, *roben = NULL; -#define LASTLINE SY-2 +#define LASTLINE SY-3 /* Letzte Zeile, in der Regionsinfo bei der Karte kommt */ diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 266bea6b0..ce32218e6 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -69,6 +69,7 @@ char datafile[256]; /* -------------------- resizeterm ------------------------------------- */ short Signals = 0; +int numnewbies = 0; unit *clipunit; struct ship *clipship; region *clipregion; @@ -342,6 +343,7 @@ readfactions(void) lang = find_locale(langname); assert(rc && r && lang); u = addplayer(r, email, rc, lang); + ++numnewbies; assert(u); i_change(&u->items, finditemtype("stein", german), 30); i_change(&u->items, finditemtype("holz", german), 30); @@ -362,6 +364,17 @@ newbie_region(region * r) return 0; } +int +dropout_region(region * r) +{ + dropout * drop = dropouts; + if (r!=NULL) while (drop) { + if (drop->x==r->x && drop->y==r->y) return 1; + drop=drop->next; + } + return 0; +} + void drawmap(boolean maponly) { int x, x1, y1, y2, s, q; @@ -370,12 +383,15 @@ drawmap(boolean maponly) { x1=left; y1=top; if(maponly == false) { + movexy(SX-36,SY-2); + sprintf(buf, "%d gesetzt, %d Rest, %d Dropouts", numnewbies, listlen(newfactions), listlen(dropouts)); + addstr(buf); movexy(SX-39, 0); vline(ACS_VLINE, SY+1); - movexy(SX-38, SY-2); + movexy(SX-38, SY-3); hline(ACS_HLINE, 39); if (hl != -1) { - movexy(SX-36,SY-2); + movexy(SX-36,SY-3); addstr(" High: "); switch (hl) { case -2: @@ -402,29 +418,32 @@ drawmap(boolean maponly) { case -9: addstr("Anfänger "); break; + case -10: + addstr("Dropouts "); + break; default: printw((NCURSES_CONST char*)"Partei %d ", hl); } } switch(politkarte) { case 0: - movexy(SX-14,SY-2); + movexy(SX-14,SY-3); addstr(" Geol.Karte "); break; case 1: - movexy(SX-14,SY-2); + movexy(SX-14,SY-3); addstr(" Politkarte "); break; case 2: - movexy(SX-14,SY-2); + movexy(SX-14,SY-3); addstr(" Handelskar "); break; case 3: - movexy(SX-14,SY-2); + movexy(SX-14,SY-3); addstr(" Botanik "); break; case 4: - movexy(SX-14,SY-2); + movexy(SX-14,SY-3); addstr(" Demand "); break; } @@ -455,6 +474,7 @@ drawmap(boolean maponly) { (hl == -7 && fval(r, RF_CHAOTIC)) || (hl == -8 && is_cursed_internal(r->attribs, C_CURSED_BY_THE_GODS, 0)) || (hl == -9 && newbie_region(r)) || + (hl == -10 && dropout_region(r)) || (hl >= 0 && factionhere(r, hl)) || (x==tx && y1==ty)) addch(rs | A_REVERSE); @@ -664,11 +684,13 @@ SetHighlight(void) WINDOW *win; char *fac_nr36; int c; - win = openwin(60, 5, "< Highlighting >"); + win = openwin(60, 6, "< Highlighting >"); wmove(win, 1, 2); wAddstr("Regionen mit P)artei, E)inheiten, B)urgen, S)chiffen,"); wmove(win, 2, 2); - wAddstr(" A)nfängern, L)aen, C)haos, G)odcurse oder N)ichts?"); + wAddstr(" A)nfängern, L)aen, C)haos, G)odcurse"); + wmove(win, 3, 2); + wAddstr(" D)ropouts oder N)ichts?"); wrefresh(win); c = tolower(getch()); switch (c) { @@ -700,6 +722,9 @@ SetHighlight(void) case 'a': hl = -9; break; + case 'd': + hl = -10; + break; case 'n': default: hl = -1; @@ -1447,6 +1472,7 @@ main(int argc, char *argv[]) { int x = 0, y = 0, i; char *s; + faction * f; boolean backup = true; boolean logging = false; boolean readlog = false; @@ -1560,6 +1586,9 @@ main(int argc, char *argv[]) sprintf(datafile, "%s/%d", datapath(), turn); readgame(backup); + for (f=factions;f;f=f->next) if (f->age==0) { + ++numnewbies; + } sprintf(buf, "%s/newfactions.%d", basepath(), turn); read_newfactions(buf); diff --git a/src/mapper/mapper.h b/src/mapper/mapper.h index 2b4426d5f..a86c05c7b 100644 --- a/src/mapper/mapper.h +++ b/src/mapper/mapper.h @@ -126,7 +126,15 @@ extern void read_newfactions(const char * filename); extern void read_orders(const char * filename); extern void read_dropouts(const char *filename); extern void seed_dropouts(void); +extern int numnewbies; #define sncat(b, s, size) strncat ((b), s, size - strlen (b)) +typedef struct dropout { + struct dropout * next; + const struct race * race; + int x, y, fno; +} dropout; + +extern dropout * dropouts; #endif /* MAPPER_H */