1
0
mirror of https://github.com/p2r3/bareiron.git synced 2025-10-01 23:25:09 +02:00

time chunk generation more accurately

This commit is contained in:
p2r3
2025-08-28 13:41:35 +03:00
parent 417729a7d0
commit 22d8bfc377

View File

@@ -294,15 +294,6 @@ void handlePacket (int client_fd, int length, int packet_id, int state) {
player->visited_x[VISITED_HISTORY - 1] = _x; player->visited_x[VISITED_HISTORY - 1] = _x;
player->visited_z[VISITED_HISTORY - 1] = _z; player->visited_z[VISITED_HISTORY - 1] = _z;
sc_setCenterChunk(client_fd, _x, _z);
int count = 0;
#ifdef DEV_LOG_CHUNK_GENERATION
printf("Sending new chunks (%d, %d)\n", _x, _z);
clock_t start, end;
start = clock();
#endif
uint32_t r = fast_rand(); uint32_t r = fast_rand();
// One in every 4 new chunks spawns a mob // One in every 4 new chunks spawns a mob
if ((r & 3) == 0) { if ((r & 3) == 0) {
@@ -342,6 +333,15 @@ void handlePacket (int client_fd, int length, int packet_id, int state) {
} }
} }
int count = 0;
#ifdef DEV_LOG_CHUNK_GENERATION
printf("Sending new chunks (%d, %d)\n", _x, _z);
clock_t start, end;
start = clock();
#endif
sc_setCenterChunk(client_fd, _x, _z);
while (dx != 0) { while (dx != 0) {
sc_chunkDataAndUpdateLight(client_fd, _x + dx * VIEW_DISTANCE, _z); sc_chunkDataAndUpdateLight(client_fd, _x + dx * VIEW_DISTANCE, _z);
count ++; count ++;