forked from github/server
commit
92e4643b72
|
@ -7,7 +7,8 @@ script: s/travis-build
|
|||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- liblua5.2-dev
|
||||
- liblua5.1-dev
|
||||
- libtolua-dev
|
||||
- libncurses5-dev
|
||||
- libsqlite3-dev
|
||||
- libxml2-dev
|
||||
|
|
|
@ -269,11 +269,6 @@
|
|||
<skill name="melee" level="1"/>
|
||||
</set>
|
||||
|
||||
<set name="new_centaur_unit">
|
||||
<skill name="polearm" level="1"/>
|
||||
<skill name="melee" level="1"/>
|
||||
</set>
|
||||
|
||||
<set name="seaserpent_spoils">
|
||||
<item name="dragonblood" amount="6"/>
|
||||
<item name="seaserpenthead" amount="1"/>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
recruitcost="-1" maintenance="0" weight="1000" capacity="440" speed="1.000000"
|
||||
hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="no"
|
||||
walk="yes" shapeshift="no" giveperson="no" giveunit="no"
|
||||
getitem="no" recruitethereal="no" equipment="yes" scarepeasants="yes"
|
||||
getitem="no" equipment="yes" scarepeasants="yes"
|
||||
cansteal="no" unarmedguard="yes" absorbpeasants="yes" noheal="yes"
|
||||
undead="yes" resistpierce="yes">
|
||||
<ai splitsize="1000" moverandom="yes" learn="yes" />
|
||||
|
|
|
@ -180,15 +180,6 @@ static void expandorders(region * r, request * requests)
|
|||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static void change_level(unit * u, skill_t sk, int bylevel)
|
||||
{
|
||||
skill *sv = unit_skill(u, sk);
|
||||
assert(bylevel > 0);
|
||||
if (sv == 0)
|
||||
sv = add_skill(u, sk);
|
||||
sk_set(sv, sv->level + bylevel);
|
||||
}
|
||||
|
||||
typedef struct recruitment {
|
||||
struct recruitment *next;
|
||||
faction *f;
|
||||
|
@ -258,10 +249,6 @@ void add_recruits(unit * u, int number, int wanted)
|
|||
strlcat(equipment, "_unit", sizeof(equipment));
|
||||
equip_unit(unew, get_equipment(equipment));
|
||||
|
||||
if (u_race(unew)->ec_flags & ECF_REC_HORSES) {
|
||||
change_level(unew, SK_RIDING, 1);
|
||||
}
|
||||
|
||||
if (unew != u) {
|
||||
transfermen(unew, u, unew->number);
|
||||
remove_unit(&r->units, unew);
|
||||
|
@ -278,24 +265,6 @@ static int any_recruiters(const struct race *rc, int qty)
|
|||
return (int)(qty * 2 * rc->recruit_multi);
|
||||
}
|
||||
|
||||
/*static int peasant_recruiters(const struct race *rc, int qty)
|
||||
{
|
||||
if (rc->ec_flags & ECF_REC_ETHEREAL)
|
||||
return -1;
|
||||
if (rc->ec_flags & ECF_REC_HORSES)
|
||||
return -1;
|
||||
return (int)(qty * 2 * rc->recruit_multi);
|
||||
}*/
|
||||
|
||||
static int horse_recruiters(const struct race *rc, int qty)
|
||||
{
|
||||
if (rc->ec_flags & ECF_REC_ETHEREAL)
|
||||
return -1;
|
||||
if (rc->ec_flags & ECF_REC_HORSES)
|
||||
return (int)(qty * 2.0 * rc->recruit_multi);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int do_recruiting(recruitment * recruits, int available)
|
||||
{
|
||||
recruitment *rec;
|
||||
|
@ -407,17 +376,6 @@ static void expandrecruit(region * r, request * recruitorders)
|
|||
|
||||
int orc_total = 0;
|
||||
|
||||
/* centaurs: */
|
||||
recruits = select_recruitment(&recruitorders, horse_recruiters, &orc_total);
|
||||
if (recruits) {
|
||||
int recruited, horses = rhorses(r) * 2;
|
||||
if (orc_total < horses)
|
||||
horses = orc_total;
|
||||
recruited = do_recruiting(recruits, horses);
|
||||
rsethorses(r, (horses - recruited) / 2);
|
||||
free_recruitments(recruits);
|
||||
}
|
||||
|
||||
/* peasant limited: */
|
||||
recruits = select_recruitment(&recruitorders, any_recruiters, &orc_total);
|
||||
if (recruits) {
|
||||
|
@ -539,7 +497,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(rc->ec_flags & ECF_REC_HORSES) && fval(r, RF_ORCIFIED)) {
|
||||
if (fval(r, RF_ORCIFIED)) {
|
||||
if (rc != get_race(RC_ORC)) {
|
||||
cmistake(u, ord, 238, MSG_EVENT);
|
||||
return;
|
||||
|
|
|
@ -70,7 +70,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/rand.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/translation.h>
|
||||
#include <util/unicode.h>
|
||||
#include <util/umlaut.h>
|
||||
#include <util/xml.h>
|
||||
|
||||
|
|
|
@ -522,6 +522,24 @@ static void set_cursedmen(curse * c, int cursedmen)
|
|||
}
|
||||
}
|
||||
|
||||
static int newcurseid(void) {
|
||||
int random_no;
|
||||
int start_random_no;
|
||||
random_no = 1 + (rng_int() % MAX_UNIT_NR);
|
||||
start_random_no = random_no;
|
||||
|
||||
while (findcurse(random_no)) {
|
||||
random_no++;
|
||||
if (random_no == MAX_UNIT_NR + 1) {
|
||||
random_no = 1;
|
||||
}
|
||||
if (random_no == start_random_no) {
|
||||
random_no = (int)MAX_UNIT_NR + 1;
|
||||
}
|
||||
}
|
||||
return random_no;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Legt eine neue Verzauberung an. Sollte es schon einen Zauber
|
||||
* dieses Typs geben, gibt es den bestehenden zurück.
|
||||
|
@ -543,7 +561,7 @@ static curse *make_curse(unit * mage, attrib ** ap, const curse_type * ct,
|
|||
c->effect = effect;
|
||||
c->magician = mage;
|
||||
|
||||
c->no = newunitid();
|
||||
c->no = newcurseid();
|
||||
chash(c);
|
||||
|
||||
switch (c->type->typ) {
|
||||
|
|
|
@ -280,7 +280,6 @@ extern "C" {
|
|||
* */
|
||||
struct curse *get_curse(struct attrib *ap, const curse_type * ctype);
|
||||
|
||||
int find_cursebyname(const char *c);
|
||||
const curse_type *ct_find(const char *c);
|
||||
bool ct_changed(int *cache);
|
||||
void ct_register(const curse_type *);
|
||||
|
|
|
@ -49,7 +49,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/resolve.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/variant.h>
|
||||
#include <util/unicode.h>
|
||||
|
||||
#include <attributes/otherfaction.h>
|
||||
|
||||
|
@ -387,19 +386,14 @@ void destroyfaction(faction ** fp)
|
|||
const race *rc = u_race(u);
|
||||
int m = rmoney(r);
|
||||
|
||||
/* Personen gehen nur an die Bauern, wenn sie auch von dort
|
||||
* stammen */
|
||||
if ((rc->ec_flags & ECF_REC_ETHEREAL) == 0) {
|
||||
int p = rpeasants(u->region);
|
||||
int h = rhorses(u->region);
|
||||
item *itm;
|
||||
|
||||
/* Personen gehen nur an die Bauern, wenn sie auch von dort
|
||||
* stammen */
|
||||
if (rc->ec_flags & ECF_REC_HORSES) { /* Zentauren an die Pferde */
|
||||
h += u->number;
|
||||
}
|
||||
else { /* Orks zählen nur zur Hälfte */
|
||||
p += (int)(u->number * rc->recruit_multi);
|
||||
}
|
||||
for (itm = u->items; itm; itm = itm->next) {
|
||||
if (itm->type->flags & ITF_ANIMAL) {
|
||||
h += itm->number;
|
||||
|
|
|
@ -217,7 +217,6 @@ extern "C" {
|
|||
#define GIVEPERSON (1<<2) /* übergibt Personen */
|
||||
#define GIVEUNIT (1<<3) /* Einheiten an andere Partei übergeben */
|
||||
#define GETITEM (1<<4) /* nimmt Gegenstände an */
|
||||
#define ECF_REC_HORSES (1<<6) /* Rekrutiert aus Pferden */
|
||||
#define ECF_REC_ETHEREAL (1<<7) /* Rekrutiert aus dem Nichts */
|
||||
#define ECF_REC_UNLIMITED (1<<8) /* Rekrutiert ohne Limit */
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <util/resolve.h>
|
||||
#include <util/rng.h>
|
||||
#include <util/umlaut.h>
|
||||
#include <util/unicode.h>
|
||||
|
||||
#include <quicklist.h>
|
||||
#include <stream.h>
|
||||
|
|
|
@ -1084,18 +1084,12 @@ void transfermen(unit * u, unit * dst, int n)
|
|||
else if (r->land) {
|
||||
if ((u_race(u)->ec_flags & ECF_REC_ETHEREAL) == 0) {
|
||||
const race *rc = u_race(u);
|
||||
if (rc->ec_flags & ECF_REC_HORSES) { /* Zentauren an die Pferde */
|
||||
int h = rhorses(r) + n;
|
||||
rsethorses(r, h);
|
||||
}
|
||||
else {
|
||||
int p = rpeasants(r);
|
||||
p += (int)(n * rc->recruit_multi);
|
||||
rsetpeasants(r, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct building *inside_building(const struct unit *u)
|
||||
{
|
||||
|
@ -1437,6 +1431,26 @@ void free_unit(unit * u)
|
|||
}
|
||||
}
|
||||
|
||||
static int newunitid(void)
|
||||
{
|
||||
int random_unit_no;
|
||||
int start_random_no;
|
||||
random_unit_no = 1 + (rng_int() % MAX_UNIT_NR);
|
||||
start_random_no = random_unit_no;
|
||||
|
||||
while (ufindhash(random_unit_no) || dfindhash(random_unit_no)
|
||||
|| forbiddenid(random_unit_no)) {
|
||||
random_unit_no++;
|
||||
if (random_unit_no == MAX_UNIT_NR + 1) {
|
||||
random_unit_no = 1;
|
||||
}
|
||||
if (random_unit_no == start_random_no) {
|
||||
random_unit_no = (int)MAX_UNIT_NR + 1;
|
||||
}
|
||||
}
|
||||
return random_unit_no;
|
||||
}
|
||||
|
||||
static void createunitid(unit * u, int id)
|
||||
{
|
||||
if (id <= 0 || id > MAX_UNIT_NR || ufindhash(id) || dfindhash(id)
|
||||
|
@ -1699,6 +1713,7 @@ int unit_getcapacity(const unit * u)
|
|||
}
|
||||
|
||||
void renumber_unit(unit *u, int no) {
|
||||
if (no == 0) no = newunitid();
|
||||
uunhash(u);
|
||||
if (!ualias(u)) {
|
||||
attrib *a = a_add(&u->attribs, a_new(&at_alias));
|
||||
|
@ -1929,27 +1944,6 @@ bool unit_can_study(const unit *u) {
|
|||
return !((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE));
|
||||
}
|
||||
|
||||
/* ID's für Einheiten und Zauber */
|
||||
int newunitid(void)
|
||||
{
|
||||
int random_unit_no;
|
||||
int start_random_no;
|
||||
random_unit_no = 1 + (rng_int() % MAX_UNIT_NR);
|
||||
start_random_no = random_unit_no;
|
||||
|
||||
while (ufindhash(random_unit_no) || dfindhash(random_unit_no)
|
||||
|| forbiddenid(random_unit_no)) {
|
||||
random_unit_no++;
|
||||
if (random_unit_no == MAX_UNIT_NR + 1) {
|
||||
random_unit_no = 1;
|
||||
}
|
||||
if (random_unit_no == start_random_no) {
|
||||
random_unit_no = (int)MAX_UNIT_NR + 1;
|
||||
}
|
||||
}
|
||||
return random_unit_no;
|
||||
}
|
||||
|
||||
static int read_newunitid(const faction * f, const region * r)
|
||||
{
|
||||
int n;
|
||||
|
|
|
@ -258,7 +258,6 @@ extern "C" {
|
|||
#define GET_PEASANTS 2
|
||||
|
||||
int getunit(const struct region * r, const struct faction * f, struct unit **uresult);
|
||||
int newunitid(void);
|
||||
int read_unitid(const struct faction *f, const struct region *r);
|
||||
|
||||
void setstatus(struct unit *u, int status);
|
||||
|
|
|
@ -1730,8 +1730,6 @@ static int parse_races(xmlDocPtr doc)
|
|||
rc->ec_flags |= GIVEUNIT;
|
||||
if (xml_bvalue(node, "getitem", false))
|
||||
rc->ec_flags |= GETITEM;
|
||||
if (xml_bvalue(node, "recruithorses", false))
|
||||
rc->ec_flags |= ECF_REC_HORSES;
|
||||
if (xml_bvalue(node, "recruitethereal", false))
|
||||
rc->ec_flags |= ECF_REC_ETHEREAL;
|
||||
if (xml_bvalue(node, "recruitunlimited", false))
|
||||
|
|
|
@ -2916,7 +2916,7 @@ int renumber_cmd(unit * u, order * ord)
|
|||
{
|
||||
char token[128];
|
||||
const char *s;
|
||||
int i;
|
||||
int i = 0;
|
||||
faction *f = u->faction;
|
||||
|
||||
init_order(ord);
|
||||
|
@ -2936,10 +2936,7 @@ int renumber_cmd(unit * u, order * ord)
|
|||
|
||||
case P_UNIT:
|
||||
s = gettoken(token, sizeof(token));
|
||||
if (s == NULL || *s == 0) {
|
||||
i = newunitid();
|
||||
}
|
||||
else {
|
||||
if (s && *s) {
|
||||
i = atoi36((const char *)s);
|
||||
if (i <= 0 || i > MAX_UNIT_NR) {
|
||||
cmistake(u, ord, 114, MSG_EVENT);
|
||||
|
|
|
@ -73,13 +73,11 @@ int lighthouse_range(const building * b, const faction * f)
|
|||
region *r = b->region;
|
||||
int c = 0;
|
||||
int cap = buildingcapacity(b);
|
||||
unit *u;
|
||||
unit *u, *uown = building_owner(b);
|
||||
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->building == b || u == building_owner(b)) {
|
||||
if (u->building == b) {
|
||||
if (u->building == b || u == uown) {
|
||||
c += u->number;
|
||||
}
|
||||
if (c > cap) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1170,11 +1170,9 @@ static void add_seen_nb(faction *f, region *r, seen_mode mode) {
|
|||
|
||||
/** mark all regions seen by the lighthouse.
|
||||
*/
|
||||
static void prepare_lighthouse(building * b, report_context *ctx)
|
||||
static void prepare_lighthouse(faction *f, region *r, int range)
|
||||
{
|
||||
faction *f = ctx->f;
|
||||
int range = lighthouse_range(b, f);
|
||||
quicklist *ql, *rlist = get_regions_distance(b->region, range);
|
||||
quicklist *ql, *rlist = get_regions_distance(r, range);
|
||||
int qi;
|
||||
|
||||
for (ql = rlist, qi = 0; ql; ql_advance(&ql, &qi, 1)) {
|
||||
|
@ -1316,7 +1314,6 @@ static void cb_add_seen(region *r, unit *u, void *cbdata) {
|
|||
void prepare_report(report_context *ctx, faction *f)
|
||||
{
|
||||
region *r;
|
||||
building *b;
|
||||
static int config;
|
||||
static bool rule_region_owners;
|
||||
const struct building_type *bt_lighthouse = bt_find("lighthouse");
|
||||
|
@ -1334,34 +1331,36 @@ void prepare_report(report_context *ctx, faction *f)
|
|||
ctx->last = lastregion(f);
|
||||
|
||||
for (r = ctx->first; r!=ctx->last; r = r->next) {
|
||||
int range = 0;
|
||||
unit *u;
|
||||
|
||||
if (fval(r, RF_LIGHTHOUSE)) {
|
||||
if (fval(r, RF_LIGHTHOUSE) && bt_lighthouse) {
|
||||
if (rule_region_owners && f == region_get_owner(r)) {
|
||||
/* region owners get the report from lighthouses */
|
||||
if (rule_region_owners && bt_lighthouse) {
|
||||
for (b = rbuildings(r); b; b = b->next) {
|
||||
if (b && b->type == bt_lighthouse) {
|
||||
u = building_owner(b);
|
||||
if (u && u->faction==f) {
|
||||
prepare_lighthouse(b, ctx);
|
||||
add_seen_nb(f, r, seen_unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
building *b;
|
||||
|
||||
for (b = r->buildings; b; b = b->next) {
|
||||
if (b->type == bt_lighthouse) {
|
||||
int br = lighthouse_range(b, NULL);
|
||||
if (br > range) range = br;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->faction == f) {
|
||||
add_seen_nb(f, r, seen_unit);
|
||||
if (fval(r, RF_LIGHTHOUSE)) {
|
||||
if (fval(r, RF_LIGHTHOUSE) && bt_lighthouse) {
|
||||
if (u->building && u->building->type == bt_lighthouse && inside_building(u)) {
|
||||
/* we are in a lighthouse. add the regions we can see from here! */
|
||||
prepare_lighthouse(u->building, ctx);
|
||||
int br = lighthouse_range(u->building, f);
|
||||
if (br > range) range = br;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (range > 0) {
|
||||
/* we are in at least one lighthouse. add the regions we can see from here! */
|
||||
prepare_lighthouse(f, r, range);
|
||||
}
|
||||
|
||||
if (fval(r, RF_TRAVELUNIT) && r->seen.mode<seen_travel) {
|
||||
travelthru_map(r, cb_add_seen, f);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "travelthru.h"
|
||||
#include "keyword.h"
|
||||
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
|
@ -344,6 +345,43 @@ static void test_prepare_lighthouse(CuTest *tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_prepare_lighthouse_owners(CuTest *tc) {
|
||||
report_context ctx;
|
||||
faction *f;
|
||||
region *r1, *r2, *r3;
|
||||
unit *u;
|
||||
building *b;
|
||||
building_type *btype;
|
||||
const struct terrain_type *t_ocean, *t_plain;
|
||||
|
||||
test_setup();
|
||||
config_set("rules.region_owner_pay_building", "lighthouse");
|
||||
config_set("rules.region_owners", "1");
|
||||
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
f = test_create_faction(0);
|
||||
r1 = test_create_region(0, 0, t_plain);
|
||||
r2 = test_create_region(1, 0, t_ocean);
|
||||
r3 = test_create_region(2, 0, t_ocean);
|
||||
btype = test_create_buildingtype("lighthouse");
|
||||
b = test_create_building(r1, btype);
|
||||
b->flags |= BLD_MAINTAINED;
|
||||
b->size = 10;
|
||||
update_lighthouse(b);
|
||||
u = test_create_unit(f, r1);
|
||||
u = test_create_unit(test_create_faction(0), r1);
|
||||
u->building = b;
|
||||
set_level(u, SK_PERCEPTION, 3);
|
||||
region_set_owner(b->region, f, 0);
|
||||
prepare_report(&ctx, f);
|
||||
CuAssertPtrEquals(tc, r1, ctx.first);
|
||||
CuAssertPtrEquals(tc, NULL, ctx.last);
|
||||
CuAssertIntEquals(tc, seen_unit, r1->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode);
|
||||
CuAssertIntEquals(tc, seen_neighbour, r3->seen.mode);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_prepare_report(CuTest *tc) {
|
||||
report_context ctx;
|
||||
faction *f;
|
||||
|
@ -432,6 +470,7 @@ CuSuite *get_reports_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_seen_neighbours);
|
||||
SUITE_ADD_TEST(suite, test_seen_travelthru);
|
||||
SUITE_ADD_TEST(suite, test_prepare_lighthouse);
|
||||
SUITE_ADD_TEST(suite, test_prepare_lighthouse_owners);
|
||||
SUITE_ADD_TEST(suite, test_prepare_lighthouse_capacity);
|
||||
SUITE_ADD_TEST(suite, test_prepare_travelthru);
|
||||
SUITE_ADD_TEST(suite, test_reorder_units);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <kernel/faction.h>
|
||||
#include <kernel/race.h>
|
||||
#include <util/language.h>
|
||||
#include <util/unicode.h>
|
||||
#include <util/log.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/log.h>
|
||||
|
|
|
@ -61,7 +61,6 @@ without prior permission by the authors of Eressea.
|
|||
#include <util/language.h>
|
||||
#include <util/message.h>
|
||||
#include <quicklist.h>
|
||||
#include <util/unicode.h>
|
||||
#include <util/xml.h>
|
||||
|
||||
#ifdef USE_LIBXML2
|
||||
|
|
Loading…
Reference in New Issue