public void updateQPFRes(StructQPF tmp) { StructQPF[] tmpdata; if (this.data.Length == 0) { tmpdata = new StructQPF[1]; tmpdata[0] = new StructQPF(); tmpdata[0] = tmp; this.header = Hexcnv.StringToByteArrayFastest("6E466C61766F7220517565737450726F700003000000"); } else { tmpdata = new StructQPF[this.data.Length + 1]; for (int i = 0; i < this.data.Length; i++) { tmpdata[i] = new StructQPF(); tmpdata[i] = data[i]; } tmpdata[this.data.Length] = new StructQPF(); tmpdata[this.data.Length] = tmp; } this.data = tmpdata; this.cnt = cnt + 1; this.edit = true; }
private void drawMapImg() { try { for (int i = 1; i <= this.cnt; i++) { PointF[] points = { new Point((int)((int)(data[i - 1].Left - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[i - 1].Top - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))), new Point((int)((int)(data[i - 1].Right - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[i - 1].Top - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))), new Point((int)((int)(data[i - 1].Right - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[i - 1].Bottom - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))), new Point((int)((int)(data[i - 1].Left - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[i - 1].Bottom - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))), new Point((int)((int)(data[i - 1].Left - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[i - 1].Top - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))) }; g.DrawLines(new Pen(Color.Blue, 1), points); } for (int i = 1; i <= this.cnt_npcinit; i++) { g.FillRectangle(new SolidBrush(Color.Pink), ((int)npcdata[i - 1].x - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25, 3072 - ((int)(npcdata[i - 1].y - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25), 3, 3); } this.error = false; this.check = true; } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } }
private void loadData() { try { if (File.Exists(this.fullpath)) { FileStream fileStream = File.Open(this.fullpath, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader binaryReader = new BinaryReader(fileStream, Encoding.ASCII); this.header = new byte[22]; for (int i = 0; i < 22; i++) { this.header[i] = binaryReader.ReadByte(); } //binaryReader.ReadBytes(22); this.cnt = binaryReader.ReadInt32(); data = new StructQPF[this.cnt]; for (int i = 1; i <= cnt; i++) { data[i - 1] = new StructQPF(); data[i - 1].id = binaryReader.ReadInt32(); if (this.loadstrings) { data[i - 1].name = this.strings.get_Fname(data[i - 1].id + 170000000); } else { data[i - 1].name = "No StringResource found!"; } /*data[i - 1].x = binaryReader.ReadSingle() / (float)5.25; * data[i - 1].y = mirrory((int)(binaryReader.ReadSingle() / (float)5.25));*/ data[i - 1].x = binaryReader.ReadSingle() + Hexcnv.GetCoords(this.filename, 1); data[i - 1].y = binaryReader.ReadSingle() + Hexcnv.GetCoords(this.filename, 2); data[i - 1].offset_z = binaryReader.ReadSingle(); data[i - 1].rotation_x = binaryReader.ReadSingle(); data[i - 1].rotation_y = binaryReader.ReadSingle(); data[i - 1].rotation_z = binaryReader.ReadSingle(); data[i - 1].scale_x = binaryReader.ReadSingle(); data[i - 1].scale_y = binaryReader.ReadSingle(); data[i - 1].scale_z = binaryReader.ReadSingle(); data[i - 1].id2 = binaryReader.ReadInt32(); binaryReader.ReadByte(); binaryReader.ReadInt32(); } binaryReader.Close(); fileStream.Close(); this.error = false; this.check = true; } } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } }
private void loadData() { try { FileStream fileStream = File.Open(this.fullpath, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader binaryReader = new BinaryReader(fileStream, Encoding.ASCII); this.cnt = binaryReader.ReadInt32(); data = new StructNFA[this.cnt]; for (int i = 1; i <= this.cnt; i++) { data[i - 1] = new StructNFA(); data[i - 1].id = i; data[i - 1].coordcount = binaryReader.ReadInt32(); data[i - 1].points = new PointF[data[i - 1].coordcount + 1]; int stringcnt = 0; for (int j = 1; j <= data[i - 1].coordcount; j++) { data[i - 1].points[j - 1] = new Point(); int x = binaryReader.ReadInt32(); int y = mirrory(binaryReader.ReadInt32()); data[i - 1].points[j - 1].X = x; data[i - 1].points[j - 1].Y = y; data[i - 1].coord = data[i - 1].coord + j + ". (" + ((x * 5.25) + Hexcnv.GetCoords(this.filename, 1)).ToString() + ", " + (((3072 - y) * 5.25) + Hexcnv.GetCoords(this.filename, 2)).ToString() + ")"; if (stringcnt == 7) { data[i - 1].coord = data[i - 1].coord + "\n"; stringcnt = 0; } else { stringcnt++; } } data[i - 1].points[data[i - 1].coordcount] = new Point(); data[i - 1].points[data[i - 1].coordcount].X = data[i - 1].points[0].X; data[i - 1].points[data[i - 1].coordcount].Y = data[i - 1].points[0].Y; } binaryReader.Close(); fileStream.Close(); this.error = false; this.check = true; } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } }
public void updateFile(bool hashexport) { try { FileStream stream; if (File.Exists(this.fullpath)) { File.Copy(this.fullpath, Path.GetDirectoryName(this.fullpath) + "\\" + Path.GetFileNameWithoutExtension(this.fullpath) + ".qpf" + DateTime.Now.ToString("ddMMMyyyyHHmmss")); stream = new FileStream(this.fullpath, FileMode.Open, FileAccess.ReadWrite); } else { stream = new FileStream(this.fullpath, FileMode.Create, FileAccess.ReadWrite); } BinaryWriter bw = new BinaryWriter(stream, Encoding.Default); //stream.Position = 22; bw.Write(header); bw.Write(BitConverter.GetBytes(Convert.ToInt32(this.cnt))); for (int i = 0; i < this.cnt; i++) { bw.Write(BitConverter.GetBytes(Convert.ToInt32(data[i].id))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(data[i].x - Hexcnv.GetCoords(this.filename, 1)))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(data[i].y - Hexcnv.GetCoords(this.filename, 2)))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(data[i].offset_z))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(data[i].rotation_x))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(data[i].rotation_y))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(data[i].rotation_z))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(data[i].scale_x))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(data[i].scale_y))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(data[i].scale_z))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(data[i].id2))); stream.WriteByte(0x00); bw.Write(BitConverter.GetBytes(Convert.ToInt32(65535))); } bw.Close(); stream.Close(); if (hashexport) { FileIO.ExportHashed(this.fullpath); } this.edit = false; } catch { this.error = true; System.Windows.Forms.MessageBox.Show("Error while saving!"); } }
public Bitmap drawSelectedNFS(int nfsid, Bitmap CurMap) { Bitmap tmp = new Bitmap(CurMap); g = Graphics.FromImage(tmp); try { PointF[] points = { new Point((int)((int)(data[nfsid].Left - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[nfsid].Top - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))), new Point((int)((int)(data[nfsid].Right - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[nfsid].Top - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))), new Point((int)((int)(data[nfsid].Right - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[nfsid].Bottom - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))), new Point((int)((int)(data[nfsid].Left - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[nfsid].Bottom - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))), new Point((int)((int)(data[nfsid].Left - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), (int)(mirrory((int)((data[nfsid].Top - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))) }; if (data[nfsid].ScriptText != null) { g.DrawLines(new Pen(Color.Blue, 2), points); g.DrawString(data[nfsid].ScriptText.ToString(), new Font("Times New Roman", 10, FontStyle.Regular), new SolidBrush(Color.Blue), new PointF(Convert.ToInt32(((int)(data[nfsid].Left - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25)) + 5, Convert.ToInt32((mirrory((int)((data[nfsid].Bottom - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))) + 5)); } else { g.DrawLines(new Pen(Color.Aquamarine, 2), points); g.DrawString("empty: " + (nfsid).ToString(), new Font("Times New Roman", 10, FontStyle.Regular), new SolidBrush(Color.Aquamarine), new PointF(Convert.ToInt32(((int)(data[nfsid].Left - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25)) + 5, Convert.ToInt32((mirrory((int)((data[nfsid].Bottom - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)))) + 5)); } this.error = false; this.check = true; } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } return(tmp); }
private void drawMapImg() { try { for (int i = 1; i <= this.cnt; i++) { g.FillRectangle(new SolidBrush(Color.Orange), ((data[i - 1].x - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), mirrory((int)((data[i - 1].y - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)), 3, 3); } this.error = false; this.check = true; } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } }
private void updateCoordstxt(int id) { int stringcnt = 0; this.data[id].coord = ""; for (int i = 0; i < this.data[id].coordcount; i++) { data[id].coord = data[id].coord + (i + 1).ToString() + ". (" + ((data[id].points[i].X * 5.25) + Hexcnv.GetCoords(this.filename, 1)).ToString() + ", " + (((3072 - data[id].points[i].Y) * 5.25) + Hexcnv.GetCoords(this.filename, 1)).ToString() + ")"; if (stringcnt == 7) { data[id].coord = data[id].coord + "\n"; stringcnt = 0; } else { stringcnt++; } } }
public Bitmap drawSelectedQPF(int qpfid, Bitmap CurMap) { Bitmap tmp = new Bitmap(CurMap); g = Graphics.FromImage(tmp); try { g.FillRectangle(new SolidBrush(Color.OrangeRed), ((data[qpfid].x - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25), mirrory((int)((data[qpfid].y - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25)), 10, 10); g.DrawString(data[qpfid].name, new Font("Times New Roman", 10, FontStyle.Regular), new SolidBrush(Color.OrangeRed), new PointF(((data[qpfid].x - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25) + 6, mirrory((int)(data[qpfid].y - Hexcnv.GetCoords(this.filename, 2)) / (float)5.25) + 6)); this.error = false; this.check = true; } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } return(tmp); }
public Bitmap drawSelectedNPC(int npcid, Bitmap CurMap) { Bitmap tmp = new Bitmap(CurMap); g = Graphics.FromImage(tmp); try { g.FillRectangle(new SolidBrush(Color.Pink), (int)(npcdata[npcid].x - Hexcnv.GetCoords(this.filename, 1)) / (float)5.25, mirrory((int)((npcdata[npcid].y - Hexcnv.GetCoords(this.filename, 2)) / 5.25)), 8, 8); g.DrawString(npcdata[npcid].name.ToString(), new Font("Times New Roman", 10, FontStyle.Regular), new SolidBrush(Color.Pink), new PointF(Convert.ToInt32((npcdata[npcid].x - Hexcnv.GetCoords(this.filename, 1)) / 5.25) + 5, Convert.ToInt32(3072 - ((npcdata[npcid].y - Hexcnv.GetCoords(this.filename, 2)) / 5.25)) + 2)); } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } return(tmp); }
private void loadData() { try { if (File.Exists(this.fullpath)) { FileStream fileStream = File.Open(this.fullpath, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader br = new BinaryReader(fileStream, Encoding.ASCII); try { this.header.szSign = System.Text.Encoding.GetEncoding(949).GetString(br.ReadBytes(16)); this.header.dwVersion = br.ReadUInt32(); this.header.dwMapPropertiesOffset = br.ReadUInt32(); this.header.dwTerrainSegmentOffset = br.ReadUInt32(); this.header.dwPropOffset = br.ReadUInt32(); this.header.dwVectorAttrOffset = br.ReadUInt32(); this.header.dwWaterOffset = br.ReadUInt32(); this.header.dwGrassColonyOffset = br.ReadUInt32(); this.header.dwEventAreaOffset = br.ReadUInt32(); this.header.nTileCountPerSegment = br.ReadInt32(); this.header.nSegmentCountPerMap = br.ReadInt32(); this.header.fTileLength = br.ReadSingle(); br.BaseStream.Position = this.header.dwMapPropertiesOffset; this.MapProps = new MapProps(); this.MapProps.u1_1 = br.ReadByte(); this.MapProps.u1_2 = br.ReadByte(); this.MapProps.u1_3 = br.ReadByte(); this.MapProps.u1_4 = br.ReadByte(); this.MapProps.u1_5 = br.ReadByte(); this.MapProps.u1_6 = br.ReadByte(); this.MapProps.u2 = br.ReadSingle(); this.MapProps.u3 = br.ReadSingle(); this.MapProps.u4 = br.ReadSingle(); this.MapProps.u5_1 = br.ReadByte(); this.MapProps.u5_2 = br.ReadByte(); this.MapProps.u5_3 = br.ReadByte(); this.MapProps.u5_4 = br.ReadByte(); this.MapProps.u5_5 = br.ReadByte(); this.MapProps.u5_6 = br.ReadByte(); this.MapProps.u6 = br.ReadSingle(); this.MapProps.u7 = br.ReadSingle(); this.MapProps.u8 = br.ReadSingle(); this.MapProps.u9_1 = br.ReadByte(); this.MapProps.u9_2 = br.ReadByte(); this.MapProps.u9_3 = br.ReadByte(); this.MapProps.u9_4 = br.ReadByte(); this.MapProps.u9_5 = br.ReadByte(); this.MapProps.u9_6 = br.ReadByte(); this.MapProps.u10 = br.ReadSingle(); this.MapProps.u11 = br.ReadSingle(); this.MapProps.u12 = br.ReadInt32(); this.MapProps.showTerrain = br.ReadBoolean(); br.BaseStream.Position = this.header.dwPropOffset; this.propsegments = new SEGMENTS_TABLE_STRUCTURE[4096]; int dataoffset = br.ReadInt32(); int segment = 0; int cnt = 0; while (segment < 4096) { br.BaseStream.Position = dataoffset; cnt = br.ReadInt32(); propsegments[segment] = new SEGMENTS_TABLE_STRUCTURE(segment, dataoffset, cnt); if (cnt > 0) { propsegments[segment].props = new PROPS_TABLE_STRUCTURE[cnt]; for (int i = 0; i < cnt; i++) { propsegments[segment].props[i] = new PROPS_TABLE_STRUCTURE(segment, br.ReadInt32(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadInt16(), br.ReadBoolean(), br.ReadSingle(), br.ReadInt16()); } } segment++; br.BaseStream.Position = this.header.dwPropOffset + (segment * 4); dataoffset = br.ReadInt32(); } this.terrain = new TerrainSegments(); this.terrain.segments = new NFM_SEGMENTHEADER_V11[4096]; br.BaseStream.Position = this.header.dwTerrainSegmentOffset; segment = 0; while (segment < 4096) { this.terrain.segments[segment] = new NFM_SEGMENTHEADER_V11(); this.terrain.segments[segment].segment = segment; this.terrain.segments[segment].dwVersion = br.ReadUInt32(); this.terrain.segments[segment].tile1 = br.ReadUInt16(); this.terrain.segments[segment].tile2 = br.ReadUInt16(); this.terrain.segments[segment].tile3 = br.ReadUInt16(); this.terrain.segments[segment].vertices = new NFM_VERTEXSTRUCT_V11[36]; for (int i = 0; i < 36; i++) { this.terrain.segments[segment].vertices[i] = new NFM_VERTEXSTRUCT_V11(); this.terrain.segments[segment].vertices[i].fHeight = br.ReadSingle(); this.terrain.segments[segment].vertices[i].wFillBits1 = br.ReadUInt32(); this.terrain.segments[segment].vertices[i].wFillBits2 = br.ReadUInt32(); this.terrain.segments[segment].vertices[i].wAttribute = br.ReadUInt64(); this.terrain.segments[segment].vertices[i].color1 = br.ReadByte(); this.terrain.segments[segment].vertices[i].color2 = br.ReadByte(); this.terrain.segments[segment].vertices[i].color3 = br.ReadByte(); } segment++; } br.BaseStream.Position = this.header.dwGrassColonyOffset; int grasscnt = br.ReadInt32(); if (grasscnt > 0) { this.grass = new SpeedGrass[grasscnt]; for (int i = 0; i < grasscnt; i++) { this.grass[i] = new SpeedGrass(); this.grass[i].nPolygonID = br.ReadInt32(); this.grass[i].fDensity = br.ReadSingle(); this.grass[i].fDisTribution = br.ReadSingle(); this.grass[i].fSize = br.ReadSingle(); this.grass[i].fHeightP = br.ReadSingle(); this.grass[i].fHeightM = br.ReadSingle(); this.grass[i].Color1 = br.ReadByte(); this.grass[i].Color2 = br.ReadByte(); this.grass[i].Color3 = br.ReadByte(); this.grass[i].Color4 = br.ReadByte(); this.grass[i].fColorRatio = br.ReadSingle(); this.grass[i].fColorTone = br.ReadSingle(); this.grass[i].fChroma = br.ReadSingle(); this.grass[i].fBrightness = br.ReadSingle(); this.grass[i].fCombinationRatio = br.ReadSingle(); this.grass[i].fWindReaction = br.ReadSingle(); this.grass[i].cnt_filename = br.ReadInt32(); this.grass[i].file_name = System.Text.Encoding.GetEncoding(949).GetString(br.ReadBytes(this.grass[i].cnt_filename)); this.grass[i].utype = br.ReadInt32(); this.grass[i].cnt_coords = br.ReadInt32(); this.grass[i].coords = new PointF[this.grass[i].cnt_coords]; for (int j = 0; j < this.grass[i].cnt_coords; j++) { this.grass[i].coords[j] = new PointF(); this.grass[i].coords[j].X = (br.ReadUInt32()) / (float)5.25; this.grass[i].coords[j].Y = (br.ReadUInt32()) / (float)5.25; } } } br.BaseStream.Position = this.header.dwEventAreaOffset; int eventcnt = br.ReadInt32(); if (eventcnt > 0) { this.events = new StructNFE[eventcnt]; for (int i = 0; i < eventcnt; i++) { this.events[i] = new StructNFE(); this.events[i] = new StructNFE(); this.events[i].id = br.ReadInt32(); this.events[i].type = br.ReadInt32(); this.events[i].count_coords = br.ReadInt32(); this.events[i].coords = new PointF[this.events[i].count_coords + 1]; for (int j = 0; j < this.events[i].count_coords; j++) { int x = br.ReadInt32(); int y = mirrory(br.ReadInt32()); this.events[i].coords[j].X = x; this.events[i].coords[j].Y = y; this.events[i].coord = this.events[i].coord + j + ". (" + ((x * 5.25) + Hexcnv.GetCoords(this.filename, 1)) + ", " + (((3072 - y) * 5.25) + Hexcnv.GetCoords(this.filename, 2)) + ")"; } } } br.BaseStream.Position = this.header.dwVectorAttrOffset; int vectorcnt = br.ReadInt32(); if (vectorcnt > 0) { this.vectordata = new VectorAttrib[vectorcnt]; for (int i = 0; i < vectorcnt; i++) { this.vectordata[i] = new VectorAttrib(); this.vectordata[i].cnt = br.ReadInt32(); if (this.vectordata[i].cnt > 0) { this.vectordata[i].data = new VectorData[this.vectordata[i].cnt]; for (int j = 0; j < this.vectordata[i].cnt; j++) { this.vectordata[i].data[j] = new VectorData(); this.vectordata[i].data[j].x = br.ReadInt32(); this.vectordata[i].data[j].y = br.ReadInt32(); } } } } this.calculateOffsets(); }catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } } } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } }
private void writenewNFSRes(bool hashexport) { try { checkHeader(); FileStream stream; if (File.Exists(this.fullpath)) { File.Copy(this.fullpath, Path.GetDirectoryName(this.fullpath) + "\\" + Path.GetFileNameWithoutExtension(this.fullpath) + ".nfs" + DateTime.Now.ToString("ddMMMyyyyHHmmss")); stream = new FileStream(this.fullpath, FileMode.Open, FileAccess.ReadWrite); } else { stream = new FileStream(this.fullpath, FileMode.Create, FileAccess.ReadWrite); } BinaryWriter bw = new BinaryWriter(stream, Encoding.Default); System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); bw.Write(enc.GetBytes(Header.Signature)); bw.Write(BitConverter.GetBytes(Header.Version)); bw.Write(BitConverter.GetBytes(Convert.ToInt32(EVENT_LOCATION_OFFSET))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(getOffset(1)))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(getOffset(2)))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(this.cnt))); for (int i = 0; i < cnt; i++) { bw.Write(BitConverter.GetBytes(Convert.ToInt32(((data[i].Left - Hexcnv.GetCoords(this.filename, 1)) / 5.25) / 8))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(((data[i].Top - Hexcnv.GetCoords(this.filename, 2)) / 5.25) / 8))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(((data[i].Right - Hexcnv.GetCoords(this.filename, 1)) / 5.25) / 8))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(((data[i].Bottom - Hexcnv.GetCoords(this.filename, 2)) / 5.25) / 8))); bw.Write(new byte[4]); } bw.Write(BitConverter.GetBytes(Convert.ToInt32(this.cnt2))); for (int i = 0; i < cnt; i++) { if (!string.IsNullOrEmpty(data[i].ScriptText)) { bw.Write(BitConverter.GetBytes(Convert.ToInt32(data[i].RegionIndex))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(data[i].MonsterCount))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(data[i].Trigger))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(data[i].ScriptLength))); bw.Write(enc.GetBytes(data[i].ScriptText)); } } bw.Write(BitConverter.GetBytes(Convert.ToInt32(this.cnt_npcinit))); if (this.cnt_npcinit > 0) { for (int i = 0; i < this.cnt_npcinit; i++) { bw.Write(BitConverter.GetBytes(Convert.ToInt16(npcdata[i].id))); bw.Write(BitConverter.GetBytes(Convert.ToInt16(npcdata[i].unknown1))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(npcdata[i].x - Hexcnv.GetCoords(this.filename, 1)))); bw.Write(BitConverter.GetBytes(Convert.ToSingle(npcdata[i].y - Hexcnv.GetCoords(this.filename, 2)))); bw.Write(BitConverter.GetBytes(Convert.ToInt16(npcdata[i].propID))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(npcdata[i].unknown2))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(npcdata[i].unknown4))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(npcdata[i].initscript.Length))); bw.Write(enc.GetBytes(npcdata[i].initscript)); if (npcdata[i].unknown2 == 2) { bw.Write(BitConverter.GetBytes(Convert.ToInt32(npcdata[i].type))); bw.Write(BitConverter.GetBytes(Convert.ToInt32(npcdata[i].contact.Length))); bw.Write(enc.GetBytes(npcdata[i].contact)); } } } bw.Close(); stream.Close(); if (hashexport) { FileIO.ExportHashed(this.fullpath); } this.editNFS = false; this.editNPC = false; } catch { this.error = true; System.Windows.Forms.MessageBox.Show("Error while saving!"); } }
private void loadData() { try { if (File.Exists(this.fullpath)) { using (FileStream fileStream = File.Open(this.fullpath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (BinaryReader binaryReader = new BinaryReader(fileStream, Encoding.ASCII)) { this.Header.Signature = Encoding.Default.GetString(binaryReader.ReadBytes(16)); this.Header.Version = binaryReader.ReadInt32(); this.Header.LocationOffset = binaryReader.ReadInt32(); this.Header.MonsterOffset = binaryReader.ReadInt32(); this.Header.NPCOffset = binaryReader.ReadInt32(); this.Header.RowCount = binaryReader.ReadInt32(); this.cnt = Header.RowCount; data = new NFS_MONSTER_LOCATION[cnt]; for (int i = 1; i <= cnt; i++) { data[i - 1] = new NFS_MONSTER_LOCATION(); data[i - 1].Left = ((Convert.ToInt32((binaryReader.ReadInt32() * 8) * 5.25)) + Hexcnv.GetCoords(this.filename, 1)); data[i - 1].Top = ((Convert.ToInt32((binaryReader.ReadInt32() * 8) * 5.25)) + Hexcnv.GetCoords(this.filename, 2)); data[i - 1].Right = ((Convert.ToInt32((binaryReader.ReadInt32() * 8) * 5.25)) + Hexcnv.GetCoords(this.filename, 1)); data[i - 1].Bottom = ((Convert.ToInt32((binaryReader.ReadInt32() * 8) * 5.25)) + Hexcnv.GetCoords(this.filename, 2)); binaryReader.ReadInt32(); } cnt2 = binaryReader.ReadInt32(); for (int i = 1; i <= cnt2; i++) { data[i - 1].RegionIndex = binaryReader.ReadInt32(); data[i - 1].MonsterCount = binaryReader.ReadInt32(); data[i - 1].Trigger = binaryReader.ReadInt32(); data[i - 1].ScriptLength = binaryReader.ReadInt32(); data[i - 1].ScriptText = new string(binaryReader.ReadChars(data[i - 1].ScriptLength)); } cnt_npcinit = binaryReader.ReadInt32(); npcdata = new StructNFSNPC[cnt_npcinit]; for (int i = 1; i <= cnt_npcinit; i++) { npcdata[i - 1] = new StructNFSNPC(); npcdata[i - 1].id = binaryReader.ReadInt16(); npcdata[i - 1].unknown1 = binaryReader.ReadInt16(); //npcdata[i - 1].x = (int)(binaryReader.ReadSingle() / (float)5.25); //npcdata[i - 1].y = mirrory((int)(binaryReader.ReadSingle() / (float)5.25)); npcdata[i - 1].x = (int)(binaryReader.ReadSingle() + Hexcnv.GetCoords(this.filename, 1)); npcdata[i - 1].y = (int)(binaryReader.ReadSingle() + Hexcnv.GetCoords(this.filename, 2)); npcdata[i - 1].propID = binaryReader.ReadInt16(); //14 //binaryReader.ReadBytes(2); npcdata[i - 1].unknown2 = binaryReader.ReadInt32(); //18 npcdata[i - 1].unknown4 = binaryReader.ReadInt32(); //22 //binaryReader.ReadBytes(4); npcdata[i - 1].cnt_initscript = binaryReader.ReadInt32(); //26 npcdata[i - 1].initscript = new string(binaryReader.ReadChars(npcdata[i - 1].cnt_initscript)); if (this.loadstrings && npcdata[i - 1].initscript.Contains("init_npc")) { Match match = Regex.Match(npcdata[i - 1].initscript, @".*\((?<inner>.*)\,.*"); Match replace = Regex.Match(npcdata[i - 1].initscript, "\"([^\"]*)\""); int name_id = Convert.ToInt32(match.Groups["inner"].Value); string replacer = replace.ToString(); string name = strings.get_NPCname(name_id + 100000000); npcdata[i - 1].name = name; name = "\"" + name + "\""; npcdata[i - 1].initscript = npcdata[i - 1].initscript.Replace(replacer, name); } else { npcdata[i - 1].name = "No StringResource found!"; } npcdata[i - 1].cnt_initscript = npcdata[i - 1].initscript.Length; if (npcdata[i - 1].unknown2 == 2) { npcdata[i - 1].type = binaryReader.ReadInt32(); npcdata[i - 1].cnt_contact = binaryReader.ReadInt32(); npcdata[i - 1].contact = new string(binaryReader.ReadChars(npcdata[i - 1].cnt_contact)); } } } } } this.error = false; this.check = true; } catch //(Exception ex) { //throw new Exception(ex.ToString()); this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } }
private void loadData() { try { if (File.Exists(this.fullpath)) { FileStream fileStream = File.Open(this.fullpath, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader binaryReader = new BinaryReader(fileStream, Encoding.ASCII); this.cnt = binaryReader.ReadInt32(); data = new StructNFC[this.cnt]; for (int i = 1; i <= this.cnt; i++) { data[i - 1] = new StructNFC(); data[i - 1].id = i; data[i - 1].type = binaryReader.ReadInt32(); data[i - 1].unknown1 = binaryReader.ReadInt32(); data[i - 1].unknown2 = binaryReader.ReadInt32(); data[i - 1].unknown3 = binaryReader.ReadInt32(); data[i - 1].unknown4 = binaryReader.ReadInt32(); data[i - 1].cnt_name = binaryReader.ReadInt32(); data[i - 1].name = new string(binaryReader.ReadChars(data[i - 1].cnt_name)); data[i - 1].cnt_script = binaryReader.ReadInt32(); data[i - 1].script = new string(binaryReader.ReadChars(data[i - 1].cnt_script)); if (this.loadstrings && data[i - 1].script.Contains("call_lc")) { Match match = Regex.Match(data[i - 1].script, @".*\((?<inner>.*)\).*"); int name_id = Convert.ToInt32(match.Groups["inner"].Value); data[i - 1].name = strings.get_Wname(name_id + 70000000); } else { data[i - 1].name = "No StringResource found or unable to parse script!"; } data[i - 1].cnt_name = data[i - 1].name.Length; data[i - 1].cnt_coords = binaryReader.ReadInt32(); data[i - 1].coords = new NFCCoords[data[i - 1].cnt_coords]; for (int k = 1; k <= data[i - 1].cnt_coords; k++) { data[i - 1].coords[k - 1] = new NFCCoords(); data[i - 1].coords[k - 1].cnt_coords = binaryReader.ReadInt32(); data[i - 1].coords[k - 1].coords = new PointF[data[i - 1].coords[k - 1].cnt_coords + 1]; data[i - 1].coord = data[i - 1].coord + k + ": {"; int stringcnt = 0; for (int j = 1; j <= data[i - 1].coords[k - 1].cnt_coords; j++) { int x = binaryReader.ReadInt32(); int y = mirrory(binaryReader.ReadInt32()); data[i - 1].coords[k - 1].coords[j - 1].X = x; data[i - 1].coords[k - 1].coords[j - 1].Y = y; data[i - 1].coord = data[i - 1].coord + j + ". (" + ((x * 5.25) + Hexcnv.GetCoords(this.filename, 1)) + ", " + (((3072 - y) * 5.25) + Hexcnv.GetCoords(this.filename, 2)) + ") "; if (stringcnt == 7) { data[i - 1].coord = data[i - 1].coord + "\n"; stringcnt = 0; } else { stringcnt++; } if (j - 1 == 0) { data[i - 1].coords[k - 1].coords[data[i - 1].coords[k - 1].cnt_coords] = new Point(x, y); } } data[i - 1].coord = data[i - 1].coord + "} "; if (this.data[i - 1].cnt_coords > 1) { this.data[i - 1].coord = data[i - 1].coord + "\n"; } } } binaryReader.Close(); fileStream.Close(); } this.check = true; this.error = false; } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } }
private void updatecoordstring(int id) { this.data[id].coord = ""; for (int i = 0; i < this.data[id].cnt_coords; i++) { this.data[id].coord = data[id].coord + (i + 1) + ": {"; int stringcnt = 0; for (int j = 0; j < this.data[id].coords[i].coords.Length - 1; j++) { data[id].coord = data[id].coord + (j + 1) + ". (" + ((data[id].coords[i].coords[j].X * 5.25) + Hexcnv.GetCoords(this.filename, 1)).ToString() + ", " + (((3072 - data[id].coords[i].coords[j].Y) * 5.25) + Hexcnv.GetCoords(this.filename, 2)).ToString() + ") "; if (stringcnt == 7) { data[id].coord = data[id].coord + "\n"; stringcnt = 0; } else { stringcnt++; } } this.data[id].coord = data[id].coord + "}"; if (this.data[id].cnt_coords > 1) { this.data[id].coord = data[id].coord + "\n"; } } }
private void loadData() { try { if (File.Exists(this.fullpath)) { FileStream fileStream = File.Open(this.fullpath, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryReader binaryReader = new BinaryReader(fileStream, Encoding.ASCII); this.cnt = binaryReader.ReadInt32(); data = new StructNFE[this.cnt]; for (int i = 1; i <= this.cnt; i++) { data[i - 1] = new StructNFE(); data[i - 1].id = binaryReader.ReadInt32(); data[i - 1].type = binaryReader.ReadInt32(); data[i - 1].count_coords = binaryReader.ReadInt32(); data[i - 1].coords = new PointF[data[i - 1].count_coords + 1]; for (int j = 1; j <= data[i - 1].count_coords; j++) { int x = binaryReader.ReadInt32(); int y = mirrory(binaryReader.ReadInt32()); data[i - 1].coords[j - 1].X = x; data[i - 1].coords[j - 1].Y = y; data[i - 1].coord = data[i - 1].coord + j + ". (" + ((x * 5.25) + Hexcnv.GetCoords(this.filename, 1)) + ", " + (((3072 - y) * 5.25) + Hexcnv.GetCoords(this.filename, 2)) + ")"; if (j - 1 == 0) { data[i - 1].coords[data[i - 1].count_coords] = new Point(x, y); } } } binaryReader.Close(); fileStream.Close(); this.error = false; this.check = true; } } catch { this.error = true; this.MapImg = new Bitmap(3072, 3072); this.check = false; } }
private void updateCoordString(int id) { this.data[id].coord = ""; for (int i = 0; i < this.data[id].count_coords; i++) { this.data[id].coord = this.data[id].coord + (i + 1) + ".(" + ((this.data[id].coords[i].X * 5.25) + Hexcnv.GetCoords(this.filename, 1)) + ", " + (((3072 - this.data[id].coords[i].Y) * 5.25) + Hexcnv.GetCoords(this.filename, 2)) + ")"; } }