JHGuitarFreak / UQM-MegaMod

A fork of The Ur-Quan Masters + HD-mod that remasters the HD graphics with a veritable smorgasbord of extra features, options, QoL improvements, and much more...
https://uqm-mods.sourceforge.net
GNU General Public License v2.0
78 stars 22 forks source link

Hard mode technology price increases every time you ask #100

Closed TomiBelan closed 2 years ago

TomiBelan commented 2 years ago

The speed you fixed #99 encouraged me to file another bug. ;)

In hard mode, every time you ask Melnorme about the price of some technology, its price increases. This persists even if you load a saved game and resets when you completely quit the game.

  1. Buy 1 technology for the normal cost
  2. Ask them about another technology - they will say it costs 50 additional credits (i.e. 200)
  3. Refuse ("I do not want to purchase any more technology.")
  4. Ask them again about the same technology (it can be in the same conversation) - now it costs 100 additional credits (i.e. 250)

This is caused by the assignment at https://github.com/Serosis/UQM-MegaMod/blob/42829465449679e9efe7cd63bffc560081338252/src/uqm/comm/melnorm/melnorm.c#L1361, which modifies a global variable.

Suggested fix: remove the TechSaleData.price field completely, instead always compute it as TECHPRICE + (DIF_HARD ? countTech() * 50 : 0) whenever needed. You could also declare tech_sale_catalog to be const as a preventative measure.

Serosis commented 2 years ago

This one will take a bit more time.

I thought I had fixed it awhile back.

EDIT: It looks like I need to verify that the amount of tech hasn't changed or increased.

Serosis commented 2 years ago

My god, you literally had the answer right there

nextTech->price = TECHPRICE + (countTech () * 50);

And you're right, you technically could get rid of TechSaleData->price, but I think it's fine seeing as it's part of the original code as well. In the future someone may want to have different prices for each tech, keeping it there would make it easier.

Fixed with commit ae5598ae0b570ae915700ca7b42862a60dd47782.