From 8bdecb71fc39c7895089a668eef67b9c7c40f7dc Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 7 Dec 2017 20:24:09 +1100 Subject: [PATCH] fix block ID 255 not showing in inventory --- ClassicalSharp/2D/Widgets/TableWidget.cs | 2 +- ClassicalSharp/Game/Inventory.cs | 14 +++++++------- src/Client/Inventory.c | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ClassicalSharp/2D/Widgets/TableWidget.cs b/ClassicalSharp/2D/Widgets/TableWidget.cs index 2f4ee4d6c..d7f7ff949 100644 --- a/ClassicalSharp/2D/Widgets/TableWidget.cs +++ b/ClassicalSharp/2D/Widgets/TableWidget.cs @@ -232,7 +232,7 @@ namespace ClassicalSharp.Gui.Widgets { } bool Show(BlockID block) { - if (block == Block.Invalid) return false; + if (block == Block.Air) return false; if (block < Block.CpeCount) { int count = game.UseCPEBlocks ? Block.CpeCount : Block.OriginalCount; diff --git a/ClassicalSharp/Game/Inventory.cs b/ClassicalSharp/Game/Inventory.cs index 81c71e36f..6ff83d1cc 100644 --- a/ClassicalSharp/Game/Inventory.cs +++ b/ClassicalSharp/Game/Inventory.cs @@ -100,16 +100,16 @@ namespace ClassicalSharp { for (int i = 0; i < Map.Length; i++) Map[i] = (BlockID)i; for (int i = 0; i < Map.Length; i++) { BlockID mapping = DefaultMapping(i); - if (game.PureClassic && IsHackBlock(mapping)) mapping = Block.Invalid; + if (game.PureClassic && IsHackBlock(mapping)) mapping = Block.Air; if (mapping != i) Map[i] = mapping; } } BlockID DefaultMapping(int i) { #if USE16_BIT - if ((i >= Block.CpeCount && i < 256) || i == Block.Air) return Block.Invalid; + if ((i >= Block.CpeCount && i < 256) || i == Block.Air) return Block.Air; #else - if (i >= Block.CpeCount || i == Block.Air) return Block.Invalid; + if (i >= Block.CpeCount || i == Block.Air) return Block.Air; #endif if (!game.ClassicMode) return (BlockID)i; @@ -178,14 +178,14 @@ namespace ClassicalSharp { public void Remove(BlockID block) { for (int i = 0; i < Map.Length; i++) { - if (Map[i] == block) Map[i] = Block.Invalid; + if (Map[i] == block) Map[i] = Block.Air; } } public void Insert(int i, BlockID block) { if (Map[i] == block) return; // Need to push the old block to a different slot if different block - if (Map[i] != Block.Invalid) PushToFreeSlots(i); + if (Map[i] != Block.Air) PushToFreeSlots(i); Map[i] = block; } @@ -199,10 +199,10 @@ namespace ClassicalSharp { } for (int j = block; j < Map.Length; j++) { - if (Map[j] == Block.Invalid) { Map[j] = block; return; } + if (Map[j] == Block.Air) { Map[j] = block; return; } } for (int j = 1; j < block; j++) { - if (Map[j] == Block.Invalid) { Map[j] = block; return; } + if (Map[j] == Block.Air) { Map[j] = block; return; } } } } diff --git a/src/Client/Inventory.c b/src/Client/Inventory.c index b9d70bf37..5cb36b189 100644 --- a/src/Client/Inventory.c +++ b/src/Client/Inventory.c @@ -47,9 +47,9 @@ bool Inventory_IsHackBlock(BlockID b) { BlockID Inventory_DefaultMapping(Int32 i) { #if USE16_BIT - if ((i >= Block_CpeCount && i < 256) || i == BLOCK_AIR) return BLOCK_INVALID; + if ((i >= Block_CpeCount && i < 256) || i == BLOCK_AIR) return BLOCK_AIR; #else - if (i >= BLOCK_CPE_COUNT || i == BLOCK_AIR) return BLOCK_INVALID; + if (i >= BLOCK_CPE_COUNT || i == BLOCK_AIR) return BLOCK_AIR; #endif if (!Game_ClassicMode) return (BlockID)i; @@ -101,7 +101,7 @@ void Inventory_SetDefaultMapping(void) { for (i = 0; i < Array_NumElements(Inventory_Map); i++) { BlockID mapping = Inventory_DefaultMapping(i); if (Game_PureClassic && Inventory_IsHackBlock(mapping)) { - mapping = BLOCK_INVALID; + mapping = BLOCK_AIR; } if (mapping != i) Inventory_Map[i] = mapping; } @@ -133,7 +133,7 @@ void Inventory_Remove(BlockID block) { Int32 i; for (i = 0; i < Array_NumElements(Inventory_Map); i++) { if (Inventory_Map[i] != block) continue; - Inventory_Map[i] = BLOCK_INVALID; + Inventory_Map[i] = BLOCK_AIR; } } @@ -147,12 +147,12 @@ void Inventory_PushToFreeSlots(Int32 i) { } for (j = block; j < Array_NumElements(Inventory_Map); j++) { - if (Inventory_Map[j] == BLOCK_INVALID) { + if (Inventory_Map[j] == BLOCK_AIR) { Inventory_Map[j] = block; return; } } for (j = 1; j < block; j++) { - if (Inventory_Map[j] == BLOCK_INVALID) { + if (Inventory_Map[j] == BLOCK_AIR) { Inventory_Map[j] = block; return; } } @@ -161,7 +161,7 @@ void Inventory_PushToFreeSlots(Int32 i) { void Inventory_Insert(Int32 i, BlockID block) { if (Inventory_Map[i] == block) return; /* Need to push the old block to a different slot if different block. */ - if (Inventory_Map[i] != BLOCK_INVALID) Inventory_PushToFreeSlots(i); + if (Inventory_Map[i] != BLOCK_AIR) Inventory_PushToFreeSlots(i); Inventory_Map[i] = block; }