Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] Re: (PR#2608) replace key_move_xxx with key_unit_move
Home

[Freeciv-Dev] Re: (PR#2608) replace key_move_xxx with key_unit_move

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2608) replace key_move_xxx with key_unit_move
From: "rwetmore@xxxxxxxxxxxx via RT" <rt@xxxxxxxxxxxxxx>
Date: Thu, 19 Dec 2002 17:54:04 -0800
Reply-to: rt@xxxxxxxxxxxxxx

At 11:38 PM 02/12/18 -0800, Jason Short via RT wrote:
>
>This patch replaces key_move_xxx functions with a single function
>key_unit_move.  This new function takes a dir8 parameter giving the
>_GUI_ direction of the unit's movement.  This GUI direction is converted
>into a _map_ direction by the backend.

On the surface there is little difference between  function_param() and 
function(param) forms except to reduce the number of functions. One just
moves the constant argument definition up a layer.

If this reduces switches that index gui_dir to call functions, that would
make a valid reason. (I note that you can now remove all hardcoded switches 
below and instead define a data array that maps various keys to enum dirs 
for a reduction to single line of code (a much simpler form :-):

  key_unit_move(key_to_guidir[ev-keyval]);

or with partial filtering flavours like ...

  if (DIR8_UNKNOWN != (guidir = key_to_guidir[ev-keyval]))
    key_unit_move(guidir);

This may make it easier to map keys to arbitrary directions in the future
on a dynamic basis as opposed to recompiling, just pass a different
key_to_guidir mapping array.

>This provides three advantages:
>
>- It gets rid of lots of unnecessary code.
>
>- It provides native support for isometric, non-isometric, and (I think)
>any future view modes we may come up with.  (Ross, if you think this is
>an insufficient design please propose a better one.)

I like the sentiment, but haven't drunk enough of the code yet to get
over the initial bad taste.

First, the conversion is from enum direction8 to the same enum. I'm
happy enough to associate the DIR8_XXX enums with GUI directions, but
think one needs to split map and GUI by creating a corresponding set
of map enums that are clearly different. I'd do this now to make it
clear that is what is happening.

I'm also not completely happy with assigning directions like "NORTH"
to *any* coordinate axes, because as with the rotation of the iso, 
DIR8_NORTH is now DIRMAP_NORTHWEST, and the compass direction is 
becoming a very fuzzy concept. I can relate to GUI NORTH as "up"
on a cartesian screen (i.e. (0,-1)) but this is because of standard
map convention. Standard/internal map NORTH which may be NORTHWEST or 
who knows what depending on the topology and other factors such as
how best to represent it in a cartesian grid, is where I start to 
lose it. 

So a clear definition of what directions mean in each type of coordinate 
system with the sorts of mappings you are starting on here prominently 
documented as the way to transform things from one to the other, may 
help people who see NORTH and think that means something constant 
everywhere - they need to at least think ISO-NORTH, GUI-NORTH etc. 
instead, or one gets rid of the NORTH labels to avoid linkage.

I definitely think the gui_to_map_dir() and map_to_gui_dir() 
transformations should end up in a "GUI_map".h (currently tilespec.h
is the dumping ground for gui coordinate stuff, at least it has the
DIR4_XXX and if DIR8_XXX are GUI they should move out of map.h to a
GUI location - the corecleanups really abused tilespec.h. but CVS 
can get it right if it starts early).

>- It provides the beginnings of a distinction between GUI and map
>directions.  This can be helpful in many places in the current code
>(like this one!), and provides a lot of flexibility for future changes. 
>See
>http://lists.complete.org/freeciv-dev@xxxxxxxxxxx/2002/01/msg00547.html.gz
>
>One counter-argument could be that the key_move_xxx functions take no
>parameters and are easily used directly as callback functions by the
>GUI.  But currently no GUI does this - even XAW which has specific
>callback functions for each key command needs a different prototype for
>them, and uses wrappers.  So this is a non-issue.

Because one can always use wrappers if needed (and may need multiple 
wrappers for flexibility), plus there are corresponding arguments (like 
switch reduction) on the otherside, one may end up with both flavours
with the current suggestion the lower layer. This change is then one of
first consolidation and second elimination of (current) dead code, but
not precluding adding new wrappers in the future. This is good ...

>The argument that this method is inefficient is also pointless.  dir_ccw
>is efficient (and could be made more so in the future), and in any case
>this code is not called intensively.

Initial implementation should probably be as macros in tilespec.h or the
*correct* file location. The "not intensively" is never a good argument 
if there are reasonable efficient alternatives. If one doubles the cost
of every snippet of code one writes, then soon the program will be twice
as slow, and soon thereafter twice as slow again and I have noticed you 
always use this same argument with every checkin :-)

Cheers,
RossW
=====

>jason
>
>
>Index:
client/control.c
>==========================================================
=========
>RCS file:
/home/freeciv/CVS/freeciv/client/control.c,v
>retrieving revision
1.88
>diff -u -r1.88 control.c
>--- client/control.c   2002/12/11 10:39:41
1.88
>+++ client/control.c   2002/12/19 07:25:26
>@@ -1385,75 +1385,32 @@
>
}
> 
>
/**************************************************************************

>-...
>-********************************************************************
******/
>-void key_move_north(void)
>-{
>-  if(get_unit_in_focus())
>-
request_move_unit_direction(punit_focus,
DIR8_NORTH);
>-}
>-
>-/*****************************************************
*********************
>-...
>-**********************************************
****************************/
>-void key_move_north_east(void)
>-{
>-
if(get_unit_in_focus())
>-    request_move_unit_direction(punit_focus,
DIR8_NORTHEAST);
>-}
>+  Convert the given GUI direction into a map
direction.
>

>-/************************************************************************
**
>-...
>-*****************************************************************
*********/
>-void key_move_east(void)
>-{
>-  if(get_unit_in_focus())
>-
request_move_unit_direction(punit_focus,
DIR8_EAST);
>-}
>-
>-/******************************************************
********************
>-...
>-***********************************************
***************************/
>-void key_move_south_east(void)
>-{
>-
if(get_unit_in_focus())
>-     request_move_unit_direction(punit_focus,
DIR8_SOUTHEAST);
>-}
>-
>-/*************************************************
*************************
>-...
>-******************************************
********************************/
>-void key_move_south(void)
>-{
>-
if(get_unit_in_focus())
>-     request_move_unit_direction(punit_focus,
DIR8_SOUTH);
>-}
>-
>-/*****************************************************
*********************
>-...
>-**********************************************
****************************/
>-void key_move_south_west(void)
>-{
>-
if(get_unit_in_focus())
>-     request_move_unit_direction(punit_focus,
DIR8_SOUTHWEST);
>-}
>-
>-/*************************************************
*************************
>-...
>+  GUI directions correspond to the
current viewing interface, so that
>+  DIR8_NORTH is up on the mapview.
map directions correspond to the
>+  underlying map tiles, so that
DIR8_NORTH means moving with a vector of
>+  (0,-1).
>
**************************************************************************/

>-void key_move_west(void)
>+static enum direction8 gui_to_map_dir(enum
direction8 gui_dir)
> {
>-  if(get_unit_in_focus())
>-
request_move_unit_direction(punit_focus, DIR8_WEST);
>+  if (is_isometric)
{
>+    return dir_ccw(gui_dir);
>+  } else {
>+    return gui_dir;
>+  }
>
}
> 
>
/**************************************************************************

>-...
>+  Move the focus unit in the given direction.  Here directions
are
>+  defined according to the GUI, so that north is "up" in the
interface.
>
**************************************************************************/

>-void key_move_north_west(void)
>+void key_unit_move(enum direction8
gui_dir)
> {
>-  if(get_unit_in_focus())
>-
request_move_unit_direction(punit_focus, DIR8_NORTHWEST);
>+  if
(get_unit_in_focus()) {
>+    enum direction8 map_dir =
gui_to_map_dir(gui_dir);
>+
request_move_unit_direction(get_unit_in_focus(), map_dir);
>+  }
> }
> 
>
/**************************************************************************

>Index:
client/control.h
>==========================================================
=========
>RCS file:
/home/freeciv/CVS/freeciv/client/control.h,v
>retrieving revision
1.30
>diff -u -r1.30 control.h
>--- client/control.h   2002/11/22 18:52:12
1.30
>+++ client/control.h   2002/12/19 07:25:26
>@@ -116,14 +116,7 @@
> void
key_fog_of_war_toggle(void);
> void key_end_turn(void);
> void
key_map_grid_toggle(void);
>-void key_move_north(void);
>-void
key_move_north_east(void);
>-void key_move_east(void);
>-void
key_move_south_east(void);
>-void key_move_south(void);
>-void
key_move_south_west(void);
>-void key_move_west(void);
>-void
key_move_north_west(void);
>+void key_unit_move(enum direction8 gui_dir);
>
void key_unit_airbase(void);
> void key_unit_auto_attack(void);
> void
key_unit_auto_explore(void);
>Index:
client/gui-gtk/gui_main.c
>=================================================
==================
>RCS file:
/home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
>retrieving revision
1.123
>diff -u -r1.123 gui_main.c
>--- client/gui-gtk/gui_main.c  2002/12/16
05:35:30        1.123
>+++ client/gui-gtk/gui_main.c  2002/12/19 07:25:26
>@@
-248,111 +248,63 @@
>     return keypress;
>   }
> 
>-  if (is_isometric &&
!client_is_observer()) {
>+  if (!client_is_observer()) {
>     switch
(ev->keyval) {
>       case GDK_Up:
>       case GDK_KP_Up:
>       case
GDK_8:
>-      case GDK_KP_8:          key_move_north_west();  break;
>+      case
GDK_KP_8:
>+      key_unit_move(DIR8_NORTH);
>+      break;
> 
>       case
GDK_Page_Up:
>       case GDK_KP_Page_Up:
>       case GDK_9:
>-      case
GDK_KP_9:               key_move_north();       break;
>+      case GDK_KP_9:
>+
key_unit_move(DIR8_NORTHEAST);
>+      break;
> 
>       case GDK_Right:
>
case GDK_KP_Right:
>       case GDK_6:
>-      case GDK_KP_6:
key_move_north_east();  break;
>+      case GDK_KP_6:
>+
key_unit_move(DIR8_EAST);
>+      break;
> 
>       case GDK_Page_Down:
>
case GDK_KP_Page_Down:
>       case GDK_3:
>-      case GDK_KP_3:
key_move_east();        break;
>+      case GDK_KP_3:
>+
key_unit_move(DIR8_SOUTHEAST);
>+      break;
> 
>       case GDK_Down:
>
case GDK_KP_Down:
>       case GDK_2:
>-      case GDK_KP_2:
key_move_south_east();  break;
>+      case GDK_KP_2:
>+
key_unit_move(DIR8_SOUTH);
>+      break;
> 
>       case GDK_End:
>       case
GDK_KP_End:
>       case GDK_1:
>-      case GDK_KP_1:          key_move_south();
break;
>+      case GDK_KP_1:
>+      key_unit_move(DIR8_SOUTHWEST);
>+      break;
>

>       case GDK_Left:
>       case GDK_KP_Left:
>       case GDK_4:
>-
  case GDK_KP_4:                key_move_south_west();  break;
>+      case GDK_KP_4:
>+
key_unit_move(DIR8_WEST);
>+      break;
> 
>       case GDK_Home:
>-      case
GDK_KP_Home:
>-      case GDK_7:
>-      case GDK_KP_7:          key_move_west();
break;
>- 
>-      case GDK_KP_Begin:
>-      case GDK_5:
>-      case
GDK_KP_5:
>-        focus_to_next_unit();
>-        break;
>-  
>-
case GDK_Return:
>-      case GDK_KP_Enter:
>-        key_end_turn();
>-
    break;
>-  
>-      case GDK_Escape:
>-        key_cancel_action();
>-
      break;
>-  
>-      case GDK_t:
>-        key_city_workers(w, ev);
>-
       break;
>-
>-      default:
>-        return FALSE;
>-    }
>-  }
else if (!client_is_observer()) {
>-    switch (ev->keyval) {
>-      case
GDK_Up:
>-      case GDK_KP_Up:
>-      case GDK_8:
>-      case GDK_KP_8:
        key_move_north();       break;
>-
>-      case GDK_Page_Up:
>-      case
GDK_KP_Page_Up:
>-      case GDK_9:
>-      case GDK_KP_9:
key_move_north_east();  break;
>-
>-      case GDK_Right:
>-      case
GDK_KP_Right:
>-      case GDK_6:
>-      case GDK_KP_6:          key_move_east();
break;
>-
>-      case GDK_Page_Down:
>-      case GDK_KP_Page_Down:
>-
 case GDK_3:
>-      case GDK_KP_3:          key_move_south_east();  break;
>-
>-
   case GDK_Down:
>-      case GDK_KP_Down:
>-      case GDK_2:
>-
case GDK_KP_2:          key_move_south();       break;
>-
>-      case GDK_End:
>-
case GDK_KP_End:
>-      case GDK_1:
>-      case GDK_KP_1:
key_move_south_west();  break;
>-
>-      case GDK_Left:
>-      case
GDK_KP_Left:
>-      case GDK_4:
>-      case GDK_KP_4:          key_move_west();
break;
>-
>-      case GDK_Home:
>       case GDK_KP_Home:               
>       case
GDK_7:
>-      case GDK_KP_7:          key_move_north_west();  break;
>+      case
GDK_KP_7:
>+      key_unit_move(DIR8_NORTHWEST);
>+      break;
> 
>       case
GDK_KP_Begin:
>       case GDK_Return:
>Index:
client/gui-gtk-2.0/gui_main.c
>=============================================
======================
>RCS file:
/home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
>retrieving
revision 1.35
>diff -u -r1.35 gui_main.c
>--- client/gui-gtk-2.0/gui_main.c
2002/12/16 05:35:31     1.35
>+++ client/gui-gtk-2.0/gui_main.c      2002/12/19
07:25:26
>@@ -340,111 +340,63 @@
>     return keypress;
>   }
> 
>-  if
(is_isometric && !client_is_observer()) {
>+  if (!client_is_observer())
{
>     switch (ev->keyval) {
>       case GDK_Up:
>       case
GDK_KP_Up:
>       case GDK_8:
>-      case GDK_KP_8:
key_move_north_west();  break;
>+      case GDK_KP_8:
>+
key_unit_move(DIR8_NORTH);
>+      break;
> 
>       case GDK_Page_Up:
>
case GDK_KP_Page_Up:
>       case GDK_9:
>-      case GDK_KP_9:
key_move_north();       break;
>+      case GDK_KP_9:
>+
key_unit_move(DIR8_NORTHEAST);
>+      break;
> 
>       case GDK_Right:
>
case GDK_KP_Right:
>       case GDK_6:
>-      case GDK_KP_6:
key_move_north_east();  break;
>+      case GDK_KP_6:
>+
key_unit_move(DIR8_EAST);
>+      break;
> 
>       case GDK_Page_Down:
>
case GDK_KP_Page_Down:
>       case GDK_3:
>-      case GDK_KP_3:
key_move_east();        break;
>+      case GDK_KP_3:
>+
key_unit_move(DIR8_SOUTHEAST);
>+      break;
> 
>       case GDK_Down:
>
case GDK_KP_Down:
>       case GDK_2:
>-      case GDK_KP_2:
key_move_south_east();  break;
>+      case GDK_KP_2:
>+
key_unit_move(DIR8_SOUTH);
>+      break;
> 
>       case GDK_End:
>       case
GDK_KP_End:
>       case GDK_1:
>-      case GDK_KP_1:          key_move_south();
break;
>+      case GDK_KP_1:
>+      key_unit_move(DIR8_SOUTHWEST);
>+      break;
>

>       case GDK_Left:
>       case GDK_KP_Left:
>       case GDK_4:
>-
  case GDK_KP_4:                key_move_south_west();  break;
>+      case GDK_KP_4:
>+
key_unit_move(DIR8_WEST);
>+      break;
> 
>       case GDK_Home:
>-      case
GDK_KP_Home:
>-      case GDK_7:
>-      case GDK_KP_7:          key_move_west();
break;
>- 
>-      case GDK_KP_Begin:
>-      case GDK_5:
>-      case
GDK_KP_5:
>-        focus_to_next_unit();
>-        break;
>-  
>-
case GDK_Return:
>-      case GDK_KP_Enter:
>-        key_end_turn();
>-
    break;
>-  
>-      case GDK_Escape:
>-        key_cancel_action();
>-
      break;
>-  
>-      case GDK_t:
>-        key_city_workers(w, ev);
>-
       break;
>-
>-      default:
>-        return FALSE;
>-    }
>-  }
else if (!client_is_observer()) {
>-    switch (ev->keyval) {
>-      case
GDK_Up:
>-      case GDK_KP_Up:
>-      case GDK_8:
>-      case GDK_KP_8:
        key_move_north();       break;
>-
>-      case GDK_Page_Up:
>-      case
GDK_KP_Page_Up:
>-      case GDK_9:
>-      case GDK_KP_9:
key_move_north_east();  break;
>-
>-      case GDK_Right:
>-      case
GDK_KP_Right:
>-      case GDK_6:
>-      case GDK_KP_6:          key_move_east();
break;
>-
>-      case GDK_Page_Down:
>-      case GDK_KP_Page_Down:
>-
 case GDK_3:
>-      case GDK_KP_3:          key_move_south_east();  break;
>-
>-
   case GDK_Down:
>-      case GDK_KP_Down:
>-      case GDK_2:
>-
case GDK_KP_2:          key_move_south();       break;
>-
>-      case GDK_End:
>-
case GDK_KP_End:
>-      case GDK_1:
>-      case GDK_KP_1:
key_move_south_west();  break;
>-
>-      case GDK_Left:
>-      case
GDK_KP_Left:
>-      case GDK_4:
>-      case GDK_KP_4:          key_move_west();
break;
>-
>-      case GDK_Home:
>       case GDK_KP_Home:               
>       case
GDK_7:
>-      case GDK_KP_7:          key_move_north_west();  break;
>+      case
GDK_KP_7:
>+      key_unit_move(DIR8_NORTHWEST);
>+      break;
> 
>       case
GDK_KP_Begin:
>       case GDK_Return:
>Index:
client/gui-mui/gui_main.c
>=================================================
==================
>RCS file:
/home/freeciv/CVS/freeciv/client/gui-mui/gui_main.c,v
>retrieving revision
1.68
>diff -u -r1.68 gui_main.c
>--- client/gui-mui/gui_main.c  2002/12/13
19:15:12        1.68
>+++ client/gui-mui/gui_main.c  2002/12/19 07:25:26
>@@
-343,36 +343,31 @@
> {
>   if (*value)
>   {
>-    if (is_isometric)
>-
{
>-      switch (*value)
>-      {
>-      case UNIT_NORTH:
key_move_north_west(); break;
>-      case UNIT_SOUTH: key_move_south_east();
break;
>-      case UNIT_EAST: key_move_north_east(); break;
>-      case UNIT_WEST:
key_move_south_west(); break;
>-      case UNIT_NORTH_EAST: key_move_north();
break;
>-      case UNIT_NORTH_WEST: key_move_west(); break;
>-      case
UNIT_SOUTH_EAST: key_move_east(); break;
>-      case UNIT_SOUTH_WEST:
key_move_south();break;
>-      }
>-    } else
>-    {
>-      switch
(*value)
>-      {
>-      case UNIT_NORTH: key_move_north(); break;
>-      case
UNIT_SOUTH: key_move_south(); break;
>-      case UNIT_EAST: key_move_east();
break;
>-      case UNIT_WEST: key_move_west(); break;
>-      case UNIT_NORTH_EAST:
key_move_north_east(); break;
>-      case UNIT_NORTH_WEST:
key_move_north_west(); break;
>-      case UNIT_SOUTH_EAST:
key_move_south_east(); break;
>-      case UNIT_SOUTH_WEST:
key_move_south_west();break;
>-      }
>-    }
>-
>-    switch (*value)
>-
  {
>+    switch (*value) {
>+    case UNIT_NORTH:
>+
key_unit_move(DIR8_NORTH);
>+      break;
>+    case UNIT_SOUTH:
>+
key_unit_move(DIR8_SOUTH);
>+      break;
>+    case UNIT_EAST:
>+
key_unit_move(DIR8_EAST);
>+      break;
>+    case UNIT_WEST:
>+
key_unit_move(DIR8_WEST);
>+      break;
>+    case UNIT_NORTH_EAST:
>+
 key_unit_move(DIR8_NORTHEAST);
>+      break;
>+    case
UNIT_NORTH_WEST:
>+      key_unit_move(DIR8_NORTHWEST);
>+      break;
>+
 case UNIT_SOUTH_EAST:
>+      key_unit_move(DIR8_SOUTHEAST);
>+
break;
>+    case UNIT_SOUTH_WEST:
>+
key_unit_move(DIR8_SOUTHWEST);
>+      break;
>     case UNIT_POPUP_CITY:
>
      {
>       struct unit *punit;
>Index:
client/gui-sdl/gui_main.c
>=================================================
==================
>RCS file:
/home/freeciv/CVS/freeciv/client/gui-sdl/gui_main.c,v
>retrieving revision
1.3
>diff -u -r1.3 gui_main.c
>--- client/gui-sdl/gui_main.c  2002/12/12
03:05:00        1.3
>+++ client/gui-sdl/gui_main.c  2002/12/19 07:25:27
>@@ -238,42
+238,42 @@
>           break;
>         case SDLK_UP:
>         case SDLK_KP8:
>-
key_move_north_west();
>+          key_unit_move(DIR8_NORTH);
>           break;
> 
>
          case SDLK_PAGEUP:
>         case SDLK_KP9:
>-          key_move_north();
>+
key_unit_move(DIR8_NORTHEAST);
>           break;
> 
>         case SDLK_RIGHT:
>
case SDLK_KP6:
>-          key_move_north_east();
>+
key_unit_move(DIR8_EAST);
>           break;
> 
>         case SDLK_PAGEDOWN:
>
case SDLK_KP3:
>-          key_move_east();
>+
key_unit_move(DIR8_SOUTHEAST);
>           break;
> 
>         case SDLK_DOWN:
>
case SDLK_KP2:
>-          key_move_south_east();
>+
key_unit_move(DIR8_SOUTH);
>           break;
> 
>         case SDLK_END:
>         case
SDLK_KP1:
>-          key_move_south();
>+          key_unit_move(DIR8_SOUTHWEST);
>
    break;
> 
>         case SDLK_LEFT:
>         case SDLK_KP4:
>-
key_move_south_west();
>+          key_unit_move(DIR8_WEST);
>           break;
> 
>
  case SDLK_HOME:
>         case SDLK_KP7:
>-          key_move_west();
>+
key_unit_move(DIR8_NORTHWEST);
>           break;
> 
>         case SDLK_KP5:
>Index:
client/gui-win32/menu.c
>===================================================
================
>RCS file:
/home/freeciv/CVS/freeciv/client/gui-win32/menu.c,v
>retrieving revision
1.12
>diff -u -r1.12 menu.c
>--- client/gui-win32/menu.c    2002/11/14
09:14:59        1.12
>+++ client/gui-win32/menu.c    2002/12/19 07:25:27
>@@ -469,32
+469,34 @@
>
**************************************************************************/

> void handle_numpad(int code)
> {
>-  if (is_isometric) {
>-    switch
(code)
>-      {
>-      case IDM_NUMPAD_BASE+1: key_move_south();
break;
>-      case IDM_NUMPAD_BASE+2: key_move_south_east(); break;
>-
 case IDM_NUMPAD_BASE+3: key_move_east(); break;
>-      case
IDM_NUMPAD_BASE+4: key_move_south_west(); break;
>-      case
IDM_NUMPAD_BASE+5: focus_to_next_unit(); break;
>-      case
IDM_NUMPAD_BASE+6: key_move_north_east(); break;
>-      case
IDM_NUMPAD_BASE+7: key_move_west(); break;
>-      case IDM_NUMPAD_BASE+8:
key_move_north_west(); break;
>-      case IDM_NUMPAD_BASE+9:
key_move_north(); break;
>-      }
>-  } else {
>-    switch (code) 
>-
 { 
>-      case IDM_NUMPAD_BASE+1: key_move_south_west(); break;
>-
case IDM_NUMPAD_BASE+2: key_move_south(); break;
>-      case
IDM_NUMPAD_BASE+3: key_move_south_east(); break;
>-      case
IDM_NUMPAD_BASE+4: key_move_west(); break;
>-      case IDM_NUMPAD_BASE+5:
focus_to_next_unit(); break;
>-      case IDM_NUMPAD_BASE+6:
key_move_east(); break;
>-      case IDM_NUMPAD_BASE+7:
key_move_north_west(); break;
>-      case IDM_NUMPAD_BASE+8:
key_move_north(); break;
>-      case IDM_NUMPAD_BASE+9:
key_move_north_east(); break;
>-      }
>+  switch (code) { 
>+  case
IDM_NUMPAD_BASE + 1:
>+    key_unit_move(DIR8_SOUTHWEST);
>+    break;
>+
case IDM_NUMPAD_BASE + 2:
>+    key_unit_move(DIR8_SOUTH);
>+    break;
>+
case IDM_NUMPAD_BASE + 3:
>+    key_unit_move(DIR8_SOUTHEAST);
>+
break;
>+  case IDM_NUMPAD_BASE + 4:
>+    key_unit_move(DIR8_WEST);
>+
break;
>+  case IDM_NUMPAD_BASE + 5:
>+    focus_to_next_unit();
>+
break;
>+  case IDM_NUMPAD_BASE + 6:
>+    key_unit_move(DIR8_EAST);
>+
break;
>+  case IDM_NUMPAD_BASE + 7:
>+
key_unit_move(DIR8_NORTHWEST);
>+    break;
>+  case IDM_NUMPAD_BASE +
8:
>+    key_unit_move(DIR8_NORTH);
>+    break;
>+  case IDM_NUMPAD_BASE +
9:
>+    key_unit_move(DIR8_NORTHEAST);
>+    break;
>   }
> }
> 
>Index:
client/gui-xaw/actions.c
>==================================================
=================
>RCS file:
/home/freeciv/CVS/freeciv/client/gui-xaw/actions.c,v
>retrieving revision
1.12
>diff -u -r1.12 actions.c
>--- client/gui-xaw/actions.c   2002/11/14
09:14:59        1.12
>+++ client/gui-xaw/actions.c   2002/12/19 07:25:27
>@@ -153,42
+153,42 @@
> 
> static void xaw_key_move_north(Widget w, XEvent *event,
String *argv, Cardinal *argc)
> {
>-  key_move_north();
>+
key_unit_move(DIR8_NORTH);
> }
> 
> static void
xaw_key_move_north_east(Widget w, XEvent *event, String *argv, Cardinal
*argc)
> {
>-  key_move_north_east();
>+  key_unit_move(DIR8_NORTHEAST);
>
}
> 
> static void xaw_key_move_east(Widget w, XEvent *event, String *argv,
Cardinal *argc)
> {
>-  key_move_east();
>+  key_unit_move(DIR8_EAST);
>
}
> 
> static void xaw_key_move_south_east(Widget w, XEvent *event, String
*argv, Cardinal *argc)
> {
>-  key_move_south_east();
>+
key_unit_move(DIR8_SOUTHEAST);
> }
> 
> static void
xaw_key_move_south(Widget w, XEvent *event, String *argv, Cardinal *argc)
>
{
>-  key_move_south();
>+  key_unit_move(DIR8_SOUTH);
> }
> 
> static void
xaw_key_move_south_west(Widget w, XEvent *event, String *argv, Cardinal
*argc)
> {
>-  key_move_south_west();
>+  key_unit_move(DIR8_SOUTHWEST);
>
}
> 
> static void xaw_key_move_west(Widget w, XEvent *event, String *argv,
Cardinal *argc)
> {
>-  key_move_west();
>+  key_unit_move(DIR8_WEST);
>
}
> 
> static void xaw_key_move_north_west(Widget w, XEvent *event, String
*argv, Cardinal *argc)
> {
>-  key_move_north_west();
>+
key_unit_move(DIR8_NORTHWEST);
> }
> 
> static void
xaw_key_open_city_report(Widget w, XEvent *event, String *argv, Cardinal
*argc





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