From 6244a2f7a4e5fef68ae1300d5c944747dcd32ab0 Mon Sep 17 00:00:00 2001 From: IonutParau Date: Thu, 9 Apr 2026 11:12:16 +0200 Subject: [PATCH] figured out how to do smth --- src/netlib.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/netlib.h b/src/netlib.h index 9a908a1..82d451e 100644 --- a/src/netlib.h +++ b/src/netlib.h @@ -28,7 +28,7 @@ typedef struct net_RadioMessageData { typedef struct net_NetworkLimits { // maximum radio lifespan in ticks size_t maxRadioLifespan; - // radio speed in coordinates per second + // radio speed in coordinates per tick double radioSpeed; // maximum connections in a device size_t maxConnections; @@ -52,6 +52,15 @@ typedef struct net_DevicePosition { double x, y, z; } net_DevicePosition; +typedef struct net_RadioPacket { + net_DevicePosition initialPosition; + size_t tickSpawned; + // the tick at which it is dead + size_t expirationTick; + char *data; + size_t datalen; +} net_Radiopacket; + typedef enum net_MessagePropagation { // direct connections NET_MESSAGE_DIRECT, @@ -141,6 +150,17 @@ size_t net_countNetworkDevices(net_Network *network); // If running stuff on multiple threads, MAKE SURE THE NETWORK IS LOCKED. THIS IS VERY IMPORTANT void net_getNetworkDevices(net_Network *network, net_Device **devices); +size_t net_getNetworkTickCount(net_Network *network); +// increase the tick count by 1 +// this will also delete dead radio packets +void net_incNetworkTickCount(net_Network *network); +// set it to 0 +void net_resetNetworkTickCount(net_Network *network); + +void net_spawnRadioPacket(net_Network *network); +size_t net_countRadioPackets(net_Network *network); +void net_getRadioPackets(net_Network *network, net_RadioPacket *packets); + // network devices // a simple non-rewriting relay, which does not contribute to the hop counter