mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -04:00
Refactor: Use @truncate
This commit is contained in:
parent
90a77ebf17
commit
3aed075a88
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user