| 517 | |
| 518 | |
| 519 | void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player) |
| 520 | { |
| 521 | cItem Result(*GetSlot(0, a_Player)); |
| 522 | if (Result.IsEmpty()) |
| 523 | { |
| 524 | return; |
| 525 | } |
| 526 | cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1; |
| 527 | for (;;) |
| 528 | { |
| 529 | // Try distributing the result. If it fails, bail out: |
| 530 | cItem ResultCopy(Result); |
| 531 | m_ParentWindow.DistributeStack(ResultCopy, a_Player, this, false); |
| 532 | if (!ResultCopy.IsEmpty()) |
| 533 | { |
| 534 | // Couldn't distribute all of it. Bail out |
| 535 | return; |
| 536 | } |
| 537 | |
| 538 | // Distribute the result, this time for real: |
| 539 | ResultCopy = Result; |
| 540 | m_ParentWindow.DistributeStack(ResultCopy, a_Player, this, true); |
| 541 | |
| 542 | // Remove the ingredients from the crafting grid and update the recipe: |
| 543 | cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player); |
| 544 | cCraftingGrid Grid(PlayerSlots, m_GridSize, m_GridSize); |
| 545 | Recipe.ConsumeIngredients(Grid); |
| 546 | Grid.CopyToItems(PlayerSlots); |
| 547 | UpdateRecipe(a_Player); |
| 548 | if (!Recipe.GetResult().IsEqual(Result)) |
| 549 | { |
| 550 | // The recipe has changed, bail out |
| 551 | return; |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | |
| 557 |
nothing calls this directly
no test coverage detected