ModAPI: Players can still enter cockpit of ship which is marked for close
today I got a report for one of my plugins that apparently is able to delete player characters when a ship is closed.
The plugin itself (ALE Shipfixer Plugin) basically cuts and pastes a grid whenever the player notices their grid to misbehave to basically reset it.
It works pretty fine, however I was made aware that just calling grid.close() just marks the grid for closing. However that does not prevent a player to enter the cockpit till the grid is actually closed.
I tried ejecting players first but at the time of running the command, there may not be any player in a cockpit so nothing happens.
The code for that is here and being Executed on Game Thread:
In theory this should also be able to be reproduced with Space Master.
pressing delete button and a have a player player jump into the grid at the right moment. However with two players its hard to coordinate and with one player alone you cannot pull it off as you have to press the button, close Space master and enter the cockpit.
The time frame for that occurrence is just a 1 to 4 frames.
Can there be a simple check added to prevent a player to enter a cockpit of a marked for close grid? I assume this could cause random issues as well, for example entering a cockpit when gridcleanup happens at the wrong time.
Thank you :-)