[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 23:45:49 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9718 >
> [kauf - Mon Aug 16 19:50:16 2004]:
>
> the function name should include "default" instead of "standard"
>
> -mike
>
Ok
--
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 17 Aug 2004 06:41:54 -0000
@@ -432,8 +432,10 @@
/* fail silently */
return;
}
- if (!section_file_load(&sf, name))
+ if (!section_file_load(&sf, name)) {
+ create_default_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_default_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 17 Aug 2004 06:42:38 -0000
@@ -370,3 +370,61 @@
freelog(LOG_DEBUG, "\n%s", buffer);
return buffer;
}
+
+
+/**************************************************************************
+ Create default cma presets for a new user (or without configuration file)
+**************************************************************************/
+void create_default_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]), ¶meters[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 17 Aug 2004 06:42:38 -0000
@@ -43,4 +43,6 @@
const struct cm_parameter *cmafec_preset_get_parameter(int index);
int cmafec_preset_num(void);
+void create_default_cma_presets(void);
+
#endif
|
|