From 34c6222b8f970b3edda4d616c34ee65ba4cdbf43 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 3 May 2018 22:44:01 +0200 Subject: [PATCH] BUG 2436: Fix the E3 tactics bonus for ships. --- src/kernel/ship.c | 1 + src/kernel/ship.h | 4 +++- src/kernel/ship.test.c | 2 +- src/xmlreader.c | 19 ++++++++++++------- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/kernel/ship.c b/src/kernel/ship.c index 08eefbd12..def6dd1fa 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -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; diff --git a/src/kernel/ship.h b/src/kernel/ship.h index 2ee1a6d3b..c726b4839 100644 --- a/src/kernel/ship.h +++ b/src/kernel/ship.h @@ -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�ndert den Angriffsskill (default: 0) */ int df_bonus; /* Ver�ndert den Verteidigungskill (default: 0) */ - float tac_bonus; + double tac_bonus; struct terrain_type ** coasts; /* coast that this ship can land on */ diff --git a/src/kernel/ship.test.c b/src/kernel/ship.test.c index aa4dc5755..074876dd5 100644 --- a/src/kernel/ship.test.c +++ b/src/kernel/ship.test.c @@ -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); diff --git a/src/xmlreader.c b/src/xmlreader.c index dfb3b54ea..2108d1841 100644 --- a/src/xmlreader.c +++ b/src/xmlreader.c @@ -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) {