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; }
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; }
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; }