chat msg testing
This commit is contained in:
parent
f88c33e332
commit
847f36d81a
@ -16,7 +16,7 @@ Readonly P_Frame P_NilFrame = {
|
||||
|
||||
void P_Bootstrap(void)
|
||||
{
|
||||
P.s2u.arena = AcquireArena(Gibi(64));
|
||||
P.s2v.arena = AcquireArena(Gibi(64));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
13
src/pp/pp.h
13
src/pp/pp.h
@ -306,14 +306,17 @@ Enum(P_MsgKind)
|
||||
{
|
||||
P_MsgKind_None,
|
||||
|
||||
// User -> sim
|
||||
// Server <-> Client
|
||||
P_MsgKind_Chat,
|
||||
|
||||
// Client -> Server
|
||||
// P_MsgKind_UserSnapshot,
|
||||
P_MsgKind_SaveWorld,
|
||||
P_MsgKind_ResetWorld,
|
||||
P_MsgKind_TileEdit,
|
||||
P_MsgKind_EntEdit,
|
||||
|
||||
// Sim -> user
|
||||
// Server -> Client
|
||||
// P_MsgKind_SimSnapshot,
|
||||
P_MsgKind_Tiles,
|
||||
};
|
||||
@ -407,8 +410,8 @@ Struct(P_RaycastResult)
|
||||
|
||||
Struct(P_Ctx)
|
||||
{
|
||||
// Sim -> User state
|
||||
TicketMutex s2u_tm;
|
||||
// Sim -> Vis state
|
||||
TicketMutex s2v_tm;
|
||||
struct
|
||||
{
|
||||
i64 gen;
|
||||
@ -418,7 +421,7 @@ Struct(P_Ctx)
|
||||
P_DebugDrawNode *last_debug_draw_node;
|
||||
|
||||
NET_PipeStatistics pipe_stats;
|
||||
} s2u;
|
||||
} s2v;
|
||||
};
|
||||
|
||||
Struct(P_ThreadLocalCtx)
|
||||
|
||||
@ -191,6 +191,10 @@ void S_TickForever(WaveLaneCtx *lane)
|
||||
client->net_key = net_key;
|
||||
DllQueuePushNPZ(&S_NilClient, S.first_client, S.last_client, client, next, prev);
|
||||
DllQueuePushNP(bin->first, bin->last, client, next_in_bin, prev_in_bin);
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -480,6 +484,22 @@ void S_TickForever(WaveLaneCtx *lane)
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- Process chat messages
|
||||
|
||||
{
|
||||
b32 should_save = 0;
|
||||
for (P_MsgNode *msg_node = in_msgs.first; msg_node; msg_node = msg_node->next)
|
||||
{
|
||||
P_Msg *msg = &msg_node->msg;
|
||||
if (msg->kind == P_MsgKind_Chat)
|
||||
{
|
||||
P_Msg *chat_msg = P_PushMsg(P_MsgKind_Chat, Zstr);
|
||||
chat_msg->data = msg->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- Update ent controls
|
||||
|
||||
@ -833,20 +853,20 @@ void S_TickForever(WaveLaneCtx *lane)
|
||||
//- Publish Sim -> User data
|
||||
|
||||
{
|
||||
LockTicketMutex(&P.s2u_tm);
|
||||
LockTicketMutex(&P.s2v_tm);
|
||||
{
|
||||
{
|
||||
i64 old_gen = P.s2u.gen;
|
||||
Arena *old_arena = P.s2u.arena;
|
||||
ZeroStruct(&P.s2u);
|
||||
P.s2u.arena = old_arena;
|
||||
P.s2u.gen = old_gen;
|
||||
i64 old_gen = P.s2v.gen;
|
||||
Arena *old_arena = P.s2v.arena;
|
||||
ZeroStruct(&P.s2v);
|
||||
P.s2v.arena = old_arena;
|
||||
P.s2v.gen = old_gen;
|
||||
}
|
||||
ZeroStruct(P.s2u.arena);
|
||||
P.s2u.gen += 1;
|
||||
P.s2u.pipe_stats = NET_StatsFromPipe(net_pipe);
|
||||
ZeroStruct(P.s2v.arena);
|
||||
P.s2v.gen += 1;
|
||||
P.s2v.pipe_stats = NET_StatsFromPipe(net_pipe);
|
||||
}
|
||||
UnlockTicketMutex(&P.s2u_tm);
|
||||
UnlockTicketMutex(&P.s2v_tm);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
|
||||
@ -352,7 +352,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
//////////////////////////////
|
||||
//- Init vis state
|
||||
|
||||
i64 s2u_gen = 0;
|
||||
i64 s2v_gen = 0;
|
||||
Arena *sim_debug_arena = AcquireArena(Gibi(64));
|
||||
P_DebugDrawNode *first_sim_debug_draw_node = 0;
|
||||
P_DebugDrawNode *last_sim_debug_draw_node = 0;
|
||||
@ -653,15 +653,15 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
//- Pop sim -> user data
|
||||
|
||||
{
|
||||
LockTicketMutex(&P.s2u_tm);
|
||||
LockTicketMutex(&P.s2v_tm);
|
||||
{
|
||||
if (P.s2u.gen > s2u_gen)
|
||||
if (P.s2v.gen > s2v_gen)
|
||||
{
|
||||
s2u_gen = P.s2u.gen;
|
||||
sim_pipe_stats = P.s2u.pipe_stats;
|
||||
s2v_gen = P.s2v.gen;
|
||||
sim_pipe_stats = P.s2v.pipe_stats;
|
||||
}
|
||||
}
|
||||
UnlockTicketMutex(&P.s2u_tm);
|
||||
UnlockTicketMutex(&P.s2v_tm);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
@ -2649,7 +2649,8 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
|
||||
case V_CmdKind_test:
|
||||
{
|
||||
V_PushNotif(Lit("Hello!!!"));
|
||||
// V_PushNotif(Lit("Hello!!!"));
|
||||
P_Msg *chat_msg = P_PushMsg(P_MsgKind_Chat, Lit("Hello!!!"));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
@ -2736,8 +2737,8 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
|
||||
|
||||
// {
|
||||
// LockTicketMutex(&P.s2u_snapshot_mutex);
|
||||
// P_SimSnapshot *src_snapshot = &P.s2u_snapshot;
|
||||
// LockTicketMutex(&P.s2v_snapshot_mutex);
|
||||
// P_SimSnapshot *src_snapshot = &P.s2v_snapshot;
|
||||
// if (src_snapshot->tick > sim_snapshot.tick)
|
||||
// {
|
||||
// ResetArena(sim_snapshot_arena);
|
||||
@ -2770,10 +2771,10 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ResetArena(P.s2u_snapshot_arena);
|
||||
// ZeroStruct(&P.s2u_snapshot);
|
||||
// ResetArena(P.s2v_snapshot_arena);
|
||||
// ZeroStruct(&P.s2v_snapshot);
|
||||
// }
|
||||
// UnlockTicketMutex(&P.s2u_snapshot_mutex);
|
||||
// UnlockTicketMutex(&P.s2v_snapshot_mutex);
|
||||
// }
|
||||
|
||||
//////////////////////////////
|
||||
@ -2794,10 +2795,11 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
// }
|
||||
|
||||
//- Chat
|
||||
// if (msg->kind == P_MsgKind_Chat)
|
||||
// {
|
||||
|
||||
// }
|
||||
if (msg->kind == P_MsgKind_Chat)
|
||||
{
|
||||
String txt = msg->data;
|
||||
V_PushNotif(txt);
|
||||
}
|
||||
|
||||
//- Tiles
|
||||
if (msg->kind == P_MsgKind_Tiles && sim_world->tiles_hash != msg->tiles_hash)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user