[Quest API] Add Parcel Sending to Perl/Lua (#4287)

This commit is contained in:
Alex King authored and GitHub committed 2024-05-04 17:11:59 -05:00
1 parent 46f3e50b5c
commit c4cda66c3b
3 files changed
+174

No files matched your search

@@ -78,6 +78,37 @@ public:
return all_entries;
}
static int GetNextFreeParcelSlot(Database& db, const uint32 character_id, const uint32 max_slots)
{
const auto& l = CharacterParcelsRepository::GetWhere(
db,
fmt::format(
"char_id = '{}' ORDER BY slot_id ASC",
character_id
)
);
if (l.empty()) {
return PARCEL_BEGIN_SLOT;
}
for (uint32 i = PARCEL_BEGIN_SLOT; i <= max_slots; i++) {
auto it = std::find_if(
l.cbegin(),
l.cend(),
[&](const auto &x) {
return x.slot_id == i;
}
);
if (it == l.end()) {
return i;
}
}
return INVALID_INDEX;
}
};
#endif //EQEMU_CHARACTER_PARCELS_REPOSITORY_H