A post by rhuber got me moving on this. Thanks. A very early version of a "Hull Upgrade" mod. Not suitable for gameplay at this stage (very messy, nowhere near enough checks or pricing code), only to have a play around with.
The player can change to a different ship type and have all the existing items on the playership installed on the new ship automatically. Much easier.
Adds an "Upgrade" action to the Ship Broker screen. So long as the armor count, device numbers and cargo mass are compatible the player ends up in the new ship type with all their existing equipment. The option is only available for the ships already available via the ship broker.
It may be better to add 'no device' ships to the shiplist instead which the player can select to buy, eg a Sapphire with 4 segments of titanium armor and nothing else. Buying one of these would automatically swap all the playership devices to the new ship. This might make it easier to add mod ships as well. Not sure.
The plan at this stage is to remove the old playership from the game but if players want it available for repurchase with all the 'other' ship equipment installed on it that should be possible.
Eventually differing armor counts will be handled if the player has the extra needed armor items in the hold. Or any excess armor will go into the hold.
Any code or advice on how to handle the cargo hold changeover would be welcome. The variation in either the old and new ship having or not having a hold and whether those holds can be removed or not is confusing me a bit. I think that 'objCanInstallItem' code will be needed but this could possibly be affected by the known issue below.
Known issues: For some reason trying to swap to an EI500 from the Taipan GodShip results in the IM90 being in the cargo hold, not installed. The same swap to a Sapphire or Wolfen works fine. Possibly something to do with the install code handling non-playership objects differently to the playership. May have to save the old playership items, then change to the new ship so it is now the playership, then install the items to get around this. Not sure. Either that or find some way of selecting device slots for installation. The only code I can find to do this is reliant on being in a deviceSelector screen which isn't suitable here.