parteipasswörter mit overrride für übergabe

This commit is contained in:
Enno Rehling 2002-03-03 12:53:05 +00:00
parent b1aadd3b92
commit 7e60d07eed
10 changed files with 72 additions and 30 deletions

View File

@ -1144,7 +1144,7 @@ quit(void)
for (u = r->units; u; u = u->next)
for (S = u->orders; S; S = S->next)
if (igetkeyword(S->s, u->faction->locale) == K_QUIT) {
if (strcasecmp(getstrtoken(), u->faction->passw) == 0) {
if (checkpasswd(u->faction, getstrtoken())) {
destroyfaction(u->faction);
} else {
cmistake(u, S->s, 86, MSG_EVENT);
@ -1185,7 +1185,7 @@ quit(void)
continue;
}
if (strcasecmp(s_pass, u->faction->passw)) {
if (!checkpasswd(u->faction, s_pass)) {
cmistake(u, S->s, 86, MSG_EVENT);
printf(" Warnung: NEUSTART mit falschem Passwort für Partei %s: %s\n",
factionid(u->faction), S->s);
@ -1206,9 +1206,24 @@ quit(void)
continue;
}
#endif
if (fval(f, FFL_OVERRIDE)) {
free(f->override);
f->override = strdup(itoa36(rand()));
}
if (turn!=f->lastorders) {
char info[256];
sprintf(info, "%d Einheiten, %d Personen, %d Silber",
f->nunits, f->number, f->money);
fprintf(sqlstream,
"UPDATE subscriptions SET lastturn=%d WHERE game=%d AND faction='%s';",
f->lastorders, GAME_ID, itoa36(f->no));
"UPDATE subscriptions SET lastturn=%d, password='%s', info='%s' "
"WHERE game=%d AND faction='%s';",
f->lastorders, f->override, info, GAME_ID, itoa36(f->no));
} else {
fprintf(sqlstream,
"UPDATE subscriptions SET lastturn=%d, password='%s' "
"WHERE game=%d AND faction='%s';",
f->lastorders, f->override, GAME_ID, itoa36(f->no));
}
if (turn - f->lastorders >= (NMRTIMEOUT - 1)) {
inactivefaction(f);
@ -2069,8 +2084,8 @@ set_passw(void)
}
}
set_string(&u->faction->passw, pbuf);
add_message(&u->faction->msgs, new_message(u->faction,
"changepasswd%s:value", gc_add(strdup(u->faction->passw))));
ADDMSG(&u->faction->msgs, msg_message("changepasswd",
"value", gc_add(strdup(u->faction->passw))));
}
break;

View File

@ -3467,7 +3467,8 @@ report_summary(summary * s, summary * o, boolean full)
out_faction(F, f);
}
if (full && NMRTIMEOUT) {
#if NMRTIMEOUT
if (full) {
fprintf(F, "\n\nFactions with NMRs:\n");
for (i = NMRTIMEOUT; i > 0; --i) {
for(f=factions; f; f=f->next) {
@ -3483,6 +3484,7 @@ report_summary(summary * s, summary * o, boolean full)
}
}
}
#endif
fclose(F);

View File

@ -470,6 +470,7 @@ stripfaction (faction * f)
free(f->email);
free(f->banner);
free(f->passw);
free(f->override);
free(f->name);
#ifndef FAST_REGION
vset_destroy(&f->regions);

View File

@ -153,13 +153,10 @@ struct xml_stack;
#define INTERIM_VERSION 309
#define NEWSKILL_VERSION 309
#define WATCHERS_VERSION 310
#define OVERRIDE_VERSION 311
#if SKILLPOINTS
# define RELEASE_VERSION INTERIM_VERSION
#else
# define RELEASE_VERSION WATCHERS_VERSION
#endif
#define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */
#define RELEASE_VERSION OVERRIDE_VERSION
/*
#if RELEASE_VERSION >= UGROUPS_VERSION
@ -890,10 +887,11 @@ extern int max_unique_id;
#define FL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
#define FL_TAKEALL (1<<25) /* Einheit nimmt alle Gegenstände an */
#define FL_UNNAMED (1<<26) /* Partei/Einheit/Gebäude/Schiff ist unbenannt */
#define FL_RESTARTED (1<<27) /* Partei hat schon einen Neustart gemacht */
/* no longer used, may contain old data! */
#define FFL_OVERRIDE (1<<27) /* Override-Passwort wurde benutzt */
/* Flags, die gespeichert werden sollen: */
#define FL_SAVEMASK (FL_NOAID | FL_RESTARTED | FL_OWNER | FL_PARTEITARNUNG | FL_LOCKED | FL_HUNGER | FL_NOIDLEOUT | FL_TAKEALL | FL_UNNAMED)
#define UFL_SAVEMASK (FL_NOAID | FL_OWNER | FL_PARTEITARNUNG | FL_LOCKED | FL_HUNGER | FL_NOIDLEOUT | FL_TAKEALL | FL_UNNAMED)
#define fval(u, i) ((u)->flags & (i))
#define fset(u, i) ((u)->flags |= (i))

View File

@ -93,6 +93,8 @@ addplayer(region *r, char *email, const struct race * frace, locale *loc)
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);
f->lastorders = turn;
f->alive = 1;
@ -130,3 +132,13 @@ addplayer(region *r, char *email, const struct race * frace, locale *loc)
return u;
}
boolean
checkpasswd(faction * f, const char * passwd)
{
if (strcasecmp(f->passw, passwd)==0) return true;
if (strcasecmp(f->override, passwd)==0) {
fset(f, FFL_OVERRIDE);
return true;
}
return false;
}

View File

@ -29,6 +29,7 @@ typedef struct faction {
char *banner;
char *email;
char *passw;
char *override;
struct locale * locale;
int lastorders; /* enno: short? */
int age; /* enno: short? */
@ -77,5 +78,6 @@ 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, char *email, const struct race * frace, struct locale *loc);
extern boolean checkpasswd(faction * f, const char * passwd);
#endif

View File

@ -444,9 +444,9 @@ readfaction(void)
f = findfaction(i36);
if (f==NULL || strcasecmp(f->passw, pass)) {
if (f==NULL || !checkpasswd(f, pass)) {
faction * f2 = findfaction(i10);
if (f2!=NULL && !strcasecmp(f2->passw, pass)) {
if (f2!=NULL && !checkpasswd(f2, pass)) {
f = f2;
addstrlist(&f->mistakes, "Die Befehle wurden nicht als base36 eingeschickt!");
}
@ -463,7 +463,7 @@ readfaction(void)
freestrlist(f->mistakes);
f->mistakes = 0;
if (strcasecmp(f->passw, pass)) {
if (!checkpasswd(f, pass)) {
addstrlist(&f->mistakes, "Das Passwort wurde falsch eingegeben");
return 0;
}
@ -915,6 +915,12 @@ readgame(boolean backup)
rds(F, &f->banner);
rds(F, &f->email);
rds(F, &f->passw);
if (global.data_version >= OVERRIDE_VERSION) {
rds(F, &f->override);
} else {
f->override = strdup(itoa36(rand()));
}
if (global.data_version < LOCALE_VERSION) {
f->locale = find_locale("de");
} else {
@ -948,6 +954,7 @@ readgame(boolean backup)
f->flags = ri(F);
else
f->flags = 0;
freset(f, FFL_OVERRIDE);
if (global.data_version>=FATTRIBS_VERSION)
a_read(F, &f->attribs);
@ -1858,6 +1865,9 @@ writegame(char *path, char quiet)
ws(F, f->banner);
ws(F, f->email);
ws(F, f->passw);
#if RELEASE_VERSION>=OVERRIDE_VERSION
ws(F, f->override);
#endif
#if RELEASE_VERSION>=LOCALE_VERSION
ws(F, locale_name(f->locale));
#endif
@ -2043,7 +2053,7 @@ writegame(char *path, char quiet)
else
wi(F, 0);
wi(F, u->status);
wi(F, u->flags & FL_SAVEMASK);
wi(F, u->flags & UFL_SAVEMASK);
#if RELEASE_VERSION < GUARDFIX_VERSION
wi(F, getguard(u));
#endif

View File

@ -332,15 +332,14 @@ tower_init(void)
static void
guardian_faction(plane * pl, int id)
{
unsigned int i;
region * r;
faction * f = findfaction(id);
if (!f) {
f = calloc(1, sizeof(faction));
f->banner = strdup("Sie dienen dem großen Wyrm");
f->passw = strdup(" ");
for (i = 0; i < 4; i++) f->passw[i] = (char) (97 + rand() % 26);
f->passw = strdup(itoa36(rand()));
f->override = strdup(itoa36(rand()));
f->email = strdup("igjarjuk@eressea-pbem.de");
f->name = strdup("Igjarjuks Kundschafter");
f->race = new_race[RC_ILLUSION];

View File

@ -618,6 +618,8 @@ gm_addquest(const char * email, const char * name, int radius, unsigned int flag
a_add(&f->attribs, make_key(atoi36("quest")));
f->banner = strdup("Questenpartei");
f->passw = strdup(itoa36(rand()));
f->override = strdup(itoa36(rand()));
f->override = strdup(itoa36(rand()));
f->email = strdup(email);
f->name = strdup("Questenpartei");
f->race = new_race[RC_TEMPLATE];

View File

@ -1389,6 +1389,7 @@ makemonsters(void)
f->unique_id = ++max_unique_id;
f->name=strdup("Monster");
f->passw=strdup("abc123");
f->override = strdup(itoa36(rand()));
fhash(f);
return f;
}