- public string FormatCode;
- public Int32 data_offset;
- public Int32 rowcount;
- public Int32 columncount;
- public void Load(string filePath)
- {
- Encoding koreanEncoding = Encoding.GetEncoding("EUC-KR");
- FileStream fileStream = File.OpenRead(filePath);
- BinaryReader fh = new BinaryReader(fileStream, koreanEncoding);
- this.FormatCode = koreanEncoding.GetString(fh.ReadBytes(4));
- this.data_offset = fh.ReadInt32();
- this.rowcount = fh.ReadInt32();
- this.columncount = fh.ReadInt32();
- fh.BaseStream.Seek(data_offset, SeekOrigin.Begin);
- Int32 rowheight = fh.ReadInt32();
- for (int x = 0; x <= columncount; x++)
- {
- Int16 columnwidth = fh.ReadInt16();
- }
- for (int x = 0; x < columncount; x++)
- {
- Int16 columntitlelength = fh.ReadInt16();
- char[] columntitle = fh.ReadChars(columntitlelength);
- }
- Int16 idcolumnnamelength = fh.ReadInt16();
- char[] idcolumnname = fh.ReadChars(idcolumnnamelength);
- for (int x = 1; x < (rowcount - 1); x++)
- {
- Int16 rowdatalength = fh.ReadInt16();
- char[] rowdata = fh.ReadChars(rowdatalength);
- }
- for (int x = 1; x < rowcount; x++)
- {
- for (int i = 1; x < columncount; i++)
- {
- Int16 celldatalength = fh.ReadInt16();
- char[] celldata = fh.ReadChars(celldatalength);
- }
- }
- }
Recently I became interested in trying to make editors for files inside the Rose client. Of course there's already a bunch of editors so for the most part there is no real purpose in trying to create and editor besides wanting to learn how to make such tools in general for fun, in my case.
I usually program in C# and I wanted to start with an STB editor because it seemed the most straightforward to me. Using the following topics I got as far as the code at the bottom shows you:
- viewtopic.php?f=34&t=4498&p=48621
- viewtopic.php?f=34&t=4498&p=48638
Although the topics were a little vague, they were still quite helpfull. Everything untill rowheight seems to be fine. I manually checked if the offset was correct using a hex editor and it was fine. But after this it only returns me negative numbers, which seems to me is incorrect as it makes the program crash and it doesn't make any sense in the first place. Some searching brought me to the subject of endianness which seems to hold the key to my fix, but I'm a little over my head here, so I was hoping one of you could help me solve the problem. I'm not an expert programmer, but I'm willing to learn.
Edit: I forgot to mention that I'm using Xadet3's STB file format pseudocode.