本文整理汇总了C++中CClient::GetAccount方法的典型用法代码示例。如果您正苦于以下问题:C++ CClient::GetAccount方法的具体用法?C++ CClient::GetAccount怎么用?C++ CClient::GetAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClient
的用法示例。
在下文中一共展示了CClient::GetAccount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hasObjectPermissionTo
int CLuaACLDefs::hasObjectPermissionTo ( lua_State* luaVM )
{
// bool hasObjectPermissionTo ( string / element theObject, string theAction [, bool defaultPermission = true ] )
CResource* pResource = NULL; CElement* pElement = NULL; SString strObject; SString strRightName; bool bDefault; CAccessControlListGroupObject::EObjectType eObjectType;
CScriptArgReader argStream ( luaVM );
if ( argStream.NextIsUserDataOfType < CResource > () )
argStream.ReadUserData ( pResource );
else
if ( argStream.NextIsUserDataOfType < CElement > () )
argStream.ReadUserData ( pElement );
else
argStream.ReadString ( strObject );
argStream.ReadString ( strRightName );
argStream.ReadBool ( bDefault, true );
if ( !argStream.HasErrors () )
{
if ( pResource )
{
// Grab the resource's name
strObject = pResource->GetName ();
eObjectType = CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE;
}
else if ( pElement )
{
// Grab the client this player/console/whatever is
CClient* pClient = pElement->GetClient ();
if ( pClient )
{
// Get his account
CAccount* pAccount = pClient->GetAccount ();
if ( pAccount )
{
// Grab the username
strObject = pAccount->GetName ();
eObjectType = CAccessControlListGroupObject::OBJECT_TYPE_USER;
}
}
}
else
{
// Extract the object name itself including the type
const char * szName = CAccessControlListManager::ExtractObjectName ( strObject.c_str (), eObjectType );
strObject = szName ? szName : "";
}
// Got a string?
if ( !strObject.empty () )
{
// Extract the right name itself including the type
CAccessControlListRight::ERightType eRightType;
strRightName = CAccessControlListManager::ExtractRightName ( strRightName, eRightType );
// Did we get a right name without the prefix?
if ( strRightName )
{
bool bHasPermission = m_pACLManager->CanObjectUseRight ( strObject, eObjectType, strRightName, eRightType, bDefault );
// Return whether we had access or not
lua_pushboolean ( luaVM, bHasPermission );
return 1;
}
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
// Failed
lua_pushnil ( luaVM );
return 1;
}
示例2: hasObjectPermissionTo
int CLuaACLDefs::hasObjectPermissionTo ( lua_State* luaVM )
{
// What object name we're going to check
CAccessControlListGroupObject::EObjectType eObjectType;
std::string strObject;
// Got a pointer argument?
if ( lua_type ( luaVM, 1 ) == LUA_TLIGHTUSERDATA )
{
// Grab it
CResource* pResource = lua_toresource ( luaVM, 1 );
CElement* pElement = lua_toelement ( luaVM, 1 );
// Is it a valid resource?
if ( pResource )
{
// Grab the resource's name
strObject = pResource->GetName ();
eObjectType = CAccessControlListGroupObject::OBJECT_TYPE_RESOURCE;
}
// Is this a valid element?
else if ( pElement )
{
// Grab the client this player/console/whatever is
CClient* pClient = pElement->GetClient ();
if ( pClient )
{
// Get his account
CAccount* pAccount = pClient->GetAccount ();
if ( pAccount )
{
// Grab the username
strObject = pAccount->GetName ();
eObjectType = CAccessControlListGroupObject::OBJECT_TYPE_USER;
}
}
}
}
// Got a string argument?
else if ( lua_type ( luaVM, 1 ) == LUA_TSTRING )
{
// Change the pointer to point to our argument
strObject = lua_tostring ( luaVM, 1 );
// Extract the object name itself including the type
const char * szName = CAccessControlListManager::ExtractObjectName ( strObject.c_str (), eObjectType );
strObject = szName ? szName : "";
}
// Got a string?
if ( !strObject.empty () )
{
// Got a string with the action to check for permission?
if ( lua_type ( luaVM, 2 ) == LUA_TSTRING )
{
// Grab the right name we should've gotten passed
const char* szRightName = lua_tostring ( luaVM, 2 );
// Extract the right name itself including the type
CAccessControlListRight::ERightType eRightType;
szRightName = CAccessControlListManager::ExtractRightName ( szRightName, eRightType );
// Did we get a right name without the prefix?
if ( szRightName )
{
// Third argument to specify what the return defaults to.
// This is if no ACL could be found.
bool bDefault = true;
if ( lua_type ( luaVM, 3 ) == LUA_TBOOLEAN )
{
bDefault = lua_toboolean ( luaVM, 3 ) ? true:false;
}
// Check whether he has permissions to do that
bool bHasPermission = m_pACLManager->CanObjectUseRight ( strObject.c_str (),
eObjectType,
szRightName,
eRightType,
bDefault );
// Return whether we had access or not
lua_pushboolean ( luaVM, bHasPermission );
return 1;
}
else
m_pScriptDebugging->LogBadType ( luaVM, "hasObjectPermissionTo" );
}
else
m_pScriptDebugging->LogBadType ( luaVM, "hasObjectPermissionTo" );
}
else
m_pScriptDebugging->LogBadType ( luaVM, "hasObjectPermissionTo" );
// Failed
lua_pushnil ( luaVM );
return 1;
}