Platform Data Engine 0.0.1
A data-driven game engine for platformers
PlatformDataEngine::PDEPacket Class Reference

How networking works: The server will spawn the entire world and start a simulation, it will send out spawn game object packets to all of it's clients to replicate the same world on their computers, the server will then spawn player game objects for each client that is connected and send out "BindPlayer" packets to the clients, this will tell the client which game object it is controlling (for things like the camera controller) More...

#include <Packet.h>

Inheritance diagram for PlatformDataEngine::PDEPacket:

Public Types

enum  PFlag {
  None , Ping , Pong , Connect ,
  Disconnect , Connected , Disconnected , Text ,
  SetObjectHealth , RequestUpdates , SendUpdates , UserInput
}
 

Public Member Functions

 PDEPacket ()
 
 PDEPacket (PFlag)
 
void setFlag (PFlag)
 
PFlag flag () const
 
sf::Uint8 flagAsU () const
 
bool isFlagged () const
 
virtual void clear ()
 

Detailed Description

How networking works: The server will spawn the entire world and start a simulation, it will send out spawn game object packets to all of it's clients to replicate the same world on their computers, the server will then spawn player game objects for each client that is connected and send out "BindPlayer" packets to the clients, this will tell the client which game object it is controlling (for things like the camera controller)

When a client gets user input, instead of updating the position of it's local game object, since it's a client, it will send a "UserInput" packet to the server, the server will simulate 1 step of input and send the resulting game object positions and any other relavent data to the client

So in this system, the server is completely authoritative, the clients will simply be puppeted by the server and the inputs they send to the server will simply be Button or Axis values that the server will interperate and send position data back for.

Member Enumeration Documentation

◆ PFlag

Enumerates the possible flags a packet can have. It will be automatically sent and received when using this class for sharing data across sockets. Feel free to extend this enumeration to match your need.

Constructor & Destructor Documentation

◆ PDEPacket() [1/2]

PDEPacket::PDEPacket ( )

Default constructor.

◆ PDEPacket() [2/2]

PDEPacket::PDEPacket ( PFlag  flag)

Overloaded constructor. Constructs a Packet and sets the flag as specified.

Member Function Documentation

◆ clear()

void PDEPacket::clear ( )
virtual

Hiding base class clear() function. Clears the packet as usual and sets the flag to 'None', so isFlagged() will return false.

◆ flag()

PFlag PlatformDataEngine::PDEPacket::flag ( ) const
inline

Reads the flag.

◆ flagAsU()

sf::Uint8 PlatformDataEngine::PDEPacket::flagAsU ( ) const
inline

Reads the flag as an 8 bytes unsigned int.

◆ isFlagged()

bool PlatformDataEngine::PDEPacket::isFlagged ( ) const
inline

Checks if a flag has been set on this Packet. Returns false if flag equals to PDEPacket::None.

◆ setFlag()

void PDEPacket::setFlag ( PFlag  flag)

Sets the flag to the packet


The documentation for this class was generated from the following files: