From 16c3757dcddeeff00b8d66e1d3308b59c8c62098 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 29 Jul 2016 23:17:51 +0200 Subject: DM: Refactor f426_isMessageOnTwoLines --- engines/dm/dialog.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/engines/dm/dialog.cpp b/engines/dm/dialog.cpp index 6a99ee5505..fc610c6ff7 100644 --- a/engines/dm/dialog.cpp +++ b/engines/dm/dialog.cpp @@ -145,21 +145,17 @@ void DialogMan::f425_printCenteredChoice(byte* bitmap, char* str, int16 posX, in } bool DialogMan::f426_isMessageOnTwoLines(char* str, char* part1, char* part2) { - uint16 L1305_ui_StringLength; - uint16 L1306_ui_SplitPosition; - - - L1305_ui_StringLength = strlen(str); - if (L1305_ui_StringLength <= 30) { + uint16 strLength = strlen(str); + if (strLength <= 30) return false; - } + strcpy(part1, str); - L1306_ui_SplitPosition = L1305_ui_StringLength >> 1; - while ((part1[L1306_ui_SplitPosition] != ' ') && L1306_ui_SplitPosition < L1305_ui_StringLength) { - L1306_ui_SplitPosition++; - } - part1[L1306_ui_SplitPosition] = '\0'; - strcpy(part2, &part1[L1306_ui_SplitPosition + 1]); + uint16 splitPosition = strLength >> 1; + while ((part1[splitPosition] != ' ') && (splitPosition < strLength)) + splitPosition++; + + part1[splitPosition] = '\0'; + strcpy(part2, &part1[splitPosition + 1]); return true; } } -- cgit v1.2.3