Wellington's army consisted of four combat arms: Infantry, cavalry and artillery. Engineers also played a valuable role in the Peninsula, such as the building of the Lines of Torres Vedras – a defensive line of forts built to protect Lisbon – and making preparations for any sieges throughout the war. Wellington's main combat arm was his well-trained infantry. He never had more than 2,000 cavalry before 1812, and his cannons, although highly competent, were inferior to French guns in both number and quality. It was with this force that Wellington aimed to defend Portugal until he took to an offensive strategy in 1812, beating the French at the Battle of Salamanca. He advanced on to Madrid, arriving on 12 August 1812 – Joseph Bonaparte had abandoned the capital after the defeat at Salamanca.