reduce struct person by 12 bytes on a 32-bit arch.

This commit is contained in:
Enno Rehling 2019-11-17 19:55:41 +01:00
parent 7850e84cea
commit 75000f2663
6 changed files with 17 additions and 27 deletions

View File

@ -104,8 +104,6 @@ const troop no_troop = { 0, 0 };
#define LOOT_KEEPLOOT (1<<4)
#define DAMAGE_CRITICAL (1<<0)
#define DAMAGE_MELEE_BONUS (1<<1)
#define DAMAGE_MISSILE_BONUS (1<<2) /* deprecated */
#define DAMAGE_SKILL_BONUS (1<<4)
static int max_turns;
@ -117,7 +115,7 @@ static int flee_chance_skill_bonus;
static int skill_formula;
static int rule_cavalry_skill;
static int rule_population_damage;
static int rule_hero_speed;
static unsigned char rule_hero_speed;
static bool rule_anon_battle;
static bool rule_igjarjuk_curse;
static int rule_goblin_bonus;
@ -139,7 +137,7 @@ static void init_rules(void)
rule_nat_armor = config_get_int("rules.combat.nat_armor", 0);
rule_tactics_formula = config_get_int("rules.tactics.formula", 0);
rule_goblin_bonus = config_get_int("rules.combat.goblinbonus", 10);
rule_hero_speed = config_get_int("rules.combat.herospeed", 10);
rule_hero_speed = (unsigned char)config_get_int("rules.combat.herospeed", 10);
rule_population_damage = config_get_int("rules.combat.populationdamage", 20);
rule_anon_battle = config_get_int("rules.stealth.anon_battle", 1) != 0;
rule_igjarjuk_curse = config_get_int("rules.combat.igjarjuk_curse", 0) != 0;
@ -157,12 +155,6 @@ static void init_rules(void)
if (config_get_int("rules.combat.critical", 1)) {
rule_damage |= DAMAGE_CRITICAL;
}
if (config_get_int("rules.combat.melee_bonus", 1)) {
rule_damage |= DAMAGE_MELEE_BONUS;
}
if (config_get_int("rules.combat.missile_bonus", 1)) { /* deprecated */
rule_damage |= DAMAGE_MISSILE_BONUS;
}
if (config_get_int("rules.combat.skill_bonus", 1)) {
rule_damage |= DAMAGE_SKILL_BONUS;
}
@ -1304,10 +1296,8 @@ terminate(troop dt, troop at, int type, const char *damage_formula, bool missile
if (awtype == NULL || !fval(awtype, WTF_MISSILE)) {
/* melee bonus */
if (rule_damage & DAMAGE_MELEE_BONUS) {
damage += af->person[at.index].damage;
}
}
/* Skilldifferenzbonus */
if (rule_damage & DAMAGE_SKILL_BONUS) {
@ -3158,7 +3148,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
fig->person[i].hp++;
if (i < speeded)
fig->person[i].speed = speed;
fig->person[i].speed = (unsigned char) speed;
else
fig->person[i].speed = 1;

View File

@ -81,9 +81,9 @@ extern "C" {
int nsides;
struct selist *meffects;
int max_tactics;
int turn;
unsigned char turn;
signed char keeploot; /* keep (50 + keeploot) percent of items as loot */
bool has_tactics_turn;
int keeploot;
bool reelarrow;
int alive;
struct {
@ -153,13 +153,13 @@ extern "C" {
int catmsg; /* Merkt sich, ob Katapultmessage schon generiert. */
struct person {
int hp; /* Trefferpunkte der Personen */
int attack;
int defense;
int damage;
int flags;
int speed;
int reload;
int last_action;
int attack; /* weapon skill bonus for attacker */
int defense; /* weapon skill bonus for defender */
char damage; /* bonus damage for melee attacks (e.g. troll belt) */
unsigned char speed;
unsigned char reload;
unsigned char last_action;
struct weapon *missile; /* missile weapon */
struct weapon *melee; /* melee weapon */
} *person;

View File

@ -280,7 +280,7 @@ static void handle_weapon(parseinfo *pi, const XML_Char *el, const XML_Char **at
wtype->defmod = xml_int(attr[i + 1]);
}
else if (xml_strequal(attr[i], "reload")) {
wtype->reload = xml_int(attr[i + 1]);
wtype->reload = (unsigned char) xml_int(attr[i + 1]);
}
else if (xml_strequal(attr[i], "skill")) {
wtype->skill = findskill(attr[i + 1]);

View File

@ -260,7 +260,7 @@ luxury_type *new_luxurytype(item_type * itype, int price)
weapon_type *new_weapontype(item_type * itype,
int wflags, variant magres, const char *damage[], int offmod, int defmod,
int reload, skill_t sk)
unsigned char reload, skill_t sk)
{
weapon_type *wtype;

View File

@ -169,7 +169,7 @@ extern "C" {
int offmod;
int defmod;
variant magres;
int reload; /* time to reload this weapon */
unsigned char reload; /* time to reload this weapon */
weapon_mod *modifiers;
/* --- functions --- */
bool(*attack) (const struct troop *, const struct weapon_type *,
@ -208,7 +208,7 @@ extern "C" {
item_type *it_get_or_create(resource_type *rtype);
luxury_type *new_luxurytype(item_type * itype, int price);
weapon_type *new_weapontype(item_type * itype, int wflags,
variant magres, const char *damage[], int offmod, int defmod, int reload,
variant magres, const char *damage[], int offmod, int defmod, unsigned char reload,
skill_t sk);
void free_wtype(struct weapon_type *wtype);
armor_type *new_armortype(item_type * itype, double penalty,

View File

@ -1378,7 +1378,7 @@ int sp_keeploot(struct castorder * co)
message_all(b, m);
msg_release(m);
b->keeploot = (int)fmax(25, b->keeploot + 5 * power);
b->keeploot = (signed char) fmax(25, b->keeploot + 5 * power);
return level;
}