* Loads an XCom format RMP file into the spawnpoints of the battlegame. * @param mapblock Pointer to MapBlock. * @param xoff Mapblock offset in X direction. * @param yoff Mapblock offset in Y direction. * @param segment Mapblock segment. * @sa http://www.ufopaedia.org/index.php?title=ROUTES */
| 1714 | * @sa http://www.ufopaedia.org/index.php?title=ROUTES |
| 1715 | */ |
| 1716 | void BattlescapeGenerator::loadRMP(MapBlock *mapblock, int xoff, int yoff, int segment) |
| 1717 | { |
| 1718 | int id = 0; |
| 1719 | char value[24]; |
| 1720 | std::ostringstream filename; |
| 1721 | filename << "ROUTES/" << mapblock->getName() << ".RMP"; |
| 1722 | |
| 1723 | // Load file |
| 1724 | std::ifstream mapFile (CrossPlatform::getDataFile(filename.str()).c_str(), std::ios::in| std::ios::binary); |
| 1725 | if (!mapFile) |
| 1726 | { |
| 1727 | throw Exception(filename.str() + " not found"); |
| 1728 | } |
| 1729 | |
| 1730 | size_t nodeOffset = _save->getNodes()->size(); |
| 1731 | |
| 1732 | while (mapFile.read((char*)&value, sizeof(value))) |
| 1733 | { |
| 1734 | if( (int)value[0] < mapblock->getSizeY() && (int)value[1] < mapblock->getSizeX() && (int)value[2] < _mapsize_z ) |
| 1735 | { |
| 1736 | Node *node = new Node(nodeOffset + id, Position(xoff + (int)value[1], yoff + (int)value[0], mapblock->getSizeZ() - 1 - (int)value[2]), segment, (int)value[19], (int)value[20], (int)value[21], (int)value[22], (int)value[23]); |
| 1737 | for (int j=0;j<5;++j) |
| 1738 | { |
| 1739 | int connectID = (int)((signed char)value[4 + j*3]); |
| 1740 | if (connectID > -1) |
| 1741 | { |
| 1742 | connectID += nodeOffset; |
| 1743 | } |
| 1744 | node->getNodeLinks()->push_back(connectID); |
| 1745 | } |
| 1746 | _save->getNodes()->push_back(node); |
| 1747 | } |
| 1748 | id++; |
| 1749 | } |
| 1750 | |
| 1751 | if (!mapFile.eof()) |
| 1752 | { |
| 1753 | throw Exception("Invalid RMP file"); |
| 1754 | } |
| 1755 | |
| 1756 | mapFile.close(); |
| 1757 | } |
| 1758 | |
| 1759 | /** |
| 1760 | * Fill power sources with an elerium-115 object. |
nothing calls this directly
no test coverage detected