29 Mar
2008
29 Mar
'08
8:21 p.m.
AMDG Robert Dailey wrote:
Is there any reason why the ID needs to be available at runtime? Instead of your specialization, I do:
class WalkPacket : Packet { static const PacketId ID = PID_WALKPACKET; };
Is there any reason why this isn't sufficient?
The dispatcher needs to know what the ID of a packet is to do its job. The idea is that instead of passing the ID and the packet separately, the packet knows its own ID. It is possible, though to replace the ID type with std::string in the dispatcher and use std::string(typeid(packet).name()) avoiding the ID's entirely inside the dispatcher. In Christ, Steven Watanabe