Skip to content

Commit

Permalink
added tracing, improved way chunks are stream to clients
Browse files Browse the repository at this point in the history
  • Loading branch information
mmbednarek committed Feb 15, 2024
1 parent bff2c9d commit 1fba424
Show file tree
Hide file tree
Showing 64 changed files with 1,419 additions and 219 deletions.
4 changes: 3 additions & 1 deletion Build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"controller",
"container",
"command",
"debug",
"entity",
"format",
"game",
Expand Down Expand Up @@ -33,6 +34,7 @@
"nbtscheme",
"recipes",
"snbt_parser",
"schema_compiler"
"schema_compiler",
"trace_tool"
]
}
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wconversion -Werror -Wno-unknown-pragmas")

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-dangling-reference -fpermissive")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-dangling-reference -Wno-missing-field-initializers -fpermissive")
endif ()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
Expand Down Expand Up @@ -103,7 +103,7 @@ FetchContent_MakeAvailable(libmb)
FetchContent_Declare(
libmb_codegen
GIT_REPOSITORY https://github.com/mmbednarek/codegen
GIT_TAG codegen-0.0.40
GIT_TAG codegen-0.0.41
)
FetchContent_MakeAvailable(libmb_codegen)

Expand Down
45 changes: 45 additions & 0 deletions api/minecpp/nbt/trace/Trace.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
generator = "nbt"
package minecpp.nbt.trace

[NBT]
record ChunkDispatchRequested {
chunk_x: int32
chunk_z: int32
}

[NBT]
record ChunkSentToPlayer {
chunk_x: int32
chunk_z: int32
player_id: string
}

[NBT]
record GeneratingChunk {
chunk_x: int32
chunk_z: int32
}

[NBT]
record HandlingChunkData {
chunk_x: int32
chunk_z: int32
}

[NBT]
record PreHandlingChunkDataJob {
chunk_x: int32
chunk_z: int32
}

[NBT]
record PostHandlingChunkDataJob {
chunk_x: int32
chunk_z: int32
}

[NBT]
record HandlingEmptyChunk {
chunk_x: int32
chunk_z: int32
}
3 changes: 2 additions & 1 deletion library/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
add_subdirectory(api)
add_subdirectory(repository)
add_subdirectory(chat)
add_subdirectory(crypto)
add_subdirectory(controller)
add_subdirectory(container)
add_subdirectory(debug)
add_subdirectory(format)
add_subdirectory(random)
add_subdirectory(util)
Expand All @@ -16,5 +16,6 @@ add_subdirectory(entity)
add_subdirectory(lexer)
add_subdirectory(command)
add_subdirectory(world)
add_subdirectory(repository)
add_subdirectory(signal)
add_subdirectory(stream)
5 changes: 5 additions & 0 deletions library/api/include/minecpp/nbt/block/Block.schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace minecpp::nbt::block {

class EnumProperty {
public:
static constexpr auto object_name = "EnumProperty";
std::string name{};
std::vector<std::string> values{};
EnumProperty() = default;
Expand All @@ -24,6 +25,7 @@ class EnumProperty {

class IntProperty {
public:
static constexpr auto object_name = "IntProperty";
std::string name{};
std::int32_t min_value{};
std::int32_t max_value{};
Expand All @@ -36,6 +38,7 @@ class IntProperty {

class BoolProperty {
public:
static constexpr auto object_name = "BoolProperty";
std::string name{};
BoolProperty() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
Expand All @@ -46,6 +49,7 @@ class BoolProperty {

class Block {
public:
static constexpr auto object_name = "Block";
std::vector<std::string> property_tags{};
Block() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
Expand All @@ -56,6 +60,7 @@ class Block {

class BlockEntityData {
public:
static constexpr auto object_name = "BlockEntityData";
BlockEntityData() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
void serialize(std::ostream &out_stream, std::string_view in_compound_name) const;
Expand Down
1 change: 1 addition & 0 deletions library/api/include/minecpp/nbt/block/BlockState.schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace minecpp::nbt::block {

class BlockState {
public:
static constexpr auto object_name = "BlockState";
std::int8_t blocks_movement{};
std::int32_t luminance{};
std::int32_t opacity{};
Expand Down
15 changes: 15 additions & 0 deletions library/api/include/minecpp/nbt/chunk/Chunk.schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace minecpp::nbt::chunk {

class ArmorItem {
public:
static constexpr auto object_name = "ArmorItem";
std::int32_t no_empty{};
ArmorItem() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
Expand All @@ -23,6 +24,7 @@ class ArmorItem {

class Attribute {
public:
static constexpr auto object_name = "Attribute";
double base{};
std::string name{};
Attribute() = default;
Expand All @@ -34,6 +36,7 @@ class Attribute {

class Memories {
public:
static constexpr auto object_name = "Memories";
std::int32_t no_empty{};
Memories() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
Expand All @@ -44,6 +47,7 @@ class Memories {

class Brain {
public:
static constexpr auto object_name = "Brain";
Memories memories{};
Brain() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
Expand All @@ -54,6 +58,7 @@ class Brain {

class HandItem {
public:
static constexpr auto object_name = "HandItem";
std::int32_t no_empty{};
HandItem() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
Expand All @@ -64,6 +69,7 @@ class HandItem {

class Entity {
public:
static constexpr auto object_name = "Entity";
float absorption_amount{};
std::int16_t air{};
std::vector<float> armor_drop_chances{};
Expand Down Expand Up @@ -102,6 +108,7 @@ class Entity {

class Heightmaps {
public:
static constexpr auto object_name = "Heightmaps";
std::vector<std::int64_t> motion_blocking{};
std::vector<std::int64_t> motion_blocking_no_leaves{};
std::vector<std::int64_t> ocean_floor{};
Expand All @@ -117,6 +124,7 @@ class Heightmaps {

class HeightmapsNet {
public:
static constexpr auto object_name = "HeightmapsNet";
std::vector<std::int64_t> motion_blocking{};
std::vector<std::int64_t> world_surface{};
HeightmapsNet() = default;
Expand All @@ -128,6 +136,7 @@ class HeightmapsNet {

class PaletteItem {
public:
static constexpr auto object_name = "PaletteItem";
std::string name{};
::minecpp::nbt::CompoundContent properties{};
PaletteItem() = default;
Expand All @@ -139,6 +148,7 @@ class PaletteItem {

class Section {
public:
static constexpr auto object_name = "Section";
std::int8_t y{};
std::vector<std::uint8_t> block_light{};
std::vector<std::uint8_t> sky_light{};
Expand All @@ -153,6 +163,7 @@ class Section {

class Start {
public:
static constexpr auto object_name = "Start";
std::string id{};
Start() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
Expand All @@ -163,6 +174,7 @@ class Start {

class Structures {
public:
static constexpr auto object_name = "Structures";
std::map<std::string, Start> starts{};
Structures() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
Expand All @@ -173,6 +185,7 @@ class Structures {

class CarvingMasks {
public:
static constexpr auto object_name = "CarvingMasks";
std::vector<std::uint8_t> air{};
std::vector<std::uint8_t> liquid{};
CarvingMasks() = default;
Expand All @@ -184,6 +197,7 @@ class CarvingMasks {

class Level {
public:
static constexpr auto object_name = "Level";
std::vector<std::int32_t> biomes{};
CarvingMasks carving_masks{};
std::vector<Entity> entities{};
Expand All @@ -207,6 +221,7 @@ class Level {

class Chunk {
public:
static constexpr auto object_name = "Chunk";
std::int32_t version{};
Level level{};
Chunk() = default;
Expand Down
3 changes: 3 additions & 0 deletions library/api/include/minecpp/nbt/common/Common.schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace minecpp::nbt::common {

class ChunkPosition {
public:
static constexpr auto object_name = "ChunkPosition";
std::int32_t x{};
std::int32_t y{};
ChunkPosition() = default;
Expand All @@ -24,6 +25,7 @@ class ChunkPosition {

class BlockPosition {
public:
static constexpr auto object_name = "BlockPosition";
std::int32_t x{};
std::int32_t y{};
std::int32_t z{};
Expand All @@ -36,6 +38,7 @@ class BlockPosition {

class FaceMask {
public:
static constexpr auto object_name = "FaceMask";
std::int8_t down{};
std::int8_t east{};
std::int8_t north{};
Expand Down
3 changes: 3 additions & 0 deletions library/api/include/minecpp/nbt/item/Item.schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace minecpp::nbt::item {

class Item {
public:
static constexpr auto object_name = "Item";
std::int8_t is_block{};
std::string corresponding_block_tag{};
std::int32_t max_item_stack{};
Expand All @@ -25,6 +26,7 @@ class Item {

class StoredEnchantment {
public:
static constexpr auto object_name = "StoredEnchantment";
std::string id{};
std::int16_t lvl{};
StoredEnchantment() = default;
Expand All @@ -36,6 +38,7 @@ class StoredEnchantment {

class SlotData {
public:
static constexpr auto object_name = "SlotData";
std::optional<std::vector<StoredEnchantment>> stored_enchantments{};
SlotData() = default;
void serialize_no_header(minecpp::nbt::Writer &w) const;
Expand Down
Loading

0 comments on commit 1fba424

Please sign in to comment.