/// store the directory void PlaceDirectory::Save( CUtlBuffer &fileBuffer ) { // store number of entries in directory IndexType count = (IndexType)m_directory.Count(); fileBuffer.PutUnsignedShort( count ); // store entries for( int i=0; i<m_directory.Count(); ++i ) { const char *placeName = TheNavMesh->PlaceToName( m_directory[i] ); // store string length followed by string itself unsigned short len = (unsigned short)(strlen( placeName ) + 1); fileBuffer.PutUnsignedShort( len ); fileBuffer.Put( placeName, len ); } fileBuffer.PutUnsignedChar( m_hasUnnamedAreas ); }
//----------------------------------------------------------------------------- // Purpose: file writing //----------------------------------------------------------------------------- void WriteAsciiStringAsUnicode(CUtlBuffer &buf, const char *string, bool addQuotes) { if (addQuotes) { buf.PutUnsignedShort('\"'); } for (const char *sz = string; *sz != 0; sz++) { // handle special characters if (addQuotes && *sz == '\"') { buf.PutUnsignedShort('\\'); } buf.PutUnsignedShort(*sz); } if (addQuotes) { buf.PutUnsignedShort('\"'); } }
//----------------------------------------------------------------------------- // Purpose: file writing //----------------------------------------------------------------------------- void WriteUnicodeString(CUtlBuffer &buf, const wchar_t *string, bool addQuotes) { if (addQuotes) { buf.PutUnsignedShort('\"'); } for (const wchar_t *ws = string; *ws != 0; ws++) { // handle special characters if (addQuotes && *ws == '\"') { buf.PutUnsignedShort('\\'); } // write the character buf.PutUnsignedShort(*ws); } if (addQuotes) { buf.PutUnsignedShort('\"'); } }