- BENENNE FREMDE ohne das Flag

- Neue Schiffe kriegen ihren Typ statt nur Schiff in den Namen
This commit is contained in:
Enno Rehling 2004-07-12 21:10:16 +00:00
parent 88e61c08cf
commit 3b29df22e7
14 changed files with 66 additions and 61 deletions

View File

@ -1587,11 +1587,19 @@ name_cmd(unit * u, struct order * ord)
if (b->type == bt_find("generic")) { if (b->type == bt_find("generic")) {
cmistake(u, ord, 278, MSG_EVENT); cmistake(u, ord, 278, MSG_EVENT);
break; break;
} } else {
const struct locale * lang = locales;
if(!fval(b,FL_UNNAMED)) { for (;lang;lang=nextlocale(lang)) {
cmistake(u, ord, 246, MSG_EVENT); const char * bdname = LOC(lang, b->type->_name);
break; 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); uo = buildingowner(r, b);
@ -1629,7 +1637,6 @@ name_cmd(unit * u, struct order * ord)
break; break;
} }
s = &u->building->name; s = &u->building->name;
freset(u->building, FL_UNNAMED);
} }
break; break;
@ -1645,10 +1652,19 @@ name_cmd(unit * u, struct order * ord)
if (f->age < 10) { if (f->age < 10) {
cmistake(u, ord, 248, MSG_EVENT); cmistake(u, ord, 248, MSG_EVENT);
break; break;
} } else {
if (!fval(f,FL_UNNAMED)) { const struct locale * lang = locales;
cmistake(u, ord, 247, MSG_EVENT); for (;lang;lang=nextlocale(lang)) {
break; 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)) { if (cansee(f, r, u, 0)) {
add_message(&f->msgs, new_message(f, add_message(&f->msgs, new_message(f,
@ -1660,7 +1676,6 @@ name_cmd(unit * u, struct order * ord)
s = &f->name; s = &f->name;
} else { } else {
s = &u->faction->name; s = &u->faction->name;
freset(u->faction, FL_UNNAMED);
} }
break; break;
@ -1672,10 +1687,26 @@ name_cmd(unit * u, struct order * ord)
if (!sh) { if (!sh) {
cmistake(u, ord, 20, MSG_EVENT); cmistake(u, ord, 20, MSG_EVENT);
break; break;
} } else {
if (!fval(sh,FL_UNNAMED)) { const struct locale * lang = locales;
cmistake(u, ord, 245, MSG_EVENT); for (;lang;lang=nextlocale(lang)) {
break; 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); uo = shipowner(sh);
if (uo) { if (uo) {
@ -1698,20 +1729,24 @@ name_cmd(unit * u, struct order * ord)
break; break;
} }
s = &u->ship->name; s = &u->ship->name;
freset(u->ship, FL_UNNAMED);
} }
break; break;
case P_UNIT: case P_UNIT:
if (foreign == true) { if (foreign == true) {
unit *u2 = getunit(r, u->faction); unit *u2 = getunit(r, u->faction);
if (!u2 || !cansee(u->faction, r, u2, 0)) { if (!u2 || !cansee(u->faction, r, u2, 0)) {
cmistake(u, ord, 63, MSG_EVENT); cmistake(u, ord, 63, MSG_EVENT);
break; break;
} } else {
if (!fval(u,FL_UNNAMED)) { const char * udefault = LOC(u2->faction->locale, "unitdefault");
cmistake(u, ord, 244, MSG_EVENT); size_t udlen = strlen(udefault);
break; 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)) { if (cansee(u2->faction, r, u, 0)) {
add_message(&u2->faction->msgs, new_message(u2->faction, add_message(&u2->faction->msgs, new_message(u2->faction,
@ -1723,7 +1758,6 @@ name_cmd(unit * u, struct order * ord)
s = &u2->name; s = &u2->name;
} else { } else {
s = &u->name; s = &u->name;
freset(u, FL_UNNAMED);
} }
break; break;

View File

@ -1005,7 +1005,7 @@ create_ship(region * r, unit * u, const struct ship_type * newtype, int want)
if (want>0) want = min(want, msize); if (want>0) want = min(want, msize);
else want = msize; else want = msize;
sh = new_ship(newtype, r); sh = new_ship(newtype, u->faction->locale, r);
addlist(&r->ships, sh); addlist(&r->ships, sh);

View File

@ -451,7 +451,6 @@ new_building(const struct building_type * btype, region * r, const struct locale
b->type = btype; b->type = btype;
set_string(&b->display, ""); set_string(&b->display, "");
fset(b, FL_UNNAMED);
b->region = r; b->region = r;
addlist(&r->buildings, b); addlist(&r->buildings, b);

View File

@ -879,7 +879,6 @@ typedef struct strlist {
#define FL_MARK (1<<23) /* für markierende algorithmen, die das hinterher auch wieder #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?) */ 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 fval(u, i) ((u)->flags & (i))
#define fset(u, i) ((u)->flags |= (i)) #define fset(u, i) ((u)->flags |= (i))

View File

@ -123,7 +123,6 @@ addfaction(const char *email, const char * password,
sprintf(buf, "%s %s", LOC(loc, "factiondefault"), factionid(f)); sprintf(buf, "%s %s", LOC(loc, "factiondefault"), factionid(f));
set_string(&f->name, buf); set_string(&f->name, buf);
fset(f, FL_UNNAMED);
addlist(&factions, f); addlist(&factions, f);

View File

@ -715,6 +715,5 @@ name_unit(unit *u)
} else { } else {
sprintf(name, "%s %s", LOC(u->faction->locale, "unitdefault"), itoa36(u->no)); sprintf(name, "%s %s", LOC(u->faction->locale, "unitdefault"), itoa36(u->no));
set_string(&u->name, name); set_string(&u->name, name);
fset(u, FL_UNNAMED);
} }
} }

View File

@ -274,7 +274,7 @@ give_starting_equipment(struct region *r, struct unit *u)
break; break;
case RC_AQUARIAN: 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; sh->size = sh->type->construction->maxsize;
addlist(&r->ships, sh); addlist(&r->ships, sh);
u->ship = sh; u->ship = sh;

View File

@ -164,7 +164,7 @@ captain(ship *sh, region *r)
ship * 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]; static char buffer[7 + IDSIZE + 1];
ship *sh = (ship *) calloc(1, sizeof(ship)); ship *sh = (ship *) calloc(1, sizeof(ship));
@ -174,10 +174,9 @@ new_ship(const ship_type * stype, region * r)
sh->type = stype; sh->type = stype;
sh->region = r; 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->name, buffer);
set_string(&sh->display, ""); set_string(&sh->display, "");
fset(sh, FL_UNNAMED);
shash(sh); shash(sh);
return sh; return sh;
} }

View File

@ -85,7 +85,7 @@ extern struct unit *shipowner(const struct ship * sh);
extern int shipcapacity(const struct ship * sh); extern int shipcapacity(const struct ship * sh);
extern void getshipweight(const struct ship * sh, int *weight, int *cabins); 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 const char *shipname(const struct ship * sh);
extern struct ship *findship(int n); extern struct ship *findship(int n);
extern struct ship *findshipr(const struct region *r, int n); extern struct ship *findshipr(const struct region *r, int n);

View File

@ -55,7 +55,7 @@ au
#define UFL_WERE (1<<28) #define UFL_WERE (1<<28)
/* Flags, die gespeichert werden sollen: */ /* 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 { typedef struct unit {
struct unit *next; /* needs to be first entry, for region's unitlist */ struct unit *next; /* needs to be first entry, for region's unitlist */

View File

@ -79,7 +79,7 @@ xe_giveballon(unit *u, struct order *ord)
return; return;
} }
sh = new_ship(st_find("balloon"),u2->region); sh = new_ship(st_find("balloon"), u2->faction->locale, u2->region);
sh->size = 5; sh->size = 5;
set_string(&sh->name,"Xontormia-Ballon"); set_string(&sh->name,"Xontormia-Ballon");
addlist(&u2->region->ships, sh); addlist(&u2->region->ships, sh);

View File

@ -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 (unlen<udlen) continue;
if (strncmp(u->name, udefault, udlen)==0) {
fset(u, FL_UNNAMED);
}
}
}
}
return 0;
}
extern plane * arena; extern plane * arena;
static void static void
@ -833,7 +811,6 @@ update_gmquests(void)
} }
do_once("et02", secondfaction(f)); do_once("et02", secondfaction(f));
} }
do_once("renm", fix_foreign());
} }
#define TEST_LOCALES 0 #define TEST_LOCALES 0

View File

@ -65,7 +65,6 @@ SpecialFunctionUnit(unit *u)
set_string(&sh->name, "Ballon"); set_string(&sh->name, "Ballon");
set_string(&sh->display, "Eine große leuchtendrote Werbeaufschrift " set_string(&sh->display, "Eine große leuchtendrote Werbeaufschrift "
"für den Xontormia Express prangt auf einer Seite des Luftgefährts."); "für den Xontormia Express prangt auf einer Seite des Luftgefährts.");
freset(sh, FL_UNNAMED);
sh->size = 5; sh->size = 5;
leave(u->region, u); leave(u->region, u);
u->ship = sh; u->ship = sh;

View File

@ -3176,7 +3176,7 @@
<arg name="region" type="region"/> <arg name="region" type="region"/>
<arg name="command" type="order"/> <arg name="command" type="order"/>
</type> </type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Schwimmer können keine Schiffe betreten."</text> <text locale="de">"$unit($unit) in $region($region): '$order($command)' - Dieser Typ Einheit kann keine Schiffe betreten."</text>
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter ships."</text> <text locale="fr">"$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter ships."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter ships."</text> <text locale="en">"$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter ships."</text>
</message> </message>
@ -3186,9 +3186,9 @@
<arg name="region" type="region"/> <arg name="region" type="region"/>
<arg name="command" type="order"/> <arg name="command" type="order"/>
</type> </type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Schwimmer können keine Gebäude betreten."</text> <text locale="de">"$unit($unit) in $region($region): '$order($command)' - Dieser Typ Einheit kann keine Gebäude betreten."</text>
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter a building."</text> <text locale="fr">"$unit($unit) in $region($region): '$order($command)' - this type of unit cannot enter a building."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - Swimmers cannot enter a building."</text> <text locale="en">"$unit($unit) in $region($region): '$order($command)' - this type of unit cannot enter a building."</text>
</message> </message>
<message name="error231" section="errors"> <message name="error231" section="errors">
<type> <type>