Convert loadmap.c to C++