forked from github/server
Merge branch 'develop' of https://github.com/ennorehling/eressea.git
This commit is contained in:
commit
2697d78c07
|
@ -1529,6 +1529,7 @@ static void report_itemtype(FILE *F, faction *f, const item_type *itype) {
|
|||
fprintf(F, "\"%s\"\n", translate(ch, LOC(f->locale, ch)));
|
||||
m++;
|
||||
}
|
||||
assert(!m->rtype);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1252,7 +1252,6 @@ static void create_potion(unit * u, const item_type * itype, int want)
|
|||
/* something missing from the list of materials */
|
||||
ADDMSG(&u->faction->msgs, msg_materials_required(u, u->thisorder,
|
||||
itype->construction, want));
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
i_change(&u->items, itype, built);
|
||||
|
|
|
@ -625,6 +625,7 @@ static void handle_requirement(parseinfo *pi, const XML_Char *el, const XML_Char
|
|||
|
||||
assert(nreqs < MAX_REQUIREMENTS);
|
||||
req = reqs + nreqs;
|
||||
req->number = 1;
|
||||
for (i = 0; attr[i]; i += 2) {
|
||||
if (xml_strcmp(attr[i], "type") == 0) {
|
||||
req->rtype = rt_get_or_create(attr[i + 1]);
|
||||
|
|
29
src/gmtool.c
29
src/gmtool.c
|
@ -530,16 +530,31 @@ static void statusline(WINDOW * win, const char *str)
|
|||
}
|
||||
|
||||
static void reset_region(region *r) {
|
||||
unit **up = &r->units;
|
||||
bool players = false;
|
||||
|
||||
r->flags = 0;
|
||||
a_removeall(&r->attribs, NULL);
|
||||
while (r->units) {
|
||||
remove_unit(&r->units, r->units);
|
||||
while (*up) {
|
||||
unit *u = *up;
|
||||
if (is_monsters(u->faction)) {
|
||||
remove_unit(up, u);
|
||||
}
|
||||
else {
|
||||
players = true;
|
||||
up = &u->next;
|
||||
}
|
||||
}
|
||||
while (r->ships) {
|
||||
remove_ship(&r->ships, r->ships);
|
||||
}
|
||||
while (r->buildings) {
|
||||
remove_building(&r->buildings, r->buildings);
|
||||
if (!players) {
|
||||
while (r->ships) {
|
||||
remove_ship(&r->ships, r->ships);
|
||||
}
|
||||
while (r->buildings) {
|
||||
remove_building(&r->buildings, r->buildings);
|
||||
}
|
||||
if (r->land) {
|
||||
init_region(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1048,6 +1048,43 @@ int fix_demand(region * rd) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void init_region(region *r)
|
||||
{
|
||||
static int changed;
|
||||
static const terrain_type *t_plain;
|
||||
const terrain_type * terrain = r->terrain;
|
||||
int horses = 0, trees = 0;
|
||||
if (terrain_changed(&changed)) {
|
||||
t_plain = get_terrain(terrainnames[T_PLAIN]);
|
||||
}
|
||||
if (terrain->size>0) {
|
||||
horses = rng_int() % (terrain->size / 50);
|
||||
trees = terrain->size * (30 + rng_int() % 40) / 1000;
|
||||
}
|
||||
if (t_plain && terrain == t_plain) {
|
||||
rsethorses(r, horses);
|
||||
if (chance(0.4)) {
|
||||
rsettrees(r, 2, trees);
|
||||
}
|
||||
}
|
||||
else if (trees>0 && chance(0.2)) {
|
||||
rsettrees(r, 2, trees);
|
||||
}
|
||||
else {
|
||||
rsettrees(r, 2, 0);
|
||||
}
|
||||
rsettrees(r, 1, rtrees(r, 2) / 4);
|
||||
rsettrees(r, 0, rtrees(r, 2) / 8);
|
||||
|
||||
if (!fval(r, RF_CHAOTIC)) {
|
||||
int peasants;
|
||||
peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100;
|
||||
rsetpeasants(r, MAX(100, peasants));
|
||||
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
|
||||
INT_MAX) + 1) + rng_int() % 5));
|
||||
}
|
||||
}
|
||||
|
||||
void terraform_region(region * r, const terrain_type * terrain)
|
||||
{
|
||||
/* Resourcen, die nicht mehr vorkommen können, löschen */
|
||||
|
@ -1195,40 +1232,8 @@ void terraform_region(region * r, const terrain_type * terrain)
|
|||
else
|
||||
freset(r, RF_MALLORN);
|
||||
}
|
||||
}
|
||||
|
||||
if (oldterrain == NULL || terrain->size != oldterrain->size) {
|
||||
static int changed;
|
||||
static const terrain_type *t_plain;
|
||||
int horses = 0, trees = 0;
|
||||
if (terrain_changed(&changed)) {
|
||||
t_plain = get_terrain(terrainnames[T_PLAIN]);
|
||||
}
|
||||
if (terrain->size>0) {
|
||||
horses = rng_int() % (terrain->size / 50);
|
||||
trees = terrain->size * (30 + rng_int() % 40) / 1000;
|
||||
}
|
||||
if (t_plain && terrain == t_plain) {
|
||||
rsethorses(r, horses);
|
||||
if (chance(0.4)) {
|
||||
rsettrees(r, 2, trees);
|
||||
}
|
||||
}
|
||||
else if (trees>0 && chance(0.2)) {
|
||||
rsettrees(r, 2, trees);
|
||||
}
|
||||
else {
|
||||
rsettrees(r, 2, 0);
|
||||
}
|
||||
rsettrees(r, 1, rtrees(r, 2) / 4);
|
||||
rsettrees(r, 0, rtrees(r, 2) / 8);
|
||||
|
||||
if (!fval(r, RF_CHAOTIC)) {
|
||||
int peasants;
|
||||
peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100;
|
||||
rsetpeasants(r, MAX(100, peasants));
|
||||
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
|
||||
INT_MAX) + 1) + rng_int() % 5));
|
||||
if (oldterrain == NULL || terrain->size != oldterrain->size) {
|
||||
init_region(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,6 +228,7 @@ extern "C" {
|
|||
struct region *new_region(int x, int y, struct plane *pl, int uid);
|
||||
void remove_region(region ** rlist, region * r);
|
||||
void terraform_region(struct region *r, const struct terrain_type *terrain);
|
||||
void init_region(struct region *r);
|
||||
bool pnormalize(int *x, int *y, const struct plane *pl);
|
||||
|
||||
extern const int delta_x[MAXDIRECTIONS];
|
||||
|
|
|
@ -2191,6 +2191,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
assert(!rm->rtype);
|
||||
}
|
||||
*bufp = 0;
|
||||
centre(out, buf, true);
|
||||
|
|
|
@ -2449,8 +2449,10 @@ bool visible_unit(const unit *u, const faction *f, int stealthmod, seen_mode mod
|
|||
return true;
|
||||
}
|
||||
else {
|
||||
if (stealthmod > INT_MIN && (mode == seen_lighthouse || mode >= seen_unit)) {
|
||||
return cansee(f, u->region, u, stealthmod);
|
||||
if (stealthmod > INT_MIN && mode >= seen_lighthouse) {
|
||||
if (mode != seen_travel || u->building || u->ship || is_guard(u)) {
|
||||
return cansee(f, u->region, u, stealthmod);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <platform.h>
|
||||
#include "reports.h"
|
||||
|
||||
#include "kernel/calendar.h"
|
||||
#include "guard.h"
|
||||
#include "keyword.h"
|
||||
#include "lighthouse.h"
|
||||
#include "laws.h"
|
||||
|
@ -10,28 +10,29 @@
|
|||
#include "spy.h"
|
||||
#include "travelthru.h"
|
||||
|
||||
#include <kernel/ally.h>
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/terrain.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/spellbook.h>
|
||||
#include <kernel/terrain.h>
|
||||
#include "kernel/ally.h"
|
||||
#include "kernel/calendar.h"
|
||||
#include "kernel/config.h"
|
||||
#include "kernel/building.h"
|
||||
#include "kernel/faction.h"
|
||||
#include "kernel/item.h"
|
||||
#include "kernel/race.h"
|
||||
#include "kernel/region.h"
|
||||
#include "kernel/ship.h"
|
||||
#include "kernel/terrain.h"
|
||||
#include "kernel/unit.h"
|
||||
#include "kernel/spell.h"
|
||||
#include "kernel/spellbook.h"
|
||||
#include "kernel/terrain.h"
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/language.h>
|
||||
#include <util/lists.h>
|
||||
#include <util/message.h>
|
||||
#include "util/attrib.h"
|
||||
#include "util/language.h"
|
||||
#include "util/lists.h"
|
||||
#include "util/message.h"
|
||||
|
||||
#include <attributes/attributes.h>
|
||||
#include <attributes/key.h>
|
||||
#include <attributes/otherfaction.h>
|
||||
#include "attributes/attributes.h"
|
||||
#include "attributes/key.h"
|
||||
#include "attributes/otherfaction.h"
|
||||
|
||||
#include <selist.h>
|
||||
#include <stream.h>
|
||||
|
@ -826,38 +827,61 @@ static void test_newbie_warning(CuTest *tc) {
|
|||
}
|
||||
|
||||
static void test_visible_unit(CuTest *tc) {
|
||||
unit *u2;
|
||||
unit *u;
|
||||
faction *f;
|
||||
ship *sh;
|
||||
building *b;
|
||||
race *rc;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
u2 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
sh = test_create_ship(u2->region, NULL);
|
||||
rc = test_create_race("smurf");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
|
||||
CuAssertTrue(tc, cansee(f, u2->region, u2, 0));
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 0, seen_unit));
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 0, seen_spell));
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 0, seen_battle));
|
||||
CuAssertTrue(tc, !visible_unit(u2, f, 0, seen_travel));
|
||||
CuAssertTrue(tc, !visible_unit(u2, f, 0, seen_none));
|
||||
CuAssertTrue(tc, !visible_unit(u2, f, 0, seen_neighbour));
|
||||
CuAssertTrue(tc, cansee(f, u->region, u, 0));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_unit));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_spell));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_battle));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_travel));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_none));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, 0, seen_neighbour));
|
||||
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 0, seen_lighthouse));
|
||||
CuAssertTrue(tc, !visible_unit(u2, f, -2, seen_lighthouse));
|
||||
u2->ship = sh;
|
||||
CuAssertTrue(tc, visible_unit(u2, f, -2, seen_lighthouse));
|
||||
u2->ship = NULL;
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_lighthouse));
|
||||
CuAssertTrue(tc, !visible_unit(u, f, -2, seen_lighthouse));
|
||||
|
||||
set_level(u2, SK_STEALTH, 1);
|
||||
CuAssertTrue(tc, !cansee(f, u2->region, u2, 0));
|
||||
CuAssertTrue(tc, cansee(f, u2->region, u2, 1));
|
||||
u->ship = sh = test_create_ship(u->region, NULL);
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
|
||||
u->ship = NULL;
|
||||
|
||||
u2->ship = sh;
|
||||
CuAssertTrue(tc, visible_unit(u2, f, -2, seen_lighthouse));
|
||||
u2->ship = NULL;
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 1, seen_spell));
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 1, seen_battle));
|
||||
setguard(u, true);
|
||||
CuAssertTrue(tc, is_guard(u));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
|
||||
setguard(u, false);
|
||||
|
||||
u->building = b = test_create_building(u->region, NULL);
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_travel));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
|
||||
u->building = NULL;
|
||||
|
||||
set_level(u, SK_STEALTH, 1);
|
||||
CuAssertTrue(tc, !cansee(f, u->region, u, 0));
|
||||
CuAssertTrue(tc, cansee(f, u->region, u, 1));
|
||||
|
||||
u->ship = sh;
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_travel));
|
||||
u->ship = NULL;
|
||||
|
||||
u->building = b;
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_lighthouse));
|
||||
CuAssertTrue(tc, visible_unit(u, f, -2, seen_travel));
|
||||
u->building = NULL;
|
||||
|
||||
CuAssertTrue(tc, visible_unit(u, f, 1, seen_spell));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 1, seen_battle));
|
||||
|
||||
test_teardown();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue