diff --git a/include/globals.h b/include/globals.h index 2417cd9..71a89c9 100644 --- a/include/globals.h +++ b/include/globals.h @@ -281,7 +281,6 @@ extern int block_changes_count; extern DeferredBlockUpdate deferred_block_updates[MAX_DEFERRED_BLOCK_UPDATES]; extern int deferred_block_updates_count; extern uint8_t is_processing_deferred_block_updates; -extern uint8_t had_too_many_deferred_block_updates; extern PlayerData player_data[MAX_PLAYERS]; extern int player_data_count; diff --git a/src/globals.c b/src/globals.c index 979a0d9..1b66086 100644 --- a/src/globals.c +++ b/src/globals.c @@ -53,7 +53,6 @@ int block_changes_count = 0; DeferredBlockUpdate deferred_block_updates[MAX_DEFERRED_BLOCK_UPDATES]; int deferred_block_updates_count = 0; uint8_t is_processing_deferred_block_updates = 0; -uint8_t had_too_many_deferred_block_updates = false; PlayerData player_data[MAX_PLAYERS]; int player_data_count = 0; diff --git a/src/main.c b/src/main.c index 32e4bcf..75d8d82 100644 --- a/src/main.c +++ b/src/main.c @@ -595,9 +595,8 @@ int main () { // Check if it's time to yield to the idle task task_yield(); - if (had_too_many_deferred_block_updates) { - printf("WARNING: Too many deferred block updates\n"); - had_too_many_deferred_block_updates = 0; + if (deferred_block_updates_count == MAX_DEFERRED_BLOCK_UPDATES) { + printf("WARNING: Deferred block update queue maxed out\n"); } // Attempt to accept a new connection diff --git a/src/procedures.c b/src/procedures.c index 61d6fae..abc7f58 100644 --- a/src/procedures.c +++ b/src/procedures.c @@ -1180,7 +1180,6 @@ void processBlockUpdate (short x, uint8_t y, short z, uint8_t block) { void deferBlockUpdate (short x, uint8_t y, short z, uint8_t awaitTicks) { if (deferred_block_updates_count == MAX_DEFERRED_BLOCK_UPDATES) { - had_too_many_deferred_block_updates = true; return; } @@ -1241,12 +1240,11 @@ void handlePlayerAction (PlayerData *player, int action, short x, short y, short } // Update nearby blocks - uint8_t block_above = getBlockAt(x, y + 1, z); - processBlockUpdate(x, y + 1, z, block_above); - processBlockUpdate(x - 1, y, z, getBlockAt(x - 1, y, z)); - processBlockUpdate(x + 1, y, z, getBlockAt(x + 1, y, z)); - processBlockUpdate(x, y, z - 1, getBlockAt(x, y, z - 1)); - processBlockUpdate(x, y, z + 1, getBlockAt(x, y, z + 1)); + deferBlockUpdate(x, y + 1, z, 0); + deferBlockUpdate(x - 1, y, z, 0); + deferBlockUpdate(x + 1, y, z, 0); + deferBlockUpdate(x, y, z - 1, 0); + deferBlockUpdate(x, y, z + 1, 0); } void handlePlayerUseItem (PlayerData *player, short x, short y, short z, uint8_t face) { @@ -1382,8 +1380,7 @@ void handlePlayerUseItem (PlayerData *player, short x, short y, short z, uint8_t (y == player->y || y == player->y + 1) && z == player->z ) && - isReplaceableBlock(getBlockAt(x, y, z)) && - (!isColumnBlock(block) || getBlockAt(x, y - 1, z) != B_air) + isReplaceableBlock(getBlockAt(x, y, z)) ) { // Apply server-side block change if (makeBlockChange(x, y, z, block)) return; @@ -1393,11 +1390,11 @@ void handlePlayerUseItem (PlayerData *player, short x, short y, short z, uint8_t if (*count == 0) *item = 0; // Send updates processBlockUpdate(x, y, z, block); - processBlockUpdate(x, y + 1, z, getBlockAt(x, y + 1, z)); - processBlockUpdate(x - 1, y, z, getBlockAt(x - 1, y, z)); - processBlockUpdate(x + 1, y, z, getBlockAt(x + 1, y, z)); - processBlockUpdate(x, y, z - 1, getBlockAt(x, y, z - 1)); - processBlockUpdate(x, y, z + 1, getBlockAt(x, y, z + 1)); + deferBlockUpdate(x, y + 1, z, 0); + deferBlockUpdate(x - 1, y, z, 0); + deferBlockUpdate(x + 1, y, z, 0); + deferBlockUpdate(x, y, z - 1, 0); + deferBlockUpdate(x, y, z + 1, 0); } // Sync hotbar contents to player