format: reformat project

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov
2024-08-03 19:53:48 +03:00
committed by Pugemon
parent 736cd175d5
commit bbf33e8e4d
202 changed files with 7389 additions and 5609 deletions
+2 -4
View File
@@ -40,15 +40,13 @@ void Inventories::remove(int64_t id) {
std::shared_ptr<Inventory> Inventories::get(int64_t id) {
auto found = map.find(id);
if (found == map.end())
return nullptr;
if (found == map.end()) return nullptr;
return found->second;
}
std::shared_ptr<Inventory> Inventories::clone(int64_t id) {
auto original = get(id);
if (original == nullptr)
return nullptr;
if (original == nullptr) return nullptr;
auto clone = std::make_shared<Inventory>(*original);
clone->setId(level.getWorld()->getNextInventoryId());
store(clone);
+3 -3
View File
@@ -1,12 +1,12 @@
#ifndef ITEMS_INVENTORIES_HPP_
#define ITEMS_INVENTORIES_HPP_
#include <string>
#include <memory>
#include <string>
#include <unordered_map>
#include "Inventory.hpp"
#include "../maths/util.hpp"
#include "Inventory.hpp"
class Level;
@@ -41,4 +41,4 @@ public:
const inventories_map& getMap() const;
};
#endif // ITEMS_INVENTORIES_HPP_
#endif // ITEMS_INVENTORIES_HPP_
+4 -7
View File
@@ -1,7 +1,7 @@
#include "Inventory.hpp"
#include "../data/dynamic.hpp"
#include "../content/ContentLUT.hpp"
#include "../data/dynamic.hpp"
Inventory::Inventory(int64_t id, size_t size) : id(id), slots(size) {
}
@@ -35,11 +35,8 @@ size_t Inventory::findSlotByItem(itemid_t id, size_t begin, size_t end) {
}
void Inventory::move(
ItemStack& item,
const ContentIndices* indices,
size_t begin,
size_t end)
{
ItemStack& item, const ContentIndices* indices, size_t begin, size_t end
) {
end = std::min(slots.size(), end);
for (size_t i = begin; i < end && !item.isEmpty(); i++) {
ItemStack& slot = slots[i];
@@ -61,7 +58,7 @@ void Inventory::deserialize(dynamic::Map* src) {
itemid_t id = item->get("id", ITEM_EMPTY);
itemcount_t count = item->get("count", 0);
auto& slot = slots[i];
slot.set(ItemStack(id, count));
slot.set(ItemStack(id, count));
}
}
+14 -14
View File
@@ -1,13 +1,12 @@
#ifndef ITEMS_INVENTORY_HPP_
#define ITEMS_INVENTORY_HPP_
#include "ItemStack.hpp"
#include "../typedefs.hpp"
#include "../interfaces/Serializable.hpp"
#include <vector>
#include <memory>
#include <vector>
#include "../interfaces/Serializable.hpp"
#include "../typedefs.hpp"
#include "ItemStack.hpp"
namespace dynamic {
class Map;
@@ -25,18 +24,19 @@ public:
Inventory(const Inventory& orig);
ItemStack& getSlot(size_t index);
size_t findEmptySlot(size_t begin=0, size_t end=-1) const;
size_t findSlotByItem(itemid_t id, size_t begin=0, size_t end=-1);
size_t findEmptySlot(size_t begin = 0, size_t end = -1) const;
size_t findSlotByItem(itemid_t id, size_t begin = 0, size_t end = -1);
inline size_t size() const {
return slots.size();
}
void move(
ItemStack& item,
const ContentIndices* indices,
size_t begin=0,
size_t end=-1);
ItemStack& item,
const ContentIndices* indices,
size_t begin = 0,
size_t end = -1
);
/* deserializing inventory */
void deserialize(dynamic::Map* src) override;
@@ -60,4 +60,4 @@ public:
static const size_t npos;
};
#endif // ITEMS_INVENTORY_HPP_
#endif // ITEMS_INVENTORY_HPP_
+1
View File
@@ -1,4 +1,5 @@
#include "ItemDef.hpp"
#include "../util/stringutil.hpp"
ItemDef::ItemDef(const std::string& name) : name(name) {
+10 -10
View File
@@ -1,22 +1,22 @@
#ifndef CONTENT_ITEMS_ITEM_DEF_HPP_
#define CONTENT_ITEMS_ITEM_DEF_HPP_
#include <string>
#include <glm/glm.hpp>
#include <string>
#include "../typedefs.hpp"
struct item_funcs_set {
bool init: 1;
bool on_use: 1;
bool on_use_on_block: 1;
bool on_block_break_by: 1;
bool init : 1;
bool on_use : 1;
bool on_use_on_block : 1;
bool on_block_break_by : 1;
};
enum class item_icon_type {
none, // invisible (core:empty) must not be rendered
sprite, // textured quad: icon is `atlas_name:texture_name`
block, // block preview: icon is string block id
none, // invisible (core:empty) must not be rendered
sprite, // textured quad: icon is `atlas_name:texture_name`
block, // block preview: icon is string block id
};
struct ItemDef {
@@ -34,7 +34,7 @@ struct ItemDef {
std::string icon = "blocks:notfound";
std::string placingBlock = "core:air";
std::string scriptName = name.substr(name.find(':')+1);
std::string scriptName = name.substr(name.find(':') + 1);
struct {
itemid_t id;
@@ -47,4 +47,4 @@ struct ItemDef {
ItemDef(const ItemDef&) = delete;
};
#endif //CONTENT_ITEMS_ITEM_DEF_HPP_
#endif // CONTENT_ITEMS_ITEM_DEF_HPP_
+5 -4
View File
@@ -1,12 +1,13 @@
#include "ItemStack.hpp"
#include "ItemDef.hpp"
#include "../content/Content.hpp"
#include "ItemDef.hpp"
ItemStack::ItemStack() : item(ITEM_EMPTY), count(0) {
}
ItemStack::ItemStack(itemid_t item, itemcount_t count) : item(item), count(count) {
ItemStack::ItemStack(itemid_t item, itemcount_t count)
: item(item), count(count) {
}
void ItemStack::set(const ItemStack& item) {
@@ -26,13 +27,13 @@ bool ItemStack::accepts(const ItemStack& other) const {
void ItemStack::move(ItemStack& item, const ContentIndices* indices) {
auto def = indices->items.get(item.getItemId());
int count = std::min(item.count, def->stackSize-this->count);
int count = std::min(item.count, def->stackSize - this->count);
if (isEmpty()) {
set(ItemStack(item.getItemId(), count));
} else {
setCount(this->count + count);
}
item.setCount(item.count-count);
item.setCount(item.count - count);
}
void ItemStack::setCount(itemcount_t count) {
+2 -2
View File
@@ -1,8 +1,8 @@
#ifndef ITEMS_ITEM_STACK_HPP_
#define ITEMS_ITEM_STACK_HPP_
#include "../typedefs.hpp"
#include "../constants.hpp"
#include "../typedefs.hpp"
class ContentIndices;
@@ -37,4 +37,4 @@ public:
}
};
#endif // ITEMS_ITEM_STACK_HPP_
#endif // ITEMS_ITEM_STACK_HPP_