static void Main(string[] args) { string filename = @"d:\Download\Sango2\test\Sango01.sav"; Sang_save ssave = new Sang_save(filename); List <Generals> mglist = new List <Generals>(); Monarch m = ssave.getMonarch("曹操"); int count = 0; Generals g = ssave.generalsList[(int)m.generals_index]; mglist.Add(g); Console.WriteLine(count++ + ":" + g.name.Trim('\0')); while (true) { if (g.next_index_in_monarch != 0xffffffff) { g = ssave.generalsList[(int)g.next_index_in_monarch]; Console.WriteLine(count++ + ":" + g.name.Trim('\0')); mglist.Add(g); g.save(); } else { break; } } ssave.save(); List <Generals> otherglist = new List <Generals>(); foreach (Generals g1 in ssave.generalsList) { if (!mglist.Contains(g1)) { otherglist.Add(g1); } } IEnumerable <Generals> query = ssave.reorderGenerals(mglist); //IEnumerable<Generals> query = ssave.reorderGenerals(); //IEnumerable<Generals> query = ssave.reorderGenerals(otherglist); foreach (Generals gq in query) { Console.WriteLine(gq.name.Trim('\0') + "\tlevel:" + gq.experience + "\t" + gq.level + "\t" //+ Convert.ToString(gq.status, 16) + "\t" + ((gq.city_index != 0xffffffff) ? ssave.cityList[(int)gq.city_index].name.Trim('\0') : "no city")); } }
private void load(string filename) { fs = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); BinaryReader br = new BinaryReader(fs); header = br.ReadChars(4); Byte[] bytes = br.ReadBytes(4); version = bytes[2]; br.ReadBytes(4); bytes = br.ReadBytes(0x40); save_title = Encoding.GetEncoding(950).GetString(bytes); br.ReadBytes(4); monarch_index = br.ReadUInt32(); rogue_monarch_index = br.ReadUInt32(); current_year = br.ReadUInt32(); br.ReadBytes(0x4 + 0x4 + 0x4); monarch_nummax = br.ReadUInt32(); monarch_fileoffset = br.ReadUInt32(); monarch_head_index = br.ReadUInt32(); monarch_next_index = br.ReadUInt32(); monarch_tail_index = br.ReadUInt32(); city_nummax = br.ReadUInt32(); city_fileoffset = br.ReadUInt32(); city_head_index = br.ReadUInt32(); city_next_index = br.ReadUInt32(); city_tail_index = br.ReadUInt32(); city_index_inlist = new uint[city_nummax]; for (int i = 0; i < city_nummax; i++) { city_index_inlist[i] = br.ReadUInt32(); } troop_nummax = br.ReadUInt32(); troop_fileoffset = br.ReadUInt32(); troop_head_index = br.ReadUInt32(); troop_next_index = br.ReadUInt32(); troop_tail_index = br.ReadUInt32(); generals_nummax = br.ReadUInt32(); generals_fileoffset = br.ReadUInt32(); generals_head_index = br.ReadUInt32(); generals_next_index = br.ReadUInt32(); generals_tail_index = br.ReadUInt32(); path_nummax = br.ReadUInt32(); path_fileoffset = br.ReadUInt32(); path_point_nummax = br.ReadUInt32(); path_point_fileoffset = br.ReadUInt32(); equipment_nummax = br.ReadUInt32(); equipment_issearched_fileoffset = br.ReadUInt32(); uint max = monarch_tail_index; if (monarch_tail_index > monarch_nummax) { max = monarch_nummax; } for (int i = 0; i < monarch_nummax; i++) { Monarch m = new Monarch(fs); if (i <= max) { monarchList.Add(m); } } for (int i = 0; i < city_nummax; i++) { City c = new City(fs); if (i <= city_tail_index) { cityList.Add(c); } } for (int i = 0; i < troop_nummax; i++) { Troop t = new Troop(fs); } for (int i = 0; i < generals_nummax; i++) { Generals g = new Generals(fs); if (i <= generals_tail_index) { generalsList.Add(g); } } }