MapReaderWriterInfo.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  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 3 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, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // MapReaderWriterInfo.h
  24. // Version and interface info for map file writers and reader.
  25. // Author: John Ahlquist, October 2001
  26. #pragma once
  27. #ifndef _MAP_READER_WRITER_INFO_H_
  28. #define _MAP_READER_WRITER_INFO_H_
  29. #define K_HEIGHT_MAP_VERSION_1 1 // Height map cell = 5.0
  30. #define K_HEIGHT_MAP_VERSION_2 2 // Height map cell = 10.0
  31. #define K_HEIGHT_MAP_VERSION_3 3 // Added m_borderSize
  32. #define K_HEIGHT_MAP_VERSION_4 4 // Major rev. See comments at bottom of file.
  33. #define K_BLEND_TILE_VERSION_1 1 // Height map cell = 5.0
  34. #define K_BLEND_TILE_VERSION_2 2 // Height map cell = 10.0
  35. #define K_BLEND_TILE_VERSION_3 3 // Added long diagonal blends.
  36. #define K_BLEND_TILE_VERSION_4 4 // Added custom edge blends.
  37. #define K_BLEND_TILE_VERSION_5 5 // Added custom cliff u/v coordinates.
  38. #define K_BLEND_TILE_VERSION_6 6 // Added extra blend layer for 3 textures in cell.
  39. #define K_BLEND_TILE_VERSION_7 7 // Added flag for painting passable/impassable to cells.
  40. #define K_BLEND_TILE_VERSION_8 8 // Added flag for painting passable/impassable to cells.
  41. #define K_OBJECTS_VERSION_1 1 // no dict
  42. #define K_OBJECTS_VERSION_2 2 // includes dict
  43. #define K_OBJECTS_VERSION_3 3 // includes dict
  44. #define K_MAP_OBJECT_VERSION_1 1
  45. #define K_WAYPOINTS_VERSION_1 1
  46. #define K_PLAYERLIST_VERSION_1 1
  47. #define K_TRIGGERS_VERSION_1 1
  48. #define K_TRIGGERS_VERSION_2 2 // Added m_isWaterArea
  49. #define K_TRIGGERS_VERSION_3 3 // Added m_isRiver & m_riverStart
  50. #define K_TRIGGERS_VERSION_4 4 // Added layer name.
  51. #define K_LIGHTING_VERSION_1 1
  52. #define K_LIGHTING_VERSION_2 2 // Added 2 additional global lights for objects.
  53. #define K_LIGHTING_VERSION_3 3 // Added 2 additional global lights for terrain.
  54. #define K_WORLDDICT_VERSION_1 1
  55. #define K_MAPPREVIEW_VERSION_1 1
  56. /** Virtual helper class, so that we can write map data using FILE* or CFile. */
  57. class OutputStream {
  58. public:
  59. virtual Int write(const void *pData, Int numBytes) = 0;
  60. };
  61. /** Virtual helper class, so that we can read in tile and map data from a
  62. variety of sources, such as FILE* or CFile. */
  63. class InputStream {
  64. public:
  65. virtual Int read(void *pData, Int numBytes) = 0;
  66. };
  67. /** Virtual helper class, so that we can read in tile and map data from a
  68. variety of sources, such as FILE* or CFile. */
  69. class ChunkInputStream : public InputStream{
  70. public:
  71. virtual Int read(void *pData, Int numBytes) = 0;
  72. virtual UnsignedInt tell(void) = 0;
  73. virtual Bool absoluteSeek(UnsignedInt pos) = 0;
  74. virtual Bool eof(void) = 0;
  75. };
  76. /** An instance of InputStream that uses a FILE* to read data. */
  77. class CachedFileInputStream : public ChunkInputStream
  78. {
  79. protected:
  80. int m_size;
  81. char* m_buffer;
  82. int m_pos;
  83. public:
  84. CachedFileInputStream(void);
  85. ~CachedFileInputStream(void);
  86. Bool open(AsciiString path); ///< Returns true if open succeeded.
  87. void close(void); ///< Explict close. Destructor closes if file is left open.
  88. virtual Int read(void *pData, Int numBytes);
  89. virtual UnsignedInt tell(void);
  90. virtual Bool absoluteSeek(UnsignedInt pos);
  91. virtual Bool eof(void);
  92. void rewind(void);
  93. };
  94. /** An instance of InputStream that uses a FILE* to read data. */
  95. /* Always using Cached version, as that lets us do compression, etc easily
  96. class FileInputStream : public ChunkInputStream
  97. {
  98. protected:
  99. File *m_file;
  100. public:
  101. FileInputStream(void);
  102. ~FileInputStream(void);
  103. Bool open(AsciiString path); ///< Returns true if open succeeded.
  104. void close(void); ///< Explict close. Destructor closes if file is left open.
  105. virtual Int read(void *pData, Int numBytes);
  106. virtual UnsignedInt tell(void);
  107. virtual Bool absoluteSeek(UnsignedInt pos);
  108. virtual Bool eof(void);
  109. void rewind(void);
  110. };
  111. */
  112. #endif // _MAP_READER_WRITER_INFO_H_
  113. /*
  114. rev K_HEIGHT_MAP_VERSION_4
  115. This is a major rev of the heightmap chunk. Here's the basic overview of what has happened:
  116. We now support multiple boundary areas. They are stored in a vector of ICoord2Ds. The lower-
  117. left corner is always (0,0), and the ICoord2D specifies the top-right coordinate.
  118. The boundary also contains a name.
  119. */