Remove debug statements
parent
f5691e45f1
commit
03bf16cba4
22
src/game.zig
22
src/game.zig
|
@ -217,34 +217,17 @@ pub fn start() !void {
|
||||||
.pos = 0,
|
.pos = 0,
|
||||||
.buffer = world_data,
|
.buffer = world_data,
|
||||||
};
|
};
|
||||||
w4.tracef("[world]: size=%d", world_data.len);
|
|
||||||
const world_reader = stream.reader();
|
const world_reader = stream.reader();
|
||||||
|
|
||||||
var levels = try world.read(alloc, world_reader);
|
var levels = try world.read(alloc, world_reader);
|
||||||
var level_data_offset = try stream.getPos();
|
var level_data_offset = try stream.getPos();
|
||||||
w4.tracef("header_size=%d", level_data_offset);
|
|
||||||
|
|
||||||
try stream.seekTo(level_data_offset + levels[1].offset);
|
try stream.seekTo(level_data_offset + levels[0].offset);
|
||||||
w4.tracef("seek_to=%d", try stream.getPos());
|
|
||||||
|
|
||||||
for (levels) |lvl, i| {
|
|
||||||
w4.tracef("[%d]: offset=%d, x=%d, y=%d", i, lvl.offset, @intCast(isize, lvl.x), @intCast(isize, lvl.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
level = try world.Level.read(world_reader);
|
level = try world.Level.read(world_reader);
|
||||||
w4.tracef("level_read_end=%d", try stream.getPos());
|
|
||||||
// w4.tracef(
|
|
||||||
// "[level 0]: x=%d, y=%d, width=%d, size=%d, entity_count=%d, seek_head=%d",
|
|
||||||
// level.world_x,
|
|
||||||
// level.world_y,
|
|
||||||
// level.width,
|
|
||||||
// level.size,
|
|
||||||
// level.entity_count,
|
|
||||||
// );
|
|
||||||
|
|
||||||
level_buf = try alloc.alloc(world.TileData, level.size);
|
level_buf = try alloc.alloc(world.TileData, level.size);
|
||||||
try level.readTiles(world_reader, level_buf);
|
try level.readTiles(world_reader, level_buf);
|
||||||
w4.tracef("level_read_end=%d", try stream.getPos());
|
|
||||||
|
|
||||||
try extract.extractLevel(.{
|
try extract.extractLevel(.{
|
||||||
.alloc = frame_alloc,
|
.alloc = frame_alloc,
|
||||||
|
@ -258,11 +241,8 @@ pub fn start() !void {
|
||||||
.switch_on = world.Tiles.SwitchesOn,
|
.switch_on = world.Tiles.SwitchesOn,
|
||||||
});
|
});
|
||||||
|
|
||||||
w4.tracef("entity_count=%d", level.entity_count);
|
|
||||||
w4.tracef("entity_size=%d", level.entity_count * world.Entity.calculateSize());
|
|
||||||
var entity_buf = try alloc.alloc(world.Entity, level.entity_count);
|
var entity_buf = try alloc.alloc(world.Entity, level.entity_count);
|
||||||
try level.readEntities(world_reader, entity_buf);
|
try level.readEntities(world_reader, entity_buf);
|
||||||
w4.tracef("entity_read_end=%d", try stream.getPos());
|
|
||||||
|
|
||||||
const spawnArr = level.getSpawn() orelse return error.NoPlayerSpawn;
|
const spawnArr = level.getSpawn() orelse return error.NoPlayerSpawn;
|
||||||
const spawn = Vec2{ spawnArr[0], spawnArr[1] };
|
const spawn = Vec2{ spawnArr[0], spawnArr[1] };
|
||||||
|
|
|
@ -44,6 +44,7 @@ export fn update() void {
|
||||||
error.EndOfStream => showErr(@errorName(e)),
|
error.EndOfStream => showErr(@errorName(e)),
|
||||||
error.OutOfMemory => showErr(@errorName(e)),
|
error.OutOfMemory => showErr(@errorName(e)),
|
||||||
error.NullTiles => showErr(@errorName(e)),
|
error.NullTiles => showErr(@errorName(e)),
|
||||||
|
error.NoPlayerSpawn => showErr(@errorName(e)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,6 @@ fn make(step: *std.build.Step) !void {
|
||||||
.y = level.world_y,
|
.y = level.world_y,
|
||||||
.offset = offset,
|
.offset = offset,
|
||||||
});
|
});
|
||||||
std.log.warn("[{}] x={} y={}; {} + {} = {}", .{ i, level.world_x, level.world_y, last_offset, last_size, offset });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create array to write data to
|
// Create array to write data to
|
||||||
|
@ -107,45 +106,9 @@ fn make(step: *std.build.Step) !void {
|
||||||
|
|
||||||
// Write levels
|
// Write levels
|
||||||
for (levels.items) |level| {
|
for (levels.items) |level| {
|
||||||
std.log.warn("{} + {} + {} + {} + {} + {} + {}", .{
|
|
||||||
@sizeOf(i8),
|
|
||||||
@sizeOf(i8),
|
|
||||||
@sizeOf(u16),
|
|
||||||
@sizeOf(u16),
|
|
||||||
@sizeOf(u16),
|
|
||||||
level.tiles.?.len,
|
|
||||||
level.entities.?.len * world.Entity.calculateSize(),
|
|
||||||
});
|
|
||||||
|
|
||||||
std.log.warn("x={} y={} w={} s={} ec={} t={} e={}", .{
|
|
||||||
level.world_x,
|
|
||||||
level.world_y,
|
|
||||||
level.width,
|
|
||||||
level.size,
|
|
||||||
level.entity_count,
|
|
||||||
level.tiles.?.len,
|
|
||||||
level.entities.?.len,
|
|
||||||
});
|
|
||||||
try level.write(writer);
|
try level.write(writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
var stream = std.io.FixedBufferStream([]const u8){
|
|
||||||
.pos = 0,
|
|
||||||
.buffer = data.items,
|
|
||||||
};
|
|
||||||
const world_reader = stream.reader();
|
|
||||||
var lvls = try world.read(allocator, world_reader);
|
|
||||||
var level_data_offset = try stream.getPos();
|
|
||||||
std.log.warn("level_data_offset {}", .{level_data_offset});
|
|
||||||
|
|
||||||
try stream.seekTo(level_data_offset + lvls[1].offset);
|
|
||||||
std.log.warn("seek to 1 {}", .{try stream.getPos()});
|
|
||||||
|
|
||||||
var level = try world.Level.read(world_reader);
|
|
||||||
std.log.warn("level x={}, y={}", .{ level.world_x, level.world_y });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open output file and write data into it
|
// Open output file and write data into it
|
||||||
cwd.makePath(this.builder.getInstallPath(.lib, "")) catch |e| switch (e) {
|
cwd.makePath(this.builder.getInstallPath(.lib, "")) catch |e| switch (e) {
|
||||||
error.PathAlreadyExists => {},
|
error.PathAlreadyExists => {},
|
||||||
|
|
Loading…
Reference in New Issue