What laws could have prevented this?

He was using an illegal magazine, so that law did not help.

So you need a law that says all veterans who served in combat loose their second amendment rights because they could pose a risk to society. This would have to be the case because all veterans who served in combat have PTSD or have experienced PTSD.

In fact your just going to have to outlaw everybody who has had a traumatic experience from possessing guns because all of them have experienced PTSD.

Every cop, every fire fighter, every ambulance worker and every ER doctor and nurse, everybody who has ever been in a traumatic event or witnessed one will have to have their 2nd amendment rights revoked because any of them could pose a risk to society.

You need to evaluate everybody on an annual basis who owns firearms to make sure they are fit to possess them.

The truth is you could do all of these things and it would have no impact on mass shootings, homicide or suicide with guns.

If someone is going to do something like that sometimes they show warning signs and sometimes they don't. Its like when someone wants to actually kill themselves they don't tell anybody they just do it. If someone wants a gun legal or not they can get one and use it, no law would prevent these shootings.

The only thing what would work is if they removed the 2nd amendment and destroyed all guns in America, then people would use knives or shovels instead to do mass killings.