예제 #1
0
void Faction::Uninit()
{
	for (FactionIterator it = s_factions.begin(); it != s_factions.end(); ++it) {
		delete *it;
	}
	s_factions.clear();
	s_factions_byName.clear();
}
예제 #2
0
void CharSheetManager::_processFactionRequest(Message* message,DispatchClient* client)
{
    PlayerObject* player = gWorldManager->getPlayerByAccId(client->getAccountId());

    if(player == NULL)
    {
        DLOG(info) << "CharSheetManager::_processFactionRequest: could not find player " << client->getAccountId();
        return;
    }

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(opFactionResponseMessage);
    gMessageFactory->addString(player->getFaction());
    gMessageFactory->addUint32(player->getFactionPointsByFactionId(2));
    gMessageFactory->addUint32(player->getFactionPointsByFactionId(3));
    gMessageFactory->addUint32(0);

    FactionList* factions = player->getFactionList();

    gMessageFactory->addUint32(factions->size());

    FactionList::iterator it = factions->begin();

    while(it != factions->end())
    {
        gMessageFactory->addString(mvFactions[(*it).first - 1]);
        ++it;
    }

    gMessageFactory->addUint32(factions->size());

    it = factions->begin();

    while(it != factions->end())
    {
        gMessageFactory->addFloat((float)((*it).second));
        ++it;
    }

    Message* newMessage = gMessageFactory->EndMessage();

    client->SendChannelA(newMessage,client->getAccountId(),CR_Client,6);
}
예제 #3
0
Faction* Faction::GetNearestFaction(const Sector sec, Uint32 sysIndex)
{
	/* firstly if this a custom StarSystem it may already have a faction assigned
	*/
	if (sec.m_systems[sysIndex].customSys && sec.m_systems[sysIndex].customSys->faction) {
		return sec.m_systems[sysIndex].customSys->faction;
	}

	/* if it didn't, or it wasn't a custom StarStystem, then we go ahead and assign it a faction allegiance like normal below...
	*/
	Faction*    result             = &s_no_faction;
	double      closestFactionDist = HUGE_VAL;
	FactionList candidates         = s_spatial_index.CandidateFactions(sec, sysIndex);

	for (FactionIterator it = candidates.begin(); it != candidates.end(); ++it) {
		if ((*it)->IsCloserAndContains(closestFactionDist, sec, sysIndex)) result = *it;
	}
	return result;
}