#ifndef __OD2SRC_MAP_H__ #define __OD2SRC_MAP_H__ 1 /* OD2 - Dune II Clone * * Copyright (C) 2009 Robert Crossfield * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * * $Id$ * */ class cMapCell; enum eTerrain { TERRAIN_SAND = 0, TERRAIN_DUNES = 2, TERRAIN_ROCK = 4, TERRAIN_MOUNTAIN = 6, TERRAIN_SPICE = 8, TERRAIN_SPICELOTS = 9 }; class cMap : public cBase { private: cMapCell *_mapCells[0x1000]; public: cMap(cOD2 *pEngine); ~cMap(); void mapLoad(); // Load the map from the generator void cellSingleAnimAdd(word pMapIndex, uint16_t animIdx); bool isInMapScale(word pMapIndex); word mapFindTile(word pMapIndex, word pArg_2); uint32_t mapColorGet(word pMapIndex); word mapTileTypeGet(word pMapIndex); bool mapTileCheckIfFogWar(word pMapindex); void mapRetile(word pMapIndex); void mapReveal(cHouse *pHouse, UPoint point, word pSight); void mapRevealNear(word pMapIndex); inline cMapCell **mapCellGet(word pMapIndex) { return &_mapCells[ pMapIndex ]; } inline cMapCell **mapCellGet(UPoint p) { p &= 0x3F; return mapCellGet(posToIndex(p)); } inline uint16_t mapIndexFromMapTile(UPoint pos) { word bx = pos.x; bx &= 0xFF00; word ax = pos.y; ax &= 0xFF00; ax >>= 2; ax |= bx >> 8; return ax; } SPoint mapXYCorrect(SPoint pPoint, word pRandMax, bool pAdd80); // mapIndex to Tile centre inline SPoint mapIndexTo(uint16_t mapPos) { SPoint point; point.x = ((mapPos & 0x3F) << 8) | 0x80; point.y = ((mapPos << 2) & 0xFF00) | 0x80; return point; } inline uint16_t mapIndexFrom(SPoint pPoint) { pPoint.x >>= 8; pPoint.y &= 0xFF00; pPoint.y >>= 2; return (pPoint.y | pPoint.x); } // Adjust to centre of tile inline SPoint mapPosAdjustToTileCentre(SPoint pPoint) { pPoint.x &= 0xFF00; pPoint.x += 0x80; pPoint.y &= 0xFF00; pPoint.y += 0x80; return pPoint; } inline UPoint posFromIndex(uint16_t index) { return UPoint(index & 0x3F, (index >> 6) & 0x3F); } // seg012:034C inline uint16_t posToIndex(const UPoint &pos) { return pos.x | (pos.y << 6); } inline uint16_t posXMaxYtoIndex(UPoint p) { // Convert X/Y into MapArray Index p.x &= 0x3f; return posToIndex(p); } cUnit *unitGetByMap(word pMapIndex); cStructure *structureGetByMap(word pMapIndex); word sub_5700A(word pMapIndex, short int pArg_2); word sub_57146(word pMapIndex); word sub_57D26(word pArg_0, word pHouseID); word sub_1D7E0(word pMapIndex1, word pMapIndex2); }; #endif // __OD2SRC_MAP_H__