From 0b2938bbfc318cb3dd6ecf123ae5bb77cd24cf72 Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Fri, 13 Nov 2009 22:11:29 +0100 Subject: Put duplicated body weight calculations into actor::. --- crawl-ref/source/actor.cc | 28 ++++++++++++++++++++++++++++ crawl-ref/source/actor.h | 2 +- crawl-ref/source/monster.cc | 33 +-------------------------------- crawl-ref/source/player.cc | 33 +-------------------------------- 4 files changed, 31 insertions(+), 65 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/actor.cc b/crawl-ref/source/actor.cc index a9da27b6ad..3b3599b377 100644 --- a/crawl-ref/source/actor.cc +++ b/crawl-ref/source/actor.cc @@ -162,3 +162,31 @@ void actor::shield_block_succeeded(actor *foe) unrand_entry->fight_func.melee_effects(sh, this, foe, false); } } + +int actor::body_weight() const +{ + switch (body_size(PSIZE_BODY)) + { + case SIZE_TINY: + return (150); + case SIZE_LITTLE: + return (300); + case SIZE_SMALL: + return (425); + case SIZE_MEDIUM: + return (550); + case SIZE_LARGE: + return (1300); + case SIZE_BIG: + return (1500); + case SIZE_GIANT: + return (1800); + case SIZE_HUGE: + return (2200); + default: + mpr("ERROR: invalid body weight"); + perror("actor::body_weight(): invalid body weight"); + end(0); + return (0); + } +} diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h index 401b768d7f..ae0204aa6c 100644 --- a/crawl-ref/source/actor.h +++ b/crawl-ref/source/actor.h @@ -50,7 +50,7 @@ public: virtual size_type body_size(size_part_type psize = PSIZE_TORSO, bool base = false) const = 0; - virtual int body_weight() const = 0; + virtual int body_weight() const; virtual int total_weight() const = 0; virtual int damage_brand(int which_attack = -1) = 0; diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index 0781f1a4d3..459b9914d0 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -334,38 +334,7 @@ int monsters::body_weight() const // is sucked. Grrrr. if (weight == 0 && !mons_is_insubstantial(type)) { - const monsterentry *entry = get_monster_data(mclass); - switch (entry->size) - { - case SIZE_TINY: - weight = 150; - break; - case SIZE_LITTLE: - weight = 300; - break; - case SIZE_SMALL: - weight = 425; - break; - case SIZE_MEDIUM: - weight = 550; - break; - case SIZE_LARGE: - weight = 1300; - break; - case SIZE_BIG: - weight = 1500; - break; - case SIZE_GIANT: - weight = 1800; - break; - case SIZE_HUGE: - weight = 2200; - break; - default: - mpr("ERROR: invalid monster body weight"); - perror("monsters::body_weight(): invalid monster body weight"); - end(0); - } + weight = actor::body_weight(); switch (mclass) { diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 39b9f2242d..1deed6be73 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5590,38 +5590,7 @@ size_type player::body_size(size_part_type psize, bool base) const int player::body_weight() const { - int weight = 0; - switch (body_size(PSIZE_BODY)) - { - case SIZE_TINY: - weight = 150; - break; - case SIZE_LITTLE: - weight = 300; - break; - case SIZE_SMALL: - weight = 425; - break; - case SIZE_MEDIUM: - weight = 550; - break; - case SIZE_LARGE: - weight = 1300; - break; - case SIZE_BIG: - weight = 1500; - break; - case SIZE_GIANT: - weight = 1800; - break; - case SIZE_HUGE: - weight = 2200; - break; - default: - mpr("ERROR: invalid player body weight"); - perror("player::body_weight(): invalid player body weight"); - end(0); - } + int weight = actor::body_weight(); switch (attribute[ATTR_TRANSFORMATION]) { -- cgit v1.2.3-54-g00ecf