Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!
Thanks for the reply. I already have a packet handling system with a simple function pointer array (handlers[opcode](params)) so execute function might be inapplicable. I'm not sure which one is better though, having the factory inside the base class or basically having an external factory which would take required data and return a NetworkMessage which is basically an std::vector<unsigned char> . Second option would save me from writing all those derived classes(considering there're over a 100 packets it feels second option might have an advantage).
Obiective programming is about beauty, and extensibility. To add new packet all you do is create new implementation (yes there will be a LOT of derived classes but also the same ammount of them in any other way of handling it) and add it to factory. Tell me about your handlers[opcode](params). What if one packet sends a single int (lets say, quest ID accepted), and other packet sends a 3 ints (xyz update)? In C++ it impossible to create array of function pointers with different ammount/type of arguments, how do you solve the issue? If u cast, then its bad already. Take a look at java implementation of packet handling in Lineage2 server. It is decent: