Energy output bugs

Upgrading buildings bug (fix) above 65535 credits; support/discussion/questions

Moderator: thunderchero

Post Reply
User avatar
Korth
Ensign
Ensign
Posts: 48
Joined: Wed Nov 15, 2017 9:13 am

Energy output bugs

Post by Korth » Fri Nov 17, 2017 2:07 pm

... Not sure where to put this thread, and not sure if it's already been discussed (or fixed), but I haven't found the topic mentioned elsewhere and don't mind if it's moved ...



First game bug ...
Newly-built structures are unpowered if the exact amount of needed Energy is available.

Example: a Shipyard needs 25 Energy and is built on a system with exactly +25 Energy available but it initially stays unpowered.

Manually clicking to power the structure on then Save/Load game can be used as a workaround (which is important when you immediately need the increased range from that new Shipyard to move ships this turn).

But it's sometimes a little annoying and it seems like a simple thing to fix (change a specific conditional CMP instruction or increment/decrement the parameter it checks against by one).



Second game bug ...
Scrapping Energy-producing structures subtracts from Energy output.
When population is unallocated from Energy-producing structures AND some of Energy-producing structures are scrapped then the game subtracts Energy output from both together in some strange combination.

Example: starting a new game with Federation tech 1, the Sol system has three Plasma Reactor I (which provide 21 Energy each, +2% Tech bonus, +150% System bonus = 52.92 Energy each, rounded up to 53) and three population units are allocated to these three Plasma Reactors (producing a total of 159 Energy).

Unallocating one of these population units (into the Labour Pool) subtracts 54 from total Energy (105 remaining).
Scrapping one of these Reactors subtracts 53 total Energy (106 remaining).
This second subtraction is obviously unintended/wrong, but at least the minor discrepancy appears to be caused by rounding errors applied by calculating total Energy output from opposite directions, one's an addition and one's a subtraction.

Then things gets worse ...
Unallocating two population units or scrapping two Reactors subtracts 106 total Energy (53 remaining).
Unallocating one population unit and scrapping one Reactor subtracts 89 total Energy (70 remaining).
Unallocating one population unit and scrapping two Reactors, or unallocating two population units and scrapping one Reactor subtracts 124 total Energy (35 remaining).
Unallocating two population units and scrapping two Reactors subtracts 141 total Energy (18 remaining).
Unallocating/scrapping any more results in 0 total Energy output (even if three population units are still busy working the Reactors).

This bug mostly affects me only when my empire's economy is precarious, so I sell needless buildings for a few extra Credits and/or to reduce upgrade costs, every Credit and every population and turn and point adds up when you're broke and suffering, lol. But it also comes into play on newly-acquired member/subject worlds (previously under AI control) where I decide to reallocate population away from those 35 Fusion Plants and into useful things while simultaneously cleaning some ugly things up. The numbers become far more bizarre when things are complicated with higher Energy tech, different system bonuses, different base Energy structures (Plasma Reactor, Gravitic Turbine, Fusion Plant, etc) at different upgrade levels, and larger raw numbers of population and buildings.

Not sure how you'd fix this. It looks like two code segments involving different versions of the same calculations are invoked. Shouldn't scrapped structures remain active until the next turn?
[/Korth]

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 5864
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: Energy output bugs

Post by thunderchero » Fri Nov 17, 2017 2:54 pm

here is a past discussion I found by Gowron "Output of partially manned building groups"
not sure if this is relative to your issue though. :wink:
viewtopic.php?f=167&t=116&p=934#p934

User avatar
Korth
Ensign
Ensign
Posts: 48
Joined: Wed Nov 15, 2017 9:13 am

Re: Energy output bugs

Post by Korth » Fri Nov 17, 2017 3:04 pm

Ach, bugs layered onto other bugs, lol.
[/Korth]

User avatar
Spocks-cuddly-tribble
Code Master
Code Master
Posts: 703
Joined: Sun Apr 27, 2008 2:00 am

Re: Energy output bugs

Post by Spocks-cuddly-tribble » Fri Nov 17, 2017 6:41 pm

Korth wrote:
Fri Nov 17, 2017 2:07 pm
First game bug ...
Newly-built structures are unpowered if the exact amount of needed Energy is available.
You might try this: :wink:

Code: Select all

445EE0   jge -> jg   // at 0x452E0 change 7D to 7F

4460AE   jge -> jg   // at 0x454AF change 8D to 8F (for multiple buildings i.e. OBs)
Fixing your second bug is too intricate. Thunderchero pointed in the right direction, here wrong implementation of updates from manpower percentage vs. ordinfo.
On the verge of a nervous breakdown? Try the relaxing tribble sounds.

User avatar
Korth
Ensign
Ensign
Posts: 48
Joined: Wed Nov 15, 2017 9:13 am

Re: Energy output bugs

Post by Korth » Fri Nov 17, 2017 8:32 pm

Doesn't get much more elegant than a two-bytes hex hack, lol, thanx!

Curious why nobody has tried altering what Gowron calls the "global multiplier, M" at 0x1766a4 from 100 to 255 and the "output specific multipliers, m" from 1/100 to 1/255. The reciprocal of 255 (~0.003922) is much smaller than the reciprocal of 100 (0.01). So in his two examples the farms would produce 598 food instead of 595 food (or the expected 600 food) and the energy structures would produce 349 energy instead of 348 energy (or the expected 350 energy). Still a rounding error, but a smaller one, much less influential on smaller numbers of buildings.

Yes, he notes "You might be considering increasing the value at 0x1766a4, but that would cause significant changes to the game, because that value is an important multiplier" ... but the subsequent link is broken, lol.

It does seem like an obtuse and arcane way for the game to calculate straightforward things which can actually be worked out with whole number arithmetic (with a final rounding, if needed), lol.
[/Korth]

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 5864
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: Energy output bugs

Post by thunderchero » Fri Nov 17, 2017 9:17 pm

Link went though for me
viewtopic.php?name=Forums&file=viewtopic&t=10#p11

I think he was talking about the linear multiplier bonus factors for each manned structure type with default value of 0.01 giving a bad effect. But I am not sure how or what effect myself.
Gowron wrote:
Sat May 17, 2008 2:21 pm
position: 0x1766e4
default value: 0.01
meaning(s): linear multiplier for energy (output of manned structures); linear multiplier for local energy bonus

position: 0x17674c
default value: 0.01
meaning(s): linear multiplier for food (output of manned structures); linear multiplier for local food bonus

position: 0x17677c
default value: 0.01
meaning(s): linear multiplier for industry (output of manned structures); linear multiplier for local industry bonus

position: 0x176794
default value: 0.01
meaning(s): linear multiplier for research (output of manned structures); linear multiplier for local research bonus
NOTE: The local research bonus is determined by morale. It can also be chosen as a building benefit type (e.g. via UE) , but that doesn't seem to work.

position: 0x17679c
default value: 0.01
meaning(s): linear multiplier for information (output of manned structures)

User avatar
Korth
Ensign
Ensign
Posts: 48
Joined: Wed Nov 15, 2017 9:13 am

Re: Energy output bugs

Post by Korth » Fri Nov 17, 2017 9:35 pm

Well, as far as my second bug (scrapping Energy structures) goes ...

It seems the game "scraps" Energy output immediately instead of applying it at end of current turn (or at beginning of next turn, whichever). Is there a "simple" fix to delay this procedure (and thus completely bypass the bizarre/wrong subtractions of Energy output)?
[/Korth]

User avatar
thunderchero
Site Administrator aka Fleet Admiral
Site  Administrator aka Fleet Admiral
Posts: 5864
Joined: Fri Apr 25, 2008 2:00 am
Location: On a three month training mission, in command of the USS Valiant.
Contact:

Re: Energy output bugs

Post by thunderchero » Fri Nov 17, 2017 10:59 pm

Korth wrote:
Fri Nov 17, 2017 2:07 pm
Shouldn't scrapped structures remain active until the next turn?
since the AI does it system changes at the beginning turn, I guess your changes would be the end of the turn. (except combat that depends on your ship movements)

also just a note if you are interested here is the idb database. QD has labeled many subsection
trek-20120522.idb.zip
(8.07 MiB) Downloaded 12 times

User avatar
Korth
Ensign
Ensign
Posts: 48
Joined: Wed Nov 15, 2017 9:13 am

Re: Energy output bugs

Post by Korth » Sun Nov 19, 2017 4:38 pm

Thanx for the database! I use a GitHub IDA Pro/DIE, it looks compatible. But for now I'm focussed on playing the game (when my multiplayer opponents are available) and learning how to customize the installer (when they're not), lol.

I am amazed at 15+ years of effort in reverse-engineering and decompiling this game. Especially since attempts have been made to clone this game from raw source ... although, sadly, very few of these ambitious startups approach completion.
[/Korth]

Post Reply

Return to “Upgrading buildings bug (fix) above 65535 credits”

Who is online

Users browsing this forum: No registered users and 2 guests