diff options
Diffstat (limited to 'src/core/netserver.cc')
-rw-r--r-- | src/core/netserver.cc | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/core/netserver.cc b/src/core/netserver.cc index c4eef11..32b2d69 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -561,8 +561,11 @@ void NetServer::send_player_disconnect_info(NetClient *client, Player *player) // send a "inf" info record void NetServer::send_info_update(NetClient *client, Info *info) { + if (!info || !info->type()) + return; + std::ostringstream msg; - msg << "inf " << info->id() << ' '; + msg << "inf " << info->type()->label() << ' ' << info->label() << ' '; info->serialize_server_update(msg); msg << '\n'; client->send_raw(msg.str()); @@ -672,19 +675,27 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me } if (command == "inf") { - std::string n; - char c; - - while ((msgstream.get(c)) && (c != '"')); - while ((msgstream.get(c)) && (c != '"')) - n += c; - - if (n.size()) { - Info *info = Info::find(n); - if (info) { - send_info_update(client, info); - client->transmit(); - } + std::string typelabelstr; + std::string infolabelstr; + + if (!(msgstream >> typelabelstr)) { + con_warn << "^B" << client->player()->name() << "^W invalid info record request" << std::endl; + return; + } + + InfoType *infotype = InfoType::find(typelabelstr); + if (!infotype) + return; + + if (!(msgstream >> infolabelstr)) { + con_warn << "^B" << client->player()->name() << "^W invalid info record request" << std::endl; + return; + } + + Info *info = Info::find(infotype, infolabelstr); + if (info) { + send_info_update(client, info); + client->transmit(); } } @@ -709,7 +720,7 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me } else { send_message(client, "info", "rcon access denied"); - con_print << "^B" << client->player()->name() << "^W rcon access denied" << std::endl; + con_warn << "^B" << client->player()->name() << "^W rcon access denied" << std::endl; } } return; @@ -734,7 +745,7 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me EntityControlable *entitycontrolable = (EntityControlable *)entity; if (entitycontrolable->owner() != client->player()) { - con_warn << client->host() << ":" << client->port() << " update for not-owned entity " << id << "\n"; + con_warn << client->host() << ":" << client->port() << " update for non-owned entity " << id << "\n"; return; } |