Removed magic numbers for card score length and intmax buffer sizes
This commit is contained in:
+11
-8
@@ -270,42 +270,45 @@ bool joker_object_score(JokerObject *joker_object, Card* scored_card, int *chips
|
||||
*money += joker_effect.money;
|
||||
// TODO: Retrigger
|
||||
|
||||
const int joker_score_display_offset_px = (MAX_CARD_SCORE_STR_LEN + 1)*TTE_CHAR_SIZE;
|
||||
// + 1 For space
|
||||
|
||||
int cursorPosX = fx2int(joker_object->sprite_object->x) + 8; // Offset of 16 pixels to center the text on the card
|
||||
if (joker_effect.chips > 0)
|
||||
{
|
||||
char score_buffer[12];
|
||||
char score_buffer[INT_MAX_DIGITS + 2]; // For '+' and null terminator
|
||||
tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y);
|
||||
tte_set_special(0xD000); // Blue
|
||||
snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.chips);
|
||||
tte_write(score_buffer);
|
||||
cursorPosX += 30;
|
||||
cursorPosX += joker_score_display_offset_px;
|
||||
}
|
||||
if (joker_effect.mult > 0)
|
||||
{
|
||||
char score_buffer[12];
|
||||
char score_buffer[INT_MAX_DIGITS + 2];
|
||||
tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y);
|
||||
tte_set_special(0xE000); // Red
|
||||
snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.mult);
|
||||
tte_write(score_buffer);
|
||||
cursorPosX += 30;
|
||||
cursorPosX += joker_score_display_offset_px;
|
||||
}
|
||||
if (joker_effect.xmult > 0)
|
||||
{
|
||||
char score_buffer[12];
|
||||
char score_buffer[INT_MAX_DIGITS + 2];
|
||||
tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y);
|
||||
tte_set_special(0xE000); // Red
|
||||
snprintf(score_buffer, sizeof(score_buffer), "X%d", joker_effect.xmult);
|
||||
tte_write(score_buffer);
|
||||
cursorPosX += 30;
|
||||
cursorPosX += joker_score_display_offset_px;
|
||||
}
|
||||
if (joker_effect.money > 0)
|
||||
{
|
||||
char score_buffer[12];
|
||||
char score_buffer[INT_MAX_DIGITS + 2];
|
||||
tte_set_pos(cursorPosX, JOKER_SCORE_TEXT_Y);
|
||||
tte_set_special(0xC000); // Yellow
|
||||
snprintf(score_buffer, sizeof(score_buffer), "+%d", joker_effect.money);
|
||||
tte_write(score_buffer);
|
||||
cursorPosX += 30;
|
||||
cursorPosX += joker_score_display_offset_px;
|
||||
}
|
||||
|
||||
joker_object->joker->processed = true; // Mark the joker as processed
|
||||
|
||||
Reference in New Issue
Block a user