Code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace updateHeaders20150422
{
internal class Program
{
private static void Main(string[] args)
{
FileStream stream = new FileStream("GWA2.au3", FileMode.Open, FileAccess.ReadWrite);
FileStream stream2 = new FileStream("GWA2.new.au3", FileMode.Create, FileAccess.ReadWrite);
UTF8Encoding encoding = new UTF8Encoding(false);
StreamReader streamReader = new StreamReader(stream, encoding, false);
StreamWriter streamWriter = new StreamWriter(stream2, encoding);
streamWriter.AutoFlush = true;
List<string[]> list = new List<string[]>();
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x62C]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x690] ;from 0x62C"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4AC",
"$lOffset[3] = 0x510 ;from 0x4AC"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4A4",
"$lOffset[3] = 0x508 ;from 0x4A4"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x4]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x4] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x7C]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x7C] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0xCC]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0xCC] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0xF4]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0xF4] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x11C]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x11C] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x16C]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x16C] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x194]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x194] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x25C]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x25C] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x284]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x284] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x2AC]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x2AC] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x324]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x324] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x374]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x374] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x39C]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x39C] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x4DC]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x4DC] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x554]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x554] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x5F4]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x5F4] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x61C]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x61C] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x644]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x644] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x66C]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x66C] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x694]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x694] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x6BC]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x6BC] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x6E4]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x6E4] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x70C]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x70C] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x7B8, 0x734]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x81C, 0x734] ;from 0x7B8"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x6E4]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x748] ;from 0x6E4"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x754]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x7B8] ;from 0x754"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x6F4]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x758] ;from 0x6F4"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x758]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x7BC] ;from 0x758"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x734]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x798] ;from 0x734"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x75C]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x7C0] ;from 0x75C"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x708]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x76C] ;from 0x708"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x760]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x7C4] ;from 0x760"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x658, 0]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x6BC, 0] ;from 0x658"
});
list.Add(new string[]
{
"Local $lOffset[6] = [0, 0x18, 0x2C, 0x7A8, 76 * $lLogin + 0x28, 0]",
"Local $lOffset[6] = [0, 0x18, 0x2C, 0x80C, 76 * $lLogin + 0x28, 0] ;from 0x7A8"
});
list.Add(new string[]
{
"$lOffset[3] = 0x510 ;from 0x4AC",
"$lOffset[3] = 0x508 ;from 0x4A4"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4A4",
"$lOffset[3] = 0x508 ;from 0x4A4"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4AC",
"$lOffset[3] = 0x510 ;from 0x4AC"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4A4",
"$lOffset[3] = 0x508 ;from 0x4A4"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4AC",
"$lOffset[3] = 0x510 ;from 0x4AC"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4A4",
"$lOffset[3] = 0x508 ;from 0x4A4"
});
list.Add(new string[]
{
"$lOffset[3] = 0x68C",
"$lOffset[3] = 0x6F0 ;from 0x68C"
});
list.Add(new string[]
{
"$lOffset[3] = 0x5D4",
"$lOffset[3] = 0x638 ;from 0x5D4"
});
list.Add(new string[]
{
"$lOffset[3] = 0x5C8",
"$lOffset[3] = 0x62C ;from 0x5C8"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4AC",
"$lOffset[3] = 0x510 ;from 0x4AC"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4A4",
"$lOffset[3] = 0x508 ;from 0x4A4"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4A4",
"$lOffset[3] = 0x508 ;from 0x4A4"
});
list.Add(new string[]
{
"$lOffset[3] = 0xAC",
"$lOffset[3] = 0x110 ;from 0xAC"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x6DC]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x740] ;from 0x6DC"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x7e8]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x84C] ;from 0x7E8"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x7ec]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x850] ;from 0x7EC"
});
list.Add(new string[]
{
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x4D0]",
"Local $lOffset[4] = [0, 0x18, 0x2C, 0x534] ;from 0x4D0"
});
list.Add(new string[]
{
"$lOffset[3] = 0x4C4",
"$lOffset[3] = 0x528 ;from 0x4C4"
});
list.Add(new string[]
{
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x4C8, 0]",
"Local $lOffset[5] = [0, 0x18, 0x2C, 0x52C, 0] ;from 0x4C8"
});
string text;
while ((text = streamReader.ReadLine()) != null)
{
string text2 = text;
foreach (string[] current in list)
{
Regex regex = new Regex(Regex.Escape(current[0]));
if (regex.IsMatch(text))
{
Console.WriteLine("Converting: " + text);
text2 = text.Replace(current[0], current[1]);
Console.WriteLine("Converted to: " + text2);
break;
}
}
streamWriter.WriteLine(text2);
}
}
}
}