<URL: http://bugs.freeciv.org/Ticket/Display.html?id=34529 >

On 3/17/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
> On 1/25/07, Daniel Markstedt <[EMAIL PROTECTED]> wrote:
> >
> > This is an issue with larger scale scenarios: nation/race specific
> > technologies clutter the tech tree overview in the GTK2 client.
>
>  Patch for S2_1 attached.
>
>  In trunk this introduces a problem that techs with root_req cannot be
> given to player even in editor mode.

 Untested version for trunk.


 - ML

diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/menu.c freeciv/client/gui-gtk-2.0/menu.c
--- freeciv/client/gui-gtk-2.0/menu.c	2007-03-14 13:15:03.000000000 +0200
+++ freeciv/client/gui-gtk-2.0/menu.c	2007-03-18 14:32:31.000000000 +0200
@@ -607,6 +607,7 @@
   switch(callback_action) {
   case MENU_EDITOR_TOGGLE:
     key_editor_toggle();
+    popdown_science_dialog(); /* Unreachbale techs in reqtree on/off */
     break;
   case MENU_EDITOR_TOOLS:
     editdlg_show_tools();
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/repodlgs.c freeciv/client/gui-gtk-2.0/repodlgs.c
--- freeciv/client/gui-gtk-2.0/repodlgs.c	2007-03-12 20:47:50.000000000 +0200
+++ freeciv/client/gui-gtk-2.0/repodlgs.c	2007-03-18 14:27:23.000000000 +0200
@@ -235,12 +235,20 @@
 static GtkWidget *create_reqtree_diagram(void)
 {
   GtkWidget *sw;
-  struct reqtree *reqtree = create_reqtree();
+  struct reqtree *reqtree;
   GtkAdjustment* adjustment;
   int width, height;
   int x;
   Tech_type_id researching;
 
+  if (can_conn_edit(&aconnection)) {
+    /* Show all techs in editor mode, not only currently reachable ones */
+    reqtree = create_reqtree(NULL);
+  } else {
+    /* Show only at some point reachable techs */
+    reqtree = create_reqtree(game.player_ptr);
+  }
+
   get_reqtree_dimensions(reqtree, &width, &height);
 
   sw = gtk_scrolled_window_new(NULL, NULL);
diff -Nurd -X.diff_ignore freeciv/client/reqtree.c freeciv/client/reqtree.c
--- freeciv/client/reqtree.c	2007-03-05 21:12:22.000000000 +0200
+++ freeciv/client/reqtree.c	2007-03-18 14:22:15.000000000 +0200
@@ -367,8 +367,10 @@
   Create a "dummy" tech tree from current ruleset.  This tree is then
   fleshed out further (see create_reqtree). This tree doesn't include
   dummy edges. Layering and ordering isn't done also.
+
+  If pplayer is given, add only techs reachable by that player to tree.
 *************************************************************************/
-static struct reqtree *create_dummy_reqtree(void)
+static struct reqtree *create_dummy_reqtree(struct player *pplayer)
 {
   struct reqtree *tree = fc_malloc(sizeof(*tree));
   struct advance *advance;
@@ -380,6 +382,12 @@
       nodes[tech] = NULL;
       continue;
     }
+    if (pplayer && !tech_is_available(pplayer, tech)) {
+      /* Reqtree requested for particular player and this tech is
+       * unreachable to him/her. */
+      nodes[tech] = NULL;
+      continue;
+    }
     nodes[tech] = new_tree_node();
     nodes[tech]->is_dummy = FALSE;
     nodes[tech]->tech = tech;
@@ -389,13 +397,18 @@
     if (!tech_exists(tech)) {
       continue;
     }
+    if (nodes[tech] == NULL) {
+      continue;
+    }
+
     advance = &advances[tech];
     /* Don't include redundant edges */
     if (advance->req[0] != A_NONE && advance->req[1] != A_LAST) {
       if ((advance->req[1] != A_NONE
-	   && !is_tech_a_req_for_goal(game.player_ptr, advance->req[0],
-				      advance->req[1]))
-	  || advance->req[1] == A_NONE) {
+          && !is_tech_a_req_for_goal(game.player_ptr, advance->req[0],
+                                     advance->req[1]))
+         || advance->req[1] == A_NONE) {
+
 	add_requirement(nodes[tech], nodes[advance->req[0]]);
       }
 
@@ -789,13 +802,15 @@
 /*************************************************************************
   Generate optimized tech_tree from current ruleset.
   You should free it by destroy_reqtree.
+
+  If pplayer is not NULL, techs unreachable to that player are not shown.
 *************************************************************************/
-struct reqtree *create_reqtree(void)
+struct reqtree *create_reqtree(struct player *pplayer)
 {
   struct reqtree *tree1, *tree2;
   int i, j;
 
-  tree1 = create_dummy_reqtree();
+  tree1 = create_dummy_reqtree(pplayer);
   longest_path_layering(tree1);
   tree2 = add_dummy_nodes(tree1);
   destroy_reqtree(tree1);
diff -Nurd -X.diff_ignore freeciv/client/reqtree.h freeciv/client/reqtree.h
--- freeciv/client/reqtree.h	2007-03-05 21:12:22.000000000 +0200
+++ freeciv/client/reqtree.h	2007-03-18 14:22:15.000000000 +0200
@@ -32,7 +32,7 @@
 
 struct reqtree;
 
-struct reqtree *create_reqtree(void);
+struct reqtree *create_reqtree(struct player *pplayer);
 void destroy_reqtree(struct reqtree *tree);
 
 void get_reqtree_dimensions(struct reqtree *tree,
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to