BUG 2436: Fix the E3 tactics bonus for ships.

This commit is contained in:
Enno Rehling 2018-05-03 22:44:01 +02:00
parent 5bcd8369af
commit 34c6222b8f
4 changed files with 17 additions and 9 deletions

View file

@ -127,6 +127,7 @@ ship_type *st_get_or_create(const char * name) {
st = (ship_type *)calloc(sizeof(ship_type), 1);
st->_name = str_strdup(name);
st->storm = 1.0;
st->tac_bonus = 1.0;
st_register(st);
}
return st;

View file

@ -36,6 +36,8 @@ extern "C" {
#define SFL_NOCOAST 0x04
#define SFL_SPEEDY 0x08
#define SFL_DEFAULT 0
typedef struct ship_type {
char *_name;
@ -57,7 +59,7 @@ extern "C" {
int at_bonus; /* Ver<65>ndert den Angriffsskill (default: 0) */
int df_bonus; /* Ver<65>ndert den Verteidigungskill (default: 0) */
float tac_bonus;
double tac_bonus;
struct terrain_type ** coasts; /* coast that this ship can land on */

View file

@ -369,7 +369,7 @@ static void test_stype_defaults(CuTest *tc) {
CuAssertPtrEquals(tc, 0, stype->coasts);
CuAssertDblEquals(tc, 0.0, stype->damage, 0.0);
CuAssertDblEquals(tc, 1.0, stype->storm, 0.0);
CuAssertDblEquals(tc, 0.0, stype->tac_bonus, 0.0);
CuAssertDblEquals(tc, 1.0, stype->tac_bonus, 0.01);
CuAssertIntEquals(tc, 0, stype->cabins);
CuAssertIntEquals(tc, 0, stype->cargo);
CuAssertIntEquals(tc, 0, stype->combat);

View file

@ -448,14 +448,19 @@ static int parse_ships(xmlDocPtr doc)
for (child = node->children; child; child = child->next) {
if (strcmp((const char *)child->name, "modifier") == 0) {
double value = xml_fvalue(child, "value", 0.0);
propValue = xmlGetProp(child, BAD_CAST "type");
if (strcmp((const char *)propValue, "tactics") == 0)
st->tac_bonus = (float)value;
else if (strcmp((const char *)propValue, "attack") == 0)
st->at_bonus = (int)value;
else if (strcmp((const char *)propValue, "defense") == 0)
st->df_bonus = (int)value;
if (strcmp((const char *)propValue, "tactics") == 0) {
st->tac_bonus = xml_fvalue(child, "factor", 1.0);
}
else {
int value = xml_ivalue(child, "value", 0);
if (strcmp((const char *)propValue, "attack") == 0) {
st->at_bonus = (int)value;
}
else if (strcmp((const char *)propValue, "defense") == 0) {
st->df_bonus = (int)value;
}
}
xmlFree(propValue);
}
else if (strcmp((const char *)child->name, "construction") == 0) {