MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / formatStringFromMasterServer

Function formatStringFromMasterServer

source/utils/MasterServer.cpp:147–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145 }
146
147 std::string formatStringFromMasterServer(const std::string& str)
148 {
149 // We replace special meaning chars
150 std::string formatted;
151 for(auto it = str.begin(); it != str.end(); ++it)
152 {
153 char c = *it;
154 if(c != replacementChar)
155 {
156 formatted += c;
157 continue;
158 }
159
160 // If we have a replacementChar, we expect a char telling us
161 // what the original char is
162 ++it;
163 if(it == str.end())
164 {
165 // It is not normal to end a string with replacementChar!
166 OD_LOG_ERR("Error while processing str=" + str + std::string(", c=") + c);
167 break;
168 }
169 c = *it;
170 bool isSpecialChar = false;
171 for(const std::pair<char,char>& specialChar : specialChars)
172 {
173 if(c == specialChar.second)
174 {
175 formatted += specialChar.first;
176 isSpecialChar = true;
177 break;
178 }
179 }
180 if(!isSpecialChar)
181 {
182 OD_LOG_ERR("Unexpected special char found c=" + c + std::string(" in str=") + str);
183 break;
184 }
185 }
186 return formatted;
187 }
188}

Callers 1

fillMasterServerGamesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected