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:
bors[bot] 2023-03-23 12:18:44 +00:00 committed by GitHub
commit f1149b83e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -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)

View file

@ -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)