fix crashes related to chunk loading

This commit is contained in:
onezplpl 2024-07-14 12:28:56 -04:00
parent 5c914908d5
commit 2b53defbb7
No known key found for this signature in database
GPG key ID: 7EC026A136F9EEC3
3 changed files with 28 additions and 22 deletions

7
gen.c
View file

@ -86,9 +86,6 @@ Chunk fetch_chunk(int x, int y, int z, int ci) {
fclose(fp);
return chunk;
}
if (fp != 0) {
fclose(fp);
}
if (!fp) {
fp = fopen(fname, "wb");
}
@ -124,6 +121,10 @@ Chunk fetch_chunk(int x, int y, int z, int ci) {
chunks2[i] = chunk;
if (!fp) {
return chunk;
}
fwrite(&chunk, sizeof(Chunk), 1, fp);
fclose(fp);