fix build on non windows

This commit is contained in:
matcool 2024-02-26 19:03:04 -03:00
parent 2689320116
commit 10edd35475

View file

@ -1,7 +1,7 @@
#include "ModListSource.hpp"
#include <server/Server.hpp>
static size_t PAGE_SIZE = 10;
static size_t PER_PAGE = 10;
static size_t ceildiv(size_t a, size_t b) {
// https://stackoverflow.com/questions/2745074/fast-ceiling-of-an-integer-division-in-c-c
@ -38,7 +38,7 @@ typename ModListSource::PagePromise ModListSource::loadPage(size_t page, bool up
}
std::optional<size_t> ModListSource::getPageCount() const {
return m_cachedItemCount ? std::optional(ceildiv(m_cachedItemCount.value(), PAGE_SIZE)) : std::nullopt;
return m_cachedItemCount ? std::optional(ceildiv(m_cachedItemCount.value(), PER_PAGE)) : std::nullopt;
}
std::optional<size_t> ModListSource::getItemCount() const {
@ -52,8 +52,8 @@ typename ModListSource::PagePromise InstalledModsList::reloadPage(size_t page) {
auto content = Page();
auto all = Loader::get()->getAllMods();
for (
size_t i = page * PAGE_SIZE;
i < all.size() && i < (page + 1) * PAGE_SIZE;
size_t i = page * PER_PAGE;
i < all.size() && i < (page + 1) * PER_PAGE;
i += 1
) {
content.push_back(InstalledModItem::create(all.at(i)));
@ -72,7 +72,7 @@ typename ModListSource::PagePromise FeaturedModsList::reloadPage(size_t page) {
return PagePromise([this, page](auto resolve, auto reject, auto progress, auto cancelled) {
server::getMods(server::ModsQuery {
.page = page,
.pageSize = PAGE_SIZE,
.pageSize = PER_PAGE,
})
.then([this, resolve, reject](server::ServerModsList list) {
m_cachedItemCount = list.totalModCount;