Bump to C++ 20

master
Auri 2021-09-03 14:22:58 -07:00
parent 22a6c4c28f
commit a08af1b260
12 changed files with 26 additions and 56 deletions

View File

@ -2,35 +2,5 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/build/_deps/corrade-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/build/_deps/glfw-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/build/_deps/imgui-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/build/_deps/imnodes-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/build/_deps/magnum-integration-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/build/_deps/magnum-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/corrade-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/glfw-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/imgui-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/imnodes-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/magnum-integration-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-debug/_deps/magnum-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-minsizerel/_deps/corrade-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-minsizerel/_deps/glfw-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-minsizerel/_deps/imgui-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-minsizerel/_deps/imnodes-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-minsizerel/_deps/magnum-integration-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-minsizerel/_deps/magnum-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/corrade-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/glfw-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/imgui-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/imnodes-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/magnum-integration-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-release/_deps/magnum-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/corrade-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/glfw-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/imgui-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/imnodes-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/magnum-integration-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cmake-build-relwithdebinfo/_deps/magnum-src" vcs="Git" />
</component> </component>
</project> </project>

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.19)
cmake_policy(SET CMP0077 NEW) # set() overrides option() cmake_policy(SET CMP0077 NEW) # set() overrides option()
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)

View File

@ -36,7 +36,7 @@ public:
CallbackRef bind(const CB_TYPE& cb) { CallbackRef bind(const CB_TYPE& cb) {
usize cID = next++; usize cID = next++;
callbacks.emplace(cID, InvalidatableCB(cb)); callbacks.emplace(cID, InvalidatableCB(cb));
return CallbackRef([=]() { unbind(cID); }); return CallbackRef([cID, this]() { unbind(cID); });
}; };
void unbind(usize ind) { void unbind(usize ind) {

View File

@ -153,12 +153,10 @@ void MainMenuScene::findSubgames() {
} }
cf_dir_close(&subgame); cf_dir_close(&subgame);
if (!hasConf) if (!hasConf) throw std::runtime_error(
throw std::runtime_error( string("Subgame ") + string(subgameFolder.name) + " is missing a conf.json.");
string("Subgame ") + string(subgameFolder.name) + " is missing a conf.json."); if (!hasMods) throw std::runtime_error(
if (!hasMods) string("Subgame ") + string(subgameFolder.name) + " is missing a 'mods' directory.");
throw std::runtime_error(
string("Subgame ") + string(subgameFolder.name) + " is missing a 'mods' directory.");
nlohmann::json j{}; nlohmann::json j{};
try { try {

View File

@ -13,7 +13,7 @@ LocalDefinitionAtlas::LocalDefinitionAtlas(TextureAtlas& atlas) {
BlockDef* invalid = new BlockDef(); BlockDef* invalid = new BlockDef();
invalid->identifier = "invalid"; invalid->identifier = "invalid";
invalid->name = "INVALID"; invalid->name = "INVALID";
invalid->maxStackSize = 64; invalid->maxStack = 64;
invalid->model = invalidModel; invalid->model = invalidModel;
invalid->farModel = invalidModel; invalid->farModel = invalidModel;
invalid->sBoxes = {{{ 0, 0, 0 }, { 1, 1, 1 }}}; invalid->sBoxes = {{{ 0, 0, 0 }, { 1, 1, 1 }}};
@ -28,7 +28,7 @@ LocalDefinitionAtlas::LocalDefinitionAtlas(TextureAtlas& atlas) {
air->identifier = "air"; air->identifier = "air";
air->index = 1; air->index = 1;
air->name = "Air"; air->name = "Air";
air->maxStackSize = 64; air->maxStack = 64;
air->model = nullModel; air->model = nullModel;
air->farModel = nullModel; air->farModel = nullModel;
air->solid = false; air->solid = false;

View File

@ -12,7 +12,7 @@ ServerDefinitionAtlas::ServerDefinitionAtlas() {
BlockDef* invalid = new BlockDef(); BlockDef* invalid = new BlockDef();
invalid->identifier = "invalid"; invalid->identifier = "invalid";
invalid->name = "INVALID"; invalid->name = "INVALID";
invalid->maxStackSize = 64; invalid->maxStack = 64;
invalid->model = invalidModel; invalid->model = invalidModel;
invalid->farModel = invalidModel; invalid->farModel = invalidModel;
invalid->sBoxes = {{{ 0, 0, 0 }, { 1, 1, 1 }}}; invalid->sBoxes = {{{ 0, 0, 0 }, { 1, 1, 1 }}};
@ -26,7 +26,7 @@ ServerDefinitionAtlas::ServerDefinitionAtlas() {
air->identifier = "air"; air->identifier = "air";
air->index = 1; air->index = 1;
air->name = "Air"; air->name = "Air";
air->maxStackSize = 64; air->maxStack = 64;
air->model = nullModel; air->model = nullModel;
air->farModel = nullModel; air->farModel = nullModel;
air->solid = false; air->solid = false;

View File

@ -30,7 +30,7 @@ public:
HIT, HIT_CLIENT HIT, HIT_CLIENT
}; };
BlockDef() : ItemDef{ "", "", 0, 0, ItemDef::Type::BLOCK } {}; BlockDef() : ItemDef(ItemDef::Type::BLOCK) {};
void createModel(); void createModel();

View File

@ -15,7 +15,7 @@ CraftItemDef::CraftItemDef(const std::string& identifier, unsigned int index, co
unsigned short maxStackSize, const std::vector<std::string>& textures, unsigned short maxStackSize, const std::vector<std::string>& textures,
const std::vector<std::shared_ptr<AtlasRef>>& textureRefs) : const std::vector<std::shared_ptr<AtlasRef>>& textureRefs) :
ItemDef{ identifier, name, index, maxStackSize, ItemDef::Type::CRAFTITEM }, ItemDef(ItemDef::Type::CRAFTITEM, identifier, name, index, maxStackSize),
textures(textures), textures(textures),
textureRefs(textureRefs) {} textureRefs(textureRefs) {}

View File

@ -20,7 +20,7 @@ public:
HIT, HIT_CLIENT HIT, HIT_CLIENT
}; };
CraftItemDef() : ItemDef{ "", "", 0, 0, ItemDef::Type::CRAFTITEM } {}; CraftItemDef(): ItemDef(ItemDef::Type::CRAFTITEM) {};
CraftItemDef(const std::string& identifier, const std::string& name, unsigned short maxStackSize, CraftItemDef(const std::string& identifier, const std::string& name, unsigned short maxStackSize,
const std::vector<std::string>& textures, const std::vector<std::shared_ptr<AtlasRef>>& textureRefs); const std::vector<std::string>& textures, const std::vector<std::shared_ptr<AtlasRef>>& textureRefs);

View File

@ -11,22 +11,24 @@
class ItemDef { class ItemDef {
public: public:
ItemDef(const ItemDef& o) = delete;
enum class Type { enum class Type {
INVALID, INVALID,
BLOCK, BLOCK,
CRAFTITEM CRAFTITEM
}; };
std::string identifier = ""; ItemDef(const ItemDef& o) = delete;
std::string name = ""; ItemDef(Type type): type(type) {}
unsigned int index = 0; ItemDef(Type type, string identifier, string name, u16 index, u16 maxStack):
type(type), identifier(identifier), name(name), index(index), maxStack(maxStack) {}
unsigned short maxStackSize; string identifier {};
string name {};
u16 index = 0;
u16 maxStack = 0;
Type type = Type::INVALID; Type type = Type::INVALID;
std::shared_ptr<Model> entityModel = std::make_shared<Model>(); sptr<Model> entityModel = make_shared<Model>();
}; };

View File

@ -375,7 +375,7 @@ namespace RegisterBlock {
def->health = health; def->health = health;
def->defense = defense; def->defense = defense;
def->maxStackSize = maxStack; def->maxStack = maxStack;
def->model = models.first; def->model = models.first;
def->farModel = models.second; def->farModel = models.second;

View File

@ -67,7 +67,7 @@ ItemStack InventoryList::placeStack(unsigned short i, const ItemStack& stack, bo
else { else {
if (otherStack.count) { if (otherStack.count) {
if (otherStack.id == stack.id) { if (otherStack.id == stack.id) {
unsigned short maxStack = game->getDefs().fromId(stack.id).maxStackSize; unsigned short maxStack = game->getDefs().fromId(stack.id).maxStack;
if (allowedPut >= stack.count && allowedPut + otherStack.count < maxStack) { if (allowedPut >= stack.count && allowedPut + otherStack.count < maxStack) {
setStack(i, { stack.id, static_cast<unsigned short>(otherStack.count + allowedPut) }); setStack(i, { stack.id, static_cast<unsigned short>(otherStack.count + allowedPut) });
// if (on_put) on_put(i+1, LuaItemStack(otherStack, defs)); // if (on_put) on_put(i+1, LuaItemStack(otherStack, defs));
@ -126,7 +126,7 @@ ItemStack InventoryList::splitStack(unsigned short i, bool playerInitiated) {
} }
ItemStack InventoryList::addStack(ItemStack stack, bool playerInitiated) { ItemStack InventoryList::addStack(ItemStack stack, bool playerInitiated) {
unsigned short maxStack = game->getDefs().fromId(stack.id).maxStackSize; unsigned short maxStack = game->getDefs().fromId(stack.id).maxStack;
unsigned short i = 0; unsigned short i = 0;
while (i < items.size() && stack.count > 0) { while (i < items.size() && stack.count > 0) {
@ -162,7 +162,7 @@ ItemStack InventoryList::addStack(ItemStack stack, bool playerInitiated) {
} }
unsigned short InventoryList::stackFits(const ItemStack& stack) { unsigned short InventoryList::stackFits(const ItemStack& stack) {
unsigned short maxStack = game->getDefs().fromId(stack.id).maxStackSize; unsigned short maxStack = game->getDefs().fromId(stack.id).maxStack;
unsigned short i = 0; unsigned short i = 0;
unsigned short fits = 0; unsigned short fits = 0;