From 2348e97e90615fd2da3187e66f3b892242889eb2 Mon Sep 17 00:00:00 2001 From: Mark Lemming Date: Thu, 18 Apr 2013 19:20:34 -0600 Subject: [PATCH] Fix infrequent exception when non-existant glyph is pushed. --- lib/Lacuna/Role/Trader.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/Role/Trader.pm b/lib/Lacuna/Role/Trader.pm index bae52bfb..398783e1 100644 --- a/lib/Lacuna/Role/Trader.pm +++ b/lib/Lacuna/Role/Trader.pm @@ -51,9 +51,13 @@ sub check_payload { type => $item->{name}, body_id => $self->body_id, })->single; + my $gquant = 0; + if (defined $glyph) { + $gquant = $glyph->quantity; + } confess [1002, "You don't have ".$item->{quantity}." glyphs of type ". - $item->{name}." you only have ".$glyph->quantity] - unless $glyph->quantity >= $item->{quantity}; + $item->{name}." you only have ".$gquant] + unless $gquant >= $item->{quantity}; push @expanded_items, $item; $space_used += 100 * $item->{quantity}; } -- 2.51.2