rmgen: var -> let -> const
One should always use the variable declaration with the least possible scope.
This patch cleans up many (but not all) of the var in rmgen and replaces them with let or const.
The same is done for let -> const.
Differential revision: https://code.wildfiregames.com/D5214