Use unsigned ints for terrain indexing

Fixes the problem with 512x512 terrains