diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index e56abf570..988f4b59e 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -236,7 +236,7 @@ destroyfaction(faction * f) static void restart(unit *u, const race * rc) { - faction *f = addplayer(u->region, u->faction->email, rc, u->faction->locale)->faction; + faction *f = addplayer(u->region, u->faction->email, u->faction->passw, rc, u->faction->locale)->faction; unit * nu = f->units; strlist ** o=&u->orders; diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index b446da2b5..682246f4d 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -82,20 +82,23 @@ unused_faction_id(void) } unit * -addplayer(region *r, const char *email, const struct race * frace, const locale *loc) +addplayer(region *r, const char *email, const char * password, const struct race * frace, const locale *loc) { int i; unit *u; faction *f; - assert(frace != new_race[RC_ORC]); - f = calloc(sizeof(faction), 1); + assert(frace != new_race[RC_ORC]); + f = calloc(sizeof(faction), 1); - set_string(&f->email, email); - - for (i = 0; i < 6; i++) buf[i] = (char) (97 + rand() % 26); buf[i] = 0; - set_string(&f->passw, buf); + set_string(&f->email, email); + if (password) { + set_string(&f->passw, password); + } else { + for (i = 0; i < 6; i++) buf[i] = (char) (97 + rand() % 26); buf[i] = 0; + set_string(&f->passw, buf); + } for (i = 0; i < 6; i++) buf[i] = (char) (97 + rand() % 26); buf[i] = 0; set_string(&f->override, buf); diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index e443fed5a..5b44afc59 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -79,7 +79,7 @@ typedef struct faction_list { extern const struct unit * random_unit_in_faction(const struct faction *f); extern const char * factionname(const struct faction * f); extern void * resolve_faction(void * data); -extern struct unit * addplayer(struct region *r, const char *email, const struct race * frace, const struct locale *loc); +extern struct unit * addplayer(struct region *r, const char *email, const char* password, const struct race * frace, const struct locale *loc); extern boolean checkpasswd(const faction * f, const char * passwd); #endif diff --git a/src/mapper/autoseed.c b/src/mapper/autoseed.c index 40d289e8c..72b1dc027 100644 --- a/src/mapper/autoseed.c +++ b/src/mapper/autoseed.c @@ -254,8 +254,9 @@ autoseed(struct regionlist * rlist) newfaction * nf = seeds[i].player; if (nf) { newfaction ** nfp = &newfactions; + unit * u; while (*nfp!=nf) nfp=&(*nfp)->next; - addplayer(seeds[i].region, nf->email, nf->race, nf->lang); + u = addplayer(seeds[i].region, nf->email, nf->password, nf->race, nf->lang); ++numnewbies; *nfp = nf->next; free(nf); @@ -306,8 +307,9 @@ mkisland(int nsize) assert(r->terrain==T_OCEAN); if (rand() % REGIONS_PER_FACTION == 0) { newfaction ** nfp, * nextf = newfactions; + unit * u; terraform(r, preferred_terrain(nextf->race)); - addplayer(r, nextf->email, nextf->race, nextf->lang); + u = addplayer(r, nextf->email, nextf->password, nextf->race, nextf->lang); /* remove duplicate email addresses */ nfp=&newfactions; diff --git a/src/mapper/autoseed.h b/src/mapper/autoseed.h index 08fca949e..09136382d 100644 --- a/src/mapper/autoseed.h +++ b/src/mapper/autoseed.h @@ -18,7 +18,8 @@ struct newfaction; typedef struct newfaction { struct newfaction * next; - const char * email; + char * email; + char * password; const struct locale * lang; const struct race * race; int bonus; diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c index eb81e362f..829836807 100644 --- a/src/mapper/map_partei.c +++ b/src/mapper/map_partei.c @@ -282,7 +282,7 @@ seed_dropouts(void) if (u==NULL) while (*nfp) { newfaction * nf = *nfp; if (nf->race==drop->race && !nf->bonus) { - unit * u = addplayer(r, nf->email, nf->race, nf->lang); + unit * u = addplayer(r, nf->email, nf->password, nf->race, nf->lang); ++numnewbies; if (nf->bonus) give_latestart_bonus(r, u, nf->bonus); found=true; @@ -307,11 +307,11 @@ read_newfactions(const char * filename) if (F==NULL) return; for (;;) { faction * f = factions; - char race[20], email[64], lang[8]; + char race[20], email[64], lang[8], password[8]; newfaction *nf; int bonus; /* email;race;locale;startbonus */ - if (fscanf(F, "%s %s %s %d", email, race, lang, &bonus)<=0) break; + if (fscanf(F, "%s %s %s %d %s", email, race, lang, &bonus, password)<=0) break; while (f) { if (strcmp(f->email, email)==0 && f->age==0) { break; @@ -325,6 +325,7 @@ read_newfactions(const char * filename) if (nf) continue; nf = calloc(sizeof(newfaction), 1); nf->email = strdup(email); + nf->password = strdup(password); nf->race = rc_find(race); if (nf->race==NULL) nf->race = findrace(race, default_locale); nf->lang = find_locale(lang); @@ -373,6 +374,7 @@ NeuePartei(region * r) const struct race * frace; int late; unit *u; + const char * passwd = NULL; int locale_nr; faction * f; @@ -387,6 +389,7 @@ NeuePartei(region * r) frace = nf->race; late = nf->bonus; lang = nf->lang; + passwd = nf->password; strcpy(email, nf->email); if (late) { WINDOW *win = openwin(SX - 10, 3, "< Neue Partei einfügen >"); @@ -482,7 +485,7 @@ NeuePartei(region * r) else nfp = &nf->next; } modified = 1; - u = addplayer(r, email, frace, lang); + u = addplayer(r, email, passwd, frace, lang); ++numnewbies; if(late) give_latestart_bonus(r, u, late); diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index c58cc391e..f27467e08 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -322,37 +322,6 @@ crwritemap(void) return 0; } -static void -readfactions(void) -{ - FILE * F = fopen("factions.txt", "r"); - - locale * german = find_locale("de"); - while (!feof(F)) { - int x, y; - region * r; - unit * u; - const race * rc; - locale * lang; - char email[64]; - char racename[32]; - char langname[32]; - fscanf(F, "%d %d %s %s %s\n", &x, &y, langname, racename, email); - - rc = findrace(racename, german); - r = findregion(x, y); - 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); - } - fclose(F); - modified = 1; -} - int newbie_region(region * r) { @@ -838,9 +807,6 @@ movearound(int rx, int ry) { DisplayRegList(1); ch = 999999; break; - case 18: /* ctrl-r*/ - readfactions(); - break; case 23: /* ctrl-w*/ crwritemap(); break;