BASE.H 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: F:\projects\c&c\vcs\code\base.h_v 1.12 16 Oct 1995 16:46:38 JOE_BOSTIC $ */
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : BASE.H *
  22. * *
  23. * Programmer : Bill Randolph *
  24. * *
  25. * Start Date : 03/27/95 *
  26. * *
  27. * Last Update : March 27, 1995 *
  28. * *
  29. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  30. #ifndef BASE_H
  31. #define BASE_H
  32. /****************************************************************************
  33. ** This class defines one "node" in the pre-built base list. Each node
  34. ** contains a type of building to build, and the COORD to build it at.
  35. */
  36. class BaseNodeClass
  37. {
  38. public:
  39. BaseNodeClass(void) {};
  40. int operator == (BaseNodeClass const & node);
  41. int operator != (BaseNodeClass const & node);
  42. int operator > (BaseNodeClass const & node);
  43. StructType Type;
  44. COORDINATE Coord;
  45. };
  46. /****************************************************************************
  47. ** This is the class that defines a pre-built base for the computer AI.
  48. ** (Despite its name, this is NOT the "base" class for C&C's class hierarchy!)
  49. */
  50. class BaseClass
  51. {
  52. public:
  53. /**********************************************************************
  54. ** Constructor/Destructor
  55. */
  56. BaseClass(void) {};
  57. virtual ~BaseClass() {Nodes.Clear();}
  58. /**********************************************************************
  59. ** Initialization
  60. */
  61. void Init(void) {Nodes.Clear();}
  62. /**********************************************************************
  63. ** The standard suite of load/save support routines
  64. */
  65. void Read_INI(char *buffer);
  66. void Write_INI(char *buffer);
  67. static char *INI_Name(void) {return "Base";}
  68. bool Load(FileClass & file);
  69. bool Save(FileClass & file);
  70. virtual void Code_Pointers(void) {};
  71. virtual void Decode_Pointers(void) {};
  72. /**********************************************************************
  73. ** Tells if the given node has been built or not
  74. */
  75. bool Is_Built(int index);
  76. /**********************************************************************
  77. ** Returns a pointer to the object for the given node
  78. */
  79. BuildingClass * Get_Building(int index);
  80. /**********************************************************************
  81. ** Tells if the given building ptr is a node in this base's list.
  82. */
  83. bool Is_Node (BuildingClass *obj);
  84. /**********************************************************************
  85. ** Returns a pointer to the requested node.
  86. */
  87. BaseNodeClass * Get_Node(BuildingClass *obj);
  88. BaseNodeClass * Get_Node(int index) { return (&Nodes[index]); }
  89. /**********************************************************************
  90. ** Returns a pointer to the next "hole" in the Nodes list.
  91. */
  92. BaseNodeClass * Next_Buildable(StructType type = STRUCT_NONE);
  93. /**********************************************************************
  94. ** This is the list of "nodes" that define the base. Portions of this
  95. ** list can be pre-built by simply saving those buildings in the INI
  96. ** along with non-base buildings, so Is_Built will return true for them.
  97. */
  98. DynamicVectorClass<BaseNodeClass> Nodes;
  99. /**********************************************************************
  100. ** This is the house this base belongs to.
  101. */
  102. HousesType House;
  103. };
  104. #endif