Have begun testing again. This time I wanted to have a look at the upgrading function 452460 cause, regarding side affects, it might be easier to disable upgrading within that function instead of just not calling it.DCER wrote:Check the structures tab, it looks like two versions of farms might be built. If they are - it's a known occasional botf bug.
EDIT: if it's caused by this maybe we could find a fix for the old bug as well
First thing I've figured is replacing the "je short 452504" at 4524B6 by a jmp to skip some portion, causes old buildings of old type to keep in, while new ones still get added.
I don't have a savegame with that "occasional bug" to test with, but it's most likely caused in this place.
Additionally I've seen that in beginning of the function there's a race check again, preventing upgrades when owner is a major race. Could have some interesting effect, allowing minor to upgrade it's facilities when already membered. hehe
I alreaady wondered why removing the check for the evolution didn't cause them to upgrade their buildings as well. ^^
Continuing tests, I figured that first all buildings (at least the ones that shall be upgraded) get scrapped, then, at 452537, with calling 445DF0 in a loop (0 to current population number), the new buildings get build. Skipping this part or replacing the call by nops, causes zero buildings to be there after upgrading and only type 1 being buildable.
445DF0 is a function being called by many places. We already encountered it for building orbitals!
It is reading the RaceStateTable (or how to call it) at 445E21 and 445E2C and 445F74.
For the orbitals we already figured that it's for building one single structure. This time, in function 452460 that I've now labeled "_upgradeMinorBuildingType", it is called within a loop again.
It either reads out the tech level from RaceStateTable or takes it by parameter, can't tell yet but I believe it's been set somewhere before this function call. If we can set the old tech level here or stop setting the new one, we should achieve what we want without of the currently strange upgrading issues. (But they would also scrap if population gets lost)
I've now labled function 445DF0 "_buildSomething" and maybe we can find the place where the farms previously got build endless within DCER's changes and change it to become a future, so it's instead limited by population number and prevents starvation issues.
I've encountered same issues when completely skipping the upgrade part, so I think DCER's changes are fine but there's just another call to build more farms under some conditions, and somehow the real upgrade part just didn't take place anymore.
So far enough, I think we are on a good way.