Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moduled buildings demolishing #922

Closed
vaut opened this issue Jun 15, 2020 · 1 comment · Fixed by #940
Closed

Moduled buildings demolishing #922

vaut opened this issue Jun 15, 2020 · 1 comment · Fixed by #940
Labels

Comments

@vaut
Copy link
Contributor

vaut commented Jun 15, 2020

Describe the bug
When player deconstruct any buiding he recieves 50% of building's cost. But thare are some problems with demolishing almost all buldings with modules:

To Reproduce

  1. A factory costs 100 energy, a factory module costs 100 energy too. Outcome after demolishing:
    1 moduled f. -> 50 energy.
    2 moduled f. ->100 energy.
    3 moduled f. -> 100 energy (!not 150!).
  2. A power generator costs 50 energy. It's module costs 0 (can upgrade for free).
    Outcome after demolishing:
    p. g. without module -> 25 energy.
    upgraded p. g. -> 0 energy (!not 25!)
    There is no such problem with a research facility (don't know why, but demolishing of it works properly, no matter moduled or not) I haven't tested a VTOL factory, but I can suggest, that it has problems as a vehicle factory has

Your System:

  • Game version: 3.3.0
@vaut vaut added the Bug label Jun 15, 2020
@vaut vaut changed the title Moduled buildings demolishing bug Moduled buildings demolishing Jun 15, 2020
@Colin-Mac-Donald
Copy link
Contributor

Great report, thanks.

Yes, that is weird and the FIXME on that function really was needed. We're returning half the power to build the structure if it doesn't have a module, but if it has modules, we return the full power to build one module (regardless of how many it has). It's just happenstance that gives the right numbers for a research facility with or without a module.

I'll change it to return (build cost + (module cost * number of modules)) / 2

Colin-Mac-Donald added a commit to Colin-Mac-Donald/warzone2100 that referenced this issue Jun 17, 2020
The function structPowerToBuild() is rather confusingly named, as it returns the power to either build the structure, or to add its next module, not the total power it took to build it as might have been mistakenly inferred.  I've renamed it to structPowerToBuildOrAddNextModule(), since that's what it returns.

The real problem is in structureTotalReturn() which (ab)uses structPowerToBuild() and then tries to correct the (bad) number it gets back from that depending on whether the structure has any modules (irrespective of how many).

What we actually want to do is to return:

(power to build basic structure + (power to build a module * number of modules)) / 2
Colin-Mac-Donald added a commit to Colin-Mac-Donald/warzone2100 that referenced this issue Jun 18, 2020
The function structPowerToBuild() is rather confusingly named, as it returns the power to either build the structure, or to add its next module, not the total power it took to build it as might have been mistakenly inferred.  I've renamed it to structPowerToBuildOrAddNextModule(), since that's what it returns.

The real problem is in structureTotalReturn() which (ab)uses structPowerToBuild() and then tries to correct the (bad) number it gets back from that depending on whether the structure has any modules (irrespective of how many).

What we actually want to do is to return:

(power to build basic structure + (power to build a module * number of modules)) / 2
KJeff01 pushed a commit that referenced this issue Jun 18, 2020
The function structPowerToBuild() is rather confusingly named, as it returns the power to either build the structure, or to add its next module, not the total power it took to build it as might have been mistakenly inferred.  I've renamed it to structPowerToBuildOrAddNextModule(), since that's what it returns.

The real problem is in structureTotalReturn() which (ab)uses structPowerToBuild() and then tries to correct the (bad) number it gets back from that depending on whether the structure has any modules (irrespective of how many).

What we actually want to do is to return:

(power to build basic structure + (power to build a module * number of modules)) / 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants