Re: [Freeciv-Dev] (PR#37312) [Patch] Edit map knowledge

2007-03-04 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=37312 

On 3/2/07, Marko Lindqvist [EMAIL PROTECTED] wrote:

  This allows editing what tiles player knows.

 - Updated against svn
 - Fixed a bug that ETOOL_PLAYER was handled as ETOOL_VISION

 It still makes sense to edit only your own map knowledge. For that
you get visual feedback. Still, player selection menu remained in this
version.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/editor.c freeciv/client/editor.c
--- freeciv/client/editor.c	2007-03-04 18:03:59.0 +0200
+++ freeciv/client/editor.c	2007-03-05 03:17:38.0 +0200
@@ -40,6 +40,8 @@
 static enum editor_paint_type selected_paint_type = EPAINT_LAST;
 static struct unit *selected_unit;
 static struct city *selected_city;
+static struct player *selected_player;
+static enum editor_vision_mode selected_vision_mode;
 
 /
   Initialize the editor tools data.
@@ -66,6 +68,8 @@
   selected_paint_type = EPAINT_LAST;
   selected_terrain = NULL;
   selected_resource = NULL;
+  selected_player = NULL;
+  selected_vision_mode = EVISION_LAST;
 }
 
 /
@@ -109,6 +113,22 @@
 }
 
 /
+  Sets the selected editor player.
+/
+void editor_set_selected_player(struct player *pplayer)
+{
+  selected_player = pplayer;
+}
+
+/
+  Sets the selected editor vision modifying tool.
+/
+void editor_set_vision_mode(enum editor_vision_mode mode)
+{
+  selected_vision_mode = mode;
+}
+
+/
   Returns the selected unit.
 /
 struct unit *editor_get_selected_unit(void)
@@ -184,6 +204,21 @@
   return CURSOR_EDIT_ADD;
 }
 
+/
+  Edit vision
+/
+static enum cursor_type editor_vision(struct tile *ptile, bool testing)
+{
+  if (!testing) {
+if (selected_player) {
+  dsend_packet_edit_vision(aconnection, selected_player-player_no,
+   ptile-x, ptile-y, selected_vision_mode);
+}
+  }
+
+  return CURSOR_EDIT_PAINT;
+}
+
 #if 0
 /
  basically package_city in citytools.c
@@ -263,7 +298,8 @@
 {
   /* Editing tiles that we can't see (or are fogged) will only lead to
* problems. */
-  if (client_tile_get_known(ptile) != TILE_KNOWN) {
+  if (selected_tool != ETOOL_VISION 
+  client_tile_get_known(ptile) != TILE_KNOWN) {
 return CURSOR_INVALID;
   }
 
@@ -281,6 +317,9 @@
 }
 return editor_city(ptile, testing);
   case ETOOL_PLAYER:
+break;
+  case ETOOL_VISION:
+return editor_vision(ptile, testing);
   case ETOOL_DELETE:
   case ETOOL_LAST:
 break;
diff -Nurd -X.diff_ignore freeciv/client/editor.h freeciv/client/editor.h
--- freeciv/client/editor.h	2007-03-04 18:03:59.0 +0200
+++ freeciv/client/editor.h	2007-03-05 03:15:26.0 +0200
@@ -21,6 +21,7 @@
   ETOOL_UNIT,
   ETOOL_CITY,
   ETOOL_PLAYER,
+  ETOOL_VISION,
   ETOOL_DELETE,
   ETOOL_LAST
 };
@@ -42,6 +43,8 @@
 void editor_set_selected_terrain(struct terrain *pterrain);
 void editor_set_selected_special(enum tile_special_type special);
 void editor_set_selected_resource(struct resource *presource);
+void editor_set_selected_player(struct player *pplayer);
+void editor_set_vision_mode(enum editor_vision_mode mode);
 
 struct unit *editor_get_selected_unit(void);
 struct city *editor_get_selected_city(void);
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/editdlg.c freeciv/client/gui-gtk-2.0/editdlg.c
--- freeciv/client/gui-gtk-2.0/editdlg.c	2007-03-04 18:03:59.0 +0200
+++ freeciv/client/gui-gtk-2.0/editdlg.c	2007-03-05 03:14:08.0 +0200
@@ -72,8 +72,14 @@
 
 static paint_item *resources;
 
+static paint_item vision_items[] = {
+  { N_(Known),   EVISION_ADD },
+  { N_(Unknown), EVISION_REMOVE },
+  { N_(Toggle),  EVISION_TOGGLE }
+};
+
 static char *tool_names[ETOOL_LAST] = {
-  N_(Paint), N_(Unit), N_(City), N_(Player), N_(Delete)
+  N_(Paint), N_(Unit), N_(City), N_(Player), N_(Vision), N_(Delete)
 };
 
 #define SPECIALS_NUM ARRAY_SIZE(specials)
@@ -83,6 +89,7 @@
 
 static GList *tool_group;
 static GList *map_group;
+static GList *vision_group;
 
 /
   handle the toggle buttons' toggle events
@@ -187,6 +194,13 @@
   }
 }
 
+static void set_selected_vision_paint(GtkWidget 

Re: [Freeciv-Dev] (PR#37312) [Patch] Edit map knowledge

2007-03-04 Thread Egor Vyscrebentsov

URL: http://bugs.freeciv.org/Ticket/Display.html?id=37312 

On Sun, 4 Mar 2007 Marko Lindqvist wrote:

 On 3/2/07, Marko Lindqvist cazfi74@ wrote:
 
   This allows editing what tiles player knows.

  - Updated against svn
  - Fixed a bug that ETOOL_PLAYER was handled as ETOOL_VISION

  It still makes sense to edit only your own map knowledge. For that
 you get visual feedback. Still, player selection menu remained in this
 version.

So, global observer couldn't make anything now, right? Is it
planned to get things working proberly with observer anywhen?

I still think that editing [map/]scenario as global observer
is a best way.

-- 
Thanks, evyscr



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev