sudasana / armcom2

Armoured Commander II
104 stars 13 forks source link

Attempting to Access Crewman Menu When No Crewman in Hospital Causes Game Crash #32

Open cnelso00 opened 3 years ago

cnelso00 commented 3 years ago

I have a "fail silently" fix that I can PR if desired. It just adds a try-catch block around the offending code, in case of an IndexError.

The text of the error is here:

/Users/<username>/code/armcom2/armcom2.py:2445: DeprecationWarning: Call the `con.print_` method instead.
  libtcod.console_print(calendar_main_panel, 2, y, 'No crewmen currently in hospital')
Traceback (most recent call last):
  File "/Users/<username>/code/armcom2/armcom2.py", line 18246, in <module>
    campaign.DoCampaignCalendarLoop()
  File "/Users/<username>/code/armcom2/armcom2.py", line 2857, in DoCampaignCalendarLoop
    crewman = campaign.hospital[selected_hospital_crewman]
IndexError: list index out of range
sudasana commented 3 years ago

Sure - you could also check the length of campaign.hospital first, and if it's 0, continue in the loop.

This is fixed in the current Steam version of the game, if you're interested in checking it out. You get the full source code with the game.

cnelso00 commented 3 years ago

That's good to know! I bought the game on Steam, but was out of town when I bought it and only had my macbook, so I downloaded from here and got it running on that machine.