diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..9cebe6d6d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,26 @@
+# EditorConfig is awesome: http://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+end_of_line = lf
+insert_final_newline = true
+
+# 4 space indentation
+[*.{c,h,lua}]
+indent_style = space
+indent_size = 4
+
+[*.{xml,json}]
+charset = utf-8
+
+# Tab indentation (no size specified)
+[Makefile]
+indent_style = tab
+
+# Matches exact files
+[.travis.yml]
+indent_style = space
+indent_size = 2
diff --git a/res/e3a/buildings.xml b/res/e3a/buildings.xml
index 231596dc6..e8ffe2102 100644
--- a/res/e3a/buildings.xml
+++ b/res/e3a/buildings.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/src/kernel/build.c b/src/kernel/build.c
index f3c74bf95..97e5e84d0 100644
--- a/src/kernel/build.c
+++ b/src/kernel/build.c
@@ -849,7 +849,6 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
b->size += built;
if (b->type->maxsize > 0 && b->size > b->type->maxsize) {
- // this seems to be okay for a watch, but is not okay for an academy or harbour
log_error("build: %s has size=%d, maxsize=%d", buildingname(b), b->size, b->type->maxsize);
}
fset(b, BLD_EXPANDED);
diff --git a/src/kernel/building.c b/src/kernel/building.c
index f0e46cc7e..e7c60ea9a 100644
--- a/src/kernel/building.c
+++ b/src/kernel/building.c
@@ -132,7 +132,7 @@ int buildingcapacity(const building * b)
}
return b->size * b->type->capacity;
}
- if (b->size >= b->type->maxsize) {
+ if (building_finished(b)) {
if (b->type->maxcapacity >= 0) {
return b->type->maxcapacity;
}
@@ -648,15 +648,20 @@ buildingtype_exists(const region * r, const building_type * bt, bool working)
building *b;
for (b = rbuildings(r); b; b = b->next) {
- if (b->type == bt && b->size >= bt->maxsize && (!working || fval(b, BLD_WORKING)))
+ if (b->type == bt && (!working || fval(b, BLD_WORKING)) && building_finished(b)) {
return true;
+ }
}
return false;
}
+bool building_finished(const struct building *b) {
+ return b->size >= b->type->maxsize;
+}
+
bool building_is_active(const struct building *b) {
- return b && fval(b, BLD_WORKING) && b->size >= b->type->maxsize;
+ return b && fval(b, BLD_WORKING) && building_finished(b);
}
building *active_building(const unit *u, const struct building_type *btype) {
diff --git a/src/kernel/building.h b/src/kernel/building.h
index 766242c4a..52b715c59 100644
--- a/src/kernel/building.h
+++ b/src/kernel/building.h
@@ -92,15 +92,7 @@ extern "C" {
const struct building *b, int bsize);
bool in_safe_building(struct unit *u1, struct unit *u2);
- /* buildingt => building_type
- * Name => locale_string(name)
- * MaxGroesse => levels
- * MinBauTalent => construction->minskill
- * Kapazitaet => capacity, maxcapacity
- * Materialien => construction->materials
- * UnterSilber, UnterSpezialTyp, UnterSpezial => maintenance
- * per_size => !maintenance->fixed
- */
+
#define BFL_NONE 0x00
#define BLD_MAINTAINED 0x01 /* vital maintenance paid for */
#define BLD_WORKING 0x02 /* full maintenance paid, it works */
@@ -138,6 +130,7 @@ extern "C" {
struct region *r, const struct locale *lang);
int build_building(struct unit *u, const struct building_type *typ,
int id, int size, struct order *ord);
+ bool building_finished(const struct building *b);
/* Alte Gebäudetypen: */
@@ -173,10 +166,6 @@ extern "C" {
bool building_is_active(const struct building *b);
struct building *active_building(const struct unit *u, const struct building_type *btype);
-#ifdef WDW_PYRAMID
- extern int wdw_pyramid_level(const struct building *b);
-#endif
-
extern const char *buildingname(const struct building *b);
extern const char *building_getname(const struct building *b);
diff --git a/src/kernel/save.c b/src/kernel/save.c
index fd82bed96..2379db877 100644
--- a/src/kernel/save.c
+++ b/src/kernel/save.c
@@ -1676,6 +1676,7 @@ int read_game(gamedata *data) {
if (b->type == bt_lighthouse) {
r->flags |= RF_LIGHTHOUSE;
}
+
// repairs, bug 2221:
if (b->type->maxsize>0 && b->size>b->type->maxsize) {
log_error("building too big: %s (%s size %d of %d), fixing.", buildingname(b), b->type->_name, b->size, b->type->maxsize);
diff --git a/src/kernel/unit.c b/src/kernel/unit.c
index e41e5b006..09b3d80a9 100644
--- a/src/kernel/unit.c
+++ b/src/kernel/unit.c
@@ -1044,7 +1044,7 @@ struct building *inside_building(const struct unit *u)
if (!u->building) {
return NULL;
}
- else if (u->building->size < u->building->type->maxsize) {
+ else if (!building_finished(u->building)) {
/* Gebaeude noch nicht fertig */
return NULL;
}
diff --git a/src/kernel/version.h b/src/kernel/version.h
index 7ef7d9c36..4aab16f5f 100644
--- a/src/kernel/version.h
+++ b/src/kernel/version.h
@@ -10,7 +10,7 @@
without prior permission by the authors of Eressea.
*/
-#define INTPAK_VERSION 329 /* in binary, ints can get packed */
+#define INTPAK_VERSION 329 /* in binary, ints can get packed. starting with E2/572 */
#define NOZEROIDS_VERSION 330 /* 2008-05-16 zero is not a valid ID for anything (including factions) */
#define NOBORDERATTRIBS_VERSION 331 /* 2008-05-17 connection::attribs has been moved to userdata */
#define UIDHASH_VERSION 332 /* 2008-05-22 borders use the region.uid to store */
diff --git a/src/move.c b/src/move.c
index e7ca523b5..6c5950c1f 100644
--- a/src/move.c
+++ b/src/move.c
@@ -1758,7 +1758,7 @@ unit *owner_buildingtyp(const region * r, const building_type * bt)
for (b = rbuildings(r); b; b = b->next) {
owner = building_owner(b);
if (b->type == bt && owner != NULL) {
- if (b->size >= bt->maxsize) {
+ if (building_finished(b)) {
return owner;
}
}
diff --git a/src/report.c b/src/report.c
index 15c5f1b2c..229b16332 100644
--- a/src/report.c
+++ b/src/report.c
@@ -1898,7 +1898,7 @@ const faction * f)
}
}
- if (b->size < b->type->maxsize) {
+ if (!building_finished(b)) {
bytes = (int)strlcpy(bufp, LOC(lang, "nr_building_inprogress"), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
diff --git a/src/spells.c b/src/spells.c
index b93c373ae..1da440df2 100644
--- a/src/spells.c
+++ b/src/spells.c
@@ -975,7 +975,7 @@ static int sp_blessstonecircle(castorder * co)
return 0;
}
- if (b->size < b->type->maxsize) {
+ if (!building_finished(b)) {
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
"error_notcomplete", "building", b));
return 0;
@@ -4502,11 +4502,11 @@ int sp_icastle(castorder * co)
if (type == bt_illusion) {
b->size = (rng_int() % (int)((power * power) + 1) * 10);
}
- else if (type->maxsize == -1) {
- b->size = ((rng_int() % (int)(power)) + 1) * 5;
+ else if (type->maxsize >0) {
+ b->size = type->maxsize;
}
else {
- b->size = type->maxsize;
+ b->size = ((rng_int() % (int)(power)) + 1) * 5;
}
if (type->name == NULL) {
diff --git a/src/wormhole.c b/src/wormhole.c
index 36e04e9e0..916c0509d 100644
--- a/src/wormhole.c
+++ b/src/wormhole.c
@@ -149,8 +149,7 @@ make_wormhole(const building_type * bt_wormhole, region * r1, region * r2)
attrib *a2 = a_add(&b2->attribs, a_new(&at_wormhole));
a1->data.v = b2->region;
a2->data.v = b1->region;
- b1->size = bt_wormhole->maxsize;
- b2->size = bt_wormhole->maxsize;
+ b1->size = b2->size = bt_wormhole->maxcapacity * bt_wormhole->capacity;
ADDMSG(&r1->msgs, msg_message("wormhole_appear", "region", r1));
ADDMSG(&r2->msgs, msg_message("wormhole_appear", "region", r2));
}