Skip to content

Commit

Permalink
CHEWY: Rewrite aad_get_zeilen as aadGetTxtLen
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Aug 7, 2023
1 parent e0a146f commit 9367487
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
38 changes: 14 additions & 24 deletions engines/chewy/atds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,6 @@ int16 Atdsys::start_aad(int16 diaNr, bool continueWhenSpeechEnds) {
_aadv._ptr = _atdsMem[AAD_HANDLE];
aad_search_dia(diaNr, &_aadv._ptr);

//const uint8 roomNum = _G(room)->_roomInfo->_roomNr;
//Common::StringArray s = getTextArray(roomNum, diaNr, AAD_DATA);

if (_aadv._ptr) {
_aadv._person.load(_aadv._ptr, _aadv._txtHeader->_perNr);
_aadv._ptr += _aadv._txtHeader->_perNr * sizeof(AadInfo);
Expand All @@ -518,9 +515,8 @@ int16 Atdsys::start_aad(int16 diaNr, bool continueWhenSpeechEnds) {
_aadv._strNr = 0;
_aadv._strHeader = (AadStrHeader *)_aadv._ptr;
_aadv._ptr += sizeof(AadStrHeader);
int16 txt_len;
aad_get_zeilen(_aadv._ptr, &txt_len);
_aadv._delayCount = get_delay(txt_len);
int16 txtLen = aadGetTxtLen(_aadv._ptr);
_aadv._delayCount = get_delay(txtLen);
_printDelayCount1 = _aadv._delayCount / 10;

_atdsv._diaNr = diaNr;
Expand Down Expand Up @@ -579,9 +575,8 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
_ssi[personId]._y = _aadv._person[personId]._y - scrY;
}
char *start_ptr = tmp_ptr;
int16 txt_len;
aad_get_zeilen(start_ptr, &txt_len);
str_null2leer(start_ptr, start_ptr + txt_len - 1);
int16 txtLen = aadGetTxtLen(start_ptr);
str_null2leer(start_ptr, start_ptr + txtLen - 1);
SplitStringInit tmp_ssi = _ssi[personId];
SplitStringRet splitString;
split_string(&tmp_ssi, &splitString);
Expand Down Expand Up @@ -609,7 +604,7 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
}
tmp_ptr += strlen(splitString._strPtr[i]) + 1;
}
str_null2leer(start_ptr, start_ptr + txt_len - 1);
str_null2leer(start_ptr, start_ptr + txtLen - 1);

if (g_engine->_sound->speechEnabled() &&
_aadv._strHeader->_vocNr - ATDS_VOC_OFFSET != -1) {
Expand Down Expand Up @@ -650,8 +645,8 @@ void Atdsys::print_aad(int16 scrX, int16 scrY) {
}
}
}
aad_get_zeilen(_aadv._ptr, &txt_len);
_aadv._delayCount = get_delay(txt_len);
txtLen = aadGetTxtLen(_aadv._ptr);
_aadv._delayCount = get_delay(txtLen);
_printDelayCount1 = _aadv._delayCount / 10;
_aadv._silentCount = _atdsv._silent;
}
Expand All @@ -669,17 +664,13 @@ int16 Atdsys::aadGetStatus() {
return _aadv._strNr;
}

int16 Atdsys::aad_get_zeilen(char *str, int16 *txtLen) {
*txtLen = 0;
int16 Atdsys::aadGetTxtLen(char *str) {
char *ptr = str;
int16 zeilen = 0;
while (*str != ATDS_END_TEXT) {
if (*str++ == 0)
++zeilen;
}
*txtLen = (str - ptr) - 1;
while (*str != ATDS_END_TEXT)
++str;

return zeilen;
int16 txtLen = (str - ptr) - 1;
return txtLen;
}

void Atdsys::aad_search_dia(int16 diaNr, char **ptr) {
Expand Down Expand Up @@ -905,9 +896,8 @@ int16 Atdsys::startAutoDialogCloseup(char *itemAdr) {
_aadv._strNr = 0;
_aadv._strHeader = (AadStrHeader *)_aadv._ptr;
_aadv._ptr += sizeof(AadStrHeader);
int16 txt_len;
aad_get_zeilen(_aadv._ptr, &txt_len);
_aadv._delayCount = get_delay(txt_len);
int16 txtLen = aadGetTxtLen(_aadv._ptr);
_aadv._delayCount = get_delay(txtLen);
_atdsv._diaNr = _dialogCloseup._txtHeader._diaNr + 10000;

if (_atdsv.aad_str != nullptr)
Expand Down
2 changes: 1 addition & 1 deletion engines/chewy/atds.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class Atdsys {
int16 aadGetStatus();
void set_string_end_func(void (*strFunc)(int16 diaNr, int16 strNr, int16 personNr, int16 mode));
void aad_search_dia(int16 diaNr, char **ptr);
int16 aad_get_zeilen(char *str, int16 *txtLen);
int16 aadGetTxtLen(char *str);

bool startDialogCloseup(int16 diaNr);
void stopDialogCloseup();
Expand Down

0 comments on commit 9367487

Please sign in to comment.