1414 * */
1515
1616#include <stdbool.h>
17+ #include <stddef.h>
1718
1819#include "text.h"
1920#include "text_id.h"
@@ -3084,6 +3085,18 @@ char *decodeText(int textID)
30843085 p = getPassiveSkillSHelpText ();
30853086 if (textID == TEXT_NEW_PASSIVE_SKILL_UNLOCKED )
30863087 p = getNewUnlockedPassiveSkillNameTextByCurrentAIS ();
3088+
3089+ if (p == NULL )
3090+ {
3091+ p = compressedText [textID ];
3092+
3093+ if (p != lastText )
3094+ decompressText (p , decodedText );
3095+
3096+ lastText = p ;
3097+
3098+ return decodedText ;
3099+ }
30873100
30883101 if (p == lastText )
30893102 return decodedText ;
@@ -3092,47 +3105,43 @@ char *decodeText(int textID)
30923105
30933106 char * p0 = p ;
30943107 char * q = decodedText ;
3095- if (textID < sizeof (texts ) / 4 && p )
3096- {
3097- unsigned int maxLineWidth = TEXT_LINE_WIDTH_MAX ;
3098- if (textID == TEXT_SPECIAL_SKILL_HELP || textID == TEXT_ASSIST_SKILL_HELP_IN_ACTION_MENU || textID == TEXT_ASSIST_SKILL_HELP_IN_STAT_SCREEN || textID == TEXT_PASSIVE_SKILL_A_HELP || textID == TEXT_PASSIVE_SKILL_B_HELP || textID == TEXT_PASSIVE_SKILL_C_HELP || textID == TEXT_PASSIVE_SKILL_S_HELP )
3099- maxLineWidth = SKILL_HELP_WIDTH_MAX ;
3100-
3101- // copy text directly
3102- if (getStringTextWidth (p ) <= maxLineWidth )
3103- while (* p )
3108+ unsigned int maxLineWidth = TEXT_LINE_WIDTH_MAX ;
3109+ if (textID == TEXT_SPECIAL_SKILL_HELP || textID == TEXT_ASSIST_SKILL_HELP_IN_ACTION_MENU || textID == TEXT_ASSIST_SKILL_HELP_IN_STAT_SCREEN || textID == TEXT_PASSIVE_SKILL_A_HELP || textID == TEXT_PASSIVE_SKILL_B_HELP || textID == TEXT_PASSIVE_SKILL_C_HELP || textID == TEXT_PASSIVE_SKILL_S_HELP )
3110+ maxLineWidth = SKILL_HELP_WIDTH_MAX ;
3111+
3112+ // copy text directly
3113+ if (getStringTextWidth (p ) <= maxLineWidth )
3114+ while (* p )
3115+ * q ++ = * p ++ ;
3116+ else {
3117+ // add new lines automatically
3118+ unsigned int charWidth = 0 ;
3119+ unsigned int lineWidth = 0 ;
3120+
3121+ while (* p ) {
3122+ if (* p > 0 && * p < 0x20 )
31043123 * q ++ = * p ++ ;
3105- else {
3106- // add new lines automatically
3107- unsigned int charWidth = 0 ;
3108- unsigned int lineWidth = 0 ;
3109-
3110- while (* p ) {
3111- if (* p > 0 && * p < 0x20 )
3112- * q ++ = * p ++ ;
3113- else {
3114- char * p_next = getCharTextWidth (p , & charWidth );
3115- lineWidth += charWidth ;
3116- if (lineWidth > maxLineWidth ) {
3117- * q ++ = 1 ; // new line
3118- lineWidth = charWidth ;
3119- }
3120- while (* p && p < p_next )
3121- * q ++ = * p ++ ;
3124+ else {
3125+ char * p_next = getCharTextWidth (p , & charWidth );
3126+ lineWidth += charWidth ;
3127+ if (lineWidth > maxLineWidth ) {
3128+ * q ++ = 1 ; // new line
3129+ lineWidth = charWidth ;
31223130 }
3131+ while (* p && p < p_next )
3132+ * q ++ = * p ++ ;
31233133 }
31243134 }
3125-
3126- // add 0 to end string
3127- * q = 0 ;
3135+ }
3136+
3137+ // add 0 to end string
3138+ * q = 0 ;
31283139
3129- if (getStringTextWidth (p0 ) > maxLineWidth )
3130- {
3131- Debugf ("AutoNewLine for text 0x%x, width %d -> %d" , textID , getStringTextWidth (p0 ), getStringTextWidth (decodedText ));
3132- }
3140+ if (getStringTextWidth (p0 ) > maxLineWidth )
3141+ {
3142+ Debugf ("AutoNewLine for text 0x%x, width %d -> %d" , textID , getStringTextWidth (p0 ), getStringTextWidth (decodedText ));
31333143 }
3134- else
3135- decompressText (compressedText [textID ], decodedText );
3144+
31363145 return decodedText ;
31373146}
31383147
0 commit comments