forked from github/server
remove the BLD_WORKING flag.
it's all about BLD_MAINTAINED now. fix region.blocked (Lua property).
This commit is contained in:
parent
d3e05c7ddf
commit
a42bd9c3bf
|
@ -1097,13 +1097,6 @@
|
||||||
<text locale="de">"Plötzlich löst sich $building($building) in kleine Traumwolken auf."</text>
|
<text locale="de">"Plötzlich löst sich $building($building) in kleine Traumwolken auf."</text>
|
||||||
<text locale="en">"$building($building) suddenly dissolves into small pink clouds."</text>
|
<text locale="en">"$building($building) suddenly dissolves into small pink clouds."</text>
|
||||||
</message>
|
</message>
|
||||||
<message name="maintenance_none" section="events">
|
|
||||||
<type>
|
|
||||||
<arg name="building" type="building"/>
|
|
||||||
</type>
|
|
||||||
<text locale="de">"Für das Gebäude $building($building) konnte die ganze Woche kein Unterhalt bezahlt werden."</text>
|
|
||||||
<text locale="en">"Upkeep for $building($building) could not be paid all week."</text>
|
|
||||||
</message>
|
|
||||||
<message name="buildingcrash" section="events">
|
<message name="buildingcrash" section="events">
|
||||||
<type>
|
<type>
|
||||||
<arg name="region" type="region"/>
|
<arg name="region" type="region"/>
|
||||||
|
|
|
@ -52,15 +52,15 @@ static int tolua_building_set_working(lua_State * L)
|
||||||
{
|
{
|
||||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||||
bool flag = !!lua_toboolean(L, 2);
|
bool flag = !!lua_toboolean(L, 2);
|
||||||
if (flag) self->flags |= BLD_WORKING;
|
if (flag) self->flags |= BLD_MAINTAINED;
|
||||||
else self->flags &= ~BLD_WORKING;
|
else self->flags &= ~BLD_MAINTAINED;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tolua_building_get_working(lua_State * L)
|
static int tolua_building_get_working(lua_State * L)
|
||||||
{
|
{
|
||||||
building *self = (building *)tolua_tousertype(L, 1, 0);
|
building *self = (building *)tolua_tousertype(L, 1, 0);
|
||||||
bool flag = (self->flags&BLD_WORKING) != 0;
|
bool flag = (self->flags&BLD_MAINTAINED) != 0;
|
||||||
lua_pushboolean(L, flag);
|
lua_pushboolean(L, flag);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,8 @@ static int tolua_region_set_blocked(lua_State * L)
|
||||||
{
|
{
|
||||||
region *self = (region *)tolua_tousertype(L, 1, 0);
|
region *self = (region *)tolua_tousertype(L, 1, 0);
|
||||||
bool flag = !!tolua_toboolean(L, 2, 1);
|
bool flag = !!tolua_toboolean(L, 2, 1);
|
||||||
if (flag) self->flags |= BLD_WORKING;
|
if (flag) self->flags |= RF_BLOCKED;
|
||||||
else self->flags &= ~BLD_WORKING;
|
else self->flags &= ~RF_BLOCKED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -717,7 +717,7 @@ static int maintain(building * b)
|
||||||
unit *u;
|
unit *u;
|
||||||
|
|
||||||
if (fval(b, BLD_MAINTAINED) || b->type == NULL || b->type->maintenance == NULL) {
|
if (fval(b, BLD_MAINTAINED) || b->type == NULL || b->type->maintenance == NULL) {
|
||||||
return (BLD_MAINTAINED|BLD_WORKING);
|
return BLD_MAINTAINED;
|
||||||
}
|
}
|
||||||
if (fval(b, BLD_DONTPAY)) {
|
if (fval(b, BLD_DONTPAY)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -801,7 +801,7 @@ static int maintain(building * b)
|
||||||
}
|
}
|
||||||
if (work) {
|
if (work) {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("maintenance", "unit building", u, b));
|
ADDMSG(&u->faction->msgs, msg_message("maintenance", "unit building", u, b));
|
||||||
return (BLD_MAINTAINED | BLD_WORKING);
|
return BLD_MAINTAINED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ADDMSG(&u->faction->msgs, msg_message("maintenancefail", "unit building", u, b));
|
ADDMSG(&u->faction->msgs, msg_message("maintenancefail", "unit building", u, b));
|
||||||
|
@ -814,19 +814,16 @@ void maintain_buildings(region * r)
|
||||||
building **bp = &r->buildings;
|
building **bp = &r->buildings;
|
||||||
while (*bp) {
|
while (*bp) {
|
||||||
building *b = *bp;
|
building *b = *bp;
|
||||||
int flags = (BLD_MAINTAINED | BLD_WORKING);
|
int flags = BLD_MAINTAINED;
|
||||||
|
|
||||||
if (!curse_active(get_curse(b->attribs, nocost_ct))) {
|
if (!curse_active(get_curse(b->attribs, nocost_ct))) {
|
||||||
flags = maintain(b);
|
flags = maintain(b);
|
||||||
}
|
}
|
||||||
fset(b, flags);
|
fset(b, flags);
|
||||||
|
|
||||||
if (!fval(b, BLD_WORKING)) {
|
if (!fval(b, BLD_MAINTAINED)) {
|
||||||
unit *u = building_owner(b);
|
unit *u = building_owner(b);
|
||||||
const char *msgtype =
|
struct message *msg = msg_message("maintenance_nowork", "building", b);
|
||||||
flags ? "maintenance_nowork" : "maintenance_none";
|
|
||||||
struct message *msg = msg_message(msgtype, "building", b);
|
|
||||||
|
|
||||||
if (u) {
|
if (u) {
|
||||||
add_message(&u->faction->msgs, msg);
|
add_message(&u->faction->msgs, msg);
|
||||||
r_addmessage(r, u->faction, msg);
|
r_addmessage(r, u->faction, msg);
|
||||||
|
|
|
@ -805,7 +805,7 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
||||||
/* build a new building */
|
/* build a new building */
|
||||||
b = new_building(btype, r, lang);
|
b = new_building(btype, r, lang);
|
||||||
b->type = btype;
|
b->type = btype;
|
||||||
fset(b, BLD_MAINTAINED | BLD_WORKING);
|
fset(b, BLD_MAINTAINED);
|
||||||
|
|
||||||
/* Die Einheit befindet sich automatisch im Inneren der neuen Burg. */
|
/* Die Einheit befindet sich automatisch im Inneren der neuen Burg. */
|
||||||
if (u->number && leave(u, false)) {
|
if (u->number && leave(u, false)) {
|
||||||
|
|
|
@ -83,7 +83,7 @@ static void test_build_requires_building(CuTest *tc) {
|
||||||
btype->capacity = 1;
|
btype->capacity = 1;
|
||||||
CuAssertIntEquals_Msg(tc, "must be inside a production building", EBUILDINGREQ, build(u, &bf.cons, 0, 1));
|
CuAssertIntEquals_Msg(tc, "must be inside a production building", EBUILDINGREQ, build(u, &bf.cons, 0, 1));
|
||||||
u->building = test_create_building(u->region, btype);
|
u->building = test_create_building(u->region, btype);
|
||||||
fset(u->building, BLD_WORKING);
|
fset(u->building, BLD_MAINTAINED);
|
||||||
CuAssertIntEquals(tc, 1, build(u, &bf.cons, 0, 1));
|
CuAssertIntEquals(tc, 1, build(u, &bf.cons, 0, 1));
|
||||||
btype->maxcapacity = 0;
|
btype->maxcapacity = 0;
|
||||||
CuAssertIntEquals_Msg(tc, "cannot build when production building capacity exceeded", EBUILDINGREQ, build(u, &bf.cons, 0, 1));
|
CuAssertIntEquals_Msg(tc, "cannot build when production building capacity exceeded", EBUILDINGREQ, build(u, &bf.cons, 0, 1));
|
||||||
|
|
|
@ -648,7 +648,7 @@ buildingtype_exists(const region * r, const building_type * bt, bool working)
|
||||||
building *b;
|
building *b;
|
||||||
|
|
||||||
for (b = rbuildings(r); b; b = b->next) {
|
for (b = rbuildings(r); b; b = b->next) {
|
||||||
if (b->type == bt && (!working || fval(b, BLD_WORKING)) && building_finished(b)) {
|
if (b->type == bt && (!working || fval(b, BLD_MAINTAINED)) && building_finished(b)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ bool building_finished(const struct building *b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool building_is_active(const struct building *b) {
|
bool building_is_active(const struct building *b) {
|
||||||
return b && fval(b, BLD_WORKING) && building_finished(b);
|
return b && fval(b, BLD_MAINTAINED) && building_finished(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
building *active_building(const unit *u, const struct building_type *btype) {
|
building *active_building(const unit *u, const struct building_type *btype) {
|
||||||
|
|
|
@ -95,11 +95,10 @@ extern "C" {
|
||||||
|
|
||||||
#define BFL_NONE 0x00
|
#define BFL_NONE 0x00
|
||||||
#define BLD_MAINTAINED 0x01 /* vital maintenance paid for */
|
#define BLD_MAINTAINED 0x01 /* vital maintenance paid for */
|
||||||
#define BLD_WORKING 0x02 /* full maintenance paid, it works */
|
#define BLD_DONTPAY 0x02 /* PAY NOT */
|
||||||
#define BLD_UNGUARDED 0x04 /* you can enter this building anytime */
|
#define BLD_UNGUARDED 0x04 /* you can enter this building anytime */
|
||||||
#define BLD_EXPANDED 0x08 /* has been expanded this turn */
|
#define BLD_EXPANDED 0x08 /* has been expanded this turn */
|
||||||
#define BLD_SELECT 0x10 /* formerly FL_DH */
|
#define BLD_SELECT 0x10 /* formerly FL_DH */
|
||||||
#define BLD_DONTPAY 0x20 /* PAY NOT */
|
|
||||||
|
|
||||||
#define BLD_SAVEMASK 0x00 /* mask for persistent flags */
|
#define BLD_SAVEMASK 0x00 /* mask for persistent flags */
|
||||||
|
|
||||||
|
|
|
@ -409,17 +409,17 @@ static void test_buildingtype_exists(CuTest * tc)
|
||||||
|
|
||||||
CuAssertTrue(tc, buildingtype_exists(r, btype, false));
|
CuAssertTrue(tc, buildingtype_exists(r, btype, false));
|
||||||
b->size = 9;
|
b->size = 9;
|
||||||
fset(b, BLD_WORKING);
|
fset(b, BLD_MAINTAINED);
|
||||||
CuAssertTrue(tc, !buildingtype_exists(r, btype, false));
|
CuAssertTrue(tc, !buildingtype_exists(r, btype, false));
|
||||||
btype->maxsize = 0;
|
btype->maxsize = 0;
|
||||||
freset(b, BLD_WORKING);
|
freset(b, BLD_MAINTAINED);
|
||||||
CuAssertTrue(tc, buildingtype_exists(r, btype, false));
|
CuAssertTrue(tc, buildingtype_exists(r, btype, false));
|
||||||
btype->maxsize = 10;
|
btype->maxsize = 10;
|
||||||
b->size = 10;
|
b->size = 10;
|
||||||
|
|
||||||
fset(b, BLD_WORKING);
|
fset(b, BLD_MAINTAINED);
|
||||||
CuAssertTrue(tc, buildingtype_exists(r, btype, true));
|
CuAssertTrue(tc, buildingtype_exists(r, btype, true));
|
||||||
freset(b, BLD_WORKING);
|
freset(b, BLD_MAINTAINED);
|
||||||
CuAssertTrue(tc, !buildingtype_exists(r, btype, true));
|
CuAssertTrue(tc, !buildingtype_exists(r, btype, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ static void test_active_building(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, false, building_is_active(b));
|
CuAssertIntEquals(tc, false, building_is_active(b));
|
||||||
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
||||||
|
|
||||||
b->flags |= BLD_WORKING;
|
b->flags |= BLD_MAINTAINED;
|
||||||
CuAssertIntEquals(tc, true, building_is_active(b));
|
CuAssertIntEquals(tc, true, building_is_active(b));
|
||||||
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
||||||
u_set_building(u, b);
|
u_set_building(u, b);
|
||||||
|
@ -452,7 +452,7 @@ static void test_active_building(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, false, building_is_active(b));
|
CuAssertIntEquals(tc, false, building_is_active(b));
|
||||||
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
||||||
btype->maxsize = -1;
|
btype->maxsize = -1;
|
||||||
b->flags &= ~BLD_WORKING;
|
b->flags &= ~BLD_MAINTAINED;
|
||||||
CuAssertIntEquals(tc, false, building_is_active(b));
|
CuAssertIntEquals(tc, false, building_is_active(b));
|
||||||
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
|
|
@ -66,7 +66,7 @@ void update_lighthouse(building * lh)
|
||||||
int lighthouse_range(const building * b, const faction * f)
|
int lighthouse_range(const building * b, const faction * f)
|
||||||
{
|
{
|
||||||
int d = 0;
|
int d = 0;
|
||||||
if (fval(b, BLD_WORKING) && b->size >= 10) {
|
if (fval(b, BLD_MAINTAINED) && b->size >= 10) {
|
||||||
int maxd = (int)log10(b->size) + 1;
|
int maxd = (int)log10(b->size) + 1;
|
||||||
|
|
||||||
if (skill_enabled(SK_PERCEPTION)) {
|
if (skill_enabled(SK_PERCEPTION)) {
|
||||||
|
@ -112,7 +112,7 @@ bool check_leuchtturm(region * r, faction * f)
|
||||||
building *b = (building *)a->data.v;
|
building *b = (building *)a->data.v;
|
||||||
|
|
||||||
assert(b->type == bt_find("lighthouse"));
|
assert(b->type == bt_find("lighthouse"));
|
||||||
if (fval(b, BLD_WORKING) && b->size >= 10) {
|
if (fval(b, BLD_MAINTAINED) && b->size >= 10) {
|
||||||
int maxd = (int)log10(b->size) + 1;
|
int maxd = (int)log10(b->size) + 1;
|
||||||
|
|
||||||
if (skill_enabled(SK_PERCEPTION) && f) {
|
if (skill_enabled(SK_PERCEPTION) && f) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ static void test_market_curse(CuTest * tc)
|
||||||
}
|
}
|
||||||
r = findregion(1, 1);
|
r = findregion(1, 1);
|
||||||
b = test_create_building(r, btype);
|
b = test_create_building(r, btype);
|
||||||
b->flags |= BLD_WORKING;
|
b->flags |= BLD_MAINTAINED;
|
||||||
b->size = b->type->maxsize;
|
b->size = b->type->maxsize;
|
||||||
|
|
||||||
f = test_create_faction(0);
|
f = test_create_faction(0);
|
||||||
|
|
|
@ -76,7 +76,7 @@ static void setup_harbor(move_fixture *mf) {
|
||||||
r = test_create_region(0, 0, ttype);
|
r = test_create_region(0, 0, ttype);
|
||||||
|
|
||||||
b = test_create_building(r, btype);
|
b = test_create_building(r, btype);
|
||||||
b->flags |= BLD_WORKING;
|
b->flags |= BLD_MAINTAINED;
|
||||||
|
|
||||||
u = test_create_unit(test_create_faction(0), r);
|
u = test_create_unit(test_create_faction(0), r);
|
||||||
u->ship = sh;
|
u->ship = sh;
|
||||||
|
|
|
@ -161,7 +161,7 @@ static void test_study_bug_2194(CuTest *tc) {
|
||||||
u_set_building(u2, b);
|
u_set_building(u2, b);
|
||||||
i_change(&u1->items, get_resourcetype(R_SILVER)->itype, 50);
|
i_change(&u1->items, get_resourcetype(R_SILVER)->itype, 50);
|
||||||
i_change(&u2->items, get_resourcetype(R_SILVER)->itype, 50);
|
i_change(&u2->items, get_resourcetype(R_SILVER)->itype, 50);
|
||||||
b->flags = BLD_WORKING;
|
b->flags = BLD_MAINTAINED;
|
||||||
learn_inject();
|
learn_inject();
|
||||||
teach_cmd(u, u->thisorder);
|
teach_cmd(u, u->thisorder);
|
||||||
learn_reset();
|
learn_reset();
|
||||||
|
@ -236,7 +236,7 @@ static void test_academy_building(CuTest *tc) {
|
||||||
u_set_building(u2, b);
|
u_set_building(u2, b);
|
||||||
i_change(&u1->items, get_resourcetype(R_SILVER)->itype, 50);
|
i_change(&u1->items, get_resourcetype(R_SILVER)->itype, 50);
|
||||||
i_change(&u2->items, get_resourcetype(R_SILVER)->itype, 50);
|
i_change(&u2->items, get_resourcetype(R_SILVER)->itype, 50);
|
||||||
b->flags = BLD_WORKING;
|
b->flags = BLD_MAINTAINED;
|
||||||
learn_inject();
|
learn_inject();
|
||||||
teach_cmd(u, u->thisorder);
|
teach_cmd(u, u->thisorder);
|
||||||
learn_reset();
|
learn_reset();
|
||||||
|
|
Loading…
Reference in New Issue