Disallow attaching the same item to an email twice

Also fix vendor buying validation not allowing crates to be bought,
since apparently their maximum stack size is 0 in TableData.
This commit is contained in:
2021-03-09 22:26:07 +01:00
parent 89eb0b140b
commit f7e9cc2cea
2 changed files with 16 additions and 2 deletions

View File

@@ -750,6 +750,7 @@ void BuddyManager::emailSend(CNSocket* sock, CNPacketData* data) {
bool invalid = false;
int itemCount = 0;
std::set<int> seen;
for (int i = 0; i < 4; i++) {
int slot = pkt->aItem[i].iSlotNum;
if (slot < 0 || slot >= AINVEN_COUNT) {
@@ -763,9 +764,16 @@ void BuddyManager::emailSend(CNSocket* sock, CNPacketData* data) {
if (item->iID == 0)
continue;
// was the same item added multiple times?
if (seen.count(slot) > 0) {
invalid = true;
break;
}
seen.insert(slot);
itemCount++;
if (item->iType != real->iType || item->iID != real->iID
|| item->iOpt < 0 || item->iOpt > real->iOpt) {
|| item->iOpt <= 0 || item->iOpt > real->iOpt) {
invalid = true;
break;
}