Fix a loop closure bug in the weapons code.

Fixes #6597, #6599.