Could you please attach patch file? Or is this fix in your git repo?
It's in the repo, commit 86a94380
Yup, I'm a lucky man! When I've compiled ottd with full optimization, I've found another little but, but this time in compiler, in MS VC++ compiler! It just ignored "value == 0 ? last_value : " part and compiled only "last_value / value". I've found this by inspecting asm code; nothing like "cmp" nor "je/jne", only "div".
If the compiler can infer that the value will always be non-zero (assuming defined behaviour) by analysing caller sites, prior and subsequent code paths, etc, it can omit the branch.
This is particularly the case when using whole program optimisation, which it sounds like you're using.
As I see it, it's just create a buffer, copy map data into it (maybe exclude something like town buildings, industry, trees, etc), and then rebuild tile by tile starting from given tileindex and using cmd's to calculate price.
This is the basic idea, but there are many details to be handled, doing it correctly is non-trivial. Generally clipboard patch implementations make sweeping changes to map storage and access methods which doesn't help for compatibility with other patches/features either.
Redirect Left wrote:
Hopefully you can submit it trunk for fixing too then? If you have that sort of access.
I will look to draft a bug report at some point.