michaelchadwick / gemwarrior-ruby

A (not-quite-so) simple (anymore) text RPG/adventure made as a RubyGem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash on `rest`

messerman opened this issue · comments

I rested several times throughout the game, no problems. This particular time, I rested, and then attempted to rest again (using the up-arrow to auto-populate rest, as I usually do), and the game crashed. Perhaps a divide-by-0 exception in your random number generator for the sleep time?

See below:

[LV: 2][XP: 98][ROX:134] [HP: 3/35 ][STM:25/25] [Warorl @ River Bridge]
GW> rest
** ZZZZZ **
You lie down somewhere quasi-flat and after a few moments, due to extreme
exhaustion, you fall into a deep, yet troubled, slumber. Approximately 2 hours,
56 minutes, and 24 seconds later, you wake up with a start. Upon getting to your
feet you look around, notice you feel somewhat better, and wonder why you dreamt
about bains.

[LV: 2][XP: 98][ROX:134] [HP: 17/35 ][STM:25/25] [Warorl @ River Bridge]
GW> rest
no implicit conversion from nil to integer

Gem Warrior played for 32 minutes, 52 seconds, and 526 milliseconds

Player killed 22 monster(s)
picked up 8 item(s)
traveled 154 time(s)
rested 8 time(s)
died 3 time(s)

################################################################`

The whole rest command is a mangled mess of code that I don't fully understand (tests would be nice), so I'm sure there's some edge case I'm not thinking of that would result in this, but I can't yet reproduce it. The RNG for hours/minutes/seconds never does any division, nor does it result in 0s, so it must be something else.

I looked through the code and I don't see what could be causing this. I'll see if I can get it to be more reproducible so you have a better chance of debugging it. It happened twice, but never again.

I got it to happen again. I'll keep dumping the print outs as they happen, maybe we'll find a pattern:

[LV: 2][XP:109][ROX: 54] [HP: 22/35 ][STM:25/25] [Cererand @ Cave (Nook)]
GW> rest
no implicit conversion from nil to integer
######################################################################

Gem Warrior played for 14 minutes, 16 seconds, and 885 milliseconds

Player killed 16 monster(s)
picked up 8 item(s)
traveled 95 time(s)
rested 35 time(s)
died 4 time(s)
######################################################################

Also - this most recent time was a single rest, so we can ignore that data point. (i.e. I didn't rest multiple times in a row, it crashed immediately upon rest after my fight).

Meaning you started the game, rested, and it crashed?

On Tue, Aug 11, 2015 at 11:05 AM messerman notifications@github.com wrote:

Also - this most recent time was a single rest, so we can ignore that data
point.


Reply to this email directly or view it on GitHub
#32 (comment)
.

Meaning I was playing for a while, (fought and rested several times), fought, rested once more (the first time I had rested multiple times in a row), and it crashed.

Crash while attempting to rest - after resuming, while it had taken away one of my tent usages, I was able to successfully rest without crash.

[LV: 1][XP: 13][ROX: 18] [HP: 10/30 ][STM:20/20] [Jonne @ River Bridge]
 GW> rest
>> tent can be used when resting 4 more time(s).
no implicit conversion from nil to integer
######################################################################
Gem Warrior v0.10.0 played for 3 min(s), 6 sec(s), and 96 ms
----------------------------------------------------------------------
Jonne      killed 2 monster(s)
           picked up 3 item(s)
           traveled 5 time(s)
           rested 0 time(s)
           died 0 time(s)
######################################################################
Saving game...
Game saved!
[LV: 2][XP:103][ROX:137] [HP:  7/35 ][STM:25/25] [Jonne @ Snow Fields (Northeast)]
 GW> rest
no implicit conversion from nil to integer
######################################################################
Gem Warrior v0.10.0 played for 9 min(s), 31 sec(s), and 253 ms
----------------------------------------------------------------------
Jonne      killed 13 monster(s)
           picked up 7 item(s)
           traveled 65 time(s)
           rested 10 time(s)
           died 1 time(s)
######################################################################
Saving game...
Game saved!

This is (finally?) fixed in 0.10.4.