Skip to content

Commit

Permalink
Merge pull request #6203 from Xaver-DaRed/well-see
Browse files Browse the repository at this point in the history
[Cafting] Add check for craft container
  • Loading branch information
claywar authored Sep 2, 2024
2 parents d7a202d + fc8774e commit ca22204
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/map/packet_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ void SmallPacket0x01A(map_session_data_t* const PSession, CCharEntity* const PCh
return;
}

if (PChar->m_Costume != 0 || PChar->animation == ANIMATION_SYNTH)
if (PChar->m_Costume != 0 || PChar->animation == ANIMATION_SYNTH || (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() > 0))
{
PChar->pushPacket(new CReleasePacket(PChar, RELEASE_TYPE::STANDARD));
return;
Expand Down Expand Up @@ -1582,8 +1582,9 @@ void SmallPacket0x032(map_session_data_t* const PSession, CCharEntity* const PCh
return;
}

// If either player is crafting, don't allow the trade request
if (PChar->animation == ANIMATION_SYNTH || PTarget->animation == ANIMATION_SYNTH)
// If either player is crafting, don't allow the trade request.
if (PChar->animation == ANIMATION_SYNTH || (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() > 0) ||
PTarget->animation == ANIMATION_SYNTH || (PTarget->CraftContainer && PTarget->CraftContainer->getItemsCount() > 0))
{
ShowDebug("%s trade request with %s was blocked.", PChar->getName(), PTarget->getName());
PChar->pushPacket(new CTradeActionPacket(PTarget, 0x07));
Expand Down Expand Up @@ -2453,7 +2454,7 @@ void SmallPacket0x04D(map_session_data_t* const PSession, CCharEntity* const PCh
return;
}

if (PChar->animation == ANIMATION_SYNTH)
if (PChar->animation == ANIMATION_SYNTH || (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() > 0))
{
ShowWarning("SmallPacket0x04D: %s attempting to access delivery box in the middle of a synth!", PChar->getName());
return;
Expand Down Expand Up @@ -4995,7 +4996,7 @@ void SmallPacket0x083(map_session_data_t* const PSession, CCharEntity* const PCh
void SmallPacket0x084(map_session_data_t* const PSession, CCharEntity* const PChar, CBasicPacket& data)
{
TracyZoneScoped;
if (PChar->animation != ANIMATION_SYNTH)
if (PChar->animation != ANIMATION_SYNTH && (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() == 0))
{
uint32 quantity = data.ref<uint32>(0x04);
uint16 itemID = data.ref<uint16>(0x08);
Expand Down Expand Up @@ -5031,26 +5032,29 @@ void SmallPacket0x085(map_session_data_t* const PSession, CCharEntity* const PCh
CItem* gil = PChar->getStorage(LOC_INVENTORY)->GetItem(0);
CItem* PItem = PChar->getStorage(LOC_INVENTORY)->GetItem(slotID);

if ((PItem != nullptr) && ((gil != nullptr) && gil->isType(ITEM_CURRENCY)))
if (PItem != nullptr && (gil != nullptr && gil->isType(ITEM_CURRENCY)))
{
if (PChar->CraftContainer)
{
ShowWarning("SmallPacket0x085: Player %s trying to sell while in the middle of a synth!", PChar->getName());
return;
}

if (quantity < 1 || quantity > PItem->getStackSize()) // Possible exploit
{
ShowWarning("SmallPacket0x085: Player %s trying to sell invalid quantity %u of itemID %u [to VENDOR] ",
PChar->getName(), quantity, PItem->getID());
ShowWarning("SmallPacket0x085: Player %s trying to sell invalid quantity %u of itemID %u [to VENDOR] ", PChar->getName(), quantity, PItem->getID());
return;
}

if (PItem->isSubType(ITEM_LOCKED)) // Possible exploit
{
ShowWarning("SmallPacket0x085: Player %s trying to sell %u of a LOCKED item! ID %i [to VENDOR] ",
PChar->getName(), quantity, PItem->getID());
ShowWarning("SmallPacket0x085: Player %s trying to sell %u of a LOCKED item! ID %i [to VENDOR] ", PChar->getName(), quantity, PItem->getID());
return;
}

if (PItem->getReserve() > 0) // Usually caused by bug during synth, trade, etc. reserving the item. We don't want such items sold in this state.
{
ShowError("SmallPacket0x085: Player %s trying to sell %u of a RESERVED(%u) item! ID %i [to VENDOR] ",
PChar->getName(), quantity, PItem->getReserve(), PItem->getID());
ShowError("SmallPacket0x085: Player %s trying to sell %u of a RESERVED(%u) item! ID %i [to VENDOR] ", PChar->getName(), quantity, PItem->getReserve(), PItem->getID());
return;
}

Expand Down Expand Up @@ -5081,7 +5085,7 @@ void SmallPacket0x096(map_session_data_t* const PSession, CCharEntity* const PCh

// If the player is already crafting, don't allow them to craft.
// This prevents packet injection based multi-craft, or time-based exploits.
if (PChar->animation == ANIMATION_SYNTH)
if (PChar->animation == ANIMATION_SYNTH || (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() > 0))
{
return;
}
Expand Down Expand Up @@ -5416,7 +5420,7 @@ void SmallPacket0x0AB(map_session_data_t* const PSession, CCharEntity* const PCh
void SmallPacket0x0AC(map_session_data_t* const PSession, CCharEntity* const PChar, CBasicPacket& data)
{
TracyZoneScoped;
if (PChar->animation != ANIMATION_SYNTH)
if (PChar->animation != ANIMATION_SYNTH && (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() == 0))
{
if (PChar->PGuildShop != nullptr)
{
Expand Down

0 comments on commit ca22204

Please sign in to comment.