1 // _________ __ __ 2 // / _____// |_____________ _/ |______ ____ __ __ ______ 3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 6 // \/ \/ \//_____/ \/ 7 // ______________________ ______________________ 8 // T H E W A R B E G I N S 9 // Stratagus - A free fantasy real time strategy game engine 10 // 11 /**@name pud.h - pudconvert header. */ 12 // 13 // (c) Copyright 2005-2011 by The Stratagus Team and Pali Rohár 14 // 15 // This program is free software; you can redistribute it and/or modify 16 // it under the terms of the GNU General Public License as published by 17 // the Free Software Foundation; only version 2 of the License. 18 // 19 // This program is distributed in the hope that it will be useful, 20 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 // GNU General Public License for more details. 23 // 24 // You should have received a copy of the GNU General Public License 25 // along with this program; if not, write to the Free Software 26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 27 // 02111-1307, USA. 28 29 #ifndef PUD_H 30 #define PUD_H 31 32 #include <zlib.h> 33 #include <vector> 34 35 36 #ifdef _MSC_VER 37 #ifndef PATH_MAX 38 #define PATH_MAX _MAX_PATH 39 #endif 40 #if _MSC_VER >= 1800 41 #define open _open 42 #define read _read 43 #define close _close 44 #endif 45 #endif 46 47 #define PLAYERMAX 16 48 49 enum PlayerTypes { 50 PlayerNeutral = 2, // neutral 51 PlayerNobody, // unused slot 52 PlayerComputer, // computer player 53 PlayerPerson, // human player 54 PlayerRescuePassive, // passive rescue 55 PlayerRescueActive, // active rescue 56 }; 57 58 enum RaceTypes { 59 RaceHuman, 60 RaceOrc, 61 RaceNeutral 62 }; 63 64 enum TilesetTypes { 65 TilesetForest, 66 TilesetWinter, 67 TilesetWasteland, 68 TilesetSwamp 69 }; 70 71 72 73 // unit types, we dont need the whole list 74 enum UnitTypes { 75 UnitHumanOilPlatform = 0x56, 76 UnitOrcOilPlatform, 77 UnitGoldMine = 0x5C, 78 UnitOilPatch, 79 UnitHumanStart, 80 UnitOrcStart 81 }; 82 83 struct UnitData { 84 int X; 85 int Y; 86 int Type; 87 int Player; 88 int Data; 89 }; 90 91 class PudData { 92 public: 93 PudData(); 94 95 bool Parse(const unsigned char *puddata, size_t size); 96 97 void WriteSMP(gzFile smpout, const char *smsname) const; 98 void WriteSMS(gzFile smsout) const; 99 100 private: 101 char Description[32]; 102 103 enum PlayerTypes Players[PLAYERMAX]; 104 enum RaceTypes Races[PLAYERMAX]; 105 106 enum TilesetTypes Tileset; 107 int MapSizeX; 108 int MapSizeY; 109 std::vector<int> Tiles; 110 std::vector<int> Value; 111 112 std::vector<struct UnitData> Units; 113 114 int AiType[PLAYERMAX]; 115 116 int StartGold[PLAYERMAX]; 117 int StartLumber[PLAYERMAX]; 118 int StartOil[PLAYERMAX]; 119 int StartX[PLAYERMAX]; 120 int StartY[PLAYERMAX]; 121 }; 122 123 int PudToStratagus(const unsigned char *puddata, size_t size, const char *name, const char *outdir); 124 125 #endif 126