mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 20:15:35 -04:00
Prefer BLOCK_MAX_X over BLOCK_X_COUNT
This commit is contained in:
parent
074eb418e9
commit
4f80b48fcc
@ -205,7 +205,7 @@ static const cc_string Block_DefaultName(BlockID block) {
|
|||||||
static const cc_string invalid = String_FromConst("Invalid");
|
static const cc_string invalid = String_FromConst("Invalid");
|
||||||
int i, beg = 0, end;
|
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. */
|
/* Find start and end of this particular block name. */
|
||||||
for (i = 0; i < block; i++) {
|
for (i = 0; i < block; i++) {
|
||||||
beg = String_IndexOfAt(&names, beg, '_') + 1;
|
beg = String_IndexOfAt(&names, beg, '_') + 1;
|
||||||
@ -217,7 +217,7 @@ static const cc_string Block_DefaultName(BlockID block) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Block_ResetProps(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);
|
const cc_string name = Block_DefaultName(block);
|
||||||
|
|
||||||
Blocks.BlocksLight[block] = def->blocksLight;
|
Blocks.BlocksLight[block] = def->blocksLight;
|
||||||
|
@ -78,8 +78,6 @@ enum BLOCKID {
|
|||||||
|
|
||||||
/* Max block ID used in original classic */
|
/* Max block ID used in original classic */
|
||||||
BLOCK_MAX_ORIGINAL = BLOCK_OBSIDIAN,
|
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. */
|
/* Max block ID used in original classic plus CPE blocks. */
|
||||||
BLOCK_MAX_CPE = BLOCK_STONE_BRICK,
|
BLOCK_MAX_CPE = BLOCK_STONE_BRICK,
|
||||||
/* Number of blocks in original classic plus CPE blocks. */
|
/* Number of blocks in original classic plus CPE blocks. */
|
||||||
|
@ -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;
|
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;
|
Chat_Add1("&eCuboid: &cThere is no block with id \"%s\".", &value); return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void Inventory_ResetMapping(void) {
|
|||||||
|
|
||||||
void Inventory_AddDefault(BlockID block) {
|
void Inventory_AddDefault(BlockID block) {
|
||||||
int slot;
|
int slot;
|
||||||
if (block >= BLOCK_CPE_COUNT) {
|
if (block > BLOCK_MAX_CPE) {
|
||||||
Inventory.Map[block - 1] = block; return;
|
Inventory.Map[block - 1] = block; return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1713,7 +1713,7 @@ static void BlockDefs_UndefineBlock(cc_uint8* data) {
|
|||||||
Block_UpdateCulling(block);
|
Block_UpdateCulling(block);
|
||||||
|
|
||||||
Inventory_Remove(block);
|
Inventory_Remove(block);
|
||||||
if (block < BLOCK_CPE_COUNT) { Inventory_AddDefault(block); }
|
if (block <= BLOCK_MAX_CPE) { Inventory_AddDefault(block); }
|
||||||
|
|
||||||
Block_SetCustomDefined(block, false);
|
Block_SetCustomDefined(block, false);
|
||||||
Event_RaiseVoid(&BlockEvents.BlockDefChanged);
|
Event_RaiseVoid(&BlockEvents.BlockDefChanged);
|
||||||
|
@ -719,7 +719,7 @@ static cc_bool TableWidget_RowEmpty(struct TableWidget* w, int start) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TableWidget_RecreateBlocks(struct TableWidget* w) {
|
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;
|
BlockID block;
|
||||||
w->blocksCount = 0;
|
w->blocksCount = 0;
|
||||||
|
|
||||||
@ -729,7 +729,7 @@ void TableWidget_RecreateBlocks(struct TableWidget* w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
block = Inventory.Map[i];
|
block = Inventory.Map[i];
|
||||||
if (block < max) { w->blocks[w->blocksCount++] = block; }
|
if (block <= max) { w->blocks[w->blocksCount++] = block; }
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user