The packet ids have for the most part a one-to-one correspondence with the expected output (all with the exception of three or four classes of packets). We can write a static mapping between packet id and handler. This eliminates the huge ugly select statement in main with
init_read_mapping();
...
if (!read_map[message[0]]) unknown_packet(...)
else rtn = read_map[message[0]](...);
or something to that effect. Since the functions are already in packet.h/c anyways, this just makes everything much easier.
The packet ids have for the most part a one-to-one correspondence with the expected output (all with the exception of three or four classes of packets). We can write a static mapping between packet id and handler. This eliminates the huge ugly select statement in main with
or something to that effect. Since the functions are already in packet.h/c anyways, this just makes everything much easier.