refactor(proto): restructure protobuf definitions and update build system

This commit is contained in:
2026-06-23 21:10:40 +08:00
parent 4303c1cd32
commit 678fc02998
13 changed files with 69 additions and 34 deletions

View File

@@ -151,15 +151,13 @@ add_executable(${PROJECT_NAME}
src/gameplay/session.cpp
src/gameplay/network_client.cpp
)
set(PROTO_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/proto/chunk_data.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/proto/player_pos.proto
${CMAKE_CURRENT_SOURCE_DIR}/src/proto/player_request.proto
file(GLOB_RECURSE PROTO_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/proto/*.proto
)
protobuf_generate(
TARGET ${PROJECT_NAME}
LANGUAGE cpp
PROTOS ${PROTO_SOURCES}
PROTOS ${PROTO_FILES}
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Building with AddressSanitizer enabled for target: ${PROJECT_NAME}")

11
src/proto/auth/auth.proto Normal file
View File

@@ -0,0 +1,11 @@
syntax = "proto3";
message LoginReq {
string name = 1;
}
message LoginRsp {
bool success = 1;
string uuid = 2;
}

View File

@@ -1,12 +0,0 @@
syntax = "proto3";
message ChunkData {
int32 pos_x = 1;
int32 pos_z = 2;
uint32 chunk_seed = 3;
repeated uint32 chunk_blocks = 4 [packed=true];
repeated uint32 neighbor_blocks_1 = 5 [packed=true];
repeated uint32 neighbor_blocks_2 = 6 [packed=true];
repeated uint32 neighbor_blocks_3 = 7 [packed=true];
repeated uint32 neighbor_blocks_4 = 8 [packed=true];
}

View File

@@ -0,0 +1,6 @@
syntax = "proto3";
message ChunkPos {
int32 x = 1;
int32 y = 2;
}

View File

@@ -0,0 +1,6 @@
syntax = "proto3";
message Error {
int32 code = 1;
string mes = 2;
}

View File

@@ -0,0 +1,5 @@
syntax = "proto3";
message PlayerInfo {
string name = 1;
}

View File

@@ -0,0 +1,7 @@
syntax = "proto3";
message Vec3 {
float x = 1;
float y = 2;
float z = 3;
}

View File

@@ -0,0 +1,8 @@
syntax = "proto3";
import "common/vector3.proto"
message PlayerPos {
string uuid = 1;
Vec3 pos = 2;
}

View File

@@ -1,9 +0,0 @@
syntax = "proto3";
message PlayerPos {
string name = 1;
float x = 2;
float y = 3;
float z = 4;
}

View File

@@ -1,8 +0,0 @@
syntax = "proto3";
message PlayerRequest {
string name = 1;
bool join = 2;
bool exit = 3;
bool chunk_send = 4;
}

View File

@@ -0,0 +1,5 @@
syntax = "proto3";
message Ping {
uint64 timestamp = 1;
}

View File

@@ -0,0 +1,5 @@
syntax = "proto3";
message Pong {
uint64 timestamp = 1;
}

View File

@@ -0,0 +1,13 @@
syntax = "proto3";
import "common/chunk_pos.proto"
message ChunkData {
ChunkPos pos = 1;
uint32 chunk_seed = 2;
repeated uint32 chunk_blocks = 3 [packed=true];
repeated uint32 neighbor_blocks_1 = 4 [packed=true];
repeated uint32 neighbor_blocks_2 = 5 [packed=true];
repeated uint32 neighbor_blocks_3 = 6 [packed=true];
repeated uint32 neighbor_blocks_4 = 7 [packed=true];
}