virtual const char* getName() const = 0;
// Shall write the name and the parameters
- virtual void serialize(std::ostream &os) = 0;
+ virtual void serialize(std::ostream &os) const = 0;
// Shall make an exact clone of the item
virtual InventoryItem* clone() = 0;
#ifndef SERVER
{
return "MaterialItem";
}
- virtual void serialize(std::ostream &os)
+ virtual void serialize(std::ostream &os) const
{
//os.imbue(std::locale("C"));
os<<"MaterialItem2";
{
return "MBOItem";
}
- virtual void serialize(std::ostream &os)
+ virtual void serialize(std::ostream &os) const
{
- for(;;)
- {
- size_t t = m_inventorystring.find('|');
- if(t == std::string::npos)
- break;
- m_inventorystring[t] = '?';
- }
+ std::string sane_string(m_inventorystring);
+ str_replace_char(sane_string, '|', '?');
os<<getName();
os<<" ";
- os<<m_inventorystring;
+ os<<sane_string;
os<<"|";
}
virtual InventoryItem* clone()
{
return "CraftItem";
}
- virtual void serialize(std::ostream &os)
+ virtual void serialize(std::ostream &os) const
{
os<<getName();
os<<" ";
{
return "ToolItem";
}
- virtual void serialize(std::ostream &os)
+ virtual void serialize(std::ostream &os) const
{
os<<getName();
os<<" ";
InventoryList(std::string name, u32 size);
~InventoryList();
void clearItems();
- void serialize(std::ostream &os);
+ void serialize(std::ostream &os) const;
void deSerialize(std::istream &is);
InventoryList(const InventoryList &other);
Inventory(const Inventory &other);
Inventory & operator = (const Inventory &other);
- void serialize(std::ostream &os);
+ void serialize(std::ostream &os) const;
void deSerialize(std::istream &is);
InventoryList * addList(const std::string &name, u32 size);
static InventoryAction * deSerialize(std::istream &is);
virtual u16 getType() const = 0;
- virtual void serialize(std::ostream &os) = 0;
+ virtual void serialize(std::ostream &os) const = 0;
virtual void apply(InventoryContext *c, InventoryManager *mgr) = 0;
};
return IACTION_MOVE;
}
- void serialize(std::ostream &os)
+ void serialize(std::ostream &os) const
{
os<<"Move ";
os<<count<<" ";