-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allocate region file structures dynamically (#348)
Previously, there would always be memory reserved for 16 region files. This is simultaneously a large amount of space to reserve by default, and also a relatively low limit in case of multiple players and/or a large world. Now, the memory is allocated as needed, with a capacity of 1024 pointers to `BASED` items.
- Loading branch information
Showing
4 changed files
with
154 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
*> --- Copybook: reference to a loaded region file --- | ||
*> This is a BASED item, i.e., a view into a data structure referenced by a pointer. DD-REGION-FILES.cpy contains a | ||
*> table of pointers to these structures. | ||
|
||
*> The region file cache. | ||
01 REGION-FILE BASED. | ||
*> When the region file was last accessed. | ||
02 REGION-FILE-ACCESS-TIME BINARY-LONG-LONG. | ||
*> Region coordinates. | ||
02 REGION-FILE-X BINARY-LONG. | ||
02 REGION-FILE-Z BINARY-LONG. | ||
*> The file name. | ||
02 REGION-FILE-NAME PIC X(1024). | ||
*> The open file handle (input/output). | ||
02 REGION-FILE-HANDLE PIC X(4) USAGE COMP-X. | ||
*> Chunk locations within the file, consisting of the offset (3 big-endian bytes) and length (1 byte). | ||
*> Offset and length are measured in 4 kiB sectors. | ||
02 REGION-FILE-OFFSET-BYTES PIC X(REGION-SECTOR-BYTES). | ||
02 REGION-FILE-OFFSETS REDEFINES REGION-FILE-OFFSET-BYTES. | ||
03 REGION-FILE-OFFSET OCCURS REGION-SECTOR-INTS TIMES PIC X(4). | ||
*> TODO: Last-modified timestamps for each chunk | ||
*> Boolean array; one entry per file sector, indicating whether the sector is used. | ||
*> TODO: Make this use less memory (bitset?) | ||
02 REGION-FILE-USED OCCURS REGION-SECTOR-COUNT TIMES BINARY-CHAR UNSIGNED. |
Oops, something went wrong.