Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-11-14 14:14:21 +0000
committerStijn Buys <ingar@osirion.org>2009-11-14 14:14:21 +0000
commit4293e8854a30443e4d5818fc55df404976dbfd9b (patch)
tree816665ba37acfd5a39c0544c3b2acbf04c8c5d3d /src/core/netserver.cc
parenta993d31910b63a1f897e470842934e6ffefad32c (diff)
update the info system, fixes network info exchange
Diffstat (limited to 'src/core/netserver.cc')
-rw-r--r--src/core/netserver.cc43
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;
}