~mindsharing~ (C# snippets, Parse some lod files)
#1

hi Big Grin i wanna share an C# class maybe anyone can build some nice stuff with it

 

in this class are 3 Functions, and 3 structs

 

parse/struct for Itemname.lod, mobname.lod and options.lod

 

i think its already known how to read this files, ok here the class Smile

 

class ParseLod
{

//parse itemname.lod

public struct Item
{
public int ID;
public string Name;
public string Description;
public string ToString()
{
return ID + "\t" + Name + "\t" + Description;
}
}

public static Mob[] mobname(string path)
{
byte[] bytes = File.ReadAllBytes(path);
long len = bytes.Length;
long i = 0;
int i2 = 0;
long i3 = 0;
int namelen;
string mobname;
Mob[] parse = new Mob[0];
do
{
Array.Resize(ref parse, (int)i3 + 1);
parse[i3].ID = (bytes[i + 4] + (bytes[i + 5] * 256) + (bytes[i + 6] * 256) + (bytes[i + 7] * 256));
namelen = (bytes[i + 8] + bytes[i + 9] + bytes[i + 10] + bytes[i + 11]);
mobname = "";
i2 = 1;
while (i2 < namelen + 1)
{
i2++;
mobname = mobname + (char)(bytes[i + 10 + i2]);
}
parse[i3].Name = mobname;
i += 8 + namelen;
i3++;
} while (i < len - 4);
return parse;
}

//parse mobname.lod

public struct Mob
{
public int ID;
public string Name;
public string ToString()
{
return ID + "\t" + Name;
}
}

public static Item[] itemname(string path)
{
byte[] bytes = File.ReadAllBytes(path);
long len = bytes.Length;
long i = 0;
int i2 = 0;
long i3 = 0;
int namelen, deslen;
string Itemname, des;
Item[] parse = new Item[0];
do
{
Array.Resize(ref parse, (int)i3 + 1);
parse[i3].ID = (bytes[i + 4] + (bytes[i + 5] * 256) + (bytes[i + 6] * 256) + (bytes[i + 7] * 256));
namelen = (bytes[i + 8] + bytes[i + 9] + bytes[i + 10] + bytes[i + 11]);
Itemname = "";
i2 = 1;
while (i2 < namelen + 1)
{
i2++;
Itemname = Itemname + (char)(bytes[i + 10 + i2]);
}
parse[i3].Name = Itemname;
deslen = (bytes[i + 12 + namelen] + bytes[i + 13 + namelen] + bytes[i + 14 + namelen] + bytes[i + 15 + namelen]);
des = "";
i2 = 1;
while (i2 < deslen + 1)
{
i2++;
des = des + (char)(bytes[i + 14 + i2 + namelen]);
}
parse[i3].Description = des;
i += 12 + namelen + deslen;
i3++;
} while (i < len - 4);
return parse;
}

//parse option.lod

public struct Seal
{
public int ID;
public int SubID;
public string Name;
public int Value1;
public int Value2;
public int Value3;
public int Value4;
public int Value5;
public int Value6;
public int Value7;
public string ToString()
{
return ID + "\t" + SubID + "\t" + Name + "\t" + Value1 + " | " + Value2 + " | " + Value3 + " | " + Value4 + " | " + Value5 + " | " + Value6 + " | " + Value7;
}
}

public static Seal[] option(string path)
{
byte[] bytes = File.ReadAllBytes(path);
long len = bytes.Length;
long i = 0;
int i2 = 0;
long i3 = 0;
int namelen;
string sealname;
Seal[] parse = new Seal[0];
do
{
Array.Resize(ref parse, (int)i3 + 1);

parse[i3].ID = (bytes[i + 4] + (bytes[i + 5] * 256) + (bytes[i + 6] * 256) + (bytes[i + 7] * 256));
parse[i3].SubID = (bytes[i + 8] + (bytes[i + 9] * 256) + (bytes[i + 10] * 256) + (bytes[i + 11] * 256));
namelen = (bytes[i + 12] + (bytes[i + 13] * 256) + (bytes[i + 14] * 256) + (bytes[i + 15] * 256));
sealname = "";
i2 = 1;
while (i2 < namelen + 1)
{
i2++;
sealname = sealname + (char)(bytes[i + 14 + i2]);
}
parse[i3].Name = sealname;

parse[i3].Value1 = (bytes[i + 16 + namelen] + (bytes[i + 17 + namelen] * 256) + (bytes[i + 18 + namelen] * 256) + (bytes[i + 19 + namelen] * 256));
parse[i3].Value2 = (bytes[i + 20 + namelen] + (bytes[i + 21 + namelen] * 256) + (bytes[i + 22 + namelen] * 256) + (bytes[i + 23 + namelen] * 256));
parse[i3].Value3 = (bytes[i + 24 + namelen] + (bytes[i + 25 + namelen] * 256) + (bytes[i + 26 + namelen] * 256) + (bytes[i + 27 + namelen] * 256));
parse[i3].Value4 = (bytes[i + 28 + namelen] + (bytes[i + 29 + namelen] * 256) + (bytes[i + 30 + namelen] * 256) + (bytes[i + 31 + namelen] * 256));
parse[i3].Value5 = (bytes[i + 32 + namelen] + (bytes[i + 33 + namelen] * 256) + (bytes[i + 34 + namelen] * 256) + (bytes[i + 35 + namelen] * 256));
parse[i3].Value6 = (bytes[i + 36 + namelen] + (bytes[i + 37 + namelen] * 256) + (bytes[i + 38 + namelen] * 256) + (bytes[i + 39 + namelen] * 256));
parse[i3].Value7 = (bytes[i + 40 + namelen] + (bytes[i + 41 + namelen] * 256) + (bytes[i + 42 + namelen] * 256) + (bytes[i + 43 + namelen] * 256));
i += 40 + namelen;
i3++;
} while (i < len - 4);
return parse;
}
}
}

 

and an little example

 

ParseLod.Mob[] example = ParseLod.mobname(@"C:\ILC_DARK\Data\mobname.lod");

int i = 0;
while (i < example.Length)
{
Console.WriteLine(example[i].ToString());
i++;
}

 

if anywan se an way to optimize, tell me Big Grin if any one wanna usw this class, do it Big Grin

 

~ILAN12346



Messages In This Thread
[No subject] - by ILAn12346 - 05-25-2012, 04:14 AM
[No subject] - by Wizatek - 05-25-2012, 06:43 PM
[No subject] - by ILAn12346 - 05-25-2012, 09:24 PM
[No subject] - by Wizatek - 05-25-2012, 09:48 PM
[No subject] - by ILAn12346 - 05-25-2012, 10:03 PM
[No subject] - by someone - 05-26-2012, 01:07 PM
[No subject] - by Wizatek - 05-26-2012, 02:38 PM
[No subject] - by Reza - 05-31-2012, 05:41 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)