- Passwort in newfactions Datei wird übernommen für Server

This commit is contained in:
Enno Rehling 2002-04-16 07:17:36 +00:00
parent 373606a362
commit 8f24c104cb
7 changed files with 25 additions and 50 deletions

View File

@ -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;

View File

@ -82,7 +82,7 @@ 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;
@ -93,9 +93,12 @@ addplayer(region *r, const char *email, const struct race * frace, const locale
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);

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;