Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18573) Editor: change city name
Home

[Freeciv-Dev] (PR#18573) Editor: change city name

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18573) Editor: change city name
From: "Egor Vyscrebentsov" <evyscr@xxxxxxxxx>
Date: Thu, 13 Jul 2006 14:31:18 -0700
Reply-to: bugs@xxxxxxxxxxx

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

Good daytime!

Attached patch allows to change city name in edit mode for editing
connection.
(I use editor as global observer and think that this is the best way
for editing scenario.)
No changes for gtk client made, so I think it still does not allow
global observer to be good editor.
Patch was tested in xaw client, with two another patches (enabling
edit mode in xaw client and "None" palette in editor tools [which
means map clicking works as in regular game].)

PS Why `svn diff` does not ignore *_gen.[ch]?
(*_gen.[ch] diff attached as separate file in case somebody has no
python.)

-- 
Thanks, evyscr
Index: server/srv_main.c
===================================================================
--- server/srv_main.c   (revision 12080)
+++ server/srv_main.c   (working copy)
@@ -1057,7 +1057,8 @@
       || type == PACKET_EDIT_TILE
       || type == PACKET_EDIT_UNIT
       || type == PACKET_EDIT_CREATE_CITY
-      || type == PACKET_EDIT_PLAYER) {
+      || type == PACKET_EDIT_PLAYER
+      || type == PACKET_EDIT_CITY_RENAME) {
     if (!server_handle_packet(type, packet, NULL, pconn)) {
       freelog(LOG_ERROR, "Received unknown packet %d from %s",
              type, conn_description(pconn));
Index: server/edithand.c
===================================================================
--- server/edithand.c   (revision 12080)
+++ server/edithand.c   (working copy)
@@ -322,6 +322,30 @@
 #endif
 }
 
+/****************************************************************************
+  Allows the editing client to change city name.
+****************************************************************************/
+void handle_edit_city_rename(struct connection *pc,
+                            int id, char *name)
+{
+  struct city *pcity = find_city_by_id(id);
+  char message[1024];
+
+  if (!can_conn_edit(pc) || !pcity) {
+    return;
+  }
+
+  if (!is_allowed_city_name(pcity->owner, name, message, sizeof(message))) {
+    notify_conn(pc->self, pcity->tile, E_BAD_COMMAND, _("%s"),  message);
+
+    return;
+  }
+
+  sz_strlcpy(pcity->name, name);
+  city_refresh(pcity);
+  send_city_info(NULL, pcity);
+}
+
 /**************************************************************************
  right now there are no checks whatsoever in the server. beware.
 ***************************************************************************/
Index: common/packets.def
===================================================================
--- common/packets.def  (revision 12080)
+++ common/packets.def  (working copy)
@@ -1443,3 +1443,8 @@
 
 PACKET_EDIT_RECALCULATE_BORDERS=131;cs,handle-per-conn
 end
+
+PACKET_EDIT_CITY_RENAME=132;cs,handle-per-conn,dsend
+  CITY id;
+  STRING name[MAX_LEN_NAME];
+end
Index: client/citydlg_common.c
===================================================================
--- client/citydlg_common.c     (revision 12080)
+++ client/citydlg_common.c     (working copy)
@@ -858,5 +858,9 @@
 **************************************************************************/
 int city_rename(struct city *pcity, const char *name)
 {
-  return dsend_packet_city_rename(&aconnection, pcity->id, name);
+  if (game.info.is_edit_mode && can_conn_edit(&aconnection)) {
+    return dsend_packet_edit_city_rename(&aconnection, pcity->id, name);
+  } else {
+    return dsend_packet_city_rename(&aconnection, pcity->id, name);
+  }
 }

Attachment: editor_city_rename_gen.diff.gz
Description: GNU Zip compressed data


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18573) Editor: change city name, Egor Vyscrebentsov <=