Skip to content

Commit

Permalink
Merge pull request eesast#220 from shangfengh/dev
Browse files Browse the repository at this point in the history
delete a log in RPC
  • Loading branch information
DragonAura authored Apr 13, 2024
2 parents d25b6ac + 22b5879 commit 4bdacd2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,33 @@ public void SetAndStop(long value = 0)
public class TimeBasedProgressAtVariableSpeed
{
private readonly LongInVariableRangeWithStartTime progress;
public AtomicDouble speed;
private IDouble speed;
/// <summary>
/// 注意:set操作(即=)的真正意义是改变其引用,单纯改变值不应当使用该操作
/// </summary>
public IDouble Speed
{
get
{
return Interlocked.CompareExchange(ref speed!, null, null);
}
set
{
Interlocked.Exchange(ref speed, value);
}
}

#region 构造
public TimeBasedProgressAtVariableSpeed(long needProgress, double speed = 1.0)
{
progress = new LongInVariableRangeWithStartTime(0, needProgress);
if (needProgress <= 0) Debugger.Output("Bug:TimeBasedProgressAtVariableSpeed.needProgress (" + needProgress.ToString() + ") is less than 0.");
this.speed = new(speed);
this.speed = new AtomicDouble(speed);
}
public TimeBasedProgressAtVariableSpeed()
{
progress = new LongInVariableRangeWithStartTime(0, 0);
this.speed = new(1.0);
this.speed = new AtomicDouble(1.0);
}
#endregion

Expand All @@ -125,22 +139,22 @@ public override string ToString()
+ " ; LastStartTime: " + lastStartTime.ToString() + "ms"
+ " ; Speed: " + speed.ToString();
}
public long GetProgressNow() => progress.AddStartTimeToMaxV((double)speed).Item1;
public (long, long, long) GetProgressNowAndNeedTimeAndLastStartTime() => progress.AddStartTimeToMaxV((double)speed);
public long GetProgressNow() => progress.AddStartTimeToMaxV(speed.ToDouble()).Item1;
public (long, long, long) GetProgressNowAndNeedTimeAndLastStartTime() => progress.AddStartTimeToMaxV(speed.ToDouble());
public long GetProgressStored() => progress.GetValue();
public (long, long) GetProgressStoredAndNeedTime() => progress.GetValueAndMaxV();
public (long, long, long) GetProgressStoredAndNeedTimeAndLastStartTime() => progress.GetValueAndMaxVWithStartTime();

public bool IsFinished()
{
long progressNow, needTime;
(progressNow, needTime, _) = progress.AddStartTimeToMaxV((double)speed);
(progressNow, needTime, _) = progress.AddStartTimeToMaxV(speed.ToDouble());
return progressNow == needTime;
}
public bool IsProgressing()
{
long progressNow, needTime, startT;
(progressNow, needTime, startT) = progress.AddStartTimeToMaxV((double)speed);
(progressNow, needTime, startT) = progress.AddStartTimeToMaxV(speed.ToDouble());
return (startT != long.MaxValue && progressNow != needTime);
}
#endregion
Expand Down Expand Up @@ -172,14 +186,14 @@ public void Set0()
/// </summary>
public void TryStop()
{
progress.Set0IfNotAddStartTimeToMaxV(speed);
progress.Set0IfNotAddStartTimeToMaxV(speed.ToDouble());
}
/// <summary>
/// 使进度条暂停
/// </summary>
public bool Pause()
{
return progress.AddStartTime((double)speed) != 0;
return progress.AddStartTime(speed.ToDouble()) != 0;
}
/// <summary>
/// 使进度条进度为满
Expand Down
3 changes: 0 additions & 3 deletions logic/Server/RpcServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ public override async Task AddPlayer(PlayerMsg request, IServerStreamWriter<Mess
}
}
} while (game.GameMap.Timer.IsGaming);
#if DEBUG
Console.WriteLine("END Add Player");
#endif
}

public override Task<MessageOfMap> GetMap(NullRequest request, ServerCallContext context)
Expand Down

0 comments on commit 4bdacd2

Please sign in to comment.