public static ItemConfig[] ParseItemConfig(byte[] data, byte[] index) { BigEndianBinaryReader dataReader = new BigEndianBinaryReader(new MemoryStream(data)); BigEndianBinaryReader indexReader = new BigEndianBinaryReader(new MemoryStream(index)); int totalItems = indexReader.ReadUInt16(); int[] streamIndices = new int[totalItems]; ItemConfig[] itemConfig = new ItemConfig[totalItems]; int i = 2; for (int j = 0; j < totalItems; j++) { streamIndices[j] = i; i += indexReader.ReadUInt16(); } for (int x = 0; x < totalItems; x++) { dataReader.BaseStream.Position = streamIndices[x]; ItemConfig item = new ItemConfig(); do { int opCode = dataReader.ReadByte(); if (opCode == 0) { break; } if (opCode == 1) { item.modelID = dataReader.ReadUInt16(); } else if (opCode == 2) { item.name = dataReader.ReadString().TrimEnd('\n'); } else if (opCode == 3) { item.description = dataReader.ReadString().TrimEnd('\n'); } else if (opCode == 4) { item.modelInvZoom = dataReader.ReadUInt16(); } else if (opCode == 5) { item.modelInvRotationY = dataReader.ReadUInt16(); } else if (opCode == 6) { item.modelInvRotationX = dataReader.ReadUInt16(); } else if (opCode == 7) { item.modelInvPosOffsetX = dataReader.ReadUInt16(); if (item.modelInvPosOffsetX > 32767) { item.modelInvPosOffsetX -= 0x10000; } } else if (opCode == 8) { item.modelInvPosOffsetY = dataReader.ReadUInt16(); if (item.modelInvPosOffsetY > 32767) { item.modelInvPosOffsetY -= 0x10000; } } else if (opCode == 10) { dataReader.ReadUInt16(); } else if (opCode == 11) { item.stackable = true; } else if (opCode == 12) { item.value = dataReader.ReadInt32(); } else if (opCode == 16) { item.membersObject = true; } else if (opCode == 23) { item.maleWornModelID = dataReader.ReadUInt16(); item.maleYOffset = dataReader.ReadByte(); } else if (opCode == 24) { item.maleArmsID = dataReader.ReadUInt16(); } else if (opCode == 25) { item.femaleWornModelID = dataReader.ReadUInt16(); item.femaleYOffset = dataReader.ReadByte(); } else if (opCode == 26) { item.femaleArmsID = dataReader.ReadUInt16(); } else if (opCode >= 30 && opCode < 35) { if (item.groundActions == null) { item.groundActions = new string[5]; } item.groundActions[opCode - 30] = dataReader.ReadString().TrimEnd('\n'); if (item.groundActions[opCode - 30].ToLower() == "hidden") { item.groundActions[opCode - 30] = null; } } else if (opCode >= 35 && opCode < 40) { if (item.actions == null) { item.actions = new string[5]; } item.actions[opCode - 35] = dataReader.ReadString().TrimEnd('\n'); } else if (opCode == 40) { int colors = dataReader.ReadByte(); item.originalModelColors = new int[colors]; item.modifiedModelColors = new int[colors]; for (int colorPtr = 0; colorPtr < colors; colorPtr++) { item.originalModelColors[colorPtr] = dataReader.ReadUInt16(); item.modifiedModelColors[colorPtr] = dataReader.ReadUInt16(); } } else if (opCode == 78) { item.maleEmblem = dataReader.ReadUInt16(); } else if (opCode == 79) { item.femaleEmblem = dataReader.ReadUInt16(); } else if (opCode == 90) { item.maleDialog = dataReader.ReadUInt16(); } else if (opCode == 91) { item.femaleDialog = dataReader.ReadUInt16(); } else if (opCode == 92) { item.maleDialogHat = dataReader.ReadUInt16(); } else if (opCode == 93) { item.femaleDialogHat = dataReader.ReadUInt16(); } else if (opCode == 95) { item.diagonalRotation = dataReader.ReadUInt16(); } else if (opCode == 97) { item.certID = dataReader.ReadUInt16(); } else if (opCode == 98) { item.certTemplateID = dataReader.ReadUInt16(); } else if (opCode >= 100 && opCode < 110) { if (item.stackIDs == null) { item.stackIDs = new int[10]; item.stackAmounts = new int[10]; } item.stackIDs[opCode - 100] = dataReader.ReadUInt16(); item.stackAmounts[opCode - 100] = dataReader.ReadUInt16(); } else if (opCode == 110) { item.modelSizeX = dataReader.ReadUInt16(); } else if (opCode == 111) { item.modelSizeY = dataReader.ReadUInt16(); } else if (opCode == 112) { item.modelSizeZ = dataReader.ReadUInt16(); } else if (opCode == 113) { item.lightModifier = dataReader.ReadUInt16(); } else if (opCode == 114) { item.shadowModifier = dataReader.ReadByte() * 5; } else if (opCode == 115) { item.team = dataReader.ReadByte(); } else if (opCode == 116) { item.lendID = dataReader.ReadUInt16(); } else if (opCode == 117) { item.lentItemID = dataReader.ReadUInt16(); } else { Logger.Log("Unknown Item Opcode: " + opCode, LogType.Error); } } while (true); itemConfig[x] = item; } return(itemConfig); }
public static ItemConfig[] ParseItemConfig(byte[] data, byte[] index) { BigEndianBinaryReader dataReader = new BigEndianBinaryReader(new MemoryStream(data)); BigEndianBinaryReader indexReader = new BigEndianBinaryReader(new MemoryStream(index)); int totalItems = indexReader.ReadUInt16(); int[] streamIndices = new int[totalItems]; ItemConfig[] itemConfig = new ItemConfig[totalItems]; int i = 2; for (int j = 0; j < totalItems; j++) { streamIndices[j] = i; i += indexReader.ReadUInt16(); } for (int x = 0; x < totalItems; x++) { dataReader.BaseStream.Position = streamIndices[x]; ItemConfig item = new ItemConfig(); do { int opCode = dataReader.ReadByte(); if (opCode == 0) break; if (opCode == 1) item.modelID = dataReader.ReadUInt16(); else if (opCode == 2) item.name = dataReader.ReadString().TrimEnd('\n'); else if (opCode == 3) item.description = dataReader.ReadString().TrimEnd('\n'); else if (opCode == 4) item.modelInvZoom = dataReader.ReadUInt16(); else if (opCode == 5) item.modelInvRotationY = dataReader.ReadUInt16(); else if (opCode == 6) item.modelInvRotationX = dataReader.ReadUInt16(); else if (opCode == 7) { item.modelInvPosOffsetX = dataReader.ReadUInt16(); if (item.modelInvPosOffsetX > 32767) item.modelInvPosOffsetX -= 0x10000; } else if (opCode == 8) { item.modelInvPosOffsetY = dataReader.ReadUInt16(); if (item.modelInvPosOffsetY > 32767) item.modelInvPosOffsetY -= 0x10000; } else if (opCode == 10) dataReader.ReadUInt16(); else if (opCode == 11) item.stackable = true; else if (opCode == 12) item.value = dataReader.ReadInt32(); else if (opCode == 16) item.membersObject = true; else if (opCode == 23) { item.maleWornModelID = dataReader.ReadUInt16(); item.maleYOffset = dataReader.ReadByte(); } else if (opCode == 24) item.maleArmsID = dataReader.ReadUInt16(); else if (opCode == 25) { item.femaleWornModelID = dataReader.ReadUInt16(); item.femaleYOffset = dataReader.ReadByte(); } else if (opCode == 26) item.femaleArmsID = dataReader.ReadUInt16(); else if (opCode >= 30 && opCode < 35) { if (item.groundActions == null) item.groundActions = new string[5]; item.groundActions[opCode - 30] = dataReader.ReadString().TrimEnd('\n'); if (item.groundActions[opCode - 30].ToLower() == "hidden") item.groundActions[opCode - 30] = null; } else if (opCode >= 35 && opCode < 40) { if (item.actions == null) item.actions = new string[5]; item.actions[opCode - 35] = dataReader.ReadString().TrimEnd('\n'); } else if (opCode == 40) { int colors = dataReader.ReadByte(); item.originalModelColors = new int[colors]; item.modifiedModelColors = new int[colors]; for (int colorPtr = 0; colorPtr < colors; colorPtr++) { item.originalModelColors[colorPtr] = dataReader.ReadUInt16(); item.modifiedModelColors[colorPtr] = dataReader.ReadUInt16(); } } else if (opCode == 78) item.maleEmblem = dataReader.ReadUInt16(); else if (opCode == 79) item.femaleEmblem = dataReader.ReadUInt16(); else if (opCode == 90) item.maleDialog = dataReader.ReadUInt16(); else if (opCode == 91) item.femaleDialog = dataReader.ReadUInt16(); else if (opCode == 92) item.maleDialogHat = dataReader.ReadUInt16(); else if (opCode == 93) item.femaleDialogHat = dataReader.ReadUInt16(); else if (opCode == 95) item.diagonalRotation = dataReader.ReadUInt16(); else if (opCode == 97) item.certID = dataReader.ReadUInt16(); else if (opCode == 98) item.certTemplateID = dataReader.ReadUInt16(); else if (opCode >= 100 && opCode < 110) { if (item.stackIDs == null) { item.stackIDs = new int[10]; item.stackAmounts = new int[10]; } item.stackIDs[opCode - 100] = dataReader.ReadUInt16(); item.stackAmounts[opCode - 100] = dataReader.ReadUInt16(); } else if (opCode == 110) item.modelSizeX = dataReader.ReadUInt16(); else if (opCode == 111) item.modelSizeY = dataReader.ReadUInt16(); else if (opCode == 112) item.modelSizeZ = dataReader.ReadUInt16(); else if (opCode == 113) item.lightModifier = dataReader.ReadUInt16(); else if (opCode == 114) item.shadowModifier = dataReader.ReadByte() * 5; else if (opCode == 115) item.team = dataReader.ReadByte(); else if (opCode == 116) item.lendID = dataReader.ReadUInt16(); else if (opCode == 117) item.lentItemID = dataReader.ReadUInt16(); else Logger.Log("Unknown Item Opcode: " + opCode, LogType.Error); } while (true); itemConfig[x] = item; } return itemConfig; }