Three issues.

 First, dock services should not agree to remove a device if it results in a ship having fewer than zero free device slots.

 Second, dock services will not allow you to replace one weapon with another weapon if you have no device slots open, even if this would result in the same number of slots being used.

 Third, it is possible to install a two-slot reactor even if all of your device slots are full, resulting in -1 free slots.

relanat on 6/15/2016 6:16 AM:

Another example from Cabbage Corp taken from a post here;

In a Wolfen I swapped a 25MW reactor (single slot) for a dual Siva-40M reactor (2 slots) but didn't have a spare slot.
It could be installed even without a spare slot and the Ship Configuration screen showed device slots changing from '8 (0 free)' to '8 (-1 free).. non-weapons stayed at '4 (0 free)'.
I uninstalled the dual laser cannon and got the device slot numbers back to normal (8 and 4 with 0 free).

But after that I tried to replace the previously installed solar array with a biohybrid solar dynamo and the Starton dock services wouldn't do it. I think this should have been allowed because it would swap devices in a non-weapons slot.

I then uninstalled the solar array so I could install (as opposed to replace) the solar dynamo but the device slot that should have been free was a weapons slot not the non-weapons slot that I had just emptied. The Ship Configuration screen showed 'device slots:8 (1 free)' and 'non-weapons:4 (0 free)'. The end result was I uninstalled a non-weapons device and then couldn't install another non-weapons device.

If you're confused, don't worry, so am I.
I think what's happening is the Siva reactor, which was installed when there wasn't enough slots for it, is changing slots until the ship gets back to a normal setup with 8 slots and 4 (and only 4) of them with non-weapons. Making it so that 2 slot devices can't be installed when there is only 1 slot available will fix all the rest of this. (maybe!)

Although I'm not sure if this is clear enough to be of any help! :)

assumedpseudonym on 6/17/2016 10:32 PM:

 Can confirm Relanat’s observation.
 So yeah. Basically, removal or installation of any device needs to check to make sure a ship doesn’t wind up with fewer than zero slots available.

relanat on 10/10/2017 1:58 AM:

I think there also there needs to be a check that the available slot is either weapons or non-weapons as required. It looks like this is what caused some of the problems in the Cabbage Corp example above. The game was just grabbing any slot of whatever type until it could get the numbers back to where they should be regardless of device type.

the_shrike on 10/5/2018 8:50 PM:

I'm working on another slot-granting device so I also need this.

assumedpseudonym on 10/5/2018 9:03 PM:

 Updated the original post and changed the ticket name accordingly.