URL:
http://gna.org/bugs/?17348
Summary: notradesize/fulltradesize is included in corruption
Project: Freeciv
Submitted by: handuman
Submitted on: Sat Dec 18 12:17:39 2010
Category: general
Severity: 3 - Normal
Priority: 5 - Normal
Status: None
Assigned to: None
Originator Email:
Open/Closed: Open
Release: 2.2.3, trunk
Discussion Lock: Any
Operating System: None
Planned Release:
___
Details:
This is related to bug #15144.
The effects of notradesize and fulltradesize settings should be calculated
separately from the normal corruption calculation. Current calculation gives
inconsistent values and allows size-dependent effects to be mitigated with
Courthouse (as kernigh predicted in bug #15144).
An example: notradesize=3, fulltradesize=9, city size 5 with
real_map_distance of 10 from capital under monarchy, no courthouse. Trade
surplus as function of trade produced by the citizen goes like:
1(+1)
2(+1)
*3(+0)*
4(+1)
5(+1)
*6(+0)*
7(+1)
8(+1)
*9(+0)*
10(+1)
11(+1)
*12(+0)*
and so on...
If the city size is 4, you only get surplus of one trade if you produce 1 or
2 trade from the city. All other (bigger) values give zero trade.
To fix, here is my suggestion. I do not have a suitable development
environmet so I cannot compile and test this. That's why I'm not attaching it
as a patch.
Index: ../SVN/trunk/common/city.c
===
--- ../SVN/trunk/common/city.c (revision 18782)
+++ ../SVN/trunk/common/city.c (working copy)
@@ -2883,6 +2883,8 @@
int city_waste(const struct city *pcity, Output_type_id otype, int total)
{
int penalty = 0;
+ int size_penalty = 0; /* separate notradesize/fulltradeisze from normal
corruption */
+ int effective_total = total; /* normal corruption calculated on total
reduced by possible size penalty */
int waste_level = get_city_output_bonus(pcity, get_output_type(otype),
EFT_OUTPUT_WASTE);
int waste_by_dist = get_city_output_bonus(pcity, get_output_type(otype),
@@ -2902,9 +2904,9 @@
if (pcity-size = notradesize) {
return total; /* Then no trade income. */
} else if (pcity-size = fulltradesize) {
- penalty = 0;
+ size_penalty = 0;
} else {
- penalty = total * (fulltradesize - pcity-size)
+ size_penalty = effective_total * (fulltradesize - pcity-size)
/ (fulltradesize - notradesize);
}
}
@@ -2920,12 +2922,20 @@
}
}
+ /* reduce the amount subjected to corruption */
+ effective_total -= size_penalty;
+
+ /* corruption/waste calculated only for the actually produced amount */
if (waste_level 0) {
-penalty += total * waste_level / 100;
+penalty += effective_total * waste_level / 100;
}
+ /* bonus calculated only for the actually produced amount */
penalty -= penalty * waste_pct / 100;
+ /* add up total penalty */
+ penalty += size_penalty;
+
return MIN(MAX(penalty, 0), total);
}
Tip: you also might want to multiply the values by 100 or so before
calculation and divide the result accordingly to not loose precision on the
way.
___
Reply to this item at:
http://gna.org/bugs/?17348
___
Message sent via/by Gna!
http://gna.org/
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev