forked from github/server
bug 2710 ships moving in circles break guard
This commit is contained in:
parent
fe463a9f44
commit
e4e06dfcbe
2 changed files with 25 additions and 17 deletions
|
@ -529,8 +529,6 @@ function test_ship_crew_stops_guarding()
|
||||||
local sh = ship.create(r1, "longboat")
|
local sh = ship.create(r1, "longboat")
|
||||||
u1.ship = sh
|
u1.ship = sh
|
||||||
u2.ship = sh
|
u2.ship = sh
|
||||||
u1.name = 'Bolgrim'
|
|
||||||
u1.name = 'Bolle'
|
|
||||||
u1:clear_orders()
|
u1:clear_orders()
|
||||||
u1:add_order("NACH O W")
|
u1:add_order("NACH O W")
|
||||||
u1:set_skill("sailing", 1) -- cptskill = 1
|
u1:set_skill("sailing", 1) -- cptskill = 1
|
||||||
|
|
32
src/move.c
32
src/move.c
|
@ -624,9 +624,6 @@ mark_travelthru(unit * u, region * r, const region_list * route,
|
||||||
|
|
||||||
void move_ship(ship * sh, region * from, region * to, region_list * route)
|
void move_ship(ship * sh, region * from, region * to, region_list * route)
|
||||||
{
|
{
|
||||||
unit **iunit = &from->units;
|
|
||||||
unit **ulist = &to->units;
|
|
||||||
|
|
||||||
assert(sh);
|
assert(sh);
|
||||||
if (from != to) {
|
if (from != to) {
|
||||||
translist(&from->ships, &to->ships, sh);
|
translist(&from->ships, &to->ships, sh);
|
||||||
|
@ -636,26 +633,39 @@ void move_ship(ship * sh, region * from, region * to, region_list * route)
|
||||||
leave_trail(sh, from, route);
|
leave_trail(sh, from, route);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*iunit != NULL) {
|
if (route != NULL) {
|
||||||
|
unit** iunit = &from->units;
|
||||||
|
unit** ulist = &to->units;
|
||||||
|
unit* ufirst = NULL;
|
||||||
|
|
||||||
|
do {
|
||||||
unit *u = *iunit;
|
unit *u = *iunit;
|
||||||
assert(u->region == from);
|
|
||||||
|
|
||||||
if (u->ship == sh) {
|
if (u->ship == sh) {
|
||||||
if (route != NULL)
|
*iunit = u->next;
|
||||||
|
if (!ufirst) {
|
||||||
|
ufirst = u;
|
||||||
|
}
|
||||||
mark_travelthru(u, from, route, NULL);
|
mark_travelthru(u, from, route, NULL);
|
||||||
if (from != to) {
|
u->ship = NULL; /* temporary trick -- do not use u_set_ship here */
|
||||||
u->ship = 0; /* temporary trick -- do not use u_set_ship here */
|
leave_region(u);
|
||||||
|
u->region = NULL;
|
||||||
|
u->next = NULL;
|
||||||
move_unit(u, to, ulist);
|
move_unit(u, to, ulist);
|
||||||
ulist = &u->next;
|
ulist = &u->next;
|
||||||
u->ship = sh; /* undo the trick -- do not use u_set_ship here */
|
u->ship = sh; /* undo the trick -- do not use u_set_ship here */
|
||||||
}
|
if (effskill(u, SK_SAILING, from) >= 1) {
|
||||||
if (route && effskill(u, SK_SAILING, from) >= 1) {
|
|
||||||
produceexp(u, SK_SAILING, u->number);
|
produceexp(u, SK_SAILING, u->number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*iunit == u)
|
else if (ufirst) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
iunit = &u->next;
|
iunit = &u->next;
|
||||||
}
|
}
|
||||||
|
} while (*iunit && (ufirst == NULL || ufirst != *iunit));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_freezing(const unit * u)
|
static bool is_freezing(const unit * u)
|
||||||
|
|
Loading…
Reference in a new issue