diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-11-04 11:52:44 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-11-04 11:52:44 +0000 |
commit | 1923c5ae18c713fed8c37b84e4164ade6cf61a69 (patch) | |
tree | 5e96392047b5336fea18ce80efd96904e82bfebf /src/resources/dye.cpp | |
parent | 6942c7b9d3479e09697f074c1a6e848dec8af44e (diff) | |
download | mana-1923c5ae18c713fed8c37b84e4164ade6cf61a69.tar.gz mana-1923c5ae18c713fed8c37b84e4164ade6cf61a69.tar.bz2 mana-1923c5ae18c713fed8c37b84e4164ade6cf61a69.tar.xz mana-1923c5ae18c713fed8c37b84e4164ade6cf61a69.zip |
Tightened palette handling.
Diffstat (limited to 'src/resources/dye.cpp')
-rw-r--r-- | src/resources/dye.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 3c4bfecc..c27f32c1 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -179,16 +179,18 @@ void Dye::update(int color[3]) const void Dye::instantiate(std::string &target, std::string const &palettes) { - std::string::size_type last_pos = target.find('>'); - if (last_pos == std::string::npos || palettes.empty()) return; - ++last_pos; + std::string::size_type next_pos = target.find('|'); + if (next_pos == std::string::npos || palettes.empty()) return; + ++next_pos; std::ostringstream s; - std::string::size_type next_pos = 0, pal_pos = 0; + s << target.substr(0, next_pos); + std::string::size_type last_pos = target.length(), pal_pos = 0; do { std::string::size_type pos = next_pos; - next_pos = target.find_first_of(">;", pos); + next_pos = target.find(';', pos); + if (next_pos == std::string::npos) next_pos = last_pos; if (next_pos == pos + 1) { std::string::size_type pal_next_pos = palettes.find(';'); @@ -196,6 +198,7 @@ void Dye::instantiate(std::string &target, std::string const &palettes) if (pal_next_pos == std::string::npos) { s << palettes.substr(pal_pos); + s << target.substr(next_pos); break; } s << palettes.substr(pal_pos, pal_next_pos - pal_pos); @@ -213,8 +216,7 @@ void Dye::instantiate(std::string &target, std::string const &palettes) s << target[next_pos]; ++next_pos; } - while (next_pos != last_pos); + while (next_pos < last_pos); - s << target.substr(next_pos); target = s.str(); } |