diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index cc2f9e36e..eb7c9e7e9 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -114,12 +114,6 @@ income(const unit * u) /* ------------------------------------------------------------- */ -const struct ship_type * -findshiptype(char *s, const locale * lang) -{ - const struct ship_type * i = st_find(s); - return i; -} /* ------------------------------------------------------------- */ static struct scramble { diff --git a/src/common/gamecode/economy.h b/src/common/gamecode/economy.h index 8b87a6e7f..6679190f6 100644 --- a/src/common/gamecode/economy.h +++ b/src/common/gamecode/economy.h @@ -52,8 +52,6 @@ extern int income(const struct unit * u); /* Wieviel Fremde eine Partei pro Woche aufnehmen kann */ #define MAXNEWBIES 5 -const struct ship_type * findshiptype(char *s, const struct locale * lang); - void scramble(void *v1, int n, size_t width); void economics(void); void produce(void); diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 2d9ca868c..fd2a618fd 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -224,6 +224,7 @@ restart(unit *u, const race * rc) strlist ** o=&u->orders; f->magiegebiet = u->faction->magiegebiet; + fset(f, FL_RESTARTED); f->options = u->faction->options; freestrlist(nu->orders); nu->orders = u->orders; @@ -1072,10 +1073,16 @@ quit(void) cmistake(u, S->s, 242, MSG_EVENT); continue; } - if (u->faction->age < 100) { + if (fval(u->faction, FL_RESTARTED)) { + /* schon einmal neustart gemacht */ + return; + } + frace = findrace(getstrtoken(), u->faction->locale); + if (!frace && u->faction->age < 100) { frace = u->faction->race; - } else { - frace = findrace(getstrtoken(), u->faction->locale); + } else if (frace == NULL || !playerrace(frace)) { + cmistake(u, S->s, 243, MSG_EVENT); + continue; } if (frace == NULL || !playerrace(frace)) { diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index 47f87a51a..2319d3051 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -21,7 +21,6 @@ #include "curse.h" /* für C_NOCOST */ #include "unit.h" #include "region.h" -#include "language.h" #include "skill.h" #include "save.h" @@ -29,6 +28,7 @@ #include #include #include +#include /* libc includes */ #include diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 93e679b0b..86fbc17a6 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -881,12 +881,13 @@ typedef struct skillvalue { #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 */ /* Flags, die gespeichert werden sollen: */ #ifdef NOAID -#define FL_SAVEMASK (FL_OWNER | FL_PARTEITARNUNG | FL_LOCKED | FL_HUNGER | FL_NOAID | FL_NOIDLEOUT | FL_TAKEALL | FL_UNNAMED) +#define FL_SAVEMASK (FL_NOAID | FL_RESTARTED | FL_OWNER | FL_PARTEITARNUNG | FL_LOCKED | FL_HUNGER | FL_NOIDLEOUT | FL_TAKEALL | FL_UNNAMED) #else -#define FL_SAVEMASK (FL_OWNER | FL_PARTEITARNUNG | FL_LOCKED | FL_HUNGER | FL_NOIDLEOUT | FL_TAKEALL | FL_UNNAMED) +#define FL_SAVEMASK (FL_RESTARTED | FL_OWNER | FL_PARTEITARNUNG | FL_LOCKED | FL_HUNGER | FL_NOIDLEOUT | FL_TAKEALL | FL_UNNAMED) #endif #define fval(u, i) ((u)->flags & (i)) diff --git a/src/common/kernel/ship.c b/src/common/kernel/ship.c index 59044f83d..4b84fe99e 100644 --- a/src/common/kernel/ship.c +++ b/src/common/kernel/ship.c @@ -24,6 +24,7 @@ /* util includes */ #include #include +#include /* libc includes */ #include @@ -32,6 +33,34 @@ ship_typelist *shiptypes = NULL; +static local_names * snames; + +const ship_type * +findshiptype(const char * name, const locale * lang) +{ + local_names * sn = snames; + void * i; + + while (sn) { + if (sn->lang==lang) break; + sn=sn->next; + } + if (!sn) { + struct ship_typelist * stl = shiptypes; + sn = calloc(sizeof(local_names), 1); + sn->next = snames; + sn->lang = lang; + while (stl) { + const char * n = locale_string(lang, stl->type->name[0]); + addtoken(&sn->names, n, (void*)stl->type); + stl=stl->next; + } + snames = sn; + } + if (findtoken(&sn->names, name, &i)==E_TOK_NOMATCH) return NULL; + return (const ship_type*)i; +} + const ship_type * st_find(const char* name) { diff --git a/src/common/kernel/ship.h b/src/common/kernel/ship.h index 4870f3049..67d1152ee 100644 --- a/src/common/kernel/ship.h +++ b/src/common/kernel/ship.h @@ -92,4 +92,7 @@ extern struct unit *shipowner(const struct region * r, const struct ship * sh); extern ship *new_ship(const struct ship_type * stype, struct region * r); extern const char *shipname(const struct ship * sh); extern ship *findship(int n); + +extern const struct ship_type * findshiptype(const char *s, const struct locale * lang); + #endif