Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ship with less than 10T cargo capacity hang the game #2634

Closed
NyankoSensei opened this issue Jan 7, 2014 · 3 comments
Closed

Ship with less than 10T cargo capacity hang the game #2634

NyankoSensei opened this issue Jan 7, 2014 · 3 comments

Comments

@NyankoSensei
Copy link

1

@nozmajner
Copy link
Contributor

I played a bit with this.
It seems that if the startup ship has equal or less capacity than it's equipments need when setting them up in the MainMenu.lua, then the game hangs.
If I comment out every equipment and cargo from the setupPlayerShip() from the MainMenu.lua, then only the default hyperdrive (class one for the xylpohis) will be on the ship, as defined in the ship.lua
Then it gives the same redscreen at 4t capacity, and the game works with 5t capacity. The Class 1 Hyperdrive is 4t.
If the default hyperdrive is 0, then there's no hang even with 1t capacity.

If I set the startup ship to another ship, and give the xylophis 4t capacity, and a class one hyperdrive, then the game starts fine, and I can buy a xylophis, which has it's hyperdrive, and no more room for anything.

@robn
Copy link
Member

robn commented Jan 11, 2014

Ok, found the bug. It doesn't actually match the title at all. @nozmajner's analysys helped though, I wouldn't have found it if I hadn't know to drop the ship capacity.

Its nothing to do with the start ship. Adding equipment or cargo to a ship that doesn't have room just causes the add to fail. AddEquip actually returns the number of items added. If we bothered to check it we'd find that they all return 0 when you reduce the start ship capacity. There's no point ever checking it though, because we're never going to make the start ship something that doesn't have room (or we'll not put so much stuff in it!).

The bug comes from giving the ship only enough space to hold its starting drive. TradeShips adds a launch delay of 30-45 seconds per item of cargo added. If there's no room in the ship, then no cargo can be added, so the delay is 0. The delay timer function will not allow a delay of 0, resulting in the slightly-misleading error message.

The fix will be to detect a zero delay and instead choose some random amount. Interestingly, the code in TradeShips that deals with what to do after docking already handles this case. There's some nice code reuse opportunities here for anyone that's interested. Today I'm just going to fix the bug.

@robn
Copy link
Member

robn commented Jan 11, 2014

Fixed in @53ea625.

@robn robn closed this as completed Jan 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants