From 7e60d07eedbc0b6004839d2d759e872e35a64aa1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 3 Mar 2002 12:53:05 +0000 Subject: [PATCH] =?UTF-8?q?parteipassw=C3=B6rter=20mit=20overrride=20f?= =?UTF-8?q?=C3=BCr=20=C3=BCbergabe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/gamecode/laws.c | 29 ++++++++++++++++++++++------- src/common/gamecode/report.c | 6 ++++-- src/common/kernel/eressea.c | 1 + src/common/kernel/eressea.h | 26 ++++++++++++-------------- src/common/kernel/faction.c | 12 ++++++++++++ src/common/kernel/faction.h | 2 ++ src/common/kernel/save.c | 18 ++++++++++++++---- src/common/modules/arena.c | 5 ++--- src/common/modules/gmcmd.c | 2 ++ src/mapper/mapper.c | 1 + 10 files changed, 72 insertions(+), 30 deletions(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 7f9e158bc..61a6d658f 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -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 - fprintf(sqlstream, - "UPDATE subscriptions SET lastturn=%d WHERE game=%d AND faction='%s';", - f->lastorders, GAME_ID, itoa36(f->no)); + 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, 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; diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index a398ca2b3..d27c73462 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -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,7 +3484,8 @@ report_summary(summary * s, summary * o, boolean full) } } } - +#endif + fclose(F); if (full) { diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 9d132cb51..763b88f0c 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -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); diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 840706248..74aa0b2f2 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -153,13 +153,10 @@ struct xml_stack; #define INTERIM_VERSION 309 #define NEWSKILL_VERSION 309 #define WATCHERS_VERSION 310 - -#if SKILLPOINTS -# define RELEASE_VERSION INTERIM_VERSION -#else -# define RELEASE_VERSION WATCHERS_VERSION -#endif +#define OVERRIDE_VERSION 311 + #define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */ +#define RELEASE_VERSION OVERRIDE_VERSION /* #if RELEASE_VERSION >= UGROUPS_VERSION @@ -882,18 +879,19 @@ extern int max_unique_id; #define MAX_UNIT_NR (36*36*36*36-1) #define MAX_CONTAINER_NR (36*36*36*36-1) -#define FL_NOAIDF (1<<21) /* Hilfsflag Kampf */ -#define FL_NOAID (1<<22) /* Einheit hat Noaid-Status */ +#define FL_NOAIDF (1<<21) /* Hilfsflag Kampf */ +#define FL_NOAID (1<<22) /* Einheit hat Noaid-Status */ #define FL_MARK (1<<23) /* für markierende algorithmen, die das hinterher auch wieder löschen müssen! (Ist dafür nicht eigentlich FL_DH gedacht?) */ -#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 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 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)) diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index 884a8e5d7..b99eb60cc 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -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; +} \ No newline at end of file diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index f41811764..958b7b31b 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -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 diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 867942087..c36402ca6 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -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 diff --git a/src/common/modules/arena.c b/src/common/modules/arena.c index 630421e1e..bf8ded194 100644 --- a/src/common/modules/arena.c +++ b/src/common/modules/arena.c @@ -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]; diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index a99ed79a3..28140d57e 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -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]; diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 1090b87d3..c6bd3ed6c 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -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; }