From 88a9bae160dd0bf28fe41b2a45c198d67a65c914 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 10 Aug 2011 23:22:44 +0200 Subject: constify inventory item serialization --- src/inventory.h | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'src/inventory.h') diff --git a/src/inventory.h b/src/inventory.h index 0e757a1e0..9c2027a53 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -49,7 +49,7 @@ public: 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 @@ -133,7 +133,7 @@ public: { return "MaterialItem"; } - virtual void serialize(std::ostream &os) + virtual void serialize(std::ostream &os) const { //os.imbue(std::locale("C")); os<<"MaterialItem2"; @@ -208,18 +208,13 @@ public: { 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<