From 07e5eec2fa080da7b7a7006e45b9795476b5a94e Mon Sep 17 00:00:00 2001 From: Macarthur Inbody <133794m3r@gmail.com> Date: Sat, 1 May 2021 17:57:43 -0400 Subject: [PATCH] Make sure to not allow them to put more items than are allowed into the inventory no matter what. --- main.hxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.hxx b/main.hxx index a4e2741..42a2b69 100644 --- a/main.hxx +++ b/main.hxx @@ -87,16 +87,17 @@ void _add_items(Player &p, const std::string& item_tokens){ split = item_tokens.find(','); //find the number of items unsigned short num_items = static_cast(std::stoul(item_tokens.substr(0, split))); - if(num_items == 0) + if(num_items == 0 || num_items > 255) return; unsigned long idx; unsigned short item_id; unsigned short item_number; + unsigned short current_items=0; std::string item_tuple; tok_start = split+1; split = item_tokens.find(',',split+1); //now iterate over it adding items. - while(tok_start != std::string::npos){ + while(tok_start != std::string::npos || current_items > num_items){ item_tuple = item_tokens.substr(tok_start,split-tok_start); idx = item_tuple.find(';'); item_id = static_cast(std::stoul(item_tuple.substr(0, idx))); @@ -110,6 +111,7 @@ void _add_items(Player &p, const std::string& item_tokens){ p.add_item(*ALL_ITEMS_[item_id], item_number); tok_start = split; split = item_tokens.find(',',split+1); + current_items++; } }