Stardew Engine
Loading...
Searching...
No Matches
Game2DLayerNetwork.c File Reference
#include <string.h>
#include "Game2DLayerNetwork.h"
#include "Log.h"
#include "Network.h"
#include "BinarySerializer.h"
#include "AssertLib.h"
#include "DynArray.h"
#include "Entities.h"
#include "Game2DLayer.h"
#include "NetworkID.h"
#include "GameFramework.h"
#include <stdbool.h>
Include dependency graph for Game2DLayerNetwork.c:

Data Structures

struct  GameThreadClientConnection
 
struct  StateUpdateItr_Ctx
 
struct  Game2DLayerWorldstatePacketHeader
 
struct  IsNetIdTakenIteratorContext
 
struct  FindWithNetIdIteratorContext
 

Functions

void G2D_PollNetworkQueueServer (struct GameFrameworkLayer *pLayer, float deltaT)
 
void G2D_PollNetworkQueueClient (struct GameFrameworkLayer *pLayer, float deltaT)
 
void G2D_Extend_RequestLevelDataMessage (PacketExtensionNoArgsFn fn)
 extend the packet that the client sends to request level data from the server. By default tile maps and serialized entities are included, this callback is called before this Game2DLayer managed level data is serialized - see WfNetwork.c
 
void G2D_Enqueue_RequestLevelData ()
 TODO: should really be static to this file, probably.
 
enum G2DPacketType G2D_ParsePacket (u8 *pPacket, u8 **pOutBody, int *outHeaderSize)
 
void G2D_Enqueue_Worldstate_Packet (struct GameLayer2DData *pData, int clientI)
 Enqueue a packet that will cause all entities with bSerializeInNetworkUpdate == true to be saved into a packet, the serializer context will be SCTX_NetworkUpdate.
 
enum Game2DRPCType G2D_ParseRPCPacket (u8 *packet, u8 **pOutBody)
 
bool IsNetIDTakenIterator (struct Entity2D *pEnt, int i, void *pUser)
 
struct Entity2DG2D_FindEntityWithNetID (struct Entity2DCollection *pCollection, int netID)
 try to find the entity with a given net ID
 
void G2D_SendRPC (int client, enum Game2DRPCType type, void *pRPCData)
 Send an RPC.
 
void G2D_DoRPC (struct GameFrameworkLayer *pLayer, struct GameLayer2DData *pData, u8 *pRPCData, int client)
 do RPCs, call once a packet has been confirmed as a G2DPacket_RPC, call on both client and server
 
bool G2D_IsClientConnected (int i)
 call from the game thread if you're the server to determine if a client is connected
 

Function Documentation

◆ G2D_DoRPC()

void G2D_DoRPC ( struct GameFrameworkLayer pLayer,
struct GameLayer2DData pData,
u8 pRPCData,
int  client 
)

do RPCs, call once a packet has been confirmed as a G2DPacket_RPC, call on both client and server

Parameters
pData
pRPCData
clientthe number of the client who has sent the RPC, or -1 if the server has sent it and you are a client

◆ G2D_Enqueue_RequestLevelData()

void G2D_Enqueue_RequestLevelData ( )

TODO: should really be static to this file, probably.

◆ G2D_Enqueue_Worldstate_Packet()

void G2D_Enqueue_Worldstate_Packet ( struct GameLayer2DData pData,
int  clientI 
)

Enqueue a packet that will cause all entities with bSerializeInNetworkUpdate == true to be saved into a packet, the serializer context will be SCTX_NetworkUpdate.

Parameters
pDataThe Game2dLayer
clientIThe client index to send to - only relevant if you're the server

◆ G2D_Extend_RequestLevelDataMessage()

void G2D_Extend_RequestLevelDataMessage ( PacketExtensionNoArgsFn  fn)

extend the packet that the client sends to request level data from the server. By default tile maps and serialized entities are included, this callback is called before this Game2DLayer managed level data is serialized - see WfNetwork.c

Parameters
fncallback to call

◆ G2D_FindEntityWithNetID()

struct Entity2D * G2D_FindEntityWithNetID ( struct Entity2DCollection pCollection,
int  netID 
)

try to find the entity with a given net ID

Parameters
pCollectioncollection to search
netIDnetID to search for
Returns
NULL if not found

◆ G2D_IsClientConnected()

bool G2D_IsClientConnected ( int  i)

call from the game thread if you're the server to determine if a client is connected

Parameters
i
Returns

◆ G2D_ParsePacket()

enum G2DPacketType G2D_ParsePacket ( u8 pPacket,
u8 **  pOutBody,
int *  outHeaderSize 
)

◆ G2D_ParseRPCPacket()

enum Game2DRPCType G2D_ParseRPCPacket ( u8 packet,
u8 **  pOutBody 
)
Parameters
packet
pOutBody

◆ G2D_PollNetworkQueueClient()

void G2D_PollNetworkQueueClient ( struct GameFrameworkLayer pLayer,
float  deltaT 
)

◆ G2D_PollNetworkQueueServer()

void G2D_PollNetworkQueueServer ( struct GameFrameworkLayer pLayer,
float  deltaT 
)

◆ G2D_SendRPC()

void G2D_SendRPC ( int  client,
enum Game2DRPCType  type,
void *  pRPCData 
)

Send an RPC.

Parameters
clientclient to send to - send -1 if you're a client yourself
typetype of rpc to send
pRPCDataa struct appropriate to construct the rpc message - see src

◆ IsNetIDTakenIterator()

bool IsNetIDTakenIterator ( struct Entity2D pEnt,
int  i,
void *  pUser 
)