updates to engine time and seemingly bugs are fixed
This commit is contained in:
parent
81aaaa81b7
commit
9f9f40abd9
|
|
@ -21,7 +21,8 @@ pub fn tick(self: *@This(), dt: f64) void {
|
|||
}
|
||||
|
||||
pub fn deinit(self: *@This()) void {
|
||||
self.allocator.destroy(self);
|
||||
// Engine handles memory deallocation
|
||||
_ = self;
|
||||
}
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ pub const packer = @import("packer");
|
|||
|
||||
pub const StackCompactor = stacks.StackCompactor;
|
||||
|
||||
var staticsInitialized = false;
|
||||
pub var staticsInitialized = false;
|
||||
var gEngine: *Engine = undefined;
|
||||
pub const PackerFS = packer.PackerFS;
|
||||
var gPackerFS: *PackerFS = undefined;
|
||||
|
|
@ -274,8 +274,6 @@ pub fn maybeInitPackerFs(allocator: std.mem.Allocator) !void {
|
|||
}
|
||||
|
||||
pub fn start_module_(map: *SpecVariantMap, args: anytype, allocator: std.mem.Allocator) !void {
|
||||
staticsInitialized = true;
|
||||
|
||||
if (map.get("utility")) |x| {
|
||||
if (x.boolean == true) {
|
||||
engine_logs("utility mode - no gui");
|
||||
|
|
@ -299,6 +297,8 @@ pub fn start_module_(map: *SpecVariantMap, args: anytype, allocator: std.mem.All
|
|||
|
||||
gEngine = try allocator.create(Engine);
|
||||
gEngine.* = try Engine.init(allocator);
|
||||
staticsInitialized = true;
|
||||
|
||||
_ = try createObject(ModuleLoader, .{});
|
||||
try console.start();
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ pub const Engine = struct {
|
|||
if (comptime core.BuildOption("static_build")) {
|
||||
newObjectPtr = @ptrCast(@alignCast((try self.allocator.alignedAlloc(u8, .@"16", vtable.typeSize))));
|
||||
} else {
|
||||
newObjectPtr = @ptrCast(@alignCast(&(try self.allocator.create(DebugSlack)).slack));
|
||||
newObjectPtr = @ptrCast(@alignCast((try self.allocator.create(DebugSlack))));
|
||||
}
|
||||
|
||||
try vtable.init_func(newObjectPtr, self.allocator, true);
|
||||
|
|
@ -373,6 +373,7 @@ pub const Engine = struct {
|
|||
}
|
||||
|
||||
fn destroyObject(self: *@This(), item: EngineObjectRef) void {
|
||||
core.engine_log("destroying object {s}", .{item.vtable.typeName});
|
||||
if (item.vtable.deinit_func) |deinitFn| {
|
||||
deinitFn(item.ptr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,12 @@ const pscopes = core.algorithm.pscopes;
|
|||
|
||||
// returns time since engine started in nanoseconds
|
||||
pub fn getEngineTime() f64 {
|
||||
const read = core.getEngine().rootTimer.read();
|
||||
return @as(f64, @floatFromInt(read)) / std.time.ns_per_s;
|
||||
if (core.staticsInitialized) {
|
||||
const read = core.getEngine().rootTimer.read();
|
||||
return @as(f64, @floatFromInt(read)) / std.time.ns_per_s;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns a pscopes.TimingScope for the current time.
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ pub fn startEngine(spec: *core.SpecVariantMap) bool {
|
|||
|
||||
run() catch return false;
|
||||
|
||||
if (core.getEngine().shutdownModuleFunction) |f| {
|
||||
f();
|
||||
if (core.getEngine().shutdownModuleFunction) |shutdownFunc| {
|
||||
shutdownFunc();
|
||||
} else {
|
||||
core.shutdown_module(allocator);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ fn displayInstructions(self: *@This()) void {
|
|||
|
||||
pub fn deinit(self: *@This()) void {
|
||||
self.animationStore.destroy();
|
||||
self.allocator.destroy(self);
|
||||
// Engine handles memory deallocation
|
||||
}
|
||||
|
||||
fn copyRecursiveDir(
|
||||
|
|
|
|||
Loading…
Reference in New Issue