Re: [Freeciv-Dev] (PR#40607) City Health patch

2009-05-11 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40607 

2009/5/11 Marko Lindqvist cazf...@gmail.com:
 2009/5/8  :

 [cazf...@gmail.com - Mo 04. Mai. 2009, 09:53:10]:

 2009/1/7 Marko Lindqvist cazf...@gmail.com:
  2008/12/21 Yoav Luft:
 
  Hi, I think it's pretty much finished, at least the basic
 functionality.
  The attached .diff file adds the functionality of cities losing
  population when they grow too large due to diseases.
 

 I attached my last version. Changes:

 * reduced formula for the AI effect evaluation
 * change calculation of trade illness
 * save plague status for each city (never or turn x)
 * ruleset updates

  Ok, I updated this myself

  - Updated against svn
  - Adjusted AI effect evaluation
  - Marked illness text for translation
  - Typo  style fixes
  - Renamed Illness effect as Health and now positive effects are good
  - Removed plague from default ruleset
  - Renamed event E_CITY_ILL as E_CITY_PLAGUE
  - Illness value was not saved nor recalculated at game load. Fixed
 this by moving city_illness() call from update_city_activity() to
 city_refresh_from_main_map()
  - Send illness information to client side
  - Added illness value initialization to #ifdef'd part of
 create_city_virtual() for completeness (it's allocated with
 fc_calloc() anyway)
  - Fixed initialization of pcity-turn_plague to value -1 (was inside #ifdef)

 - In plague risk info popup, list each effect source (instead of just
combined value of effects and calling it, possibly incorrectly,
building effects)
 - Documentation updated


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aicity.c freeciv/ai/aicity.c
--- freeciv/ai/aicity.c 2008-10-27 04:13:32.0 +0200
+++ freeciv/ai/aicity.c 2009-05-11 14:30:46.0 +0300
@@ -520,6 +520,12 @@
   case EFT_GROWTH_FOOD:
 v += c * 4 + (amount / 7) * pcity-surplus[O_FOOD];
 break;
+  case EFT_HEALTH:
+/* Is plague possible */
+if (game.info.plague_on  pcity-size  1) {
+  v += c * 5 + (amount / 5) * pcity-illness;
+}
+break;
   case EFT_AIRLIFT:
 /* FIXME: We need some smart algorithm here. The below is 
  * totally braindead. */
diff -Nurd -X.diff_ignore freeciv/client/citydlg_common.c 
freeciv/client/citydlg_common.c
--- freeciv/client/citydlg_common.c 2009-01-25 16:51:10.0 +0200
+++ freeciv/client/citydlg_common.c 2009-05-11 14:31:17.0 +0300
@@ -490,6 +490,43 @@
 }
 
 /**
+  Return text describing the chance for a plague.
+**/
+void get_city_dialog_illness_text(const struct city *pcity,
+  char *buf, size_t bufsz)
+{
+  int illness, trade, from_size;
+  struct effect_list *plist;
+
+  illness = city_illness(pcity, trade, NULL, from_size);
+  buf[0] = '\0';
+
+  cat_snprintf(buf, bufsz, _(%+2.1f : Risk from trade\n),
+   ((float)(trade) / 10.0));
+  cat_snprintf(buf, bufsz, _(%+2.1f : Risk from over crowdness\n),
+   ((float)(from_size) / 10.0));
+
+  plist = effect_list_new();
+
+  (void) get_city_bonus_effects(plist, pcity, NULL, EFT_HEALTH);
+
+  effect_list_iterate(plist, peffect) {
+char buf2[512];
+
+get_effect_req_text(peffect, buf2, sizeof(buf2));
+
+cat_snprintf(buf, bufsz,
+ _(%+2.1f : Bonus from %s\n),
+ -peffect-value / 10.0, buf2);
+  } effect_list_iterate_end;
+  effect_list_free(plist);
+
+  cat_snprintf(buf, bufsz, _( : Adds up to\n));
+  cat_snprintf(buf, bufsz, _(%2.1f : Total chance for a plague),
+   ((float)(illness) / 10.0));
+}
+
+/**
   Return text describing the pollution output.
 **/
 void get_city_dialog_pollution_text(const struct city *pcity,
diff -Nurd -X.diff_ignore freeciv/client/citydlg_common.h 
freeciv/client/citydlg_common.h
--- freeciv/client/citydlg_common.h 2008-10-27 04:14:03.0 +0200
+++ freeciv/client/citydlg_common.h 2009-05-11 14:30:46.0 +0300
@@ -49,6 +49,8 @@
 char *buffer, size_t bufsz);
 void get_city_dialog_pollution_text(const struct city *pcity,
char *buffer, size_t bufsz);
+void get_city_dialog_illness_text(const struct city *pcity,
+  char *buf, size_t bufsz);
 
 int get_city_citizen_types(struct city *pcity, enum citizen_feeling index,
   enum citizen_category *citizens);
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/citydlg.c 
freeciv/client/gui-gtk-2.0/citydlg.c
--- freeciv/client/gui-gtk-2.0/citydlg.c2009-01-29 13:44:59.0 
+0200
+++ freeciv/client/gui-gtk-2.0/citydlg.c2009-05-11 14:30:46.0 
+0300
@@ -95,7 +95,7 @@
 enum info_style { NORMAL, ORANGE, RED, 

Re: [Freeciv-Dev] (PR#40607) City Health patch

2009-05-10 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40607 

2009/5/8  :

 [cazf...@gmail.com - Mo 04. Mai. 2009, 09:53:10]:

 2009/1/7 Marko Lindqvist cazf...@gmail.com:
  2008/12/21 Yoav Luft:
 
  Hi, I think it's pretty much finished, at least the basic
 functionality.
  The attached .diff file adds the functionality of cities losing
  population when they grow too large due to diseases.
 
   I found additional comments in RT ticket that were not sent to
  mailing list. I looked latest version of the patch,
  40607-freeciv-svn15395-health.patch.diff.

  Is anybody working on this?


 I did try to adapt the patch, especially the AI effect evaluation. But
 I did not understand how and why it is calculated ... After some time
 I moved on to the gold upkeep patch. I still observe this patch but at
 the moment my time to work on this is very limited and if I find some
 time it is the upkeep patch.

 I attached my last version. Changes:

 * reduced formula for the AI effect evaluation
 * change calculation of trade illness
 * save plague status for each city (never or turn x)
 * ruleset updates

 Ok, I updated this myself

 - Updated against svn
 - Adjusted AI effect evaluation
 - Marked illness text for translation
 - Typo  style fixes
 - Renamed Illness effect as Health and now positive effects are good
 - Removed plague from default ruleset
 - Renamed event E_CITY_ILL as E_CITY_PLAGUE
 - Illness value was not saved nor recalculated at game load. Fixed
this by moving city_illness() call from update_city_activity() to
city_refresh_from_main_map()
 - Send illness information to client side
 - Added illness value initialization to #ifdef'd part of
create_city_virtual() for completeness (it's allocated with
fc_calloc() anyway)
 - Fixed initialization of pcity-turn_plague to value -1 (was inside #ifdef)

 Untested


 PS: If it is possible I would like to get an email if a comment to
 this patch is added (matthias.pfaffer...@mapfa.de)

 Added you to ticket watchers.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aicity.c freeciv/ai/aicity.c
--- freeciv/ai/aicity.c 2008-10-27 04:13:32.0 +0200
+++ freeciv/ai/aicity.c 2009-05-11 00:57:24.0 +0300
@@ -520,6 +520,12 @@
   case EFT_GROWTH_FOOD:
 v += c * 4 + (amount / 7) * pcity-surplus[O_FOOD];
 break;
+  case EFT_HEALTH:
+/* Is plague possible */
+if (game.info.plague_on  pcity-size  1) {
+  v += c * 5 + (amount / 5) * pcity-illness;
+}
+break;
   case EFT_AIRLIFT:
 /* FIXME: We need some smart algorithm here. The below is 
  * totally braindead. */
diff -Nurd -X.diff_ignore freeciv/client/citydlg_common.c 
freeciv/client/citydlg_common.c
--- freeciv/client/citydlg_common.c 2009-01-25 16:51:10.0 +0200
+++ freeciv/client/citydlg_common.c 2009-05-11 00:25:51.0 +0300
@@ -490,6 +490,28 @@
 }
 
 /**
+  Return text describing the chance for a plague.
+**/
+void get_city_dialog_illness_text(const struct city *pcity,
+  char *buf, size_t bufsz)
+{
+  int illness, trade, effects, from_size;
+
+  illness = city_illness(pcity, trade, effects, from_size);
+  buf[0] = '\0';
+
+  cat_snprintf(buf, bufsz, _(%+2.1f : Risk from trade\n),
+   ((float)(trade) / 10.0));
+  cat_snprintf(buf, bufsz, _(%+2.1f : Risk from over crowdness\n),
+   ((float)(from_size) / 10.0));
+  cat_snprintf(buf, bufsz, _(%+2.1f : Effect of buildings\n),
+   ((float)(effects) / 10.0));
+  cat_snprintf(buf, bufsz, _( : Adds up to\n));
+  cat_snprintf(buf, bufsz, _(%2.1f : Total chance for a plague),
+   ((float)(illness) / 10.0));
+}
+
+/**
   Return text describing the pollution output.
 **/
 void get_city_dialog_pollution_text(const struct city *pcity,
diff -Nurd -X.diff_ignore freeciv/client/citydlg_common.h 
freeciv/client/citydlg_common.h
--- freeciv/client/citydlg_common.h 2008-10-27 04:14:03.0 +0200
+++ freeciv/client/citydlg_common.h 2009-05-11 00:16:36.0 +0300
@@ -49,6 +49,8 @@
 char *buffer, size_t bufsz);
 void get_city_dialog_pollution_text(const struct city *pcity,
char *buffer, size_t bufsz);
+void get_city_dialog_illness_text(const struct city *pcity,
+  char *buf, size_t bufsz);
 
 int get_city_citizen_types(struct city *pcity, enum citizen_feeling index,
   enum citizen_category *citizens);
diff -Nurd -X.diff_ignore freeciv/client/gui-gtk-2.0/citydlg.c 
freeciv/client/gui-gtk-2.0/citydlg.c
--- freeciv/client/gui-gtk-2.0/citydlg.c2009-01-29 13:44:59.0 
+0200
+++ 

[Freeciv-Dev] (PR#40607) City Health patch

2009-05-09 Thread guest

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40607 

 [cazf...@gmail.com - Mo 04. Mai. 2009, 09:53:10]:
 
 2009/1/7 Marko Lindqvist cazf...@gmail.com:
  2008/12/21 Yoav Luft:
 
  Hi, I think it's pretty much finished, at least the basic 
functionality.
  The attached .diff file adds the functionality of cities losing
  population when they grow too large due to diseases.
 
   I found additional comments in RT ticket that were not sent to
  mailing list. I looked latest version of the patch,
  40607-freeciv-svn15395-health.patch.diff.
 
  Is anybody working on this?
 

I did try to adapt the patch, especially the AI effect evaluation. But 
I did not understand how and why it is calculated ... After some time 
I moved on to the gold upkeep patch. I still observe this patch but at 
the moment my time to work on this is very limited and if I find some 
time it is the upkeep patch.

I attached my last version. Changes:

* reduced formula for the AI effect evaluation
* change calculation of trade illness
* save plague status for each city (never or turn x)
* ruleset updates

Matthias

PS: If it is possible I would like to get an email if a comment to 
this patch is added (matthias.pfaffer...@mapfa.de)

 
  - ML
 
 
 

diff -urN -X./freeciv-2.1.99svn15584/diff_ignore freeciv-2.1.99svn15584/ai/aicity.c freeciv-2.1.99svn15584.health/ai/aicity.c
--- freeciv-2.1.99svn15584/ai/aicity.c	2009-01-05 11:54:27.0 +0100
+++ freeciv-2.1.99svn15584.health/ai/aicity.c	2009-03-23 20:48:22.937206187 +0100
@@ -520,6 +520,11 @@
   case EFT_GROWTH_FOOD:
 v += c * 4 + (amount / 7) * pcity-surplus[O_FOOD];
 break;
+  case EFT_ILLNESS:
+/* old formula:
+ * v += c * 5 + (amount / 5) * pcity-illness + pcity-had_plague * 20; */
+v += c * 5 + (amount / 5) * pcity-illness;
+break;
   case EFT_AIRLIFT:
 /* FIXME: We need some smart algorithm here. The below is 
  * totally braindead. */
diff -urN -X./freeciv-2.1.99svn15584/diff_ignore freeciv-2.1.99svn15584/client/citydlg_common.c freeciv-2.1.99svn15584.health/client/citydlg_common.c
--- freeciv-2.1.99svn15584/client/citydlg_common.c	2009-01-10 20:17:51.0 +0100
+++ freeciv-2.1.99svn15584.health/client/citydlg_common.c	2009-03-23 20:48:22.941206067 +0100
@@ -490,6 +490,28 @@
 }
 
 /**
+  Return text describing the chance for a plague.
+**/
+void get_city_dialog_illness_text(const struct city *pcity,
+  char *buf, size_t bufsz)
+{
+  int illness, trade, effects, from_size;
+
+  illness = city_illness(pcity, trade, effects, from_size);
+  buf[0] = '\0';
+
+  cat_snprintf(buf, bufsz, %+2.1f : Risk from trade\n,
+   ((float)(trade) / 10.0));
+  cat_snprintf(buf, bufsz, %+2.1f : Risk from over crowdness\n,
+   ((float)(from_size) / 10.0));
+  cat_snprintf(buf, bufsz, %+2.1f : Effect of buildings\n,
+   ((float)(effects) / 10.0));
+  cat_snprintf(buf, bufsz,  : Adds up to\n);
+  cat_snprintf(buf, bufsz, %2.1f : Total chance for a plgue,
+   ((float)(illness) / 10.0));
+}
+
+/**
   Return text describing the pollution output.
 **/
 void get_city_dialog_pollution_text(const struct city *pcity,
diff -urN -X./freeciv-2.1.99svn15584/diff_ignore freeciv-2.1.99svn15584/client/citydlg_common.h freeciv-2.1.99svn15584.health/client/citydlg_common.h
--- freeciv-2.1.99svn15584/client/citydlg_common.h	2009-01-05 11:56:00.0 +0100
+++ freeciv-2.1.99svn15584.health/client/citydlg_common.h	2009-03-23 20:48:22.941206067 +0100
@@ -49,6 +49,8 @@
  char *buffer, size_t bufsz);
 void get_city_dialog_pollution_text(const struct city *pcity,
 char *buffer, size_t bufsz);
+void get_city_dialog_illness_text(const struct city *pcity,
+  char *buf, size_t bufsz);
 
 int get_city_citizen_types(struct city *pcity, enum citizen_feeling index,
 			   enum citizen_category *citizens);
diff -urN -X./freeciv-2.1.99svn15584/diff_ignore freeciv-2.1.99svn15584/client/gui-gtk-2.0/citydlg.c freeciv-2.1.99svn15584.health/client/gui-gtk-2.0/citydlg.c
--- freeciv-2.1.99svn15584/client/gui-gtk-2.0/citydlg.c	2009-02-01 19:26:51.0 +0100
+++ freeciv-2.1.99svn15584.health/client/gui-gtk-2.0/citydlg.c	2009-03-23 20:48:22.945205388 +0100
@@ -95,7 +95,7 @@
 enum info_style { NORMAL, ORANGE, RED, NUM_INFO_STYLES };
 
 #define NUM_CITIZENS_SHOWN 23
-#define NUM_INFO_FIELDS 11  /* number of fields in city_info */
+#define NUM_INFO_FIELDS 12  /* number of fields in city_info */
 #define NUM_PAGES 6 /* the number of pages in city dialog notebook 
  * (+1) if you change this, you must add an
 

[Freeciv-Dev] (PR#40607) City Health patch

2009-01-08 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40607 

 [guest - Wed Jan 07 22:25:51 2009]:
 
  [cazf...@gmail.com - Mi 07. Jan 2009, 18:43:54]:
/*
 * Note: If you add a new event, make sure you make a similar 
 change
 * to the events array in common/events.c using GEN_EV,
 * data/stdsoundes and to server/scripting/api.pkg
 */
 
 I read this but found that there are some events missing in the file. 
 I wanted to take the easy way out. Should there be a patch to first 
 add the missing data to both files?

 I imagine there could be some special events that are not needed in
those files, but more likely someone has just ignored to add them.
Please send patch (in new ticket) and we will check it.

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40607) City Health patch

2009-01-07 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40607 

2008/12/21 Yoav Luft:

 Hi, I think it's pretty much finished, at least the basic functionality.
 The attached .diff file adds the functionality of cities losing
 population when they grow too large due to diseases.

 I found additional comments in RT ticket that were not sent to
mailing list. I looked latest version of the patch,
40607-freeciv-svn15395-health.patch.diff.

 So far I only read it through and tested compile.

 Basic functionality is rather simple. Good. Extra penalty from cities
we trade with and had plague seems like unnecessary complication. It
adds realism, but no new value to the game. How often you end with
plague, and how often that happens to trigger another plague anyway. I
would leave that part out, at least for now until basic functionality
has been in use for some time.

 AI effect evaluation seems wrong to me
v += c * 5 + (amount / 5) * pcity-illness + pcity-had_plague * 20;
 - Should return 0 if plague is turned off in ruleset
 - Should return 0 for size 1 city which never can be subject to plague
 - Had_plague does not increase possibility of the future plague
(actually it makes it smaller, as city gets smaller)


 Coding style dictates that variables cannot be declared in the middle
of the block. By removing braces somewhere in cityturn.c you leave
int id in the middle of the block.

 Since you are adding new event, not this comment in event.h:
  /*
   * Note: If you add a new event, make sure you make a similar change
   * to the events array in common/events.c using GEN_EV,
   * data/stdsoundes and to server/scripting/api.pkg
   */


 - ML



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev