Skip to content
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

Code refactoring, bug fixes #37

Merged
merged 20 commits into from
Jan 29, 2025
Merged

Conversation

CuddlyBunion341
Copy link
Owner

@CuddlyBunion341 CuddlyBunion341 commented Jan 28, 2025

Refactoring of Terrain related Code (and some other stuff)

CleanShot 2025-01-28 at 23 43 56@2x

Implementing the improved terrain showed some serious flaws with the organization of code shared between the client and server binaries and also revealed some serious bugs.

Started off from #33

Note

I know this is not a clean refactoring as there are some functionality changes made. I don't care this is my project, I will do whatever I want. Especially if it enables me to go faster.

Problem assessment

  • Chunk and Chunk mangagement code was heavily duplicated between client and server.
  • Chunk Serialization was only implemented on the client side causing server crashes when larger world chunk batches were requested.
  • lib.rs was unmaintainable as it exploded in size with all sorts of code ranging from Networking Message declarations to serialization and Resource definitions.
  • Networking related configuration for client / server was duplicated.

Key Changes

  • Increased world size
  • Code such as ChunkManager, Chunk, BlockId and such have been moved to this new namespace (shared).
  • Chunk Serialization has been fixed.
  • A shared module has been created which is imported as lib via rsmc.
  • All exports from the shared namespace are automatically available in both binaries via use wildcard in prelude.
  • The lib:: prefix has been dropped as it is unnecessary.
  • Removed the i32 parameterized chunk initialization method. (Maybe this should be reverted?) 6e64d22

Notes

...

@CuddlyBunion341 CuddlyBunion341 self-assigned this Jan 28, 2025
Cargo.toml Outdated Show resolved Hide resolved
Vec3 {
x: 0.0,
y: 0.0,
z: 0.0,
},
1,
Vec3::new(1.0, 1.0, 1.0),
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I like the method "overload" with the integer param for the render distance more than this vector definition..

@CuddlyBunion341 CuddlyBunion341 marked this pull request as ready for review January 28, 2025 22:18
@CuddlyBunion341 CuddlyBunion341 changed the title Terrain refactoring Code refactoring, bug fixes Jan 28, 2025
@CuddlyBunion341 CuddlyBunion341 enabled auto-merge (squash) January 29, 2025 22:38
@CuddlyBunion341 CuddlyBunion341 merged commit 62fedcb into main Jan 29, 2025
3 checks passed
@CuddlyBunion341 CuddlyBunion341 deleted the feature/terrain-refactoring branch January 29, 2025 22:39
@CuddlyBunion341 CuddlyBunion341 restored the feature/terrain-refactoring branch January 29, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant