Microenvironmental influences on T cell immunity in cancer and inflammation