mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
Use the equality operator instead std.meta.eql for packed structs.
progress towards #1160
This commit is contained in:
parent
832f5e7e08
commit
17b8c8d8b6
@ -553,7 +553,7 @@ pub const ItemDropRenderer = struct { // MARK: ItemDropRenderer
|
||||
|
||||
fn getSlot(len: u31) u31 {
|
||||
for(freeSlots.items, 0..) |potentialSlot, i| {
|
||||
if(std.meta.eql(len, potentialSlot.len)) {
|
||||
if(len == potentialSlot.len) {
|
||||
_ = freeSlots.swapRemove(i);
|
||||
const result = potentialSlot.index;
|
||||
main.globalAllocator.destroy(potentialSlot);
|
||||
|
@ -166,7 +166,7 @@ pub const Model = struct {
|
||||
|
||||
fn addVert(vert: Vec3f, vertList: *main.List(Vec3f)) usize {
|
||||
const ind = for(vertList.*.items, 0..) |vertex, index| {
|
||||
if(std.meta.eql(vertex, vert)) break index;
|
||||
if(vertex == vert) break index;
|
||||
} else vertList.*.items.len;
|
||||
|
||||
if(ind == vertList.*.items.len) {
|
||||
|
@ -902,7 +902,7 @@ pub const MeshSelection = struct { // MARK: MeshSelection
|
||||
block.mode().onBlockBreaking(inventory.getStack(slot).item, relPos, lastDir, &newBlock);
|
||||
main.items.Inventory.Sync.ClientSide.mutex.unlock();
|
||||
|
||||
if(!std.meta.eql(newBlock, block)) {
|
||||
if(newBlock != block) {
|
||||
updateBlockAndSendUpdate(inventory, slot, selectedPos[0], selectedPos[1], selectedPos[2], block, newBlock);
|
||||
}
|
||||
}
|
||||
|
@ -821,7 +821,7 @@ pub const ChunkMesh = struct { // MARK: ChunkMesh
|
||||
const rotatedModel = blocks.meshes.model(block);
|
||||
const model = &models.models.items[rotatedModel];
|
||||
_ = model; // TODO: Check if the neighbor model occludes this one. (maybe not that relevant)
|
||||
return block.typ != 0 and (other.typ == 0 or (!std.meta.eql(block, other) and other.viewThrough()) or other.alwaysViewThrough() or !models.models.items[blocks.meshes.model(other)].isNeighborOccluded[neighbor.reverse().toInt()]);
|
||||
return block.typ != 0 and (other.typ == 0 or (block != other and other.viewThrough()) or other.alwaysViewThrough() or !models.models.items[blocks.meshes.model(other)].isNeighborOccluded[neighbor.reverse().toInt()]);
|
||||
}
|
||||
|
||||
fn initLight(self: *ChunkMesh, lightRefreshList: *main.List(*ChunkMesh)) void {
|
||||
@ -1051,7 +1051,7 @@ pub const ChunkMesh = struct { // MARK: ChunkMesh
|
||||
if(depthFilteredViewThroughMask[x][y] & setBit != 0) block.typ = block.opaqueVariant();
|
||||
if(block.viewThrough() and !block.alwaysViewThrough()) { // Needs to check the neighbor block
|
||||
const neighborBlock = self.chunk.data.getValue(chunk.getIndex(@intCast(x - 1), @intCast(y), z));
|
||||
if(std.meta.eql(block, neighborBlock)) continue;
|
||||
if(block == neighborBlock) continue;
|
||||
}
|
||||
if(block.transparent()) {
|
||||
if(block.hasBackFace()) {
|
||||
@ -1078,7 +1078,7 @@ pub const ChunkMesh = struct { // MARK: ChunkMesh
|
||||
if(depthFilteredViewThroughMask[x][y] & setBit != 0) block.typ = block.opaqueVariant();
|
||||
if(block.viewThrough() and !block.alwaysViewThrough()) { // Needs to check the neighbor block
|
||||
const neighborBlock = self.chunk.data.getValue(chunk.getIndex(@intCast(x + 1), @intCast(y), z));
|
||||
if(std.meta.eql(block, neighborBlock)) continue;
|
||||
if(block == neighborBlock) continue;
|
||||
}
|
||||
if(block.transparent()) {
|
||||
if(block.hasBackFace()) {
|
||||
@ -1105,7 +1105,7 @@ pub const ChunkMesh = struct { // MARK: ChunkMesh
|
||||
if(depthFilteredViewThroughMask[x][y] & setBit != 0) block.typ = block.opaqueVariant();
|
||||
if(block.viewThrough() and !block.alwaysViewThrough()) { // Needs to check the neighbor block
|
||||
const neighborBlock = self.chunk.data.getValue(chunk.getIndex(@intCast(x), @intCast(y - 1), z));
|
||||
if(std.meta.eql(block, neighborBlock)) continue;
|
||||
if(block == neighborBlock) continue;
|
||||
}
|
||||
if(block.transparent()) {
|
||||
if(block.hasBackFace()) {
|
||||
@ -1132,7 +1132,7 @@ pub const ChunkMesh = struct { // MARK: ChunkMesh
|
||||
if(depthFilteredViewThroughMask[x][y] & setBit != 0) block.typ = block.opaqueVariant();
|
||||
if(block.viewThrough() and !block.alwaysViewThrough()) { // Needs to check the neighbor block
|
||||
const neighborBlock = self.chunk.data.getValue(chunk.getIndex(@intCast(x), @intCast(y + 1), z));
|
||||
if(std.meta.eql(block, neighborBlock)) continue;
|
||||
if(block == neighborBlock) continue;
|
||||
}
|
||||
if(block.transparent()) {
|
||||
if(block.hasBackFace()) {
|
||||
@ -1159,7 +1159,7 @@ pub const ChunkMesh = struct { // MARK: ChunkMesh
|
||||
if(depthFilteredViewThroughMask[x][y] & setBit != 0) block.typ = block.opaqueVariant();
|
||||
if(block.viewThrough() and !block.alwaysViewThrough()) { // Needs to check the neighbor block
|
||||
const neighborBlock = self.chunk.data.getValue(chunk.getIndex(@intCast(x), @intCast(y), z - 1));
|
||||
if(std.meta.eql(block, neighborBlock)) continue;
|
||||
if(block == neighborBlock) continue;
|
||||
}
|
||||
if(block.transparent()) {
|
||||
if(block.hasBackFace()) {
|
||||
@ -1186,7 +1186,7 @@ pub const ChunkMesh = struct { // MARK: ChunkMesh
|
||||
if(depthFilteredViewThroughMask[x][y] & setBit != 0) block.typ = block.opaqueVariant();
|
||||
if(block.viewThrough() and !block.alwaysViewThrough()) { // Needs to check the neighbor block
|
||||
const neighborBlock = self.chunk.data.getValue(chunk.getIndex(@intCast(x), @intCast(y), z + 1));
|
||||
if(std.meta.eql(block, neighborBlock)) continue;
|
||||
if(block == neighborBlock) continue;
|
||||
}
|
||||
if(block.transparent()) {
|
||||
if(block.hasBackFace()) {
|
||||
@ -1223,7 +1223,7 @@ pub const ChunkMesh = struct { // MARK: ChunkMesh
|
||||
const z: u5 = @intCast(_z & chunk.chunkMask);
|
||||
var newBlock = _newBlock;
|
||||
self.mutex.lock();
|
||||
if(std.meta.eql(self.chunk.data.getValue(chunk.getIndex(x, y, z)), newBlock)) {
|
||||
if(self.chunk.data.getValue(chunk.getIndex(x, y, z)) == newBlock) {
|
||||
self.mutex.unlock();
|
||||
return;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ pub const RotationMode = struct { // MARK: RotationMode
|
||||
}
|
||||
fn canBeChangedInto(oldBlock: Block, newBlock: Block, item: main.items.ItemStack, shouldDropSourceBlockOnSuccess: *bool) CanBeChangedInto {
|
||||
shouldDropSourceBlockOnSuccess.* = true;
|
||||
if(std.meta.eql(oldBlock, newBlock)) return .no;
|
||||
if(oldBlock == newBlock) return .no;
|
||||
if(oldBlock.typ == newBlock.typ) return .yes;
|
||||
if(oldBlock.solid()) {
|
||||
var damage: f32 = 1;
|
||||
@ -1143,7 +1143,7 @@ pub const RotationModes = struct {
|
||||
}
|
||||
|
||||
pub fn canBeChangedInto(oldBlock: Block, newBlock: Block, _: main.items.ItemStack, shouldDropSourceBlockOnSuccess: *bool) RotationMode.CanBeChangedInto {
|
||||
if(std.meta.eql(oldBlock, newBlock)) return .no;
|
||||
if(oldBlock == newBlock) return .no;
|
||||
if(oldBlock.transparent() or oldBlock.viewThrough()) return .no;
|
||||
if(!main.models.models.items[main.blocks.meshes.modelIndexStart(oldBlock)].allNeighborsOccluded) return .no;
|
||||
if(oldBlock.data != 0) return .no;
|
||||
|
@ -1030,7 +1030,7 @@ pub const ServerWorld = struct { // MARK: ServerWorld
|
||||
baseChunk.mutex.lock();
|
||||
const currentBlock = baseChunk.getBlock(x, y, z);
|
||||
if(oldBlock != null) {
|
||||
if(!std.meta.eql(oldBlock.?, currentBlock)) {
|
||||
if(oldBlock.? != currentBlock) {
|
||||
baseChunk.mutex.unlock();
|
||||
return currentBlock;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user