function gadget:GetInfo()
	return {
		name = "RaiseMe",
		desc = "Special heightmap manipulation for demo",
		author = "Argh",
		date = "August 31, 2009",
		license = "(C) 2009, GNU GPL v. 2",
		layer = 1,
		enabled = true,
	}
end

local RaiseMe = {}

if (gadgetHandler:IsSyncedCode()) then
--////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////////
function gadget:Initialize()
	gadgetHandler:RegisterGlobal("PieceNums", PieceNums)
	for ud,_ in pairs(UnitDefs) do
		if UnitDefs[ud].customParams.raiseme == 'yes' then
			table.insert(RaiseMe,ud,1)
		end
	end
end


function gadget:UnitFinished(unitID, unitDefID, teamID)
	if RaiseMe[unitDefID] then
		local x,y,z = Spring.GetUnitPosition(unitID)
		local facing = Spring.GetUnitBuildFacing(unitID)
		--Spring.Echo(facing)
		local startX,startZ,finishX,finishZ
		if facing == 0 or facing == 2 then
			startX = math.floor(x - 4*UnitDefs[unitDefID].xsize) -4
			startZ = math.floor(z - 4*UnitDefs[unitDefID].zsize) -4
			finishX = math.floor(x + 4*UnitDefs[unitDefID].xsize) +4
			finishZ = math.floor(z + 4*UnitDefs[unitDefID].zsize) +4
		end

		if facing == 1 or facing == 3 then
			startX = math.floor(x - 4*UnitDefs[unitDefID].zsize) -4
			startZ = math.floor(z - 4*UnitDefs[unitDefID].xsize) -4
			finishX = math.floor(x + 4*UnitDefs[unitDefID].zsize) +4
			finishZ = math.floor(z + 4*UnitDefs[unitDefID].xsize) +4
		end

		--Spring.Echo(startX,startZ,finishX,finishZ)
		
		Spring.SetHeightMapFunc(
		  function()
			for nowX = startX,finishX,1 do
				for nowZ = startZ,finishZ,1 do
					Spring.SetHeightMap(nowX,nowZ,400,1)
				end
			end
		  end
		  ) 
		Spring.LevelHeightMap(startX, startZ, finishX, finishZ,400)
		Spring.AdjustHeightMap(startX, startZ, finishX, finishZ,0)
	end
end
--////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////////
--////////////////////////////////////////////////////////////////////
end