forked from github/server
as much as possible, replace the UFL_OWNER flag with checking the owner the canonical way.
This commit is contained in:
parent
95d1203594
commit
775e8edae1
|
@ -170,13 +170,7 @@ static int tolua_building_set_owner(lua_State * L)
|
||||||
{
|
{
|
||||||
building *b = (building *) tolua_tousertype(L, 1, 0);
|
building *b = (building *) tolua_tousertype(L, 1, 0);
|
||||||
unit *u = (unit *) tolua_tousertype(L, 2, 0);
|
unit *u = (unit *) tolua_tousertype(L, 2, 0);
|
||||||
unit *o = b ? building_owner(b) : NULL;
|
building_set_owner(b, u);
|
||||||
if (o && o != u) {
|
|
||||||
freset(o, UFL_OWNER);
|
|
||||||
}
|
|
||||||
if (u) {
|
|
||||||
fset(u, UFL_OWNER);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1351,27 +1351,29 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
||||||
ru && ru->type == &at_travelunit; ru = ru->next) {
|
ru && ru->type == &at_travelunit; ru = ru->next) {
|
||||||
unit *u = (unit *) ru->data.v;
|
unit *u = (unit *) ru->data.v;
|
||||||
if (cansee_durchgezogen(f, r, u, 0) && r != u->region) {
|
if (cansee_durchgezogen(f, r, u, 0) && r != u->region) {
|
||||||
if (!u->ship || !fval(u, UFL_OWNER))
|
if (u->ship && ship_owner(u->ship)==u) {
|
||||||
continue;
|
if (!seeships) {
|
||||||
if (!seeships)
|
|
||||||
fprintf(F, "DURCHSCHIFFUNG\n");
|
fprintf(F, "DURCHSCHIFFUNG\n");
|
||||||
|
}
|
||||||
seeships = true;
|
seeships = true;
|
||||||
fprintf(F, "\"%s\"\n", shipname(u->ship));
|
fprintf(F, "\"%s\"\n", shipname(u->ship));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (ru = a_find(r->attribs, &at_travelunit);
|
for (ru = a_find(r->attribs, &at_travelunit);
|
||||||
ru && ru->type == &at_travelunit; ru = ru->next) {
|
ru && ru->type == &at_travelunit; ru = ru->next) {
|
||||||
unit *u = (unit *) ru->data.v;
|
unit *u = (unit *) ru->data.v;
|
||||||
if (cansee_durchgezogen(f, r, u, 0) && r != u->region) {
|
if (cansee_durchgezogen(f, r, u, 0) && r != u->region) {
|
||||||
if (u->ship)
|
if (!u->ship) {
|
||||||
continue;
|
if (!seeunits) {
|
||||||
if (!seeunits)
|
|
||||||
fprintf(F, "DURCHREISE\n");
|
fprintf(F, "DURCHREISE\n");
|
||||||
|
}
|
||||||
seeunits = true;
|
seeunits = true;
|
||||||
fprintf(F, "\"%s\"\n", unitname(u));
|
fprintf(F, "\"%s\"\n", unitname(u));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cr_output_messages(F, r->msgs, f);
|
cr_output_messages(F, r->msgs, f);
|
||||||
{
|
{
|
||||||
message_list *mlist = r_getmessages(r, f);
|
message_list *mlist = r_getmessages(r, f);
|
||||||
|
|
|
@ -1105,51 +1105,6 @@ static boolean maintain(building * b, boolean first)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef COLLAPSE_CHANCE
|
|
||||||
static void gebaeude_stuerzt_ein(region * r, building * b)
|
|
||||||
{
|
|
||||||
unit *u;
|
|
||||||
int n, i;
|
|
||||||
int opfer = 0;
|
|
||||||
int road = 0;
|
|
||||||
struct message *msg;
|
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
|
||||||
if (u->building == b) {
|
|
||||||
int loss = 0;
|
|
||||||
|
|
||||||
fset(u->faction, FFL_MARK);
|
|
||||||
freset(u, UFL_OWNER);
|
|
||||||
leave(r, u);
|
|
||||||
n = u->number;
|
|
||||||
#ifdef COLLAPSE_SURVIVAL
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
if (rng_double() >= COLLAPSE_SURVIVAL) {
|
|
||||||
++loss;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
scale_number(u, u->number - loss);
|
|
||||||
opfer += loss;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
msg =
|
|
||||||
msg_message("buildingcrash", "region building opfer road", r, b, opfer,
|
|
||||||
road);
|
|
||||||
add_message(&r->msgs, msg);
|
|
||||||
for (u = r->units; u; u = u->next) {
|
|
||||||
faction *f = u->faction;
|
|
||||||
if (fval(f, FFL_MARK)) {
|
|
||||||
freset(u->faction, FFL_MARK);
|
|
||||||
add_message(&f->msgs, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg_release(msg);
|
|
||||||
remove_building(&r->buildings, b);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void maintain_buildings(region * r, boolean crash)
|
void maintain_buildings(region * r, boolean crash)
|
||||||
{
|
{
|
||||||
building **bp = &r->buildings;
|
building **bp = &r->buildings;
|
||||||
|
@ -1159,12 +1114,6 @@ void maintain_buildings(region * r, boolean crash)
|
||||||
|
|
||||||
/* the second time, send a message */
|
/* the second time, send a message */
|
||||||
if (crash) {
|
if (crash) {
|
||||||
#ifdef COLLAPSE_CHANCE
|
|
||||||
if (!maintained && (rng_double() < COLLAPSE_CHANCE)) {
|
|
||||||
gebaeude_stuerzt_ein(r, b);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!fval(b, BLD_WORKING)) {
|
if (!fval(b, BLD_WORKING)) {
|
||||||
unit *u = building_owner(b);
|
unit *u = building_owner(b);
|
||||||
const char *msgtype =
|
const char *msgtype =
|
||||||
|
|
|
@ -1203,7 +1203,7 @@ static void nmr_death(faction * f)
|
||||||
if (rule) {
|
if (rule) {
|
||||||
unit *u;
|
unit *u;
|
||||||
for (u = f->units; u; u = u->nextF) {
|
for (u = f->units; u; u = u->nextF) {
|
||||||
if (u->building && fval(u, UFL_OWNER)) {
|
if (u->building && building_owner(u->building)==u) {
|
||||||
remove_building(&u->region->buildings, u->building);
|
remove_building(&u->region->buildings, u->building);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1526,7 +1526,6 @@ static cmp_building_cb get_cmp_region_owner(void)
|
||||||
|
|
||||||
static int display_cmd(unit * u, struct order *ord)
|
static int display_cmd(unit * u, struct order *ord)
|
||||||
{
|
{
|
||||||
building *b = u->building;
|
|
||||||
char **s = NULL;
|
char **s = NULL;
|
||||||
const char *str;
|
const char *str;
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
|
@ -1538,19 +1537,19 @@ static int display_cmd(unit * u, struct order *ord)
|
||||||
switch (findparam_ex(str, u->faction->locale)) {
|
switch (findparam_ex(str, u->faction->locale)) {
|
||||||
case P_BUILDING:
|
case P_BUILDING:
|
||||||
case P_GEBAEUDE:
|
case P_GEBAEUDE:
|
||||||
if (!b) {
|
if (!u->building) {
|
||||||
cmistake(u, ord, 145, MSG_PRODUCE);
|
cmistake(u, ord, 145, MSG_PRODUCE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!fval(u, UFL_OWNER)) {
|
if (building_owner(u->building)!=u) {
|
||||||
cmistake(u, ord, 5, MSG_PRODUCE);
|
cmistake(u, ord, 5, MSG_PRODUCE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!fval(b->type, BTF_NAMECHANGE) && b->display && b->display[0] != 0) {
|
if (!fval(u->building->type, BTF_NAMECHANGE) && u->building->display && u->building->display[0]) {
|
||||||
cmistake(u, ord, 278, MSG_EVENT);
|
cmistake(u, ord, 278, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s = &b->display;
|
s = &u->building->display;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_SHIP:
|
case P_SHIP:
|
||||||
|
@ -1558,7 +1557,7 @@ static int display_cmd(unit * u, struct order *ord)
|
||||||
cmistake(u, ord, 144, MSG_PRODUCE);
|
cmistake(u, ord, 144, MSG_PRODUCE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!fval(u, UFL_OWNER)) {
|
if (ship_owner(u->ship)!=u) {
|
||||||
cmistake(u, ord, 12, MSG_PRODUCE);
|
cmistake(u, ord, 12, MSG_PRODUCE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1581,15 +1580,15 @@ static int display_cmd(unit * u, struct order *ord)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_REGION:
|
case P_REGION:
|
||||||
if (!b) {
|
if (!u->building) {
|
||||||
cmistake(u, ord, 145, MSG_EVENT);
|
cmistake(u, ord, 145, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!fval(u, UFL_OWNER)) {
|
if (building_owner(u->building)!=u) {
|
||||||
cmistake(u, ord, 148, MSG_EVENT);
|
cmistake(u, ord, 148, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (b != largestbuilding(r, get_cmp_region_owner(), false)) {
|
if (u->building != largestbuilding(r, get_cmp_region_owner(), false)) {
|
||||||
cmistake(u, ord, 147, MSG_EVENT);
|
cmistake(u, ord, 147, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1682,7 +1681,7 @@ rename_building(unit * u, order * ord, building * b, const char *name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!fval(u, UFL_OWNER)) {
|
if (owner!=u) {
|
||||||
cmistake(u, ord, 148, MSG_PRODUCE);
|
cmistake(u, ord, 148, MSG_PRODUCE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1814,7 +1813,7 @@ static int name_cmd(unit * u, struct order *ord)
|
||||||
cmistake(u, ord, 144, MSG_PRODUCE);
|
cmistake(u, ord, 144, MSG_PRODUCE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!fval(u, UFL_OWNER)) {
|
if (ship_owner(u->ship)!=u) {
|
||||||
cmistake(u, ord, 12, MSG_PRODUCE);
|
cmistake(u, ord, 12, MSG_PRODUCE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1857,7 +1856,7 @@ static int name_cmd(unit * u, struct order *ord)
|
||||||
cmistake(u, ord, 145, MSG_EVENT);
|
cmistake(u, ord, 145, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!fval(u, UFL_OWNER)) {
|
if (building_owner(b)!=u) {
|
||||||
cmistake(u, ord, 148, MSG_EVENT);
|
cmistake(u, ord, 148, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2881,7 +2880,9 @@ static void reorder(void)
|
||||||
cmistake(u, ord, 258, MSG_EVENT);
|
cmistake(u, ord, 258, MSG_EVENT);
|
||||||
} else if (v->building != u->building || v->ship != u->ship) {
|
} else if (v->building != u->building || v->ship != u->ship) {
|
||||||
cmistake(u, ord, 259, MSG_EVENT);
|
cmistake(u, ord, 259, MSG_EVENT);
|
||||||
} else if (fval(u, UFL_OWNER)) {
|
} else if (u->building && building_owner(u->building)==u) {
|
||||||
|
cmistake(u, ord, 260, MSG_EVENT);
|
||||||
|
} else if (u->ship && ship_owner(u->ship)==u) {
|
||||||
cmistake(u, ord, 260, MSG_EVENT);
|
cmistake(u, ord, 260, MSG_EVENT);
|
||||||
} else if (v == u) {
|
} else if (v == u) {
|
||||||
cmistake(u, ord, 10, MSG_EVENT);
|
cmistake(u, ord, 10, MSG_EVENT);
|
||||||
|
@ -2895,7 +2896,9 @@ static void reorder(void)
|
||||||
sorted = true;
|
sorted = true;
|
||||||
break;
|
break;
|
||||||
case P_BEFORE:
|
case P_BEFORE:
|
||||||
if (fval(v, UFL_OWNER)) {
|
if (v->ship && ship_owner(v->ship)==v) {
|
||||||
|
cmistake(v, ord, 261, MSG_EVENT);
|
||||||
|
} else if (v->building && building_owner(v->building)==v) {
|
||||||
cmistake(v, ord, 261, MSG_EVENT);
|
cmistake(v, ord, 261, MSG_EVENT);
|
||||||
} else {
|
} else {
|
||||||
unit **vp = &r->units;
|
unit **vp = &r->units;
|
||||||
|
@ -2990,7 +2993,7 @@ static int renumber_cmd(unit * u, order * ord)
|
||||||
cmistake(u, ord, 116, MSG_EVENT);
|
cmistake(u, ord, 116, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!fval(u, UFL_OWNER)) {
|
if (ship_owner(u->ship)!=u) {
|
||||||
cmistake(u, ord, 146, MSG_EVENT);
|
cmistake(u, ord, 146, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3018,7 +3021,7 @@ static int renumber_cmd(unit * u, order * ord)
|
||||||
cmistake(u, ord, 145, MSG_EVENT);
|
cmistake(u, ord, 145, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!fval(u, UFL_OWNER)) {
|
if (building_owner(u->building)!=u) {
|
||||||
cmistake(u, ord, 148, MSG_EVENT);
|
cmistake(u, ord, 148, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4068,12 +4071,6 @@ static void maintain_buildings_1(region * r)
|
||||||
maintain_buildings(r, false);
|
maintain_buildings(r, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef COLLAPSE_CHANCE
|
|
||||||
static void maintain_buildings_2(region * r)
|
|
||||||
{
|
|
||||||
maintain_buildings(r, true);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
static void reset_moved(unit * u)
|
static void reset_moved(unit * u)
|
||||||
{
|
{
|
||||||
freset(u, UFL_MOVED);
|
freset(u, UFL_MOVED);
|
||||||
|
@ -4246,11 +4243,6 @@ void init_processor(void)
|
||||||
}
|
}
|
||||||
add_proc_global(p, &demographics, "Nahrung, Seuchen, Wachstum, Wanderung");
|
add_proc_global(p, &demographics, "Nahrung, Seuchen, Wachstum, Wanderung");
|
||||||
|
|
||||||
#ifdef COLLAPSE_CHANCE
|
|
||||||
p += 10;
|
|
||||||
add_proc_region(p, &maintain_buildings_2, "Gebaeudeunterhalt (2. Versuch)");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!global.disabled[K_SORT]) {
|
if (!global.disabled[K_SORT]) {
|
||||||
p += 10;
|
p += 10;
|
||||||
add_proc_global(p, &reorder, "Einheiten sortieren");
|
add_proc_global(p, &reorder, "Einheiten sortieren");
|
||||||
|
|
|
@ -54,7 +54,6 @@ static void test_rename_building(CuTest * tc)
|
||||||
f = test_create_faction(rc_find("human"));
|
f = test_create_faction(rc_find("human"));
|
||||||
u = test_create_unit(f, r);
|
u = test_create_unit(f, r);
|
||||||
u_set_building(u, b);
|
u_set_building(u, b);
|
||||||
fset(u, UFL_OWNER);
|
|
||||||
|
|
||||||
rename_building(u, NULL, b, "Villa Nagel");
|
rename_building(u, NULL, b, "Villa Nagel");
|
||||||
CuAssertStrEquals(tc, "Villa Nagel", b->name);
|
CuAssertStrEquals(tc, "Villa Nagel", b->name);
|
||||||
|
|
|
@ -1382,7 +1382,7 @@ static void durchreisende(FILE * F, const region * r, const faction * f)
|
||||||
for (a = abegin; a && a->type == &at_travelunit; a = a->next) {
|
for (a = abegin; a && a->type == &at_travelunit; a = a->next) {
|
||||||
unit *u = (unit *) a->data.v;
|
unit *u = (unit *) a->data.v;
|
||||||
|
|
||||||
if (r != u->region && (u->ship == NULL || fval(u, UFL_OWNER))) {
|
if (r != u->region && (!u->ship || ship_owner(u->ship)==u)) {
|
||||||
if (cansee_durchgezogen(f, r, u, 0)) {
|
if (cansee_durchgezogen(f, r, u, 0)) {
|
||||||
++maxtravel;
|
++maxtravel;
|
||||||
}
|
}
|
||||||
|
@ -1399,7 +1399,7 @@ static void durchreisende(FILE * F, const region * r, const faction * f)
|
||||||
for (a = abegin; a && a->type == &at_travelunit; a = a->next) {
|
for (a = abegin; a && a->type == &at_travelunit; a = a->next) {
|
||||||
unit *u = (unit *) a->data.v;
|
unit *u = (unit *) a->data.v;
|
||||||
|
|
||||||
if (r != u->region && (u->ship == NULL || fval(u, UFL_OWNER))) {
|
if (r != u->region && (!u->ship || ship_owner(u->ship)==u)) {
|
||||||
if (cansee_durchgezogen(f, r, u, 0)) {
|
if (cansee_durchgezogen(f, r, u, 0)) {
|
||||||
++counter;
|
++counter;
|
||||||
if (u->ship != NULL) {
|
if (u->ship != NULL) {
|
||||||
|
@ -1565,7 +1565,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
unitid(u), u->name, u->number, get_money(u));
|
unitid(u), u->name, u->number, get_money(u));
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
if (u->building != NULL && fval(u, UFL_OWNER)) {
|
if (u->building && building_owner(u->building)==u) {
|
||||||
building *b = u->building;
|
building *b = u->building;
|
||||||
int cost = buildingmaintenance(b, r_silver);
|
int cost = buildingmaintenance(b, r_silver);
|
||||||
|
|
||||||
|
@ -1578,7 +1578,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
} else if (u->ship) {
|
} else if (u->ship) {
|
||||||
if (fval(u, UFL_OWNER)) {
|
if (ship_owner(u->ship)==u) {
|
||||||
bytes = (int)strlcpy(bufp, ",S", size);
|
bytes = (int)strlcpy(bufp, ",S", size);
|
||||||
} else {
|
} else {
|
||||||
bytes = (int)strlcpy(bufp, ",s", size);
|
bytes = (int)strlcpy(bufp, ",s", size);
|
||||||
|
|
|
@ -376,7 +376,6 @@ int destroy_cmd(unit * u, struct order *ord)
|
||||||
/* all units leave the building */
|
/* all units leave the building */
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->building == b) {
|
if (u2->building == b) {
|
||||||
freset(u2, UFL_OWNER);
|
|
||||||
leave_building(u2);
|
leave_building(u2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,13 +68,6 @@ extern "C" {
|
||||||
/* Chance of a monster attack */
|
/* Chance of a monster attack */
|
||||||
#define MONSTERATTACK 0.4F
|
#define MONSTERATTACK 0.4F
|
||||||
|
|
||||||
/** Chance of an unmaintained building crashing */
|
|
||||||
/* #define COLLAPSE_CHANCE 0.4F */
|
|
||||||
#undef COLLAPSE_CHANCE
|
|
||||||
/** chance to survive the crash of a building */
|
|
||||||
/* #define COLLAPSE_SURVIVAL 0.5F */
|
|
||||||
#undef COLLAPSE_SURVIVAL
|
|
||||||
|
|
||||||
/* Bewegungsweiten: */
|
/* Bewegungsweiten: */
|
||||||
#define BP_WALKING 4
|
#define BP_WALKING 4
|
||||||
#define BP_RIDING 6
|
#define BP_RIDING 6
|
||||||
|
|
|
@ -2597,13 +2597,13 @@ void movement(void)
|
||||||
set_order(&u->thisorder, NULL);
|
set_order(&u->thisorder, NULL);
|
||||||
} else {
|
} else {
|
||||||
if (ships) {
|
if (ships) {
|
||||||
if (u->ship && fval(u, UFL_OWNER)) {
|
if (u->ship && ship_owner(u->ship)==u) {
|
||||||
init_tokens(u->thisorder);
|
init_tokens(u->thisorder);
|
||||||
skip_token();
|
skip_token();
|
||||||
move(u, false);
|
move(u, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (u->ship == NULL || !fval(u, UFL_OWNER)) {
|
if (!u->ship || ship_owner(u->ship)!=u) {
|
||||||
init_tokens(u->thisorder);
|
init_tokens(u->thisorder);
|
||||||
skip_token();
|
skip_token();
|
||||||
move(u, false);
|
move(u, false);
|
||||||
|
|
|
@ -795,32 +795,21 @@ void u_set_ship(unit * u, ship * sh)
|
||||||
void leave_ship(unit * u)
|
void leave_ship(unit * u)
|
||||||
{
|
{
|
||||||
struct ship *sh = u->ship;
|
struct ship *sh = u->ship;
|
||||||
if (!sh) return;
|
|
||||||
u->ship = 0;
|
u->ship = 0;
|
||||||
|
if (sh->_owner==u) {
|
||||||
|
sh->_owner = ship_owner(sh);
|
||||||
|
}
|
||||||
set_leftship(u, sh);
|
set_leftship(u, sh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void leave_building(unit * u)
|
void leave_building(unit * u)
|
||||||
{
|
{
|
||||||
struct building *b = u->building;
|
building * b = u->building;
|
||||||
|
|
||||||
u->building = NULL;
|
u->building = 0;
|
||||||
if (b && fval(u, UFL_OWNER)) {
|
if (b->_owner==u) {
|
||||||
unit *u2, *owner = NULL;
|
b->_owner = building_owner(b);
|
||||||
freset(u, UFL_OWNER);
|
|
||||||
|
|
||||||
for (u2 = u->region->units; u2; u2 = u2->next) {
|
|
||||||
if (u2->building == b) {
|
|
||||||
if (u2->faction == u->faction) {
|
|
||||||
owner = u2;
|
|
||||||
break;
|
|
||||||
} else if (owner == NULL)
|
|
||||||
owner = u2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (owner != NULL) {
|
|
||||||
fset(owner, UFL_OWNER);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue