MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / MakePrimHandle

Method MakePrimHandle

core/logic/HandleSys.cpp:279–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279HandleError HandleSystem::MakePrimHandle(HandleType_t type,
280 QHandle **in_pHandle,
281 unsigned int *in_index,
282 Handle_t *in_handle,
283 IdentityToken_t *owner,
284 bool identity)
285{
286 HandleError err;
287 unsigned int owner_index = 0;
288
289 if (owner && (IdentityHandle(owner, &owner_index) != HandleError_None))
290 {
291 return HandleError_Identity;
292 }
293
294 unsigned int handle;
295 if ((err = TryAllocHandle(&handle)) != HandleError_None)
296 {
297 if (!TryAndFreeSomeHandles()
298 || (err = TryAllocHandle(&handle)) != HandleError_None)
299 {
300 return err;
301 }
302 }
303
304 if (owner)
305 {
306 owner->num_handles++;
307 if (!owner->warned_handle_usage && owner->num_handles >= HANDLESYS_WARN_USAGE)
308 {
309 owner->warned_handle_usage = true;
310
311 std::string path = "<unknown>";
312 if (auto plugin = scripts->FindPluginByIdentity(owner))
313 {
314 path = "plugin "s + plugin->GetFilename();
315 }
316 else if (auto ext = g_Extensions.GetExtensionFromIdent(owner))
317 {
318 path = "extension "s + ext->GetFilename();
319 }
320
321 logger->LogError("[SM] Warning: %s is using more than %d handles!",
322 path.c_str(), HANDLESYS_WARN_USAGE);
323 }
324 }
325
326 QHandle *pHandle = &m_Handles[handle];
327
328 assert(pHandle->set == false);
329
330 if (++m_HSerial >= HANDLESYS_MAX_SERIALS)
331 {
332 m_HSerial = 1;
333 }
334
335 /* Set essential information */
336 pHandle->set = identity ? HandleSet_Identity : HandleSet_Used;

Callers

nothing calls this directly

Calls 6

IdentityHandleFunction · 0.85
FindPluginByIdentityMethod · 0.80
GetExtensionFromIdentMethod · 0.80
GetFilenameMethod · 0.45
LogErrorMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected