C++ C4AI generateMasks refactoring