Esempio n. 1
0
bool AdminCache::InvalidateAdmin(AdminId id)
{
	AdminUser *pUser = (AdminUser *)m_pMemory->GetAddress(id);
	AdminUser *pOther;
	if (!pUser || pUser->magic != USR_MAGIC_SET)
	{
		return false;
	}

	if (!m_InvalidatingAdmins && !m_destroying)
	{
		g_Players.ClearAdminId(id);
	}

	/* Unlink from the dbl link list */
	if (id == m_FirstUser && id == m_LastUser)
	{
		m_FirstUser = INVALID_ADMIN_ID;
		m_LastUser = INVALID_ADMIN_ID;
	} else if (id == m_FirstUser) {
		m_FirstUser = pUser->next_user;
		pOther = (AdminUser *)m_pMemory->GetAddress(m_FirstUser);
		pOther->prev_user = INVALID_ADMIN_ID;
	} else if (id == m_LastUser) {
		m_LastUser = pUser->prev_user;
		pOther = (AdminUser *)m_pMemory->GetAddress(m_LastUser);
		pOther->next_user = INVALID_ADMIN_ID;
	} else {
		pOther = (AdminUser *)m_pMemory->GetAddress(pUser->prev_user);
		pOther->next_user = pUser->next_user;
		pOther = (AdminUser *)m_pMemory->GetAddress(pUser->next_user);
		pOther->prev_user = pUser->prev_user;
	}

	/* Unlink from auth tables */
	if (pUser->auth.identidx != -1)
	{
		Trie *pTrie = GetMethodByIndex(pUser->auth.index);
		if (pTrie)
		{
			sm_trie_delete(pTrie, m_pStrings->GetString(pUser->auth.identidx));
		}
	}

	/* Clear table counts */
	pUser->grp_count = 0;
	
	/* Link into free list */
	pUser->magic = USR_MAGIC_UNSET;
	pUser->next_user = m_FreeUserList;
	m_FreeUserList = id;

	/* Unset serial change */
	pUser->serialchange = 0;

	return true;
}
Esempio n. 2
0
void ScriptEngine::generateReference()
{
	if (!m_engine)
		return;

	std::ofstream out("AngelScript reference.txt");

	out << "*** Globals ***" << std::endl << std::endl;
	int nb = m_engine->GetGlobalFunctionCount();
	for (int i = 0; i < nb; ++i)
	{
		auto func = m_engine->GetGlobalFunctionByIndex(i);
		out << "\t" << func->GetDeclaration(true, false, true) << std::endl;
	}

	out << std::endl << "*** Types ***" << std::endl << std::endl;
	nb = m_engine->GetObjectTypeCount();
	for (int i = 0; i < nb; ++i)
	{
		auto info = m_engine->GetObjectTypeByIndex(i);
		out << " * " << info->GetName() << std::endl;

		int nb2 = info->GetPropertyCount();
		for (int j = 0; j < nb2; ++j)
		{
			const char* name;
			int typeId;
			bool isPrivate, isProtected, isReference;
			auto prop = info->GetProperty(j, &name, &typeId, &isPrivate, &isProtected, nullptr, &isReference);
			out << "\t";

			if (isProtected)
				out << "protected ";
			if (isPrivate)
				out << "private ";
			out << m_engine->GetTypeDeclaration(typeId);
			if (isReference)
				out << "&";
			out << " ";
			out << name << std::endl;
		}
		if (nb2 != 0)
			out << std::endl;

		nb2 = info->GetBehaviourCount();
		bool hasBehaviour = false;
		for (int j = 0; j < nb2; ++j)
		{
			asEBehaviours behaviour;
			auto func = info->GetBehaviourByIndex(j, &behaviour);
			if (behaviour == asBEHAVE_CONSTRUCT || behaviour == asBEHAVE_DESTRUCT)
			{
				hasBehaviour = true;
				out << "\t" << func->GetDeclaration(false, false, true) << std::endl;
			}
		}
		if (hasBehaviour)
			out << std::endl;

		nb2 = info->GetFactoryCount();
		for (int j = 0; j < nb2; ++j)
		{
			auto func = info->GetFactoryByIndex(j);
			out << "\t" << func->GetDeclaration(false, false, true) << std::endl;
		}
		if (nb2 != 0)
			out << std::endl;

		nb2 = info->GetMethodCount();
		for (int j = 0; j < nb2; ++j)
		{
			auto func = info->GetMethodByIndex(j);
			out << "\t" << func->GetDeclaration(false, false, true) << std::endl;
		}

		out << std::endl;
	}
}