Author: cazfi
Date: Sun Jan 31 12:19:21 2016
New Revision: 31686

URL: http://svn.gna.org/viewcvs/freeciv?rev=31686&view=rev
Log:
Ruleset saving writes header comment to each ruleset file.

See patch #6872

Added:
    trunk/tools/ruledit/comments.c
    trunk/tools/ruledit/comments.h
Modified:
    trunk/tools/ruledit/Makefile.am
    trunk/tools/ruledit/rulesave.c

Modified: trunk/tools/ruledit/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/Makefile.am?rev=31686&r1=31685&r2=31686&view=diff
==============================================================================
--- trunk/tools/ruledit/Makefile.am     (original)
+++ trunk/tools/ruledit/Makefile.am     Sun Jan 31 12:19:21 2016
@@ -32,6 +32,8 @@
             meta_tab_unit.cpp
 
 freeciv_ruledit_SOURCES =      \
+               comments.c      \
+               comments.h      \
                edit_utype.cpp  \
                edit_utype.h    \
                tab_building.cpp \

Added: trunk/tools/ruledit/comments.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/comments.c?rev=31686&view=auto
==============================================================================
--- trunk/tools/ruledit/comments.c      (added)
+++ trunk/tools/ruledit/comments.c      Sun Jan 31 12:19:21 2016
@@ -0,0 +1,43 @@
+/**********************************************************************
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <fc_config.h>
+#endif
+
+/* utility */
+#include "registry_ini.h"
+#include "section_file.h"
+
+#include "comments.h"
+
+/**************************************************************************
+  Write file header.
+**************************************************************************/
+void comment_file_header(struct section_file *sfile)
+{
+
+  secfile_insert_long_comment(sfile, "\
+; Modifying this file:\n\
+; You should not modify this file except to make bugfixes or\n\
+; for other \"maintenance\".  If you want to make custom changes,\n\
+; you should create a new datadir subdirectory and copy this file\n\
+; into that directory, and then modify that copy.  Then use the\n\
+; command \"rulesetdir <mysubdir>\" in the server to have freeciv\n\
+; use your new customized file.\n\
+\n\
+; Note that the freeciv AI may not cope well with anything more\n\
+; than minor changes.\n\
+");
+
+}

Added: trunk/tools/ruledit/comments.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/comments.h?rev=31686&view=auto
==============================================================================
--- trunk/tools/ruledit/comments.h      (added)
+++ trunk/tools/ruledit/comments.h      Sun Jan 31 12:19:21 2016
@@ -0,0 +1,28 @@
+/********************************************************************** 
+ Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+***********************************************************************/
+#ifndef FC__COMMENTS_H
+#define FC__COMMENTS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct section_file;
+
+void comment_file_header(struct section_file *sfile);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* FC__COMMENTS_H */

Modified: trunk/tools/ruledit/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/rulesave.c?rev=31686&r1=31685&r2=31686&view=diff
==============================================================================
--- trunk/tools/ruledit/rulesave.c      (original)
+++ trunk/tools/ruledit/rulesave.c      Sun Jan 31 12:19:21 2016
@@ -35,6 +35,9 @@
 #include "ruleset.h"
 #include "settings.h"
 
+/* tools/ruledit */
+#include "comments.h"
+
 #include "rulesave.h"
 
 /* Ruleset format version */
@@ -52,6 +55,8 @@
 {
   struct section_file *sfile = secfile_new(TRUE);
   char buf[500];
+
+  comment_file_header(sfile);
 
   if (rsname != NULL && rsname[0] != '\0') {
     fc_snprintf(buf, sizeof(buf), "%s %s data for Freeciv", rsname, rstype);


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

Reply via email to