I have been thinking, and to me it seems that a lot of the packet handlers (especially LOTF) are pretty large. Would it take up more resources to do something more dynamic such as the following? This is just an example obviously. But the main concept is there. The void would be your PacketID, the Arg1 would be your data[]. And it simply calls the method immediately rather then going through a case?
Code:
class Program
{
static void Main(string[] args)
{
string Void = Convert.ToString(Console.ReadLine());
string Arg1 = Convert.ToString(Console.ReadLine());
object[] Args = new object[1];
Args[0] = Arg1;
try
{
typeof(Program).InvokeMember(Void, BindingFlags.InvokeMethod, null, null, Args);
}
catch
{
Console.WriteLine("Missing Packet Handler " + Void);
}
Console.ReadKey();
}
public static void Chat(string Arg1)
{
Console.WriteLine("Chat Handler " + Arg1);
}
public static void General()
{
Console.WriteLine("General Data Handler");
}
}