.
This commit is contained in:
parent
c6fdd68afe
commit
fb238a1966
@ -5,7 +5,7 @@ const shared = @import("shared");
|
||||
const server = @import("server.zig");
|
||||
const enet = @import("c.zig").enet;
|
||||
|
||||
pub fn spawn(allocator: std.mem.Allocator, chunk: *shared.chunk.Chunk, comptime T: type, value: T) !void {
|
||||
pub fn spawn(allocator: std.mem.Allocator, host: *enet.ENetHost, chunk: *shared.chunk.Chunk, comptime T: type, value: T) !void {
|
||||
std.debug.assert(value.id == shared.entity.INVALID_ID);
|
||||
|
||||
const id = server.next_entity_id;
|
||||
@ -44,6 +44,11 @@ pub fn spawn(allocator: std.mem.Allocator, chunk: *shared.chunk.Chunk, comptime
|
||||
|
||||
std.debug.print("{s}\n", .{fixed2.buffered()});
|
||||
|
||||
const data = fixed.buffered();
|
||||
const packet = enet.enet_packet_create(data.ptr, data.len + 1, enet.ENET_PACKET_FLAG_RELIABLE);
|
||||
|
||||
enet.enet_host_broadcast(host, 0, packet);
|
||||
|
||||
// const encoded = fixed.buffered();
|
||||
|
||||
// const packet = try znet.Packet.init(encoded, 0, .reliable);
|
||||
|
||||
@ -49,6 +49,7 @@ pub fn main() !void {
|
||||
|
||||
try chunk.spawn(
|
||||
allocator,
|
||||
host,
|
||||
&the_chunk,
|
||||
shared.entity.Soldier,
|
||||
.{
|
||||
@ -120,7 +121,7 @@ pub fn main() !void {
|
||||
}
|
||||
|
||||
if (send_accumulator > 1) {
|
||||
try chunk.broadcastChanges(&the_chunk, host);
|
||||
// try chunk.broadcastChanges(&the_chunk, host);
|
||||
|
||||
send_accumulator = 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user