Improper building scrapping

Problems and solutions for installing or running FreeOrion, including discussion of bugs if needed before posting a bug report on GitHub. For problems building from source, post in Compile.

Moderator: Oberlus

Post Reply
Message
Author
unjashfan
Creative Contributor
Posts: 175
Joined: Fri Dec 30, 2011 8:08 am

Improper building scrapping

#1 Post by unjashfan »

Somehow, FO thinks any scrapped building still exists. The outpost in the pic had a scanning facility on it, but it was scrapped just before it was captured. When I recaptured it, the building is gone but its effects remained. I also tried scrapping the imperial palace and building it elsewhere, but it was not possible because the game thinks it's still there (I don't remember checking if the palace's bonuses still remained or not though).
Attachments
BuildingSac.png
BuildingSac.png (52.88 KiB) Viewed 387 times

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12725
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Improper building scrapping

#2 Post by Geoff the Medio »

This is probably because the code implementing scrapping is passing a TemporaryPtr<Building> to a function that takes an int, and the compiler is accepting it, casting the TemporaryPtr<Building> to an int (somehow... maybe through the bool operator() function?), probably with value 0 or 1, then using that as the id of the building to scrap. This does nothing, as object ids 0 and 1 are usually systems, and buildings don't get scrapped.

I'm not sure how to disable such automatic casting... it's come up a few times causing similar errors.

Edit: Looks like just declaring a private conversion function does it at compile time...

Code: Select all

operator int() const;

Post Reply