My 2D Top Down Online RPG
Posted: Tue Nov 08, 2011 5:49 pm
Hey, I'm going to throw this thread up to ask any things I'd like input on... such as a way of doing a certain thing.
Firstly, at the moment a client connects to the server, they can either send a packet to create an account, or login, should all the packets in ym game be encrypted, or would it be simpler to just encrypt the password before it sent and decrypted on the server side.
Also, at the moment this is how I handle my packets, I use SFML for the window manager, audio/input, and network modules. Here is a simple packet that is in my game.. [Just holds the type, for things such as the heartbeat, and what not.]
so I pass it an address of a sf::Packet and it appends itself to it, [append just add it to the char* of data the packet has, which can be later be sent to the server/client.
If a struct has many members, such as two ints, will they always be appended in the same way? I've looked into this and I inclined to say it happens in the way the variables are declared. Heres a disconnect packet.
Is this a good way to go about things? So each different packet would have a different struct?
Any input appreciated.
Thanks, Fouf.
Firstly, at the moment a client connects to the server, they can either send a packet to create an account, or login, should all the packets in ym game be encrypted, or would it be simpler to just encrypt the password before it sent and decrypted on the server side.
Also, at the moment this is how I handle my packets, I use SFML for the window manager, audio/input, and network modules. Here is a simple packet that is in my game.. [Just holds the type, for things such as the heartbeat, and what not.]
- Code: Select all
struct dataPacket
{
dataPacket(sf::Int8 type)
{
this->packetType = type;
}
void loadPacket(sf::Packet *packet)
{
packet->Clear();
packet->Append(this, sizeof(*this));
}
sf::Int8 packetType;
};
so I pass it an address of a sf::Packet and it appends itself to it, [append just add it to the char* of data the packet has, which can be later be sent to the server/client.
If a struct has many members, such as two ints, will they always be appended in the same way? I've looked into this and I inclined to say it happens in the way the variables are declared. Heres a disconnect packet.
- Code: Select all
struct disconnectPacket
{
disconnectPacket(sf::Int32 playerId)
{
this->packetType = DISCONNECT;
this->playerId = playerId;
}
void loadPacket(sf::Packet *packet)
{
packet->Clear();
packet->Append(this, sizeof(*this));
}
sf::Int8 packetType;
sf::Int32 playerId;
sf::Int8 errorType;
};
Is this a good way to go about things? So each different packet would have a different struct?
Any input appreciated.
Thanks, Fouf.