chore(m2): 保存功能验收及后续清理前检查点
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using asap.core;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
@@ -67,19 +67,33 @@ namespace game
|
||||
}
|
||||
internal bool HasFormalPromptOwner(PlayerDataStorage.PlayerKVGameSessionHandle owner) =>
|
||||
requiresFormalKV && ReferenceEquals(promptOwner, owner);
|
||||
|
||||
internal void ReleaseFailedPromptOwner(PlayerDataStorage.PlayerKVGameSessionHandle owner)
|
||||
{
|
||||
if (promptOwner == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!ReferenceEquals(promptOwner, owner) || owner.Status != PlayerDataStorage.PlayerKVSyncStatus.Closed)
|
||||
{
|
||||
throw DefaultSettingService.PromptFailure("IsOpenClubRed: failed owner has not closed.");
|
||||
}
|
||||
promptOwner = null;
|
||||
LastPromptEdit = null;
|
||||
}
|
||||
internal void RequirePromptOwner()
|
||||
{
|
||||
if (promptOwner != null) ReadPrompt();
|
||||
else if (requiresFormalKV)
|
||||
throw DefaultSettingService.PromptFailure("IsOpenClubRed: formal owner not handed off.");
|
||||
}
|
||||
PlayerDataStorage.PlayerKVKeyReadResult ReadPrompt()
|
||||
private PlayerDataStorage.PlayerKVKeyReadResult ReadPrompt()
|
||||
{
|
||||
if (LastPromptEdit != null && !LastPromptEdit.Accepted)
|
||||
throw DefaultSettingService.PromptFailure($"IsOpenClubRed owner={promptOwner.OwnerInstanceId}: {LastPromptEdit.StateResult.Error}; uncertain={LastPromptEdit.StateResult.LocalCommitMayHaveSucceeded}");
|
||||
var read = KVMgr.ReadKV(promptOwner, "IsOpenClubRed");
|
||||
if (!read.Success)
|
||||
{
|
||||
throw DefaultSettingService.PromptFailure($"IsOpenClubRed owner={promptOwner.OwnerInstanceId}: {read.Error}");
|
||||
}
|
||||
return read;
|
||||
}
|
||||
// END B01 fixed prompt owner
|
||||
@@ -101,25 +115,10 @@ namespace game
|
||||
LureDonateData lureDonateData;
|
||||
|
||||
// KV loading owns these three fields only; membership, transport and chat lifecycle stay untouched.
|
||||
internal static PlayerDataStorage.PlayerKVClubState DecodeForKVLoad(IReadOnlyDictionary<string,string> raw,
|
||||
PlayerDataStorage.PlayerKVSchemaSnapshot snapshot, PlayerDataStorage.PlayerKVSchemaDiagnostics errors) =>
|
||||
PlayerDataStorage.PlayerKVSaveSchema.DecodeClub(raw,snapshot,errors);
|
||||
internal void ResetForKVLoad()
|
||||
{
|
||||
signTime = null;
|
||||
lureDonateData = new LureDonateData();
|
||||
IsOpenClubRed = true;
|
||||
}
|
||||
internal void ReplaceFromKVDecoded(PlayerDataStorage.PlayerKVClubState state)
|
||||
{
|
||||
if (state == null) throw new ArgumentNullException(nameof(state));
|
||||
var donation = new LureDonateData { DonateCountTime=state.DonateTime,
|
||||
ClubLureDonateCount=state.DonateCount, ClubLureRequestCDEnd=state.RequestEnd };
|
||||
signTime = state.SignTime; lureDonateData = donation; IsOpenClubRed = state.OpenRed;
|
||||
}
|
||||
internal PlayerDataStorage.PlayerKVClubState SnapshotForKVValidation() =>
|
||||
new PlayerDataStorage.PlayerKVClubState(signTime,lureDonateData.DonateCountTime,
|
||||
lureDonateData.ClubLureDonateCount,lureDonateData.ClubLureRequestCDEnd,IsOpenClubRed);
|
||||
|
||||
|
||||
|
||||
|
||||
public int ClubLureDonateCount => lureDonateData.ClubLureDonateCount;
|
||||
public DateTime ClubLureRequestCDEnd => lureDonateData.ClubLureRequestCDEnd;
|
||||
|
||||
@@ -203,20 +202,24 @@ namespace game
|
||||
|
||||
public void SetOpenClubRed()
|
||||
{
|
||||
if (requiresFormalKV && promptOwner == null) RequirePromptOwner();
|
||||
if (requiresFormalKV && promptOwner == null)
|
||||
{
|
||||
RequirePromptOwner();
|
||||
}
|
||||
if (promptOwner != null)
|
||||
{
|
||||
var read = ReadPrompt();
|
||||
// M14: any present string means read, including "0" and the empty string.
|
||||
if (read.Found != true)
|
||||
ReadPrompt();
|
||||
if (IsOpenClubRed)
|
||||
{
|
||||
IsOpenClubRed = false;
|
||||
SetClubRed();
|
||||
LastPromptEdit = KVMgr.WriteKV(promptOwner, "IsOpenClubRed", "1");
|
||||
if (!LastPromptEdit.Accepted)
|
||||
{
|
||||
throw DefaultSettingService.PromptFailure($"IsOpenClubRed owner={promptOwner.OwnerInstanceId}: {LastPromptEdit.StateResult.Error}; uncertain={LastPromptEdit.StateResult.LocalCommitMayHaveSucceeded}");
|
||||
}
|
||||
}
|
||||
RequirePromptOwner();
|
||||
IsOpenClubRed = false;
|
||||
SetClubRed();
|
||||
return;
|
||||
}
|
||||
if (IsOpenClubRed)
|
||||
|
||||
Reference in New Issue
Block a user