]> hydra-www.ietfng.org Git - acmetensortoys-ctfws-android/commitdiff
flag counts: BigInteger
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sun, 6 Oct 2019 21:13:34 +0000 (22:13 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Tue, 8 Oct 2019 09:19:50 +0000 (10:19 +0100)
Fixes https://github.com/cmukgb/ctfws-timer-android/issues/21

lib/src/main/java/com/acmetensortoys/ctfwstimer/lib/CtFwSGameStateManager.java
mobile/src/main/java/com/acmetensortoys/ctfwstimer/service/MainServiceNotification.java

index 26967d9b0fa97221756c464bbe5acc8b562a15f3..bfa660c8e02e954dc66720c2d8aad30c9eb3fb7b 100644 (file)
@@ -1,5 +1,6 @@
 package com.acmetensortoys.ctfwstimer.lib;
 
+import java.math.BigInteger;
 import java.util.HashSet;
 import java.util.InputMismatchException;
 import java.util.Locale;
@@ -198,8 +199,8 @@ public class CtFwSGameStateManager {
     private class Flags {
         public boolean flagsVisible = false;
         public long flagsTime = 0;
-        public int  flagsRed = 0;
-        public int  flagsYel = 0;
+        public BigInteger flagsRed = BigInteger.ZERO;
+        public BigInteger flagsYel = BigInteger.ZERO;
 
         public boolean equals(Flags f) {
             return     (this.flagsVisible == f.flagsVisible)
@@ -214,10 +215,11 @@ public class CtFwSGameStateManager {
         Scanner s = new Scanner(tm);
         try {
             f.flagsTime = s.nextLong();
-            f.flagsRed = s.nextInt();
-            f.flagsYel = s.nextInt();
+            f.flagsRed = s.nextBigInteger();
+            f.flagsYel = s.nextBigInteger();
             f.flagsVisible = true;
         } catch (NumberFormatException | InputMismatchException e) {
+            // XXX This isn't quite right.
             f.flagsVisible = false;
         }
         if (!curflags.equals(f)) {
@@ -230,12 +232,14 @@ public class CtFwSGameStateManager {
             return "?";
         }
 
-        return String.format(Locale.ROOT, "%d %d", curflags.flagsRed, curflags.flagsYel);
+        return String.format(Locale.ROOT, "%d %d %d",
+                curflags.flagsTime,
+                curflags.flagsRed, curflags.flagsYel);
     }
     public boolean getFlagsVisible() { return curflags.flagsVisible; }
     // Only sensible if flags visible
-    public int getFlagsRed() { return curflags.flagsRed; }
-    public int getFlagsYel() { return curflags.flagsYel; }
+    public BigInteger getFlagsRed() { return curflags.flagsRed; }
+    public BigInteger getFlagsYel() { return curflags.flagsYel; }
 
     // Informative messages handling
     public class Msg implements Comparable<Msg> {
index 6be0b34ea42e25a1726e3f9240e08a3b4ebacd35..46d2e35430ef324ba266708bd20a8cf8da96df8c 100644 (file)
@@ -21,6 +21,7 @@ import com.acmetensortoys.ctfwstimer.activity.main.Activity;
 import com.acmetensortoys.ctfwstimer.R;
 import com.acmetensortoys.ctfwstimer.lib.CtFwSGameStateManager;
 
+import java.math.BigInteger;
 import java.text.NumberFormat;
 import java.util.SortedSet;
 
@@ -137,7 +138,8 @@ class MainServiceNotification {
                 // asserted, in which case, we allow a correction.
                 if (game.getFlagsVisible()
                         && ((lastContextTextSource == LastContentTextSource.FLAG)
-                            || (game.getFlagsRed() + game.getFlagsYel() > 0))) {
+                            || !game.getFlagsRed().equals(BigInteger.ZERO)
+                            || !game.getFlagsYel().equals(BigInteger.ZERO))) {
                     notifyUserSomehow(NotificationSource.FLAG);
                     lastContextTextSource = LastContentTextSource.FLAG;
                     NumberFormat nf = NumberFormat.getIntegerInstance();