Fix to shop, where a NULL object variable could cause a crash

This commit is contained in:
JamDog 2009-04-13 21:34:26 +00:00
parent 3d6c633d66
commit 8f001492ce
2 changed files with 4 additions and 2 deletions

View file

@ -34,6 +34,8 @@ OLC copy and delete options.
export (QQ's a zone into a tarball)t
Xlist (mlist, olist, rlist, zlist, slist, tlist, qlist)
(lots of major bugfixes too)
[Apr 13 2009] - Jamdog
Bug-Fix: Shopping for multiple items caused an occasional crash due to NULL variable - now fixed (I hope)
[Apr 12 2009] - Jamdog
Bug-Fix: Stat player displayed current quest information incorrectly - fixed 'if'
[Apr 11 2009] - Jamdog

View file

@ -609,7 +609,7 @@ static void shopping_buy(char *arg, struct char_data *ch, struct char_data *keep
snprintf(buf, sizeof(buf), "%s Something screwy only gave you %d.", GET_NAME(ch), bought);
do_tell(keeper, buf, cmd_tell, 0);
}
if (!IS_GOD(ch) && !OBJ_FLAGGED(obj, ITEM_QUEST)) {
if (!IS_GOD(ch) && obj && !OBJ_FLAGGED(obj, ITEM_QUEST)) {
GET_GOLD(keeper) += goldamt;
if (SHOP_USES_BANK(shop_nr))
if (GET_GOLD(keeper) > MAX_OUTSIDE_BANK) {
@ -622,7 +622,7 @@ static void shopping_buy(char *arg, struct char_data *ch, struct char_data *keep
snprintf(tempbuf, sizeof(tempbuf), "$n buys %s.", tempstr);
act(tempbuf, FALSE, ch, obj, 0, TO_ROOM);
if (OBJ_FLAGGED(obj, ITEM_QUEST))
if (obj && OBJ_FLAGGED(obj, ITEM_QUEST))
snprintf(tempbuf, sizeof(tempbuf), "%s That has cost you %d quest points.", GET_NAME(ch), goldamt);
else
snprintf(tempbuf, sizeof(tempbuf), shop_index[shop_nr].message_buy, GET_NAME(ch), goldamt);