Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/netserver.cc')
-rw-r--r--src/core/netserver.cc61
1 files changed, 45 insertions, 16 deletions
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 32b2d69..65388e8 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -562,10 +562,10 @@ void NetServer::send_player_disconnect_info(NetClient *client, Player *player)
void NetServer::send_info_update(NetClient *client, Info *info)
{
if (!info || !info->type())
- return;
+ return;
std::ostringstream msg;
- msg << "inf " << info->type()->label() << ' ' << info->label() << ' ';
+ msg << "inf " << info->id() << " \"" << info->type()->label() << "\" \"" << info->label() << "\" ";
info->serialize_server_update(msg);
msg << '\n';
client->send_raw(msg.str());
@@ -675,24 +675,53 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me
}
if (command == "inf") {
- std::string typelabelstr;
- std::string infolabelstr;
+ unsigned int id;
- 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;
+ if (!(msgstream >> id)) {
+ con_warn << "^B" << client->player()->name() << "^W invalid info request" << std::endl;
return;
}
- Info *info = Info::find(infotype, infolabelstr);
+ Info *info = 0;
+ if (id == 0) {
+ // the client is requesting an information record by type and label
+ std::string typelabelstr;
+ std::string infolabelstr;
+ std::string n;
+ char c;
+
+ // read type label
+ n.clear();
+ while ((msgstream.get(c)) && (c != '"'));
+ while ((msgstream.get(c)) && (c != '"'))
+ n +=c;
+ typelabelstr.assign(n);
+ if (!typelabelstr.size()) {
+ con_warn << "^B" << client->player()->name() << "^W invalid info request" << std::endl;
+ return;
+ }
+
+ InfoType *infotype = InfoType::find(typelabelstr);
+ if (!infotype)
+ return;
+
+ // read info label
+ n.clear();
+ while ((msgstream.get(c)) && (c != '"'));
+ while ((msgstream.get(c)) && (c != '"'))
+ n +=c;
+ infolabelstr.assign(n);
+ if (!infolabelstr.size()) {
+ con_warn << "^B" << client->player()->name() << "^W invalid info request" << std::endl;
+ return;
+ }
+
+ info = Info::find(infotype, infolabelstr);
+ } else {
+ // the client is requesting an information record by id
+ info = Info::find(id);
+ }
+
if (info) {
send_info_update(client, info);
client->transmit();