Commit Graph

163 Commits

Author SHA1 Message Date
cb3f78b1f3 perf(client): improve chunk rendering performance with snapshots and threaded generation 2026-07-01 12:30:02 +08:00
810ce672da refactor(gameplay): pass new_chunks vector as parameter instead of member variable 2026-07-01 10:06:33 +08:00
1af41db615 refactor(dev_panel): remove seed editing and server rebuild world, move client rebuild
- Remove text editing for perlin seed and filter function
- Remove ServerWorld::rebuild_world() method and its atomic flag
- Move 'Rebuild World' button to client world tab
- Remove unused perlin_noise_input_buffer
2026-06-30 18:36:22 +08:00
1e17474122 refactor(math_tools): convert free functions to inline in header 2026-06-30 17:44:31 +08:00
b24ce458dc perf(world): cull distant players from updates and rendering
Add distance2 utility function. On client, skip rendering other players if distance squared exceeds rendering distance. On server, only send player position and block change updates to players in relevant chunks.
2026-06-30 17:41:12 +08:00
85db85a737 refactor(client_world): use concurrent data structures for chunk management
Replace std::shared_mutex and std::unordered_set with tbb::concurrent_hash_map for chunk storage, tbb::concurrent_queue for pending uploads, and absl::flat_hash_set for player chunk positions. This improves thread safety and reduces locking overhead. Refactor receive_chunk and request_chunk to work with the new concurrent model.
2026-06-29 14:14:36 +08:00
8faf4c9a81 refactor(server_world): replace future-based chunk generation with queue
Remove `std::future` per-chunk tracking and poll_finished_chunks().
Instead, generation tasks push completed chunks to a concurrent queue
consumed during update. This eliminates wait_all_chunk_tasks() and
simplifies synchronization.
2026-06-29 11:58:10 +08:00
50a6a8c0ef refactor(gameplay): migrate chunk storage to tbb::concurrent_hash_map 2026-06-28 22:11:17 +08:00
9788f68b12 refactor(server): replace chunk set with flat_hash_set and add ref count
- Replace std::unordered_set with absl::flat_hash_set for chunk position sets.
- Add ref_count field to ChunkEntity and implement update_ref_count().
- Remove clear_unused_chunks() and use ref counting for chunk lifetime.
- Add get_chunk_pos_set() accessors to ServerPlayer.
2026-06-28 20:11:14 +08:00
cbe3548dcd refactor(gameplay): remove old pre_remove chunk, player, and world files 2026-06-28 19:29:52 +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
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
6b79a75b70 fix: build fail on windows 2026-06-27 17:48:57 +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
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
18090bfd95 refactor(gameplay): rename remote player types and add interpolation 2026-06-26 22:15:31 +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
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
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
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
2953e8a233 feat(protocol): add packet serialization and login handling
Introduce packet header and ID mapping for protobuf messages.
Refactor session and server_world to use new packet wrapper.
Fix missing semicolons in proto files.
2026-06-23 21:58:35 +08:00
4303c1cd32 feat(network): integrate protobuf for player sync and session management
Add Protobuf dependency, define proto messages for player requests, positions, and chunk data. Refactor Session to use strand and async write. Implement player join/exit and position sync in ServerWorld.
2026-06-23 20:08:40 +08:00
1acfeef9e6 feat(gameplay): add Session class and UUID generation utility 2026-06-23 15:54:01 +08:00