From 3b29df22e75267f6a544969b27b5b7f7680a75c2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 12 Jul 2004 21:10:16 +0000 Subject: [PATCH] - BENENNE FREMDE ohne das Flag - Neue Schiffe kriegen ihren Typ statt nur Schiff in den Namen --- src/common/gamecode/laws.c | 76 ++++++++++++++++++++++++++---------- src/common/kernel/build.c | 2 +- src/common/kernel/building.c | 1 - src/common/kernel/eressea.h | 1 - src/common/kernel/faction.c | 1 - src/common/kernel/names.c | 1 - src/common/kernel/race.c | 2 +- src/common/kernel/ship.c | 5 +-- src/common/kernel/ship.h | 2 +- src/common/kernel/unit.h | 2 +- src/common/modules/xecmd.c | 2 +- src/eressea/korrektur.c | 23 ----------- src/mapper/map_units.c | 1 - src/res/messages.xml | 8 ++-- 14 files changed, 66 insertions(+), 61 deletions(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 36a018564..000ce43b7 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -1587,11 +1587,19 @@ name_cmd(unit * u, struct order * ord) if (b->type == bt_find("generic")) { cmistake(u, ord, 278, MSG_EVENT); break; - } - - if(!fval(b,FL_UNNAMED)) { - cmistake(u, ord, 246, MSG_EVENT); - break; + } else { + const struct locale * lang = locales; + for (;lang;lang=nextlocale(lang)) { + const char * bdname = LOC(lang, b->type->_name); + size_t bdlen = strlen(bdname); + if (strlen(b->name)>=bdlen && strncmp(b->name, bdname, bdlen)==0) { + break; + } + } + if (lang==NULL) { + cmistake(u, ord, 246, MSG_EVENT); + break; + } } uo = buildingowner(r, b); @@ -1629,7 +1637,6 @@ name_cmd(unit * u, struct order * ord) break; } s = &u->building->name; - freset(u->building, FL_UNNAMED); } break; @@ -1645,10 +1652,19 @@ name_cmd(unit * u, struct order * ord) if (f->age < 10) { cmistake(u, ord, 248, MSG_EVENT); break; - } - if (!fval(f,FL_UNNAMED)) { - cmistake(u, ord, 247, MSG_EVENT); - break; + } else { + const struct locale * lang = locales; + for (;lang;lang=nextlocale(lang)) { + const char * fdname = LOC(lang, "factiondefault"); + size_t fdlen = strlen(fdname); + if (strlen(f->name)>=fdlen && strncmp(f->name, fdname, fdlen)==0) { + break; + } + } + if (lang==NULL) { + cmistake(u, ord, 247, MSG_EVENT); + break; + } } if (cansee(f, r, u, 0)) { add_message(&f->msgs, new_message(f, @@ -1660,7 +1676,6 @@ name_cmd(unit * u, struct order * ord) s = &f->name; } else { s = &u->faction->name; - freset(u->faction, FL_UNNAMED); } break; @@ -1672,10 +1687,26 @@ name_cmd(unit * u, struct order * ord) if (!sh) { cmistake(u, ord, 20, MSG_EVENT); break; - } - if (!fval(sh,FL_UNNAMED)) { - cmistake(u, ord, 245, MSG_EVENT); - break; + } else { + const struct locale * lang = locales; + for (;lang;lang=nextlocale(lang)) { + const char * sdname = LOC(lang, sh->type->name[0]); + size_t sdlen = strlen(sdname); + if (strlen(sh->name)>=sdlen && strncmp(sh->name, sdname, sdlen)==0) { + break; + } + + sdname = LOC(lang, parameters[P_SHIP]); + sdlen = strlen(sdname); + if (strlen(sh->name)>=sdlen && strncmp(sh->name, sdname, sdlen)==0) { + break; + } + + } + if (lang==NULL) { + cmistake(u, ord, 245, MSG_EVENT); + break; + } } uo = shipowner(sh); if (uo) { @@ -1698,20 +1729,24 @@ name_cmd(unit * u, struct order * ord) break; } s = &u->ship->name; - freset(u->ship, FL_UNNAMED); } break; case P_UNIT: if (foreign == true) { unit *u2 = getunit(r, u->faction); + if (!u2 || !cansee(u->faction, r, u2, 0)) { cmistake(u, ord, 63, MSG_EVENT); break; - } - if (!fval(u,FL_UNNAMED)) { - cmistake(u, ord, 244, MSG_EVENT); - break; + } else { + const char * udefault = LOC(u2->faction->locale, "unitdefault"); + size_t udlen = strlen(udefault); + size_t unlen = strlen(u2->name); + if (unlen>=udlen && strncmp(u2->name, udefault, udlen)!=0) { + cmistake(u2, ord, 244, MSG_EVENT); + break; + } } if (cansee(u2->faction, r, u, 0)) { add_message(&u2->faction->msgs, new_message(u2->faction, @@ -1723,7 +1758,6 @@ name_cmd(unit * u, struct order * ord) s = &u2->name; } else { s = &u->name; - freset(u, FL_UNNAMED); } break; diff --git a/src/common/kernel/build.c b/src/common/kernel/build.c index 0a74ac4b1..58949f072 100644 --- a/src/common/kernel/build.c +++ b/src/common/kernel/build.c @@ -1005,7 +1005,7 @@ create_ship(region * r, unit * u, const struct ship_type * newtype, int want) if (want>0) want = min(want, msize); else want = msize; - sh = new_ship(newtype, r); + sh = new_ship(newtype, u->faction->locale, r); addlist(&r->ships, sh); diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index 84a1638ad..142df4fa0 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -451,7 +451,6 @@ new_building(const struct building_type * btype, region * r, const struct locale b->type = btype; set_string(&b->display, ""); - fset(b, FL_UNNAMED); b->region = r; addlist(&r->buildings, b); diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 944269325..b62226ff6 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -879,7 +879,6 @@ typedef struct strlist { #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_UNNAMED (1<<26) /* Partei/Einheit/Gebäude/Schiff ist unbenannt */ #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 0df00df95..a49487f5b 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -123,7 +123,6 @@ addfaction(const char *email, const char * password, sprintf(buf, "%s %s", LOC(loc, "factiondefault"), factionid(f)); set_string(&f->name, buf); - fset(f, FL_UNNAMED); addlist(&factions, f); diff --git a/src/common/kernel/names.c b/src/common/kernel/names.c index 13db592f5..d9ceaf52f 100644 --- a/src/common/kernel/names.c +++ b/src/common/kernel/names.c @@ -715,6 +715,5 @@ name_unit(unit *u) } else { sprintf(name, "%s %s", LOC(u->faction->locale, "unitdefault"), itoa36(u->no)); set_string(&u->name, name); - fset(u, FL_UNNAMED); } } diff --git a/src/common/kernel/race.c b/src/common/kernel/race.c index b438058b0..8ebd10b2c 100644 --- a/src/common/kernel/race.c +++ b/src/common/kernel/race.c @@ -274,7 +274,7 @@ give_starting_equipment(struct region *r, struct unit *u) break; case RC_AQUARIAN: { - ship *sh = new_ship(st_find("boat"), r); + ship *sh = new_ship(st_find("boat"), u->faction->locale, r); sh->size = sh->type->construction->maxsize; addlist(&r->ships, sh); u->ship = sh; diff --git a/src/common/kernel/ship.c b/src/common/kernel/ship.c index 6a914166b..eb40792d1 100644 --- a/src/common/kernel/ship.c +++ b/src/common/kernel/ship.c @@ -164,7 +164,7 @@ captain(ship *sh, region *r) ship * -new_ship(const ship_type * stype, region * r) +new_ship(const ship_type * stype, const struct locale * lang, region * r) { static char buffer[7 + IDSIZE + 1]; ship *sh = (ship *) calloc(1, sizeof(ship)); @@ -174,10 +174,9 @@ new_ship(const ship_type * stype, region * r) sh->type = stype; sh->region = r; - sprintf(buffer, "Schiff %s", shipid(sh)); + sprintf(buffer, "%s %s", LOC(lang, stype->name[0]), shipid(sh)); set_string(&sh->name, buffer); set_string(&sh->display, ""); - fset(sh, FL_UNNAMED); shash(sh); return sh; } diff --git a/src/common/kernel/ship.h b/src/common/kernel/ship.h index b713989b0..bad8029a1 100644 --- a/src/common/kernel/ship.h +++ b/src/common/kernel/ship.h @@ -85,7 +85,7 @@ extern struct unit *shipowner(const struct ship * sh); extern int shipcapacity(const struct ship * sh); extern void getshipweight(const struct ship * sh, int *weight, int *cabins); -extern ship *new_ship(const struct ship_type * stype, struct region * r); +extern ship *new_ship(const struct ship_type * stype, const struct locale * lang, struct region * r); extern const char *shipname(const struct ship * sh); extern struct ship *findship(int n); extern struct ship *findshipr(const struct region *r, int n); diff --git a/src/common/kernel/unit.h b/src/common/kernel/unit.h index 38b72c34e..937cdf0f5 100644 --- a/src/common/kernel/unit.h +++ b/src/common/kernel/unit.h @@ -55,7 +55,7 @@ au #define UFL_WERE (1<<28) /* Flags, die gespeichert werden sollen: */ -#define UFL_SAVEMASK (UFL_NOAID | UFL_OWNER | UFL_PARTEITARNUNG | UFL_LOCKED | UFL_HUNGER | FFL_NOIDLEOUT | UFL_TAKEALL | FL_UNNAMED) +#define UFL_SAVEMASK (UFL_NOAID | UFL_OWNER | UFL_PARTEITARNUNG | UFL_LOCKED | UFL_HUNGER | FFL_NOIDLEOUT | UFL_TAKEALL) typedef struct unit { struct unit *next; /* needs to be first entry, for region's unitlist */ diff --git a/src/common/modules/xecmd.c b/src/common/modules/xecmd.c index ec27d6778..f214508aa 100644 --- a/src/common/modules/xecmd.c +++ b/src/common/modules/xecmd.c @@ -79,7 +79,7 @@ xe_giveballon(unit *u, struct order *ord) return; } - sh = new_ship(st_find("balloon"),u2->region); + sh = new_ship(st_find("balloon"), u2->faction->locale, u2->region); sh->size = 5; set_string(&sh->name,"Xontormia-Ballon"); addlist(&u2->region->ships, sh); diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 0aadd97c5..46dcb7abb 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -310,28 +310,6 @@ show_newspells(void) } } -static int -fix_foreign(void) -{ - region * r; - for (r=regions;r;r=r->next) { - struct locale * lang; - for (lang=locales;lang;lang=nextlocale(lang)) { - const char * udefault = LOC(lang, "unitdefault"); - size_t udlen = strlen(udefault); - unit * u; - for (u=r->units;u;u=u->next) { - size_t unlen = strlen(u->name); - if (unlenname, udefault, udlen)==0) { - fset(u, FL_UNNAMED); - } - } - } - } - return 0; -} - extern plane * arena; static void @@ -833,7 +811,6 @@ update_gmquests(void) } do_once("et02", secondfaction(f)); } - do_once("renm", fix_foreign()); } #define TEST_LOCALES 0 diff --git a/src/mapper/map_units.c b/src/mapper/map_units.c index c12020fb9..d88c4693d 100644 --- a/src/mapper/map_units.c +++ b/src/mapper/map_units.c @@ -65,7 +65,6 @@ SpecialFunctionUnit(unit *u) set_string(&sh->name, "Ballon"); set_string(&sh->display, "Eine große leuchtendrote Werbeaufschrift " "für den Xontormia Express prangt auf einer Seite des Luftgefährts."); - freset(sh, FL_UNNAMED); sh->size = 5; leave(u->region, u); u->ship = sh; diff --git a/src/res/messages.xml b/src/res/messages.xml index 8888883f1..5da503ee4 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -3176,7 +3176,7 @@ - "$unit($unit) in $region($region): '$order($command)' - Schwimmer können keine Schiffe betreten." + "$unit($unit) in $region($region): '$order($command)' - Dieser Typ Einheit kann keine Schiffe betreten." "$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter ships." "$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter ships." @@ -3186,9 +3186,9 @@ - "$unit($unit) in $region($region): '$order($command)' - Schwimmer können keine Gebäude betreten." - "$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter a building." - "$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter a building." + "$unit($unit) in $region($region): '$order($command)' - Dieser Typ Einheit kann keine Gebäude betreten." + "$unit($unit) in $region($region): '$order($command)' - this type of unit cannot enter a building." + "$unit($unit) in $region($region): '$order($command)' - this type of unit cannot enter a building."