// ------------------------------------------------------------------ // Name : getMapCoords // ------------------------------------------------------------------ CoordsMap DisplayEngine::getMapCoords(Coords3D d3Coords) { if (m_iMapWidth == 0 || m_iMapHeight == 0) return CoordsMap(); if (d3Coords.x < 0.0f && d3Coords.x != (double)(int)d3Coords.x) d3Coords.x -= 1.0f; if (d3Coords.y < 0.0f && d3Coords.y != (double)(int)d3Coords.y) d3Coords.y -= 1.0f; CoordsMap mapCoords((int)d3Coords.x + m_iMapWidth/2, (int)d3Coords.y + m_iMapHeight/2); // CoordsMap mapCoords((int)d3Coords.x + m_pServerParams->mapXSize/2, m_pServerParams->mapYSize/2 - (int)d3Coords.y); return mapCoords; }
bool BuildOperation::isBuildAllowed(const MapObjectToBuild& mapObjectToBuild) const { const MapObjectType* mapObjectType = mapObjectToBuild.mapObjectType; const Map* map = context.game->getMap(); unsigned char mapWidth, mapHeight; if (mapObjectToBuild.view == Direction::NORTH || mapObjectToBuild.view == Direction::SOUTH) { mapWidth = mapObjectType->mapWidth; mapHeight = mapObjectType->mapHeight; } else { mapWidth = mapObjectType->mapHeight; mapHeight = mapObjectType->mapWidth; } // Gucken, ob alles frei is for (int y = 0, my = mapObjectToBuild.mapCoords.y(); y < mapHeight; y++, my++) { for (int x = 0, mx = mapObjectToBuild.mapCoords.x(); x < mapWidth; x++, mx++) { MapCoords mapCoords(mx, my); // Passt das Gelände? const MapTile* mapTile = map->getMapTileAt(mapCoords); const MapTileConfig* mapTileConfig = mapTile->getMapTileConfig(); if (((MapTileTypeInt) mapTileConfig->mapTileType & mapObjectType->placeableOnMapTileTypeMask) == 0) { return false; } // Gebiet erschlossen und unseres? if (mapTile->player == nullptr || mapTile->player != &player) { return false; } MapObjectFixed* mapObjectFixedAlreadyThere = map->getMapObjectFixedAt(mapCoords); if (mapObjectFixedAlreadyThere != nullptr) { // Überbauen erlaubt? if (!(mayBuildOver(mapObjectFixedAlreadyThere->getMapObjectType(), mapObjectType))) { return false; } } } } return true; }
int BIDSCloneLayer::updateState(double timef, double dt) { int status = PV_SUCCESS; mapCoords(); return status; }