Can't switch capitals

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

Can't switch capitals

#1 Post by unjashfan »

There seems to be something wrong with how the game detects the imperial palace because scrapping the imperial palace at the homeworld doesn't completely remove the effects. I see something like "Imperial palace: +5" followed by "Unknown: -5" for planetary defense. The other meters have the same thing. As of now, it's impossible to build another imperial palace.

User avatar
eleazar
Design & Graphics Lead Emeritus
Posts: 3858
Joined: Sat Sep 23, 2006 7:09 pm
Location: USA — midwest

Re: Can't switch capitals

#2 Post by eleazar »

Do you get the ghost readings for more than one turn after you scrap it?

But I don't think scrapping is a good method. Start building a new one and it should remove the old one.

unjashfan
Creative Contributor
Posts: 175
Joined: Fri Dec 30, 2011 8:08 am

Re: Can't switch capitals

#3 Post by unjashfan »

Yes the ghost readings stay for more than one turn; it seems to be permanent. Building a second one before scrapping the first isn't possible either because one of the requirements for the palace is "if there are between 0 and 0 objects that is an imperial palace building and that it belongs to and was produced by the source's empire". From how I interpret this, it pretty much means that the old palace must be removed first before a second one can be built.

User avatar
eleazar
Design & Graphics Lead Emeritus
Posts: 3858
Joined: Sat Sep 23, 2006 7:09 pm
Location: USA — midwest

Re: Can't switch capitals

#4 Post by eleazar »

Weird. My testing confirms.
I note that the troop meter doesn't have the ghost readings after scrapping.

I wonder if it is some sort of visibility issue. When the turn is processing the about-to-be-scrapped building is shown with the scan lines for a fraction of a second.

unjashfan
Creative Contributor
Posts: 175
Joined: Fri Dec 30, 2011 8:08 am

Re: Can't switch capitals

#5 Post by unjashfan »

I changed the check condition from "between 0 and 0" to "between -1 and 1" and it seems to work as intended (numbers don't seem to be inclusive). Building new imperial palaces will require scrapping the old one first (I'm assuming that's how it was intended). Here's the patch:

[The extension patch has been deactivated and can no longer be displayed.]

Released under the GNU GPL 2.0 and Creative Commons Attribution-ShareAlike 3.0 licenses.

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

Re: Can't switch capitals

#6 Post by Geoff the Medio »

unjashfan wrote:I changed the check condition from "between 0 and 0" to "between -1 and 1" and it seems to work as intended (numbers don't seem to be inclusive).
The code for comparing meter values to the low and high end limits is:

Code: Select all

return m_low <= value && value <= m_high;
. It's possible that the value wasn't quite 0 though, even it appeared as such, due to rounding.

User avatar
eleazar
Design & Graphics Lead Emeritus
Posts: 3858
Joined: Sat Sep 23, 2006 7:09 pm
Location: USA — midwest

Re: Can't switch capitals

#7 Post by eleazar »

How can there be 0.1 imperial palaces?

I see some odd crashes with this patch applied, when the identical sequence of actions doesn't cause a crash without it.
Attachments
logs.zip
(347.32 KiB) Downloaded 19 times

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

Re: Can't switch capitals

#8 Post by Geoff the Medio »

eleazar wrote:Weird. My testing confirms.
I can't reproduce this. Exactly how did you?

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

Re: Can't switch capitals

#9 Post by Geoff the Medio »

eleazar wrote:How can there be 0.1 imperial palaces?
Hrm.. well, perhaps that's not the issue in this case, although it could potentially be fore float-valued things like meters.

Edit: I think the problem is that it's counting destroyed objects when finding how many of something exist. There are likely a few other places where this sort of thing is happening. /Edit
I see some odd crashes with this patch applied, when the identical sequence of actions doesn't cause a crash without it.
What sequence of actions? The log isn't very helpful...

User avatar
eleazar
Design & Graphics Lead Emeritus
Posts: 3858
Joined: Sat Sep 23, 2006 7:09 pm
Location: USA — midwest

Re: Can't switch capitals

#10 Post by eleazar »

Geoff the Medio wrote:
eleazar wrote:I see some odd crashes with this patch applied, when the identical sequence of actions doesn't cause a crash without it.
What sequence of actions? The log isn't very helpful...
Using the 5689 binary with updated scripting...

These tests were performed starting a new game each time. There was a nearby Scylior planet, i would send troop ships there so i had a second planet to try to build the imperial palace on. Once troop ships were there, clicking on the system to bring up the side panel crashed it twice in a row. Without the patch, no crash. I also got a crash once when opening the production window.

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

Re: Can't switch capitals

#11 Post by Geoff the Medio »

The imperial palace issue should be fixed now. This could also have been, and might probably should be, worked around in some cases by adding VisibleToEmpire conditions.

unjashfan
Creative Contributor
Posts: 175
Joined: Fri Dec 30, 2011 8:08 am

Re: Can't switch capitals

#12 Post by unjashfan »

Once troop ships were there, clicking on the system to bring up the side panel crashed it twice in a row
Weird. I can't replicate this, but the natives in question for me was abaddonni. I thought the check wasn't inclusive, but I was allowed to build the palace on all my colonies. Now I'm really confused :?. I must've missed something somewhere.

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

Re: Can't switch capitals

#13 Post by Geoff the Medio »

unjashfan wrote:...I thought the check wasn't inclusive...
The problem was that it counted the destroyed starting palace as an existing palace, so decided you had a palace and couldn't produce another one. Extending the range to -1 to 1 (which gets truncated to 0 to 1 internally), allowed a new palace to be produced since (it thought) you had 1 palace after scrapping the first. Had you produced and scrapped a second, it would likely not have allowed you to produce a third. Also, note that palaces you didn't produce don't count in any case, so capturing another empire's palace won't (shouldn't?) affect how many you can/can't produce.

Post Reply