if ($dstStorageUsed + $neededSpace > $dstUnit->get('carryCap') && $dstStorageUsed + $neededSpace > 100000) { exit('error 2-6011-' . ($dstStorageUsed + $neededSpace) . '/' . $dstUnit->get('carryCap')); } // Remove the resources from the source listUnitID for ($i = 3; $i < $pvSize; $i += 2) { $srcSupply->addItemAtSpot($srcSupply->slotData[$spotList[$postVals[$i]]] - $postVals[$i + 1], $spotList[$postVals[$i]], $slotFile); } // Index the spots for the destination slot $dstSpotList = []; for ($i = 3; $i < sizeof($postVals); $i += 2) { $dstSpotList[$postVals[$i]] = 0; for ($j = 1; $j <= sizeof($dstSupply->slotData); $j += 2) { if ($postVals[$i] == $dstSupply->slotData[$j]) { $dstSpotList[$postVals[$i]] = $j + 1; break; } } } echo 'DestSpotList'; print_r($dstSpotList); // Add the resources to the destination list for ($i = 3; $i < $pvSize; $i += 2) { if ($dstSpotList[$postVals[$i]] > 0) { $dstSupply->slotData[$dstSpotList[$postVals[$i]]] = $dstSupply->slotData[$dstSpotList[$postVals[$i]]] + $postVals[$i + 1]; } else { array_push($dstSupply->slotData[], $postVals[$i], $postVals[$i + 1]); } $dstSupply->saveSlot(); } fclose($slotFile); fclose($unitFile);