Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] Re: (PR#4827) more goto crashes
Home

[Freeciv-Dev] Re: (PR#4827) more goto crashes

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4827) more goto crashes
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Tue, 12 Aug 2003 11:12:33 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Tue, 12 Aug 2003, Christian Knoke wrote:

> Ok, sorry. Here is *one* way to do it.
> 
> Load savegame, login as chris, start, activate staem ship near Braunschweig,
> point mouse into ocean, then:
> 
> Press 'G' 3 times, then click left.

Wow, your inventivenss amazes me!

Ok, attached patch helps this crash, any other way to crash goto? ;)

G.

Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.57
diff -u -r1.57 goto.c
--- client/goto.c       2003/08/11 17:12:06     1.57
+++ client/goto.c       2003/08/12 18:10:32
@@ -270,13 +270,16 @@
 ***********************************************************************/
 void goto_add_waypoint(void)
 {
-  int x, y;
+  struct part *p = &goto_map.parts[goto_map.num_parts - 1];
 
   assert(is_active);
   assert(find_unit_by_id(goto_map.unit_id)
         && find_unit_by_id(goto_map.unit_id) == get_unit_in_focus());
-  get_line_dest(&x, &y);
-  add_part();
+
+  if (!same_pos(p->start_x, p->start_y, p->end_x, p->end_y)) {
+    /* Otherwise the last part has zero length. */
+    add_part();
+  }
 }
 
 /********************************************************************** 

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