Commit Graph

221 Commits

Author SHA1 Message Date
4073664624 fix: address unused parameter warnings and missing port assignment 2026-06-28 19:28:23 +08:00
a016e08a2a fix(app): correct port validation and remove redundant TOML helper 2026-06-28 15:47:08 +08:00
a5764e901b feat(gameplay): implement server stop and client exit handling
Add server_stop flag to LogoutRsp protocol. Modify client_world to check for server stop or own logout to set exit flag. Add ServerWorld::stop() to broadcast stop and cleanly shut down. Refactor chunk ownership to unique_ptr. Remove name parameter from get_look_block_pos.
2026-06-28 15:27:51 +08:00
429520b1f7 feat(client_world): implement server exit acknowledgment with timeout 2026-06-28 15:04:21 +08:00
d2636189a4 refactor(server_world): separate gen and net thread pools
Introduce a second thread pool for network operations and a `ThreadPoolKind` enum to distinguish between gen and net pools. Rename `pool_threads()` to `gen_pool_threads()`, add `change_pool_threads()` overload that accepts the pool kind, and update the dev panel to use the gen pool. Adjust logging and initialization to handle both pools.
2026-06-28 14:46:42 +08:00
3d4c41a76e fix(server): ensure chunk is ready before sending or setting block 2026-06-28 14:30:36 +08:00
28b66ee275 refactor(world): rework chunk state machine and player chunk tracking
Introduce ChunkState enum and ChunkEntity struct to manage chunk lifecycle. Store chunks as shared_ptr to avoid move operations during generation. Add clear_unused_chunks to remove chunks not referenced by any player. Implement deferred chunk request queue for safe processing after generation completes. Update player chunk set during required chunk computation. Improve thread safety with mutexes on chunk and player maps. Fix m_gening flag not reset after generation and add assertions for correctness. Change need_gen to require a player UUID, removing std::optional. Add chunk_size query method for debugging.
2026-06-28 14:27:30 +08:00
e1e9efb86c refactor(renderer): rename Logger level enum value DEBUG to L_DEBUG 2026-06-27 18:33:49 +08:00
6b79a75b70 fix: build fail on windows 2026-06-27 17:48:57 +08:00
426202ba9e build(cmake): modularize build configuration 2026-06-27 16:04:48 +08:00
20402d1fda feat: add player name configuration and rename config file
- Add --player command-line argument and 'player' field in Arguments struct
- Rename ip.toml to server.toml and corresponding internal variable to 'server'
- Fix block.cpp source path in CMakeLists.txt
2026-06-27 15:13:25 +08:00
3d4490a46b feat(toml): add shared TOML utilities and handle ip.toml 2026-06-27 15:06:47 +08:00
d93748e7fb refactor(block): move block source to gameplay directory 2026-06-27 14:50:30 +08:00
1d4aa48230 feat(gameplay): add task ID to chunk requests to discard stale responses 2026-06-27 14:05:49 +08:00
65429b22d6 feat(tools): add RecentQueue to replace std::deque in server_world 2026-06-27 13:47:06 +08:00
43395d4794 feat(dev_panel): split world tab; add chunk request logging and fix flag reset 2026-06-27 12:07:39 +08:00
7b6c11e904 feat(gameplay): add packet to clear all chunks on server rebuild
Add new packet S2C_ClearAllChunks (ID 3005) to notify clients when the server rebuilds its world. Clients respond by clearing their chunk cache and requesting fresh chunks. Shift UPDATE_TIME packet ID to 3006 to accommodate.
2026-06-27 11:20:51 +08:00
aace0b4888 refactor(packet): replace if-constexpr chain with explicit template specializations
Refactor `get_packet_id()` by removing the if-constexpr chain and instead
providing explicit specializations for each packet type. This simplifies the
primary template (which now only contains a static assertion) and improves
compile-time dispatch clarity. The `always_false` helper is no longer needed
in the primary template.
2026-06-27 10:51:57 +08:00
e3f973284c refactor(server_world): use thread pool for chunk request handling 2026-06-26 22:56:32 +08:00
18090bfd95 refactor(gameplay): rename remote player types and add interpolation 2026-06-26 22:15:31 +08:00
09fc46d306 refactor(gameplay): use steady clock and sleep_until for tick loop timing 2026-06-26 22:00:36 +08:00
932ef9ace4 perf(gameplay): optimize protobuf message allocation with Arena and limit thread pool size
Switch to Arena allocation for protobuf messages to reduce heap allocations. Pass ChunkDataRsp by value to enable move semantics. Cap thread pool size to hardware concurrency with max 4 threads.
2026-06-26 21:52:57 +08:00
d31ec68f3c feat(packet): implement zstd compression and refactor packet decoding 2026-06-26 20:20:34 +08:00
c7c6ee9a61 refactor(network): extract packet header decoding into function 2026-06-26 19:20:14 +08:00
db7b67f265 refactor(packet): replace zlib with zstd compression and restructure header
Increase header length to 12 bytes, add CompressType and PacketHeader struct, and implement decode_packet_header. Update CMake to find zstd and link against it, adding Findzstd module.
2026-06-26 19:12:39 +08:00
7e42f595c9 build: add ZLIB dependency 2026-06-26 17:23:35 +08:00
11c902d2bf fix(dev_panel): add protobuf to about table libraries 2026-06-26 17:18:05 +08:00
e5e84848a9 feat(gameplay): add player logout and disconnect handling 2026-06-26 17:05:09 +08:00
25e9b0e0d3 feat(gameplay): add thread pool for asynchronous chunk data processing 2026-06-26 16:14:20 +08:00
48300b5fe2 feat(multiplayer): add rendering of other players as colored cubes 2026-06-26 15:52:22 +08:00
3c14a4ffe1 feat(app): add client/server CLI arguments and init guards 2026-06-26 13:48:07 +08:00
fbb6fe2fa6 feat(client): add center-based chunk loading priority 2026-06-26 11:32:52 +08:00
a858774b71 refactor(client_world): split pending queue into data and upload queues 2026-06-26 11:20:47 +08:00
4631bbe6d6 feat(gameplay): optimize chunk request with player chunk tracking
Add `update_player_chunk()` method to `ClientPlayer` that triggers a chunk request when the player moves more than 2 chunks away from the last recorded chunk. Introduce an atomic `m_requesting_chunk` flag in `ClientWorld` to prevent concurrent requests. Rename `m_player_chunk_pos` to `m_last_chunk_pos` for clarity.
2026-06-25 21:57:55 +08:00
db10d30dc2 fix: correct neighbor block indexing and add time update support 2026-06-25 21:37:19 +08:00
47552a1887 feat(gameplay): add time sync and network improvements 2026-06-25 20:13:51 +08:00
d7d47e9e7f refactor(gameplay): split world into client and server
Remove monolithic World, Player, Chunk classes. Introduce ClientWorld, ServerWorld, ClientPlayer, and related networked components. Add Abseil dependency for logging and checks. Rename old files to pre_remove_* and update all includes and references accordingly.
2026-06-25 17:54:32 +08:00
2c6dccfb53 refactor(server): replace Chunk with ServerChunk 2026-06-25 17:13:50 +08:00
b782b40133 feat(gameplay): add block change sync and coordinate utils 2026-06-25 17:09:41 +08:00
4a1ef54258 feat(gameplay): integrate network client and thread-safe player pos 2026-06-25 16:49:45 +08:00
cbc04f6ab0 feat(client_player): add name constructor param, remove chunk transition 2026-06-25 14:38:57 +08:00
df2e26e731 feat(client-chunk): add greedy meshing, receive_chunk, and biome field 2026-06-25 14:31:11 +08:00
c92e2249a4 feat(client): add client-side chunk, player, world and network classes 2026-06-24 21:49:30 +08:00
4e6f29bedd fix(gameplay): correct unknown error log condition and missing chunk pos update 2026-06-24 18:50:02 +08:00
0223fefa6b fix(network-server): stop accept loop on shutdown flag 2026-06-24 18:03:40 +08:00
8d86a71c3f fix(session): catch std::exception in read_loop and log error 2026-06-24 17:59:32 +08:00
af8812916d refactor(server): enhance thread safety and session management 2026-06-24 17:56:11 +08:00
85341651b3 feat(server): add block change packet handling and increase reserved threads 2026-06-24 17:02:21 +08:00
9d33b240c6 feat(world): add player-based chunk loading and UUID support
Restructure world generation to trigger chunk loading based on player
movement. Replace player name with UUID for identification. Implement
chunk request/response protocol. Improve thread management for gen
thread.
2026-06-24 14:51:48 +08:00
6f39ff771d refactor(packet): serialize directly into packet buffer with ByteSizeLong 2026-06-23 22:00:19 +08:00