This commit is contained in:
Enno Rehling 2016-11-20 14:50:49 +01:00
commit ae951ee780
23 changed files with 85 additions and 54 deletions

View File

@ -380,6 +380,21 @@ function test_events()
assert(fail==0)
end
function test_renumber_ship()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply4@eressea.de", "human", "de")
local u = unit.create(f, r)
local s = ship.create(r, config.ships[1])
u.ship = s
u:add_order("NUMMER SCHIFF 1")
process_orders()
assert_equal(1, s.id)
u:clear_orders()
u:add_order("NUMMER SCHIFF 2")
process_orders()
assert_equal(2, s.id)
end
function test_recruit2()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply4@eressea.de", "human", "de")

View File

@ -7,6 +7,7 @@ function setup()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.grow.formula", "0")
eressea.settings.set("rules.peasants.growth.factor", "0")
eressea.settings.set("volcano.active.percent", "0")
end
function test_snowglobe_fail()

View File

@ -17,10 +17,12 @@ set_source_files_properties(kernel/version.c PROPERTIES
COMPILE_DEFINITIONS ERESSEA_VERSION="${ERESSEA_VERSION}")
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
IF (CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
ENDIF()
IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
add_definitions(-DHAVE__BOOL)
ELSEIF(MSVC)

View File

@ -181,7 +181,7 @@ static int potion_power(unit *u, int amount) {
if (u->number % 10 > 0) ++use;
amount = use;
}
/* Verfünffacht die HP von max. 10 Personen in der Einheit */
/* Verf<EFBFBD>nffacht die HP von max. 10 Personen in der Einheit */
u->hp += _min(u->number, 10 * amount) * unit_max_hp(u) * 4;
return amount;
}
@ -241,8 +241,7 @@ static void init_potiondelay(attrib * a)
a->data.v = malloc(sizeof(potiondelay));
}
static void free_potiondelay(attrib * a)
{
static void free_potiondelay(attrib * a) {
free(a->data.v);
}

View File

@ -1022,16 +1022,15 @@ static int armor_bonus(const race *rc) {
int natural_armor(unit * du)
{
const race *rc = u_race(du);
int bonus, an = rc->armor;
int an;
assert(rc);
bonus = armor_bonus(rc);
if (bonus > 0) {
an = armor_bonus(rc);
if (an > 0) {
int sk = effskill(du, SK_STAMINA, 0);
sk /= bonus;
an += sk;
return rc->armor + sk / an;
}
return an;
return rc->armor;
}
static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_type *wtype)
@ -2042,19 +2041,12 @@ int hits(troop at, troop dt, weapon * awp)
void dazzle(battle * b, troop * td)
{
/* Nicht kumulativ ! */
if (td->fighter->person[td->index].flags & FL_DAZZLED)
return;
#ifdef TODO_RUNESWORD
if (td->fighter->weapon[WP_RUNESWORD].count > td->index) {
return;
}
#endif
if (td->fighter->person[td->index].flags & FL_COURAGE) {
return;
}
if (td->fighter->person[td->index].flags & FL_DAZZLED) {
if (td->fighter->person[td->index].flags & (FL_COURAGE|FL_DAZZLED)) {
return;
}
@ -2497,7 +2489,7 @@ static int loot_quota(const unit * src, const unit * dst,
{
if (dst && src && src->faction != dst->faction) {
double divisor = config_get_flt("rules.items.loot_divisor", 1);
assert(divisor == 0 || divisor >= 1);
assert(divisor <= 0 || divisor >= 1);
if (divisor >= 1) {
double r = n / divisor;
int x = (int)r;

View File

@ -211,7 +211,7 @@ border_type *find_bordertype(const char *name)
{
border_type *bt = bordertypes;
while (bt && strcmp(bt->__name, name))
while (bt && strcmp(bt->__name, name)!=0)
bt = bt->next;
return bt;
}
@ -620,7 +620,6 @@ int read_borders(gamedata *data)
assert(type || !"connection type not registered");
}
READ_INT(store, &bid);
if (data->version < UIDHASH_VERSION) {
int fx, fy, tx, ty;
@ -639,9 +638,7 @@ int read_borders(gamedata *data)
to = findregionbyid(tid);
}
if (!to || !from) {
if (!to || !from) {
log_error("%s connection %d has missing regions", zText, bid);
}
log_error("%s connection %d has missing regions", zText, bid);
if (type->read) {
// skip ahead
connection dummy;
@ -650,7 +647,7 @@ int read_borders(gamedata *data)
continue;
}
if (to == from && type && from) {
if (to == from && from) {
direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS);
region *r = rconnect(from, dir);
log_error("[read_borders] invalid %s in %s\n", type->__name, regionname(from, NULL));
@ -659,7 +656,7 @@ int read_borders(gamedata *data)
}
if (type->read) {
connection *b = new_border(type, from, to);
nextborder--; /* new_border erhöht den Wert */
nextborder--; /* new_border erh<EFBFBD>ht den Wert */
b->id = bid;
assert(bid <= nextborder);
type->read(b, data);

View File

@ -796,7 +796,7 @@ static void json_settings(cJSON *json) {
else {
char value[32];
if (child->type == cJSON_Number && child->valuedouble && child->valueint<child->valuedouble) {
_snprintf(value, sizeof(value), "%lf", child->valuedouble);
_snprintf(value, sizeof(value), "%f", child->valuedouble);
}
else {
_snprintf(value, sizeof(value), "%d", child->valueint);

View File

@ -74,4 +74,5 @@ CuSuite *get_messages_suite(void) {
SUITE_ADD_TEST(suite, test_merge_split);
SUITE_ADD_TEST(suite, test_message);
return suite;
}
}

View File

@ -297,10 +297,9 @@ int crew_skill(const ship *sh) {
int shipspeed(const ship * sh, const unit * u)
{
int k = sh->type->range;
attrib *a;
struct curse *c;
int bonus;
int k, bonus;
assert(sh);
if (!u) u = ship_owner(sh);
@ -310,6 +309,7 @@ int shipspeed(const ship * sh, const unit * u)
assert(sh->type->construction);
assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */
k = sh->type->range;
if (sh->size != sh->type->construction->maxsize)
return 0;
@ -417,7 +417,7 @@ static unit * ship_owner_ex(const ship * sh, const struct faction * last_owner)
{
unit *u, *heir = 0;
/* Eigentümer tot oder kein Eigentümer vorhanden. Erste lebende Einheit
/* Eigent<EFBFBD>mer tot oder kein Eigent<6E>mer vorhanden. Erste lebende Einheit
* nehmen. */
for (u = sh->region->units; u; u = u->next) {
if (u->ship == sh) {

View File

@ -16,7 +16,7 @@
const attrib_type at_lighthouse = {
"lighthouse"
/* Rest ist NULL; temporäres, nicht alterndes Attribut */
/* Rest ist NULL; tempor<EFBFBD>res, nicht alterndes Attribut */
};
/* update_lighthouse: call this function whenever the size of a lighthouse changes
@ -127,7 +127,7 @@ bool check_leuchtturm(region * r, faction * f)
c += u->number;
if (c > buildingcapacity(b))
break;
if (f == NULL || u->faction == f) {
if (u->faction == f) {
if (!d)
d = distance(r, r2);
if (maxd < d)

View File

@ -1240,9 +1240,9 @@ static bool roadto(const region * r, direction_t dir)
if (!r || dir >= MAXDIRECTIONS || dir < 0)
return false;
r2 = rconnect(r, dir);
if (r == NULL || r2 == NULL)
if (!r2) {
return false;
}
if (r->attribs || r2->attribs) {
const curse_type *roads_ct = ct_find("magicstreet");
if (roads_ct != NULL) {

View File

@ -273,10 +273,10 @@ void setup_drift (struct drift_fixture *fix) {
fix->st_boat->cabins = 20000;
fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0));
assert(fix->r);
assert(fix->r && fix->u && fix->f);
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
assert(fix->f && fix->u && fix->sh);
assert(fix->sh);
}
static void test_ship_no_overload(CuTest *tc) {

View File

@ -83,12 +83,12 @@ static void test_piracy_cmd(CuTest * tc) {
t_ocean = get_or_create_terrain("ocean");
st_boat = st_get_or_create("boat");
u2 = test_create_unit(test_create_faction(0), test_create_region(1, 0, t_ocean));
u_set_ship(u2, test_create_ship(u2->region, st_boat));
assert(u2);
u_set_ship(u2, test_create_ship(u2->region, st_boat));
u = test_create_unit(f = test_create_faction(0), r = test_create_region(0, 0, t_ocean));
assert(f && u);
set_level(u, SK_SAILING, st_boat->sumskill);
u_set_ship(u, test_create_ship(u->region, st_boat));
assert(f && u);
f->locale = get_or_create_locale("de");
u->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36(u2->faction->no));

View File

@ -102,6 +102,27 @@ static void test_renumber_ship(CuTest *tc) {
test_cleanup();
}
static void test_renumber_ship_twice(CuTest *tc) {
unit *u;
int uno, no;
const struct locale *lang;
test_setup_ex(tc);
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
u->ship = test_create_ship(u->region, 0);
no = u->ship->no;
uno = (no > 1) ? no - 1 : no + 1;
lang = u->faction->locale;
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, uno, u->ship->no);
free_order(u->thisorder);
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(no));
renumber_cmd(u, u->thisorder);
CuAssertIntEquals(tc, no, u->ship->no);
test_cleanup();
}
static void test_renumber_ship_duplicate(CuTest *tc) {
unit *u;
faction *f;
@ -204,6 +225,7 @@ CuSuite *get_renumber_suite(void)
SUITE_ADD_TEST(suite, test_renumber_building);
SUITE_ADD_TEST(suite, test_renumber_building_duplicate);
SUITE_ADD_TEST(suite, test_renumber_ship);
SUITE_ADD_TEST(suite, test_renumber_ship_twice);
SUITE_ADD_TEST(suite, test_renumber_ship_duplicate);
SUITE_ADD_TEST(suite, test_renumber_faction);
SUITE_ADD_TEST(suite, test_renumber_faction_duplicate);

View File

@ -489,13 +489,14 @@ size_t size)
building *b;
bool isbattle = (bool)(mode == seen_battle);
item *itm, *show = NULL;
faction *fv = visible_faction(f, u);
faction *fv;
char *bufp = buf;
int result = 0;
item results[MAX_INVENTORY];
assert(f);
bufp = STRLCPY(bufp, unitname(u), size);
fv = visible_faction(f, u);
if (!isbattle) {
attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
if (u->faction == f) {
@ -770,7 +771,7 @@ size_t size)
}
dh = 0;
if (!getarnt && f) {
if (!getarnt) {
if (alliedfaction(rplane(u->region), f, fv, HELP_ALL)) {
dh = 1;
}

View File

@ -3237,8 +3237,7 @@ static int sp_magicboost(castorder * co)
}
effect = 6;
c = create_curse(mage, &mage->attribs, ct_magicboost, power, 10, effect, 1);
create_curse(mage, &mage->attribs, ct_magicboost, power, 10, effect, 1);
/* one aura boost with 200% aura now: */
effect = 200;
c = create_curse(mage, &mage->attribs, ct_auraboost, power, 4, effect, 1);
@ -4031,7 +4030,7 @@ static int sp_recruit(castorder * co)
* ein mehrfaches von Stufe 1, denn in beiden Faellen gibt es nur 1
* Bauer, nur die Kosten steigen. */
n = (pow(force, 1.6) * 100) / f->race->recruitcost;
if (rc->recruit_multi != 0) {
if (rc->recruit_multi > 0) {
double multp = (double)maxp / rc->recruit_multi;
n = _min(multp, n);
n = _max(n, 1);

View File

@ -22,4 +22,5 @@ extern "C" {
}
#endif
#endif
#endif

View File

@ -185,9 +185,7 @@ plane *get_astralplane(void)
if (!rule_astralplane) {
return NULL;
}
if (!astralspace) {
astralspace = getplanebyname("Astralraum");
}
astralspace = getplanebyname("Astralraum");
if (!astralspace) {
astralspace = create_new_plane(1, "Astralraum",
TE_CENTER_X - 500, TE_CENTER_X + 500,

View File

@ -26,6 +26,7 @@ extern "C" {
struct trigger_type;
struct trigger;
struct unit;
struct race;
extern struct trigger_type tt_changerace;

View File

@ -81,10 +81,11 @@ void test_upkeep_from_pool(CuTest * tc)
i_silver = it_find("money");
assert(i_silver);
r = findregion(0, 0);
assert(r);
u1 = test_create_unit(test_create_faction(test_create_race("human")), r);
assert(u1);
u2 = test_create_unit(u1->faction, r);
assert(r && u1 && u2);
assert(u2);
config_set("rules.food.flags", "0");
i_change(&u1->items, i_silver, 30);

View File

@ -51,4 +51,5 @@ void register_function(pf_generic fun, const char *name)
void free_functions(void) {
cb_clear(&cb_functions);
}
}

View File

@ -284,7 +284,8 @@ void volcano_update(void)
}
}
else if (r->terrain == t_volcano) {
if (rng_int() % 100 < 4) {
int volcano_chance = config_get_int("volcano.active.percent", 4);
if (rng_int() % 100 < volcano_chance) {
ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r));
r->terrain = t_active;
}

1
tolua

@ -1 +0,0 @@
Subproject commit de289b60c5009b6ac8e786f39432c08eadbb69b7