summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorThomas--S <Thomas--S@users.noreply.github.com>2017-06-04 21:42:32 +0200
committerSmallJoker <SmallJoker@users.noreply.github.com>2017-06-04 21:42:32 +0200
commit599e13e95e81aadb959c9f3715aec9b425ede084 (patch)
tree1cb10b680945d2f4e28c53df111bfbc680a77661 /src/inventory.cpp
parenta98baef5e4fedca36c8c8755ad7c8233469f6a3f (diff)
downloadminetest-599e13e95e81aadb959c9f3715aec9b425ede084.tar.gz
minetest-599e13e95e81aadb959c9f3715aec9b425ede084.tar.bz2
minetest-599e13e95e81aadb959c9f3715aec9b425ede084.zip
Remove deprecated code segments (#5891)
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp163
1 files changed, 22 insertions, 141 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 8617f7263..b4d1b4dd9 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -24,8 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h"
#include "itemdef.h"
#include "util/strfnd.h"
-#include "content_mapnode.h" // For loading legacy MaterialItems
-#include "nameidmapping.h" // For loading legacy MaterialItems
#include "util/serialize.h"
#include "util/string.h"
@@ -33,18 +31,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
ItemStack
*/
-static content_t content_translate_from_19_to_internal(content_t c_from)
-{
- for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
- {
- if(trans_table_19[i][1] == c_from)
- {
- return trans_table_19[i][0];
- }
- }
- return c_from;
-}
-
ItemStack::ItemStack(const std::string &name_, u16 count_,
u16 wear_, IItemDefManager *itemdef) :
name(itemdef->getAlias(name_)),
@@ -99,140 +85,35 @@ void ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef)
if(!tmp.empty())
throw SerializationError("Unexpected text after item name");
- if(name == "MaterialItem")
- {
- // Obsoleted on 2011-07-30
-
- u16 material;
- is>>material;
- u16 materialcount;
- is>>materialcount;
- // Convert old materials
- if(material <= 0xff)
- material = content_translate_from_19_to_internal(material);
- if(material > 0xfff)
- throw SerializationError("Too large material number");
- // Convert old id to name
- NameIdMapping legacy_nimap;
- content_mapnode_get_name_id_mapping(&legacy_nimap);
- legacy_nimap.getName(material, name);
- if(name == "")
- name = "unknown_block";
- if (itemdef)
- name = itemdef->getAlias(name);
- count = materialcount;
- }
- else if(name == "MaterialItem2")
- {
- // Obsoleted on 2011-11-16
-
- u16 material;
- is>>material;
- u16 materialcount;
- is>>materialcount;
- if(material > 0xfff)
- throw SerializationError("Too large material number");
- // Convert old id to name
- NameIdMapping legacy_nimap;
- content_mapnode_get_name_id_mapping(&legacy_nimap);
- legacy_nimap.getName(material, name);
- if(name == "")
- name = "unknown_block";
- if (itemdef)
- name = itemdef->getAlias(name);
- count = materialcount;
- }
- else if(name == "node" || name == "NodeItem" || name == "MaterialItem3"
- || name == "craft" || name == "CraftItem")
- {
- // Obsoleted on 2012-01-07
-
- std::string all;
- std::getline(is, all, '\n');
- // First attempt to read inside ""
- Strfnd fnd(all);
- fnd.next("\"");
- // If didn't skip to end, we have ""s
- if(!fnd.at_end()){
- name = fnd.next("\"");
- } else { // No luck, just read a word then
- fnd.start(all);
- name = fnd.next(" ");
- }
- fnd.skip_over(" ");
- if (itemdef)
- name = itemdef->getAlias(name);
- count = stoi(trim(fnd.next("")));
- if(count == 0)
- count = 1;
- }
- else if(name == "MBOItem")
- {
- // Obsoleted on 2011-10-14
- throw SerializationError("MBOItem not supported anymore");
- }
- else if(name == "tool" || name == "ToolItem")
- {
- // Obsoleted on 2012-01-07
+ do { // This loop is just to allow "break;"
+ // The real thing
- std::string all;
- std::getline(is, all, '\n');
- // First attempt to read inside ""
- Strfnd fnd(all);
- fnd.next("\"");
- // If didn't skip to end, we have ""s
- if(!fnd.at_end()){
- name = fnd.next("\"");
- } else { // No luck, just read a word then
- fnd.start(all);
- name = fnd.next(" ");
- }
- count = 1;
- // Then read wear
- fnd.skip_over(" ");
+ // Apply item aliases
if (itemdef)
name = itemdef->getAlias(name);
- wear = stoi(trim(fnd.next("")));
- }
- else
- {
- do // This loop is just to allow "break;"
- {
- // The real thing
-
- // Apply item aliases
- if (itemdef)
- name = itemdef->getAlias(name);
-
- // Read the count
- std::string count_str;
- std::getline(is, count_str, ' ');
- if(count_str.empty())
- {
- count = 1;
- break;
- }
- else
- count = stoi(count_str);
- // Read the wear
- std::string wear_str;
- std::getline(is, wear_str, ' ');
- if(wear_str.empty())
- break;
- else
- wear = stoi(wear_str);
+ // Read the count
+ std::string count_str;
+ std::getline(is, count_str, ' ');
+ if (count_str.empty()) {
+ count = 1;
+ break;
+ } else {
+ count = stoi(count_str);
+ }
- // Read metadata
- metadata.deSerialize(is);
+ // Read the wear
+ std::string wear_str;
+ std::getline(is, wear_str, ' ');
+ if (wear_str.empty())
+ break;
+ else
+ wear = stoi(wear_str);
- // In case fields are added after metadata, skip space here:
- //std::getline(is, tmp, ' ');
- //if(!tmp.empty())
- // throw SerializationError("Unexpected text after metadata");
+ // Read metadata
+ metadata.deSerialize(is);
- } while(false);
- }
+ } while(false);
if (name.empty() || count == 0)
clear();