Пример #1
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);

			//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);
}
Пример #2
0
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);

}