cgame: duplicate code removal