Page 1 of 1

Bug: Relocating a firm to Owned Land fails

Posted: Fri Mar 04, 2022 9:32 am
by Hans_Lemurson
When you try to relocate a firm to a destination where you own the land, the firm does not get relocated.
After clicking the "Relocate" button, you are taken to a view of the firm as if it had relocated...but it has not moved from its original position.

If you sell the land at the destination, and then attempt to relocate, it proceeds normally.

Re: Bug: Relocating a firm to Owned Land fails

Posted: Sun Mar 06, 2022 7:50 am
by David
I've tested it. I was able to relocate the firm to owned land, as seen in the attached screenshot.

Could you please send your save game for further investigation?

Re: Bug: Relocating a firm to Owned Land fails

Posted: Sun Mar 06, 2022 10:48 am
by Hans_Lemurson
Weird, I just tested it with a small factory it and it worked, just like it did for you.

I know the bug happened though, since that's what motivated me to report it, so maybe it's a more special case than I first thought.
...
Ok, I have a partial reproduction:
caplab relocation error.png
caplab relocation error.png (456.31 KiB) Viewed 2422 times
When I relocated on partially owned land, I got the error.

But I've also had the relocation succeed on partially owned land.
More testing needed.

Re: Bug: Relocating a firm to Owned Land fails

Posted: Sun Mar 06, 2022 11:45 am
by Hans_Lemurson
Ok, I think I've figured it out! It's not an error due to land ownership, it's due to INSUFFICIENT CASH. (update: land ownership does matter also)

Relocating a firm requires that you have enough cash on hand to do so...so far, so good. But the problem is how it calculates this. The cost of Relocation is assumed to be the Land Cost + Building Cost. But this is the cost for an empty building. Farms, stores, factories, and r&d centers have Production Units within them that have to be rebuilt, and this is not taken into account when the cost is estimated.

If you attempt to relocate a firm with enough cash on hand to Buy the Land, and Build the Building, but not enough to replace all of the guts of that building, then the Relocate order fails.
...
(more testing...)
No, wait, even that isn't quite right. That is only true if you own a portion of the land you are relocating to.
...
(even more testing)
If you own NONE of the land you are re-locating to, then there is no problem. Actually, worse than that, you somehow...save money? :?
There appear to be differential outcomes based on whether you own any of the land you are relocating to.
Here I make two attempts to relocate a factory: In both cases, the amount of money is sufficient for the stated cost, but not enough to rebuild all of the Manufacturing Units.
caplab relocation bug reproduced.png
caplab relocation bug reproduced.png (2.7 MiB) Viewed 2421 times
Left Picture: the relocation fails when you own even a single square of the destination.
Middle Picture: The relocation succeeds when the land is completely un-owned
Right Picture: After success, you are charged even LESS than was stated for the relocation!

...
It gets even weirder: Duplicating a firm, when you have enough cash for the Building but not for the Production Units, can let you go into negative cash :shock:
caplab duplicate firm error.png
caplab duplicate firm error.png (316.23 KiB) Viewed 2421 times

Re: Bug: Relocating a firm to Owned Land fails

Posted: Mon Mar 07, 2022 10:59 am
by David
Could you please provide me with a save game where the relocation is going to have problems, specifying which firm should be relocated? I will then pass it to the programmer to test and debug it.

Re: Bug: Relocating a firm to Owned Land fails

Posted: Mon Mar 07, 2022 10:30 pm
by Hans_Lemurson
I had been messing around in the Food&Snacks scenario, but I didn't save a place where it was convenient to recreate the bug.

Given that the Scenarios have the DLCs de-activated, I thought it would be a better test to try to reproduce it in the main game with all DLCs active.
I started a new game and created a situation where I could reproduce the bug, and succeeded!
All 3 Bugs have been reproduced.

I have included a save-file which can demonstrate 3 Bugs:
Bug #1: Relocating a firm to land you own fails when you have enough cash to rebuild the firm but not all of its production units.
Bug #2: Relocating a firm to land you don't own succeeds when it shouldn't, and costs less than the stated price.
(The stated price is wrong, as per bug #1)
Bug #3: Duplicating a firm, when you have enough cash to Build the Firm, but not it's production units, will succeed, and send you into negative cash.[/b]
(Land ownership does not seem to matter here.)
caplab relocation bug reproduced 2.png
caplab relocation bug reproduced 2.png (1.86 MiB) Viewed 2374 times
Steps to Reproduce:
(1) Attempt to Relocate the "Large Soup Factory" to the 4x4 site adjacent to it.
-It will open the factory menu, but the firm will not have moved.
(2) Sell that 4x4 plot of land and attempt to relocate.
-It will succeed, but you will have $486,329 in cash remaining, instead of the $226,242 that the numbers say you should. Note that both of these numbers are wrong, since they disregard the cost of the Production Units
(3) Load the save-file again.
(4) Attempt to Duplicate the factory into the 4x4 zone of land adjacent to the original. This will succeed, but send your cash to $-794,197.
(5) Sell the land first, and then Duplicate the Factory into that location. This will succeed, and once again send your cash into the negatives.

Overall, there seems to be an error with two different ways of calculating the cost of a Relocation/Duplication.
-The "Nominal Cost" is just the cost of Land + Building
-The "True Cost" is the cost of Land + Building + Units
Different situations will either use one cost or the other. Ideally only the "True Cost" should be used for all situations.

Re: Bug: Relocating a firm to Owned Land fails

Posted: Wed Mar 09, 2022 5:41 am
by David
The bug has been fixed. Please download the new patch v8.0.15 from https://www.capitalism2.com/forum/viewt ... f=7&t=8732

Re: Bug: Relocating a firm to Owned Land fails

Posted: Thu Mar 10, 2022 10:57 am
by Hans_Lemurson
I can confirm that Relocation seems to always work whenever you have enough cash on hand to pay for the nominal cost (land + building).

One slight (possible) bug remains: When "Duplicating" a firm, you can go into negative cash, since you are paying the cost of building the internal Units as well as the buying the building and land. This can be tested using that same save.