TITANIC: Implement TTquotes read

This commit is contained in:
Paul Gilbert 2016-06-04 08:36:51 -04:00
parent b3bcf1cc4e
commit e9c239797d
2 changed files with 44 additions and 2 deletions

View File

@ -100,12 +100,46 @@ int TTquotes::read(const char *startP, const char *endP) {
return 0;
uint index = MIN((uint)(*startP - 'a'), (uint)25);
TTquotesLetter &letter = _alphabet[index];
const TTquotesLetter &letter = _alphabet[index];
if (letter._entries.empty())
// No entries for the letter, so exit immediately
return 0;
// TODO
int maxSize = size + 4;
bool letterFlag = index != 25;
for (uint idx = 0; idx < letter._entries.size(); ++idx) {
const TTquotesEntry &entry = letter._entries[idx];
if (entry._val2 > maxSize)
continue;
const char *srcP = startP;
const char *destP = entry._strP;
int srcIndex = 0, destIndex = 0;
if (*destP) {
do {
if (!srcP[srcIndex]) {
break;
} else if (srcP[srcIndex] == '*') {
++srcIndex;
} else if (destP[destIndex] == '-') {
++destIndex;
if (srcP[srcIndex] == ' ')
++srcIndex;
} else if (srcP[srcIndex] != destP[destIndex]) {
break;
} else {
++destIndex;
++srcIndex;
}
} while (destP[destIndex]);
if (!destP[destIndex] && (srcP[srcIndex] <= '*' ||
(srcP[srcIndex] == 's' && srcP[srcIndex + 1] <= '*')))
return entry._val1;
}
}
return 0;
}

View File

@ -49,6 +49,10 @@ private:
size_t _dataSize;
int _field544;
private:
/**
* Test whether a substring contains one of the quotes,
* and if so, returns the Id associated with it
*/
int read(const char *startP, const char *endP);
public:
TTquotes();
@ -59,6 +63,10 @@ public:
*/
void load(const CString &name);
/**
* Test whether a passed string contains one of the quotes,
* and if so, returns the Id associated with it
*/
int read(const char *str);
};