serialize tick
This commit is contained in:
parent
f1eb4ea855
commit
63c7e9122d
@ -62,8 +62,8 @@ void S_TickForever(WaveLaneCtx *lane)
|
||||
|
||||
P_World *world = P_AcquireWorld();
|
||||
|
||||
// TODO: Real per-client deltas
|
||||
b32 has_sent_initial_tick = 0;
|
||||
// TODO: Real level-load logic
|
||||
b32 has_swapped_in = 0;
|
||||
|
||||
NET_PipeHandle net_pipe = NET_AcquirePipe();
|
||||
BB_Buff packer_bb = BB_AcquireDynamicBuff(Gibi(64));
|
||||
@ -112,8 +112,9 @@ void S_TickForever(WaveLaneCtx *lane)
|
||||
b32 swapout = shutdown && IsSwappingOut();
|
||||
|
||||
//- Swap in
|
||||
if (world->last_frame->tick == 1)
|
||||
if (!has_swapped_in)
|
||||
{
|
||||
has_swapped_in = 1;
|
||||
String packed = Zi;
|
||||
if (swapin)
|
||||
{
|
||||
@ -125,6 +126,7 @@ void S_TickForever(WaveLaneCtx *lane)
|
||||
|
||||
world->seed = unpacked.seed;
|
||||
world_frame->time_ns = unpacked.time_ns;
|
||||
world_frame->tick = unpacked.tick;
|
||||
if (world->seed == 0)
|
||||
{
|
||||
TrueRand(StringFromStruct(&world->seed));
|
||||
|
||||
@ -13,6 +13,7 @@ String P_PackWorld(Arena *arena, P_World *src_world)
|
||||
result.len += StringF(arena, "\n").len;
|
||||
result.len += StringF(arena, "seed: 0x%F\n", FmtHex(src_world->seed)).len;
|
||||
result.len += StringF(arena, "time: %F\n", FmtSint(src_frame->time_ns)).len;
|
||||
result.len += StringF(arena, "tick: %F\n", FmtSint(src_frame->tick)).len;
|
||||
|
||||
// Pack entities
|
||||
// FIXME: Precision
|
||||
@ -60,6 +61,8 @@ String P_PackWorld(Arena *arena, P_World *src_world)
|
||||
}
|
||||
}
|
||||
result.len += StringF(arena, " }\n").len;
|
||||
result.len += StringF(arena, " created_at_ns: \"%F\"\n", FmtSint(ent->created_at_ns)).len;
|
||||
result.len += StringF(arena, " created_at_tick: \"%F\"\n", FmtSint(ent->created_at_tick)).len;
|
||||
result.len += StringF(arena, " pos: \"%F\"\n", FmtFloat2(ent->xf.t)).len;
|
||||
result.len += StringF(arena, " angle: \"%F\"\n", FmtFloat(AngleFromVec2(ent->xf.r))).len;
|
||||
result.len += StringF(arena, " look: \"%F\"\n", FmtFloat2(ent->control.look)).len;
|
||||
@ -128,6 +131,10 @@ P_UnpackedWorld P_UnpackWorld(Arena *arena, String packed)
|
||||
{
|
||||
result.time_ns = CR_IntFromString(top_item->value);
|
||||
}
|
||||
if (MatchString(top_item->name, Lit("tick")))
|
||||
{
|
||||
result.tick = CR_IntFromString(top_item->value);
|
||||
}
|
||||
|
||||
// Unpack entities
|
||||
if (MatchString(top_item->name, Lit("entities")))
|
||||
@ -168,6 +175,14 @@ P_UnpackedWorld P_UnpackWorld(Arena *arena, String packed)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (MatchString(attr->name, Lit("created_at_ns")))
|
||||
{
|
||||
ent->created_at_ns = CR_IntFromString(attr->value);
|
||||
}
|
||||
if (MatchString(attr->name, Lit("created_at_tick")))
|
||||
{
|
||||
ent->created_at_tick = CR_IntFromString(attr->value);
|
||||
}
|
||||
if (MatchString(attr->name, Lit("pos")))
|
||||
{
|
||||
ent->xf.t = CR_Vec2FromString(attr->value);
|
||||
|
||||
@ -16,8 +16,8 @@ Struct(P_UnpackedWorld)
|
||||
P_Tv version;
|
||||
|
||||
u64 seed;
|
||||
i64 tick;
|
||||
i64 time_ns;
|
||||
i64 tick;
|
||||
|
||||
P_EntList ents;
|
||||
u8 *tiles;
|
||||
|
||||
@ -1074,7 +1074,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
{
|
||||
P_MsgNode tmp_msg_node = Zi;
|
||||
tmp_msg_node.msg.kind = P_MsgKind_Connect;
|
||||
tmp_msg_node.msg.data = Lit("Bro");
|
||||
tmp_msg_node.msg.data = Lit("Brosef");
|
||||
tmp_msg_node.msg.key = V.player_key;
|
||||
|
||||
P_MsgList tmp_msglist = Zi;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user