Same cause, reason and solution as !2409 (merged) - the only exception being that this patch also fixes it for 2D maps, since they use different logic for initializing these variables.