Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-11-12 20:53:35 +0000
committerStijn Buys <ingar@osirion.org>2009-11-12 20:53:35 +0000
commit5ddb64795cc959916eeedbec8dc3f65c06f49698 (patch)
treeee7231607b0bf49528570e5d3badcdedcb33f54e /src/core
parent3605a7bd8fffebfba38d31025b6f33cb82626a3b (diff)
initial commodities and entity inventory, bump network proto version to 18
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Makefile.am4
-rw-r--r--src/core/commandbuffer.cc8
-rw-r--r--src/core/entity.cc23
-rw-r--r--src/core/entity.h17
-rw-r--r--src/core/gameconnection.cc2
-rw-r--r--src/core/gameinterface.cc5
-rw-r--r--src/core/info.cc111
-rw-r--r--src/core/info.h98
-rw-r--r--src/core/inventory.cc69
-rw-r--r--src/core/inventory.h64
-rw-r--r--src/core/item.cc100
-rw-r--r--src/core/item.h116
-rw-r--r--src/core/net.h2
-rw-r--r--src/core/netconnection.cc22
-rw-r--r--src/core/netserver.cc2
15 files changed, 401 insertions, 242 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index c780239..fce79a6 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -3,7 +3,7 @@ INCLUDES = -I$(top_srcdir)/src
libcore_la_SOURCES = application.cc commandbuffer.cc core.cc cvar.cc \
descriptions.cc entity.cc extension.cc func.cc gameconnection.cc gameinterface.cc \
- gameserver.cc info.cc item.cc loader.cc module.cc netclient.cc netconnection.cc \
+ gameserver.cc info.cc item.cc inventory.cc loader.cc module.cc netclient.cc netconnection.cc \
netplayer.cc netserver.cc parser.cc player.cc stats.cc timer.cc zone.cc
libcore_la_LDFLAGS = -avoid-version -no-undefined
libcore_la_LIBADD = $(top_builddir)/src/model/libmodel.la \
@@ -14,4 +14,4 @@ noinst_LTLIBRARIES = libcore.la
noinst_HEADERS = application.h commandbuffer.h core.h cvar.h entity.h func.h \
gameconnection.h gameinterface.h gameserver.h message.h module.h net.h netclient.h \
netconnection.h netserver.h player.h range.h stats.h timer.h parser.h descriptions.h \
- extension.h loader.h info.h item.h
+ extension.h loader.h info.h item.h inventory.h
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index eb13382..fc98e21 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -87,11 +87,6 @@ void func_list_module(std::string const &args)
Loader::list();
}
-void func_list_item(std::string const &args)
-{
- Item::list();
-}
-
void func_set(std::string const &args)
{
std::istringstream argstream(args);
@@ -197,9 +192,6 @@ void CommandBuffer::init()
func = Func::add("list_info", (FuncPtr)func_list_info);
func->set_info("list info records");
- func = Func::add("list_item", (FuncPtr)func_list_item);
- func->set_info("list item types");
-
func = Func::add("list_var", (FuncPtr)func_list_var);
func->set_info("list variables");
diff --git a/src/core/entity.cc b/src/core/entity.cc
index ce313e6..d01d825 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -114,6 +114,9 @@ Entity::Entity(const unsigned int flags) :
entity_visible = true;
entity_serverside = false;
+
+ entity_inventory = 0;
+ entity_info = 0;
memset(entity_extension, 0, sizeof(entity_extension));
@@ -133,6 +136,9 @@ Entity::Entity(std::istream & is)
entity_created = true;
entity_destroyed = false;
+
+ entity_inventory = 0;
+ entity_info = 0;
memset(entity_extension, 0, sizeof(entity_extension));
}
@@ -151,6 +157,10 @@ Entity::~Entity()
delete(*it);
}
menus().clear();
+
+ // delete inventory
+ if (entity_inventory)
+ delete entity_inventory;
if (entity_zone)
entity_zone->remove(this);
@@ -168,6 +178,19 @@ void Entity::clear_updates()
entity_oldzone = 0;
}
+void Entity::set_info(Info *info)
+{
+ entity_info = info;
+}
+
+void Entity::set_inventory(Inventory *inventory)
+{
+ if (entity_inventory && (entity_inventory != inventory)) {
+ delete entity_inventory;
+ }
+ entity_inventory = inventory;
+}
+
void Entity::set_zone(Zone *zone)
{
if (entity_zone == zone)
diff --git a/src/core/entity.h b/src/core/entity.h
index 92cb5ab..ed0b1f8 100644
--- a/src/core/entity.h
+++ b/src/core/entity.h
@@ -26,6 +26,7 @@ class EntityControlable;
#include "core/extension.h"
#include "core/descriptions.h"
+#include "core/inventory.h"
#include "core/player.h"
#include "core/zone.h"
@@ -169,6 +170,11 @@ public:
return entity_visible;
}
+ ///entity inventory
+ inline Inventory *inventory() {
+ return entity_inventory;
+ }
+
/// entity menus
inline Menus &menus() {
return entity_menus;
@@ -303,6 +309,14 @@ public:
return entity_color_second;
}
+ /**
+ * @brief add an inventory to this entity
+ * Entity takes ownership over the inventory pointer
+ */
+ void set_inventory(Inventory *inventory);
+
+ void set_info(Info *info);
+
/* ---- deserializers -------------------------------------- */
/// receive a client-to-server update from a stream
@@ -390,6 +404,9 @@ private:
Zone* entity_oldzone;
Menus entity_menus;
+
+ Inventory* entity_inventory;
+ Info* entity_info;
Extension* entity_extension[4];
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc
index b615b5f..c0a769c 100644
--- a/src/core/gameconnection.cc
+++ b/src/core/gameconnection.cc
@@ -99,8 +99,6 @@ Info *GameConnection::info(const std::string &label)
// create a new information record and set the label
info = new Info(label);
- Info::add(info);
-
info->text().push_back("Requesting information...");
// send an information request to the server
diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc
index 272c349..b37f11a 100644
--- a/src/core/gameinterface.cc
+++ b/src/core/gameinterface.cc
@@ -13,7 +13,6 @@
#include "core/cvar.h"
#include "core/func.h"
#include "core/info.h"
-#include "core/item.h"
#include "core/gameinterface.h"
#include "core/player.h"
#include "core/zone.h"
@@ -142,13 +141,9 @@ void GameInterface::clear()
// remove all models
model::Model::clear();
-
// remove infos
Info::clear();
- // remove items
- Item::clear();
-
// clear player list
for (Players::iterator it = game_players.begin(); it != game_players.end(); it++) {
Player *player = (*it);
diff --git a/src/core/info.cc b/src/core/info.cc
index 745bc3b..4e5399a 100644
--- a/src/core/info.cc
+++ b/src/core/info.cc
@@ -12,14 +12,65 @@
namespace core
{
-Info::Registry Info::info_registry;
+/* ---- class Info ------------------------------------------------- */
+
+// default constructor
+Info::Info()
+{
+ static_info_id_counter++;
+ info_id = static_info_id_counter;
+
+ info_model = 0;
+ info_timestamp = 0;
+
+ add(this);
+}
Info::Info(const std::string & label)
{
+ static_info_id_counter++;
+ info_id = static_info_id_counter;
+
+ info_timestamp = 0;
+ info_model = 0;
+
info_label.assign(label);
aux::to_lowercase(info_label);
aux::strip_quotes(info_label);
+
+ add(this);
+}
+
+Info::Info(const unsigned int id)
+{
+ info_id = id;
+
+ info_timestamp = 0;
+ info_model = 0;
+
+ add(this);
+}
+
+Info::~Info()
+{
+ info_text.clear();
+ info_label.clear();
+ info_modelname.clear();
+ info_text.clear();
info_timestamp = 0;
+ info_model = 0;
+}
+
+void Info::set_label(const std::string & label)
+{
+ info_label.assign(label);
+ aux::to_label(info_label);
+}
+
+void Info::set_label(const char *label)
+{
+ info_label.assign(label);
+ aux::to_label(info_label);
}
void Info::set_name(const std::string & name)
@@ -42,6 +93,11 @@ void Info::set_modelname(const char *modelname)
info_modelname.assign(modelname);
}
+void Info::set_model(const model::Model *model)
+{
+ info_model = model;
+}
+
void Info::set_timestamp(const unsigned long timestamp)
{
info_timestamp = timestamp;
@@ -71,7 +127,7 @@ void Info::clear_text()
void Info::serialize_server_update(std::ostream & os) const
{
- os << '"' << name() << "\" \"" << modelname() << "\" " << info_text.size() << " ";
+ os << '"' << label() << "\" \"" << name() << "\" \"" << modelname() << "\" " << info_text.size() << " ";
for (Text::const_iterator it = info_text.begin(); it != info_text.end(); it++) {
if (it != info_text.begin())
@@ -86,6 +142,12 @@ void Info::receive_server_update(std::istream &is)
std::string n;
char c;
+ // read label
+ while ((is.get(c)) && (c != '"'));
+ while ((is.get(c)) && (c != '"'))
+ n += c;
+ info_label.assign(n);
+
// read name
while ((is.get(c)) && (c != '"'));
while ((is.get(c)) && (c != '"'))
@@ -114,13 +176,6 @@ void Info::receive_server_update(std::istream &is)
}
}
-Info::~Info()
-{
- info_text.clear();
- info_modelname.clear();
- info_text.clear();
-}
-
void Info::print() const
{
con_print << "label: ^B" << label() << " ^Nname: ^B" << name() << " ^Nmodel: ^B" << modelname() << "^N" << std::endl;
@@ -130,20 +185,24 @@ void Info::print() const
}
}
+
/* ---- static info registry --------------------------------------- */
+Info::Registry Info::info_registry;
+unsigned int Info::static_info_id_counter = 0;
+
void Info::add(Info *info)
{
- if (find(info->label()))
- return;
-
- info_registry[info->label()] = info;
+ info_registry.push_back(info);
}
Info *Info::find(const char *label)
{
+ if (!label)
+ return 0;
+
for (Registry::iterator it = info_registry.begin(); it != info_registry.end(); it++) {
- Info *info = (*it).second;
+ Info *info = (*it);
if (info->label().compare(label) == 0) {
return info;
}
@@ -153,8 +212,11 @@ Info *Info::find(const char *label)
Info *Info::find(const std::string & label)
{
+ if (!label.size())
+ return 0;
+
for (Registry::iterator it = info_registry.begin(); it != info_registry.end(); it++) {
- Info *info = (*it).second;
+ Info *info = (*it);
if (info->label().compare(label) == 0) {
return info;
}
@@ -162,19 +224,34 @@ Info *Info::find(const std::string & label)
return 0;
}
+Info *Info::find(const unsigned int id)
+{
+ if (!id)
+ return 0;
+
+ for (Registry::iterator it = info_registry.begin(); it != info_registry.end(); it++) {
+ Info *info = (*it);
+ if (info->id() == id) {
+ return info;
+ }
+ }
+ return 0;
+}
+
void Info::clear()
{
for (Registry::iterator it = info_registry.begin(); it != info_registry.end(); it++) {
- Info *info = (*it).second;;
+ Info *info = (*it);
delete info;
}
info_registry.clear();
+ static_info_id_counter = 0;
}
void Info::list()
{
for (Registry::iterator it = info_registry.begin(); it != info_registry.end(); it++) {
- Info *info = (*it).second;;
+ Info *info = (*it);
con_print << info->label() << std::endl;
}
con_print << info_registry.size() << " registered info " << aux::plural("record", info_registry.size()) << std::endl;
diff --git a/src/core/info.h b/src/core/info.h
index 8395954..9f1fab8 100644
--- a/src/core/info.h
+++ b/src/core/info.h
@@ -9,7 +9,7 @@
#include <iostream>
#include <string>
-#include <map>
+#include <vector>
#include <deque>
#include "model/model.h"
@@ -18,19 +18,34 @@ namespace core
{
/**
- * an information record
+ * @brief an information record
+ * An information record holds extended information about a specific entity or item class.
+ * This information isexchanged between server and the client, and can be used to build
+ * HUD widgets/
*/
class Info
{
public:
+ /// type definition for the text description
+ typedef std::deque<std::string> Text;
+
+ /// create a new labeled information record
+ Info();
+
/// create a new labeled information record
Info(const std::string & label);
+
+ Info(const unsigned int id);
/// delete the information record
~Info();
- typedef std::deque<std::string> Text;
+ /* ---- inspectors ------------------------------------------------- */
+ inline const unsigned int id() const {
+ return info_id;
+ }
+
inline const std::string & label() const {
return info_label;
}
@@ -42,15 +57,26 @@ public:
inline const std::string & modelname() const {
return info_modelname;
}
+
+ inline const model::Model *model() const {
+ return info_model;
+ }
inline const unsigned long &timestamp() const {
return info_timestamp;
}
+ /// text description
inline Text & text() {
return info_text;
}
+ /* ---- mutators --------------------------------------------------- */
+
+ void set_label(const std::string & name);
+
+ void set_label(const char *name);
+
void set_name(const std::string & name);
void set_name(const char *name);
@@ -58,16 +84,12 @@ public:
void set_modelname(const std::string & modelname);
void set_modelname(const char *modelname);
+
+ void set_model(const model::Model *model);
/// set the timestamp
void set_timestamp(const unsigned long timestamp);
- /// clear the timestamp
- void clear_timestamp();
-
- /// add a line of info text
- void add_text(const char *text);
-
/// add a line of info text
void add_text(const std::string & text);
@@ -76,25 +98,54 @@ public:
/// print info to sys::con_out
void print() const;
+
+ /// clear the timestamp
+ void clear_timestamp();
+ /// add a line of info text
+ void add_text(const char *text);
+
+ /* ---- serializers ------------------------------------------------ */
+
/// serialize a server-to-client update on a stream
void serialize_server_update(std::ostream & os) const;
/// receive a server-to-client update from a stream
void receive_server_update(std::istream &is);
- /* ---- static info registry --------------------------------------- */
+private:
- typedef std::map<std::string, Info*> Registry;
+ unsigned int info_id;
+
+ std::string info_label;
+ std::string info_name;
+ std::string info_modelname;
+
+ const model::Model* info_model;
+
+ long info_credits;
+ unsigned long info_timestamp;
- /// add an item to the info regsitry
- static void add(Info *info);
+ Text info_text;
- /// search the info registry for a labeled item
+ /* ---- static info registry --------------------------------------- */
+
+public:
+ /// info registry type definition
+ typedef std::vector<Info*> Registry;
+
+ /// the info registry
+ static inline Registry & registry() {
+ return info_registry;
+ }
+ /// search the info registry for a labeled item
static Info *find(const char * label);
- /// search the info registry for a labeled item
+ /// search the info registry for a label
static Info *find(const std::string & label);
+
+ /// search the info registry for an id
+ static Info *find(const unsigned int id);
/// clear the info registry
static void clear();
@@ -102,21 +153,12 @@ public:
/// list the info registry
static void list();
- /// the info registry
- static inline Registry & registry() {
- return info_registry;
- }
-
private:
- std::string info_label;
- std::string info_name;
- std::string info_modelname;
- Text info_text;
-
- long info_credits;
- static Registry info_registry;
+ /// add a record to the info registry
+ static void add(Info *info);
- unsigned long info_timestamp;
+ static Registry info_registry;
+ static unsigned int static_info_id_counter;
};
}
diff --git a/src/core/inventory.cc b/src/core/inventory.cc
new file mode 100644
index 0000000..a58664c
--- /dev/null
+++ b/src/core/inventory.cc
@@ -0,0 +1,69 @@
+/*
+ core/inventory.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#include "core/inventory.h"
+#include "sys/sys.h"
+
+namespace core
+{
+
+/* ---- class Inventory -------------------------------------------- */
+
+Inventory::Inventory()
+{
+
+}
+
+Inventory::~Inventory()
+{
+ clear();
+}
+
+void Inventory::add(Item *item)
+{
+ for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); it++) {
+ // check if the item was already added
+ if ((*it) == item)
+ return;
+ }
+ inventory_items.push_back(item);
+}
+
+void Inventory::remove(Item *item)
+{
+ for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); it++) {
+ if ((*it) == item) {
+ inventory_items.erase(it);
+ delete item;
+ return;
+ }
+ }
+}
+
+Item *Inventory::find(unsigned int const class_id, unsigned int const info_id)
+{
+ // sarch the inventory for a specified item type
+ for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); it++) {
+ Item *item = (*it);
+ if ((item->class_id() == class_id) && (item->info_id() == info_id )) {
+ return item;
+ }
+ }
+ // not found
+ return 0;
+}
+
+void Inventory::clear()
+{
+ for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); it++) {
+ Item *item = (*it);
+ delete item;
+ }
+ inventory_items.clear();
+}
+
+} // namespace core
+
diff --git a/src/core/inventory.h b/src/core/inventory.h
new file mode 100644
index 0000000..0a1db92
--- /dev/null
+++ b/src/core/inventory.h
@@ -0,0 +1,64 @@
+/*
+ core/inventory.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CORE_INVENTORY_H__
+#define __INCLUDED_CORE_INVENTORY_H__
+
+#include "core/item.h"
+
+#include <vector>
+
+namespace core
+{
+
+/**
+ * @brief an entity inventory
+ */
+class Inventory
+{
+public:
+ /**
+ * @brief type definition for the items in the inventory
+ */
+ typedef std::vector<Item *> Items;
+
+ /**
+ * @brief default constructor
+ */
+ Inventory();
+
+ /**
+ * @brief default destructor
+ */
+ ~Inventory();
+
+ /**
+ * @brief add an item to the inventory
+ */
+ void add(Item *item);
+
+ /**
+ * @brief remove an item from the inventory and delete it
+ */
+ void remove(Item *item);
+
+ /**
+ * @brief removes all items from the inventory and delete them
+ */
+ void clear();
+
+ /**
+ * @brief search the inventory for a specific item type
+ */
+ Item *find(unsigned int const class_id, unsigned int const info_id);
+
+private:
+ Items inventory_items;
+};
+
+} // namsepace core
+
+#endif // __INCLUDED_CORE_INVENTORY_H__
diff --git a/src/core/item.cc b/src/core/item.cc
index 53da74d..a029674 100644
--- a/src/core/item.cc
+++ b/src/core/item.cc
@@ -12,102 +12,24 @@ namespace core
/* ---- class Item ------------------------------------------------- */
-
-Item::Registry Item::item_registry;
-
-void Item::add_class(ItemClass * itemclass)
-{
-
-}
-
-void Item::add_type(ItemClass * itemclass, ItemType *itemtype)
-{
-
-}
-
-void Item::find_class(const char *label)
-{
-
-}
-
-void Item::clear()
-{
- for (Registry::iterator it = item_registry.begin(); it != item_registry.end(); it++) {
- delete(*it);
- }
- item_registry.clear();
-}
-
-void Item::list()
-{
- for (Registry::iterator it = item_registry.begin(); it != item_registry.end(); it++) {
- con_print << " item class ^B " << (*it)->name() << std::endl;
- (*it)->list();
- }
- con_print << item_registry.size() << " registered item classes" << std::endl;
-}
-
-/* ---- class ItemClass -------------------------------------------- */
-
-ItemClass::ItemClass(const char *label)
+Item::Item(const unsigned int class_id, const unsigned int info_id)
{
- if (label) {
- itemclass_label.assign(label);
- } else {
- itemclass_label.clear();
- }
-}
-
-ItemClass::~ItemClass()
-{
- for (Types::iterator it = itemclass_types.begin(); it != itemclass_types.end(); it++) {
- delete(*it);
- }
-}
-
-void ItemClass::list()
-{
-}
-
-void ItemClass::set_name(const std::string &name)
-{
- itemclass_name.assign(name);
-}
-
-void ItemClass::add_type(ItemType *itemtype)
-{
- for (Types::iterator it = itemclass_types.begin(); it != itemclass_types.end(); it++) {
- con_print << " " << (*it)->name() << std::endl;
- }
-}
-
-ItemType *ItemClass::find_type(const char *label)
-{
- return 0;
-}
-
-/* ---- class ItemType --------------------------------------------- */
-
-ItemType::ItemType(const char *label)
-{
- if (label) {
- itemtype_label.assign(label);
- } else {
- itemtype_label.clear();
- }
-
- itemtype_baseprice = 0;
+ item_class_id = class_id;
+ item_info_id = info_id;
+
+ item_amount = 0;
+ item_info = Info::find(info_id);
}
-void ItemType::set_name(const std::string &name)
+Item::~Item()
{
- itemtype_name.assign(name);
+ item_amount = 0;
}
-void ItemType::set_baseprice(const float baseprice)
+void Item::set_amount(const int amount)
{
- itemtype_baseprice = 0;
+ item_amount = amount;
}
-} // class core
+} // namespace core
diff --git a/src/core/item.h b/src/core/item.h
index 0845c21..f88da57 100644
--- a/src/core/item.h
+++ b/src/core/item.h
@@ -7,93 +7,53 @@
#ifndef __INCLUDED_CORE_ITEM_H__
#define __INCLUDED_CORE_ITEM_H__
-#include <string>
-#include <vector>
+#include "core/info.h"
namespace core
{
/**
- * @brief a specific type of item in the game
- * Examples are tritanium hull armor, ion cannon, iron ore
+ * @brief an item in the inventory of an entity
+ * The info record represents the type of the item
*/
-class ItemType
+class Item
{
public:
- ItemType(const char *label);
-
- inline const std::string &label() {
- return itemtype_label;
- }
-
- inline const std::string &name() {
- return itemtype_name;
- }
-
- inline const float baseprice() {
- return itemtype_baseprice;
- }
-
- void set_name(const std::string &name);
-
- void set_baseprice(const float baseprice);
-
+ Item(const unsigned int class_id, const unsigned int info_id);
+
+ ~Item();
+
+ /* ---- inspectors --------------------------------------------- */
+
+ inline unsigned int class_id() const { return item_class_id; }
+
+ inline unsigned int info_id() const { return item_info_id; }
+
+ /**
+ * @brief associated amount
+ */
+ inline int amount() const { return item_amount; }
+
+ /**
+ * @brief information record
+ */
+ inline Info *info();
+
+ /* ---- mutators ----------------------------------------------- */
+
+ /**
+ * @brief set associated amount
+ */
+ void set_amount(const int amount);
+
private:
- std::string itemtype_label;
- std::string itemtype_name;
-
- float itemtype_baseprice;
+ unsigned int item_class_id;
+ unsigned int item_info_id;
+ int item_amount;
+
+ Info *item_info;
};
+} // namespace core
-/**
- * @brief a class of items
- * Examples are armor, cannons, commodities...
- */
-class ItemClass
-{
-public:
- typedef std::vector<ItemType *> Types;
-
- ItemClass(const char *label);
- ~ItemClass();
-
- inline const std::string &label() {
- return itemclass_label;
- }
-
- inline const std::string &name() {
- return itemclass_name;
- }
-
- ItemType *find_type(const char *label);
-
- void set_name(const std::string &name);
-
- void add_type(ItemType *itemtype);
-
- void list();
-
-private:
- std::string itemclass_label;
- std::string itemclass_name;
-
- Types itemclass_types;
-};
-
-class Item
-{
-public:
- typedef std::vector<ItemClass *> Registry;
-
- static void add_class(ItemClass * itemclass);
- static void add_type(ItemClass * itemclass, ItemType *itemtype);
- static void find_class(const char *label);
- static void clear();
- static void list();
-
- static Registry item_registry;
-};
-
-}
-#endif
+#endif // __INCLUDED_CORE_ITEM_H__
diff --git a/src/core/net.h b/src/core/net.h
index cd8e249..a217d94 100644
--- a/src/core/net.h
+++ b/src/core/net.h
@@ -11,7 +11,7 @@ namespace core
{
/// network protocol version
-const unsigned int PROTOCOLVERSION = 17;
+const unsigned int PROTOCOLVERSION = 18;
/// maximum lenght of a (compressed) network message block
const unsigned int FRAMESIZE = 1152;
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index c37fe05..39a25a3 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -436,6 +436,8 @@ void NetConnection::send_info_request(Info *info)
* frame
* sup <id>
* pif <id>
+ * pid <id>
+ * inf <id>
* zone
*/
void NetConnection::parse_incoming_message(const std::string & message)
@@ -684,29 +686,27 @@ void NetConnection::parse_incoming_message(const std::string & message)
return;
}
}
+
} else if (command == "inf") {
// incoming info record
- std::string label;
- char c;
-
- while ((msgstream.get(c)) && (c != '"'));
- while ((msgstream.get(c)) && (c != '"'))
- label += c;
-
- if (label.size()) {
- Info *info = Info::find(label);
+ unsigned int id;
+ if (msgstream >> id) {
+
+ Info *info = Info::find(id);
if (!info) {
- info = new Info(label);
- Info::add(info);
+ info = new Info(id);
}
info->receive_server_update(msgstream);
info->clear_timestamp();
+
} else {
con_warn << "Received empty information record!" << std::endl;
}
+
} else if (command == "sup") {
+
if (connection_state == Connected) {
unsigned int id;
if (msgstream >> id) {
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 1ae928b..c4eef11 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -562,7 +562,7 @@ void NetServer::send_player_disconnect_info(NetClient *client, Player *player)
void NetServer::send_info_update(NetClient *client, Info *info)
{
std::ostringstream msg;
- msg << "inf " << '"' << info->label() << '"' << ' ';
+ msg << "inf " << info->id() << ' ';
info->serialize_server_update(msg);
msg << '\n';
client->send_raw(msg.str());