Exemple #1
0
//======================================================================================================================
// Leader choosen a new master looter
void GroupManager::_processGroupLootMasterResponse(Message* message, DispatchClient* client)
{
    gLogger->log(LogManager::DEBUG,"_processGroupLootMasterResponse");

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


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

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

    if(targetPlayer->getGroupMemberIndex() == 0xFFFF)
    {
        // target hasnt accepted the invite yet
        return;
    }

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

    if(group == NULL)
    {
        gChatMessageLib->sendSystemMessage(player, L"@group:disbanded");
        gChatMessageLib->sendIsmGroupCREO6deltaGroupId(0,player);
        return;
    }

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

    if(targetPlayer->getCharId() == group->getMasterLooter())
    {
        // no change needed
        return;
    }

    group->changeMasterLooter(targetPlayer);
    gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("set_new_master_looter"), NULL, group);
}
Exemple #2
0
void GroupManager::_processIsmIsGroupLeaderRequest(Message* message, DispatchClient* client)
{
    uint64 requestId = message->getUint64();
    uint64 playerId = message->getUint64();
    uint64 groupId	= message->getUint64();

    GroupObject* group = this->getGroupById(groupId);

    if(!group)
    {
        gLogger->log(LogManager::DEBUG,"GroupManager::_processIsmIsGroupLeaderRequest: Couldnt find group with id %I64u; player %I64u",groupId,playerId);
    }

    gChatMessageLib->sendIsmIsGroupLeaderResponse(group->getLeader(), requestId, (group->getLeader()->getCharId() == playerId));
}
int LuaCreatureObject::getGroupSize(lua_State* L) {
    Locker locker(realObject);

    GroupObject* group = realObject->getGroup();

    if (group == NULL) {
        lua_pushnumber(L, 0);
        return 1;
    }

    Locker lock(group, realObject);

    lua_pushnumber(L, group->getGroupSize());

    return 1;
}
int LuaCreatureObject::sendGroupMessage(lua_State* L) {
    String value = lua_tostring(L, -1);

    if (realObject == NULL)
        return 0;

    if (!realObject->isGrouped()) {
        realObject->sendSystemMessage(value);
    } else {
        GroupObject* group = realObject->getGroup();

        group->sendSystemMessage(value);
    }

    return 0;
}
int DeclarativeGroupManager::createOutgoingMessageEvent(int groupId, const QString &localUid,
                                                        const QString &remoteUid, const QString &text)
{
    if (groupId < 0) {
        // Try to find an appropriate group
        GroupObject *group = findGroup(localUid, remoteUid);
        if (group) {
            groupId = group->id();
        } else {
            Group g;
            g.setLocalUid(localUid);
            g.setRemoteUids(QStringList() << remoteUid);
            g.setChatType(Group::ChatTypeP2P);
            DEBUG() << Q_FUNC_INFO << "Creating group for" << localUid << remoteUid;
            if (!addGroup(g)) {
                qWarning() << Q_FUNC_INFO << "Failed creating group";
                return -1;
            }
            groupId = g.id();
        }
    }

    Event event;
    if (localUid.indexOf("/ring/tel/") >= 0)
        event.setType(Event::SMSEvent);
    else
        event.setType(Event::IMEvent);

    event.setDirection(Event::Outbound);
    event.setIsRead(true);
    event.setLocalUid(localUid);
    event.setRemoteUid(remoteUid);
    event.setFreeText(text);
    event.setStartTime(QDateTime::currentDateTime());
    event.setEndTime(event.startTime());
    event.setStatus(Event::SendingStatus);
    event.setGroupId(groupId);

    DEBUG() << Q_FUNC_INFO << groupId << localUid << remoteUid << text;
    EventModel model;
    if (model.addEvent(event))
        return event.id();

    qWarning() << Q_FUNC_INFO << "Failed creating event";
    return -1;
}
void MissionObjectImplementation::updateMissionLocation() {
	if (getMissionObjective() == NULL || getMissionObjective()->getPlayerOwner() == NULL) {
		return;
	}
	CreatureObject* playerCreature = getMissionObjective()->getPlayerOwner().castTo<CreatureObject*>();
	
	ManagedReference<WaypointObject* > waypointToMission = this->waypointToMission;

	if (playerCreature != NULL && waypointToMission != NULL) {
		MissionObjectDeltaMessage3* dmiso3 = new MissionObjectDeltaMessage3(_this.get());
		dmiso3->updateWaypoint(waypointToMission);
		dmiso3->close();

		playerCreature->sendMessage(dmiso3);

		if (playerCreature->isGrouped() && playerCreature->getGroup() != NULL) {
			GroupObject* group = playerCreature->getGroup();
			group->scheduleUpdateNearestMissionForGroup(playerCreature->getPlanetCRC());
		}
	}
}
Exemple #7
0
void GroupManager::_processGroupMakeLeader(Message* message, DispatchClient* client)
{

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


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

    if(targetPlayer ==  player)
    {
        return;
    }

    if(targetPlayer->getGroupMemberIndex() == 0xFFFF)
    {
        // target hasnt accepted the invite yet
        return;
    }

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

    if(group == NULL)
    {
        return;
    }

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

    group->changeLeader(targetPlayer);

}
Exemple #8
0
bool WorldManager::_handleDisconnectUpdate(uint64 callTime,void* ref)
{
    PlayerList::iterator it = mPlayersToRemove.begin();

    while(it != mPlayersToRemove.end())
    {
        PlayerObject* playerObject = (*it);

        // we timed out, so save + remove it
        if(--*(playerObject->getDisconnectTime()) <= 0 && playerObject->isLinkDead())
        {
            // reset link dead state
            playerObject->togglePlayerFlagOff(PlayerFlag_LinkDead);
            playerObject->setConnectionState(PlayerConnState_Destroying);

            // Stop update timers.
            removePlayerMovementUpdateTime(playerObject);

            //remove the player out of his group - if any
            GroupObject* group = gGroupManager->getGroupObject(playerObject->getGroupId());
            if(group)
            {
                group->removePlayer(playerObject->getId());
            }

            //asynch save
            savePlayer(playerObject->getAccountId(),true,WMLogOut_LogOut);

            it = mPlayersToRemove.erase(it);
        }
        else
            ++it;

    }

    return(true);
}
Exemple #9
0
void GroupManager::_processGroupPositionNotification(Message* message, DispatchClient* client)
{

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

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

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

    if(group == NULL)
    {
        return;
    }

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


    group->broadcastPlayerPositionNotification(player);
}
Exemple #10
0
void GroupObjectManager::draw()
{
	if (GroupObjectList.empty())
		return;

	GroupObject *main = GroupObjectList[0];

	int groupsCount = main->getGroupsCount();
	ModelTextureGroup* groups = main->getGroups();

	for (int i = 0; i < groupsCount; i++)
	{
		ModelTextureGroup *group = &groups[i];
		main->beginDrawGroup(group);

		for (vector<GroupObject *>::iterator it = GroupObjectList.begin(); it != GroupObjectList.end(); ++it) 
		{
			if ((*it)->visible)
				(*it)->draw(group);
		}

		main->endDrawGroup(group);
	}
}
void GroupMissionCriticalObjectsBuilderNamespace::updateGroupMissionCriticalObjects(GroupObject const & groupObject, CreatureObject::GroupMissionCriticalObjectSet const & groupMissionCriticalObjects)
{
	GroupObject::GroupMemberVector const & groupMemberVector = groupObject.getGroupMembers();
	for (GroupObject::GroupMemberVector::const_iterator groupMemberVectorIter = groupMemberVector.begin(); groupMemberVectorIter != groupMemberVector.end(); ++groupMemberVectorIter)
	{
		Object * const object = NetworkIdManager::getObjectById(groupMemberVectorIter->first);
		if (!object)
			continue;

		ServerObject * serverObject = object->asServerObject();
		if (!serverObject)
			continue;

		CreatureObject * const creatureObject = serverObject->asCreatureObject();
		if (!creatureObject)
			continue;

		updateGroupMissionCriticalObjects(*creatureObject, groupMissionCriticalObjects);
	}
}
Exemple #12
0
void GroupManager::_processIsmInviteInRangeResponse(Message* message, DispatchClient* client)
{
    Player* player			= gChatManager->getPlayerByAccId(message->getUint32());
    Player* targetPlayer	= gChatManager->getPlayerByAccId(message->getUint32());
    uint8	inRange			= message->getUint8();

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

    // If we are not in range, inform the player and return.
    if(!inRange)
    {
        gChatMessageLib->sendSystemMessage(player, L"@error_message:error_invite_ran");
        return;
    }

    // I must be the group leader and group not full before we bother checking target...
    GroupObject* group = NULL;
    uint64 groupId = player->getGroupId();

    if (groupId != 0)
    {
        group = getGroupById(player->getGroupId());
        if (group == NULL)
        {
            return;
        }
        // Sender in group.

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

        // is it full?
        if(group->getMemberCount() >= 20)
        {
            gChatMessageLib->sendSystemMessage(group->getLeader(),L"@group:full");
            return;
        }
    }

    // If target have me ignored, auto decline my invitation.
    BString ignoreName = player->getName();
    ignoreName.toLower();

    // check our ignorelist
    if (targetPlayer->checkIgnore(ignoreName.getCrc()))
    {
        gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("decline_leader"), player, NULL);
        return;
    }


    // if target is member of a group already
    if(targetPlayer->getGroupId() != 0 && targetPlayer->getGroupMemberIndex() != 0xFFFF)
    {
        if(targetPlayer->getGroupId() == groupId)
        {
            gChatMessageLib->sendSystemMessage(player,L"This player is already in your group.");
        }
        else
        {
            gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("already_grouped"), player, NULL);
        }
        return;
    }


    // if target in group and is considering to join a group
    if ((targetPlayer->getGroupMemberIndex() == 0xFFFF) && (targetPlayer->getGroupId() != 0))
    {
        // considering to join your group
        if(targetPlayer->getGroupId() == player->getGroupId())
        {
            gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("considering_your_group"), player, NULL);
        }

        // considering to join another group
        else
        {
            gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("considering_other_group"), player, NULL);
        }
        return;
    }


    // the sender is not in a group, lets create a new one
    // and insert it in the group map
    if (groupId == 0)
    {
        groupId = this->getNextGroupId();
        group = new GroupObject(player, groupId);
        mGroups.insert(std::make_pair(groupId, group));
    }

    // add the target player as temp member
    group->addTempMember(targetPlayer);

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

    // tell the zone to display the invite box
    gChatMessageLib->sendIsmInviteRequest(player, targetPlayer);

}
Exemple #13
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);
}
ConversationScreen* PetTrainingScreenHandler::handleScreen(CreatureObject* conversingPlayer, CreatureObject* conversingNPC, int selectedOption, ConversationScreen* conversationScreen) {

	ManagedReference<PetControlDevice*> controller = conversingNPC->getControlDevice().get().castTo<PetControlDevice*>();
	if (controller == NULL) {
		return NULL;
	}

	if (conversationScreen->getScreenID() == "convoscreenpetinfo") {
		if(conversingNPC->isDroidObject()) {
			// we can technically just re-add the 4 options from base hireling
			DroidObject* droid = cast<DroidObject*>(conversingNPC);
			if (droid->getModule("repair_module") != NULL) {
				conversationScreen->addOption("@hireling/hireling:menu_repair_other","pet_repair_command");
			}
		}
	}

	Locker locker(controller);

	if (conversationScreen->getScreenID() == "pet_repair_command") {
		controller->setTrainingCommand(PetManager::REPAIR);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_formation_1_command") {
		controller->setTrainingCommand(PetManager::FORMATION1);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_formation_2_command") {
		controller->setTrainingCommand(PetManager::FORMATION2);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_attack_command") {
		controller->setTrainingCommand(PetManager::ATTACK);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_guard_command") {
		controller->setTrainingCommand(PetManager::GUARD);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_friend_command") {
		controller->setTrainingCommand(PetManager::FRIEND);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_transfer_command") {
		controller->setTrainingCommand(PetManager::TRANSFER);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_clear_patrol_points_command") {
		controller->setTrainingCommand(PetManager::CLEARPATROLPOINTS);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_get_patrol_point_command") {
		controller->setTrainingCommand(PetManager::GETPATROLPOINT);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_patrol_command") {
		controller->setTrainingCommand(PetManager::PATROL);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_stay_command") {
		controller->setTrainingCommand(PetManager::STAY);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_follow_command") {
		controller->setTrainingCommand(PetManager::FOLLOW);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_follow_other_command") {
		controller->setTrainingCommand(PetManager::FOLLOWOTHER);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_group_command") {
		controller->setTrainingCommand(PetManager::GROUP);
		return NULL;
	}
	if (conversationScreen->getScreenID() == "pet_release_command") {
		controller->setTrainingCommand(PetManager::STORE);
		return NULL;
	}

	locker.release();

	if (conversationScreen->getScreenID() == "pet_leave_group_command") {
		GroupObject* g = conversingNPC->getGroup();
		if (g != NULL) {
			g->removeMember(conversingNPC);
		}
		return NULL;
	}


	return conversationScreen;
}
void GroupManager::_processIsmGroupCREO6deltaGroupId(Message* message)
{
	// this packet is sent by the chatserver to update the group_id in the CREO6
	// it concerns the player itself and all the inrange players

	PlayerObject* const player = gWorldManager->getPlayerByAccId(message->getUint32());  // the player whos group_id has changed
	if(player == NULL)
	{
		gLogger->logMsg("GroupManager::_processIsmGroupCREO6deltaGroupId PlayerAccId not found");
		return;
	}
	
	//this makes the player a member of the group
	uint64 id = message->getUint64();

	//did he just leave the group - is the id zero ?
	if(id == 0)
	{
		GroupObject* group = getGroupObject(player->getGroupId());
		if(group != NULL)
		{
			//got it - just remove him from the group
			group->removePlayer(player->getId());

			if(player->getIDPartner() != 0)
			{
				if(PlayerObject* idPartner = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(player->getIDPartner())))
				{
					idPartner->SetImageDesignSession(IDSessionNONE);
					idPartner->setIDPartner(0);
					player->SetImageDesignSession(IDSessionNONE);
					player->setIDPartner(0);
				}

			}

			//if the group is now empty we need to delete it
			Uint64List* groupList = group->getPlayerList();
			if(groupList->size() == 0)
			{
				deleteGroupObject(player->getGroupId());
				delete(group);
			}
		}
	}
	
	player->setGroupId(id);
	
	if(id != 0)
	{
		//check if a group with that Id already exists
		GroupObject* group;
		group = getGroupObject(id);

		if(group != NULL)
		{
			//yes - just add the player
			group->addPlayer(player->getId());
		}
		else
		{
			//add a new group
			group = new GroupObject(id);
			addGroupObject(group);
			group->addPlayer(player->getId());
		}
	}

	// to in-range folks
	const PlayerObjectSet*	const inRangePlayers	= player->getKnownPlayers();
	PlayerObjectSet::const_iterator	it				= inRangePlayers->begin();
	
	while(it != inRangePlayers->end())
	{
		const PlayerObject* const targetObject = (*it);

		if(targetObject->isConnected())
		{
			gMessageLib->sendGroupIdUpdateDeltasCreo6(player->getGroupId(),player,targetObject);
		}

		++it;
	}

	// to self
	gMessageLib->sendGroupIdUpdateDeltasCreo6(player->getGroupId(), player, player);

}
Exemple #16
0
QVariant GroupModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid() || index.row() >= d->groups.count()) {
        return QVariant();
    }

    GroupObject *group = d->groups.value(index.row());
    if (!group)
        return QVariant();

    if (role == GroupRole) {
        return QVariant::fromValue(group->toGroup());
    } else if (role == GroupObjectRole) {
        return QVariant::fromValue<QObject*>(group);
    } else if (role == ContactIdsRole) {
        return QVariant::fromValue(group->contactIds());
    } else if (role == WeekdaySectionRole) {
        QDateTime dateTime = group->endTime().toLocalTime();

        // Return the date for the past week, and group all older items together under an
        // arbitrary older date
        const int daysDiff = QDate::currentDate().toJulianDay() - dateTime.date().toJulianDay();
        if (daysDiff < 7)
            return dateTime.date();

        // Arbitrary static date for older items..
        return QDate(2000, 1, 1);
    }

    int column = index.column();
    if (role >= BaseRole) {
        column = role - BaseRole;
        role = Qt::DisplayRole;
    }
    
    if (role != Qt::DisplayRole) {
        return QVariant();
    }

    QVariant var;
    switch (column) {
        case GroupId:
            var = QVariant::fromValue(group->id());
            break;
        case LocalUid:
            var = QVariant::fromValue(group->localUid());
            break;
        case RemoteUids:
            var = QVariant::fromValue(group->remoteUids());
            break;
        case ChatName:
            var = QVariant::fromValue(group->chatName());
            break;
        case EndTime:
            var = QVariant::fromValue(group->endTime());
            break;
        case TotalMessages:
            var = QVariant::fromValue(group->totalMessages());
            break;
        case UnreadMessages:
            var = QVariant::fromValue(group->unreadMessages());
            break;
        case SentMessages:
            var = QVariant::fromValue(group->sentMessages());
            break;
        case LastEventId:
            var = QVariant::fromValue(group->lastEventId());
            break;
        case Contacts:
            var = QVariant::fromValue(group->contacts());
            break;
        case LastMessageText:
            var = QVariant::fromValue(group->lastMessageText());
            break;
        case LastVCardFileName:
            var = QVariant::fromValue(group->lastVCardFileName());
            break;
        case LastVCardLabel:
            var = QVariant::fromValue(group->lastVCardLabel());
            break;
        case LastEventType:
            var = QVariant::fromValue((int)group->lastEventType());
            break;
        case LastEventStatus:
            var = QVariant::fromValue((int)group->lastEventStatus());
            break;
        case LastModified:
            var = QVariant::fromValue(group->lastModified());
            break;
        case StartTime:
            var = QVariant::fromValue(group->startTime());
            break;
        default:
            qDebug() << "Group::data: invalid column id??" << column;
            break;
    }

    return var;
}
Exemple #17
0
void GroupManager::joinGroup(CreatureObject* player) {
	//Pre: player locked
	//Post: player locked
	uint64 inviterID = player->getGroupInviterID();

	Zone* zone = player->getZone();

	if (zone == NULL)
		return;

	ManagedReference<ZoneServer*> server = zone->getZoneServer();
	ManagedReference<SceneObject*> object = server->getObject(inviterID);

	if (object == NULL || !object->isPlayerCreature() || object == player)
		return;

	CreatureObject* inviter = cast<CreatureObject*>( object.get());
	GroupObject* group = NULL;

	Locker clocker(inviter, player);

	group = inviter->getGroup();

	if (group == NULL) {
		group = createGroup(inviter);

		if (group == NULL)
			return;
	}

	Locker clocker2(group, player);

	if (group->getGroupSize() >= 20) {
		clocker.release();

		player->updateGroupInviterID(0);

		player->sendSystemMessage("The group is full.");
		return;
	}

	// if inviter IS in the group but is not the leader
	if (group->getLeader() != inviter && !playerIsInvitingOwnPet(inviter, player)) {
		player->updateGroupInviterID(0);
		StringIdChatParameter param("group", "prose_leader_changed"); // "%TU has abdicated group leadership to %TT."
		param.setTU( inviter->getDisplayedName() );
		param.setTT( group->getLeader()->getDisplayedName() ) ;
		player->sendSystemMessage(param);

		return;
    }

	player->info("joining group");

	player->updateGroup(group);
	group->addMember(player);

	if (player->isPlayerCreature()) {
		player->sendSystemMessage("@group:joined_self");

		//Inform new member who the Master Looter is.
		if (group->getLootRule() == MASTERLOOTER) {
			StringIdChatParameter masterLooter("group","set_new_master_looter");
			masterLooter.setTT(group->getMasterLooterID());
			player->sendSystemMessage(masterLooter);
		}

		// clear invitee's LFG setting once a group is joined
		Reference<PlayerObject*> ghost = player->getSlottedObject("ghost").castTo<PlayerObject*>();
		if (ghost != NULL)
			ghost->clearCharacterBit(PlayerObject::LFG, true);

		ManagedReference<ChatRoom*> groupChannel = group->getGroupChannel();

		if (groupChannel != NULL) {
			groupChannel->sendTo(cast<CreatureObject*>(player));
			groupChannel->addPlayer(cast<CreatureObject*>(player), false);
		}

		if (player->isPlayingMusic()) {
			ManagedReference<Facade*> facade = player->getActiveSession(SessionFacadeType::ENTERTAINING);
			ManagedReference<EntertainingSession*> session = dynamic_cast<EntertainingSession*> (facade.get());
			if (session != NULL && session->isPlayingMusic()) {
				String song = session->getPerformanceName();
				String bandSong = group->getBandSong();
				if (bandSong == "") {
					Locker locker(group);

					group->setBandSong(song);
				} else {
					if (bandSong != song) {
						player->sendSystemMessage("@performance:music_join_band_stop"); // You must play the same song as the band.
						session->stopPlayingMusic();
					} else {
						player->sendSystemMessage("@performance:music_join_band_self"); // You join with the band in the currently playing song.
					}
				}
			}
		}
	}

	player->updateGroupInviterID(0);
}