Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9718) Some default cma presets
Home

[Freeciv-Dev] (PR#9718) Some default cma presets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9718) Some default cma presets
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Mon, 16 Aug 2004 12:44:39 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9718 >

We need some standard cma presets available in the client. They will
help new users understand CMA.

With this patch "Max Food", "Max Gold", "Max Prod", "Max Science" and
"Very happy" presets are created if there's no configuration file (or
when it is too old)

You have to remove "[cma]" section from your ~/.civclientrc to test it.
--
mateusz
? civgame-3650.sav.gz
? civgame-3750.sav.gz
? civgame-3950.sav.gz
? core.25993
? core.26163
Index: options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.101
diff -u -r1.101 options.c
--- options.c   3 Aug 2004 00:09:44 -0000       1.101
+++ options.c   16 Aug 2004 19:34:11 -0000
@@ -432,8 +432,10 @@
     /* fail silently */
     return;
   }
-  if (!section_file_load(&sf, name))
+  if (!section_file_load(&sf, name)) {
+    create_standard_cma_presets();
     return;  
+  }
 
   /* a "secret" option for the lazy. TODO: make this saveable */
   sz_strlcpy(password, 
@@ -484,9 +486,13 @@
 
   /* Load cma presets. If cma.number_of_presets doesn't exist, don't load 
    * any, the order here should be reversed to keep the order the same */
-  num = secfile_lookup_int_default(&sf, 0, "cma.number_of_presets");
-  for (i = num - 1; i >= 0; i--) {
-    load_cma_preset(&sf, i);
+  num = secfile_lookup_int_default(&sf, -1, "cma.number_of_presets");
+  if (num == -1) {
+    create_standard_cma_presets();
+  } else {
+    for (i = num - 1; i >= 0; i--) {
+      load_cma_preset(&sf, i);
+    }
   }
  
   section_file_free(&sf);
Index: agents/cma_fec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_fec.c,v
retrieving revision 1.22
diff -u -r1.22 cma_fec.c
--- agents/cma_fec.c    20 Jul 2004 16:27:07 -0000      1.22
+++ agents/cma_fec.c    16 Aug 2004 19:34:22 -0000
@@ -370,3 +370,61 @@
   freelog(LOG_DEBUG, "\n%s", buffer);
   return buffer;
 }
+
+
+/**************************************************************************
+  Create standard cma presets for a new user (or without configuration file)
+**************************************************************************/
+void create_standard_cma_presets(void)
+{
+ int i;
+ struct cm_parameter parameters[] = {
+   { /* max food */
+     minimal_surplus: {0, 0, 0, 0, 0, 0},
+     require_happy: FALSE,
+     allow_disorder: FALSE,
+     allow_specialists: TRUE,
+     factor: {10, 1, 1, 1, 1, 1},
+     happy_factor: 0
+   }, { /* max prod */
+     minimal_surplus: {0, 0, 0, 0, 0, 0},
+     require_happy: FALSE,
+     allow_disorder: FALSE,
+     allow_specialists: TRUE,
+     factor: {1, 10, 1, 1, 1, 1},
+     happy_factor: 0
+   }, { /* max gold */
+     minimal_surplus: {0, 0, 0, 0, 0, 0},
+     require_happy: FALSE,
+     allow_disorder: FALSE,
+     allow_specialists: TRUE,
+     factor: {1, 1, 1, 10, 1, 1},
+     happy_factor: 0
+   }, { /* max science */
+     minimal_surplus: {0, 0, 0, 0, 0, 0},
+     require_happy: FALSE,
+     allow_disorder: FALSE,
+     allow_specialists: TRUE,
+     factor: {1, 1, 1, 1, 1, 10},
+     happy_factor: 0
+   }, { /* very happy */
+     minimal_surplus: {0, 0, 0, 0, 0, 0},
+     require_happy: FALSE,
+     allow_disorder: FALSE,
+     allow_specialists: TRUE,
+     factor: {1, 1, 1, 1, 1, 1},
+     happy_factor: 25
+   }   
+ };
+ const char* names[ARRAY_SIZE(parameters)] = {
+   N_("?cma:Max food"),
+   N_("?cma:Max production"),
+   N_("?cma:Max gold"),
+   N_("?cma:Max science"),
+   N_("?cma:Very happy")
+ };
+
+ for (i = ARRAY_SIZE(parameters) - 1; i >= 0; i--) {
+   cmafec_preset_add(Q_(names[i]), &parameters[i]);
+ }
+}
Index: agents/cma_fec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_fec.h,v
retrieving revision 1.5
diff -u -r1.5 cma_fec.h
--- agents/cma_fec.h    21 Dec 2002 14:19:05 -0000      1.5
+++ agents/cma_fec.h    16 Aug 2004 19:34:22 -0000
@@ -43,4 +43,6 @@
 const struct cm_parameter *cmafec_preset_get_parameter(int index);
 int cmafec_preset_num(void);
 
+void create_standard_cma_presets(void);
+
 #endif

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9718) Some default cma presets, Mateusz Stefek <=