forked from github/server
simplify sail/travel, remove route from arguments.
This commit is contained in:
parent
52ee682a48
commit
fd1b981983
44
src/move.c
44
src/move.c
|
@ -1683,12 +1683,13 @@ bool can_takeoff(const ship * sh, const region * from, const region * to)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
|
static void sail(unit * u, order * ord, bool drifting)
|
||||||
{
|
{
|
||||||
|
region_list *route = NULL;
|
||||||
region *starting_point = u->region;
|
region *starting_point = u->region;
|
||||||
region *current_point, *last_point;
|
region *current_point, *last_point;
|
||||||
int k, step = 0;
|
int k, step = 0;
|
||||||
region_list **iroute = routep;
|
region_list **iroute = &route;
|
||||||
ship *sh = u->ship;
|
ship *sh = u->ship;
|
||||||
faction *f = u->faction;
|
faction *f = u->faction;
|
||||||
region *next_point = NULL;
|
region *next_point = NULL;
|
||||||
|
@ -1698,10 +1699,6 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
|
||||||
int lighthouse_div = config_get_int("rules.storm.lighthouse.divisor", 0);
|
int lighthouse_div = config_get_int("rules.storm.lighthouse.divisor", 0);
|
||||||
const char *token = getstrtoken();
|
const char *token = getstrtoken();
|
||||||
|
|
||||||
if (routep) {
|
|
||||||
*routep = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = movewhere(u, token, starting_point, &next_point);
|
error = movewhere(u, token, starting_point, &next_point);
|
||||||
if (error) {
|
if (error) {
|
||||||
message *msg = movement_error(u, token, ord, error);
|
message *msg = movement_error(u, token, ord, error);
|
||||||
|
@ -1940,7 +1937,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
|
||||||
if (fval(u, UFL_FOLLOWING))
|
if (fval(u, UFL_FOLLOWING))
|
||||||
caught_target(current_point, u);
|
caught_target(current_point, u);
|
||||||
|
|
||||||
move_ship(sh, starting_point, current_point, routep ? *routep : NULL);
|
move_ship(sh, starting_point, current_point, route);
|
||||||
|
|
||||||
/* Hafengebuehren ? */
|
/* Hafengebuehren ? */
|
||||||
|
|
||||||
|
@ -1982,6 +1979,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free_regionlist(route);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Segeln, Wandern, Reiten
|
/* Segeln, Wandern, Reiten
|
||||||
|
@ -2088,14 +2086,12 @@ static const region_list *travel_i(unit * u, const region_list * route_begin,
|
||||||
/** traveling without ships
|
/** traveling without ships
|
||||||
* walking, flying or riding units use this function
|
* walking, flying or riding units use this function
|
||||||
*/
|
*/
|
||||||
static void travel(unit * u, order *ord, region_list ** routep)
|
static void travel(unit * u, order *ord)
|
||||||
{
|
{
|
||||||
region *r = u->region;
|
region_list *route = NULL;
|
||||||
region_list *route_begin;
|
|
||||||
follower *followers = NULL;
|
|
||||||
|
|
||||||
assert(routep);
|
region *r = u->region;
|
||||||
*routep = NULL;
|
follower *followers = NULL;
|
||||||
|
|
||||||
/* a few pre-checks that need not be done for each step: */
|
/* a few pre-checks that need not be done for each step: */
|
||||||
if (!fval(r->terrain, SEA_REGION)) {
|
if (!fval(r->terrain, SEA_REGION)) {
|
||||||
|
@ -2131,12 +2127,10 @@ static void travel(unit * u, order *ord, region_list ** routep)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
make_route(u, ord, routep);
|
make_route(u, ord, &route);
|
||||||
route_begin = *routep;
|
if (route) {
|
||||||
|
|
||||||
if (route_begin) {
|
|
||||||
/* und ab die post: */
|
/* und ab die post: */
|
||||||
travel_i(u, route_begin, NULL, ord, TRAVEL_NORMAL, &followers);
|
travel_i(u, route, NULL, ord, TRAVEL_NORMAL, &followers);
|
||||||
|
|
||||||
/* followers */
|
/* followers */
|
||||||
while (followers != NULL) {
|
while (followers != NULL) {
|
||||||
|
@ -2157,34 +2151,30 @@ static void travel(unit * u, order *ord, region_list ** routep)
|
||||||
follow_order = create_order(K_FOLLOW, lang, "%s %i",
|
follow_order = create_order(K_FOLLOW, lang, "%s %i",
|
||||||
s, ut->no);
|
s, ut->no);
|
||||||
|
|
||||||
route_end = reroute(uf, route_begin, route_end);
|
route_end = reroute(uf, route, route_end);
|
||||||
travel_i(uf, route_begin, route_end, follow_order, TRAVEL_FOLLOWING,
|
travel_i(uf, route, route_end, follow_order, TRAVEL_FOLLOWING,
|
||||||
&followers);
|
&followers);
|
||||||
caught_target(uf->region, uf);
|
caught_target(uf->region, uf);
|
||||||
free_order(follow_order);
|
free_order(follow_order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free_regionlist(route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void move_cmd(unit * u, order * ord)
|
void move_cmd(unit * u, order * ord)
|
||||||
{
|
{
|
||||||
region_list *route = NULL;
|
|
||||||
|
|
||||||
assert(u->number);
|
assert(u->number);
|
||||||
if (u->ship && u == ship_owner(u->ship)) {
|
if (u->ship && u == ship_owner(u->ship)) {
|
||||||
bool drifting = (getkeyword(ord) == K_MOVE);
|
bool drifting = (getkeyword(ord) == K_MOVE);
|
||||||
sail(u, ord, &route, drifting);
|
sail(u, ord, drifting);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
travel(u, ord, &route);
|
travel(u, ord);
|
||||||
}
|
}
|
||||||
|
|
||||||
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
||||||
set_order(&u->thisorder, NULL);
|
set_order(&u->thisorder, NULL);
|
||||||
|
|
||||||
if (route != NULL)
|
|
||||||
free_regionlist(route);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void age_traveldir(region * r)
|
static void age_traveldir(region * r)
|
||||||
|
|
Loading…
Reference in New Issue