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;
|
||||
}
|
||||
|
||||
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 *current_point, *last_point;
|
||||
int k, step = 0;
|
||||
region_list **iroute = routep;
|
||||
region_list **iroute = &route;
|
||||
ship *sh = u->ship;
|
||||
faction *f = u->faction;
|
||||
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);
|
||||
const char *token = getstrtoken();
|
||||
|
||||
if (routep) {
|
||||
*routep = NULL;
|
||||
}
|
||||
|
||||
error = movewhere(u, token, starting_point, &next_point);
|
||||
if (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))
|
||||
caught_target(current_point, u);
|
||||
|
||||
move_ship(sh, starting_point, current_point, routep ? *routep : NULL);
|
||||
move_ship(sh, starting_point, current_point, route);
|
||||
|
||||
/* Hafengebuehren ? */
|
||||
|
||||
|
@ -1982,6 +1979,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
|
|||
}
|
||||
}
|
||||
}
|
||||
free_regionlist(route);
|
||||
}
|
||||
|
||||
/* Segeln, Wandern, Reiten
|
||||
|
@ -2088,14 +2086,12 @@ static const region_list *travel_i(unit * u, const region_list * route_begin,
|
|||
/** traveling without ships
|
||||
* 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_begin;
|
||||
follower *followers = NULL;
|
||||
region_list *route = NULL;
|
||||
|
||||
assert(routep);
|
||||
*routep = NULL;
|
||||
region *r = u->region;
|
||||
follower *followers = NULL;
|
||||
|
||||
/* a few pre-checks that need not be done for each step: */
|
||||
if (!fval(r->terrain, SEA_REGION)) {
|
||||
|
@ -2131,12 +2127,10 @@ static void travel(unit * u, order *ord, region_list ** routep)
|
|||
return;
|
||||
}
|
||||
|
||||
make_route(u, ord, routep);
|
||||
route_begin = *routep;
|
||||
|
||||
if (route_begin) {
|
||||
make_route(u, ord, &route);
|
||||
if (route) {
|
||||
/* und ab die post: */
|
||||
travel_i(u, route_begin, NULL, ord, TRAVEL_NORMAL, &followers);
|
||||
travel_i(u, route, NULL, ord, TRAVEL_NORMAL, &followers);
|
||||
|
||||
/* followers */
|
||||
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",
|
||||
s, ut->no);
|
||||
|
||||
route_end = reroute(uf, route_begin, route_end);
|
||||
travel_i(uf, route_begin, route_end, follow_order, TRAVEL_FOLLOWING,
|
||||
route_end = reroute(uf, route, route_end);
|
||||
travel_i(uf, route, route_end, follow_order, TRAVEL_FOLLOWING,
|
||||
&followers);
|
||||
caught_target(uf->region, uf);
|
||||
free_order(follow_order);
|
||||
}
|
||||
}
|
||||
free_regionlist(route);
|
||||
}
|
||||
}
|
||||
|
||||
void move_cmd(unit * u, order * ord)
|
||||
{
|
||||
region_list *route = NULL;
|
||||
|
||||
assert(u->number);
|
||||
if (u->ship && u == ship_owner(u->ship)) {
|
||||
bool drifting = (getkeyword(ord) == K_MOVE);
|
||||
sail(u, ord, &route, drifting);
|
||||
sail(u, ord, drifting);
|
||||
}
|
||||
else {
|
||||
travel(u, ord, &route);
|
||||
travel(u, ord);
|
||||
}
|
||||
|
||||
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
||||
set_order(&u->thisorder, NULL);
|
||||
|
||||
if (route != NULL)
|
||||
free_regionlist(route);
|
||||
}
|
||||
|
||||
static void age_traveldir(region * r)
|
||||
|
|
Loading…
Reference in New Issue