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 LOOT_KEEPLOOT (1<<4)
#define DAMAGE_CRITICAL (1<<0) #define DAMAGE_CRITICAL (1<<0)
#define DAMAGE_MELEE_BONUS (1<<1)
#define DAMAGE_MISSILE_BONUS (1<<2) /* deprecated */
#define DAMAGE_SKILL_BONUS (1<<4) #define DAMAGE_SKILL_BONUS (1<<4)
static int max_turns; static int max_turns;
@ -117,7 +115,7 @@ static int flee_chance_skill_bonus;
static int skill_formula; static int skill_formula;
static int rule_cavalry_skill; static int rule_cavalry_skill;
static int rule_population_damage; static int rule_population_damage;
static int rule_hero_speed; static unsigned char rule_hero_speed;
static bool rule_anon_battle; static bool rule_anon_battle;
static bool rule_igjarjuk_curse; static bool rule_igjarjuk_curse;
static int rule_goblin_bonus; 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_nat_armor = config_get_int("rules.combat.nat_armor", 0);
rule_tactics_formula = config_get_int("rules.tactics.formula", 0); rule_tactics_formula = config_get_int("rules.tactics.formula", 0);
rule_goblin_bonus = config_get_int("rules.combat.goblinbonus", 10); 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_population_damage = config_get_int("rules.combat.populationdamage", 20);
rule_anon_battle = config_get_int("rules.stealth.anon_battle", 1) != 0; rule_anon_battle = config_get_int("rules.stealth.anon_battle", 1) != 0;
rule_igjarjuk_curse = config_get_int("rules.combat.igjarjuk_curse", 0) != 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)) { if (config_get_int("rules.combat.critical", 1)) {
rule_damage |= DAMAGE_CRITICAL; 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)) { if (config_get_int("rules.combat.skill_bonus", 1)) {
rule_damage |= DAMAGE_SKILL_BONUS; 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)) { if (awtype == NULL || !fval(awtype, WTF_MISSILE)) {
/* melee bonus */ /* melee bonus */
if (rule_damage & DAMAGE_MELEE_BONUS) {
damage += af->person[at.index].damage; damage += af->person[at.index].damage;
} }
}
/* Skilldifferenzbonus */ /* Skilldifferenzbonus */
if (rule_damage & DAMAGE_SKILL_BONUS) { 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++; fig->person[i].hp++;
if (i < speeded) if (i < speeded)
fig->person[i].speed = speed; fig->person[i].speed = (unsigned char) speed;
else else
fig->person[i].speed = 1; fig->person[i].speed = 1;

View File

@ -81,9 +81,9 @@ extern "C" {
int nsides; int nsides;
struct selist *meffects; struct selist *meffects;
int max_tactics; int max_tactics;
int turn; unsigned char turn;
signed char keeploot; /* keep (50 + keeploot) percent of items as loot */
bool has_tactics_turn; bool has_tactics_turn;
int keeploot;
bool reelarrow; bool reelarrow;
int alive; int alive;
struct { struct {
@ -153,13 +153,13 @@ extern "C" {
int catmsg; /* Merkt sich, ob Katapultmessage schon generiert. */ int catmsg; /* Merkt sich, ob Katapultmessage schon generiert. */
struct person { struct person {
int hp; /* Trefferpunkte der Personen */ int hp; /* Trefferpunkte der Personen */
int attack;
int defense;
int damage;
int flags; int flags;
int speed; int attack; /* weapon skill bonus for attacker */
int reload; int defense; /* weapon skill bonus for defender */
int last_action; 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 *missile; /* missile weapon */
struct weapon *melee; /* melee weapon */ struct weapon *melee; /* melee weapon */
} *person; } *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]); wtype->defmod = xml_int(attr[i + 1]);
} }
else if (xml_strequal(attr[i], "reload")) { 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")) { else if (xml_strequal(attr[i], "skill")) {
wtype->skill = findskill(attr[i + 1]); 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, weapon_type *new_weapontype(item_type * itype,
int wflags, variant magres, const char *damage[], int offmod, int defmod, 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; weapon_type *wtype;

View File

@ -169,7 +169,7 @@ extern "C" {
int offmod; int offmod;
int defmod; int defmod;
variant magres; variant magres;
int reload; /* time to reload this weapon */ unsigned char reload; /* time to reload this weapon */
weapon_mod *modifiers; weapon_mod *modifiers;
/* --- functions --- */ /* --- functions --- */
bool(*attack) (const struct troop *, const struct weapon_type *, bool(*attack) (const struct troop *, const struct weapon_type *,
@ -208,7 +208,7 @@ extern "C" {
item_type *it_get_or_create(resource_type *rtype); item_type *it_get_or_create(resource_type *rtype);
luxury_type *new_luxurytype(item_type * itype, int price); luxury_type *new_luxurytype(item_type * itype, int price);
weapon_type *new_weapontype(item_type * itype, int wflags, 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); skill_t sk);
void free_wtype(struct weapon_type *wtype); void free_wtype(struct weapon_type *wtype);
armor_type *new_armortype(item_type * itype, double penalty, 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); message_all(b, m);
msg_release(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; return level;
} }