mirror of
https://github.com/xtreme8000/CavEX.git
synced 2025-01-22 09:11:55 -05:00
Allow mirrored crafting recipe
This commit is contained in:
parent
12c734fb7e
commit
95953847d7
1 changed files with 30 additions and 23 deletions
|
@ -649,42 +649,49 @@ bool recipe_match(array_recipe_t recipes, struct item_data slots[9],
|
||||||
|
|
||||||
for(size_t y = 0; y <= 3 - current->height; y++) {
|
for(size_t y = 0; y <= 3 - current->height; y++) {
|
||||||
for(size_t x = 0; x <= 3 - current->width; x++) {
|
for(size_t x = 0; x <= 3 - current->width; x++) {
|
||||||
bool match = true;
|
bool match_outside_empty = true;
|
||||||
|
|
||||||
// check that outside of pattern is empty
|
// check that outside of pattern is empty
|
||||||
for(size_t py = 0; py < 3 && match; py++) {
|
for(size_t py = 0; py < 3 && match_outside_empty; py++) {
|
||||||
for(size_t px = 0; px < 3 && match; px++) {
|
for(size_t px = 0; px < 3 && match_outside_empty; px++) {
|
||||||
if((px < x || px >= x + current->width || py < y
|
if((px < x || px >= x + current->width || py < y
|
||||||
|| py >= y + current->height)
|
|| py >= y + current->height)
|
||||||
&& !slot_empty[px + py * 3])
|
&& !slot_empty[px + py * 3])
|
||||||
match = false;
|
match_outside_empty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check pattern itself
|
// check pattern itself
|
||||||
for(size_t py = 0; py < current->height && match; py++) {
|
for(int flip = 0; flip <= 1; flip++) {
|
||||||
for(size_t px = 0; px < current->width && match; px++) {
|
bool match = match_outside_empty;
|
||||||
size_t slots_idx = (px + x) + (py + y) * 3;
|
|
||||||
size_t shape_idx = px + py * current->width;
|
|
||||||
|
|
||||||
if(current->shape[shape_idx].item.id == 0) {
|
for(size_t py = 0; py < current->height && match; py++) {
|
||||||
if(!slot_empty[slots_idx])
|
for(size_t px = 0; px < current->width && match; px++) {
|
||||||
match = false;
|
size_t slots_idx = (px + x) + (py + y) * 3;
|
||||||
} else {
|
size_t shape_idx
|
||||||
if(slot_empty[slots_idx]
|
= (flip ? (current->width - 1 - px) : px)
|
||||||
|| current->shape[shape_idx].item.id
|
+ py * current->width;
|
||||||
!= slots[slots_idx].id
|
|
||||||
|| (current->shape->match_durability
|
if(current->shape[shape_idx].item.id == 0) {
|
||||||
&& current->shape[shape_idx].item.durability
|
if(!slot_empty[slots_idx])
|
||||||
!= slots[slots_idx].durability))
|
match = false;
|
||||||
match = false;
|
} else {
|
||||||
|
if(slot_empty[slots_idx]
|
||||||
|
|| current->shape[shape_idx].item.id
|
||||||
|
!= slots[slots_idx].id
|
||||||
|
|| (current->shape->match_durability
|
||||||
|
&& current->shape[shape_idx]
|
||||||
|
.item.durability
|
||||||
|
!= slots[slots_idx].durability))
|
||||||
|
match = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(match) {
|
if(match) {
|
||||||
*result = current->result;
|
*result = current->result;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue