Old bug in macros.h
Moderator: OpenTTD Developers
Old bug in macros.h
There is a bug in CHANCE16 macros which causes industry growth miscalculation with smooth economy. Its in SVN since revision 1.
Patch for 0.4.7 attached, should apply to trunk too.
Patch for 0.4.7 attached, should apply to trunk too.
- Attachments
-
- macros-0.4.7.patch
- (750 Bytes) Downloaded 214 times
Re: Old bug in macros.h
If it's been in macros.h since revision 1, how do you know it's an error? :PASM wrote:There is a bug in CHANCE16 macros which causes industry growth miscalculation with smooth economy. Its in SVN since revision 1.
Patch for 0.4.7 attached, should apply to trunk too.
Re: Old bug in macros.h
Because it makes smooth economy unusableRyalla wrote:If it's been in macros.h since revision 1, how do you know it's an error?

With it we have 20/1024 chance of production decrease and same chance of production increase, so industries doesn't grow at all.
Re: Old bug in macros.h
Indeed it is - smooth economy without my improved patch (didn't touch the macros though) is totally unusable - industries mostly decrease if they are being used and increase if they are not used... :-SASM wrote:Because it makes smooth economy unusableRyalla wrote:If it's been in macros.h since revision 1, how do you know it's an error?![]()
With it we have 20/1024 chance of production decrease and same chance of production increase, so industries doesn't grow at all.
At any rate - I'll test your patch...
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Wow - it's already been included into trunk...
It works - quite nicely - now 2 more bugs with the current smooth_economy - IT_FARM_2 = tropical maize_farm doesn't plant any fields and once industry production decreases to 32/40 units per month it does not increase anymore, which is annoying - here is a quick fix for those 2 bugs.
It works - quite nicely - now 2 more bugs with the current smooth_economy - IT_FARM_2 = tropical maize_farm doesn't plant any fields and once industry production decreases to 32/40 units per month it does not increase anymore, which is annoying - here is a quick fix for those 2 bugs.
- Attachments
-
- smooth_econ_quick_fix.patch
- diff_-_r5095
- (905 Bytes) Downloaded 193 times
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Oh cry me a river - it's fixed now, ain't it?henrik wrote:And this is why macros are evil and should rarely be used. Inline functions are so much better for this kind of thing!
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
It takes into account all of the a, especially if a is something likeMeusH wrote:Can anyone explain me the patch by ASM? How do a and (a) differ?
x + ((20 * pct_transported) >> 8 ).

NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names, Use-able default aircraft, Oil Rig for Snowland and Desert, Speed for Suspension bridges.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.
Keep 'em rollin'!
It's about what happens at the precompiling stage. Suppose you have the codeMeusH wrote:Can anyone explain me the patch by ASM? How do a and (a) differ?
Code: Select all
#define SQUARE(a) a*a
Now if you put in something like
Code: Select all
SQUARE(2+3);
Code: Select all
#define SQUARE(a) (a)*(a)
Code: Select all
SQUARE(2+3);
[edit]Whoops. Don't forget to check when copy-pasting next time

Last edited by hertogjan on 20 Jun 2006 19:03, edited 1 time in total.
Code: Select all
#define SQUARE(a) (a)*(a)

Let's turn it into this, shall we?glx wrote:return the correct valueCode: Select all
#define SQUARE(a) (a)*(a)

Code: Select all
#define SQUARE(a) ((a)*(a))
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
Who is online
Users browsing this forum: No registered users and 8 guests