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

Method CreateAdmin

core/logic/AdminCache.cpp:395–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395AdminId AdminCache::CreateAdmin(const char *name)
396{
397 AdminId id;
398 AdminUser *pUser;
399
400 if (m_FreeUserList != INVALID_ADMIN_ID)
401 {
402 pUser = (AdminUser *)m_pMemory->GetAddress(m_FreeUserList);
403 assert(pUser->magic == USR_MAGIC_UNSET);
404 id = m_FreeUserList;
405 m_FreeUserList = pUser->next_user;
406 }
407 else
408 {
409 id = m_pMemory->CreateMem(sizeof(AdminUser), (void **)&pUser);
410 pUser->grp_size = 0;
411 pUser->grp_table = -1;
412 }
413
414 pUser->flags = 0;
415 pUser->eflags = 0;
416 pUser->grp_count = 0;
417 pUser->password = -1;
418 pUser->magic = USR_MAGIC_SET;
419 pUser->auth.identidx = -1;
420 pUser->auth.index = 0;
421 pUser->immunity_level = 0;
422 pUser->serialchange = 1;
423
424 if (m_FirstUser == INVALID_ADMIN_ID)
425 {
426 m_FirstUser = id;
427 m_LastUser = id;
428 }
429 else
430 {
431 AdminUser *pPrev = (AdminUser *)m_pMemory->GetAddress(m_LastUser);
432 pPrev->next_user = id;
433 pUser->prev_user = m_LastUser;
434 m_LastUser = id;
435 }
436
437 /* Since we always append to the tail, we should invalidate their next */
438 pUser->next_user = -1;
439
440 if (name && name[0] != '\0')
441 {
442 int nameidx = m_pStrings->AddString(name);
443 pUser = (AdminUser *)m_pMemory->GetAddress(id);
444 pUser->nameidx = nameidx;
445 }
446 else
447 {
448 pUser->nameidx = -1;
449 }
450
451 return id;
452}

Callers 3

CreateAdminFunction · 0.80
AddUserFlagsFunction · 0.80
SetUserFlagBitsFunction · 0.80

Calls 3

GetAddressMethod · 0.45
CreateMemMethod · 0.45
AddStringMethod · 0.45

Tested by

no test coverage detected