mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6454
6454: Round by millisecond, not centisecond (fixes #6453) r=heinrich5991 a=def- Some servers seem to allow times with millisecond precision, official DDNet doesn't, so never noticed this issue. ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Dennis Felsing <dennis@felsin9.de>
This commit is contained in:
commit
f1149b83e5
|
@ -3428,7 +3428,7 @@ int str_time(int64_t centisecs, int format, char *buffer, int buffer_size)
|
|||
|
||||
int str_time_float(float secs, int format, char *buffer, int buffer_size)
|
||||
{
|
||||
return str_time(llroundf(secs * 100), format, buffer, buffer_size);
|
||||
return str_time(llroundf(secs * 1000) / 10, format, buffer, buffer_size);
|
||||
}
|
||||
|
||||
void str_escape(char **dst, const char *src, const char *end)
|
||||
|
|
|
@ -685,6 +685,9 @@ TEST(Str, TimeFloat)
|
|||
|
||||
EXPECT_EQ(str_time_float(12.16, TIME_HOURS_CENTISECS, aBuf, sizeof(aBuf)), 8);
|
||||
EXPECT_STREQ(aBuf, "00:12.16");
|
||||
|
||||
EXPECT_EQ(str_time_float(22.995, TIME_MINS, aBuf, sizeof(aBuf)), 5);
|
||||
EXPECT_STREQ(aBuf, "00:22");
|
||||
}
|
||||
|
||||
TEST(Str, HasCc)
|
||||
|
|
Loading…
Reference in a new issue