Author: cazfi
Date: Wed Dec  9 23:34:23 2015
New Revision: 30927

URL: http://svn.gna.org/viewcvs/freeciv?rev=30927&view=rev
Log:
Added authors property for scenarios

Requested by Sveinung Kvilhaugsvik <sveinung>

See patch #6450

Modified:
    branches/S2_6/client/gui-gtk-2.0/editprop.c
    branches/S2_6/client/gui-gtk-3.0/editprop.c
    branches/S2_6/client/packhand.c
    branches/S2_6/common/game.c
    branches/S2_6/common/packets.def
    branches/S2_6/fc_version
    branches/S2_6/server/edithand.c
    branches/S2_6/server/savegame.c
    branches/S2_6/server/savegame2.c

Modified: branches/S2_6/client/gui-gtk-2.0/editprop.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/editprop.c?rev=30927&r1=30926&r2=30927&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/editprop.c (original)
+++ branches/S2_6/client/gui-gtk-2.0/editprop.c Wed Dec  9 23:34:23 2015
@@ -356,6 +356,7 @@
   OPID_GAME_YEAR,
   OPID_GAME_SCENARIO,
   OPID_GAME_SCENARIO_NAME,
+  OPID_GAME_SCENARIO_AUTHORS,
   OPID_GAME_SCENARIO_DESC,
   OPID_GAME_SCENARIO_RANDSTATE,
   OPID_GAME_SCENARIO_PLAYERS,
@@ -1791,6 +1792,9 @@
       case OPID_GAME_SCENARIO_NAME:
         pv->data.v_const_string = pgame->scenario.name;
         break;
+      case OPID_GAME_SCENARIO_AUTHORS:
+        pv->data.v_const_string = pgame->scenario.authors;
+        break;
       case OPID_GAME_SCENARIO_DESC:
         pv->data.v_const_string = pgame->scenario.description;
         break;
@@ -2300,6 +2304,7 @@
       packet->year = pgame->info.year;
       packet->scenario = pgame->scenario.is_scenario;
       sz_strlcpy(packet->scenario_name, pgame->scenario.name);
+      sz_strlcpy(packet->scenario_authors, pgame->scenario.authors);
       sz_strlcpy(packet->scenario_desc, pgame->scenario.description);
       packet->scenario_players = pgame->scenario.players;
       /* TODO: Set more packet fields. */
@@ -2535,6 +2540,9 @@
         return;
       case OPID_GAME_SCENARIO_NAME:
         sz_strlcpy(packet->scenario_name, pv->data.v_const_string);
+        return;
+      case OPID_GAME_SCENARIO_AUTHORS:
+        sz_strlcpy(packet->scenario_authors, pv->data.v_const_string);
         return;
       case OPID_GAME_SCENARIO_DESC:
         sz_strlcpy(packet->scenario_desc, pv->data.v_const_string);
@@ -2975,6 +2983,7 @@
   case OPID_CITY_BUILDINGS:
   case OPID_PLAYER_NATION:
   case OPID_PLAYER_INVENTIONS:
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     ev = extviewer_new(op);
     objprop_set_extviewer(op, ev);
@@ -3185,6 +3194,7 @@
   case OPID_CITY_BUILDINGS:
   case OPID_PLAYER_NATION:
   case OPID_PLAYER_INVENTIONS:
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     ev = objprop_get_extviewer(op);
     if (pv) {
@@ -3403,6 +3413,7 @@
   case OPID_STARTPOS_NATIONS:
   case OPID_CITY_BUILDINGS:
   case OPID_PLAYER_INVENTIONS:
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     hbox = gtk_hbox_new(FALSE, 4);
     ev->panel_widget = hbox;
@@ -3490,6 +3501,7 @@
     store = gtk_list_store_new(4, G_TYPE_BOOLEAN, G_TYPE_INT,
                                GDK_TYPE_PIXBUF, G_TYPE_STRING);
     break;
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     textbuf = gtk_text_buffer_new(NULL);
     break;
@@ -3614,6 +3626,7 @@
                FALSE, FALSE, NULL, NULL);
     break;
 
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     g_signal_connect(textbuf, "changed",
                      G_CALLBACK(extviewer_textbuf_changed), ev);
@@ -3870,6 +3883,7 @@
     g_free(buf);
     break;
 
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     disable_gobject_callback(G_OBJECT(ev->textbuf),
                              G_CALLBACK(extviewer_textbuf_changed));
@@ -3877,6 +3891,7 @@
       GtkTextIter start, end;
       char *oldtext;
       /* Don't re-set content if unchanged, to avoid moving cursor */
+
       gtk_text_buffer_get_bounds(textbuf, &start, &end);
       oldtext = gtk_text_buffer_get_text(textbuf, &start, &end, TRUE);
       if (strcmp(oldtext, pv->data.v_const_string) != 0) {
@@ -3935,6 +3950,7 @@
     gtk_list_store_clear(ev->store);
     gtk_image_set_from_pixbuf(GTK_IMAGE(ev->panel_image), NULL);
     break;
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     disable_gobject_callback(G_OBJECT(ev->textbuf),
                              G_CALLBACK(extviewer_textbuf_changed));
@@ -4195,6 +4211,7 @@
   pv = &value;
 
   switch (propid) {
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     buf = propval_as_string(pv);
     gtk_label_set_text(GTK_LABEL(ev->panel_label), buf);
@@ -4362,6 +4379,9 @@
             | OPF_HAS_WIDGET | OPF_EDITABLE, VALTYPE_BOOL);
     ADDPROP(OPID_GAME_SCENARIO_NAME, _("Scenario Name"), OPF_IN_LISTVIEW
             | OPF_HAS_WIDGET | OPF_EDITABLE, VALTYPE_STRING);
+    ADDPROP(OPID_GAME_SCENARIO_AUTHORS, _("Scenario Authors"),
+            OPF_IN_LISTVIEW | OPF_HAS_WIDGET | OPF_EDITABLE,
+            VALTYPE_STRING);
     ADDPROP(OPID_GAME_SCENARIO_DESC, _("Scenario Description"),
             OPF_IN_LISTVIEW | OPF_HAS_WIDGET | OPF_EDITABLE,
             VALTYPE_STRING);

Modified: branches/S2_6/client/gui-gtk-3.0/editprop.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/editprop.c?rev=30927&r1=30926&r2=30927&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/editprop.c (original)
+++ branches/S2_6/client/gui-gtk-3.0/editprop.c Wed Dec  9 23:34:23 2015
@@ -356,6 +356,7 @@
   OPID_GAME_YEAR,
   OPID_GAME_SCENARIO,
   OPID_GAME_SCENARIO_NAME,
+  OPID_GAME_SCENARIO_AUTHORS,
   OPID_GAME_SCENARIO_DESC,
   OPID_GAME_SCENARIO_RANDSTATE,
   OPID_GAME_SCENARIO_PLAYERS,
@@ -1791,6 +1792,9 @@
       case OPID_GAME_SCENARIO_NAME:
         pv->data.v_const_string = pgame->scenario.name;
         break;
+      case OPID_GAME_SCENARIO_AUTHORS:
+        pv->data.v_const_string = pgame->scenario.authors;
+        break;
       case OPID_GAME_SCENARIO_DESC:
         pv->data.v_const_string = pgame->scenario.description;
         break;
@@ -2300,6 +2304,7 @@
       packet->year = pgame->info.year;
       packet->scenario = pgame->scenario.is_scenario;
       sz_strlcpy(packet->scenario_name, pgame->scenario.name);
+      sz_strlcpy(packet->scenario_authors, pgame->scenario.authors);
       sz_strlcpy(packet->scenario_desc, pgame->scenario.description);
       packet->scenario_players = pgame->scenario.players;
       /* TODO: Set more packet fields. */
@@ -2535,6 +2540,9 @@
         return;
       case OPID_GAME_SCENARIO_NAME:
         sz_strlcpy(packet->scenario_name, pv->data.v_const_string);
+        return;
+      case OPID_GAME_SCENARIO_AUTHORS:
+        sz_strlcpy(packet->scenario_authors, pv->data.v_const_string);
         return;
       case OPID_GAME_SCENARIO_DESC:
         sz_strlcpy(packet->scenario_desc, pv->data.v_const_string);
@@ -2987,6 +2995,7 @@
   case OPID_CITY_BUILDINGS:
   case OPID_PLAYER_NATION:
   case OPID_PLAYER_INVENTIONS:
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     ev = extviewer_new(op);
     objprop_set_extviewer(op, ev);
@@ -3200,6 +3209,7 @@
   case OPID_CITY_BUILDINGS:
   case OPID_PLAYER_NATION:
   case OPID_PLAYER_INVENTIONS:
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     ev = objprop_get_extviewer(op);
     if (pv) {
@@ -3418,6 +3428,7 @@
   case OPID_STARTPOS_NATIONS:
   case OPID_CITY_BUILDINGS:
   case OPID_PLAYER_INVENTIONS:
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     hbox = gtk_grid_new();
     gtk_grid_set_column_spacing(GTK_GRID(hbox), 4);
@@ -3510,6 +3521,7 @@
     store = gtk_list_store_new(4, G_TYPE_BOOLEAN, G_TYPE_INT,
                                GDK_TYPE_PIXBUF, G_TYPE_STRING);
     break;
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     textbuf = gtk_text_buffer_new(NULL);
     break;
@@ -3639,6 +3651,7 @@
                FALSE, FALSE, NULL, NULL);
     break;
 
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     g_signal_connect(textbuf, "changed",
                      G_CALLBACK(extviewer_textbuf_changed), ev);
@@ -3895,12 +3908,14 @@
     g_free(buf);
     break;
 
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     disable_gobject_callback(G_OBJECT(ev->textbuf),
                              G_CALLBACK(extviewer_textbuf_changed));
     {
       GtkTextIter start, end;
       char *oldtext;
+
       /* Don't re-set content if unchanged, to avoid moving cursor */
       gtk_text_buffer_get_bounds(textbuf, &start, &end);
       oldtext = gtk_text_buffer_get_text(textbuf, &start, &end, TRUE);
@@ -3960,6 +3975,7 @@
     gtk_list_store_clear(ev->store);
     gtk_image_set_from_pixbuf(GTK_IMAGE(ev->panel_image), NULL);
     break;
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     disable_gobject_callback(G_OBJECT(ev->textbuf),
                              G_CALLBACK(extviewer_textbuf_changed));
@@ -4220,6 +4236,7 @@
   pv = &value;
 
   switch (propid) {
+  case OPID_GAME_SCENARIO_AUTHORS:
   case OPID_GAME_SCENARIO_DESC:
     buf = propval_as_string(pv);
     gtk_label_set_text(GTK_LABEL(ev->panel_label), buf);
@@ -4386,6 +4403,9 @@
             | OPF_HAS_WIDGET | OPF_EDITABLE, VALTYPE_BOOL);
     ADDPROP(OPID_GAME_SCENARIO_NAME, _("Scenario Name"), OPF_IN_LISTVIEW
             | OPF_HAS_WIDGET | OPF_EDITABLE, VALTYPE_STRING);
+    ADDPROP(OPID_GAME_SCENARIO_AUTHORS, _("Scenario Authors"),
+            OPF_IN_LISTVIEW | OPF_HAS_WIDGET | OPF_EDITABLE,
+            VALTYPE_STRING);
     ADDPROP(OPID_GAME_SCENARIO_DESC, _("Scenario Description"),
             OPF_IN_LISTVIEW | OPF_HAS_WIDGET | OPF_EDITABLE,
             VALTYPE_STRING);

Modified: branches/S2_6/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/packhand.c?rev=30927&r1=30926&r2=30927&view=diff
==============================================================================
--- branches/S2_6/client/packhand.c     (original)
+++ branches/S2_6/client/packhand.c     Wed Dec  9 23:34:23 2015
@@ -2882,6 +2882,7 @@
 {
   game.scenario.is_scenario = packet->is_scenario;
   sz_strlcpy(game.scenario.name, packet->name);
+  sz_strlcpy(game.scenario.authors, packet->authors);
   sz_strlcpy(game.scenario.description, packet->description);
   game.scenario.players = packet->players;
   game.scenario.startpos_nations = packet->startpos_nations;

Modified: branches/S2_6/common/game.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/game.c?rev=30927&r1=30926&r2=30927&view=diff
==============================================================================
--- branches/S2_6/common/game.c (original)
+++ branches/S2_6/common/game.c Wed Dec  9 23:34:23 2015
@@ -340,6 +340,7 @@
   game.scenario.description[0] = '\0';
   game.scenario.is_scenario = FALSE;
   game.scenario.name[0] = '\0';
+  game.scenario.authors[0] = '\0';
   game.scenario.players = TRUE;
   game.scenario.startpos_nations = FALSE;
   game.scenario.handmade = FALSE;

Modified: branches/S2_6/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/packets.def?rev=30927&r1=30926&r2=30927&view=diff
==============================================================================
--- branches/S2_6/common/packets.def    (original)
+++ branches/S2_6/common/packets.def    Wed Dec  9 23:34:23 2015
@@ -1848,7 +1848,8 @@
 PACKET_SCENARIO_INFO = 180; sc, handle-via-packet, handle-per-conn
   BOOL   is_scenario;
   STRING name[256];
-  STRING description[MAX_LEN_PACKET];
+  STRING authors[MAX_LEN_PACKET / 5];
+  STRING description[MAX_LEN_PACKET / 5 * 3];
   BOOL   players;
   BOOL   startpos_nations;
   BOOL   save_random;
@@ -2103,7 +2104,8 @@
   YEAR year;
   BOOL scenario;
   STRING scenario_name[256];
-  STRING scenario_desc[MAX_LEN_PACKET];
+  STRING scenario_authors[MAX_LEN_PACKET / 5];
+  STRING scenario_desc[MAX_LEN_PACKET / 5 * 3];
   BOOL scenario_random;
   BOOL scenario_players;
   BOOL startpos_nations;

Modified: branches/S2_6/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=30927&r1=30926&r2=30927&view=diff
==============================================================================
--- branches/S2_6/fc_version    (original)
+++ branches/S2_6/fc_version    Wed Dec  9 23:34:23 2015
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Dec.07"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Dec.10"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: branches/S2_6/server/edithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/edithand.c?rev=30927&r1=30926&r2=30927&view=diff
==============================================================================
--- branches/S2_6/server/edithand.c     (original)
+++ branches/S2_6/server/edithand.c     Wed Dec  9 23:34:23 2015
@@ -1557,6 +1557,12 @@
     changed = TRUE;
   }
 
+  if (0 != strncmp(packet->scenario_authors, game.scenario.authors,
+                   MAX_LEN_PACKET)) {
+    sz_strlcpy(game.scenario.authors, packet->scenario_authors);
+    changed = TRUE;
+  }
+
   if (0 != strncmp(packet->scenario_desc, game.scenario.description,
                    MAX_LEN_PACKET)) {
     sz_strlcpy(game.scenario.description, packet->scenario_desc);

Modified: branches/S2_6/server/savegame.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame.c?rev=30927&r1=30926&r2=30927&view=diff
==============================================================================
--- branches/S2_6/server/savegame.c     (original)
+++ branches/S2_6/server/savegame.c     Wed Dec  9 23:34:23 2015
@@ -3037,6 +3037,7 @@
   if (scen_text[0] != '\0') {
     game.scenario.is_scenario = TRUE;
     sz_strlcpy(game.scenario.name, scen_text);
+    game.scenario.authors[0] = '\0';
     scen_text = secfile_lookup_str_default(file, "",
                                            "scenario.description");
     if (scen_text[0] != '\0') {

Modified: branches/S2_6/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame2.c?rev=30927&r1=30926&r2=30927&view=diff
==============================================================================
--- branches/S2_6/server/savegame2.c    (original)
+++ branches/S2_6/server/savegame2.c    Wed Dec  9 23:34:23 2015
@@ -2581,6 +2581,14 @@
   }
 
   buf = secfile_lookup_str_default(loading->file, "",
+                                   "scenario.authors");
+  if (buf[0] != '\0') {
+    sz_strlcpy(game.scenario.authors, buf);
+  } else {
+    game.scenario.authors[0] = '\0';
+  }
+
+  buf = secfile_lookup_str_default(loading->file, "",
                                    "scenario.description");
   if (buf[0] != '\0') {
     sz_strlcpy(game.scenario.description, buf);
@@ -2639,6 +2647,13 @@
   /* Name is mandatory to the level that is saved even if empty. */
   mod_entry = secfile_insert_str(saving->file, game.scenario.name, 
"scenario.name");
   entry_str_set_gt_marking(mod_entry, TRUE);
+
+  /* Authors list is saved only if it exist */
+  if (game.scenario.authors[0] != '\0') {
+    mod_entry = secfile_insert_str(saving->file, game.scenario.authors,
+                                   "scenario.authors");
+    entry_str_set_gt_marking(mod_entry, TRUE);
+  }
 
   /* Description is saved only if it exist */
   if (game.scenario.description[0] != '\0') {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to