Servers merging
This is related to #156, but with reproducible steps and a theory on why.
- Install an asset/agenda into Server 0 (call this Asset0).
- Install an asset/agenda into Server 1 (call this Asset1).
- Install an ice into Server 1 (optional, helps visualize the bug).
- Install an asset/agenda into Server 0 (call this Asset2).
Expected: Asset2 replaces Asset0 in Server 0. Server 1 has Asset1 and ice.
Actual: Server 1 is no more. Asset1, ice, and Asset2 are now all in Server 0.
Why: I believe this happens because of the following logic flow:
- Corp chooses to install Asset2 in Server 0.
corp-installchecks to see if an asset/agenda is already in server 0, sees that there is, calls(trash)to get rid of it.trashcallsmove. Asset0 gets moved to Archives.movechecks to see if Asset0 was in a remote, and if that remote has no content and no ice. Because this is true, the remote is removed from[:corp :servers :remote].- Because remotes are numbered implicitly by their position in
[:corp :servers :remote], Server 1 is now Server 0 by virtue of being first in the list. corp-installresumes its command to install Asset2 in Server 0, unaware that the old Server 0 is gone and Server 1 is now Server 0. Asset2 is installed into Server 0:content, blissfully unaware that something has gone horribly wrong.
Interesting. If no one is already working on this, I'll try to fix it this evening.
Go for it. The easiest solution might be to just wait to trash the old asset until after the new one moved to the server. That will technically trigger events in the wrong order though... it will trigger :corp-install before :trash when according to game rules it should go the other way. Not that I know of any interactions where that would matter... hmm...
I had the same idea, and the same worry (don't want to move the bug to the future when a card comes out where it actually does matter).
Ideally Servers would not be numbered implicitly IMHO, but I guess that would requiere a lot of code changes (but I'll have to take a look first).
I'll have to look at the source first to decide what would be the best approach.