astrid
19.08.2006, 03:43
Written in lack of time. will work long time (very unoptimised algoritm, i too lazy to rewrite) and not 100% accurate becouse some quest names are different. But result better than emty strings in quest selection. also you must do search&replace for (in progress) string.
usage: in C:\ai\ put your ai and 2 txt files from pack. start software and wait about 1.5 hour :). in c:\ will be generated fixed ai.
rapid:http://rapidshare.de/files/29937170/aifixer.rar.html
have fun :)
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication3
{
public class Class1
{
public static void Main()
{
string[] AIArray=new string[4566333];
string path = @"c:\ai\ai.obj";
using (StreamReader sr = new StreamReader(path))
{
String line;
int i=0;
Console.WriteLine("Loading AI...");
while ((line = sr.ReadLine()) != null)
{
AIArray[i++]=line;
}
Console.WriteLine("Loading AI finished...");
}
string pathEN = @"c:\ai\QuestName-e.txt";
using (StreamReader sr = new StreamReader(pathEN))
{
String line;
string[] elements;
string buff="";
while ((line = sr.ReadLine()) != null)
{
elements=line.Split(" ".ToCharArray());
if (buff!=elements[3])
{
buff=elements[3];
string result=elements[3].Substring(7).TrimEnd("]".ToCharArray());
string source=GetCN(elements[1]).Substring(7).TrimEnd("]".ToCharArray());
//InAI(source,result);
int i=0;
foreach (string linei in AIArray)
{
if (AIArray[i]!=null)
{
if (Regex.IsMatch(AIArray[i],source))
{
AIArray[i]=Regex.Replace(AIArray[i],source,result);
}
}
++i;
}
Console.WriteLine("--- Quest "+elements[1]+" done ---");
}
}
//array to file
Console.WriteLine("Dumping fixed AI to file...");
FileStream fs=new FileStream("c:\\ai-fixed.txt", FileMode.Append, FileAccess.Write, FileShare.Write);
fs.Close();
StreamWriter sw=new StreamWriter("c:\\ai-fixed.txt", true, Encoding.Unicode);
foreach (string linei in AIArray)
{
sw.WriteLine(linei);
}
sw.Close();
Console.WriteLine("Done.");
}
}
public static string GetCN(string id)
{
string pathCN = @"c:\ai\QuestName-cn.txt";
using (StreamReader sr = new StreamReader(pathCN))
{
String line;
string[] elements;
while ((line = sr.ReadLine()) != null)
{
elements=line.Split(" ".ToCharArray());
if (elements[1]==id)
{
return elements[3];
}
}
return id;
}
}
}
}
usage: in C:\ai\ put your ai and 2 txt files from pack. start software and wait about 1.5 hour :). in c:\ will be generated fixed ai.
rapid:http://rapidshare.de/files/29937170/aifixer.rar.html
have fun :)
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication3
{
public class Class1
{
public static void Main()
{
string[] AIArray=new string[4566333];
string path = @"c:\ai\ai.obj";
using (StreamReader sr = new StreamReader(path))
{
String line;
int i=0;
Console.WriteLine("Loading AI...");
while ((line = sr.ReadLine()) != null)
{
AIArray[i++]=line;
}
Console.WriteLine("Loading AI finished...");
}
string pathEN = @"c:\ai\QuestName-e.txt";
using (StreamReader sr = new StreamReader(pathEN))
{
String line;
string[] elements;
string buff="";
while ((line = sr.ReadLine()) != null)
{
elements=line.Split(" ".ToCharArray());
if (buff!=elements[3])
{
buff=elements[3];
string result=elements[3].Substring(7).TrimEnd("]".ToCharArray());
string source=GetCN(elements[1]).Substring(7).TrimEnd("]".ToCharArray());
//InAI(source,result);
int i=0;
foreach (string linei in AIArray)
{
if (AIArray[i]!=null)
{
if (Regex.IsMatch(AIArray[i],source))
{
AIArray[i]=Regex.Replace(AIArray[i],source,result);
}
}
++i;
}
Console.WriteLine("--- Quest "+elements[1]+" done ---");
}
}
//array to file
Console.WriteLine("Dumping fixed AI to file...");
FileStream fs=new FileStream("c:\\ai-fixed.txt", FileMode.Append, FileAccess.Write, FileShare.Write);
fs.Close();
StreamWriter sw=new StreamWriter("c:\\ai-fixed.txt", true, Encoding.Unicode);
foreach (string linei in AIArray)
{
sw.WriteLine(linei);
}
sw.Close();
Console.WriteLine("Done.");
}
}
public static string GetCN(string id)
{
string pathCN = @"c:\ai\QuestName-cn.txt";
using (StreamReader sr = new StreamReader(pathCN))
{
String line;
string[] elements;
while ((line = sr.ReadLine()) != null)
{
elements=line.Split(" ".ToCharArray());
if (elements[1]==id)
{
return elements[3];
}
}
return id;
}
}
}
}