fix udppunch whisper parsing

This commit is contained in:
Tim Felgentreff 2020-11-26 14:42:21 +01:00
parent ab4f322c2d
commit 63f6a41678

View file

@ -1443,9 +1443,9 @@ private:
if (!text.empty()) {
std::string prefix = "/udppunch ";
unsigned int a, b, c, d, ip, port;
if (text.size() > prefix.size() && text.rfind(prefix, 0)) {
int res = sscanf(text.substr(prefix.size()).c_str(), "%uhh.%uhh.%uhh.%uhh:%d", &d, &c, &b, &a, &port);
if (res == 5) {
if (text.size() > prefix.size() && text.rfind(prefix, 0) != std::string::npos) {
int res = sscanf(text.substr(prefix.size()).c_str(), "%d.%d.%d.%d:%d", &a, &b, &c, &d, &port);
if (res == 5 && a < 255 && b < 255 && c < 255 && d < 255 && port > 1024) {
ip = a | b << 8 | c << 16 | d << 24;
if (NetConnectType == 1 && !GameRunning) { // the server, waiting for clients
const CInitMessage_Header message(MessageInit_FromServer, ICMAYT);