From 293ed517ea56d0bb46b0fbcc422f251db036e654 Mon Sep 17 00:00:00 2001 From: p2r3 Date: Tue, 19 Aug 2025 17:42:45 +0300 Subject: [PATCH] optimize block changes struct --- src/globals.h | 2 +- src/tools.c | 4 ++-- src/tools.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/globals.h b/src/globals.h index 27405ac..cc5388b 100644 --- a/src/globals.h +++ b/src/globals.h @@ -42,7 +42,7 @@ extern uint32_t rng_seed; typedef struct { short x; - short y; + uint8_t y; short z; uint8_t block; } BlockChange; diff --git a/src/tools.c b/src/tools.c index 4ba1dc1..f0d2b82 100644 --- a/src/tools.c +++ b/src/tools.c @@ -330,7 +330,7 @@ int givePlayerItem (PlayerData *player, uint16_t item, uint8_t count) { } -uint8_t getBlockChange (short x, short y, short z) { +uint8_t getBlockChange (short x, uint8_t y, short z) { for (int i = 0; i < block_changes_count; i ++) { if (block_changes[i].block == 0xFF) continue; if ( @@ -342,7 +342,7 @@ uint8_t getBlockChange (short x, short y, short z) { return 0xFF; } -void makeBlockChange (short x, short y, short z, uint8_t block) { +void makeBlockChange (short x, uint8_t y, short z, uint8_t block) { // Transmit block update to all in-game clients for (int i = 0; i < MAX_PLAYERS; i ++) { diff --git a/src/tools.h b/src/tools.h index 3b3200c..ae6c78e 100644 --- a/src/tools.h +++ b/src/tools.h @@ -42,8 +42,8 @@ int givePlayerItem (PlayerData *player, uint16_t item, uint8_t count); uint8_t serverSlotToClientSlot (int window_id, uint8_t slot); uint8_t clientSlotToServerSlot (int window_id, uint8_t slot); -uint8_t getBlockChange (short x, short y, short z); -void makeBlockChange (short x, short y, short z, uint8_t block); +uint8_t getBlockChange (short x, uint8_t y, short z); +void makeBlockChange (short x, uint8_t y, short z, uint8_t block); uint16_t getMiningResult (int client_fd, uint8_t block);