From 649fdb1c512e9608aa05c99a08b867c8758eeaf8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Jun 2013 19:25:09 +0300 Subject: Add support for monster look. --- src/utils/stringutils.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/utils/stringutils.cpp') diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index a07cd1a96..a0e31f06d 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -508,6 +508,36 @@ std::string combineDye2(std::string file, const std::string &dye) } } +std::string combineDye3(std::string file, const std::string &dye) +{ + if (dye.empty()) + return file; + + const size_t pos = file.find_last_of("|"); + if (pos != std::string::npos) + { + const std::string dye1 = file.substr(pos + 1); + std::string str; + file = file.substr(0, pos); + const std::list list1 = splitToStringList(dye1, ';'); + const std::list list2 = splitToStringList(dye, ';'); + for (std::list::const_iterator it1 = list1.begin(), + it2 = list2.begin(), it1_end = list1.end(), it2_end = list2.end(); + it1 != it1_end && it2 != it2_end; ++it1, ++it2) + { + str.append(*it1).append(":").append(*it2).append(";"); + } + return file.append("|").append(str); + } + else + { + if (dye.empty() || file.empty()) + return file; + else + return file.append("|").append(dye); + } +} + std::string packList(const std::list &list) { std::list::const_iterator i = list.begin(); -- cgit v1.2.3-60-g2f50