コード例 #1
0
ファイル: inventory.cpp プロジェクト: astrellon/GPP
	bool Inventory::findSpotFor(const Item *item, int &x, int &y) const
	{
		bool found = false;
		for (int j = 0; j < mSpacesY; j++)
		{
			int jOffset = j * mSpacesX;
			for (int i = 0; i < mSpacesX; i++)
			{
				if (mSpotMap[i + jOffset] != NULL)
				{
					continue;
				}

				if (hasSpaceFor(item, i, j))
				{
					x = i;
					y = j;
					found = true;
					break;
				}
			}
			if (found)
			{
				break;
			}
		}
		return found;
	}
コード例 #2
0
ファイル: MESegment.cpp プロジェクト: cbrafter/sumo
bool
MESegment::initialise(MEVehicle* veh, SUMOTime time) {
    if (hasSpaceFor(veh, time, true)) {
        receive(veh, time, true);
        // we can check only after insertion because insertion may change the route via devices
        std::string msg;
        if (MSGlobals::gCheckRoutes && !veh->hasValidRoute(msg)) {
            throw ProcessError("Vehicle '" + veh->getID() + "' has no valid route. " + msg);
        }
        return true;
    }
    return false;
}
コード例 #3
0
ファイル: inventory.cpp プロジェクト: astrellon/GPP
	bool Inventory::addItem(Item *item, int x, int y)
	{
		if (item == NULL)
		{
			return false;
		}
		if (hasItem(item))
		{
			return true;
		}
		if (hasSpaceFor(item, x, y))
		{
			placeItem(item, x, y);

			return true;
		}
		return false;
	}