remove dead code, move weight(unit) to unit.c

This commit is contained in:
Enno Rehling 2014-12-25 19:40:40 +01:00
parent 901c70efd9
commit 4e94a95835
5 changed files with 43 additions and 92 deletions

View File

@ -444,42 +444,6 @@ FILE *debug;
/* ----------------------------------------------------------------------- */
void verify_data(void)
{
#ifndef NDEBUG
int lf = -1;
faction *f;
unit *u;
int mage, alchemist;
if (verbosity >= 1)
puts(" - checking data for correctness...");
for (f = factions; f; f = f->next) {
mage = 0;
alchemist = 0;
for (u = f->units; u; u = u->nextF) {
if (eff_skill(u, SK_MAGIC, u->region)) {
mage += u->number;
}
if (eff_skill(u, SK_ALCHEMY, u->region))
alchemist += u->number;
if (u->number > UNIT_MAXSIZE) {
if (lf != f->no) {
lf = f->no;
log_printf(stdout, "Partei %s:\n", factionid(f));
}
log_warning("Einheit %s hat %d Personen\n", unitid(u), u->number);
}
}
if (f->no != 0 && ((mage > 3 && f->race != get_race(RC_ELF)) || mage > 4))
log_error("Partei %s hat %d Magier.\n", factionid(f), mage);
if (alchemist > 3)
log_error("Partei %s hat %d Alchemisten.\n", factionid(f), alchemist);
}
#endif
}
int distribute(int old, int new_value, int n)
{
int i;
@ -497,23 +461,6 @@ int distribute(int old, int new_value, int n)
return t;
}
int change_hitpoints(unit * u, int value)
{
int hp = u->hp;
hp += value;
/* Jede Person benötigt mindestens 1 HP */
if (hp < u->number) {
if (hp < 0) { /* Einheit tot */
hp = 0;
}
scale_number(u, hp);
}
u->hp = hp;
return hp;
}
bool unit_has_cursed_item(const unit * u)
{
item *itm = u->items;
@ -1313,31 +1260,6 @@ bool faction_id_is_unused(int id)
return findfaction(id) == NULL;
}
int weight(const unit * u)
{
int w = 0, n = 0, in_bag = 0;
const resource_type *rtype = get_resourcetype(R_BAG_OF_HOLDING);
item *itm;
for (itm = u->items; itm; itm = itm->next) {
w = itm->type->weight * itm->number;
n += w;
if (rtype && !fval(itm->type, ITF_BIG)) {
in_bag += w;
}
}
n += u->number * u_race(u)->weight;
if (rtype) {
w = i_get(u->items, rtype->itype) * BAGCAPACITY;
if (w > in_bag) w = in_bag;
n -= w;
}
return n;
}
unsigned int guard_flags(const unit * u)
{
unsigned int flags =

View File

@ -180,20 +180,6 @@ extern "C" {
bool has_limited_skills(const struct unit *u);
const struct race *findrace(const char *, const struct locale *);
int ispresent(const struct faction *f, const struct region *r);
int check_option(struct faction *f, int option);
/* Anzahl Personen in einer Einheit festlegen. NUR (!) mit dieser Routine,
* sonst großes Unglück. Durch asserts an ein paar Stellen abgesichert. */
void verify_data(void);
int change_hitpoints(struct unit *u, int value);
int weight(const struct unit *u);
void changeblockchaos(void);
bool idle(struct faction *f);
bool unit_has_cursed_item(const struct unit *u);

View File

@ -67,6 +67,31 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define FIND_FOREIGN_TEMP
int weight(const unit * u)
{
int w = 0, n = 0, in_bag = 0;
const resource_type *rtype = get_resourcetype(R_BAG_OF_HOLDING);
item *itm;
for (itm = u->items; itm; itm = itm->next) {
w = itm->type->weight * itm->number;
n += w;
if (rtype && !fval(itm->type, ITF_BIG)) {
in_bag += w;
}
}
n += u->number * u_race(u)->weight;
if (rtype) {
w = i_get(u->items, rtype->itype) * BAGCAPACITY;
if (w > in_bag) w = in_bag;
n -= w;
}
return n;
}
attrib_type at_creator = {
"creator"
/* Rest ist NULL; temporaeres, nicht alterndes Attribut */

View File

@ -125,6 +125,7 @@ extern "C" {
extern struct attrib_type at_showskchange;
int ualias(const struct unit *u);
int weight(const struct unit *u);
const struct race *u_irace(const struct unit *u);
const struct race *u_race(const struct unit *u);

View File

@ -2784,6 +2784,23 @@ static int sp_unholypower(castorder * co)
return cast_level;
}
static int change_hitpoints(unit * u, int value)
{
int hp = u->hp;
hp += value;
/* Jede Person benötigt mindestens 1 HP */
if (hp < u->number) {
if (hp < 0) { /* Einheit tot */
hp = 0;
}
scale_number(u, hp);
}
u->hp = hp;
return hp;
}
static int dc_age(struct curse *c)
/* age returns 0 if the attribute needs to be removed, !=0 otherwise */
{