[Freeciv-Dev] Re: (PR#4683) allow pauses during client-side goto
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
ChrisK@xxxxxxxx wrote:
> On Fri, Jul 25, 2003 at 01:52:16AM -0700, Jason Short wrote:
>
>
>>+ * for tririemes. FIXME: we shouldn't lose the movepoints but should
>>+ * instead return GR_WAITING and just sit tight. */
>
>
> I think that, too. :-/
This may do the trick. It's a little riskier; I'm not sure if
GR_WAITING needs special handling anywhere. It also takes client
changes to get the focus to advance properly - I think these changes are
fundamentally sound but may cause problems in other situations.
jason
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.107
diff -u -r1.107 control.c
--- client/control.c 2003/07/23 13:46:01 1.107
+++ client/control.c 2003/07/25 09:51:15
@@ -191,8 +191,7 @@
void update_unit_focus(void)
{
if(!punit_focus
- || (punit_focus->activity!=ACTIVITY_IDLE
- && punit_focus->activity!=ACTIVITY_GOTO)
+ || punit_focus->activity != ACTIVITY_IDLE
|| punit_focus->moves_left==0
|| punit_focus->ai.control) {
advance_unit_focus();
Index: server/gotohand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.h,v
retrieving revision 1.27
diff -u -r1.27 gotohand.h
--- server/gotohand.h 2003/02/20 09:45:22 1.27
+++ server/gotohand.h 2003/07/25 09:51:15
@@ -24,6 +24,7 @@
GR_DIED, /* pretty obvious that */
GR_ARRIVED, /* arrived to the destination */
GR_OUT_OF_MOVEPOINTS, /* either no moves left or plane refueling */
+ GR_WAITING, /* waiting due to danger, has moves */
GR_FOUGHT, /* was stopped due to fighting, has moves */
GR_FAILED /* failed for some other reason, has moves */
};
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.236
diff -u -r1.236 unittools.c
--- server/unittools.c 2003/07/24 16:52:28 1.236
+++ server/unittools.c 2003/07/25 09:51:15
@@ -2975,7 +2975,7 @@
{
struct goto_route *pgr = punit->pgr;
int index, x, y;
- bool res, last_tile;
+ bool res, last_tile, moved;
int patrol_stop_index = pgr->last_index;
int unitid = punit->id;
struct player *pplayer = unit_owner(punit);
@@ -3010,7 +3010,12 @@
/* Move unit */
last_tile = (((index + 1) % pgr->length) == (pgr->last_index));
freelog(LOG_DEBUG, "handling\n");
- res = handle_unit_move_request(punit, x, y, FALSE, !last_tile);
+ moved = !same_pos(punit->x, punit->y, x, y);
+ if (moved) {
+ res = handle_unit_move_request(punit, x, y, FALSE, !last_tile);
+ } else {
+ res = TRUE;
+ }
if (!player_find_unit_by_id(pplayer, unitid)) {
return GR_DIED;
@@ -3033,6 +3038,13 @@
if (maybe_cancel_patrol_due_to_enemy(punit)) {
return GR_FAILED;
}
+ }
+
+ if (!moved) {
+ /* Sometimes the goto route will have us sit still for a moment -
+ * for instance a trireme will do this to have enough MP to
+ * cross the ocean in one turn. */
+ return GR_WAITING;
}
}
|
|