public void LoadFromStreamBinary(EraBinaryDataReader bReader) { EraSaveFileType fileType = bReader.ReadFileType(); if (fileType != EraSaveFileType.Normal) throw new FileEE("セーブデータが壊れています"); if (!gamebase.UniqueCodeEqualTo(bReader.ReadInt64())) throw new FileEE("異なるゲームのセーブデータです"); Int64 version = bReader.ReadInt64(); if (!gamebase.CheckVersion(version)) throw new FileEE("セーブデータのバーションが異なります"); string text = bReader.ReadString();//PUTFORM varData.SetDefaultValue(constant); varData.SetDefaultLocalValue(); varData.LastLoadVersion = version; //varData.LastLoadNo = dataIndex; varData.LastLoadText = text; int charaCount = (int)bReader.ReadInt64(); varData.CharacterList.Clear(); for (int i = 0; i < charaCount; i++) { CharacterData chara = new CharacterData(constant); varData.CharacterList.Add(chara); chara.LoadFromStreamBinary(bReader); } varData.LoadFromStreamBinary(bReader); }
public void LoadChara(int saveIndex) { string filepath = getSaveDataPathC(saveIndex); if (!File.Exists(filepath)) return; EraBinaryDataReader bReader = null; FileStream fs = null; try { List<CharacterData> addCharaList = new List<CharacterData>(); fs = new FileStream(filepath, FileMode.Open, FileAccess.Read); bReader = EraBinaryDataReader.CreateReader(fs); if (bReader == null) return; if (bReader.ReadFileType() != EraSaveFileType.CharVar) return; if (!gamebase.UniqueCodeEqualTo(bReader.ReadInt64())) return; Int64 version = bReader.ReadInt64(); if (!gamebase.CheckVersion(version)) return; bReader.ReadString();//saveMes Int64 loadnum = bReader.ReadInt64(); for (int i = 0; i < loadnum; i++) { CharacterData chara = new CharacterData(constant); chara.LoadFromStreamBinary(bReader); addCharaList.Add(chara); } varData.CharacterList.AddRange(addCharaList); RESULT = 1; return; } catch (Exception) { RESULT = 0; return; } finally { if (bReader != null) bReader.Close(); else if(fs != null) fs.Close(); } }