diff options
author | uruk | 2013-08-01 12:13:44 +0200 |
---|---|---|
committer | uruk | 2013-08-01 12:13:44 +0200 |
commit | 599aa9a0637bce5e25f5f0cf178e953079c65794 (patch) | |
tree | 9f0904072d3a0a97fb0bac79e17c5bad3421f92c /engines | |
parent | d66feb32a0ee26671e2439b52e35c8c8c4d45d4c (diff) | |
download | scummvm-rg350-599aa9a0637bce5e25f5f0cf178e953079c65794.tar.gz scummvm-rg350-599aa9a0637bce5e25f5f0cf178e953079c65794.tar.bz2 scummvm-rg350-599aa9a0637bce5e25f5f0cf178e953079c65794.zip |
AVALANCHE: Move pos() from Acci to Parser, update other code accordingly.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/avalanche/acci2.cpp | 25 | ||||
-rw-r--r-- | engines/avalanche/acci2.h | 2 | ||||
-rw-r--r-- | engines/avalanche/parser.cpp | 7 | ||||
-rw-r--r-- | engines/avalanche/parser.h | 2 |
4 files changed, 18 insertions, 18 deletions
diff --git a/engines/avalanche/acci2.cpp b/engines/avalanche/acci2.cpp index 02fda21d66..d1eeb71297 100644 --- a/engines/avalanche/acci2.cpp +++ b/engines/avalanche/acci2.cpp @@ -244,7 +244,7 @@ byte Acci::wordnum(Common::String x) { } void Acci::replace(Common::String old1, byte new1) { - int16 q = pos(old1, thats); + int16 q = _vm->_parser->pos(old1, thats); while (q != -1) { if (new1 == 0) thats.deleteChar(q); @@ -253,7 +253,7 @@ void Acci::replace(Common::String old1, byte new1) { thats.deleteChar(q); thats.insertChar(new1, q); } - q = pos(old1, thats); + q = _vm->_parser->pos(old1, thats); } } @@ -324,7 +324,7 @@ void Acci::punctustrip(Common::String &x) { /* Strips punctuation from x. for (byte fv = 0; fv < 32; fv++) do { - int16 p = pos(Common::String(punct[fv]), x); + int16 p = _vm->_parser->pos(Common::String(punct[fv]), x); if (p == -1) break; x.deleteChar(p); @@ -409,13 +409,6 @@ void Acci::clearuint16s() { warning("STUB: Acci::clearuint16s()"); } -int16 Acci::pos(const Common::String &crit, const Common::String &src) { - if (src.contains(crit)) - return strstr(src.c_str(),crit.c_str()) - src.c_str(); - else - return -1; -} - void Acci::parse() { byte n, fv, ff; Common::String c, cc, thisword; @@ -462,7 +455,7 @@ void Acci::parse() { break; // Get the following word of the strings. - byte size = pos(Common::String(' '), c) + 1; + byte size = _vm->_parser->pos(Common::String(' '), c) + 1; char *subStr = new char[size]; Common::strlcpy(subStr, c.c_str(), size); thisword = subStr; @@ -477,7 +470,7 @@ void Acci::parse() { // Check also[] first, which conatins words about the actual room. if (!thisword.empty()) { for (ff = 0; ff < 31; ff++) { - if ((_vm->_gyro->also[ff][0] != 0) && (pos(',' + thisword, *_vm->_gyro->also[ff][0]) > -1)) { + if ((_vm->_gyro->also[ff][0] != 0) && (_vm->_parser->pos(',' + thisword, *_vm->_gyro->also[ff][0]) > -1)) { thats = thats + Common::String(99 + ff); notfound = false; } @@ -496,18 +489,18 @@ void Acci::parse() { } // Delete words we already processed. - int16 spacePos = pos(Common::String(' '), c); + int16 spacePos = _vm->_parser->pos(Common::String(' '), c); if (spacePos > -1) for (byte i = 0; i <= spacePos; i++) c.deleteChar(0); - spacePos = pos(Common::String(' '), cc); + spacePos = _vm->_parser->pos(Common::String(' '), cc); if (spacePos > -1) for (byte i = 0; i <= spacePos; i++) cc.deleteChar(0); } - if (pos(Common::String(254), thats) > -1) - unknown = realwords[pos(Common::String(254), thats)]; + if (_vm->_parser->pos(Common::String(254), thats) > -1) + unknown = realwords[_vm->_parser->pos(Common::String(254), thats)]; else if (!unknown.empty()) unknown.clear(); diff --git a/engines/avalanche/acci2.h b/engines/avalanche/acci2.h index 0660f497b3..2a97b98529 100644 --- a/engines/avalanche/acci2.h +++ b/engines/avalanche/acci2.h @@ -210,8 +210,6 @@ private: void heythanks(); - int16 pos(const Common::String &crit, const Common::String &src); // Returns the index of the first appearance of crit in src. - }; } // End of namespace Avalanche. diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp index 5fbc31e594..86f46c1f08 100644 --- a/engines/avalanche/parser.cpp +++ b/engines/avalanche/parser.cpp @@ -126,6 +126,13 @@ void Parser::tryDropdown() { warning("STUB: Parser::tryDropdown()"); // TODO: Implement at the same time with Dropdown. } +int16 Parser::pos(const Common::String &crit, const Common::String &src) { + if (src.contains(crit)) + return strstr(src.c_str(),crit.c_str()) - src.c_str(); + else + return -1; +} + void Parser::drawCursor() { // Draw the '_' character. Similar to plotText(). char cursor = '_'; diff --git a/engines/avalanche/parser.h b/engines/avalanche/parser.h index 2a34839920..6b9240011c 100644 --- a/engines/avalanche/parser.h +++ b/engines/avalanche/parser.h @@ -60,6 +60,8 @@ public: void tryDropdown(); // This asks the parsekey proc in Dropdown if it knows it. + int16 pos(const Common::String &crit, const Common::String &src); // Returns the index of the first appearance of crit in src. + private: AvalancheEngine *_vm; |