Catch SerializationError in CCraftDefManager::getCraftResult()

This commit is contained in:
Perttu Ahola 2011-11-17 10:13:38 +02:00
parent 227e067512
commit cebbaf1664

@ -114,8 +114,8 @@ public:
IGameDef *gamedef) const IGameDef *gamedef) const
{ {
if(input_cpi.width > 3){ if(input_cpi.width > 3){
errorstream<<"getCraftResult: IGNORING ERROR: " errorstream<<"getCraftResult(): ERROR: "
<<"input_cpi.width > 3"<<std::endl; <<"input_cpi.width > 3; Failing to craft."<<std::endl;
return NULL; return NULL;
} }
InventoryItem *input_items[9]; InventoryItem *input_items[9];
@ -134,14 +134,16 @@ public:
{ {
CraftDefinition *def = *i; CraftDefinition *def = *i;
infostream<<"Checking "<<createInput(input_cpi).dump()<<std::endl /*infostream<<"Checking "<<createInput(input_cpi).dump()<<std::endl
<<" against "<<def->input.dump() <<" against "<<def->input.dump()
<<" (output=\""<<def->output<<"\")"<<std::endl; <<" (output=\""<<def->output<<"\")"<<std::endl;*/
try {
CraftPointerInput spec_cpi = createPointerInput(def->input, gamedef); CraftPointerInput spec_cpi = createPointerInput(def->input, gamedef);
if(spec_cpi.width > 3){ if(spec_cpi.width > 3){
errorstream<<"getCraftResult: IGNORING ERROR: " errorstream<<"getCraftResult: ERROR: "
<<"spec_cpi.width > 3"<<std::endl; <<"spec_cpi.width > 3 in recipe "
<<def->dump()<<std::endl;
continue; continue;
} }
InventoryItem *spec_items[9]; InventoryItem *spec_items[9];
@ -153,7 +155,6 @@ public:
spec_items[i] = NULL; spec_items[i] = NULL;
else else
spec_items[i] = spec_cpi.items[y*spec_cpi.width+x]; spec_items[i] = spec_cpi.items[y*spec_cpi.width+x];
infostream<<"spec_items["<<i<<"] = "<<spec_items[i]<<std::endl;
} }
bool match = checkItemCombination(input_items, spec_items); bool match = checkItemCombination(input_items, spec_items);
@ -163,6 +164,14 @@ public:
return InventoryItem::deSerialize(iss, gamedef); return InventoryItem::deSerialize(iss, gamedef);
} }
} }
catch(SerializationError &e)
{
errorstream<<"getCraftResult: ERROR: "
<<"Serialization error in recipe "
<<def->dump()<<std::endl;
// then go on with the next craft definition
}
}
return NULL; return NULL;
} }
virtual void registerCraft(const CraftDefinition &def) virtual void registerCraft(const CraftDefinition &def)