Author: cazfi
Date: Sun Aug 23 20:52:23 2015
New Revision: 29662

URL: http://svn.gna.org/viewcvs/freeciv?rev=29662&view=rev
Log:
Save scenario name and description with gettext marking.

See patch #6273

Modified:
    trunk/server/savegame3.c
    trunk/utility/registry_ini.c
    trunk/utility/registry_ini.h

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=29662&r1=29661&r2=29662&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Sun Aug 23 20:52:23 2015
@@ -2214,6 +2214,8 @@
 ****************************************************************************/
 static void sg_save_scenario(struct savedata *saving)
 {
+  struct entry *mod_entry;
+
   /* Check status and return if not OK (sg_success != TRUE). */
   sg_check_ret();
 
@@ -2223,9 +2225,11 @@
   }
 
   secfile_insert_bool(saving->file, TRUE, "scenario.is_scenario");
-  secfile_insert_str(saving->file, game.scenario.name, "scenario.name");
-  secfile_insert_str(saving->file, game.scenario.description,
-                     "scenario.description");
+  mod_entry = secfile_insert_str(saving->file, game.scenario.name, 
"scenario.name");
+  entry_str_set_gt_marking(mod_entry, TRUE);
+  mod_entry = secfile_insert_str(saving->file, game.scenario.description,
+                                 "scenario.description");
+  entry_str_set_gt_marking(mod_entry, TRUE);
   secfile_insert_bool(saving->file, game.scenario.save_random, 
"scenario.save_random");
   secfile_insert_bool(saving->file, game.scenario.players, "scenario.players");
   secfile_insert_bool(saving->file, game.scenario.startpos_nations,

Modified: trunk/utility/registry_ini.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/utility/registry_ini.c?rev=29662&r1=29661&r2=29662&view=diff
==============================================================================
--- trunk/utility/registry_ini.c        (original)
+++ trunk/utility/registry_ini.c        Sun Aug 23 20:52:23 2015
@@ -656,6 +656,7 @@
       for (ent_iter = entry_list_head(section_entries(psection));
            ent_iter && (pentry = entry_list_link_data(ent_iter));
            ent_iter = entry_list_link_next(ent_iter)) {
+        const char *comment;
 
         /* Tables: break out of this loop if this is a non-table
          * entry (pentry and ent_iter unchanged) or after table (pentry
@@ -807,8 +808,9 @@
           ent_iter = col_iter;
         }
 
-        if (entry_comment(pentry)) {
-          fz_fprintf(fs, "#%s\n", entry_comment(pentry));
+        comment = entry_comment(pentry);
+        if (comment) {
+          fz_fprintf(fs, "#%s\n", comment);
         } else {
           fz_fprintf(fs, "\n");
         }
@@ -2836,6 +2838,7 @@
     struct {
       char *value;              /* Malloced string. */
       bool escaped;             /* " or $. Usually TRUE */
+      bool gt_marking;          /* Save with gettext marking. */
     } string;
   };
 };
@@ -2930,6 +2933,7 @@
     pentry->type = ENTRY_STR;
     pentry->string.value = fc_strdup(NULL != value ? value : "");
     pentry->string.escaped = escaped;
+    pentry->string.gt_marking = FALSE;
   }
 
   return pentry;
@@ -3220,6 +3224,20 @@
                              ENTRY_STR == pentry->type, FALSE);
 
   pentry->string.escaped = escaped;
+  return TRUE;
+}
+
+/**************************************************************************
+  Sets if the string should get gettext marking. Returns TRUE on success.
+**************************************************************************/
+bool entry_str_set_gt_marking(struct entry *pentry, bool gt_marking)
+{
+  SECFILE_RETURN_VAL_IF_FAIL(NULL, NULL, NULL != pentry, FALSE);
+  SECFILE_RETURN_VAL_IF_FAIL(pentry->psection->secfile, pentry->psection,
+                             ENTRY_STR == pentry->type, FALSE);
+
+  pentry->string.gt_marking = gt_marking;
+
   return TRUE;
 }
 
@@ -3240,7 +3258,11 @@
   case ENTRY_STR:
     if (pentry->string.escaped) {
       make_escapes(pentry->string.value, buf, sizeof(buf));
-      fz_fprintf(fs, "\"%s\"", buf);
+      if (pentry->string.gt_marking) {
+        fz_fprintf(fs, "_(\"%s\")", buf);
+      } else {
+        fz_fprintf(fs, "\"%s\"", buf);
+      }
     } else {
       fz_fprintf(fs, "$%s$", pentry->string.value);
     }

Modified: trunk/utility/registry_ini.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/utility/registry_ini.h?rev=29662&r1=29661&r2=29662&view=diff
==============================================================================
--- trunk/utility/registry_ini.h        (original)
+++ trunk/utility/registry_ini.h        Sun Aug 23 20:52:23 2015
@@ -612,6 +612,7 @@
 bool entry_str_set(struct entry *pentry, const char *value);
 bool entry_str_escaped(const struct entry *pentry);
 bool entry_str_set_escaped(struct entry *pentry, bool escaped);
+bool entry_str_set_gt_marking(struct entry *pentry, bool gt_marking);
 
 #ifdef __cplusplus
 }


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

Reply via email to