Commit Graph

33 Commits

Author SHA1 Message Date
647f980c66 feat(server-world): use priority thread pool for chunk generation
Introduce PriorityThreadPool to process chunk generation tasks with priorities based on their distance from the player. Closer chunks receive higher priority, improving responsiveness.
2026-07-01 15:13:33 +08:00
ad1d3b3ac9 feat(networking): add priority and sequence ordering to packet send queues 2026-07-01 14:53:23 +08:00
810ce672da refactor(gameplay): pass new_chunks vector as parameter instead of member variable 2026-07-01 10:06:33 +08:00
f8e2ff5ce3 fix(server_world): floor block position coordinates in handle_block_change 2026-07-01 10:00:18 +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
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
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
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
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
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
e3f973284c refactor(server_world): use thread pool for chunk request handling 2026-06-26 22:56:32 +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
e5e84848a9 feat(gameplay): add player logout and disconnect handling 2026-06-26 17:05:09 +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
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
4a1ef54258 feat(gameplay): integrate network client and thread-safe player pos 2026-06-25 16:49:45 +08:00
df2e26e731 feat(client-chunk): add greedy meshing, receive_chunk, and biome field 2026-06-25 14:31:11 +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
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
27e3cd6851 refactor(gameplay): split Chunk into server/client variants and add networking 2026-06-23 14:49:16 +08:00