mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
refactor(proto): restructure protobuf definitions and update build system
This commit is contained in:
@@ -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
11
src/proto/auth/auth.proto
Normal file
@@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message LoginReq {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message LoginRsp {
|
||||
bool success = 1;
|
||||
string uuid = 2;
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
6
src/proto/common/chunk_pos.proto
Normal file
6
src/proto/common/chunk_pos.proto
Normal file
@@ -0,0 +1,6 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message ChunkPos {
|
||||
int32 x = 1;
|
||||
int32 y = 2;
|
||||
}
|
||||
6
src/proto/common/error.proto
Normal file
6
src/proto/common/error.proto
Normal file
@@ -0,0 +1,6 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Error {
|
||||
int32 code = 1;
|
||||
string mes = 2;
|
||||
}
|
||||
5
src/proto/common/player_info.proto
Normal file
5
src/proto/common/player_info.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message PlayerInfo {
|
||||
string name = 1;
|
||||
}
|
||||
7
src/proto/common/vector3.proto
Normal file
7
src/proto/common/vector3.proto
Normal file
@@ -0,0 +1,7 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Vec3 {
|
||||
float x = 1;
|
||||
float y = 2;
|
||||
float z = 3;
|
||||
}
|
||||
8
src/proto/player/player.proto
Normal file
8
src/proto/player/player.proto
Normal file
@@ -0,0 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "common/vector3.proto"
|
||||
|
||||
message PlayerPos {
|
||||
string uuid = 1;
|
||||
Vec3 pos = 2;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message PlayerPos {
|
||||
string name = 1;
|
||||
float x = 2;
|
||||
float y = 3;
|
||||
float z = 4;
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message PlayerRequest {
|
||||
string name = 1;
|
||||
bool join = 2;
|
||||
bool exit = 3;
|
||||
bool chunk_send = 4;
|
||||
}
|
||||
5
src/proto/system/ping.proto
Normal file
5
src/proto/system/ping.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Ping {
|
||||
uint64 timestamp = 1;
|
||||
}
|
||||
5
src/proto/system/pong.proto
Normal file
5
src/proto/system/pong.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Pong {
|
||||
uint64 timestamp = 1;
|
||||
}
|
||||
13
src/proto/world/chunk_data.proto
Normal file
13
src/proto/world/chunk_data.proto
Normal 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];
|
||||
}
|
||||
Reference in New Issue
Block a user