public void saveWriter(EexBinaryWriter writer) { computeExValue(writer); int sectionStart = writer.getIndex(); writer.writeUShort(0); for (int i = 0; i < commandList.Count; i++) { ScriptCommand cmd = commandList[i]; writer.writeUShort((ushort)cmd.Id); cmd.saveWriter(writer); if (cmd.isExtValueAvailable()) { writer.writeUShort((ushort)cmd.getExtValue()); } } int sectionEnd = writer.getIndex(); writer.setIndex(sectionStart).writeUShort((ushort)(sectionEnd - sectionStart - 2)); writer.setIndex(sectionEnd); }
public void computeExValue(EexBinaryWriter writer) { int writerIndex = writer.getIndex(); for (int i = 0; i < commandList.Count; i++) { if (!commandList[i].isExtValueAvailable()) { continue; } int level = 1; writer.setIndex(writerIndex); for (int j = i + 1; j < commandList.Count; j++) { ScriptCommand cmd = commandList[j]; if (cmd.isExtValueAvailable()) { level++; } writer.writeUShort((ushort)cmd.Id); cmd.saveWriter(writer); if (cmd.isExtValueAvailable()) { writer.writeUShort((ushort)cmd.getExtValue()); } if (cmd.Id == (int)CommandId.CMD_ACTION_END) { level--; if (level == 0) { break; } } } commandList[i].setExtValue(writer.getIndex() - writerIndex); } writer.setIndex(writerIndex); }