MCPcopy Create free account
hub / github.com/DFHack/dfhack / getTexposByHandle

Method getTexposByHandle

library/modules/Textures.cpp:220–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220long Textures::getTexposByHandle(TexposHandle handle) {
221 if (!handle || !enabler)
222 return -1;
223
224 if (g_handle_to_reserved_texpos.contains(handle))
225 return g_handle_to_reserved_texpos[handle];
226 if (g_handle_to_texpos.contains(handle))
227 return g_handle_to_texpos[handle];
228 if (std::find(g_delayed_regs.begin(), g_delayed_regs.end(), handle) != g_delayed_regs.end())
229 return 0;
230 if (g_handle_to_surface.contains(handle)) {
231 g_handle_to_surface[handle]->refcount++; // prevent destruct on next FreeSurface by game
232 if (loading_state) { // reinit dor dynamic range during loading -> delayed
233 g_delayed_regs.push_back(handle);
234 return 0;
235 }
236 auto texpos = add_texture(g_handle_to_surface[handle]);
237 g_handle_to_texpos.emplace(handle, texpos);
238 return texpos;
239 }
240
241 return -1;
242}
243
244TexposHandle Textures::createTile(std::vector<uint32_t>& pixels, int tile_px_w, int tile_px_h,
245 bool reserved) {

Callers

nothing calls this directly

Calls 5

add_textureFunction · 0.85
containsMethod · 0.80
findFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected