diff --git a/src/client/conn/ClientNetworkInterpreter.cpp b/src/client/conn/ClientNetworkInterpreter.cpp index 952388f1..98485bf6 100644 --- a/src/client/conn/ClientNetworkInterpreter.cpp +++ b/src/client/conn/ClientNetworkInterpreter.cpp @@ -95,8 +95,7 @@ void ClientNetworkInterpreter::receivedPacket(std::unique_ptr p) { case Packet::Type::INV_INVALID: { std::string source = p->d.read(); std::string list = p->d.read(); - throw std::runtime_error("Invalid inventory " + source + ":" + list + " was request by client."); - break; } + throw std::runtime_error("Invalid inventory " + source + ":" + list + " was request by client."); } } } diff --git a/src/client/menu/MenuSandbox.cpp b/src/client/menu/MenuSandbox.cpp index 025e6472..5d7fbd33 100644 --- a/src/client/menu/MenuSandbox.cpp +++ b/src/client/menu/MenuSandbox.cpp @@ -195,11 +195,11 @@ sol::protected_function_result MenuSandbox::errorCallback(sol::protected_functio throw std::out_of_range("Error thrown outside of handled files. [2]"); } - catch (std::runtime_error e) { + catch (const std::runtime_error& e) { std::cout << Log::err << e.what() << std::endl; throw; } - catch (std::out_of_range e) { + catch (const std::out_of_range& e) { std::cout << Log::err << "Failed to format error, " << e.what() << Log::endl; throw std::runtime_error(errString); } diff --git a/src/client/scene/MainMenuScene.cpp b/src/client/scene/MainMenuScene.cpp index 4ca615a9..548c89ff 100644 --- a/src/client/scene/MainMenuScene.cpp +++ b/src/client/scene/MainMenuScene.cpp @@ -184,7 +184,7 @@ void MainMenuScene::findSubgames() { subgames.push_back({icon, {name, description, version}, subgameFolder.path}); } - catch(const std::runtime_error e) { + catch(const std::runtime_error& e) { std::cout << Log::err << "Encountered an error while loading subgames:\n\t" << e.what() << Log::endl; } diff --git a/src/util/Lockable.h b/src/util/Lockable.h index 714af6e2..73aabd82 100644 --- a/src/util/Lockable.h +++ b/src/util/Lockable.h @@ -6,20 +6,20 @@ #include -using MutexType = std::shared_timed_mutex; -using ReadLock = std::shared_lock; -using WriteLock = std::unique_lock; +using mutex_type = std::shared_timed_mutex; +using read_lock = std::shared_lock; +using write_lock = std::unique_lock; class Lockable { public: - ReadLock getReadLock() const { - return ReadLock {const_cast(mutex)}; + read_lock getReadLock() const { + return read_lock {const_cast(mutex)}; }; - WriteLock getWriteLock() { - return WriteLock {mutex}; + write_lock getWriteLock() { + return write_lock {mutex}; }; private: - MutexType mutex; + mutex_type mutex; }; \ No newline at end of file diff --git a/src/world/dim/Dimension.cpp b/src/world/dim/Dimension.cpp index 25c03107..5fa15b86 100644 --- a/src/world/dim/Dimension.cpp +++ b/src/world/dim/Dimension.cpp @@ -36,7 +36,7 @@ bool Dimension::setBlock(glm::ivec3 pos, unsigned int block) { } unsigned int Dimension::nextEntityInd() { - auto l = getWriteLock(); + auto _ = getWriteLock(); return entityInd++; } @@ -103,7 +103,7 @@ std::unordered_set Dimension::propogateAddNodes() { int subtract = sunDown ? 0 : 1; chunk->setLight(ind, channel, lightLevel - subtract); - auto l = getWriteLock(); + l.lock(); lightAddQueue[channel].emplace(ind, chunk); l.unlock(); } @@ -147,7 +147,7 @@ std::unordered_set Dimension::propogateRemoveNodes() { game->getDefs().blockFromId(chunk->getBlock(Space::Block::index(check))).lightSource[channel]); chunk->setLight(ind, channel, replaceLight); - auto l = getWriteLock(); + l.lock(); if (replaceLight) lightAddQueue[channel].emplace(ind, chunk); lightRemoveQueue[channel].emplace(ind, checkLight, chunk); l.unlock(); @@ -156,7 +156,7 @@ std::unordered_set Dimension::propogateRemoveNodes() { auto chunk = containsWorldPos(node.chunk, check) ? node.chunk : getChunk(Space::Chunk::world::fromBlock(check)).get(); if (!chunk) continue; - auto l = getWriteLock(); + l.lock(); lightAddQueue[channel].emplace(ind, chunk); l.unlock(); } @@ -219,7 +219,7 @@ void Dimension::addBlockLight(glm::ivec3 pos, glm::ivec3 light) { startChunk->setLight(ind, 1, light.y); startChunk->setLight(ind, 2, light.z); - auto l = getWriteLock(); + auto _ = getWriteLock(); lightAddQueue[0].emplace(ind, startChunk.get()); lightAddQueue[1].emplace(ind, startChunk.get()); lightAddQueue[2].emplace(ind, startChunk.get()); @@ -234,7 +234,7 @@ void Dimension::removeBlockLight(glm::ivec3 pos) { startChunk->setLight(ind, 1, 0); startChunk->setLight(ind, 2, 0); - auto l = getWriteLock(); + auto _ = getWriteLock(); lightRemoveQueue[0].emplace(ind, val.x, startChunk.get()); lightRemoveQueue[1].emplace(ind, val.y, startChunk.get()); lightRemoveQueue[2].emplace(ind, val.z, startChunk.get()); @@ -259,7 +259,7 @@ void Dimension::reflowLight(glm::ivec3 pos) { chunk->setLight(ind, placeLight); - auto l = getWriteLock(); + auto _ = getWriteLock(); lightAddQueue[0].emplace(ind, chunk.get()); lightAddQueue[1].emplace(ind, chunk.get()); lightAddQueue[2].emplace(ind, chunk.get()); @@ -272,7 +272,7 @@ void Dimension::removeSunlight(glm::ivec3 pos) { unsigned int light = chunk->getLight(ind, 3); chunk->setLight(ind, 3, 0); - auto l = getWriteLock(); + auto _ = getWriteLock(); lightRemoveQueue[SUNLIGHT_CHANNEL].emplace(ind, light, chunk.get()); } @@ -281,6 +281,6 @@ void Dimension::setAndReflowSunlight(glm::ivec3 pos, unsigned char level) { unsigned int ind = Space::Block::index(pos); chunk->setLight(ind, 3, level); - auto l = getWriteLock(); + auto _ = getWriteLock(); lightAddQueue[SUNLIGHT_CHANNEL].emplace(ind, chunk.get()); } \ No newline at end of file diff --git a/src/world/dim/DimensionBase.cpp b/src/world/dim/DimensionBase.cpp index 8264cc3f..9b8648c4 100644 --- a/src/world/dim/DimensionBase.cpp +++ b/src/world/dim/DimensionBase.cpp @@ -23,15 +23,13 @@ unsigned int DimensionBase::getInd() { } std::shared_ptr DimensionBase::getRegion(glm::ivec3 regionPosition) const { -// std::cout << "region start" << std::endl; - auto l = getReadLock(); -// std::cout << "region mid" << std::endl; + auto _ = getReadLock(); if (!regions.count(regionPosition)) return nullptr; return regions.at(regionPosition); } void DimensionBase::removeRegion(glm::ivec3 pos) { - auto l = getWriteLock(); + auto _ = getWriteLock(); regions.erase(pos); } @@ -44,8 +42,8 @@ std::shared_ptr DimensionBase::getMapBlock(glm::ivec3 mapBlockPosition void DimensionBase::removeMapBlock(glm::ivec3 pos) { auto region = getRegion(Space::Region::world::fromMapBlock(pos)); if (!region) return; - auto ind = Space::MapBlock::index(pos); - region->remove(ind); + auto i = Space::MapBlock::index(pos); + region->remove(i); if (region->count == 0) removeRegion(Space::Region::world::fromMapBlock(pos)); } @@ -68,8 +66,8 @@ void DimensionBase::setChunk(std::shared_ptr chunk) { void DimensionBase::removeChunk(glm::ivec3 pos){ auto mapBlock = getMapBlock(Space::MapBlock::world::fromChunk(pos)); if (!mapBlock) return; - auto ind = Space::Chunk::index(pos); - mapBlock->remove(ind); + auto i = Space::Chunk::index(pos); + mapBlock->remove(i); if (mapBlock->count == 0) removeMapBlock(Space::MapBlock::world::fromChunk(pos)); } @@ -91,7 +89,7 @@ bool DimensionBase::setBlock(glm::ivec3 pos, unsigned int block) { double DimensionBase::getBlockDamage(glm::ivec3 pos) const { - auto l = getReadLock(); + auto _ = getReadLock(); return blockDamages.count(pos) ? blockDamages.at(pos).curr : 0; } @@ -99,7 +97,7 @@ double DimensionBase::setBlockDamage(glm::ivec3 pos, double damage) { if (blockDamages.count(pos)) blockDamages[pos].curr = damage; else { double health = game->getDefs().blockFromId(getBlock(pos)).health; - auto l = getWriteLock(); + auto _ = getWriteLock(); blockDamages.insert({pos, Damage { damage, health }}); } @@ -121,7 +119,7 @@ bool DimensionBase::setBiome(glm::ivec3 pos, unsigned int biome) { } std::shared_ptr DimensionBase::getOrCreateRegion(glm::ivec3 pos) { - auto l = getWriteLock(); + auto _ = getWriteLock(); if (regions[pos]) return regions[pos]; regions[pos] = std::make_shared(pos); return regions[pos]; diff --git a/subgames/zeus/LICENSE.md b/subgames/zeus/LICENSE.md index f8ce6969..1bb2bc54 100644 --- a/subgames/zeus/LICENSE.md +++ b/subgames/zeus/LICENSE.md @@ -2,7 +2,7 @@ This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License](https://creativecommons.org/licenses/by-sa/3.0/). -### File-specific attribution and Licenses +## File-specific attribution and Licenses **zeus_button_extex.png** diff --git a/subgames/zeus/mods/aurailus_item_collection/README.md b/subgames/zeus/mods/aurailus_item_collection/README.md index 01c1cbca..f0a9539a 100644 --- a/subgames/zeus/mods/aurailus_item_collection/README.md +++ b/subgames/zeus/mods/aurailus_item_collection/README.md @@ -1,6 +1,6 @@ # Item Collection -**By Aurailus** +**By Auri Collings (Aurailus)** ## Description @@ -12,9 +12,9 @@ Item Collection is a mod that enables blocks to yield zero or more items when br Item Collection can be configured to yield items in multiple ways: -1) Adding blocks directly to the user's inventory. `"direct"` -2) Creating a dropped-item entity that can be picked up by a player standing nearby. `"ent_nearby"` -3) Creating a dropped-item entity that can be picked up by interacting with it. `"ent_interact"` +1. Adding blocks directly to the user's inventory. `"direct"` +2. Creating a dropped-item entity that can be picked up by a player standing nearby. `"ent_nearby"` +3. Creating a dropped-item entity that can be picked up by interacting with it. `"ent_interact"` This can be configured using the `/item_collection:set_mode` chat command, or by setting the `mode` parameter inside of the config file. (UNIMPLEMENTED) @@ -27,17 +27,17 @@ Item Collection will, by default, attempt to add all items to a `main` list insi Item Collection will look for a `yields` parameter in the definition of the block broken. This field can either be a string containing an item name, an item name followed by a number denoting how many of the item to yield, or a function which returns a string in one of the two previous formats. The following code blocks are examples of valid formats: Drop a dirt block: -``` +```lua yields = "zeus:default:dirt" ``` Drop four dirt blocks: -``` +```lua yields = "zeus:default:dirt 4" ``` Drop a dirt block 50% of the time: -``` +```lua yields = function(pos) if math.random() >= 0.5 then return "zeus:default:dirt"