small fixes

This commit is contained in:
Enno Rehling 2006-10-29 14:03:56 +00:00
parent 4f182eb06b
commit 974747b4ad
3 changed files with 33 additions and 34 deletions

View file

@ -26,9 +26,9 @@ struct locale;
struct troop; struct troop;
typedef struct item { typedef struct item {
struct item * next;
const struct item_type * type; const struct item_type * type;
int number; int number;
struct item * next;
} item; } item;
typedef struct resource { typedef struct resource {

View file

@ -1073,24 +1073,23 @@ readunit(FILE * F)
} }
set_order(&u->thisorder, NULL); set_order(&u->thisorder, NULL);
assert(u->number <= UNIT_MAXSIZE); assert(u->race);
assert(u->race); if (global.data_version<NEWSKILL_VERSION) {
if (global.data_version<NEWSKILL_VERSION) { /* convert old data */
/* convert old data */
if (u->number) { if (u->number) {
while ((sk = (skill_t) ri(F)) != NOSKILL) { while ((sk = (skill_t) ri(F)) != NOSKILL) {
int days = ri(F) / u->number; int days = ri(F) / u->number;
int lvl = level(days); int lvl = level(days);
int weeks = lvl + 1 - (days - level_days(lvl))/30; int weeks = lvl + 1 - (days - level_days(lvl))/30;
assert(weeks>0 && weeks<=lvl+1); assert(weeks>0 && weeks<=lvl+1);
if (lvl) { if (lvl) {
skill * sv = add_skill(u, sk); skill * sv = add_skill(u, sk);
sv->level = sv->old = (unsigned char)lvl; sv->level = sv->old = (unsigned char)lvl;
sv->weeks = (unsigned char)weeks; sv->weeks = (unsigned char)weeks;
} }
} }
} }
} else { } else {
while ((sk = (skill_t) ri(F)) != NOSKILL) { while ((sk = (skill_t) ri(F)) != NOSKILL) {
int level = ri(F); int level = ri(F);
int weeks = ri(F); int weeks = ri(F);
@ -1190,26 +1189,25 @@ writeunit(FILE * F, const unit * u)
wnl(F); wnl(F);
#endif #endif
assert(u->number <= UNIT_MAXSIZE);
assert(u->race); assert(u->race);
for (i=0;i!=u->skill_size;++i) { for (i=0;i!=u->skill_size;++i) {
skill * sv = u->skills+i; skill * sv = u->skills+i;
assert(sv->weeks<=sv->level*2+1); assert(sv->weeks<=sv->level*2+1);
if (sv->level>0) { if (sv->level>0) {
wi(F, sv->id); wi(F, sv->id);
wi(F, sv->level); wi(F, sv->level);
wi(F, sv->weeks); wi(F, sv->weeks);
} }
} }
wi(F, -1); wi(F, -1);
wnl(F); wnl(F);
write_items(F, u->items); write_items(F, u->items);
wnl(F); wnl(F);
if (u->hp == 0) { if (u->hp == 0) {
log_error(("Einheit %s hat 0 Trefferpunkte\n", itoa36(u->no))); log_error(("Einheit %s hat 0 Trefferpunkte\n", itoa36(u->no)));
((unit*)u)->hp = 1; ((unit*)u)->hp = 1;
} }
wi(F, u->hp); wi(F, u->hp);
wnl(F); wnl(F);
a_write(F, u->attribs); a_write(F, u->attribs);

View file

@ -5524,6 +5524,7 @@
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>
<arg name="region" type="region"/> <arg name="region" type="region"/>
<arg name="command" type="order"/> <arg name="command" type="order"/>
<arg name="maxsize" type="int"/>
</type> </type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Einheiten dürfen nicht mehr als $int($maxsize) Personen enthalten."</text> <text locale="de">"$unit($unit) in $region($region): '$order($command)' - Einheiten dürfen nicht mehr als $int($maxsize) Personen enthalten."</text>
<text locale="fr">"$unit($unit) in $region($region): '$order($command)' - Units may not have more than $int($maxsize) members."</text> <text locale="fr">"$unit($unit) in $region($region): '$order($command)' - Units may not have more than $int($maxsize) members."</text>