Esempio n. 1
0
void Grid::removeRaceCheckpoint(const Item::SharedRaceCheckpoint &raceCheckpoint, bool reassign)
{
    bool found = false;
    if (raceCheckpoint->cell)
    {
        boost::unordered_map<CellID, SharedCell>::iterator c = cells.find(raceCheckpoint->cell->cellID);
        if (c != cells.end())
        {
            boost::unordered_map<int, Item::SharedRaceCheckpoint>::iterator r = c->second->raceCheckpoints.find(raceCheckpoint->raceCheckpointID);
            if (r != c->second->raceCheckpoints.end())
            {
                c->second->raceCheckpoints.quick_erase(r);
                eraseCellIfEmpty(c->second);
                found = true;
            }
        }
    }
    else
    {
        boost::unordered_map<int, Item::SharedRaceCheckpoint>::iterator r = globalCell->raceCheckpoints.find(raceCheckpoint->raceCheckpointID);
        if (r != globalCell->raceCheckpoints.end())
        {
            globalCell->raceCheckpoints.quick_erase(r);
            found = true;
        }
    }
    if (found)
    {
        if (reassign)
        {
            addRaceCheckpoint(raceCheckpoint);
        }
    }
}
Esempio n. 2
0
void Grid::removePickup(const Item::SharedPickup &pickup, bool reassign)
{
    bool found = false;
    if (pickup->cell)
    {
        boost::unordered_map<CellID, SharedCell>::iterator c = cells.find(pickup->cell->cellID);
        if (c != cells.end())
        {
            boost::unordered_map<int, Item::SharedPickup>::iterator p = c->second->pickups.find(pickup->pickupID);
            if (p != c->second->pickups.end())
            {
                c->second->pickups.quick_erase(p);
                eraseCellIfEmpty(c->second);
                found = true;
            }
        }
    }
    else
    {
        boost::unordered_map<int, Item::SharedPickup>::iterator p = globalCell->pickups.find(pickup->pickupID);
        if (p != globalCell->pickups.end())
        {
            globalCell->pickups.quick_erase(p);
            found = true;
        }
    }
    if (found)
    {
        if (reassign)
        {
            addPickup(pickup);
        }
    }
}
Esempio n. 3
0
void Grid::removeMapIcon(const Item::SharedMapIcon &mapIcon, bool reassign)
{
    bool found = false;
    if (mapIcon->cell)
    {
        boost::unordered_map<CellID, SharedCell>::iterator c = cells.find(mapIcon->cell->cellID);
        if (c != cells.end())
        {
            boost::unordered_map<int, Item::SharedMapIcon>::iterator m = c->second->mapIcons.find(mapIcon->mapIconID);
            if (m != c->second->mapIcons.end())
            {
                c->second->mapIcons.quick_erase(m);
                eraseCellIfEmpty(c->second);
                found = true;
            }
        }
    }
    else
    {
        boost::unordered_map<int, Item::SharedMapIcon>::iterator m = globalCell->mapIcons.find(mapIcon->mapIconID);
        if (m != globalCell->mapIcons.end())
        {
            globalCell->mapIcons.quick_erase(m);
            found = true;
        }
    }
    if (found)
    {
        if (reassign)
        {
            addMapIcon(mapIcon);
        }
    }
}
Esempio n. 4
0
void Grid::removeObject(const Item::SharedObject &object, bool reassign)
{
    bool found = false;
    if (object->cell)
    {
        boost::unordered_map<CellID, SharedCell>::iterator c = cells.find(object->cell->cellID);
        if (c != cells.end())
        {
            boost::unordered_map<int, Item::SharedObject>::iterator o = c->second->objects.find(object->objectID);
            if (o != c->second->objects.end())
            {
                c->second->objects.quick_erase(o);
                eraseCellIfEmpty(c->second);
                found = true;
            }
        }
    }
    else
    {
        boost::unordered_map<int, Item::SharedObject>::iterator o = globalCell->objects.find(object->objectID);
        if (o != globalCell->objects.end())
        {
            globalCell->objects.quick_erase(o);
            found = true;
        }
    }
    if (found)
    {
        if (reassign)
        {
            addObject(object);
        }
        else
        {
            if (object->attach)
            {
                core->getStreamer()->attachedObjects.erase(object);
            }
            if (object->move)
            {
                core->getStreamer()->movingObjects.erase(object);
            }
        }
    }
}
Esempio n. 5
0
void Grid::removeTextLabel(const Item::SharedTextLabel &textLabel, bool reassign)
{
    bool found = false;
    if (textLabel->cell)
    {
        boost::unordered_map<CellID, SharedCell>::iterator c = cells.find(textLabel->cell->cellID);
        if (c != cells.end())
        {
            boost::unordered_map<int, Item::SharedTextLabel>::iterator t = c->second->textLabels.find(textLabel->textLabelID);
            if (t != c->second->textLabels.end())
            {
                c->second->textLabels.quick_erase(t);
                eraseCellIfEmpty(c->second);
                found = true;
            }
        }
    }
    else
    {
        boost::unordered_map<int, Item::SharedTextLabel>::iterator t = globalCell->textLabels.find(textLabel->textLabelID);
        if (t != globalCell->textLabels.end())
        {
            globalCell->textLabels.quick_erase(t);
            found = true;
        }
    }
    if (found)
    {
        if (reassign)
        {
            addTextLabel(textLabel);
        }
        else
        {
            if (textLabel->attach)
            {
                core->getStreamer()->attachedTextLabels.erase(textLabel);
            }
        }
    }
}
Esempio n. 6
0
void Grid::removeArea(const Item::SharedArea &area, bool reassign)
{
    bool found = false;
    if (area->cell)
    {
        boost::unordered_map<CellID, SharedCell>::iterator c = cells.find(area->cell->cellID);
        if (c != cells.end())
        {
            boost::unordered_map<int, Item::SharedArea>::iterator a = c->second->areas.find(area->areaID);
            if (a != c->second->areas.end())
            {
                c->second->areas.quick_erase(a);
                eraseCellIfEmpty(c->second);
                found = true;
            }
        }
    }
    else
    {
        boost::unordered_map<int, Item::SharedArea>::iterator a = globalCell->areas.find(area->areaID);
        if (a != globalCell->areas.end())
        {
            globalCell->areas.quick_erase(a);
            found = true;
        }
    }
    if (found)
    {
        if (reassign)
        {
            addArea(area);
        }
        else
        {
            if (area->attach)
            {
                core->getStreamer()->attachedAreas.erase(area);
            }
        }
    }
}
Esempio n. 7
0
void Grid::removeAllItems(int type)
{
	boost::unordered_map<CellID, SharedCell> temporaryCells(cells);
	switch (type)
	{
		case STREAMER_TYPE_OBJECT:
		{
			globalCell->objects.clear();
			for (boost::unordered_map<CellID, SharedCell>::iterator c = temporaryCells.begin(); c != temporaryCells.end(); ++c)
			{
				c->second->objects.clear();
				eraseCellIfEmpty(c->second);
			}
			break;
		}
		case STREAMER_TYPE_PICKUP:
		{
			globalCell->pickups.clear();
			for (boost::unordered_map<CellID, SharedCell>::iterator c = temporaryCells.begin(); c != temporaryCells.end(); ++c)
			{
				c->second->pickups.clear();
				eraseCellIfEmpty(c->second);
			}
			break;
		}
		case STREAMER_TYPE_CP:
		{
			globalCell->checkpoints.clear();
			for (boost::unordered_map<CellID, SharedCell>::iterator c = temporaryCells.begin(); c != temporaryCells.end(); ++c)
			{
				c->second->checkpoints.clear();
				eraseCellIfEmpty(c->second);
			}
			break;
		}
		case STREAMER_TYPE_RACE_CP:
		{
			globalCell->raceCheckpoints.clear();
			for (boost::unordered_map<CellID, SharedCell>::iterator c = temporaryCells.begin(); c != temporaryCells.end(); ++c)
			{
				c->second->raceCheckpoints.clear();
				eraseCellIfEmpty(c->second);
			}
			break;
		}
		case STREAMER_TYPE_MAP_ICON:
		{
			globalCell->mapIcons.clear();
			for (boost::unordered_map<CellID, SharedCell>::iterator c = temporaryCells.begin(); c != temporaryCells.end(); ++c)
			{
				c->second->mapIcons.clear();
				eraseCellIfEmpty(c->second);
			}
			break;
		}
		case STREAMER_TYPE_3D_TEXT_LABEL:
		{
			globalCell->textLabels.clear();
			for (boost::unordered_map<CellID, SharedCell>::iterator c = temporaryCells.begin(); c != temporaryCells.end(); ++c)
			{
				c->second->textLabels.clear();
				eraseCellIfEmpty(c->second);
			}
			break;
		}
		case STREAMER_TYPE_AREA:
		{
			globalCell->areas.clear();
			for (boost::unordered_map<CellID, SharedCell>::iterator c = temporaryCells.begin(); c != temporaryCells.end(); ++c)
			{
				c->second->areas.clear();
				eraseCellIfEmpty(c->second);
			}
			break;
		}
	}
}