void FlattenDataTable(int serverClassIndex) { SendTable table = DataTables[ServerClasses[serverClassIndex].DataTableID]; CurrentExcludes.Clear(); CurrentBaseclasses = new List <ServerClass> (); //NOT .clear because we use *this* reference //LITERALLY 3 lines later. @main--, this is warning for you. GatherExcludesAndBaseclasses(table, true); ServerClasses [serverClassIndex].BaseClasses = CurrentBaseclasses; GatherProps(table, serverClassIndex, ""); var flattenedProps = ServerClasses[serverClassIndex].FlattenedProps; List <int> priorities = new List <int>(); priorities.Add(64); priorities.AddRange(flattenedProps.Select(a => a.Prop.Priority).Distinct()); priorities.Sort(); int start = 0; for (int priorityIndex = 0; priorityIndex < priorities.Count; priorityIndex++) { int priority = priorities[priorityIndex]; while (true) { int currentProp = start; while (currentProp < flattenedProps.Count) { SendTableProperty prop = flattenedProps[currentProp].Prop; if (prop.Priority == priority || (priority == 64 && prop.Flags.HasFlagFast(SendPropertyFlags.ChangesOften))) { if (start != currentProp) { FlattenedPropEntry temp = flattenedProps[start]; flattenedProps[start] = flattenedProps[currentProp]; flattenedProps[currentProp] = temp; } start++; break; } currentProp++; } if (currentProp == flattenedProps.Count) { break; } } } }
public static object DecodeProp(FlattenedPropEntry prop, IBitStream stream) { var sendProp = prop.Prop; switch (sendProp.Type) { case SendPropertyType.Int: return DecodeInt(sendProp, stream); case SendPropertyType.Float: return DecodeFloat(sendProp, stream); case SendPropertyType.Vector: return DecodeVector(sendProp, stream); case SendPropertyType.Array: var test = DecodeArray(prop, stream); return test; case SendPropertyType.String: return DecodeString(sendProp, stream); case SendPropertyType.VectorXY: return DecodeVectorXY(sendProp, stream); default: throw new NotImplementedException("Could not read property. Abort! ABORT!"); } }
public static object[] DecodeArray(FlattenedPropEntry flattenedProp, IBitStream reader) { int numElements = flattenedProp.Prop.NumberOfElements; int maxElements = numElements; int numBits = 1; while (( maxElements >>= 1 ) != 0) { numBits++; } int nElements = (int)reader.ReadInt(numBits); object[] result = new object[nElements]; FlattenedPropEntry temp = new FlattenedPropEntry("", flattenedProp.ArrayElementProp, null); for (int i = 0; i < nElements; i++) { result[i] = DecodeProp(temp, reader); } return result; }