buildnum.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/buildnum.cpp $*
  25. * *
  26. * Author:: Steve Tall *
  27. * *
  28. * $Modtime:: 10/29/01 10:06p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "always.h"
  36. #include "buildnum.h"
  37. #include "wwdebug.h"
  38. #include <stdio.h>
  39. #include "win.h"
  40. /*
  41. **
  42. ** This is just a placeholder for the build number.
  43. ** A post build step will stamp the build number into here.
  44. **
  45. */
  46. char BuildInfoClass::BuildNumber [64] = {"Insert1Build2Number3Here4 xxxx "};
  47. char BuildInfoClass::BuildDate [64] = {"Insert1Build2Date3Here4 xxxx "};
  48. /*
  49. ** Unreachable code warning.
  50. */
  51. #pragma warning(disable : 4702)
  52. /***********************************************************************************************
  53. * BuildInfoClass::Get_Build_Number -- Gets the 32 bit build number. *
  54. * *
  55. * *
  56. * *
  57. * INPUT: Nothing *
  58. * *
  59. * OUTPUT: Build number *
  60. * *
  61. * WARNINGS: None *
  62. * *
  63. * HISTORY: *
  64. * 10/29/2001 4:54PM ST : Created *
  65. *=============================================================================================*/
  66. unsigned long BuildInfoClass::Get_Build_Number(void)
  67. {
  68. return (*(unsigned long*)(&BuildNumber[28]));
  69. }
  70. /***********************************************************************************************
  71. * BuildInfoClass::Get_Build_Number_String -- Gets the build number as a human readable string.*
  72. * *
  73. * *
  74. * *
  75. * INPUT: Nothing *
  76. * *
  77. * OUTPUT: Ptr to build number string *
  78. * *
  79. * WARNINGS: None *
  80. * *
  81. * HISTORY: *
  82. * 10/29/2001 4:55PM ST : Created *
  83. *=============================================================================================*/
  84. char *BuildInfoClass::Get_Build_Number_String(void)
  85. {
  86. static char _buffer[16];
  87. sprintf (_buffer, "%d", *(unsigned long*)(&BuildNumber[28]));
  88. return (_buffer);
  89. }
  90. /***********************************************************************************************
  91. * BuildInfoClass::Get_Builder_Name -- Gets the name of the person who built this executable. *
  92. * *
  93. * *
  94. * *
  95. * INPUT: Nothing *
  96. * *
  97. * OUTPUT: Ptr to builder name string *
  98. * *
  99. * WARNINGS: None *
  100. * *
  101. * HISTORY: *
  102. * 10/29/2001 5:08PM ST : Created *
  103. *=============================================================================================*/
  104. char *BuildInfoClass::Get_Builder_Name(void)
  105. {
  106. return(&BuildNumber[32]);
  107. }
  108. /***********************************************************************************************
  109. * BuildInfoClass::Get_Build_Date_String -- Gets the date this executable was built on. *
  110. * *
  111. * *
  112. * *
  113. * INPUT: Nothing *
  114. * *
  115. * OUTPUT: Ptr to build date string *
  116. * *
  117. * WARNINGS: None *
  118. * *
  119. * HISTORY: *
  120. * 10/29/2001 5:10PM ST : Created *
  121. *=============================================================================================*/
  122. char *BuildInfoClass::Get_Build_Date_String(void)
  123. {
  124. static char _buffer[64];
  125. SYSTEMTIME systime;
  126. if (FileTimeToSystemTime ((LPFILETIME)(&BuildDate[28]), &systime) ) {
  127. sprintf(_buffer, "%02d/%02d/%04d - %02d:%02d:%02d", systime.wMonth, systime.wDay, systime.wYear, systime.wHour, systime.wMinute, systime.wSecond);
  128. } else {
  129. _buffer[0] = 0;
  130. }
  131. return(_buffer);
  132. }
  133. /***********************************************************************************************
  134. * BuildInfoClass::Get_Builder_Initials -- Gets the initials of the builder *
  135. * *
  136. * *
  137. * *
  138. * INPUT: Nothing *
  139. * *
  140. * OUTPUT: Ptr to string containing initials *
  141. * *
  142. * WARNINGS: None *
  143. * *
  144. * HISTORY: *
  145. * 10/29/2001 5:12PM ST : Created *
  146. *=============================================================================================*/
  147. char *BuildInfoClass::Get_Builder_Initials(void)
  148. {
  149. static char _buffer[4];
  150. _buffer[0] = BuildNumber[32];
  151. _buffer[1] = 0;
  152. _buffer[2] = 0;
  153. char *lastname = strchr(&BuildNumber[32], '_');
  154. if (lastname) {
  155. _buffer[1] = lastname[1];
  156. }
  157. return (_buffer);
  158. }
  159. /***********************************************************************************************
  160. * BuildInfoClass::Get_Build_Version_String -- Get composite version as string *
  161. * *
  162. * *
  163. * *
  164. * INPUT: Nothing *
  165. * *
  166. * OUTPUT: Version string *
  167. * *
  168. * WARNINGS: None *
  169. * *
  170. * HISTORY: *
  171. * 10/29/2001 7:30PM ST : Created *
  172. *=============================================================================================*/
  173. char *BuildInfoClass::Get_Build_Version_String(void)
  174. {
  175. static char _buffer[128];
  176. sprintf(_buffer, "%s-%s", Get_Builder_Initials(), Get_Build_Number_String());
  177. return(_buffer);
  178. }
  179. /***********************************************************************************************
  180. * BuildInfoClass::Get_Build_Type -- Get the type of build this is *
  181. * *
  182. * *
  183. * *
  184. * INPUT: Nothing *
  185. * *
  186. * OUTPUT: Build type *
  187. * *
  188. * WARNINGS: None *
  189. * *
  190. * HISTORY: *
  191. * 10/29/2001 7:40PM ST : Created *
  192. *=============================================================================================*/
  193. BuildInfoClass::BuildType BuildInfoClass::Get_Build_Type(void)
  194. {
  195. #ifndef _DEBUG
  196. #ifdef WWDEBUG
  197. return(BUILD_PROFILE);
  198. #else //WWDEBUG
  199. return(BUILD_RELEASE);
  200. #endif //WWDEBUG
  201. #else //_DEBUG
  202. return(BUILD_DEBUG);
  203. #endif //_DEBUG
  204. }
  205. /***********************************************************************************************
  206. * BuildInfoClass::Get_Build_Type_String -- Get the build type as a string. *
  207. * *
  208. * *
  209. * *
  210. * INPUT: Nothing *
  211. * *
  212. * OUTPUT: Nothing *
  213. * *
  214. * WARNINGS: None *
  215. * *
  216. * HISTORY: *
  217. * 10/29/2001 7:42PM ST : Created *
  218. *=============================================================================================*/
  219. char *BuildInfoClass::Get_Build_Type_String(void)
  220. {
  221. switch (Get_Build_Type()) {
  222. case BUILD_DEBUG:
  223. return("DEBUG");
  224. case BUILD_RELEASE:
  225. return("RELEASE");
  226. case BUILD_PROFILE:
  227. return("PROFILE");
  228. default:
  229. WWASSERT(false);
  230. return("UNKNOWN");
  231. }
  232. }
  233. /***********************************************************************************************
  234. * BuildInfoClass::Composite_Build_Info -- Get lots of build info *
  235. * *
  236. * *
  237. * *
  238. * INPUT: Nothing *
  239. * *
  240. * OUTPUT: Ptr to info *
  241. * *
  242. * WARNINGS: None *
  243. * *
  244. * HISTORY: *
  245. * 10/29/2001 7:49PM ST : Created *
  246. *=============================================================================================*/
  247. char *BuildInfoClass::Composite_Build_Info(void)
  248. {
  249. static char _buffer[256];
  250. sprintf(_buffer, "%s Build %d by %s - Build time %s", Get_Build_Type_String(), Get_Build_Number(), Get_Builder_Name(), Get_Build_Date_String());
  251. return(_buffer);
  252. }
  253. /***********************************************************************************************
  254. * BuildInfoClass::Log_Build_Info -- Dump build info to the logfile. *
  255. * *
  256. * *
  257. * *
  258. * INPUT: Nothing *
  259. * *
  260. * OUTPUT: Nothing *
  261. * *
  262. * WARNINGS: None *
  263. * *
  264. * HISTORY: *
  265. * 10/29/2001 7:49PM ST : Created *
  266. *=============================================================================================*/
  267. void BuildInfoClass::Log_Build_Info(void)
  268. {
  269. WWDEBUG_SAY((Composite_Build_Info()));
  270. WWDEBUG_SAY(("\n"));
  271. }