Skip to content

Commit 35b61f0

Browse files
Don't continously reset Status3 message, after having done a draw op once.
1 parent 901676a commit 35b61f0

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

fCraft/Player/Player.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,8 @@ internal UndoState RedoPop() {
15461546

15471547
[NotNull]
15481548
internal UndoState RedoBegin( DrawOperation op ) {
1549-
LastDrawOp = op;
1549+
LastDrawOp = op;
1550+
AnnouncedLastDrawOpFinished = false;
15501551
UndoState newState = new UndoState( op );
15511552
undoStack.AddLast( newState );
15521553
return newState;
@@ -1556,6 +1557,7 @@ internal UndoState RedoBegin( DrawOperation op ) {
15561557
[NotNull]
15571558
internal UndoState UndoBegin( DrawOperation op ) {
15581559
LastDrawOp = op;
1560+
AnnouncedLastDrawOpFinished = false;
15591561
UndoState newState = new UndoState( op );
15601562
redoStack.AddLast( newState );
15611563
return newState;
@@ -1575,6 +1577,7 @@ public UndoState UndoPop() {
15751577

15761578
public UndoState DrawBegin( DrawOperation op ) {
15771579
LastDrawOp = op;
1580+
AnnouncedLastDrawOpFinished = false;
15781581
UndoState newState = new UndoState( op );
15791582
undoStack.AddLast( newState );
15801583
if( undoStack.Count > ConfigKey.MaxUndoStates.GetInt() ) {
@@ -1655,6 +1658,8 @@ public string BrushDescription {
16551658
/// <summary> Last DrawOperation executed by this player this session. May be null (if nothing has been executed yet). </summary>
16561659
[CanBeNull]
16571660
public DrawOperation LastDrawOp { get; set; }
1661+
1662+
internal bool AnnouncedLastDrawOpFinished;
16581663

16591664
/// <summary> Whether clicks should be registered towards selection marks. </summary>
16601665
public bool DisableClickToMark { get; set; }

fCraft/System/Server.cs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -755,27 +755,12 @@ public static TimeSpan CheckIdlesInterval {
755755

756756

757757
private static void CheckIdles(SchedulerTask task) {
758-
759758
Player[] tempPlayerList = Players;
760759
for (int i = 0; i < tempPlayerList.Length; i++) {
761760
Player player = tempPlayerList[i];
762761

763762
if (player.Supports(CpeExt.MessageType)) {
764-
//double speed = (Math.Sqrt(player.Position.DistanceSquaredTo(player.lastSolidPos)) / 32);
765-
//player.Send(Packet.Message((byte)MessageType.Announcement, string.Format("&eSpeed: &f{0:N2} &eBlocks/s", speed), player.UseFallbackColors));
766-
string bottomRight2 = player.Position.ToBlockCoordsRaw() + "&S[" + compassString(player.Position.R) + "&S]";
767-
if (bottomRight2 != player.lastBottomRight2) {
768-
player.lastBottomRight2 = bottomRight2;
769-
player.Send(Packet.Message((byte)MessageType.BottomRight2, bottomRight2, player));
770-
}
771-
772-
if (player.LastDrawOp != null && !player.IsPlayingCTF)
773-
if (player.LastDrawOp.PercentDone < 100) {
774-
player.Send(Packet.Message((byte)MessageType.Status3, player.LastDrawOp.Description +
775-
" percent done: &f" + player.LastDrawOp.PercentDone + "&S%", player));
776-
} else if (player.LastDrawOp.PercentDone == 100 || player.LastDrawOp.IsDone) {
777-
player.Send(Packet.Message((byte)MessageType.Status3, "", player));
778-
}
763+
UpdateStatusMessages(player);
779764
}
780765
CTF.PrintCtfState(player);
781766
player.lastSolidPos = player.Position;
@@ -809,6 +794,28 @@ private static void CheckIdles(SchedulerTask task) {
809794
UpdateTabList(false);
810795
}
811796

797+
static void UpdateStatusMessages(Player player) {
798+
//double speed = (Math.Sqrt(player.Position.DistanceSquaredTo(player.lastSolidPos)) / 32);
799+
//player.Send(Packet.Message((byte)MessageType.Announcement, string.Format("&eSpeed: &f{0:N2} &eBlocks/s", speed), player.UseFallbackColors));
800+
string bottomRight2 = player.Position.ToBlockCoordsRaw() + "&S[" + compassString(player.Position.R) + "&S]";
801+
if (bottomRight2 != player.lastBottomRight2) {
802+
player.lastBottomRight2 = bottomRight2;
803+
player.Send(Packet.Message((byte)MessageType.BottomRight2, bottomRight2, player));
804+
}
805+
806+
if (player.LastDrawOp != null && !player.IsPlayingCTF) {
807+
if (player.LastDrawOp.PercentDone < 100) {
808+
player.Send(Packet.Message((byte)MessageType.Status3, player.LastDrawOp.Description +
809+
" percent done: &f" + player.LastDrawOp.PercentDone + "&S%", player));
810+
} else if (player.LastDrawOp.PercentDone == 100 || player.LastDrawOp.IsDone) {
811+
if (!player.AnnouncedLastDrawOpFinished) {
812+
player.Send(Packet.Message((byte)MessageType.Status3, "", player));
813+
player.AnnouncedLastDrawOpFinished = true;
814+
}
815+
}
816+
}
817+
}
818+
812819
public static string compassString(int rot) {
813820
if (rot > 240 || rot < 15) {
814821
return "&1S";

0 commit comments

Comments
 (0)