Prefer BLOCK_MAX_X over BLOCK_X_COUNT

This commit is contained in:
UnknownShadow200 2022-02-14 23:37:56 +11:00
parent 074eb418e9
commit 4f80b48fcc
6 changed files with 7 additions and 9 deletions

View File

@ -205,7 +205,7 @@ static const cc_string Block_DefaultName(BlockID block) {
static const cc_string invalid = String_FromConst("Invalid");
int i, beg = 0, end;
if (block >= BLOCK_CPE_COUNT) return invalid;
if (block > BLOCK_MAX_CPE) return invalid;
/* Find start and end of this particular block name. */
for (i = 0; i < block; i++) {
beg = String_IndexOfAt(&names, beg, '_') + 1;
@ -217,7 +217,7 @@ static const cc_string Block_DefaultName(BlockID block) {
}
void Block_ResetProps(BlockID block) {
const struct SimpleBlockDef* def = block < BLOCK_CPE_COUNT ? &core_blockDefs[block] : &invalid_blockDef;
const struct SimpleBlockDef* def = block <= BLOCK_MAX_CPE ? &core_blockDefs[block] : &invalid_blockDef;
const cc_string name = Block_DefaultName(block);
Blocks.BlocksLight[block] = def->blocksLight;

View File

@ -78,8 +78,6 @@ enum BLOCKID {
/* Max block ID used in original classic */
BLOCK_MAX_ORIGINAL = BLOCK_OBSIDIAN,
/* Number of blocks in original classic. */
BLOCK_ORIGINAL_COUNT = (BLOCK_MAX_ORIGINAL + 1),
/* Max block ID used in original classic plus CPE blocks. */
BLOCK_MAX_CPE = BLOCK_STONE_BRICK,
/* Number of blocks in original classic plus CPE blocks. */

View File

@ -579,7 +579,7 @@ static cc_bool CuboidCommand_ParseArgs(const cc_string* args) {
Chat_Add1("&eCuboid: &c\"%s\" is not a valid block name or id.", &value); return false;
}
if (block >= BLOCK_CPE_COUNT && !Block_IsCustomDefined(block)) {
if (block > BLOCK_MAX_CPE && !Block_IsCustomDefined(block)) {
Chat_Add1("&eCuboid: &cThere is no block with id \"%s\".", &value); return false;
}

View File

@ -111,7 +111,7 @@ void Inventory_ResetMapping(void) {
void Inventory_AddDefault(BlockID block) {
int slot;
if (block >= BLOCK_CPE_COUNT) {
if (block > BLOCK_MAX_CPE) {
Inventory.Map[block - 1] = block; return;
}

View File

@ -1713,7 +1713,7 @@ static void BlockDefs_UndefineBlock(cc_uint8* data) {
Block_UpdateCulling(block);
Inventory_Remove(block);
if (block < BLOCK_CPE_COUNT) { Inventory_AddDefault(block); }
if (block <= BLOCK_MAX_CPE) { Inventory_AddDefault(block); }
Block_SetCustomDefined(block, false);
Event_RaiseVoid(&BlockEvents.BlockDefChanged);

View File

@ -719,7 +719,7 @@ static cc_bool TableWidget_RowEmpty(struct TableWidget* w, int start) {
}
void TableWidget_RecreateBlocks(struct TableWidget* w) {
int i, max = Game_UseCPEBlocks ? BLOCK_COUNT : BLOCK_ORIGINAL_COUNT;
int i, max = Game_UseCPEBlocks ? BLOCK_MAX_DEFINED : BLOCK_MAX_ORIGINAL;
BlockID block;
w->blocksCount = 0;
@ -729,7 +729,7 @@ void TableWidget_RecreateBlocks(struct TableWidget* w) {
}
block = Inventory.Map[i];
if (block < max) { w->blocks[w->blocksCount++] = block; }
if (block <= max) { w->blocks[w->blocksCount++] = block; }
i++;
}