Daniel Murray knows it’ll be easier to stay out of trouble if he gets off the street.

On parole after spending 14 months in prison for selling drugs, he’s currently homeless. He makes only about $180 a week doing part-time maintenance work for CalTrans — not enough to cover rent, plus living expenses, at even the most rundown downtown hotel. The best he’s been able to find costs $700 a month for a room with a shared bathroom.

“I could flip $500 in drugs and get a hotel by nightfall,” he said, standing on an East Village sidewalk on a recent afternoon, “but I’m not going to do that.”

Residential hotels, also called single-room occupancy hotels, or SROs, are often referred to as the housing of last resort for low-wage workers and folks on fixed incomes. A decade ago, you could find a room for $400 or $500 a month, sometimes less. But two things are happening to the city’s SRO stock: It’s shrinking and what remains is often unaffordable to the populations it used to serve: low-wage workers, seniors and folks on disability.

According to a recent survey by the San Diego Housing Commission, as of October 2015, there were 3,872 single-room occupancy units within the city, down significantly from the 8,950 units counted in a 2003 survey. Those two studies looked at SROs citywide. A 1988 report on SRO creation and preservation, prepared for the City Council, counted more than 4,000 units in downtown alone, with another 1,800 units in the pipeline. That report warned in bold text: “The impact of losing SROs results in an increase in the homeless population.”

Steven Russell, executive director of the San Diego Housing Federation, said there’s no question the loss of SRO units has led to a spike in downtown San Diego’s homeless population.

“Nearly two-thirds of them became homeless here in San Diego,” he said. “They didn’t arrive here that way. That speaks to me of a housing ladder that has lost its bottom rungs.”

In 2004, a change to a state law called the Ellis Act gave cities the ability to pass regulations to protect SROs from being demolished or turned into market-rate housing. San Diego’s ordinance says property owners can’t convert or tear down an SRO without agreeing to replace the lost units and pay each long-term tenant two months’ rent to cover relocation costs.

Owners of downtown’s 44-unit Star Hotel, for instance, which closed earlier this year to be replaced by a high-rise, were required to provide relocation assistance and pay just over $1 million into the Housing Commission’s SRO replacement fund, said commission spokeswoman Maria Velasquez.

But owners of 22 downtown SROs, representing more than 2,100 units, successfully applied for an exemption from the 2004 law. Of those, nearly half no longer exist. Meanwhile, buildings with owners who didn’t apply for the exemption are locked into being SROs. The result is decades-old buildings with deferred maintenance and code-compliance issues that owners can’t afford to fix.

“The regulations are so onerous, people don’t want to touch them,” Russell said. “And any change that requires any kind of permit is going to trigger all kind of [additional] upgrades. So what we’ve done is frozen pretty degraded land-use. There’s no incentive to tear them down or replace them.”

Redevelopment — the urban-renewal program axed by the state in 2012 — used to provide an incentive: In 2006, for instance, the city’s now-defunct redevelopment agency worked out a deal with the owners of the Southern Hotel, an 89-unit historic SRO: In exchange for a $1.6-million loan to cover rehabilitation costs, they agreed to keep 50 units affordable to people making less than $20,000 a year.

At a recent panel discussion on homelessness, Piedad Garcia, deputy director for the county’s Behavioral Health Services division, said cities should find ways to encourage the rehab of old motels into housing for the homeless. The benefit would be two-fold, she said: You’re fixing up a community eyesore and providing much-needed units quickly.

“It takes anywhere from two years to five years to build affordable units from the ground up,” Garcia said.

She pointed to Los Angeles’ plans to convert run-down motels and empty hospitals into 500 units of affordable housing for homeless and low-income military veterans. But that project wouldn’t be possible without state and federal funding aimed at reducing veteran homelessness.

Earlier this year, the county launched Project One for All with the goal to get homeless people who’ve been diagnosed with a serious mental illness off the street and into supportive housing. Todd Henderson, San Diego County’s director of Housing & Community Development, said the program includes funding for housing projects, both new construction and rehabbing existing units.

Without funding assistance, rehabbing motels and SROs generally isn’t cost-effective, Henderson said.

“Some of the challenges I’ve heard from developers is a lot of the motels, the ones that are available for purchase, typically have a lot of deferred maintenance,” he said. “They’ve been run with an eye on maximizing profit.”

The Hotel Churchill, located in downtown San Diego, is one example of a rehab project that ended up costing more than originally planned. In late 2007, the Housing Commission acquired the 92-unit SRO after the building’s owner evicted tenants and unsuccessfully challenged the city’s SRO law in court. When it reopens later this year, the Churchill will provide 72 studio apartments — for homeless veterans, former foster youth and adults requiring supportive services — but at a rehab cost of more than $20 million, or $280,000 per unit, partially due to unforeseen problems with the building’s top floor.

A structural engineer who reviewed plans for the Churchill’s retrofit last year described the 102-year-old building as “at least as good as a new.”

For SROs and motel rehabs that could be relatively quick, cost-efficient and targeted toward the homeless, there’s really no dedicated source of funding. Those projects have to compete with new construction projects for local, state or federal dollars that are already scarce.

“The state housing bonds are exhausted, redevelopment is gone and federal funds have been reduced. All told, that’s a $1.7 billion reduction per year in funding for affordable housing,” said Assemblywoman Toni Atkins, who, as a member of the San Diego City Council, challenged the closure of several SROs.

As for what the state can do to incentivize the purchase and rehab of SROs: “The state can identify a new source of money,” Atkins said. “That’s the answer.”

A new state program called No Place Like Home will provide $2 billion to house homeless folks with mental illness, but that does not replace the loss of other funding sources.

For now, the city is exploring ways to preserve SRO units and keep them affordable. One proposed change would give property owners the option of selling an SRO to the San Diego Housing Commission for fair market value. Such a sale would exempt the owner from the replacement requirement and ensure the units remain affordable and well-maintained.

Another proposed change would reduce the one-for-one replacement requirement by half, making it less likely an owner would ask the city for a waiver or modification, something that happened twice in 2015, prompting City Councilman Todd Gloria to call for a review of the city’s SRO laws.

Gloria said he doesn’t know the answer to making older SROs both safe and affordable — like Atkins, he mentioned redevelopment as having been a significant funding source for such projects. He said he’s hoping to see policy changes “that will preserve the units and hopefully upgrade them so that they’re not affordable only because they’re substandard housing.”

The Housing Federation’s Russell agrees the replacement requirement could be lowered to a level that isn’t punitive, “but still provides significant resources for the replacement of those units.”

But, he said, there’s the lingering, bigger question: “We’re protecting [SROs], but in terms of adding to the absolute supply, we need more units.”