MapReaderWriterInfo.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. ** Command & Conquer Generals(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_OBJECTS_VERSION_1 1 // no dict
  41. #define K_OBJECTS_VERSION_2 2 // includes dict
  42. #define K_OBJECTS_VERSION_3 3 // includes dict
  43. #define K_MAP_OBJECT_VERSION_1 1
  44. #define K_WAYPOINTS_VERSION_1 1
  45. #define K_PLAYERLIST_VERSION_1 1
  46. #define K_TRIGGERS_VERSION_1 1
  47. #define K_TRIGGERS_VERSION_2 2 // Added m_isWaterArea
  48. #define K_TRIGGERS_VERSION_3 3 // Added m_isRiver & m_riverStart
  49. #define K_LIGHTING_VERSION_1 1
  50. #define K_LIGHTING_VERSION_2 2 // Added 2 additional global lights for objects.
  51. #define K_LIGHTING_VERSION_3 3 // Added 2 additional global lights for terrain.
  52. #define K_WORLDDICT_VERSION_1 1
  53. #define K_MAPPREVIEW_VERSION_1 1
  54. /** Virtual helper class, so that we can write map data using FILE* or CFile. */
  55. class OutputStream {
  56. public:
  57. virtual Int write(const void *pData, Int numBytes) = 0;
  58. };
  59. /** Virtual helper class, so that we can read in tile and map data from a
  60. variety of sources, such as FILE* or CFile. */
  61. class InputStream {
  62. public:
  63. virtual Int read(void *pData, Int numBytes) = 0;
  64. };
  65. /** Virtual helper class, so that we can read in tile and map data from a
  66. variety of sources, such as FILE* or CFile. */
  67. class ChunkInputStream : public InputStream{
  68. public:
  69. virtual Int read(void *pData, Int numBytes) = 0;
  70. virtual UnsignedInt tell(void) = 0;
  71. virtual Bool absoluteSeek(UnsignedInt pos) = 0;
  72. virtual Bool eof(void) = 0;
  73. };
  74. /** An instance of InputStream that uses a FILE* to read data. */
  75. class CachedFileInputStream : public ChunkInputStream
  76. {
  77. protected:
  78. int m_size;
  79. char* m_buffer;
  80. int m_pos;
  81. public:
  82. CachedFileInputStream(void);
  83. ~CachedFileInputStream(void);
  84. Bool open(AsciiString path); ///< Returns true if open succeeded.
  85. void close(void); ///< Explict close. Destructor closes if file is left open.
  86. virtual Int read(void *pData, Int numBytes);
  87. virtual UnsignedInt tell(void);
  88. virtual Bool absoluteSeek(UnsignedInt pos);
  89. virtual Bool eof(void);
  90. void rewind(void);
  91. };
  92. /** An instance of InputStream that uses a FILE* to read data. */
  93. /* Always using Cached version, as that lets us do compression, etc easily
  94. class FileInputStream : public ChunkInputStream
  95. {
  96. protected:
  97. File *m_file;
  98. public:
  99. FileInputStream(void);
  100. ~FileInputStream(void);
  101. Bool open(AsciiString path); ///< Returns true if open succeeded.
  102. void close(void); ///< Explict close. Destructor closes if file is left open.
  103. virtual Int read(void *pData, Int numBytes);
  104. virtual UnsignedInt tell(void);
  105. virtual Bool absoluteSeek(UnsignedInt pos);
  106. virtual Bool eof(void);
  107. void rewind(void);
  108. };
  109. */
  110. #endif // _MAP_READER_WRITER_INFO_H_
  111. /*
  112. rev K_HEIGHT_MAP_VERSION_4
  113. This is a major rev of the heightmap chunk. Here's the basic overview of what has happened:
  114. We now support multiple boundary areas. They are stored in a vector of ICoord2Ds. The lower-
  115. left corner is always (0,0), and the ICoord2D specifies the top-right coordinate.
  116. The boundary also contains a name.
  117. */