Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: Anxious Trireme (PR#1267)
Home

[Freeciv-Dev] Re: Anxious Trireme (PR#1267)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Christian Knoke <ChrisK@xxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Anxious Trireme (PR#1267)
From: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Date: Tue, 19 Feb 2002 19:39:46 +0000 (GMT)

 --- Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx> wrote: >  
--- Christian Knoke <ChrisK@xxxxxxxx> wrote: 
> > CVS 19 FEB 2002 w/ buy5 patch Gtk bla bla
> > 
> > On Goto the trireme's got a bit to anxious to sink.
> > Instead of entering the city in distance 3, it takes
> > a route along the coast which is 4 moves long.
> 
> Aha.  It's not my fault and it's not easily fixable.  I'll think about it
> though...

Ok, so I was wrong.  Here is a quick and dirty fix.
Please tell me what you think.

I think it is bad since although it plans to finish every turn near a shore,
it should also try to stick to shore if it does not make the route longer. 
Just in case something unexpected happens... Now this is a really hard part.

G.

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
? auto.rc
? saves
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.34
diff -u -r1.34 goto.c
--- client/goto.c       2002/02/19 16:41:17     1.34
+++ client/goto.c       2002/02/19 19:35:22
@@ -281,6 +281,13 @@
       || is_my_zoc(unit_owner(punit), dest_x, dest_y);
 }
 
+static bool will_end_move_there(struct unit *punit, int move_rate, 
+                               int move_cost)
+{
+  assert(move_rate > 0);
+  return (((move_cost - punit->moves_left) % move_rate) == 0);
+}
+
 /********************************************************************** 
 fills out the goto_map with move costs and vectors as to how we get
 there. Somewhat similar to the one in server/gotohand.c
@@ -307,6 +314,8 @@
   struct tile *psrctile, *pdesttile;
   enum unit_move_type move_type = unit_type(punit)->move_type;
   int move_cost, total_cost;
+  /* Used only for trireme */
+  int moverate = unit_move_rate(punit);
   bool igter = unit_flag(punit, F_IGTER);
   bool add_to_queue;
 
@@ -390,7 +399,9 @@
        } else if (psrctile->move_cost[dir] != MOVE_COST_FOR_VALID_SEA_STEP) {
          continue;
        } else if (unit_flag(punit, F_TRIREME) 
-                  && trireme_loss_pct(unit_owner(punit), x1, y1) > 0) {
+                  && trireme_loss_pct(unit_owner(punit), x1, y1) > 0
+                  && will_end_move_there(punit, moverate, SINGLE_MOVE 
+                                         + goto_map.move_cost[x][y])) {
          move_cost = 2*SINGLE_MOVE+1;
        } else {
          move_cost = SINGLE_MOVE;

[Prev in Thread] Current Thread [Next in Thread]