MCPcopy Create free account
hub / github.com/ddnet/ddnet / TimeFromStr

Method TimeFromStr

src/game/client/race.cpp:57–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57int CRaceHelper::TimeFromStr(const char *pStr)
58{
59 static constexpr const char *MINUTES_STR = " minute(s) ";
60 static constexpr const char *SECONDS_STR = " second(s)";
61
62 const char *pSeconds = str_find(pStr, SECONDS_STR);
63 if(!pSeconds)
64 return -1;
65
66 const char *pMinutes = str_find(pStr, MINUTES_STR);
67 if(pMinutes)
68 {
69 while(*pStr == ' ') // skip leading spaces
70 pStr++;
71 int SecondsTime = TimeFromSecondsStr(pMinutes + str_length(MINUTES_STR));
72 if(SecondsTime == -1 || !isdigit(*pStr))
73 return -1;
74 return str_toint(pStr) * 60 * 1000 + SecondsTime;
75 }
76 else
77 return TimeFromSecondsStr(pStr);
78}
79
80int CRaceHelper::TimeFromFinishMessage(const char *pStr, char *pNameBuf, int NameBufSize)
81{

Callers

nothing calls this directly

Calls 3

str_findFunction · 0.85
str_lengthFunction · 0.85
str_tointFunction · 0.85

Tested by

no test coverage detected