forked from github/server
BUG 2436: Fix the E3 tactics bonus for ships.
This commit is contained in:
parent
5bcd8369af
commit
34c6222b8f
4 changed files with 17 additions and 9 deletions
|
@ -127,6 +127,7 @@ ship_type *st_get_or_create(const char * name) {
|
||||||
st = (ship_type *)calloc(sizeof(ship_type), 1);
|
st = (ship_type *)calloc(sizeof(ship_type), 1);
|
||||||
st->_name = str_strdup(name);
|
st->_name = str_strdup(name);
|
||||||
st->storm = 1.0;
|
st->storm = 1.0;
|
||||||
|
st->tac_bonus = 1.0;
|
||||||
st_register(st);
|
st_register(st);
|
||||||
}
|
}
|
||||||
return st;
|
return st;
|
||||||
|
|
|
@ -36,6 +36,8 @@ extern "C" {
|
||||||
#define SFL_NOCOAST 0x04
|
#define SFL_NOCOAST 0x04
|
||||||
#define SFL_SPEEDY 0x08
|
#define SFL_SPEEDY 0x08
|
||||||
|
|
||||||
|
#define SFL_DEFAULT 0
|
||||||
|
|
||||||
typedef struct ship_type {
|
typedef struct ship_type {
|
||||||
char *_name;
|
char *_name;
|
||||||
|
|
||||||
|
@ -57,7 +59,7 @@ extern "C" {
|
||||||
|
|
||||||
int at_bonus; /* Ver<65>ndert den Angriffsskill (default: 0) */
|
int at_bonus; /* Ver<65>ndert den Angriffsskill (default: 0) */
|
||||||
int df_bonus; /* Ver<65>ndert den Verteidigungskill (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 */
|
struct terrain_type ** coasts; /* coast that this ship can land on */
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,7 @@ static void test_stype_defaults(CuTest *tc) {
|
||||||
CuAssertPtrEquals(tc, 0, stype->coasts);
|
CuAssertPtrEquals(tc, 0, stype->coasts);
|
||||||
CuAssertDblEquals(tc, 0.0, stype->damage, 0.0);
|
CuAssertDblEquals(tc, 0.0, stype->damage, 0.0);
|
||||||
CuAssertDblEquals(tc, 1.0, stype->storm, 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->cabins);
|
||||||
CuAssertIntEquals(tc, 0, stype->cargo);
|
CuAssertIntEquals(tc, 0, stype->cargo);
|
||||||
CuAssertIntEquals(tc, 0, stype->combat);
|
CuAssertIntEquals(tc, 0, stype->combat);
|
||||||
|
|
|
@ -448,14 +448,19 @@ static int parse_ships(xmlDocPtr doc)
|
||||||
|
|
||||||
for (child = node->children; child; child = child->next) {
|
for (child = node->children; child; child = child->next) {
|
||||||
if (strcmp((const char *)child->name, "modifier") == 0) {
|
if (strcmp((const char *)child->name, "modifier") == 0) {
|
||||||
double value = xml_fvalue(child, "value", 0.0);
|
|
||||||
propValue = xmlGetProp(child, BAD_CAST "type");
|
propValue = xmlGetProp(child, BAD_CAST "type");
|
||||||
if (strcmp((const char *)propValue, "tactics") == 0)
|
if (strcmp((const char *)propValue, "tactics") == 0) {
|
||||||
st->tac_bonus = (float)value;
|
st->tac_bonus = xml_fvalue(child, "factor", 1.0);
|
||||||
else if (strcmp((const char *)propValue, "attack") == 0)
|
}
|
||||||
st->at_bonus = (int)value;
|
else {
|
||||||
else if (strcmp((const char *)propValue, "defense") == 0)
|
int value = xml_ivalue(child, "value", 0);
|
||||||
st->df_bonus = (int)value;
|
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);
|
xmlFree(propValue);
|
||||||
}
|
}
|
||||||
else if (strcmp((const char *)child->name, "construction") == 0) {
|
else if (strcmp((const char *)child->name, "construction") == 0) {
|
||||||
|
|
Loading…
Reference in a new issue