| 88 | } |
| 89 | |
| 90 | std::string_view Packet::readString() |
| 91 | { |
| 92 | if (bytesRead >= data.size()) |
| 93 | return {}; |
| 94 | |
| 95 | const char* str = reinterpret_cast<const char*>(data.data() + bytesRead); |
| 96 | |
| 97 | size_t stringLen = 0; |
| 98 | while (bytesRead < data.size() && str[stringLen] != '\0') |
| 99 | { |
| 100 | bytesRead++; |
| 101 | stringLen++; |
| 102 | } |
| 103 | |
| 104 | if (str[stringLen] != '\0') |
| 105 | return {}; |
| 106 | |
| 107 | // Skip null terminator. |
| 108 | bytesRead++; |
| 109 | |
| 110 | return std::string_view(str, stringLen); |
| 111 | } |
| 112 | } // namespace OpenRCT2::Network |
| 113 | |
| 114 | #endif |
no test coverage detected