Refactor: Use @truncate

This commit is contained in:
IntegratedQuantum 2022-10-13 19:04:56 +02:00
parent 90a77ebf17
commit 3aed075a88
3 changed files with 4 additions and 4 deletions

View File

@ -97,7 +97,7 @@ pub const ClientEntityManager = struct {
fn update() void {
std.debug.assert(!mutex.tryLock()); // The mutex should be locked when calling this function.
var time = @bitCast(i16, @intCast(u16, std.time.milliTimestamp() & 65535));
var time = @truncate(i16, std.time.milliTimestamp());
time -%= timeDifference.difference;
for(entities.items) |*ent| {
ent.update(time, lastTime);

View File

@ -801,14 +801,14 @@ pub const Protocols: struct {
const fullEntityData = main.threadAllocator.alloc(u8, entityData.len + 3);
defer main.threadAllocator.free(fullEntityData);
fullEntityData[0] = type_entity;
std.mem.writeIntBig(i16, fullEntityData[1..3], @bitCast(i16, @intCast(u16, std.time.milliTimestamp() & 65535)));
std.mem.writeIntBig(i16, fullEntityData[1..3], @truncate(i16, std.time.milliTimestamp()));
std.mem.copy(u8, fullEntityData[3..], entityData);
conn.sendUnimportant(id, fullEntityData);
const fullItemData = main.threadAllocator.alloc(u8, itemData.len + 3);
defer main.threadAllocator.free(fullItemData);
fullItemData[0] = type_item;
std.mem.writeIntBig(i16, fullItemData[1..3], @bitCast(i16, @intCast(u16, std.time.milliTimestamp() & 65535)));
std.mem.writeIntBig(i16, fullItemData[1..3], @truncate(i16, std.time.milliTimestamp()));
std.mem.copy(u8, fullItemData[3..], itemData);
conn.sendUnimportant(id, fullItemData);
}

View File

@ -491,7 +491,7 @@ pub const TimeDifference = struct {
firstValue: bool = true,
pub fn addDataPoint(self: *TimeDifference, time: i16) void {
const currentTime = @bitCast(i16, @intCast(u16, std.time.milliTimestamp() & 65535));
const currentTime = @truncate(i16, std.time.milliTimestamp());
const timeDifference = currentTime -% time;
if(self.firstValue) {
self.difference = timeDifference;