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

 This allows editing player techs in science dialog.

 - Global observer cannot edit techs.
 - Wrong cursor. This is old bug, but it's more obvious with this patch


 - ML

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-05 21:11:59.000000000 +0200
+++ freeciv/client/gui-gtk-2.0/repodlgs.c	2007-03-08 05:55:37.000000000 +0200
@@ -184,22 +184,32 @@
   if (tech == A_NONE) {
     return;
   }
-  if (event->button == 1 && can_client_issue_orders()) {
-    /* LMB: set research or research goal */
-    switch (get_invention(game.player_ptr, tech)) {
-    case TECH_REACHABLE:
-      dsend_packet_player_research(&aconnection, tech);
-      break;
-    case TECH_UNKNOWN:
-      dsend_packet_player_tech_goal(&aconnection, tech);
-      break;
-    case TECH_KNOWN:
-      break;
-    }
-  } else if (event->button == 3) {
+
+  if (event->button == 3) {
     /* RMB: get help */
     /* FIXME: this should work for ctrl+LMB or shift+LMB (?) too */
     popup_help_dialog_typed(get_tech_name(game.player_ptr, tech), HELP_TECH);
+  } else if (!can_conn_edit(&aconnection)) {
+    if (event->button == 1 && can_client_issue_orders()) {
+      /* LMB: set research or research goal */
+      switch (get_invention(game.player_ptr, tech)) {
+       case TECH_REACHABLE:
+         dsend_packet_player_research(&aconnection, tech);
+         break;
+       case TECH_UNKNOWN:
+         dsend_packet_player_tech_goal(&aconnection, tech);
+         break;
+       case TECH_KNOWN:
+         break;
+      }
+    }
+  } else {
+    /* Editor mode */
+    if (game.player_ptr) {
+      /* Not a global observer */
+      dsend_packet_edit_player_tech(&aconnection, game.player_ptr->player_no,
+                                    tech, ETECH_TOGGLE);
+    }
   }
 }
 
diff -Nurd -X.diff_ignore freeciv/common/fc_types.h freeciv/common/fc_types.h
--- freeciv/common/fc_types.h	2007-03-05 21:11:49.000000000 +0200
+++ freeciv/common/fc_types.h	2007-03-08 05:52:45.000000000 +0200
@@ -174,4 +174,11 @@
 
 #define AI_LEVEL_DEFAULT AI_LEVEL_NOVICE
 
+enum editor_tech_mode {
+  ETECH_ADD,
+  ETECH_REMOVE,
+  ETECH_TOGGLE,
+  ETECH_LAST
+};
+
 #endif /* FC__FC_TYPES_H */
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def	2007-03-08 03:45:10.000000000 +0200
+++ freeciv/common/packets.def	2007-03-08 05:49:51.000000000 +0200
@@ -219,6 +219,7 @@
 type TEAM		= UINT8
 type CONTINENT          = sint16(Continent_id)
 type IMPROVEMENT	= uint8(Impr_type_id)
+type EDIT_TECH_MODE     = uint8(enum editor_tech_mode)
 
 # other typedefs
 type COORD  		= UINT8
@@ -1460,5 +1461,11 @@
   UINT16 small_wonders[B_LAST]; diff
 end
 
+PACKET_EDIT_PLAYER_TECH=133;cs,handle-per-conn,dsend
+  PLAYER          playerno;
+  TECH            tech;
+  EDIT_TECH_MODE  mode;
+end
+
 PACKET_EDIT_RECALCULATE_BORDERS=131;cs,handle-per-conn
 end
diff -Nurd -X.diff_ignore freeciv/server/edithand.c freeciv/server/edithand.c
--- freeciv/server/edithand.c	2007-03-05 21:09:47.000000000 +0200
+++ freeciv/server/edithand.c	2007-03-08 05:52:56.000000000 +0200
@@ -407,6 +407,43 @@
 }
 
 /****************************************************************************
+  Edit techs known by player
+****************************************************************************/
+void handle_edit_player_tech(struct connection *pc,
+                             int playerno, Tech_type_id tech,
+                             enum editor_tech_mode mode)
+{
+  struct player *pplayer = get_player(playerno);
+
+  if (!can_conn_edit(pc) || !pplayer || !tech_exists(tech)) {
+    return;
+  }
+
+  switch(mode) {
+   case ETECH_ADD:
+     set_invention(pplayer, tech, TECH_KNOWN);
+     break;
+   case ETECH_REMOVE:
+     set_invention(pplayer, tech, TECH_UNKNOWN);
+     break;
+   case ETECH_TOGGLE:
+     if (get_invention(pplayer, tech) == TECH_KNOWN) {
+       set_invention(pplayer, tech, TECH_UNKNOWN);
+     } else {
+       set_invention(pplayer, tech, TECH_KNOWN);
+     }
+     break;
+   default:
+     break;
+  }
+
+  update_research(pplayer);
+
+  /* send update back to client */
+  send_player_info(NULL, pplayer);  
+}
+
+/****************************************************************************
   Client editor requests us to recalculate borders. Note that this does
   not necessarily extend borders to their maximum due to the way the
   borders code is written. This may be considered a feature or limitation.
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in	2007-03-08 03:45:10.000000000 +0200
+++ freeciv/version.in	2007-03-08 05:19:23.000000000 +0200
@@ -24,4 +24,4 @@
 #   - Avoid adding a new manditory capbility to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-FREECIV_NETWORK_CAPSTRING("+Freeciv.Devel.2007.Mar.08")
+FREECIV_NETWORK_CAPSTRING("+Freeciv.Devel.2007.Mar.08-2")
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to