Hello people. I'm working on an emulator and I need some advice on how to serialize packets. The way I've been storing packet data until now is:
NetworkMessage is a simple class that wraps std::vector<BYTE> with some useful functions and operators. characterID is a 32 bit unsigned integer. Is there a better way of doing this in terms of cleaner code and better performance?
Code:
NetworkMessage packet = { // Header and stuff
(BYTE)(characterID & 0xFF),
(BYTE)((characterID >> 8) & 0xFF),
(BYTE)((characterID >> 16) & 0xFF),
(BYTE)((characterID >> 24) & 0xFF),
// Rest of packet
};
NetworkMessage is a simple class that wraps std::vector<BYTE> with some useful functions and operators. characterID is a 32 bit unsigned integer. Is there a better way of doing this in terms of cleaner code and better performance?
Last edited: