ScriptFactory.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. ** Command & Conquer Renegade(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. * FILE
  21. *
  22. * DESCRIPTION
  23. *
  24. * PROGRAMMER
  25. * Denzil E. Long, Jr.
  26. *
  27. * VERSION INFO
  28. * $Author: Byon_g $
  29. * $Revision: 4 $
  30. * $Modtime: 8/16/00 11:58a $
  31. * $Archive: /Commando/Code/Scripts/ScriptFactory.cpp $
  32. *
  33. ******************************************************************************/
  34. #include "scriptfactory.h"
  35. #include "scriptregistrar.h"
  36. #include "scripts.h"
  37. #include "dprint.h"
  38. #include <string.h>
  39. /******************************************************************************
  40. *
  41. * NAME
  42. * ScriptFactory::ScriptFactory
  43. *
  44. * DESCRIPTION
  45. * ScriptFactory constructor
  46. *
  47. * INPUTS
  48. * Name - Script name.
  49. * Parameters - Parameter description string.
  50. *
  51. * RESULTS
  52. * NONE
  53. *
  54. ******************************************************************************/
  55. ScriptFactory::ScriptFactory(const char* name, const char* param)
  56. : mNext(NULL)
  57. {
  58. // Save script name
  59. assert(name != NULL);
  60. ScriptName = name;
  61. // Save parameter description
  62. assert(param != NULL);
  63. ParamDescription = param;
  64. // Register this factory with the registrar
  65. ScriptRegistrar::RegisterScript(this);
  66. }
  67. /******************************************************************************
  68. *
  69. * NAME
  70. * ScriptFactory::~ScriptFactory
  71. *
  72. * DESCRIPTION
  73. * ScriptFactory destructor
  74. *
  75. * INPUTS
  76. * NONE
  77. *
  78. * RESULTS
  79. * NONE
  80. *
  81. ******************************************************************************/
  82. ScriptFactory::~ScriptFactory()
  83. {
  84. // Remove this factory from the registrar
  85. ScriptRegistrar::UnregisterScript(this);
  86. ScriptName = NULL;
  87. ParamDescription = NULL;
  88. }
  89. /******************************************************************************
  90. *
  91. * NAME
  92. * ScriptFactory::GetNext
  93. *
  94. * DESCRIPTION
  95. * Retrieve next script factory.
  96. *
  97. * INPUTS
  98. * NONE
  99. *
  100. * RESULTS
  101. * ScriptFactory*
  102. *
  103. ******************************************************************************/
  104. ScriptFactory* ScriptFactory::GetNext(void) const
  105. {
  106. return mNext;
  107. }
  108. /******************************************************************************
  109. *
  110. * NAME
  111. * ScriptFactory::SetNext
  112. *
  113. * DESCRIPTION
  114. * Set next script factory.
  115. *
  116. * INPUTS
  117. * ScriptFactory* link
  118. *
  119. * RESULTS
  120. * NONE
  121. *
  122. ******************************************************************************/
  123. void ScriptFactory::SetNext(ScriptFactory* link)
  124. {
  125. if (mNext != NULL) {
  126. assert(link != NULL);
  127. link->SetNext(mNext);
  128. }
  129. mNext = link;
  130. }
  131. /******************************************************************************
  132. *
  133. * NAME
  134. * ScriptFactory::GetName
  135. *
  136. * DESCRIPTION
  137. * Retrieve the name.
  138. *
  139. * INPUTS
  140. * NONE
  141. *
  142. * RESULTS
  143. * Name - Name of script.
  144. *
  145. ******************************************************************************/
  146. const char* ScriptFactory::GetName(void)
  147. {
  148. return ScriptName;
  149. }
  150. /******************************************************************************
  151. *
  152. * NAME
  153. * ScriptFactory::GetParamDescription
  154. *
  155. * DESCRIPTION
  156. * Retrieve the parameter description.
  157. *
  158. * INPUTS
  159. * NONE
  160. *
  161. * RESULTS
  162. * Parameters - Parameter description string.
  163. *
  164. ******************************************************************************/
  165. const char* ScriptFactory::GetParamDescription(void)
  166. {
  167. return ParamDescription;
  168. }