-
Notifications
You must be signed in to change notification settings - Fork 0
Persistent world #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Persistent world #68
Conversation
| "Received block update from client {} {} {:?}", | ||
| client_id, position, block | ||
| ); | ||
| chunk_manager.update_block(position, block); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💀
| "Received block update from client {} {} {:?}", | ||
| client_id, position, block | ||
| ); | ||
| chunk_manager.update_block(position, block); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't spot this one as the clients always receive world updates.
The world serializer doesn't take the diff into consideration but rather the physical chunks from the ChunkManager.
| pub struct TerrainPlugin; | ||
| mod persistence; | ||
|
|
||
| pub enum TerrainStrategy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if I like this name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay. Or TerrainGenerationStrategy, but that's quite long.
|
|
||
| pub enum TerrainStrategy { | ||
| SeededRandom(u32), | ||
| LoadFromSave(Box<WorldSave>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Borrow checker complained about WorldSave being too many bytes for an enum, fair enough..
| event.chunk_position | ||
| ); | ||
| let chunk_option = chunk_manager.get_chunk(event.chunk_position); | ||
| let chunk_option = chunk_manager.get_chunk(&event.chunk_position); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated refactoring.
| serde-big-array = "0.5.1" | ||
| chrono = "0.4.38" | ||
| rayon = "1.10.0" | ||
| clap = { version = "4.5.54", features = ["derive"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLI arg parsing
| let mut file = File::create(path)?; | ||
| let serialized = bincode::serialize(&world_save)?; | ||
| file.write_all(&serialized)?; | ||
| file.flush()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file should be auto flushed once dropped.
somehow was causing UnexpectedEOF without manual flush.
hunchr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling could be better. I'd expect the server to exit here instead of creating a new world:
$ cargo rs -- -w my_world.rsmcw
Loading world save from file 'my_world.rsmcw'
Error: Save File not found 'my_world.rsmcw'
Generating new world with seed [0]
The world persistence is a nice feature!
| pub struct TerrainPlugin; | ||
| mod persistence; | ||
|
|
||
| pub enum TerrainStrategy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay. Or TerrainGenerationStrategy, but that's quite long.
I also noticed this issue. |
Persistent World
When starting the server, the admin may select a world file that should be loaded instead of generating a new world every time. Files are non-human readable but small-ish.
A masterpiece of a structure that shouldn't be forgotten in history
Added clap for CLI args with two commands
generate-worldandload-world:Added periodic world backups:
Added world save files
rsmcw -> rsmc world
Some cool sources:
Things I learned:
ResultErrclapstd::ioMade with ❤️