public void deleteNPC(int id) { StructNFSNPC[] tmpdata = new StructNFSNPC[this.npcdata.Length - 1]; int j = 0; for (int i = 0; i < this.npcdata.Length; i++) { if (npcdata[i].id != id) { tmpdata[j] = new StructNFSNPC(); tmpdata[j] = npcdata[i]; tmpdata[j].id = j + 1; j++; } } this.npcdata = tmpdata; this.cnt_npcinit = cnt_npcinit - 1; this.editNPC = true; }
public void updateNPCRes(StructNFSNPC tmp) { StructNFSNPC[] tmpdata; if (this.npcdata.Length == 0) { tmpdata = new StructNFSNPC[1]; tmpdata[0] = new StructNFSNPC(); tmpdata[0] = tmp; } else { tmpdata = new StructNFSNPC[this.npcdata.Length + 1]; for (int i = 0; i < this.npcdata.Length; i++) { tmpdata[i] = new StructNFSNPC(); tmpdata[i] = npcdata[i]; } tmpdata[this.npcdata.Length] = new StructNFSNPC(); tmpdata[this.npcdata.Length] = tmp; } this.npcdata = tmpdata; this.cnt_npcinit = cnt_npcinit + 1; this.editNPC = true; }
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; } }