forked from EXTERNAL/bareiron
fix network overhead in worldgen
This commit is contained in:
@@ -308,15 +308,8 @@ int sc_chunkDataAndUpdateLight (int client_fd, int _x, int _z) {
|
|||||||
writeByte(client_fd, 8); // bits per entry
|
writeByte(client_fd, 8); // bits per entry
|
||||||
writeVarInt(client_fd, 256);
|
writeVarInt(client_fd, 256);
|
||||||
for (int j = 0; j < 256; j ++) writeVarInt(client_fd, block_palette[j]);
|
for (int j = 0; j < 256; j ++) writeVarInt(client_fd, block_palette[j]);
|
||||||
for (int j = 0; j < 4096; j += 8) {
|
buildChunkSection(x, y, z);
|
||||||
for (int k = j + 7; k >= j; k --) {
|
send(client_fd, chunk_section, 4096, 0);
|
||||||
writeByte(client_fd, getBlockAt(
|
|
||||||
k % 16 + x,
|
|
||||||
k / 256 + y,
|
|
||||||
k / 16 % 16 + z
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// biome data
|
// biome data
|
||||||
writeByte(client_fd, 0); // bits per entry
|
writeByte(client_fd, 0); // bits per entry
|
||||||
writeByte(client_fd, W_plains); // palette
|
writeByte(client_fd, W_plains); // palette
|
||||||
|
@@ -141,3 +141,22 @@ skip_tree:
|
|||||||
return B_air;
|
return B_air;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t chunk_section[4096];
|
||||||
|
|
||||||
|
void buildChunkSection (int cx, int cy, int cz) {
|
||||||
|
|
||||||
|
for (int j = 0; j < 4096; j += 8) {
|
||||||
|
|
||||||
|
int y = j / 256 + cy;
|
||||||
|
int z = j / 16 % 16 + cz;
|
||||||
|
|
||||||
|
for (int offset = 7; offset >= 0; offset--) {
|
||||||
|
int k = j + offset;
|
||||||
|
int x = k % 16 + cx;
|
||||||
|
chunk_section[j + 7 - offset] = getBlockAt(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -9,4 +9,7 @@ uint32_t getChunkHash (short x, short z);
|
|||||||
int getHeightAt (int rx, int rz, int _x, int _z, uint32_t chunk_hash);
|
int getHeightAt (int rx, int rz, int _x, int _z, uint32_t chunk_hash);
|
||||||
uint8_t getBlockAt (int x, int y, int z);
|
uint8_t getBlockAt (int x, int y, int z);
|
||||||
|
|
||||||
|
extern uint8_t chunk_section[4096];
|
||||||
|
void buildChunkSection (int x, int y, int z);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user