Fixed crash, and started to improve log output.

This commit is contained in:
hiker 2016-02-25 17:00:08 +11:00
parent 6f55877e94
commit 2357e965b4

View File

@ -93,7 +93,7 @@ BareNetworkString& BareNetworkString::encodeString(const irr::core::stringw &val
*/ */
int BareNetworkString::decodeString(int pos, std::string *out) const int BareNetworkString::decodeString(int pos, std::string *out) const
{ {
uint8_t len = get<uint8_t>(pos); uint8_t len = get<uint8_t>(m_current_offset+pos);
*out = getString(pos+1, len); *out = getString(pos+1, len);
return len+1; return len+1;
} // decodeString } // decodeString
@ -136,7 +136,11 @@ std::string BareNetworkString::getLogMessage() const
// Add ascii representation // Add ascii representation
for(unsigned int i=line; i<upper_limit; i++) for(unsigned int i=line; i<upper_limit; i++)
{ {
oss << getUInt8(i); uint8_t c = getUInt8(i);
if(isprint(c))
oss << char(getUInt8(i));
else
oss << '.';
} // for i } // for i
oss << "\n"; oss << "\n";
} // for line } // for line