Jump to content

Question about a condition in c++


Recommended Posts

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Bronze
				BYTE bMaxItemSize = 1;
				const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(dwBoxVnum);
				if (pGroup)
				{
					for (int i = 0; i < pGroup->GetGroupSize(); i++)
					{
						const TItemTable* itemTable = ITEM_MANAGER::instance().GetTable(pGroup->GetVnum(i));
						if(itemTable)
						{
							if(itemTable->bSize > bMaxItemSize)
							{
								bMaxItemSize = itemTable->bSize;
								if(bMaxItemSize == 3)
									break;
							}
						}
					}
				}
				
				if(GetEmptyInventory(bMaxItemSize) == -1)
				{
					ChatPacket(CHAT_TYPE_INFO, "You need %d perpendicular slots in your inventory to open the Chest.", bMaxItemSize);
					return false;
				}

 

Place it in char_item.cpp inside case ITEM_GIFTBOX: after dwBoxVnum. (there are other cases for other types of chests, this instruction is only for giftbox type). 

Also I think the max size from the chest must be a info loaded when the special group is loaded and saved in a variable.

The code I posted for you increases the time complexity of the function and it's not a good ideea 😀

 

Edited by Abel(Tiger)
Link to comment
Share on other sites

6 hours ago, Abel(Tiger) said:
				BYTE bMaxItemSize = 1;
				const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(dwBoxVnum);
				if (pGroup)
				{
					for (int i = 0; i < pGroup->GetGroupSize(); i++)
					{
						const TItemTable* itemTable = ITEM_MANAGER::instance().GetTable(pGroup->GetVnum(i));
						if(itemTable)
						{
							if(itemTable->bSize > bMaxItemSize)
							{
								bMaxItemSize = itemTable->bSize;
								if(bMaxItemSize == 3)
									break;
							}
						}
					}
				}
				
				if(GetEmptyInventory(bMaxItemSize) == -1)
				{
					ChatPacket(CHAT_TYPE_INFO, "You need %d perpendicular slots in your inventory to open the Chest.", bMaxItemSize);
					return false;
				}

 

Place it in char_item.cpp inside case ITEM_GIFTBOX: after dwBoxVnum. (there are other cases for other types of chests, this instruction is only for giftbox type). 

Also I think the max size from the chest must be a info loaded when the special group is loaded and saved in a variable.

The code I posted for you increases the time complexity of the function and it's not a good ideea 😀

 

 

It was a patch to a item duplication bug. I'm pretty sure this is something everyone needs (since the dupe-bug appeared on official server)

 

Big thanks to you abel.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.