FloooD / custom_cs2dsrv

Jermuk's custom Counter Strike 2D Server written in C and modified by FloooD and leegao.
173.192.35.85:36000
3 stars 0 forks source link

Static mapping onto functions for the input reading #8

Closed leegao closed 13 years ago

leegao commented 13 years ago

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.

leegao commented 13 years ago

currently working on this.

leegao commented 13 years ago

k, patched in the experimental branch