Skip to content

feat: Block & Chunk API v2 & World region file - #35

Merged
Zffu merged 90 commits into
masterfrom
feat/blocks-and-chunks-v2_34
Nov 15, 2025
Merged

feat: Block & Chunk API v2 & World region file#35
Zffu merged 90 commits into
masterfrom
feat/blocks-and-chunks-v2_34

Conversation

@Zffu

@Zffu Zffu commented Nov 15, 2025

Copy link
Copy Markdown
Member

Apologies in advance if this pr is too big or has a part already in master but Git fucked up for me

These changes bring something very important! World Saving and also Stability! The removal of complex blocks for a new system brings more stability, increased peformance, lower file sizes and ram usage

A region file can currently be at minimum 65 kilobytes for 64 stored chunks inside!

Breaking changes

Critical fixes

  • Fixed an illegal instruction caused by LibAsan inside world_savefile_manager::load_chunk due to a missing return statement (severity: HIGH, would cause crashes no matter what)
  • Fixed a memory leak caused by a missing chunk hashmap append statement in World::load_chunk (severity: HIGH, would cause chunks that could be loaded trough region files to not be registered inside of the world chunks and thus be leaked and not deleted

Fixes

  • Fixed NetworkBuff::can_read returning false if ind + read size == size
  • Fixed NetworkBuff::can_write returning false if ind + write size == size
  • Fixed NetworkBuff::read_byte returning false instead of 0 when cannot read

Behavioral changes

  • Made World::load_chunk and World::unload_chunk use the new chunk region files

API changes

  • Every API changes in feat: Chunk & Block API v2 #34
  • Added world level has_data and get_data functions
  • Add Chunk::remove_data
  • Added region file header struct regionfile_header_t
  • Added cavernfall::world::world_savefile_manager to manage region files
  • Added cavernfall::world::world_savefile to represent a region save file
  • Added region file struct region_file_data_entry to represent block data entries within chunks
  • Added reading, writing and container class region_file_chunk to contain region file chunks

Codebase changes

  • Added cavernfall::fs::file_handle, a safe way to handle c++ files and allows for both writing and reading on the same pointer with automatic state switching
  • Moved every number related operation inside NetworkBuff inside of its own header utils/num.hpp

Test changes

  • Added block data tests
  • Fixed AllocatedAndStaticParity network buffer test not being able to pass no matter what

Zffu added 30 commits November 13, 2025 15:07
bump: savefiles <- master
@Zffu Zffu changed the title feat: Block & Chunk API v2 [draft] feat: Block & Chunk API v2 Nov 15, 2025
@Zffu Zffu changed the title [draft] feat: Block & Chunk API v2 [draft] feat: Block & Chunk API v2 & World region file Nov 15, 2025
@Zffu Zffu changed the title [draft] feat: Block & Chunk API v2 & World region file feat: Block & Chunk API v2 & World region file Nov 15, 2025
@Zffu
Zffu requested a review from tobezdev November 15, 2025 21:39

@tobezdev tobezdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code LGTM.
Gonna request changes on the tests_on_pr.yaml‎ workflow because it is returning early with error code 126.

@tobezdev

Copy link
Copy Markdown
Contributor

Ping me in staff-chat when this runs successfully and I'll approve it :D
lol

@Zffu

Zffu commented Nov 15, 2025

Copy link
Copy Markdown
Member Author

Ping me in staff-chat when this runs successfully and I'll approve it :D lol

Yep, just setting it up at the moment thus why it fails

@Zffu

Zffu commented Nov 15, 2025

Copy link
Copy Markdown
Member Author
image_2025-11-15_232350286

Finally this passes

@Zffu
Zffu requested a review from tobezdev November 15, 2025 22:24

@tobezdev tobezdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's get an F in the chat for lines 65-80 on ‎tests/net/sock.cpp - gg.
Nice work on fixing the workflow tho lol

@Zffu

Zffu commented Nov 15, 2025

Copy link
Copy Markdown
Member Author

Let's get an F in the chat for lines 65-80 on ‎tests/net/sock.cpp - gg. Nice work on fixing the workflow tho lol

That's because the codebase is cursed 😭😭 like either the linux kernel documentation is wrong or that gtest is doing something sneaky with the socket functions

@Zffu
Zffu merged commit 3d898e2 into master Nov 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants