attribute.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. //////////////////////////////////////////////////////////////////////
  19. //
  20. // ATTRIBUTE.H
  21. //
  22. // Created on 10/03/96 BRH
  23. // Implemented 10/03/96 BRH
  24. //
  25. // 10/03/96 BRH Started this class for use in the Postal
  26. // demo to provide a way to load the attribute
  27. // map and to access the data.
  28. //
  29. // 10/31/96 BRH Changed CAttributeMap to RAttributeMap for the
  30. // new naming convention.
  31. //
  32. // 11/20/96 BRH Changed to new file version now that there are
  33. // detail maps in addition to the block map.
  34. //
  35. // 01/23/97 BRH Changed walkable attribute bit to allow bit
  36. // space for another alpha layer. Changed the
  37. // version number due to this change.
  38. //
  39. // 02/03/97 BRH Added Load(RFile*) in addition to the Load(char*)
  40. //
  41. // 03/13/97 JMI Added ATTRIBUTE_HEIGHT_MASK macro.
  42. //
  43. //////////////////////////////////////////////////////////////////////
  44. #ifndef ATTRIBUTE_H
  45. #define ATTRIBUTE_H
  46. #ifdef PATHS_IN_INCLUDES
  47. #include "BLUE/Blue.h"
  48. #include "ORANGE/File/file.h"
  49. #else
  50. #include "Blue.h"
  51. #include "file.h"
  52. #endif // PATHS_IN_INCLUDES
  53. #define ATTRIBUTE_MAP_COOKIE 0x4d525441 //Looks like "ATRM" in the file
  54. #define ATTRIBUTE_CURRENT_VERSION 5
  55. #define ATTRIBUTE_NOT_WALKABLE 0x2000 // was 0x0800
  56. #define ATTRIBUTE_LIGHT_EFFECT 0x4000
  57. #define ATTRIBUTE_HEIGHT_MASK 0x00FF // Mask of height bits.
  58. //////////////////////////////////////////////////////////////////////
  59. //
  60. // RAttributeMap class
  61. //
  62. // This class makes it easier to load and access attribute maps for
  63. // games. There is a separate utility that converts Photoshop files
  64. // (.PSD) to attribute maps. It looks for a layer called
  65. // "attributes" and reads the R, G and B channels to get the
  66. // attribute data. The attribute bits are set in that utility.
  67. // This class simply returns the values stored in the attribute map
  68. // at different locations. It has functions for returning attributes
  69. // for a single point or an OR mask of all points within a rectangle.
  70. //
  71. //////////////////////////////////////////////////////////////////////
  72. class RAttributeMap
  73. {
  74. public:
  75. long m_lWidth;
  76. long m_lHeight;
  77. long m_lWorldWidth;
  78. long m_lWorldHeight;
  79. short m_sScaleX;
  80. short m_sScaleY;
  81. short m_sNumDetailMaps;
  82. short m_sBlockDataSize;
  83. // General Constructor
  84. RAttributeMap();
  85. // Contstuctor that opens the given map file
  86. RAttributeMap(char* pszFilename);
  87. // General Destructor
  88. ~RAttributeMap();
  89. // Load function - to load a map
  90. short Load(char* pszFilename);
  91. // Load function that takes an open RFile pointer
  92. short Load(RFile* prf);
  93. // Single point attribute
  94. USHORT GetAttribute(long lX, long lY);
  95. // Rectangle attribute
  96. USHORT GetAttribute(long lTop, long lBottom, long lLeft, long lRight);
  97. // Get just the low 8 bits (flags) from the last GetAttribute Call
  98. UCHAR GetFlags()
  99. {return m_ucFlags;};
  100. // Get the maximum height from the last GetAttribute Call
  101. UCHAR GetMaxHeight()
  102. {return m_ucMaxHeight;};
  103. // Get the minimum height from the last GetAttribute Call
  104. UCHAR GetMinHeight()
  105. {return m_ucMinHeight;};
  106. private:
  107. // pointer to map buffer
  108. USHORT* m_pusMap;
  109. // pointer to detail map buffer
  110. USHORT* m_pusDetailMap;
  111. // The attribute stored since the last GetAttribute Call
  112. USHORT m_usLastAttribute;
  113. // The Max height stored since the last GetAttribute Call
  114. UCHAR m_ucMaxHeight;
  115. // The Min height stored since the last GetAttribute Call
  116. UCHAR m_ucMinHeight;
  117. // The flags stored since the last GetAttribute Call
  118. UCHAR m_ucFlags;
  119. // Allocate buffer for map
  120. short AllocateMap(ULONG ulSize, ULONG ulDetailMapSize);
  121. public:
  122. // Deallocate buffer for map
  123. void FreeMap();
  124. };
  125. #endif //ATTRIBUTE_H
  126. //////////////////////////////////////////////////////////////////////
  127. // EOF
  128. //////////////////////////////////////////////////////////////////////