![]() |
|
Newbie Problems - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Programmers Gateway (https://lckb.dev/forum/forumdisplay.php?fid=196) +---- Forum: Coders Talk (https://lckb.dev/forum/forumdisplay.php?fid=192) +---- Thread: Newbie Problems (/showthread.php?tid=3964) Pages:
1
2
|
- dethunter12 - 03-27-2015 alright so i wrote an itemall editor that opens the new files but reads _usa instead of Itemall.lod im aware that id description and index are not in the new itemall structure but istead are in strItem_usa.lod so im trying to ask how to write my editor hey open itemall.lod and then after that open the stritem_usa and sort the listbox by index once loaded . and also i know i have to pull a_castle_war from Itemall.lod if somebody could answer how this would be done that would be helpful code looks like this ItemALL_Structure.ItemList.Clear(); using (BinaryReader reader = new BinaryReader(File.Open(openFileDialog1.FileName, FileMode.Open))) { reader.ReadInt32(); while (reader.BaseStream.Position < reader.BaseStream.Length - 8) { ItemALL_Structure item = new ItemALL_Structure(); item.ItemID = reader.ReadInt32(); item.Name = iso.GetString(reader.ReadBytes(reader.ReadInt32())); item.JobFlag = reader.ReadInt32(); item.Weight = reader.ReadInt32(); item.MaxUse = reader.ReadInt32(); item.Level = reader.ReadInt32(); item.Flag = reader.ReadInt32(); item.Position = reader.ReadInt32(); item.Type = reader.ReadInt32(); item.SubType = reader.ReadInt32(); int[] temp1 = new int[10]; int[] temp2 = new int[10]; for (int i = 0; i < 10; i++) { temp1[i] = reader.ReadInt32(); temp2[i] = reader.ReadInt32(); } item.CraftItemID = temp1; item.CraftItemAmount = temp2; item.Need_SSkill1_Id = reader.ReadInt32(); item.Need_SSkill1_Level = reader.ReadInt32(); item.Need_SSkill2_Id = reader.ReadInt32(); item.Need_SSkill2_Level = reader.ReadInt32(); item.Num0 = reader.ReadInt32(); item.Num1 = reader.ReadInt32(); item.Num2 = reader.ReadInt32(); item.Num3 = reader.ReadInt32(); item.a_num_4 = reader.ReadInt32(); item.Price = reader.ReadInt32(); item.Smc = iso.GetString(reader.ReadBytes(reader.ReadInt32())); item.TexID = reader.ReadInt32(); item.TexRow = reader.ReadInt32(); item.TexCol = reader.ReadInt32(); item.Description = iso.GetString(reader.ReadBytes(reader.ReadInt32())); item.Effect1 = iso.GetString(reader.ReadBytes(reader.ReadInt32())); item.Effect2 = iso.GetString(reader.ReadBytes(reader.ReadInt32())); item.Effect3 = iso.GetString(reader.ReadBytes(reader.ReadInt32())); item.Set1 = reader.ReadInt32(); item.Set2 = reader.ReadInt32(); item.Set3 = reader.ReadInt32(); item.Set4 = reader.ReadInt32(); item.Set5 = reader.ReadInt32(); item.RareOption = reader.ReadInt32(); item.RareChance = reader.ReadInt32(); item.FortuneDataCount = reader.ReadInt32(); if (item.FortuneDataCount == 0) { item.SkillID = null; item.SkillLevel = null; item.StringID = null; item.Prob = null; } else if (item.FortuneDataCount != 1) { int[] tmp1 = new int[item.FortuneDataCount]; int[] tmp2 = new int[item.FortuneDataCount]; int[] tmp3 = new int[item.FortuneDataCount]; int[] tmp4 = new int[item.FortuneDataCount]; for (int y = 0; y < item.FortuneDataCount; y++) { tmp1[y] = reader.ReadInt32(); tmp2[y] = reader.ReadInt32(); tmp3[y] = reader.ReadInt32(); tmp4[y] = reader.ReadInt32(); } item.SkillID = tmp1; item.SkillLevel = tmp2; item.StringID = tmp3; item.Prob = tmp4; } item.a_enable = 1; item.a_num_4 = 0; item.a_level2 = 999; item.a_zone_flag = 1023; item.a_set = -1; item.a_grade = 0; item.a_fame = -1; item.a_rare_index_x = null; item.a_rare_prob_x = null; item.a_quest_trigger_count = 0; item.a_quest_trigger_ids = ""; item.a_origin_variationx = null; ItemALL_Structure.ItemList.Add(item); } reader.Close(); OpenedFile = openFileDialog1.FileName; } MessageBox.Show(openFileDialog1.FileName + " Opened Successfully ."); - Nikolee - 03-27-2015 First read your ItemAll as usual and then after your function succeed just read the strItem loop with a list and set the Name and Description on the right positon. And after that is also done just create a List<string> menu = new List<string>(); menu.Add(item.Index + " - " item.Name); If i understood you right, if not then please explain it better. - Wizatek - 03-27-2015 Its a better idea to make your tool edit the database with the option to export the files. - dethunter12 - 03-27-2015 okay thanks everyone ill try to make it read from database with option to export - Nikolee - 03-27-2015 Also i would suggest you the create an Item Object. I have made an Example: 2 And the Class which you innerhit 2 - Tarissuis - 03-27-2015 You should stick to a database exporter, however, if you're planning to open .lod files as well be aware that the original .lods usually not exactly fit each other (at least they didn't some time ago), so you have to doublecheck the ID- - Wizatek - 03-27-2015 They do now indeed because pragma pack is used. But before there was padding involved. But even with the padding C# could still read it fine with Marshal.PtrToStructure public static T ByteToType<T>(BinaryReader reader) { byte[] bytes = reader.ReadBytes(Marshal.SizeOf(typeof(T))); GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); T theStructure = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); handle.Free(); return theStructure; } - Wahrheit - 03-28-2015 I wouldn't call reader.close() in a using statement simply because that's not necessary. The using directive calls Dispose() after executing and that takes care of closing the reader. Side note: If you want to implement it in your own classes e.g if your objects use unmanaged resources such as file handles: That means every object x in the using statement [using (foo x = new foo())] has to implement the IDisposable interface inorder to use the using statement. You can use multiple using statements at once. You can't access the object outside the using statement. Usualy the Dispose method is implemented as that: public class Foo : IDisposable { private bool disposed = false; /* Implementation of your class onmitted */ public void Dispose() { Dispose(true); GC.SupressFinialize(this); } protected virtual void Dispose(bool disposeManaged) { if(disposed){ return; } if(disposeManaged){ //take care of managed objects here } //take care of unmanaged object here disposed = true; } } - DamonA - 03-28-2015 If you create an database editor, you can use my exporter to create the .lod. Than you only must handle the tables and can download/export it with my api. if you want you can write me an pm. - Nikolee - 03-28-2015 I wouldn't call reader.close() in a using statement simply because that's not necessary. The using directive calls Dispose() after executing and that takes care of closing the reader. Side note: If you want to implement it in your own classes e.g if your objects use unmanaged resources such as file handles: That means every object x in the using statement [using (foo x = new foo())] has to implement the IDisposable interface inorder to use the using statement. You can use multiple using statements at once. You can't access the object outside the using statement. Usualy the Dispose method is implemented as that: public class Foo : IDisposable { private bool disposed = false; /* Implementation of your class onmitted */ public void Dispose() { Dispose(true); GC.SupressFinialize(this); } protected virtual void Dispose(bool disposeManaged) { if(disposed){ return; } if(disposeManaged){ //take care of managed objects here } //take care of unmanaged object here disposed = true; } } why should he care about unmanaged objects? I dont understand what u trying to explain ![]() If its about memory then its useless because there is a GC that destroys the not used objects.(Only if there is no reference to it) |