const char *getDebugName() { static char buffer[512]; dSprintf(buffer, sizeof(buffer), "%s - \"", getClassName()); expandEscape(buffer + dStrlen(buffer), mString.getString()); dStrcat(buffer, "\""); return buffer; }
void NetStringTable::expandString(NetStringHandle &inString, char *buf, U32 bufSize, U32 argc, const char **argv) { buf[0] = StringTagPrefixByte; dSprintf(buf + 1, bufSize - 1, "%d ", inString.getIndex()); const char *string = inString.getString(); if (string != NULL) { U32 index = dStrlen(buf); while(index < bufSize) { char c = *string++; if(c == '%') { c = *string++; if(c >= '1' && c <= '9') { U32 strIndex = c - '1'; if(strIndex >= argc) continue; // start copying out of arg index const char *copy = argv[strIndex]; // skip past any tags: if(*copy == StringTagPrefixByte) { while(*copy && *copy != ' ') copy++; if(*copy) copy++; } while(*copy && index < bufSize) buf[index++] = *copy++; continue; } } buf[index++] = c; if(!c) break; } buf[bufSize - 1] = 0; } else { dStrcat(buf, "<NULL>"); } }
virtual void process(NetConnection *connection) { Con::printf("Mapping string: %s to index: %d", mString.getString(), mIndex); connection->mapString(mIndex, mString); }
virtual void write(NetConnection* /*ps*/, BitStream *bstream) { bstream->writeInt(mIndex, ConnectionStringTable::EntryBitSize); bstream->writeString(mString.getString()); }