summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-09-18 06:00:05 -0400
committerMichael Sevakis <jethead71@rockbox.org>2017-11-21 05:01:14 -0500
commitaced667f48c29a160aa4e5c0a8df037092b28189 (patch)
tree66e48e4a27daaf36f01d7ff1ed6876a7de38b0c0 /apps/plugins
parent5c9688961ef9166cec5225db50d5f73691d8292d (diff)
downloadrockbox-aced667f48c29a160aa4e5c0a8df037092b28189.tar.gz
rockbox-aced667f48c29a160aa4e5c0a8df037092b28189.zip
Undo hacks to meant to get around string formatting limitations
The new vuprintf makes unnecessary workarounds due to formatting limitations. I checked grep output for whatever appeared to fit but it's possible I missed some instances because they weren't so obvious. Also, this means sound settings can dynamically work with any number of decimals rather than the current assumption of one or two. Add an ipow() function to help and take advantage of dynamic field width and precision. Consolidate string formatting of sound settings. Change-Id: I46caf534859dfd1916cd440cd25e5206b192fcd8
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/doom/hu_stuff.c8
-rw-r--r--apps/plugins/doom/wi_stuff.c9
-rw-r--r--apps/plugins/otp.c22
3 files changed, 17 insertions, 22 deletions
diff --git a/apps/plugins/doom/hu_stuff.c b/apps/plugins/doom/hu_stuff.c
index 639c963f72..6a1b07b238 100644
--- a/apps/plugins/doom/hu_stuff.c
+++ b/apps/plugins/doom/hu_stuff.c
@@ -311,14 +311,14 @@ void HU_Init(void)
311 { 311 {
312 snprintf(buffer, sizeof(buffer), "DIG%d",j-48); 312 snprintf(buffer, sizeof(buffer), "DIG%d",j-48);
313 R_SetPatchNum(hu_font2 +i, buffer); 313 R_SetPatchNum(hu_font2 +i, buffer);
314 snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d" 314 snprintf(buffer, sizeof(buffer), "STCFN%.3d", j);
315 R_SetPatchNum(&hu_font[i], buffer); 315 R_SetPatchNum(&hu_font[i], buffer);
316 } 316 }
317 else if ('A'<=j && j<='Z') 317 else if ('A'<=j && j<='Z')
318 { 318 {
319 snprintf(buffer, sizeof(buffer), "DIG%c",j); 319 snprintf(buffer, sizeof(buffer), "DIG%c",j);
320 R_SetPatchNum(hu_font2 +i, buffer); 320 R_SetPatchNum(hu_font2 +i, buffer);
321 snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d" 321 snprintf(buffer, sizeof(buffer), "STCFN%.3d", j);
322 R_SetPatchNum(&hu_font[i], buffer); 322 R_SetPatchNum(&hu_font[i], buffer);
323 } 323 }
324 else if (j=='-') 324 else if (j=='-')
@@ -348,14 +348,14 @@ void HU_Init(void)
348 } 348 }
349 else if (j<97) 349 else if (j<97)
350 { 350 {
351 snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d" 351 snprintf(buffer, sizeof(buffer), "STCFN%.3d", j);
352 R_SetPatchNum(hu_font2 +i, buffer); 352 R_SetPatchNum(hu_font2 +i, buffer);
353 R_SetPatchNum(&hu_font[i], buffer); 353 R_SetPatchNum(&hu_font[i], buffer);
354 //jff 2/23/98 make all font chars defined, useful or not 354 //jff 2/23/98 make all font chars defined, useful or not
355 } 355 }
356 else if (j>122) 356 else if (j>122)
357 { 357 {
358 snprintf(buffer, sizeof(buffer), "STBR%d", j); //NOTE: "STBR%.3d" 358 snprintf(buffer, sizeof(buffer), "STBR%.3d", j);
359 R_SetPatchNum(hu_font2 +i, buffer); 359 R_SetPatchNum(hu_font2 +i, buffer);
360 R_SetPatchNum(&hu_font[i], buffer); 360 R_SetPatchNum(&hu_font[i], buffer);
361 } 361 }
diff --git a/apps/plugins/doom/wi_stuff.c b/apps/plugins/doom/wi_stuff.c
index 7c7831d084..b73839f55b 100644
--- a/apps/plugins/doom/wi_stuff.c
+++ b/apps/plugins/doom/wi_stuff.c
@@ -397,8 +397,7 @@ void WI_unloadData(void);
397void WI_levelNameLump(int epis, int map, char* buf, int bsize) 397void WI_levelNameLump(int epis, int map, char* buf, int bsize)
398{ 398{
399 if (gamemode == commercial) { 399 if (gamemode == commercial) {
400 snprintf(buf, bsize,"CWILV%s%d",(map/10>0?"":"0"), map); //ANOTHER ROCKHACK "CWILV%2.2d" 400 snprintf(buf,bsize, "CWILV%2.2d", map);
401 //snprintf(buf,bsize, "CWILV%2.2d", map);
402 } else { 401 } else {
403 snprintf(buf,bsize, "WILV%d%d", epis, map); 402 snprintf(buf,bsize, "WILV%d%d", epis, map);
404 } 403 }
@@ -1829,8 +1828,7 @@ void WI_loadData(void)
1829 if (wbs->epsd != 1 || j != 8) 1828 if (wbs->epsd != 1 || j != 8)
1830 { 1829 {
1831 // animations 1830 // animations
1832 snprintf(name, sizeof(name),"WIA%d%s%d%s%d", wbs->epsd, (j/10>0?"":"0"), j,(i/10>0?"":"0"), i); //ANOTHER ROCKHACK 1831 snprintf(name, sizeof(name),"WIA%d%.2d%.2d", wbs->epsd, j, i);
1833 //snprintf(name, sizeof(name),"WIA%d%.2d%.2d", wbs->epsd, j, i);
1834 a->p[i] = W_CacheLumpName(name); 1832 a->p[i] = W_CacheLumpName(name);
1835 } 1833 }
1836 else 1834 else
@@ -1872,8 +1870,7 @@ void WI_unloadData(void)
1872 // MONDO HACK! 1870 // MONDO HACK!
1873 if (wbs->epsd != 1 || j != 8) { 1871 if (wbs->epsd != 1 || j != 8) {
1874 // animations 1872 // animations
1875 snprintf(name, sizeof(name),"WIA%d%s%d%s%d", wbs->epsd, (j/10>0?"":"0"), j,(i/10>0?"":"0"), i); //ANOTHER ROCKHACK 1873 snprintf(name,sizeof(name), "WIA%d%.2d%.2d", wbs->epsd, j, i);
1876 //snprintf(name,sizeof(name), "WIA%d%.2d%.2d", wbs->epsd, j, i);
1877 W_UnlockLumpName(name); 1874 W_UnlockLumpName(name);
1878 } 1875 }
1879 } 1876 }
diff --git a/apps/plugins/otp.c b/apps/plugins/otp.c
index 69cb8b7982..6dece4ad38 100644
--- a/apps/plugins/otp.c
+++ b/apps/plugins/otp.c
@@ -516,25 +516,23 @@ static void add_acct(void)
516 516
517static void show_code(int acct) 517static void show_code(int acct)
518{ 518{
519 /* rockbox's printf doesn't support a variable field width afaik */
520 char format_buf[64];
521 if(!accounts[acct].is_totp) 519 if(!accounts[acct].is_totp)
522 { 520 {
523 rb->snprintf(format_buf, sizeof(format_buf), "%%0%dd", accounts[acct].digits); 521 rb->splashf(0, "%0*d", accounts[acct].digits,
524 rb->splashf(0, format_buf, HOTP(accounts[acct].secret, 522 HOTP(accounts[acct].secret,
525 accounts[acct].sec_len, 523 accounts[acct].sec_len,
526 accounts[acct].hotp_counter, 524 accounts[acct].hotp_counter,
527 accounts[acct].digits)); 525 accounts[acct].digits));
528 ++accounts[acct].hotp_counter; 526 ++accounts[acct].hotp_counter;
529 } 527 }
530#if CONFIG_RTC 528#if CONFIG_RTC
531 else 529 else
532 { 530 {
533 rb->snprintf(format_buf, sizeof(format_buf), "%%0%dd (%%ld second(s) left)", accounts[acct].digits); 531 rb->splashf(0, "%0*d (%ld seconds(s) left)", accounts[acct].digits,
534 rb->splashf(0, format_buf, TOTP(accounts[acct].secret, 532 TOTP(accounts[acct].secret,
535 accounts[acct].sec_len, 533 accounts[acct].sec_len,
536 accounts[acct].totp_period, 534 accounts[acct].totp_period,
537 accounts[acct].digits), 535 accounts[acct].digits),
538 accounts[acct].totp_period - get_utc() % accounts[acct].totp_period); 536 accounts[acct].totp_period - get_utc() % accounts[acct].totp_period);
539 } 537 }
540#else 538#else