1 /***************************************************************************
2  *   Free Heroes of Might and Magic II: https://github.com/ihhub/fheroes2  *
3  *   Copyright (C) 2020                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 
21 #ifndef AGG_FILE_H
22 #define AGG_FILE_H
23 
24 #include <map>
25 #include <string>
26 #include <vector>
27 
28 #include "serialize.h"
29 
30 namespace fheroes2
31 {
32     class AGGFile
33     {
34     public:
AGGFile()35         AGGFile()
36         {
37             // Avoid C4592 warning in Visual Studio.
38         }
39 
40         bool isGood() const;
41         bool open( const std::string & fileName );
42         std::vector<uint8_t> read( const std::string & fileName );
43 
44     private:
45         static const size_t _maxFilenameSize = 15; // 8.3 ASCIIZ file name + 2-bytes padding
46 
47         StreamFile _stream;
48         std::map<std::string, std::pair<uint32_t, uint32_t> > _files;
49     };
50 
51     struct ICNHeader
52     {
ICNHeaderICNHeader53         ICNHeader()
54             : offsetX( 0 )
55             , offsetY( 0 )
56             , width( 0 )
57             , height( 0 )
58             , animationFrames( 0 )
59             , offsetData( 0 )
60         {}
61 
62         uint16_t offsetX;
63         uint16_t offsetY;
64         uint16_t width;
65         uint16_t height;
66         uint8_t animationFrames; // used for adventure map animations, this can replace ICN::AnimationFrame
67         uint32_t offsetData;
68     };
69 }
70 
71 StreamBase & operator>>( StreamBase & st, fheroes2::ICNHeader & icn );
72 
73 #endif
74