diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 014ec5bbb..0459c9b54 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2306,7 +2306,7 @@ display_item(faction *f, unit *u, const item_type * itype) } } ADDMSG(&f->msgs, msg_message("displayitem", "weight item description", - itype->weight/1000, itype->rtype, strdup(info))); + itype->weight, itype->rtype, strdup(info))); return true; } @@ -2354,7 +2354,7 @@ display_race(faction *f, unit *u, const race * rc) size -= rsize; bufp += rsize; - sprintf(filename, "showdata/%s", LOC(default_locale, name)); + sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(default_locale), LOC(default_locale, name)); fp = fopen(filename, "r"); if(fp) { while (fgets(t, NAMESIZE, fp) != NULL) { diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 6e45f58d6..4f98a9701 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -3674,6 +3674,33 @@ eval_building(struct opstack ** stack, const void * userdata) /* building -> str opush(stack, var); } +static void +eval_weight(struct opstack ** stack, const void * userdata) /* region -> string */ +{ + char buffer[32]; + const struct faction * f = (const struct faction *)userdata; + const struct locale * lang = f->locale; + int weight = opop_i(stack); + variant var; + + if (weight % SCALEWEIGHT == 0) { + if (weight==SCALEWEIGHT) { + sprintf(buffer, "1 %s", LOC(lang, "weight_unit")); + } else { + sprintf(buffer, "%u %s", weight/SCALEWEIGHT, LOC(lang, "weight_unit_p")); + } + } else { + if (weight==1) { + sprintf(buffer, "1 %s %u", LOC(lang, "weight_per"), SCALEWEIGHT); + } else { + sprintf(buffer, "%u %s %u", weight, LOC(lang, "weight_per_p"), SCALEWEIGHT); + } + } + + var.v = strcpy(balloc(strlen(buffer)+1), buffer); + opush(stack, var); +} + static void eval_resource(struct opstack ** stack, const void * userdata) { @@ -3787,6 +3814,7 @@ report_init(void) { add_function("alliance", &eval_alliance); add_function("region", &eval_region); + add_function("weight", &eval_weight); add_function("resource", &eval_resource); add_function("race", &eval_race); add_function("faction", &eval_faction);