Skip to content

Commit

Permalink
MORTEVIELLE: Little refactoring of decryptNextChar()
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Jul 20, 2013
1 parent b831332 commit 34e556e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion engines/mortevielle/mortevielle.h
Expand Up @@ -432,7 +432,7 @@ class MortevielleEngine : public Engine {
void putInHand(int &objId);
void prepareDisplayText();

void cinq_huit(char &c, int &idx, byte &pt, bool &the_end);
bool decryptNextChar(char &c, int &idx, byte &pt);
void copcha();
void adzon();
void phaz(int &rand, int &p, int cf);
Expand Down
17 changes: 13 additions & 4 deletions engines/mortevielle/utils.cpp
Expand Up @@ -1846,7 +1846,15 @@ const byte cryptoArr31De[32]= {
const byte *cryptoArrDefault, *cryptoArr30, *cryptoArr31;
uint16 ctrlChar;

void MortevielleEngine::cinq_huit(char &c, int &idx, byte &pt, bool &the_end) {
/**
* Decrypt the next character
* @param c OUT, next decrypted char
* @param idx IN/OUT, current buffer index
* @param pt IN/OUT, current encryption point
* @return a boolean specifying if a stop character has been encountered
* @remarks Originally called 'cinq_huit'
*/
bool MortevielleEngine::decryptNextChar(char &c, int &idx, byte &pt) {
uint16 oct, ocd;

/* 5-8 */
Expand All @@ -1864,7 +1872,7 @@ void MortevielleEngine::cinq_huit(char &c, int &idx, byte &pt, bool &the_end) {

if (oct == ctrlChar) {
c = '$';
the_end = true;
return true;
} else if (oct == 30 || oct == 31) {
ocd = _dialogIndexArray[idx];
ocd = (uint16)(ocd << (16 - pt)) >> (16 - pt);
Expand All @@ -1884,12 +1892,13 @@ void MortevielleEngine::cinq_huit(char &c, int &idx, byte &pt, bool &the_end) {
c = chr(cryptoArr31[ocd]);

if (c == '\0') {
the_end = true;
c = '#';
return true;
}
} else {
c = chr(cryptoArrDefault[oct]);
}
return false;
}

/**
Expand All @@ -1910,7 +1919,7 @@ Common::String MortevielleEngine::getString(int num) {
bool endFl = false;
char let;
do {
cinq_huit(let, hint, point, endFl);
endFl = decryptNextChar(let, hint, point);
wrkStr += let;
++length;
} while (!endFl);
Expand Down

0 comments on commit 34e556e

Please sign in to comment.