Skip to content

Commit bb35349

Browse files
committed
Updated sprintf function calls to use macros
1 parent afd6faa commit bb35349

File tree

3 files changed

+50
-47
lines changed

3 files changed

+50
-47
lines changed

ttyd-tools/rel/source/codes.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <ttyd/battle_ac.h>
2424

2525
#include <cstdio>
26+
#include <cinttypes>
2627

2728
namespace mod {
2829

@@ -667,7 +668,7 @@ void spawnItem()
667668

668669
char *tempDisplayBuffer = DisplayBuffer;
669670
sprintf(tempDisplayBuffer,
670-
"C_Item%d",
671+
"C_Item%" PRIu16,
671672
SpawnItem.SpawnItemCounter);
672673

673674
ttyd::itemdrv::itemEntry(tempDisplayBuffer, MenuSecondaryValue, 16,

ttyd-tools/rel/source/draw.cpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <ttyd/battle_ac.h>
2020

2121
#include <cstdio>
22+
#include <cinttypes>
2223

2324
namespace mod {
2425

@@ -630,7 +631,7 @@ void iconViewer()
630631

631632
char *tempDisplayBuffer = DisplayBuffer;
632633
sprintf(tempDisplayBuffer,
633-
"%d",
634+
"%" PRId16,
634635
tempValue);
635636

636637
drawText(tempDisplayBuffer, 0, 60, 0xFF, 0xFFFFFFFF, 0.8);
@@ -884,7 +885,7 @@ void drawMarioStats()
884885
if (i != 11) // Special moves -- drawn separately
885886
{
886887
sprintf(tempDisplayBuffer,
887-
"%ld",
888+
"%" PRId32,
888889
MarioStatsArray[Counter]);
889890

890891
drawText(tempDisplayBuffer, ValuesPosX, PosY, Alpha, Color, TextScale);
@@ -1015,7 +1016,7 @@ void drawPartnerStats()
10151016
for (uint32_t i = 0; i < (tempStatsPartnerOptionsLinesSize - 1); i++)
10161017
{
10171018
sprintf(tempDisplayBuffer,
1018-
"%d",
1019+
"%" PRId16,
10191020
PartnerStats[i]);
10201021

10211022
drawText(tempDisplayBuffer, PosX, PosY, Alpha, Color, Scale);
@@ -1093,7 +1094,7 @@ void drawBattlesActorStats()
10931094
for (uint32_t i = 0; i < (tempBattlesCurrentActorStatsSize); i++)
10941095
{
10951096
sprintf(tempDisplayBuffer,
1096-
"%d",
1097+
"%" PRId16,
10971098
ActorStats[i]);
10981099

10991100
drawText(tempDisplayBuffer, PosX, PosY, Alpha, Color, Scale);
@@ -1378,7 +1379,7 @@ void drawMemoryModifyList()
13781379
// Draw the X and Y positions
13791380
char *tempDisplayBuffer = DisplayBuffer;
13801381
sprintf(tempDisplayBuffer,
1381-
"%ld, %ld",
1382+
"%" PRId32 ", %" PRId32,
13821383
MemoryWatch[tempMenuSelectedOption].PosX,
13831384
MemoryWatch[tempMenuSelectedOption].PosY);
13841385

@@ -1570,7 +1571,7 @@ void drawMemoryChangeAddressList()
15701571

15711572
// Draw the text for the current level
15721573
sprintf(tempDisplayBuffer,
1573-
"Level %ld",
1574+
"Level %" PRIu32,
15741575
i);
15751576
drawText(tempDisplayBuffer, PosX, PosY, Alpha, Color, Scale);
15761577

@@ -1586,13 +1587,13 @@ void drawMemoryChangeAddressList()
15861587
tempOffset = -tempOffset;
15871588

15881589
sprintf(tempDisplayBuffer,
1589-
"-0x%lX",
1590+
"-0x%" PRIX32,
15901591
tempOffset);
15911592
}
15921593
else
15931594
{
15941595
sprintf(tempDisplayBuffer,
1595-
"0x%lX",
1596+
"0x%" PRIX32,
15961597
tempOffset);
15971598
}
15981599

@@ -1792,7 +1793,7 @@ void drawBattlesStatusesList()
17921793

17931794
// Draw the text of the value
17941795
sprintf(tempDisplayBuffer,
1795-
"%d",
1796+
"%" PRId8,
17961797
CurrentValue);
17971798

17981799
Color = 0xFFFFFFFF;
@@ -2019,7 +2020,7 @@ void drawSingleLineFromStringAndValue(int32_t posX, int32_t posY,
20192020
{
20202021
char *tempDisplayBuffer = DisplayBuffer;
20212022
sprintf(tempDisplayBuffer,
2022-
"%s%ld",
2023+
"%s%" PRId32,
20232024
line,
20242025
value);
20252026

@@ -2205,7 +2206,7 @@ void drawAdjustableValue(bool changingItem, uint32_t currentMenu)
22052206

22062207
char *tempDisplayBuffer = DisplayBuffer;
22072208
sprintf(tempDisplayBuffer,
2208-
"%d",
2209+
"%" PRIu8,
22092210
AdjustableValue[i]);
22102211

22112212
drawText(tempDisplayBuffer, x, y, alpha, color, scale);
@@ -2347,7 +2348,7 @@ void drawMemoryWatchAdjustableValue(uint32_t currentMenu)
23472348

23482349
char *tempDisplayBuffer = DisplayBuffer;
23492350
sprintf(tempDisplayBuffer,
2350-
"%01X",
2351+
"%01" PRIX8,
23512352
AdjustableValue[i]);
23522353

23532354
drawText(tempDisplayBuffer, x, y, alpha, color, scale);
@@ -2499,7 +2500,7 @@ void drawPageNumber(int32_t posX, int32_t posY, uint32_t currentPage)
24992500

25002501
char *tempDisplayBuffer = DisplayBuffer;
25012502
sprintf(tempDisplayBuffer,
2502-
"Page %ld",
2503+
"Page %" PRIu32,
25032504
currentPage + 1);
25042505

25052506
drawText(tempDisplayBuffer, posX, posY, Alpha, Color, Scale);
@@ -2545,7 +2546,7 @@ void drawCheatsChangeSequence()
25452546
// Draw the text for showing what the current Sequence value is
25462547
char *tempDisplayBuffer = DisplayBuffer;
25472548
sprintf(tempDisplayBuffer,
2548-
"Current Value: %ld",
2549+
"Current Value: %" PRIu32,
25492550
SequencePosition);
25502551

25512552
drawText(tempDisplayBuffer, PosX, PosY, Alpha, Color, Scale);
@@ -2569,7 +2570,7 @@ void drawCheatsChangeSequence()
25692570
}
25702571
else
25712572
{
2572-
int StageNumber;
2573+
int32_t StageNumber;
25732574
if ((SequencePosition >= 23) && (SequencePosition <= 70))
25742575
{
25752576
StageNumber = 1;
@@ -2607,7 +2608,7 @@ void drawCheatsChangeSequence()
26072608
clearMemory(tempString, sizeof(tempString));
26082609

26092610
sprintf(tempString,
2610-
"Stage %d",
2611+
"Stage %" PRId32,
26112612
StageNumber);
26122613

26132614
StageName = tempString;
@@ -2739,7 +2740,7 @@ void drawChangeButtonCombo(uint16_t &currentButtonCombo)
27392740
char *tempDisplayBuffer = DisplayBuffer;
27402741

27412742
sprintf(tempDisplayBuffer,
2742-
"Time Left: %02ld.%02ld",
2743+
"Time Left: %02" PRIu32 ".%02" PRIu32,
27432744
second,
27442745
frame);
27452746

@@ -2928,7 +2929,7 @@ void drawSequenceInPauseMenu()
29282929
char *tempDisplayBuffer = DisplayBuffer;
29292930

29302931
sprintf(tempDisplayBuffer,
2931-
"Seq: %lu",
2932+
"Seq: %" PRIu32,
29322933
SequencePosition);
29332934

29342935
drawText(tempDisplayBuffer, PosX, PosY, Alpha, Color, Scale);
@@ -2948,7 +2949,7 @@ void drawOnScreenTimer()
29482949

29492950
char *tempDisplayBuffer = DisplayBuffer;
29502951
sprintf(tempDisplayBuffer,
2951-
"%02ld:%02ld:%02ld.%02ld",
2952+
"%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%02" PRIu32,
29522953
hour,
29532954
minute,
29542955
second,
@@ -3023,7 +3024,7 @@ void drawJumpStorageDetails()
30233024
char *tempDisplayBuffer = DisplayBuffer;
30243025

30253026
sprintf(tempDisplayBuffer,
3026-
"JS: %ld\nSpdY: %.2f",
3027+
"JS: %" PRIu32 "\nSpdY: %.2f",
30273028
(player->flags3 & (1 << 16)) >> 16, // Get only the 16 bit
30283029
player->wJumpVelocityY);
30293030

@@ -3147,7 +3148,7 @@ void drawYoshiSkipDetails()
31473148
// Draw the text
31483149
char *tempDisplayBuffer = DisplayBuffer;
31493150
sprintf(tempDisplayBuffer,
3150-
"YST: %lu\nStickAngle: %.2f",
3151+
"YST: %" PRIu32 "\nStickAngle: %.2f",
31513152
YoshiSkip.MainTimer,
31523153
getStickAngle());
31533154

@@ -3291,7 +3292,7 @@ void drawPalaceSkipDetails()
32913292
// Draw the text
32923293
char *tempDisplayBuffer = DisplayBuffer;
32933294
sprintf(tempDisplayBuffer,
3294-
"PST: %lu\nItemTimer: %ld\nPhaEmY: %.2f\nParY: %.2f",
3295+
"PST: %" PRIu32 "\nItemTimer: %" PRId32 "\nPhaEmY: %.2f\nParY: %.2f",
32953296
PalaceSkip.MainTimer,
32963297
ItemTimer,
32973298
PhantomEmberPosY,
@@ -3388,7 +3389,7 @@ void drawActionCommandsTiming()
33883389
}
33893390

33903391
sprintf(tempDisplayBuffer,
3391-
"Pressed %c on frame %ld of %ld",
3392+
"Pressed %c on frame %" PRIu32 " of %" PRIu32,
33923393
Button,
33933394
FramePressed,
33943395
CurrentDifficultyFrames);
@@ -3431,7 +3432,7 @@ void drawActionCommandsTiming()
34313432
}
34323433

34333434
sprintf(tempDisplayBuffer,
3434-
"Pressed %c %ld frame%s early",
3435+
"Pressed %c %" PRIu32 " frame%s early",
34353436
Button,
34363437
FramesEarly,
34373438
CheckForPlural);

0 commit comments

Comments
 (0)