Skip to content

Commit 33ce996

Browse files
committed
fix(bink): Implement subtitle time string parser for ICU code path.
1 parent b331580 commit 33ce996

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

Code/BinkMovie/subtitleparser.cpp

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -450,46 +450,15 @@ unsigned int Decode_Time_String(unichar_t* string)
450450

451451
WWASSERT(string != NULL);
452452

453-
unichar_t buffer[12];
454-
u_strncpy(buffer, string, 12);
455-
buffer[11] = 0;
456-
457-
unichar_t* ptr = &buffer[0];
458-
459-
#ifndef W3D_USING_ICU
460-
// Isolate hours part
461-
unichar_t* separator = u_strchr(ptr, U_CHAR(':'));
462-
WWASSERT(separator != NULL);
463-
*separator++ = 0;
464-
unsigned int hours = wcstoul(ptr, NULL, 10);
465-
466-
// Isolate minutes part
467-
ptr = separator;
468-
separator = u_strchr(ptr, U_CHAR(':'));
469-
WWASSERT(separator != NULL);
470-
*separator++ = 0;
471-
unsigned int minutes = wcstoul(ptr, NULL, 10);
472-
473-
// Isolate seconds part
474-
ptr = separator;
475-
separator = u_strchr(ptr, U_CHAR(':'));
476-
WWASSERT(separator != NULL);
477-
*separator++ = 0;
478-
unsigned int seconds = wcstoul(ptr, NULL, 10);
479-
480-
// Isolate hundredth part (1/100th of a second)
481-
ptr = separator;
482-
unsigned int hundredth = wcstoul(ptr, NULL, 10);
453+
unsigned hours = 0, minutes = 0, seconds = 0, hundredth = 0;
454+
u_sscanf_u(string, U_CHAR("%u:%u:%u:%u"), hours, minutes, seconds, hundredth);
483455

484456
unsigned int time = (hours * TICKS_PER_HOUR);
485457
time += (minutes * TICKS_PER_MINUTE);
486458
time += (seconds * TICKS_PER_SECOND);
487459
time += ((hundredth * TICKS_PER_SECOND) / 100);
488460

489461
return time;
490-
#else
491-
return 0; // TODO, ICU implementation
492-
#endif
493462
}
494463

495464

0 commit comments

Comments
 (0)