1
0
forked from mirrors/0ad

Unique network transmission handling of flares

This patch addresses issues concerning a1796ed71f:

Allow for a more elegant implementation of observer flares.
And still display flares even if the sender is lagging behind:
Split off flares from simulation commands.
Remove the new, problematic 'observer commands' entirely.
Provide an engine function 'SendNetworkFlare' to the JS interface.
-> which sets off the (pretty ordinary) transmission process.
Add a new type of net messages exclusively for flares
-> contains the flare's position and its sender's GUID.
This commit is contained in:
Vantha
2024-12-03 21:24:55 +01:00
committed by phosit
parent 75205699d0
commit 960bd5eace
11 changed files with 125 additions and 55 deletions
+13
View File
@@ -673,6 +673,7 @@ void CNetServerWorker::SetupSession(CNetServerSession* session)
session->AddTransition(NSS_INGAME, (uint)NMT_CONNECTION_LOST, NSS_UNCONNECTED, &OnDisconnect, session);
session->AddTransition(NSS_INGAME, (uint)NMT_CHAT, NSS_INGAME, &OnChat, session);
session->AddTransition(NSS_INGAME, (uint)NMT_SIMULATION_COMMAND, NSS_INGAME, &OnSimulationCommand, session);
session->AddTransition(NSS_INGAME, (uint)NMT_FLARE, NSS_INGAME, &OnFlare, session);
session->AddTransition(NSS_INGAME, (uint)NMT_SYNC_CHECK, NSS_INGAME, &OnSyncCheck, session);
session->AddTransition(NSS_INGAME, (uint)NMT_END_COMMAND_BATCH, NSS_INGAME, &OnEndCommandBatch, session);
@@ -1194,6 +1195,18 @@ bool CNetServerWorker::OnSimulationCommand(CNetServerSession* session, CFsmEvent
return true;
}
bool CNetServerWorker::OnFlare(CNetServerSession* session, CFsmEvent* event)
{
ENSURE(event->GetType() == (uint)NMT_FLARE);
CNetServerWorker& server = session->GetServer();
CFlareMessage* message = (CFlareMessage*)event->GetParamRef();
message->m_GUID = session->GetGUID();
server.Broadcast(message, { NSS_INGAME });
return true;
}
bool CNetServerWorker::OnSyncCheck(CNetServerSession* session, CFsmEvent* event)
{
ENSURE(event->GetType() == (uint)NMT_SYNC_CHECK);