diff options
author | Arnaud Boutonné | 2011-02-12 14:37:59 +0000 |
---|---|---|
committer | Arnaud Boutonné | 2011-02-12 14:37:59 +0000 |
commit | 4ad7f20b77cd7239d43f1b2c61ea424d0d826ffa (patch) | |
tree | 989ea407d1f128559ad425135347a4865c75310f /engines/hugo/schedule.cpp | |
parent | 4ec51bd84368579f53d4e290bc84868e23ae94fb (diff) | |
download | scummvm-rg350-4ad7f20b77cd7239d43f1b2c61ea424d0d826ffa.tar.gz scummvm-rg350-4ad7f20b77cd7239d43f1b2c61ea424d0d826ffa.tar.bz2 scummvm-rg350-4ad7f20b77cd7239d43f1b2c61ea424d0d826ffa.zip |
HUGO: little optimization in decodeString(), cleanup
svn-id: r55894
Diffstat (limited to 'engines/hugo/schedule.cpp')
-rw-r--r-- | engines/hugo/schedule.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp index 789bff7d34..b31cab6819 100644 --- a/engines/hugo/schedule.cpp +++ b/engines/hugo/schedule.cpp @@ -1427,10 +1427,11 @@ void Scheduler_v1d::promptAction(act *action) { void Scheduler_v1d::decodeString(char *line) { debugC(1, kDebugSchedule, "decodeString(%s)", line); - static const char *cypher = getCypher(); + static const Common::String cypher = getCypher(); - for(uint16 i = 0; i < strlen(line); i++) { - line[i] = (line[i] + cypher[i]) % '~'; + uint16 linelength = strlen(line); + for(uint16 i = 0; i < linelength; i++) { + line[i] = (line[i] + cypher.c_str()[i % cypher.size()]) % '~'; if (line[i] < ' ') line[i] += ' '; } @@ -1479,10 +1480,11 @@ void Scheduler_v2d::promptAction(act *action) { void Scheduler_v2d::decodeString(char *line) { debugC(1, kDebugSchedule, "decodeString(%s)", line); - static const char *cypher = getCypher(); + static const Common::String cypher = getCypher(); - for (uint16 i = 0; i < strlen(line); i++) - line[i] -= cypher[i % strlen(cypher)]; + int16 lineLength = strlen(line); + for (uint16 i = 0; i < lineLength; i++) + line[i] -= cypher.c_str()[i % cypher.size()]; debugC(1, kDebugSchedule, "result : %s", line); } |