Corrected bugs with removing items from the incorrect main inventory.

pull/28/head
sigonasr2 1 year ago
parent 22d1a6d834
commit a139072d68
  1. 4
      Crawler/Crawler.cpp
  2. 15
      Crawler/Item.cpp
  3. 2
      Crawler/Version.h

@ -176,8 +176,6 @@ bool Crawler::OnUserCreate(){
Inventory::AddItem("Blue Slime Remains",22); Inventory::AddItem("Blue Slime Remains",22);
LoadLevel(LEVEL_NAMES["starting_map"_S]); LoadLevel(LEVEL_NAMES["starting_map"_S]);
Inventory::AddItem("Bandages",3);
Inventory::AddItem("Blue Slime Remains",10,true);
ChangePlayerClass(WARRIOR); ChangePlayerClass(WARRIOR);
GameState::Initialize(); GameState::Initialize();
@ -1309,6 +1307,8 @@ void Crawler::LoadLevel(MapName map){
totalBossEncounterMobs=0; totalBossEncounterMobs=0;
Inventory::Clear("Monster Loot"); Inventory::Clear("Monster Loot");
Inventory::Clear("Stage Loot"); Inventory::Clear("Stage Loot");
Inventory::AddItem("Bandages",3);
Inventory::AddItem("Blue Slime Remains",10,true);
#pragma region Monster Spawn Data Setup #pragma region Monster Spawn Data Setup
for(auto key:MAP_DATA[map].SpawnerData){ for(auto key:MAP_DATA[map].SpawnerData){

@ -185,10 +185,7 @@ bool Inventory::UseItem(IT it,uint32_t amt){
//Returns true if the item has been consumed completely and there are 0 remaining of that type in our inventory. //Returns true if the item has been consumed completely and there are 0 remaining of that type in our inventory.
bool Inventory::RemoveItem(IT it,ITCategory inventory,uint32_t amt){ bool Inventory::RemoveItem(IT it,ITCategory inventory,uint32_t amt){
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory) #pragma region Calculate Inventory to Manipulate
if (!_inventory.count(it))return false;
if (amt>=_inventory.at(it).Amt()){
int count=0;
std::vector<Item>&inv=sortedInv.at(inventory); std::vector<Item>&inv=sortedInv.at(inventory);
bool eraseFromLootWindow=false; bool eraseFromLootWindow=false;
if(inventory=="Monster Loot") { if(inventory=="Monster Loot") {
@ -199,10 +196,17 @@ bool Inventory::RemoveItem(IT it,ITCategory inventory,uint32_t amt){
inv=sortedInv.at("Stage Loot"); inv=sortedInv.at("Stage Loot");
eraseFromLootWindow=true; eraseFromLootWindow=true;
} }
int count=0;
for(Item&item:inv){ for(Item&item:inv){
if(item.Name()==it)break; if(item.Name()==it)break;
count++; count++;
} }
#pragma endregion
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
if (!inv.at(count).Amt())return false;
if (amt>=inv.at(count).Amt()){
inv.erase(inv.begin()+count); inv.erase(inv.begin()+count);
if(!eraseFromLootWindow){ if(!eraseFromLootWindow){
_inventory.erase(it); _inventory.erase(it);
@ -211,7 +215,10 @@ bool Inventory::RemoveItem(IT it,ITCategory inventory,uint32_t amt){
Menu::InventorySlotsUpdated(inventory); Menu::InventorySlotsUpdated(inventory);
return true; return true;
}else{ }else{
inv.at(count).amt-=amt;
if(!eraseFromLootWindow){
_inventory.at(it).amt-=amt; _inventory.at(it).amt-=amt;
}
return false; return false;
} }
} }

@ -35,7 +35,7 @@ SUCH DAMAGE.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 1 #define VERSION_PATCH 1
#define VERSION_BUILD 2979 #define VERSION_BUILD 2981
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save