Exemplo n.º 1
0
void ParallelCollector::finish(const ObjectMap& data) {
	IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
	if (_done) {
		return;
	}
	_result.insert(data.begin(), data.end());
	if (--_count <= 0) {
		notify();
	}
}
Exemplo n.º 2
0
void SetNativePopulationValues(ObjectMap& object_map) {
    for (ObjectMap::iterator<> it = object_map.begin(); it != object_map.end(); ++it) {
        Meter* meter = it->GetMeter(METER_POPULATION);
        Meter* targetmax_meter = it->GetMeter(METER_TARGET_POPULATION);
        // only applies to unowned planets
        if (meter && targetmax_meter && it->Unowned()) {
            double r = RandZeroToOne();
            double factor = (0.1 < r) ? r : 0.1;
            meter->SetCurrent(targetmax_meter->Current() * factor);
        }
    }
}
Exemplo n.º 3
0
void AdapterI::add(Ice::Int category, const ObjectMap& os) {
	if (_cluster <= 0) {
		locate(0)->addObjects(category, os);
	} else {
		map<int, ObjectMap> targets;
		for (ObjectMap::const_iterator it = os.begin(); it != os.end(); ++it) {
			targets[abs(it->first) % _cluster][it->first] = it->second;
		}
		for (map<int, ObjectMap>::iterator it = targets.begin(); it
				!= targets.end(); ++it) {
			locate(it->first)->addObjects(category, it->second);
		}
	}
}
Exemplo n.º 4
0
/*
   void GameMan::Unselect(List* objectList)
   {

   }
   */
void GameMan::Update(float dt)
{
    for(ObjectTypeMap::const_iterator objTypeMap = m_objects.begin(); objTypeMap != m_objects.end(); objTypeMap++)
    {
	ObjectMap ObjMap = (*objTypeMap).second;
	std::stack<uint32_t> eraseStack;
	for(ObjectMap::const_iterator objMap = ObjMap.begin(); objMap != ObjMap.end(); objMap++)
	{
	    ObjectPtr object = objMap->second;
	    if (object->clearObject())
		eraseStack.push(objMap->first);
	    else
		object->update(dt);
	}
	while(!eraseStack.empty())
	{
	    ObjMap.erase(eraseStack.top());
	    eraseStack.pop();
	}
    }
}
Exemplo n.º 5
0
void ObjectRetention::add(const ObjectMap& servants) {
	
	ObjectMap dataChunk[_chunkSize];

	for (ObjectMap::const_iterator it = servants.begin(); it != servants.end(); ++it)
	{
		dataChunk[it->first % _chunkSize].insert(make_pair(it->first, it->second));
	}

	int iRandom = rand() % (int)_chunkSize;

	for(int i =iRandom; i < (int)_chunkSize + iRandom; ++i )
	{
		int j = i % _chunkSize;
		
		if(dataChunk[j].size()>0)
		{
			_chunks.at(j % _chunkSize)->retention->add(dataChunk[j]);
		}
	}

}
Exemplo n.º 6
0
void SetActiveMetersToTargetMaxCurrentValues(ObjectMap& object_map) {
    std::map<MeterType, MeterType> meters;
    meters[METER_POPULATION] =   METER_TARGET_POPULATION;
    meters[METER_INDUSTRY] =     METER_TARGET_INDUSTRY;
    meters[METER_RESEARCH] =     METER_TARGET_RESEARCH;
    meters[METER_TRADE] =        METER_TARGET_TRADE;
    meters[METER_CONSTRUCTION] = METER_TARGET_CONSTRUCTION;
    meters[METER_HAPPINESS] =    METER_TARGET_HAPPINESS;
    meters[METER_FUEL] =         METER_MAX_FUEL;
    meters[METER_SHIELD] =       METER_MAX_SHIELD;
    meters[METER_STRUCTURE] =    METER_MAX_STRUCTURE;
    meters[METER_DEFENSE] =      METER_MAX_DEFENSE;
    meters[METER_TROOPS] =       METER_MAX_TROOPS;
    meters[METER_SUPPLY] =       METER_MAX_SUPPLY;

    // check for each pair of meter types.  if both exist, set active
    // meter current value equal to target meter current value.
    for (ObjectMap::iterator<> it = object_map.begin(); it != object_map.end(); ++it) {
        for (std::map<MeterType, MeterType>::const_iterator meter_it = meters.begin(); meter_it != meters.end(); ++meter_it)
            if (Meter* meter = it->GetMeter(meter_it->first))
                if (Meter* targetmax_meter = it->GetMeter(meter_it->second))
                    meter->SetCurrent(targetmax_meter->Current());
    }
}
Exemplo n.º 7
0
void ObjectEvictor::add(const ObjectMap& servants) {
	for (ObjectMap::const_iterator it = servants.begin(); it != servants.end(); ++it) {
		_chunks.at(it->first % _chunkSize)->evictor->add(it->second, it->first);
	}
}