forked from Mirrorlandia_minetest/minetest
Catch SerializationError in CCraftDefManager::getCraftResult()
This commit is contained in:
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,33 +134,42 @@ 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;*/
|
||||||
|
|
||||||
CraftPointerInput spec_cpi = createPointerInput(def->input, gamedef);
|
try {
|
||||||
if(spec_cpi.width > 3){
|
CraftPointerInput spec_cpi = createPointerInput(def->input, gamedef);
|
||||||
errorstream<<"getCraftResult: IGNORING ERROR: "
|
if(spec_cpi.width > 3){
|
||||||
<<"spec_cpi.width > 3"<<std::endl;
|
errorstream<<"getCraftResult: ERROR: "
|
||||||
continue;
|
<<"spec_cpi.width > 3 in recipe "
|
||||||
|
<<def->dump()<<std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
InventoryItem *spec_items[9];
|
||||||
|
for(u32 y=0; y<3; y++)
|
||||||
|
for(u32 x=0; x<3; x++)
|
||||||
|
{
|
||||||
|
u32 i=y*3+x;
|
||||||
|
if(x >= spec_cpi.width || y >= spec_cpi.height())
|
||||||
|
spec_items[i] = NULL;
|
||||||
|
else
|
||||||
|
spec_items[i] = spec_cpi.items[y*spec_cpi.width+x];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool match = checkItemCombination(input_items, spec_items);
|
||||||
|
|
||||||
|
if(match){
|
||||||
|
std::istringstream iss(def->output, std::ios::binary);
|
||||||
|
return InventoryItem::deSerialize(iss, gamedef);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InventoryItem *spec_items[9];
|
catch(SerializationError &e)
|
||||||
for(u32 y=0; y<3; y++)
|
|
||||||
for(u32 x=0; x<3; x++)
|
|
||||||
{
|
{
|
||||||
u32 i=y*3+x;
|
errorstream<<"getCraftResult: ERROR: "
|
||||||
if(x >= spec_cpi.width || y >= spec_cpi.height())
|
<<"Serialization error in recipe "
|
||||||
spec_items[i] = NULL;
|
<<def->dump()<<std::endl;
|
||||||
else
|
// then go on with the next craft definition
|
||||||
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);
|
|
||||||
|
|
||||||
if(match){
|
|
||||||
std::istringstream iss(def->output, std::ios::binary);
|
|
||||||
return InventoryItem::deSerialize(iss, gamedef);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user