Exemple #1
0
void GroupManager::_processGroupUnInvite(Message* message, DispatchClient* client)
{

    Player* player = gChatManager->getPlayerByAccId(client->getAccountId());

    if(player == NULL)
    {
        gLogger->log(LogManager::DEBUG,"GroupManager::_processGroupUnInvite: player not found");
        return;
    }

    Player* targetPlayer	= gChatManager->getPlayerByAccId(message->getUint32());
    if(targetPlayer== NULL)
    {
        gLogger->log(LogManager::DEBUG,"GroupManager::_processGroupUnInvite: target not found");
        return;
    }

    if(targetPlayer->getGroupMemberIndex() != 0xFFFF)
    {
        // target has already join the group
        return;
    }

    if(player->getGroupId() == 0)
    {
        return;
    }

    if(player->getGroupId() != targetPlayer->getGroupId())
    {
        // not the same group
        return;
    }

    GroupObject* group = getGroupById(player->getGroupId());

    if(group == NULL)
    {
        return;
    }

    if(player != group->getLeader())
    {
        gChatMessageLib->sendSystemMessage(player,L"@group:must_be_leader");
        return;
    }

    group->removeTempMember(targetPlayer);

    gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("uninvite_self"), player, NULL);
    gChatMessageLib->sendGroupSystemMessage(player->getName(), BString("uninvite_target"),targetPlayer, NULL);

}
Exemple #2
0
void GroupManager::_processGroupInviteResponse(Message* message, DispatchClient* client)
{

    Player* player = gChatManager->getPlayerByAccId(client->getAccountId());

    if(player == NULL)
    {
        gLogger->log(LogManager::DEBUG,"GroupManager::_processGroupInviteResponse: player not found");
        return;
    }

    if(player->getGroupId() == 0 || player->getGroupMemberIndex() != 0xFFFF )
    {
        // player hasnt been invited
        gChatMessageLib->sendSystemMessage(player,L"@group:must_be_invited");
        return;
    }

    GroupObject* group = getGroupById(player->getGroupId());

    if(group == NULL)
    {
        // the group has died im the mean time
        // lets tell zone to update groupId of this guy
        // and tell him the group is no more
        gChatMessageLib->sendIsmGroupCREO6deltaGroupId(0,player);
        gChatMessageLib->sendSystemMessage(player, L"@group:disbanded");
        return;
    }


    // if player refuses to join the group
    if(message->getUint8() == 0)
    {
        gChatMessageLib->sendGroupSystemMessage(player->getName(), BString("decline_leader"), group->getLeader(), NULL);
        group->removeTempMember(player);
        return;
    }


    // if accept to join the group
    gChatMessageLib->sendSystemMessage(player, L"@group:joined_self");

    player->setPositionX(message->getFloat());
    player->setPositionZ(message->getFloat());

    // if this is the first member, we have to
    // create objects in leader's client too
    Player *groupLeader = group->getLeader();
    DispatchClient* clientLeader = groupLeader->getClient();

    ChatAvatarId* avatarLeader = NULL;
    if(group->getSize() == 1)
    {
        // create the channel and create the group on leaders'client
        group->createChannel();

        avatarLeader = new ChatAvatarId();
        avatarLeader->setPlayer(group->getLeader());
        avatarLeader->setGalaxy(gChatManager->getGalaxyName());

        group->getChannel()->addUser(avatarLeader);
        group->sendCreate(group->getLeader());
        gChatMessageLib->sendSystemMessage(group->getLeader(), L"@group:formed_self");
    }

    // set the member index of the player
    player->setGroupMemberIndex(group->getSize());

    // advise existing members
    group->broadcastDeltaAdd(player);

    // add the member to the list
    group->addMember(player);

    ChatAvatarId* avatar = new ChatAvatarId();
    avatar->setPlayer(player);
    avatar->setGalaxy(gChatManager->getGalaxyName());

    group->getChannel()->addUser(avatar);

    // create the group on the new client
    group->sendCreate(player);

    // gChatMessageLib->sendChatOnEnteredRoom(client, avatar, group->getChannel(), 0);

    // When we have changed number of members in group, we need to update the client also.
    // right now doing a quick and dirty for two players since not everything is working.

    if (avatarLeader)
    {
        gChatMessageLib->sendChatQueryRoomResults(clientLeader, group->getChannel(), 0);
    }

    gChatMessageLib->sendChatQueryRoomResults(client, group->getChannel(), 0);

    if (avatarLeader)
    {
        gChatMessageLib->sendChatOnEnteredRoom(clientLeader, avatarLeader, group->getChannel(), 0);
    }

    gChatMessageLib->sendChatOnEnteredRoom(client, avatar, group->getChannel(), 0);
}