--------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------


function reverseGlobalMarket(player)
	
	local save = _L.Saving.Get(player)
	if not save then
		return
	end	
	
	if save.HasReversedGlobalMarket then
		return
	end
	
	wait(2)
	
	-- add all auction postings back into the player's inventory
	local liveAuctions = _L.Functions.CloneTable(save.Auctions)
	save.Auctions = {}
	for _, auctionListing in ipairs(liveAuctions) do
		local quantity  = auctionListing.quantity
		local itemID    = auctionListing.itemID
		local className = auctionListing.className
		local payload = {
			quantity = quantity,
			itemID = itemID,
			className = className
		}
		table.insert(save.ReversedAuctionPostings, payload)
		_L.Inventory.AddItem(player, className, itemID, quantity)
	end
	
	save.HasReversedGlobalMarket = true
	
end
