public static ClientVersion Instantiate(ClientVersionStruct versionstruct) { if (!m_byVal.ContainsKey(versionstruct)) { m_byVal[versionstruct] = Instantiate(ToString(versionstruct)); } return(m_byVal[versionstruct]); }
/// <summary> /// Called when the server receives a packet that it cannot handle. /// </summary> /// <param name="pSocket">The servers socket which received the packet.</param> unsafe static bool OnHandleOutsideRangePacket(byte *pSocket) { //ClientSocket sock = new ClientSocket(pSocket); byte PacketID = *(pSocket + 0x28); uint PacketSize = 0; bool IsPacketDynamicSized = false; ClientVersionStruct ver = *(ClientVersionStruct *)(pSocket + 0x1003C); ClientVersion version; if (PacketID == 0xBB && ver < ClientVersion.v1_26_0) // detect client 1.26.0 { UODemo.ISocket socket = UODemo.Socket.Acquire(Server.Core, (struct_ServerSocket *)pSocket); //ClientSocket(pSocket); version = ClientVersion.v1_26_0; socket.SetClientVersion(version.Version); } else { version = ClientVersion.Instantiate(ver); } PacketVersionEntry packetinfo = PacketVersions.GetPacketInfo(PacketID, version); if (packetinfo == null) { ConsoleUtils.PushColor(ConsoleColor.Red); Console.WriteLine("WARNING: Ignored Invalid Packet {0:X2}.", PacketID); ConsoleUtils.PopColor(); return(false); } else { //case 0xB6: PacketSize = 9; IsPacketDynamicSized = false; break; //case 0xB8: PacketSize = 0; IsPacketDynamicSized = true; break; //case 0xBB: PacketSize = 9; IsPacketDynamicSized = false; break; //case 0xBD: PacketSize = 0; IsPacketDynamicSized = true; break; //default: PacketSize = packetinfo.Length; IsPacketDynamicSized = packetinfo.Dynamic; if (MyServerConfig.PacketDebug) { Console.WriteLine("Handling Invalid Packet {0:X2} from client version {1}", PacketID, version); } OnPacketReceived(pSocket, PacketID, PacketSize, IsPacketDynamicSized ? -1 : 0); return(true); } }
public static string ToString(ClientVersionStruct Version) { if (Version < v5_0_7_0) { if (Version.Revision <= 0) { return(string.Format("{0}.{1}.{2}", Version.Major, Version.Minor, Version.Build)); } else { return(string.Format("{0}.{1}.{2}{3}", Version.Major, Version.Minor, Version.Build, (char)((ushort)'a' + Version.Revision - 1))); } } return(string.Format("{0}.{1}.{2}.{3}", Version.Major, Version.Minor, Version.Build, Version.Revision)); }
public static ClientVersionStruct Parse(string VersionString) { ClientVersionStruct ver = new ClientVersionStruct(); string[] parts = VersionString.Split('.'); byte n; if (parts.Length >= 1 && byte.TryParse(parts[0], out n)) { ver.Major = n; if (parts.Length >= 2 && byte.TryParse(parts[1], out n)) { ver.Minor = n; if (parts.Length >= 3) { // The third section is tricky, version such as 2.0.0g1 may be possible in versions below 5.0.7.0 if (byte.TryParse(parts[2], out n)) { // easy ver.Build = n; if (parts.Length >= 4 && byte.TryParse(parts[3], out n)) { ver.Revision = n; } } else { // not as easy // Find non-numeric character in string int i = 0; while (i < parts[2].Length && char.IsDigit(parts[2][i])) { i++; } if (i > 0 && byte.TryParse(parts[2].Substring(0, i), out n)) // extract the number { ver.Build = n; if (char.IsLetter(parts[2][i])) // extract the letter { ver.Revision = (byte)(ASCIIEncoding.ASCII.GetBytes(parts[2].Substring(i, 1))[0] - (byte)'a' + 1); // Ignoring sub revision which occurs in two client versions. Example: 2.0.0e1, 4.0.4b2 } } } } } } return(ver); }
public void SetClientVersion(ClientVersionStruct vStruct) { Socket.SetClientVersion(vStruct); }
public MockClient_00_CreateCharater(ClientVersionStruct version) : base(0x00, version >= ClientVersion.v1_26_0 ? v1_26_0len : expectedLen) { }
public static uint ToLong(ClientVersionStruct clientversion) { return((uint)(clientversion.Major << 24) + (uint)(clientversion.Minor << 16) + (uint)(clientversion.Build << 8) + clientversion.Revision); }