public ParseNano ( int recnum, byte data, string sqlFile ) : ZoneEngine.GameObject.Nanos.NanoFormula | ||
recnum | int | /// The recnum. /// |
data | byte | /// The data. /// |
sqlFile | string | /// The sql file. /// |
return | ZoneEngine.GameObject.Nanos.NanoFormula |
public NanoFormula ParseNano(int recnum, byte[] data, string sqlFile)
{
this.br = new BufferedReader((int)Extractor.RecordType.Nano, recnum, data);
NanoFormula aon = new NanoFormula();
aon.ID = recnum;
this.br.Skip(16);
int numberOfAttributes = this.br.Read3F1() - 1;
int counter = 0;
while (true)
{
if (counter > numberOfAttributes)
{
break;
}
int attrkey = this.br.ReadInt32();
int attrval = this.br.ReadInt32();
if (attrkey == 54)
{
aon.Stats.Add(attrkey, attrval);
}
else
{
aon.Stats.Add(attrkey, attrval);
}
counter++;
}
this.br.Skip(8);
short nameLength = this.br.ReadInt16();
short descriptionLength = this.br.ReadInt16();
if (nameLength > 0)
{
this.br.ReadString(nameLength);
}
if (descriptionLength > 0)
{
this.br.ReadString(descriptionLength); // Read and discard Description
}
bool flag4 = true;
checked
{
while (this.br.Ptr < this.br.Buffer.Length - 8 && flag4)
{
switch (this.br.ReadInt32())
{
case 2:
this.ParseFunctionSet(aon.Events);
break;
case 3:
case 5:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 15:
case 16:
case 17:
case 18:
case 19:
case 21:
goto IL_4BF;
case 4:
this.ParseAtkDefSet(aon.Attack, aon.Defend);
break;
case 6:
{
this.br.Skip(4);
int count = this.br.Read3F1() * 8;
this.br.Skip(count);
break;
}
case 14:
this.ParseAnimSoundSet(1, null);
break;
case 20:
this.ParseAnimSoundSet(2, null);
break;
case 22:
this.ParseActionSet(aon.Actions);
break;
case 23:
this.ParseShopHash(aon.Events);
break;
default:
goto IL_4BF;
}
continue;
IL_4BF:
flag4 = false;
}
}
return aon;
}
/// <summary> /// </summary> /// <returns> /// </returns> private static List <NanoFormula> ReadNanoFormulas() { var np = new NewParser(); List <NanoFormula> rawNanoList = new List <NanoFormula>(); int counter = 0; foreach (int recnum in extractor.GetRecordInstances(Extractor.RecordType.Nano)) { if (counter == 0) { counter = recnum; } byte[] data = extractor.GetRecordData(Extractor.RecordType.Nano, recnum); NanoFormula nano = np.ParseNano(recnum, data, "temp.sql"); rawNanoList.Add(nano); if ((counter % 2000) == 0) { Console.Write("\rNano ID: " + recnum.ToString().PadLeft(9)); } counter++; } Console.Write("\rNano ID: " + rawNanoList[rawNanoList.Count - 1].ID.ToString().PadLeft(9)); File.Delete("temp.sql"); return(rawNanoList); }