Announcement

Collapse
No announcement yet.

[SDK] Complete whipping bugfixes.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SDK] Complete whipping bugfixes.

    As per this thread at apolyton and this thread at RBCiv I have fixed the code for whipping, such that it works is a much more sensible way.
    Specifically:
    • Production Bonuses are handled in a sane way.
    • The "truncation error" is fixed which resulted in very specific hammer counts giving exceptional value whips.
    • The penalty for whipping with 0 hammers invested is always applied correctly.
    • CIVGameSpeedInfo.xml has been adjusted to fix whips on epic - they now give 45 hammers instead of 44.

    For more info on the way it's broken in CIV just check one of the linked threads.

    The use of this mod will not break save game compatibility, you can take it in and out of CustomAssets at will.


    You can download the fixed CvGameCoreDLL.dll (includes CIVGameSpeedInfo.xml):
    WhippingFix_CoreDLL.zip (~1.2mb)

    This should go in your CustomAssets folder.


    The only cpp changes are in CvCity.cpp which you can download separately:
    WhippingFix_CvCityCpp.zip (~37kb)

    If you know what to do with this you'll know where to put it .

    C++ Code Changes:
    There are two sections of modified code, both in CvCity.cpp

    In the function int CvCity::hurryCost(bool bExtra) near the bottom the production bonuses are applied with rounding up instead of truncation.

    The function int CvCity::hurryProduction(HurryTypes eHurry) has been rewritten with basically the code from hurryCost, but inverted.



    XML Changes:
    In the Epic gamespeed section of CIVGameSpeedInfo.xml the field iHurryPercent is changed from 67 to 66.


    I believe this code to work 100% because I pretty much just modified the existing code in a simple way and also duplicated the code in a spreadsheet to quickly "test" a wide range of cases.
    More testing can't hurt though.
    Last edited by Blake; June 23, 2006, 00:14.

  • #2
    Summary of Changes:
    Firstly in patch 1.61 the correct amount of population is always killed (with the exception of the truncation error), the bug is in the hammers given.

    My bugfix corrects the hammers given. How it works is pretty simple:
    It takes the calculated pop-killed, and then multiplies it by the adjusted bundle size.

    Like lets say you want to whip a swordsman at 1/40 hammers on normal speed, with a +25% production bonus.
    This will kill 2 population.
    On normal speed the bundle size is 30 hammers, the 1.61 algorithm calculates that 2 bundles are needed, and thus gives 60 hammers towards the build. The production bonus has no effect.
    With my bugfix, it calculates that the new bundle size should be 37 hammers per population (30*1.25). Since 2 population is killed, it gives 74 hammers.

    Lets take the flipside, an Axeman at 31/35 hammers on normal speed with a +25% bonus.
    This time it calculates that 1 population is needed.
    With 1.61 it gives 2 bundles of 30 hammers, since that's the minimum to complete the build. In effect there's a +100% bonus instead of +25%.
    With my bugfix it simply gives the 37 hammers, just completing the build.

    So what you get is consistency, the production bonus is always applied correctly.

    As for rushing with no hammers invested.
    An archer at 0/25 with no production bonuses.
    It calculates that 2 population is needed.

    With 1.61 it gives 30 hammers, since a single bundle completes the build. In effect you take a -50% penalty.

    With my bugfix it calculates the hammers per pop as 20 (30/1.5) and gives you the 2 bundles, a total of 40 hammers. The penalty is applied precisely.

    A note on Overflow
    Overflow works extremely well in 1.61 but it interacted with whipping in a weird way. Overflow correction ensures that the production bonus doesn't get applied twice.

    Whipping something with 1 hammer remaining with a +50% bonus:
    With 1.61 the build will have 29 overflow, this overflow is then reduced by the 50 bonus, to 19 hammers. So the next turn you have 19 overflow from whipping. As such you effectively only get 20 raw hammers for 1 pop.

    With the bugfix whipping with 1 hammer remaining will add the full modified bundle size, in this case 45 hammers, so there is 44 overflow, this is reduced by the modifier to 29, so next turn you have 29 overflow from whipping. As such whips are always worth 30 *raw* hammers.

    Another example would be whipping any +100% boosted build with 1 hammer remaining. With 1.61 this gives the usual 30 hammers, the overflow is halved, so you only get 15(nearer to 14) raw hammers per whip. In fact with like a +200% bonus it could get as low as 10 raw hammers per pop.

    Because of the bugged overflows of 1.61 the bugfix will result in overflows which are on average larger.

    To summarize concisely, bugfixed whips always give 30 raw hammers per population (modified by game speed, wonder penalty and zero-hammer rush penalty, of course).

    Comment

    Working...
    X