/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is SystemPartData)) { return; } SystemPartData mData = (SystemPartData)data; this.version = mData.version; this.serverTime = mData.serverTime; this.isBlock = mData.isBlock; this.flowStep = mData.flowStep; this.keepSave = mData.keepSave; this.clientRandomSeeds = mData.clientRandomSeeds; this.clientRandomSeedIndex = mData.clientRandomSeedIndex; this.clientOfflineWorkReceiveIndex = mData.clientOfflineWorkReceiveIndex; this.gmCommandSet = mData.gmCommandSet; this.gmType = mData.gmType; this.serverBornCode = mData.serverBornCode; this.serverStartTime = mData.serverStartTime; this.logQueue = mData.logQueue; this.nextDailyTime = mData.nextDailyTime; this.createDate = mData.createDate; this.clientRandomSeedKey = mData.clientRandomSeedKey; }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { stream.startReadObj(); this.keep = (KeepSaveData)stream.createData(KeepSaveData.dataID); this.keep.readBytesFull(stream); stream.endReadObj(); }
private void doSave(KeepSaveData data) { _stream.clear(); _stream.writeVersion(ShineGlobal.localSaveVersion); data.writeBytesFull(_stream); FileUtils.writeFileForBytes(_localSavePath, _stream); }
/// <summary> /// 初始化初值 /// </summary> public override void initDefault() { this.version = new SaveVersionData(); this.version.initDefault(); this.keepSave = new KeepSaveData(); this.keepSave.initDefault(); this.logQueue = new SQueue <InfoLogData>(); this.createDate = new DateData(); this.createDate.initDefault(); }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is ClientPlayerLocalCacheData)) { return; } ClientPlayerLocalCacheData mData = (ClientPlayerLocalCacheData)data; this.keep = mData.keep; }
/// <summary> /// 保存本地文件 /// </summary> private void save() { KeepSaveData data = new KeepSaveData(); data.copy(_data); ThreadControl.addIOFunc(() => { doSave(data); }); }
/// <summary> /// 复制(潜拷贝) /// </summary> protected override void toShadowCopy(BaseData data) { if (!(data is KeepSaveData)) { return; } KeepSaveData mData = (KeepSaveData)data; this.booleanDic = mData.booleanDic; this.intDic = mData.intDic; this.longDic = mData.longDic; this.stringDic = mData.stringDic; }
/// <summary> /// 读取本地文件 /// </summary> private void load() { _data = new KeepSaveData(); BytesReadStream stream = FileUtils.readFileForBytesReadStream(_localSavePath); if (stream != null && stream.checkVersion(ShineGlobal.localSaveVersion)) { _data.readBytesFull(stream); } else { _data.initDefault(); } }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { this.version = null; this.serverTime = 0L; this.isBlock = false; this.flowStep = 0; this.keepSave = null; this.clientRandomSeeds = null; this.clientRandomSeedIndex = 0; this.clientOfflineWorkReceiveIndex = 0; this.gmCommandSet = null; this.gmType = 0; this.serverBornCode = 0; this.serverStartTime = 0L; this.logQueue = null; this.nextDailyTime = 0L; this.createDate = null; this.clientRandomSeedKey = 0; }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is ClientPlayerLocalCacheData)) { return; } ClientPlayerLocalCacheData mData = (ClientPlayerLocalCacheData)data; if (mData.keep != null) { this.keep = (KeepSaveData)BytesControl.createData(KeepSaveData.dataID); this.keep.copy(mData.keep); } else { this.keep = null; nullObjError("keep"); } }
/// <summary> /// 回池 /// </summary> protected override void toRelease(DataPool pool) { this.keep = null; }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { this.keep = (KeepSaveData)stream.createData(KeepSaveData.dataID); this.keep.readBytesSimple(stream); }
/// <summary> /// 读取字节流(完整版) /// </summary> protected override void toReadBytesFull(BytesReadStream stream) { stream.startReadObj(); BaseData versionT = stream.readDataFullNotNull(); if (versionT != null) { if (versionT is SaveVersionData) { this.version = (SaveVersionData)versionT; } else { this.version = new SaveVersionData(); if (!(versionT.GetType().IsAssignableFrom(typeof(SaveVersionData)))) { stream.throwTypeReadError(typeof(SaveVersionData), versionT.GetType()); } this.version.shadowCopy(versionT); } } else { this.version = null; } this.serverTime = stream.readLong(); this.isBlock = stream.readBoolean(); this.flowStep = stream.readInt(); this.keepSave = (KeepSaveData)stream.createData(KeepSaveData.dataID); this.keepSave.readBytesFull(stream); if (stream.readBoolean()) { int clientRandomSeedsLen = stream.readLen(); if (this.clientRandomSeeds == null || this.clientRandomSeeds.Length != clientRandomSeedsLen) { this.clientRandomSeeds = new int[clientRandomSeedsLen]; } int[] clientRandomSeedsT = this.clientRandomSeeds; for (int clientRandomSeedsI = 0; clientRandomSeedsI < clientRandomSeedsLen; ++clientRandomSeedsI) { int clientRandomSeedsV; clientRandomSeedsV = stream.readInt(); clientRandomSeedsT[clientRandomSeedsI] = clientRandomSeedsV; } } else { this.clientRandomSeeds = null; } this.clientRandomSeedIndex = stream.readInt(); this.clientOfflineWorkReceiveIndex = stream.readInt(); if (stream.readBoolean()) { int gmCommandSetLen = stream.readLen(); if (this.gmCommandSet != null) { this.gmCommandSet.clear(); this.gmCommandSet.ensureCapacity(gmCommandSetLen); } else { this.gmCommandSet = new SSet <string>(); } SSet <string> gmCommandSetT = this.gmCommandSet; for (int gmCommandSetI = gmCommandSetLen - 1; gmCommandSetI >= 0; --gmCommandSetI) { string gmCommandSetV; gmCommandSetV = stream.readUTF(); gmCommandSetT.add(gmCommandSetV); } } else { this.gmCommandSet = null; } this.gmType = stream.readInt(); this.serverBornCode = stream.readInt(); this.serverStartTime = stream.readLong(); int logQueueLen = stream.readLen(); if (this.logQueue != null) { this.logQueue.clear(); this.logQueue.ensureCapacity(logQueueLen); } else { this.logQueue = new SQueue <InfoLogData>(); } SQueue <InfoLogData> logQueueT = this.logQueue; for (int logQueueI = logQueueLen - 1; logQueueI >= 0; --logQueueI) { InfoLogData logQueueV; BaseData logQueueVT = stream.readDataFullNotNull(); if (logQueueVT != null) { if (logQueueVT is InfoLogData) { logQueueV = (InfoLogData)logQueueVT; } else { logQueueV = new InfoLogData(); if (!(logQueueVT.GetType().IsAssignableFrom(typeof(InfoLogData)))) { stream.throwTypeReadError(typeof(InfoLogData), logQueueVT.GetType()); } logQueueV.shadowCopy(logQueueVT); } } else { logQueueV = null; } logQueueT.offer(logQueueV); } this.nextDailyTime = stream.readLong(); this.createDate = (DateData)stream.createData(DateData.dataID); this.createDate.readBytesFull(stream); this.clientRandomSeedKey = stream.readInt(); stream.endReadObj(); }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is SystemPartData)) { return; } SystemPartData mData = (SystemPartData)data; if (mData.version != null) { this.version = (SaveVersionData)mData.version.clone(); } else { this.version = null; nullObjError("version"); } this.serverTime = mData.serverTime; this.isBlock = mData.isBlock; this.flowStep = mData.flowStep; if (mData.keepSave != null) { this.keepSave = (KeepSaveData)BytesControl.createData(KeepSaveData.dataID); this.keepSave.copy(mData.keepSave); } else { this.keepSave = null; nullObjError("keepSave"); } if (mData.clientRandomSeeds != null) { int[] clientRandomSeedsR = mData.clientRandomSeeds; int clientRandomSeedsLen = clientRandomSeedsR.Length; if (this.clientRandomSeeds == null || this.clientRandomSeeds.Length != clientRandomSeedsLen) { this.clientRandomSeeds = new int[clientRandomSeedsLen]; } BytesControl.arrayCopy(mData.clientRandomSeeds, this.clientRandomSeeds, clientRandomSeedsLen); } else { this.clientRandomSeeds = null; } this.clientRandomSeedIndex = mData.clientRandomSeedIndex; this.clientOfflineWorkReceiveIndex = mData.clientOfflineWorkReceiveIndex; if (mData.gmCommandSet != null) { if (this.gmCommandSet != null) { this.gmCommandSet.clear(); this.gmCommandSet.ensureCapacity(mData.gmCommandSet.size()); } else { this.gmCommandSet = new SSet <string>(); } SSet <string> gmCommandSetT = this.gmCommandSet; if (!mData.gmCommandSet.isEmpty()) { string[] gmCommandSetVKeys = mData.gmCommandSet.getKeys(); for (int gmCommandSetVI = gmCommandSetVKeys.Length - 1; gmCommandSetVI >= 0; --gmCommandSetVI) { if (gmCommandSetVKeys[gmCommandSetVI] != null) { string gmCommandSetV = gmCommandSetVKeys[gmCommandSetVI]; string gmCommandSetU; gmCommandSetU = gmCommandSetV; gmCommandSetT.add(gmCommandSetU); } } } } else { this.gmCommandSet = null; } this.gmType = mData.gmType; this.serverBornCode = mData.serverBornCode; this.serverStartTime = mData.serverStartTime; if (mData.logQueue != null) { if (this.logQueue != null) { this.logQueue.clear(); this.logQueue.ensureCapacity(mData.logQueue.size()); } else { this.logQueue = new SQueue <InfoLogData>(); } SQueue <InfoLogData> logQueueT = this.logQueue; if (!mData.logQueue.isEmpty()) { InfoLogData[] logQueueVValues = mData.logQueue.getValues(); int logQueueVMark = mData.logQueue.getMark(); int logQueueVStart = mData.logQueue.getStart(); for (int logQueueVI = 0, logQueueVLen = mData.logQueue.length(); logQueueVI < logQueueVLen; ++logQueueVI) { InfoLogData logQueueV = logQueueVValues[(logQueueVI + logQueueVStart) & logQueueVMark]; InfoLogData logQueueU; if (logQueueV != null) { logQueueU = (InfoLogData)logQueueV.clone(); } else { logQueueU = null; nullObjError("logQueueU"); } logQueueT.offer(logQueueU); } } } else { this.logQueue = null; nullObjError("logQueue"); } this.nextDailyTime = mData.nextDailyTime; if (mData.createDate != null) { this.createDate = (DateData)BytesControl.createData(DateData.dataID); this.createDate.copy(mData.createDate); } else { this.createDate = null; nullObjError("createDate"); } this.clientRandomSeedKey = mData.clientRandomSeedKey; }
/// <summary> /// 复制(深拷贝) /// </summary> protected override void toCopy(BaseData data) { if (!(data is KeepSaveData)) { return; } KeepSaveData mData = (KeepSaveData)data; if (mData.booleanDic != null) { if (this.booleanDic != null) { this.booleanDic.clear(); this.booleanDic.ensureCapacity(mData.booleanDic.size()); } else { this.booleanDic = new IntBooleanMap(mData.booleanDic.size()); } IntBooleanMap booleanDicT = this.booleanDic; if (!mData.booleanDic.isEmpty()) { int booleanDicKFreeValue = mData.booleanDic.getFreeValue(); int[] booleanDicKKeys = mData.booleanDic.getKeys(); bool[] booleanDicVValues = mData.booleanDic.getValues(); for (int booleanDicKI = booleanDicKKeys.Length - 1; booleanDicKI >= 0; --booleanDicKI) { int booleanDicK = booleanDicKKeys[booleanDicKI]; if (booleanDicK != booleanDicKFreeValue) { bool booleanDicV = booleanDicVValues[booleanDicKI]; int booleanDicW; bool booleanDicU; booleanDicW = booleanDicK; booleanDicU = booleanDicV; booleanDicT.put(booleanDicW, booleanDicU); } } } } else { this.booleanDic = null; nullObjError("booleanDic"); } if (mData.intDic != null) { if (this.intDic != null) { this.intDic.clear(); this.intDic.ensureCapacity(mData.intDic.size()); } else { this.intDic = new IntIntMap(mData.intDic.size()); } IntIntMap intDicT = this.intDic; if (!mData.intDic.isEmpty()) { int intDicKFreeValue = mData.intDic.getFreeValue(); int[] intDicKKeys = mData.intDic.getKeys(); int[] intDicVValues = mData.intDic.getValues(); for (int intDicKI = intDicKKeys.Length - 1; intDicKI >= 0; --intDicKI) { int intDicK = intDicKKeys[intDicKI]; if (intDicK != intDicKFreeValue) { int intDicV = intDicVValues[intDicKI]; int intDicW; int intDicU; intDicW = intDicK; intDicU = intDicV; intDicT.put(intDicW, intDicU); } } } } else { this.intDic = null; nullObjError("intDic"); } if (mData.longDic != null) { if (this.longDic != null) { this.longDic.clear(); this.longDic.ensureCapacity(mData.longDic.size()); } else { this.longDic = new IntLongMap(mData.longDic.size()); } IntLongMap longDicT = this.longDic; if (!mData.longDic.isEmpty()) { int longDicKFreeValue = mData.longDic.getFreeValue(); int[] longDicKKeys = mData.longDic.getKeys(); long[] longDicVValues = mData.longDic.getValues(); for (int longDicKI = longDicKKeys.Length - 1; longDicKI >= 0; --longDicKI) { int longDicK = longDicKKeys[longDicKI]; if (longDicK != longDicKFreeValue) { long longDicV = longDicVValues[longDicKI]; int longDicW; long longDicU; longDicW = longDicK; longDicU = longDicV; longDicT.put(longDicW, longDicU); } } } } else { this.longDic = null; nullObjError("longDic"); } if (mData.stringDic != null) { if (this.stringDic != null) { this.stringDic.clear(); this.stringDic.ensureCapacity(mData.stringDic.size()); } else { this.stringDic = new SMap <string, string>(mData.stringDic.size()); } SMap <string, string> stringDicT = this.stringDic; if (!mData.stringDic.isEmpty()) { string[] stringDicKKeys = mData.stringDic.getKeys(); string[] stringDicVValues = mData.stringDic.getValues(); for (int stringDicKI = stringDicKKeys.Length - 1; stringDicKI >= 0; --stringDicKI) { string stringDicK = stringDicKKeys[stringDicKI]; if (stringDicK != null) { string stringDicV = stringDicVValues[stringDicKI]; string stringDicW; string stringDicU; stringDicW = stringDicK; stringDicU = stringDicV; stringDicT.put(stringDicW, stringDicU); } } } } else { this.stringDic = null; nullObjError("stringDic"); } }
/// <summary> /// 读取字节流(简版) /// </summary> protected override void toReadBytesSimple(BytesReadStream stream) { this.version = (SaveVersionData)stream.readDataSimpleNotNull(); this.serverTime = stream.readLong(); this.isBlock = stream.readBoolean(); this.flowStep = stream.readInt(); this.keepSave = (KeepSaveData)stream.createData(KeepSaveData.dataID); this.keepSave.readBytesSimple(stream); if (stream.readBoolean()) { int clientRandomSeedsLen = stream.readLen(); if (this.clientRandomSeeds == null || this.clientRandomSeeds.Length != clientRandomSeedsLen) { this.clientRandomSeeds = new int[clientRandomSeedsLen]; } int[] clientRandomSeedsT = this.clientRandomSeeds; for (int clientRandomSeedsI = 0; clientRandomSeedsI < clientRandomSeedsLen; ++clientRandomSeedsI) { int clientRandomSeedsV; clientRandomSeedsV = stream.readInt(); clientRandomSeedsT[clientRandomSeedsI] = clientRandomSeedsV; } } else { this.clientRandomSeeds = null; } this.clientRandomSeedIndex = stream.readInt(); this.clientOfflineWorkReceiveIndex = stream.readInt(); if (stream.readBoolean()) { int gmCommandSetLen = stream.readLen(); if (this.gmCommandSet != null) { this.gmCommandSet.clear(); this.gmCommandSet.ensureCapacity(gmCommandSetLen); } else { this.gmCommandSet = new SSet <string>(); } SSet <string> gmCommandSetT = this.gmCommandSet; for (int gmCommandSetI = gmCommandSetLen - 1; gmCommandSetI >= 0; --gmCommandSetI) { string gmCommandSetV; gmCommandSetV = stream.readUTF(); gmCommandSetT.add(gmCommandSetV); } } else { this.gmCommandSet = null; } this.gmType = stream.readInt(); this.serverBornCode = stream.readInt(); this.serverStartTime = stream.readLong(); int logQueueLen = stream.readLen(); if (this.logQueue != null) { this.logQueue.clear(); this.logQueue.ensureCapacity(logQueueLen); } else { this.logQueue = new SQueue <InfoLogData>(); } SQueue <InfoLogData> logQueueT = this.logQueue; for (int logQueueI = logQueueLen - 1; logQueueI >= 0; --logQueueI) { InfoLogData logQueueV; logQueueV = (InfoLogData)stream.readDataSimpleNotNull(); logQueueT.offer(logQueueV); } this.nextDailyTime = stream.readLong(); this.createDate = (DateData)stream.createData(DateData.dataID); this.createDate.readBytesSimple(stream); this.clientRandomSeedKey = stream.readInt(); }
/// <summary> /// 初始化初值 /// </summary> public override void initDefault() { this.keep = new KeepSaveData(); this.keep.initDefault(); }
/// <summary> /// 是否数据一致 /// </summary> protected override bool toDataEquals(BaseData data) { KeepSaveData mData = (KeepSaveData)data; if (mData.booleanDic != null) { if (this.booleanDic == null) { return(false); } if (this.booleanDic.size() != mData.booleanDic.size()) { return(false); } IntBooleanMap booleanDicR = mData.booleanDic; if (!this.booleanDic.isEmpty()) { int booleanDicKFreeValue = this.booleanDic.getFreeValue(); int[] booleanDicKKeys = this.booleanDic.getKeys(); bool[] booleanDicVValues = this.booleanDic.getValues(); for (int booleanDicKI = booleanDicKKeys.Length - 1; booleanDicKI >= 0; --booleanDicKI) { int booleanDicK = booleanDicKKeys[booleanDicKI]; if (booleanDicK != booleanDicKFreeValue) { bool booleanDicV = booleanDicVValues[booleanDicKI]; bool booleanDicU = booleanDicR.get(booleanDicK); if (booleanDicV != booleanDicU) { return(false); } } } } } else { if (this.booleanDic != null) { return(false); } } if (mData.intDic != null) { if (this.intDic == null) { return(false); } if (this.intDic.size() != mData.intDic.size()) { return(false); } IntIntMap intDicR = mData.intDic; if (!this.intDic.isEmpty()) { int intDicKFreeValue = this.intDic.getFreeValue(); int[] intDicKKeys = this.intDic.getKeys(); int[] intDicVValues = this.intDic.getValues(); for (int intDicKI = intDicKKeys.Length - 1; intDicKI >= 0; --intDicKI) { int intDicK = intDicKKeys[intDicKI]; if (intDicK != intDicKFreeValue) { int intDicV = intDicVValues[intDicKI]; int intDicU = intDicR.get(intDicK); if (intDicV != intDicU) { return(false); } } } } } else { if (this.intDic != null) { return(false); } } if (mData.longDic != null) { if (this.longDic == null) { return(false); } if (this.longDic.size() != mData.longDic.size()) { return(false); } IntLongMap longDicR = mData.longDic; if (!this.longDic.isEmpty()) { int longDicKFreeValue = this.longDic.getFreeValue(); int[] longDicKKeys = this.longDic.getKeys(); long[] longDicVValues = this.longDic.getValues(); for (int longDicKI = longDicKKeys.Length - 1; longDicKI >= 0; --longDicKI) { int longDicK = longDicKKeys[longDicKI]; if (longDicK != longDicKFreeValue) { long longDicV = longDicVValues[longDicKI]; long longDicU = longDicR.get(longDicK); if (longDicV != longDicU) { return(false); } } } } } else { if (this.longDic != null) { return(false); } } if (mData.stringDic != null) { if (this.stringDic == null) { return(false); } if (this.stringDic.size() != mData.stringDic.size()) { return(false); } SMap <string, string> stringDicR = mData.stringDic; if (!this.stringDic.isEmpty()) { string[] stringDicKKeys = this.stringDic.getKeys(); string[] stringDicVValues = this.stringDic.getValues(); for (int stringDicKI = stringDicKKeys.Length - 1; stringDicKI >= 0; --stringDicKI) { string stringDicK = stringDicKKeys[stringDicKI]; if (stringDicK != null) { string stringDicV = stringDicVValues[stringDicKI]; string stringDicU = stringDicR.get(stringDicK); if (stringDicV != stringDicU) { return(false); } } } } } else { if (this.stringDic != null) { return(false); } } return(true); }