public void saveWriter(EexBinaryWriter writer, int group) { cmdIndexList.Clear(); computeExValue(writer, group); int sectionStart = writer.getIndex(); writer.writeUShort(0); for (int i = 0; i < commandList.Count; i++) { ScriptCommand cmd = commandList[i]; int cmdIndex = writer.getIndex(); writer.writeUShort((ushort)cmd.Id); cmd.saveWriter(writer, group); if (cmd.isExtValueAvailable()) { writer.writeUShort((ushort)cmd.getExtValue()); } cmdIndexList.Add(cmdIndex); } int sectionEnd = writer.getIndex(); writer.setIndex(sectionStart).writeUShort((ushort)(sectionEnd - sectionStart - 2)); writer.setIndex(sectionEnd); }
public void computeExValue(EexBinaryWriter writer, int group) { 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, group); 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); }
public void saveNewWriter(EexBinaryWriter 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, 0); if (cmd.isExtValueAvailable()) { writer.writeUShort((ushort)cmd.getExtValue()); } } int sectionEnd = writer.getIndex(); writer.setIndex(sectionStart).writeUShort((ushort)commandList.Count); writer.setIndex(sectionEnd); }