mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
Update zig version to 0.11.0-dev.3380+7e0a02ee2
Zig got worse at copying unnecessary stuff onto the stack :(
This commit is contained in:
parent
4fcfd10307
commit
e2280c2b63
@ -27,7 +27,7 @@ pub fn readAllJsonFilesInAddons(externalAllocator: Allocator, addons: std.ArrayL
|
||||
defer walker.deinit();
|
||||
|
||||
while(try walker.next()) |entry| {
|
||||
if(entry.kind == .File and std.ascii.endsWithIgnoreCase(entry.basename, ".json")) {
|
||||
if(entry.kind == .file and std.ascii.endsWithIgnoreCase(entry.basename, ".json")) {
|
||||
const folderName = addonName;
|
||||
var id: []u8 = try externalAllocator.alloc(u8, folderName.len + 1 + entry.path.len - 5);
|
||||
@memcpy(id[0..folderName.len], folderName);
|
||||
@ -56,7 +56,7 @@ pub fn readAllFilesInAddons(externalAllocator: Allocator, addons: std.ArrayList(
|
||||
defer walker.deinit();
|
||||
|
||||
while(try walker.next()) |entry| {
|
||||
if(entry.kind == .File) {
|
||||
if(entry.kind == .file) {
|
||||
var file = try dir.dir.openFile(entry.path, .{});
|
||||
defer file.close();
|
||||
const string = try file.readToEndAlloc(externalAllocator, std.math.maxInt(usize));
|
||||
@ -77,7 +77,7 @@ pub fn readAssets(externalAllocator: Allocator, assetPath: []const u8, blocks: *
|
||||
defer dir.close();
|
||||
var iterator = dir.iterate();
|
||||
while(try iterator.next()) |addon| {
|
||||
if(addon.kind == .Directory) {
|
||||
if(addon.kind == .directory) {
|
||||
try addons.append(try dir.dir.openDir(addon.name, .{}));
|
||||
try addonNames.append(try main.threadAllocator.dupe(u8, addon.name));
|
||||
}
|
||||
|
@ -215,68 +215,68 @@ pub const Block = packed struct {
|
||||
return Block{.typ=@truncate(u16, self), .data=@intCast(u16, self>>16)};
|
||||
}
|
||||
pub inline fn lightingTransparent(self: Block) bool {
|
||||
return _lightingTransparent[self.typ];
|
||||
return (&_lightingTransparent)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub inline fn transparent(self: Block) bool {
|
||||
return _transparent[self.typ];
|
||||
return (&_transparent)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub inline fn id(self: Block) []u8 {
|
||||
return _id[self.typ];
|
||||
return (&_id)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
/// Time in seconds to break this block by hand.
|
||||
pub inline fn hardness(self: Block) f32 {
|
||||
return _hardness[self.typ];
|
||||
return (&_hardness)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
/// Minimum pickaxe/axe/shovel power required.
|
||||
pub inline fn breakingPower(self: Block) f32 {
|
||||
return _breakingPower[self.typ];
|
||||
return (&_breakingPower)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub inline fn solid(self: Block) bool {
|
||||
return _solid[self.typ];
|
||||
return (&_solid)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub inline fn selectable(self: Block) bool {
|
||||
return _selectable[self.typ];
|
||||
return (&_selectable)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub inline fn blockDrops(self: Block) []BlockDrop {
|
||||
return _blockDrops[self.typ];
|
||||
return (&_blockDrops)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
/// Meaning undegradable parts of trees or other structures can grow through this block.
|
||||
pub inline fn degradable(self: Block) bool {
|
||||
return _degradable[self.typ];
|
||||
return (&_degradable)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub inline fn viewThrough(self: Block) bool {
|
||||
return (&_viewThrough)[self.typ]; // ← a temporary fix to a compiler performance bug. TODO: check if this was fixed.
|
||||
return (&_viewThrough)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub inline fn blockClass(self: Block) BlockClass {
|
||||
return _blockClass[self.typ];
|
||||
return (&_blockClass)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub inline fn light(self: Block) u32 {
|
||||
return _light[self.typ];
|
||||
return (&_light)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
/// How much light this block absorbs if it is transparent.
|
||||
pub inline fn absorption(self: Block) u32 {
|
||||
return _absorption[self.typ];
|
||||
return (&_absorption)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
/// GUI that is opened on click.
|
||||
pub inline fn gui(self: Block) []u8 {
|
||||
return _gui[self.typ];
|
||||
return (&_gui)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub inline fn mode(self: Block) *RotationMode {
|
||||
return _mode[self.typ];
|
||||
return (&_mode)[self.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
// TODO:
|
||||
@ -380,7 +380,7 @@ pub const meshes = struct {
|
||||
}
|
||||
|
||||
pub inline fn modelIndexStart(block: Block) u16 {
|
||||
return _modelIndex[block.typ];
|
||||
return (&_modelIndex)[block.typ]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub fn readTexture(textureInfo: JsonElement, assetFolder: []const u8) !?u31 {
|
||||
|
@ -120,7 +120,7 @@ pub fn onOpen() Allocator.Error!void {
|
||||
std.log.err("Encountered error while iterating over folder \"saves\": {s}", .{@errorName(err)});
|
||||
return;
|
||||
}) |entry| {
|
||||
if(entry.kind == .Directory) {
|
||||
if(entry.kind == .directory) {
|
||||
var row = try HorizontalList.init();
|
||||
|
||||
const decodedName = try parseEscapedFolderName(entry.name);
|
||||
|
@ -124,7 +124,7 @@ pub const ItemDropManager = struct {
|
||||
pub fn getPositionAndVelocityData(self: *ItemDropManager, allocator: Allocator) ![]u8 {
|
||||
const _data = try allocator.alloc(u8, self.size*50);
|
||||
var data = _data;
|
||||
for(self.indices) |i| {
|
||||
for(self.indices[0..self.size]) |i| {
|
||||
std.mem.writeIntBig(u16, data[0..2], i);
|
||||
std.mem.writeIntBig(u64, data[2..10], @bitCast(u64, self.pos[i][0]));
|
||||
std.mem.writeIntBig(u64, data[10..18], @bitCast(u64, self.pos[i][1]));
|
||||
@ -158,7 +158,7 @@ pub const ItemDropManager = struct {
|
||||
{
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
for(self.indices) |i| {
|
||||
for(self.indices[0..self.size]) |i| {
|
||||
const item = try self.storeSingle(allocator, i);
|
||||
try jsonArray.JsonArray.append(item);
|
||||
}
|
||||
@ -504,7 +504,7 @@ pub const ClientItemDropManager = struct {
|
||||
{
|
||||
self.super.mutex.lock();
|
||||
defer self.super.mutex.unlock();
|
||||
self.interpolation.updateIndexed(time, self.lastTime, &self.super.indices, 4);
|
||||
self.interpolation.updateIndexed(time, self.lastTime, self.super.indices[0..self.super.size], 4);
|
||||
}
|
||||
self.lastTime = time;
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ pub const MenuBackGround = struct {
|
||||
}
|
||||
|
||||
while(try walker.next()) |entry| {
|
||||
if(entry.kind == .File and std.ascii.endsWithIgnoreCase(entry.basename, ".png")) {
|
||||
if(entry.kind == .file and std.ascii.endsWithIgnoreCase(entry.basename, ".png")) {
|
||||
try fileList.append(try main.threadAllocator.dupe(u8, entry.path));
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ pub const CaveBiomeGenerator = struct {
|
||||
return lhs.priority < rhs.priority;
|
||||
}
|
||||
}.lessThan;
|
||||
std.sort.sort(CaveBiomeGenerator, list, {}, lessThan);
|
||||
std.sort.insertion(CaveBiomeGenerator, list, {}, lessThan);
|
||||
return list;
|
||||
}
|
||||
};
|
||||
@ -303,20 +303,20 @@ pub const InterpolatableCaveBiomeMapView = struct {
|
||||
|
||||
noinline fn _getBiome(self: InterpolatableCaveBiomeMapView, wx: i32, wy: i32, wz: i32, map: u1) *const Biome {
|
||||
var index: u8 = 0;
|
||||
if(wx - self.fragments[0].pos.wx >= CaveBiomeMapFragment.caveBiomeMapSize) {
|
||||
if(wx - (&self.fragments)[0].pos.wx >= CaveBiomeMapFragment.caveBiomeMapSize) { // TODO: #15685
|
||||
index += 4;
|
||||
}
|
||||
if(wy - self.fragments[0].pos.wy >= CaveBiomeMapFragment.caveBiomeMapSize) {
|
||||
if(wy - (&self.fragments)[0].pos.wy >= CaveBiomeMapFragment.caveBiomeMapSize) { // TODO: #15685
|
||||
index += 2;
|
||||
}
|
||||
if(wz - self.fragments[0].pos.wz >= CaveBiomeMapFragment.caveBiomeMapSize) {
|
||||
if(wz - (&self.fragments)[0].pos.wz >= CaveBiomeMapFragment.caveBiomeMapSize) { // TODO: #15685
|
||||
index += 1;
|
||||
}
|
||||
const relX = @intCast(u31, wx - self.fragments[index].pos.wx);
|
||||
const relY = @intCast(u31, wy - self.fragments[index].pos.wy);
|
||||
const relZ = @intCast(u31, wz - self.fragments[index].pos.wz);
|
||||
const relX = @intCast(u31, wx - (&self.fragments)[index].pos.wx); // TODO: #15685
|
||||
const relY = @intCast(u31, wy - (&self.fragments)[index].pos.wy); // TODO: #15685
|
||||
const relZ = @intCast(u31, wz - (&self.fragments)[index].pos.wz); // TODO: #15685
|
||||
const indexInArray = CaveBiomeMapFragment.getIndex(relX, relY, relZ);
|
||||
return self.fragments[index].biomeMap[indexInArray][map];
|
||||
return (&(&self.fragments)[index].biomeMap[indexInArray])[map]; // TODO: #15685
|
||||
}
|
||||
|
||||
/// Useful when the rough biome location is enough, for example for music.
|
||||
|
@ -122,7 +122,7 @@ pub const CaveGenerator = struct {
|
||||
return lhs.priority < rhs.priority;
|
||||
}
|
||||
}.lessThan;
|
||||
std.sort.sort(CaveGenerator, list, {}, lessThan);
|
||||
std.sort.insertion(CaveGenerator, list, {}, lessThan);
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
@ -73,13 +73,13 @@ pub const MapFragment = struct {
|
||||
pub fn getBiome(self: *MapFragment, wx: i32, wz: i32) *const Biome {
|
||||
const xIndex = wx>>self.pos.voxelSizeShift & mapMask;
|
||||
const zIndex = wz>>self.pos.voxelSizeShift & mapMask;
|
||||
return self.biomeMap[@intCast(usize, xIndex)][@intCast(usize, zIndex)];
|
||||
return (&self.biomeMap[@intCast(usize, xIndex)])[@intCast(usize, zIndex)]; // TODO: #15685
|
||||
}
|
||||
|
||||
pub fn getHeight(self: *MapFragment, wx: i32, wz: i32) f32 {
|
||||
const xIndex = wx>>self.pos.voxelSizeShift & mapMask;
|
||||
const zIndex = wz>>self.pos.voxelSizeShift & mapMask;
|
||||
return self.heightMap[@intCast(usize, xIndex)][@intCast(usize, zIndex)];
|
||||
return (&self.heightMap[@intCast(usize, xIndex)])[@intCast(usize, zIndex)]; // TODO: #15685
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -116,15 +116,15 @@ pub fn generateMapFragment(map: *ClimateMapFragment, worldSeed: u64) Allocator.E
|
||||
while(x < mapSize/biomeSize) : (x += 1) {
|
||||
var z: i32 = 0;
|
||||
while(z < mapSize/biomeSize) : (z += 1) {
|
||||
const biome = biomeMap[@intCast(usize, x + 1)][@intCast(usize, z + 1)];
|
||||
const biome = (&biomeMap[@intCast(usize, x + 1)])[@intCast(usize, z + 1)]; // TODO: #15685
|
||||
var maxMinHeight: i32 = std.math.minInt(i32);
|
||||
var minMaxHeight: i32 = std.math.maxInt(i32);
|
||||
var dx: i32 = -1;
|
||||
while(dx <= 1) : (dx += 1) {
|
||||
var dz: i32 = -1;
|
||||
while(dz <= 1) : (dz += 1) {
|
||||
maxMinHeight = @max(maxMinHeight, biomeMap[@intCast(usize, x + dx + 1)][@intCast(usize, z + dz + 1)].minHeight);
|
||||
minMaxHeight = @min(minMaxHeight, biomeMap[@intCast(usize, x + dx + 1)][@intCast(usize, z + dz + 1)].maxHeight);
|
||||
maxMinHeight = @max(maxMinHeight, (&biomeMap[@intCast(usize, x + dx + 1)])[@intCast(usize, z + dz + 1)].minHeight); // TODO: #15685
|
||||
minMaxHeight = @min(minMaxHeight, (&biomeMap[@intCast(usize, x + dx + 1)])[@intCast(usize, z + dz + 1)].maxHeight); // TODO: #15685
|
||||
}
|
||||
}
|
||||
var seed: u64 = @intCast(u64, @bitCast(u32, x +% map.pos.wx))*%675893674893 +% @intCast(u64, @bitCast(u32, z +% map.pos.wz))*%2895478591 +% worldSeed;
|
||||
|
@ -54,7 +54,7 @@ pub const BlockGenerator = struct {
|
||||
return lhs.priority < rhs.priority;
|
||||
}
|
||||
}.lessThan;
|
||||
std.sort.sort(BlockGenerator, list, {}, lessThan);
|
||||
std.sort.insertion(BlockGenerator, list, {}, lessThan);
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ pub const Compression = struct {
|
||||
defer walker.deinit();
|
||||
|
||||
while(try walker.next()) |entry| {
|
||||
if(entry.kind == .File) {
|
||||
if(entry.kind == .file) {
|
||||
var relPath = entry.path;
|
||||
var len: [4]u8 = undefined;
|
||||
std.mem.writeIntBig(u32, &len, @intCast(u32, relPath.len));
|
||||
|
Loading…
x
Reference in New Issue
Block a user