MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / expandString

Method expandString

Engine/source/sim/netStringTable.cpp:201–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201void NetStringTable::expandString(NetStringHandle &inString, char *buf, U32 bufSize, U32 argc, const char **argv)
202{
203 buf[0] = StringTagPrefixByte;
204 dSprintf(buf + 1, bufSize - 1, "%d ", inString.getIndex());
205
206 const char *string = inString.getString();
207 if (string != NULL) {
208 U32 index = dStrlen(buf);
209 while(index < bufSize)
210 {
211 char c = *string++;
212 if(c == '%')
213 {
214 c = *string++;
215 if(c >= '1' && c <= '9')
216 {
217 U32 strIndex = c - '1';
218 if(strIndex >= argc)
219 continue;
220 // start copying out of arg index
221 const char *copy = argv[strIndex];
222 // skip past any tags:
223 if(*copy == StringTagPrefixByte)
224 {
225 while(*copy && *copy != ' ')
226 copy++;
227 if(*copy)
228 copy++;
229 }
230
231 while(*copy && index < bufSize)
232 buf[index++] = *copy++;
233 continue;
234 }
235 }
236 buf[index++] = c;
237 if(!c)
238 break;
239 }
240 buf[bufSize - 1] = 0;
241 } else {
242 dStrcat(buf, "<NULL>");
243 }
244}
245
246#ifdef TORQUE_DEBUG
247

Callers

nothing calls this directly

Calls 5

dSprintfFunction · 0.85
dStrcatFunction · 0.85
dStrlenFunction · 0.50
getIndexMethod · 0.45
getStringMethod · 0.45

Tested by

no test coverage detected