MCPcopy Create free account
hub / github.com/assaultcube/AC / showhudtimer

Function showhudtimer

source/src/clientgame.cpp:584–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582
583
584bool showhudtimer(int maxsecs, int startmillis, const char *msg, bool flash)
585{
586 static string str = "";
587 static int tickstart = 0, curticks = -1, maxticks = -1;
588 int nextticks = (lastmillis - startmillis) / 200;
589 if(tickstart!=startmillis || maxticks != 5*maxsecs)
590 {
591 tickstart = startmillis;
592 maxticks = 5*maxsecs;
593 curticks = -1;
594 copystring(str, "\f3");
595 }
596 if(curticks >= maxticks) return false;
597 nextticks = min(nextticks, maxticks);
598 while(curticks < nextticks)
599 {
600 if(++curticks%5) concatstring(str, ".");
601 else
602 {
603 defformatstring(sec)("%d", maxsecs - (curticks/5));
604 concatstring(str, sec);
605 }
606 }
607 if(nextticks < maxticks) hudeditf(HUDMSG_TIMER|HUDMSG_OVERWRITE, "%s", flash ? str : str+2);
608 else hudeditf(HUDMSG_TIMER, "%s", msg);
609 return true;
610}
611
612int lastspawnattempt = 0;
613

Callers 1

showrespawntimerFunction · 0.85

Calls 4

copystringFunction · 0.85
minFunction · 0.85
concatstringFunction · 0.85
hudeditfFunction · 0.85

Tested by

no test coverage detected