public object ReadObject(L2ObjType objType) { if (objType == L2ObjType.ObjectRef) { var id = ReadInt32(); return(Objects[id]); } return(ReadObject((int)objType)); }
public string ReadIdString(L2ObjType type = L2ObjType.Unknown) { var objType = ReadNumber(); if (type != L2ObjType.Unknown && objType != (int)type) { throw new ArgumentException($"Type mismatch: Expect {type}({(int) type}) , Actual {objType}"); } if (objType == (int)L2ObjType.ObjectRef) { var id = ReadInt32(); //WTF bad design return(Objects[id]?.ToString()); //can be null, will be the first null in the list } string obj = null; switch (objType) { case (int)L2ObjType.Null: break; case (int)L2ObjType.DrawDataID: obj = ReadUTF8String(); break; case (int)L2ObjType.BaseDataID: obj = ReadUTF8String(); break; case (int)L2ObjType.PartsDataID: obj = ReadUTF8String(); break; case (int)L2ObjType.ParamID: obj = ReadUTF8String(); break; case (int)L2ObjType.String: obj = ReadUTF8String(); break; default: throw new ArgumentOutOfRangeException("", $"Type is not a ID: {objType}"); } Objects.Add(obj); return(obj); }