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

This commit is contained in:
Alex King
2024-05-04 18:11:59 -04:00
committed by GitHub
parent 46f3e50b5c
commit c4cda66c3b
3 changed files with 174 additions and 0 deletions
@@ -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