]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_ctfws/commitdiff
Deal with very long times better
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 29 Jun 2019 15:45:20 +0000 (16:45 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 29 Jun 2019 16:07:27 +0000 (17:07 +0100)
Things will still break eventually, but surely no CtFwS game will ever
go for over 16 hours, yeah?

ctfws-lcd.lua
ctfws-lfs-strings.lua

index 06b848a8af1ba3c1f02e3796ec92595d7f8aa316..9625bb95b75fefccc479cd52bbc1992ff431d1d4 100644 (file)
@@ -21,11 +21,16 @@ local function drawDS(lcd, row, col, max, last, decisec)
   --     decisec/3600, decisec/600, (decisec/10)%60, decisec%10))
   -- else
   if drawDScond(max, last, decisec, 600) then -- minutes, seconds, and deci
-     lcd:put(lcd:locate(row,col), string.format("%02d:%02d.%d", decisec/600, (decisec/10)%60, decisec%10))
+      if decisec >= 60000 then
+       -- for incredibly long times, just space pad and hope for the best
+       lcd:put(lcd:locate(row,col), string.format("% 4d:%02d.%d", decisec/600, (decisec/10)%60, decisec%10))
+     else
+       lcd:put(lcd:locate(row,col), string.format("  %02d:%02d.%d", decisec/600, (decisec/10)%60, decisec%10))
+     end
   elseif drawDScond(max, last, decisec, 10) then -- seconds and deci
-     lcd:put(lcd:locate(row,col+3), string.format("%02d.%d", (decisec/10)%60, decisec%10))
+     lcd:put(lcd:locate(row,col+5), string.format("%02d.%d", (decisec/10)%60, decisec%10))
   else -- just deci
-     lcd:put(lcd:locate(row,col+6), string.format("%d",decisec%10))
+     lcd:put(lcd:locate(row,col+8), string.format("%d",decisec%10))
   end
 end
 
@@ -80,7 +85,7 @@ local function drawSteadyTopLine(self,rix,maxt,ela)
       else lcd:put(lcd:locate(0,0), "GAME      :")
     end
   end
-  drawDS(lcd,0,13,maxt,self.dl_elapsed,ela); self.dl_elapsed = ela
+  drawDS(lcd,0,11,maxt,self.dl_elapsed,ela); self.dl_elapsed = ela
 end
 
 local function drawSteadyBotLine(self,rix,maxt,rem)
@@ -99,7 +104,7 @@ local function drawSteadyBotLine(self,rix,maxt,rem)
       lcd:put(lcd:locate(3,0), "GAME END  :")
     end
   end
-  drawDS(lcd,3,13,maxt,self.dl_remain ,rem); self.dl_remain  = rem
+  drawDS(lcd,3,11,maxt,self.dl_remain ,rem); self.dl_remain  = rem
 end
 
 local function attention(self,long)
index de6aad2bb77161efa724657c3f538ea01b3b5170..82b965212a2b031d96e2fbc4f0119c7564717256 100644 (file)
@@ -21,7 +21,7 @@ local lcdpreload =
   "define_char",
   "lcd", "mtmr", "ftmr", "fatmr", "dl_elapsed", "dl_elapsed", "dl_remain", "dl_round",
   "attnState", "reset", "drawTimes", "drawFlags", "drawMessage", "drawFlagsMessage",
-  "%02d:%02d.%d", "%02d.%d", "%d", "%-20s",
+  "% 4d:%02d.%d", "  %02d:%02d.%d", "%02d.%d", "%d", "%-20s",
   "%d\000: %s=%s %s=%s", "%d\000: %s=%s%s",
   " CMUKGB CTFWS TIMER ", "                    ",
   "GAME      :",