Fix RepairBuilding not working for AI and Lua scripts

Fixes #5861
Merge pull request #5865 from obrakmann/fix5861

Fix RepairBuilding not working for AI and Lua scripts