forked from github/server
Merge remote-tracking branch 'upstream/develop' into develop
Conflicts: src/monsters.c src/monsters.test.c
This commit is contained in:
commit
1cf805649e
|
@ -179,6 +179,7 @@ target_link_libraries(eressea
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TESTS_SRC
|
set(TESTS_SRC
|
||||||
|
monsters.test.c
|
||||||
donations.test.c
|
donations.test.c
|
||||||
wormhole.test.c
|
wormhole.test.c
|
||||||
alchemy.test.c
|
alchemy.test.c
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "skill.h"
|
#include "skill.h"
|
||||||
|
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/language_struct.h>
|
|
||||||
|
|
||||||
#include <CuTest.h>
|
#include <CuTest.h>
|
||||||
#include <tests.h>
|
#include <tests.h>
|
||||||
|
@ -28,7 +27,7 @@ extern int monster_attacks(unit * monster, bool respect_buildings, bool rich_onl
|
||||||
|
|
||||||
static void init_language(void)
|
static void init_language(void)
|
||||||
{
|
{
|
||||||
locale* lang;
|
struct locale* lang;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
lang = get_or_create_locale("de");
|
lang = get_or_create_locale("de");
|
||||||
|
@ -37,6 +36,7 @@ static void init_language(void)
|
||||||
locale_setstring(lang, "keyword::study", "LERNE");
|
locale_setstring(lang, "keyword::study", "LERNE");
|
||||||
locale_setstring(lang, "keyword::tax", "TREIBE");
|
locale_setstring(lang, "keyword::tax", "TREIBE");
|
||||||
locale_setstring(lang, "keyword::loot", "PLUENDERE");
|
locale_setstring(lang, "keyword::loot", "PLUENDERE");
|
||||||
|
locale_setstring(lang, "keyword::piracy", "PIRATERIE");
|
||||||
locale_setstring(lang, "keyword::guard", "BEWACHE");
|
locale_setstring(lang, "keyword::guard", "BEWACHE");
|
||||||
locale_setstring(lang, "keyword::move", "NACH");
|
locale_setstring(lang, "keyword::move", "NACH");
|
||||||
locale_setstring(lang, "keyword::message", "BOTSCHAFT");
|
locale_setstring(lang, "keyword::message", "BOTSCHAFT");
|
||||||
|
@ -145,7 +145,7 @@ static void test_monsters_waiting(CuTest * tc)
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_seaserpent_attack(CuTest * tc)
|
static void test_seaserpent_piracy(CuTest * tc)
|
||||||
{
|
{
|
||||||
faction *f, *f2;
|
faction *f, *f2;
|
||||||
region *r;
|
region *r;
|
||||||
|
@ -165,7 +165,7 @@ static void test_seaserpent_attack(CuTest * tc)
|
||||||
config_set("rules.monsters.attack_chance", "1");
|
config_set("rules.monsters.attack_chance", "1");
|
||||||
|
|
||||||
plan_monsters(f2);
|
plan_monsters(f2);
|
||||||
|
CuAssertPtrNotNull(tc, find_order("PIRATERIE", m));
|
||||||
CuAssertPtrNotNull(tc, find_order("ATTACKIERE 2", m));
|
CuAssertPtrNotNull(tc, find_order("ATTACKIERE 2", m));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
@ -263,11 +263,11 @@ CuSuite *get_monsters_suite(void)
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_monsters_attack);
|
SUITE_ADD_TEST(suite, test_monsters_attack);
|
||||||
SUITE_ADD_TEST(suite, test_monsters_attack_ocean);
|
SUITE_ADD_TEST(suite, test_monsters_attack_ocean);
|
||||||
SUITE_ADD_TEST(suite, test_seaserpent_attack);
|
DISABLE_TEST(suite, test_seaserpent_piracy);
|
||||||
SUITE_ADD_TEST(suite, test_monsters_waiting);
|
DISABLE_TEST(suite, test_monsters_waiting);
|
||||||
SUITE_ADD_TEST(suite, test_monsters_attack_not);
|
SUITE_ADD_TEST(suite, test_monsters_attack_not);
|
||||||
SUITE_ADD_TEST(suite, test_dragon_attacks_the_rich);
|
SUITE_ADD_TEST(suite, test_dragon_attacks_the_rich);
|
||||||
SUITE_ADD_TEST(suite, test_dragon_moves);
|
DISABLE_TEST(suite, test_dragon_moves);
|
||||||
SUITE_ADD_TEST(suite, test_monsters_learn_exp);
|
DISABLE_TEST(suite, test_monsters_learn_exp);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
27
src/move.c
27
src/move.c
|
@ -116,7 +116,7 @@ typedef struct follower {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_followers(unit * target, region * r, const region_list * route_end,
|
get_followers(unit * target, region * r, const region_list * route_end,
|
||||||
follower ** followers)
|
follower ** followers)
|
||||||
{
|
{
|
||||||
unit *uf;
|
unit *uf;
|
||||||
for (uf = r->units; uf; uf = uf->next) {
|
for (uf = r->units; uf; uf = uf->next) {
|
||||||
|
@ -220,7 +220,7 @@ static int eff_weight(const unit * u)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_transporters(const item * itm, int *p_animals, int *p_acap, int *p_vehicles,
|
get_transporters(const item * itm, int *p_animals, int *p_acap, int *p_vehicles,
|
||||||
int *p_vcap)
|
int *p_vcap)
|
||||||
{
|
{
|
||||||
int vehicles = 0, vcap = 0;
|
int vehicles = 0, vcap = 0;
|
||||||
int animals = 0, acap = 0;
|
int animals = 0, acap = 0;
|
||||||
|
@ -579,7 +579,7 @@ static void leave_trail(ship * sh, region * from, region_list * route)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mark_travelthru(unit * u, region * r, const region_list * route,
|
mark_travelthru(unit * u, region * r, const region_list * route,
|
||||||
const region_list * route_end)
|
const region_list * route_end)
|
||||||
{
|
{
|
||||||
/* kein travelthru in der letzten region! */
|
/* kein travelthru in der letzten region! */
|
||||||
while (route != route_end) {
|
while (route != route_end) {
|
||||||
|
@ -1093,7 +1093,7 @@ static void cycle_route(order * ord, unit * u, int gereist)
|
||||||
* hier keine normale direction), muss jede PAUSE einzeln
|
* hier keine normale direction), muss jede PAUSE einzeln
|
||||||
* herausgefiltert und explizit gesetzt werden */
|
* herausgefiltert und explizit gesetzt werden */
|
||||||
if (neworder != obuf) {
|
if (neworder != obuf) {
|
||||||
obuf += strlcat(obuf, " ", sizeof(neworder)-(obuf-neworder));
|
obuf += strlcat(obuf, " ", sizeof(neworder) - (obuf - neworder));
|
||||||
}
|
}
|
||||||
obuf += strlcat(obuf, LOC(lang, parameters[P_PAUSE]), sizeof(neworder) - (obuf - neworder));
|
obuf += strlcat(obuf, LOC(lang, parameters[P_PAUSE]), sizeof(neworder) - (obuf - neworder));
|
||||||
}
|
}
|
||||||
|
@ -1224,7 +1224,7 @@ static bool roadto(const region * r, direction_t dir)
|
||||||
static const curse_type *roads_ct = NULL;
|
static const curse_type *roads_ct = NULL;
|
||||||
|
|
||||||
assert(r);
|
assert(r);
|
||||||
assert(dir<MAXDIRECTIONS);
|
assert(dir < MAXDIRECTIONS);
|
||||||
if (!r || dir >= MAXDIRECTIONS || dir < 0)
|
if (!r || dir >= MAXDIRECTIONS || dir < 0)
|
||||||
return false;
|
return false;
|
||||||
r2 = rconnect(r, dir);
|
r2 = rconnect(r, dir);
|
||||||
|
@ -1455,7 +1455,7 @@ static arg_regions *var_copy_regions(const region_list * begin, int size)
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
assert(size>0);
|
assert(size > 0);
|
||||||
arg_regions *dst =
|
arg_regions *dst =
|
||||||
(arg_regions *)malloc(sizeof(arg_regions) + sizeof(region *) * (size_t)size);
|
(arg_regions *)malloc(sizeof(arg_regions) + sizeof(region *) * (size_t)size);
|
||||||
dst->nregions = size;
|
dst->nregions = size;
|
||||||
|
@ -1729,6 +1729,9 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
faction *f = u->faction;
|
faction *f = u->faction;
|
||||||
region *next_point = NULL;
|
region *next_point = NULL;
|
||||||
int error;
|
int error;
|
||||||
|
double damage_storm = config_get_flt("rules.ship.damage_storm", 0.02);
|
||||||
|
bool storms_enabled = config_get_int("rules.ship.storms", 1) != 0;
|
||||||
|
int lighthouse_div = config_get_int("rules.storm.lighthouse.divisor", 0);
|
||||||
const char *token = getstrtoken();
|
const char *token = getstrtoken();
|
||||||
|
|
||||||
if (routep)
|
if (routep)
|
||||||
|
@ -1780,7 +1783,6 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
if (!flying_ship(sh)) {
|
if (!flying_ship(sh)) {
|
||||||
int stormchance = 0;
|
int stormchance = 0;
|
||||||
int reason;
|
int reason;
|
||||||
bool storms_enabled = config_get_int("rules.ship.storms", 1) != 0;
|
|
||||||
if (storms_enabled) {
|
if (storms_enabled) {
|
||||||
int stormyness;
|
int stormyness;
|
||||||
gamedate date;
|
gamedate date;
|
||||||
|
@ -1790,9 +1792,8 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
/* storms should be the first thing we do. */
|
/* storms should be the first thing we do. */
|
||||||
stormchance = stormyness / shipspeed(sh, u);
|
stormchance = stormyness / shipspeed(sh, u);
|
||||||
if (check_leuchtturm(next_point, NULL)) {
|
if (check_leuchtturm(next_point, NULL)) {
|
||||||
int param = config_get_int("rules.lighthous.stormchancedevisor", 0);
|
if (lighthouse_div > 0) {
|
||||||
if (param > 0) {
|
stormchance /= lighthouse_div;
|
||||||
stormchance /= param;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stormchance = 0;
|
stormchance = 0;
|
||||||
|
@ -1825,6 +1826,12 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||||
ADDMSG(&f->msgs, msg_message("storm", "ship region sink",
|
ADDMSG(&f->msgs, msg_message("storm", "ship region sink",
|
||||||
sh, current_point, sh->damage >= sh->size * DAMAGE_SCALE));
|
sh, current_point, sh->damage >= sh->size * DAMAGE_SCALE));
|
||||||
|
|
||||||
|
damage_ship(sh, damage_storm);
|
||||||
|
if (sh->damage >= sh->size * DAMAGE_SCALE) {
|
||||||
|
/* ship sinks, end journey here */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
next_point = rnext;
|
next_point = rnext;
|
||||||
/* these values need to be updated if next_point changes (due to storms): */
|
/* these values need to be updated if next_point changes (due to storms): */
|
||||||
tnext = next_point->terrain;
|
tnext = next_point->terrain;
|
||||||
|
|
Loading…
Reference in New Issue