1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-11-16 06:15:06 -05:00

Catch SerializationError in CCraftDefManager::getCraftResult()

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

View File

@ -114,8 +114,8 @@ public:
IGameDef *gamedef) const
{
if(input_cpi.width > 3){
errorstream<<"getCraftResult: IGNORING ERROR: "
<<"input_cpi.width > 3"<<std::endl;
errorstream<<"getCraftResult(): ERROR: "
<<"input_cpi.width > 3; Failing to craft."<<std::endl;
return NULL;
}
InventoryItem *input_items[9];
@ -134,14 +134,16 @@ public:
{
CraftDefinition *def = *i;
infostream<<"Checking "<<createInput(input_cpi).dump()<<std::endl
/*infostream<<"Checking "<<createInput(input_cpi).dump()<<std::endl
<<" against "<<def->input.dump()
<<" (output=\""<<def->output<<"\")"<<std::endl;
<<" (output=\""<<def->output<<"\")"<<std::endl;*/
try {
CraftPointerInput spec_cpi = createPointerInput(def->input, gamedef);
if(spec_cpi.width > 3){
errorstream<<"getCraftResult: IGNORING ERROR: "
<<"spec_cpi.width > 3"<<std::endl;
errorstream<<"getCraftResult: ERROR: "
<<"spec_cpi.width > 3 in recipe "
<<def->dump()<<std::endl;
continue;
}
InventoryItem *spec_items[9];
@ -153,7 +155,6 @@ public:
spec_items[i] = NULL;
else
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);
@ -163,6 +164,14 @@ public:
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;
}
virtual void registerCraft(const CraftDefinition &def)