本文整理汇总了C++中USER::IsCannotAddFriend方法的典型用法代码示例。如果您正苦于以下问题:C++ USER::IsCannotAddFriend方法的具体用法?C++ USER::IsCannotAddFriend怎么用?C++ USER::IsCannotAddFriend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USER
的用法示例。
在下文中一共展示了USER::IsCannotAddFriend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
//.........这里部分代码省略.........
Send.SetGUID( pTargetUser->GetGUID() );
Send.SetName( pTargetUser->GetName() );
// ...
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...View Player: %s!",
pTargetUser->GetName() );
}
break;
case REQ_ADDFRIEND:
case REQ_TEMPFRIEND_TO_FRIEND:
{ // 检查需要添加的好友是否在线,并发回新好友的详细信息,这里不做合法性判断
REQUEST_ADD_RELATION_WITH_GROUP& ReqRelation = pRelationPacket->m_AddRelationWithGroup;
if ( ReqRelation.GetTargetGUID() != INVALID_ID )
{
pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetGUID() );
}
else if ( strlen(ReqRelation.GetTargetName()) > 0 )
{
pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetName() );
}
if ( pTargetUser == NULL )
{ //没有发现在“在线用户列表”里对应此名字的用户
uErr = RET_ERR_TARGETNOTEXIST;
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!",
ReqRelation.GetTargetName() );
Assert( FALSE && "找不到该好友" );
break;
}
// 判断 pTargetUser 是否拒绝被加为好友
if ( pTargetUser->IsCannotAddFriend() )
{
uErr = RET_ERR_CANNOT_ADDFRIEND;
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added!",
ReqRelation.GetTargetName() );
break;
}
if( pUser->IsEnemy( pTargetUser->GetUserCampData() ) )
{
uErr = RET_ERR_ISENEMY;
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s is enemy!",
ReqRelation.GetTargetName() );
break;
}
RELATION_TYPE RelationType = pUser->GetRelationType( pTargetUser->GetGUID() );
if ( RelationType != RELATION_TYPE_NONE )
{
if ( RelationType == RELATION_TYPE_BLACKNAME )
{
uErr = RET_ERR_ISBLACKNAME;
}
else
{
uErr = RET_ERR_ISFRIEND;
}
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added2!",
ReqRelation.GetTargetName() );
break;
示例2: Execute
//.........这里部分代码省略.........
Assert(FALSE);
break;
}
pTServerPlayer->SendPacket( &NotifyMsg );
return PACKET_EXE_CONTINUE;
}
break;
case REQ_ADDFRIEND:
//case REQ_TEMPFRIEND_TO_FRIEND:
{ // 检查需要添加的玩家是否在线,并发回提示被加玩家是否同意加为好友消息
REQUEST_ADD_RELATION_WITH_GROUP& ReqRelation = pRelationPacket->m_AddRelationWithGroup;
if ( ReqRelation.GetTargetGUID() != INVALID_ID )
{
pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetGUID() );
}
else if ( strlen(ReqRelation.GetTargetName()) > 0 )
{
pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetName() );
}
if ( pTargetUser == NULL )
{ //没有发现在“在线用户列表”里对应此名字的用户 (这里注释错了,在玩家正确操作离开游戏后,仍有段时间其他玩家可以通过FindUser()函数获得离开游戏玩家的数据)
uErr = RET_ERR_TARGETNOTEXIST;
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!",
ReqRelation.GetTargetName() );
//Assert( FALSE && "找不到该好友" );
break;
}
// 判断 pTargetUser 是否拒绝被加为好友
if ( pTargetUser->IsCannotAddFriend() )
{
uErr = RET_ERR_CANNOT_ADDFRIEND;
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added!",
ReqRelation.GetTargetName() );
break;
}
RELATION_TYPE RelationType = pUser->GetRelationType( pTargetUser->GetGUID() );
if ( RelationType != RELATION_TYPE_NONE )
{
if (RelationType == RELATION_TYPE_ENEMY)
{
// 如果该玩家是仇人,则也可以加为好友
}
else if ( RelationType == RELATION_TYPE_BLACKNAME )//(temp)判断被邀请为好友的人是否已经被加入黑名单
{
uErr = RET_ERR_ISBLACKNAME;
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added2!",
ReqRelation.GetTargetName() );
break;
}
else
{
uErr = RET_ERR_ISFRIEND;//(temp)如果被邀请的人已经是好友了
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added2!",
ReqRelation.GetTargetName() );
break;
}
}