From 00da6b5977574a0564169172227d8aab45be188f Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 3 Jan 2015 21:07:56 -0800 Subject: Switch MATCH to separate begin/end macros The for loop trick turned out to be very prone to infinite loops at runtime. It's better to force compiler errors even if it's ugly. --- src/map/trade.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/map/trade.cpp') diff --git a/src/map/trade.cpp b/src/map/trade.cpp index 5ec63c9..bc6e98f 100644 --- a/src/map/trade.cpp +++ b/src/map/trade.cpp @@ -174,7 +174,7 @@ void trade_tradeadditem(dumb_ptr sd, IOff2 index, int amount) sd->status.inventory[index.unshift()].nameid) continue; - if OPTION_IS_SOME_INLOOP(id, target_sd->inventory_data[i]) + OMATCH_BEGIN_SOME (id, target_sd->inventory_data[i]) { if (id->type != ItemType::WEAPON && id->type != ItemType::ARMOR @@ -182,9 +182,12 @@ void trade_tradeadditem(dumb_ptr sd, IOff2 index, int amount) && id->type != ItemType::_8) { free_++; - break; + goto break_outer1; } } + OMATCH_END (); + break_outer1: + break; } if (target_sd->weight + trade_weight > @@ -231,7 +234,7 @@ void trade_tradeadditem(dumb_ptr sd, IOff2 index, int amount) sd->status. inventory[sd->deal_item_index[trade_i].unshift()].nameid) continue; - if OPTION_IS_SOME_INLOOP(id, target_sd->inventory_data[i]) + OMATCH_BEGIN_SOME (id, target_sd->inventory_data[i]) { if (id->type != ItemType::WEAPON && id->type != ItemType::ARMOR @@ -239,9 +242,12 @@ void trade_tradeadditem(dumb_ptr sd, IOff2 index, int amount) && id->type != ItemType::_8) { free_++; - break; + goto break_outer2; } } + OMATCH_END (); + break_outer2: + break; } } // used a slot, but might be cancelled out by stackable checks above -- cgit v1.2.3-70-g09d2