本文整理汇总了C++中USER::GetRelationType方法的典型用法代码示例。如果您正苦于以下问题:C++ USER::GetRelationType方法的具体用法?C++ USER::GetRelationType怎么用?C++ USER::GetRelationType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USER
的用法示例。
在下文中一共展示了USER::GetRelationType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
//.........这里部分代码省略.........
{
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;
}
// 加入好友名单
_RELATION_USER RUser;
RUser.m_UserGUID = pTargetUser->GetGUID();
RUser.m_RelationType = RELATION_TYPE_FRIEND;
RUser.m_nFriendPoint = 0;
pUser->AddRelation( pTargetUser->GetGUID(), &RUser );
// 传回去在线信息
if ( pRelationPacket->m_Type == REQ_ADDFRIEND )
{
Msg.GetRelation()->m_Type = RET_ADDFRIEND;
}
else if ( pRelationPacket->m_Type == REQ_TEMPFRIEND_TO_FRIEND )
{
Msg.GetRelation()->m_Type = RET_TEMPFRIEND_TO_FRIEND;
}
示例2: Execute
//.........这里部分代码省略.........
//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;
}
}
//如果被邀请的人掉线,则给邀请人返回掉线提示信息
if ( pTargetUser->UserStatus() == US_OFFLINE )
{
uErr = RET_ERR_TARGETNOTEXIST;
Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!",
ReqRelation.GetTargetName() );
break;