VERSION.CPP 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. /*
  2. ** Command & Conquer Red Alert(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. /* $Header: /CounterStrike/VERSION.CPP 14 3/16/97 10:16p Joe_b $ */
  19. /***************************************************************************
  20. *** 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 ***
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * File Name : VERSION.CPP *
  25. * *
  26. * Programmer : Bill R. Randolph *
  27. * *
  28. * Start Date : 10/26/95 *
  29. * *
  30. * Last Update : September 17, 1996 [JLB] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * VersionClass::VersionClass -- Class constructor *
  35. * VersionClass::Version_Number -- Returns program version number *
  36. * VersionClass::Major_Version -- returns major version # *
  37. * VersionClass::Minor_Version -- returns minor version (revision) number*
  38. * VersionClass::Version_Name -- returns version # as char string *
  39. * VersionClass::Read_Text_String -- reads version text string from disk *
  40. * VersionClass::Version_Protocol -- returns default protocol for version*
  41. * VersionClass::Init_Clipping -- Initializes version clipping *
  42. * VersionClass::Clip_Version -- "clips" the given version range *
  43. * VersionClass::Min_Version -- returns lowest version # to connect to *
  44. * VersionClass::Max_Version -- returns highest version # to connect to *
  45. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  46. #include "function.h"
  47. #ifdef FIXIT_VERSION_3
  48. #include "rawolapi.h" // For version number.
  49. #endif
  50. /****************************** Globals ************************************/
  51. //---------------------------------------------------------------------------
  52. // This is a table of version numbers # the communications protocol used for
  53. // that version number. It's used by the game owner to determine the
  54. // protocol to be used for a given session.
  55. //
  56. // This table needs to be updated every time a new communications protocol
  57. // is implemented, not every time a new version is created.
  58. //
  59. // A given protocol is used from its corresponding version #, up to (but not
  60. // including) the next version number in the table. The last protocol in
  61. // the table is the default protocol for this version.
  62. //---------------------------------------------------------------------------
  63. static VersionProtocolType VersionProtocol[] = {
  64. {0x00001000,COMM_PROTOCOL_SINGLE_NO_COMP}, // (obsolete)
  65. {0x00002000,COMM_PROTOCOL_SINGLE_E_COMP}, // (obsolete)
  66. {0x00010000,COMM_PROTOCOL_MULTI_E_COMP},
  67. };
  68. /***************************************************************************
  69. * VersionClass::VersionClass -- Class constructor *
  70. * *
  71. * INPUT: *
  72. * none. *
  73. * *
  74. * OUTPUT: *
  75. * none. *
  76. * *
  77. * WARNINGS: *
  78. * none. *
  79. * *
  80. * HISTORY: *
  81. * 10/26/1995 BRR : Created. *
  82. * 09/17/1996 JLB : Converted to used initializer list. *
  83. *=========================================================================*/
  84. VersionClass::VersionClass(void) :
  85. Version(0),
  86. MajorVer(0),
  87. MinorVer(0),
  88. MinClipVer(0),
  89. MaxClipVer(0),
  90. VersionInit(false),
  91. MajorInit(false),
  92. MinorInit(false),
  93. TextInit(false)
  94. {
  95. VersionText[0] = '\0';
  96. VersionName[0] = '\0';
  97. }
  98. /***************************************************************************
  99. * VersionClass::Version_Number -- Returns program version number *
  100. * *
  101. * Version Number Format: *
  102. * Non-CHEAT format: *
  103. * Byte 3,2: major version (printed to the left of a decimal) *
  104. * Byte 1,0: minor version (printed to the right of a decimal) *
  105. * Thus, version 1.07 would appear as 0x0001 0700 *
  106. * *
  107. * This format guarantees that a greater-than or less-than comparison *
  108. * will work on version numbers. *
  109. * *
  110. * CHEAT format: *
  111. * Byte 3: Month # *
  112. * Byte 2: Day # *
  113. * Byte 1: Hour # *
  114. * Byte 0: Minute # *
  115. * *
  116. * This format guarantees a unique version number for each compile (as *
  117. * long as they're a minute or more apart), with increasing version #'s *
  118. * for later times. *
  119. * *
  120. * Either format should be printed in hex. *
  121. * *
  122. * This routine also fills in a text string (retrieved with Version_Text), *
  123. * which may contain a custom string (such as "Beta"); this string is *
  124. * read from the file VERSION.TXT. *
  125. * *
  126. * INPUT: *
  127. * none. *
  128. * *
  129. * OUTPUT: *
  130. * Version number *
  131. * *
  132. * WARNINGS: *
  133. * Don't call this function until the file system has been init'd! *
  134. * *
  135. * HISTORY: *
  136. * 10/26/1995 BRR : Created. *
  137. *=========================================================================*/
  138. //ajw Note: This function is no longer called. MIN_VERSION is now incorrect, but I don't have time
  139. // for a full rebuild (3 hrs!), and as MIN_VERSION is no longer referred to, I'm going to leave it.
  140. // Really, it should be deleted or commented out.
  141. // Version number used is now GAME_VERSION.
  142. // Note also that VERSION_RA_300 is wrong, but not used.
  143. unsigned long VersionClass::Version_Number(void)
  144. {
  145. //------------------------------------------------------------------------
  146. // Read the text description, if there is one
  147. //------------------------------------------------------------------------
  148. if (!TextInit) {
  149. Read_Text_String();
  150. TextInit = 1;
  151. }
  152. //------------------------------------------------------------------------
  153. // If the version has already been set, just return it.
  154. //------------------------------------------------------------------------
  155. if (VersionInit) {
  156. return (Version);
  157. }
  158. //------------------------------------------------------------------------
  159. // Generate the version #
  160. //------------------------------------------------------------------------
  161. Version = ((Major_Version() << 16) | Minor_Version());
  162. VersionInit = 1;
  163. return (Version);
  164. } /* end of Version_Number */
  165. /***************************************************************************
  166. * VersionClass::Major_Version -- returns major version # *
  167. * *
  168. * INPUT: *
  169. * none. *
  170. * *
  171. * OUTPUT: *
  172. * Major Version number *
  173. * *
  174. * WARNINGS: *
  175. * Don't call this function until the file system has been init'd! *
  176. * *
  177. * HISTORY: *
  178. * 10/26/1995 BRR : Created. *
  179. *=========================================================================*/
  180. unsigned short VersionClass::Major_Version(void)
  181. {
  182. #ifdef DEV_VERSION
  183. static char * date = __DATE__; // format: Mmm dd yyyy
  184. static char const * months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
  185. char buf[10];
  186. char * ptr;
  187. char * tok;
  188. int monthnum;
  189. int daynum;
  190. #endif
  191. //------------------------------------------------------------------------
  192. // Read the text description, if there is one
  193. //------------------------------------------------------------------------
  194. if (!TextInit) {
  195. Read_Text_String();
  196. TextInit = 1;
  197. }
  198. //------------------------------------------------------------------------
  199. // If the major version # is already set, just return it.
  200. //------------------------------------------------------------------------
  201. if (MajorInit) {
  202. return (MajorVer);
  203. }
  204. //------------------------------------------------------------------------
  205. // For a development version, use the date (month & day) as the major
  206. // version number.
  207. //------------------------------------------------------------------------
  208. #ifdef DEV_VERSION
  209. //........................................................................
  210. // Fetch the month and place in the high byte.
  211. //........................................................................
  212. strupr(date);
  213. tok = strtok(date, " ");
  214. ptr = strstr(months, tok);
  215. if (ptr) {
  216. monthnum = (((ptr - months) / 3) + 1);
  217. } else {
  218. monthnum = 0;
  219. }
  220. //........................................................................
  221. // Convert the month number to a hex counterpart (so, when it's printed
  222. // in hex, it will read correctly.)
  223. //........................................................................
  224. sprintf(buf,"%d",monthnum);
  225. sscanf(buf,"%x",&monthnum);
  226. //........................................................................
  227. // Fetch the date and place that in the low byte.
  228. //........................................................................
  229. tok = strtok(NULL, " ");
  230. if (tok) {
  231. daynum = atoi(tok);
  232. } else {
  233. daynum = 0;
  234. }
  235. //........................................................................
  236. // Convert the day number to a hex counterpart
  237. //........................................................................
  238. sprintf(buf,"%d",daynum);
  239. sscanf(buf,"%x",&daynum);
  240. MajorVer = ((monthnum << 8) | daynum);
  241. //------------------------------------------------------------------------
  242. // For a non-development version, use the hard-coded minor version number.
  243. //------------------------------------------------------------------------
  244. #else
  245. MajorVer = MAJOR_VERSION;
  246. #endif
  247. MajorInit = 1;
  248. return (MajorVer);
  249. } /* end of Major_Version */
  250. /***************************************************************************
  251. * VersionClass::Minor_Version -- returns minor version (revision) number *
  252. * *
  253. * INPUT: *
  254. * none. *
  255. * *
  256. * OUTPUT: *
  257. * Minor Version number *
  258. * *
  259. * WARNINGS: *
  260. * Don't call this function until the file system has been init'd! *
  261. * *
  262. * HISTORY: *
  263. * 10/26/1995 BRR : Created. *
  264. *=========================================================================*/
  265. unsigned short VersionClass::Minor_Version(void)
  266. {
  267. #ifdef DEV_VERSION
  268. static char * time = __TIME__; // format: hh:mm:ss
  269. char * tok;
  270. char buf[10];
  271. int hournum;
  272. int minnum;
  273. #endif
  274. //------------------------------------------------------------------------
  275. // Read the text description, if there is one
  276. //------------------------------------------------------------------------
  277. if (!TextInit) {
  278. Read_Text_String();
  279. TextInit = 1;
  280. }
  281. //------------------------------------------------------------------------
  282. // If the minor version # is already set, just return it.
  283. //------------------------------------------------------------------------
  284. if (MinorInit) {
  285. return (MinorVer);
  286. }
  287. //------------------------------------------------------------------------
  288. // For in-development versions, use the time (hour & min) as the minor
  289. // version
  290. //------------------------------------------------------------------------
  291. #ifdef DEV_VERSION
  292. //........................................................................
  293. // Fetch the hour and place that in the last two digit positions.
  294. //........................................................................
  295. tok = strtok(time, ": ");
  296. if (tok) {
  297. hournum = atoi(tok);
  298. } else {
  299. hournum = 0;
  300. }
  301. //........................................................................
  302. // Convert the hour number to a hex counterpart (so, when it's printed
  303. // in hex, it will read correctly.)
  304. //........................................................................
  305. sprintf(buf,"%d",hournum);
  306. sscanf(buf,"%x",&hournum);
  307. //........................................................................
  308. // Fetch the minute and place that in the last two digit positions.
  309. //........................................................................
  310. tok = strtok(NULL, ": ");
  311. if (tok) {
  312. minnum = atoi(tok);
  313. } else {
  314. minnum = 0;
  315. }
  316. //........................................................................
  317. // Convert the minute number to a hex counterpart
  318. //........................................................................
  319. sprintf(buf,"%d",minnum);
  320. sscanf(buf,"%x",&minnum);
  321. MinorVer = ((hournum << 8) | minnum);
  322. //------------------------------------------------------------------------
  323. // For a non-development version, use the hard-coded minor revision number.
  324. //------------------------------------------------------------------------
  325. #else
  326. #ifdef FIXIT_VERSION_3 // Insanity. CS installation should not have affected version number. ajw
  327. MinorVer = MINOR_VERSION;
  328. #else // FIXIT_VERSION_3
  329. #ifdef FIXIT_CSII
  330. MinorVer = MINOR_VERSION;
  331. if (Is_Counterstrike_Installed()) {
  332. MinorVer = MINOR_VERSION - 1;
  333. }
  334. #else
  335. #ifdef FIXIT_VERSION
  336. /* If counterstrike is not installed then we report version 1.06
  337. * otherwise we report ourselves as 1.08
  338. */
  339. if (Is_Counterstrike_Installed() == false) {
  340. MinorVer = (MINOR_VERSION - CS_MINOR_VERSION_MODIFIER);
  341. } else {
  342. MinorVer = MINOR_VERSION;
  343. }
  344. #else
  345. MinorVer = MINOR_VERSION;
  346. #endif
  347. #endif
  348. #endif // FIXIT_VERSION_3
  349. #endif
  350. MinorInit = 1;
  351. return (MinorVer);
  352. } /* end of Minor_Version */
  353. /***************************************************************************
  354. * VersionClass::Version_Name -- returns version # as char string *
  355. * *
  356. * INPUT: *
  357. * none. *
  358. * *
  359. * OUTPUT: *
  360. * ptr to name *
  361. * *
  362. * WARNINGS: *
  363. * none. *
  364. * *
  365. * HISTORY: *
  366. * 10/30/1995 BRR : Created. *
  367. *=========================================================================*/
  368. char * VersionClass::Version_Name(void)
  369. {
  370. //------------------------------------------------------------------------
  371. // For developmental versions, just use the major & minor version #'s
  372. //------------------------------------------------------------------------
  373. #ifdef DEV_VERSION
  374. sprintf(VersionName, "%x.%x", VerNum.Major_Version(), VerNum.Minor_Version());
  375. //------------------------------------------------------------------------
  376. // For final versions, trim 0's off the minor version
  377. //------------------------------------------------------------------------
  378. #else
  379. unsigned short adjusted_minor;
  380. int i;
  381. adjusted_minor = Minor_Version();
  382. for (i = 0; i < 4; i++) {
  383. if ( (adjusted_minor & 0x000f) != 0) {
  384. break;
  385. }
  386. adjusted_minor >>= 4;
  387. }
  388. sprintf(VersionName, "%x.%x", VerNum.Major_Version(), adjusted_minor);
  389. #endif
  390. return (VersionName);
  391. } /* end of Version_Name */
  392. /***************************************************************************
  393. * VersionClass::Read_Text_String -- reads version # text string from disk *
  394. * *
  395. * INPUT: *
  396. * none. *
  397. * *
  398. * OUTPUT: *
  399. * none. *
  400. * *
  401. * WARNINGS: *
  402. * Don't call this function until the file system has been init'd! *
  403. * *
  404. * HISTORY: *
  405. * 10/26/1995 BRR : Created. *
  406. *=========================================================================*/
  407. void VersionClass::Read_Text_String(void)
  408. {
  409. RawFileClass file("VERSION.TXT");
  410. if (file.Is_Available()) {
  411. file.Read(VersionText, sizeof(VersionText));
  412. VersionText[sizeof(VersionText)-1] = '\0';
  413. while (VersionText[strlen(VersionText)-1] == '\r') {
  414. VersionText[strlen(VersionText)-1] = '\0';
  415. }
  416. } else {
  417. VersionText[0] = '\0';
  418. }
  419. } /* end of Read_Text_String */
  420. /***************************************************************************
  421. * VersionClass::Version_Protocol -- returns default protocol for version *
  422. * *
  423. * INPUT: *
  424. * version version # to look up *
  425. * *
  426. * OUTPUT: *
  427. * protocol value to use for that version # *
  428. * *
  429. * WARNINGS: *
  430. * none. *
  431. * *
  432. * HISTORY: *
  433. * 10/26/1995 BRR : Created. *
  434. *=========================================================================*/
  435. CommProtocolType VersionClass::Version_Protocol(unsigned long version)
  436. {
  437. int i,j;
  438. //------------------------------------------------------------------------
  439. // Compute # entries in the VersionProtocol table
  440. //------------------------------------------------------------------------
  441. j = sizeof (VersionProtocol) / sizeof(VersionProtocolType);
  442. //------------------------------------------------------------------------
  443. // Search backwards through the table, finding the first entry for which
  444. // the given version # is >= the table's; this is the range containing
  445. // the given version number.
  446. //------------------------------------------------------------------------
  447. for (i = j - 1; i >= 0; i--) {
  448. if (version >= VersionProtocol[i].Version) {
  449. return (VersionProtocol[i].Protocol);
  450. }
  451. }
  452. //------------------------------------------------------------------------
  453. // If no range was found for the given version, return the highest
  454. // possible protocol. (If version clipping is being done properly, this
  455. // case should never happen, but never say never.)
  456. //------------------------------------------------------------------------
  457. return (VersionProtocol[j-1].Protocol);
  458. } /* end of Version_Protocol */
  459. /***************************************************************************
  460. * VersionClass::Init_Clipping -- Initializes version clipping *
  461. * *
  462. * Initializes the Min & Max clip version #'s to the min & max values *
  463. * defined for this program. This sets the initial range for use by *
  464. * the Clip_Version routine. *
  465. * *
  466. * INPUT: *
  467. * none. *
  468. * *
  469. * OUTPUT: *
  470. * none. *
  471. * *
  472. * WARNINGS: *
  473. * The DEV_VERSION version of this routine calls Version_Number(), so *
  474. * don't call this routine until the file system has been initialized! *
  475. * *
  476. * HISTORY: *
  477. * 10/26/1995 BRR : Created. *
  478. *=========================================================================*/
  479. void VersionClass::Init_Clipping(void)
  480. {
  481. MinClipVer = Min_Version();
  482. MaxClipVer = Max_Version();
  483. } /* end of Init_Clipping */
  484. /***************************************************************************
  485. * VersionClass::Clip_Version -- "clips" the given version range *
  486. * *
  487. * This routine compares another program's supported min/max version *
  488. * range with the range currently defined by 'MinClipVer' and 'MaxClipVer'.*
  489. * If there is overlap in the two ranges, Min & MaxClipVer are adjusted *
  490. * to the bounds of the overlap. The routine returns the largest version *
  491. * number shared by the ranges (MaxClipVer). *
  492. * *
  493. * Thus, by calling Init_Clipping(), then a series of Clip_Version() calls,*
  494. * a mutually-acceptable range of version #'s may be negotiated between *
  495. * different versions of this program. The max shared version may then *
  496. * be used to decide upon a communications protocol that all programs *
  497. * support. *
  498. * *
  499. * INPUT: *
  500. * minver min version to clip to *
  501. * maxver max version to clip to *
  502. * *
  503. * OUTPUT: *
  504. * highest clipped version # *
  505. * 0 = given range is below our current range *
  506. * 0xFFFFFFFF = given range is above our current range *
  507. * *
  508. * WARNINGS: *
  509. * Be sure Init_Clipping() was called before performing a clipping *
  510. * session. *
  511. * *
  512. * HISTORY: *
  513. * 10/26/1995 BRR : Created. *
  514. *=========================================================================*/
  515. unsigned long VersionClass::Clip_Version(unsigned long minver,
  516. unsigned long maxver)
  517. {
  518. //------------------------------------------------------------------------
  519. // If the given range is outside & above our own, return an error.
  520. //------------------------------------------------------------------------
  521. if (minver > MaxClipVer)
  522. return (0xffffffff);
  523. //------------------------------------------------------------------------
  524. // If the given range is outside & below our own, return an error.
  525. //------------------------------------------------------------------------
  526. if (maxver < MinClipVer)
  527. return (0);
  528. //------------------------------------------------------------------------
  529. // Clip the lower range value
  530. //------------------------------------------------------------------------
  531. if (minver > MinClipVer)
  532. MinClipVer = minver;
  533. //------------------------------------------------------------------------
  534. // Clip the upper range value
  535. //------------------------------------------------------------------------
  536. if (maxver < MaxClipVer)
  537. MaxClipVer = maxver;
  538. //------------------------------------------------------------------------
  539. // Return the highest version supported by the newly-adjusted range.
  540. //------------------------------------------------------------------------
  541. return (MaxClipVer);
  542. } /* end of Clip_Version */
  543. /***************************************************************************
  544. * VersionClass::Min_Version -- returns lowest version # to connect to *
  545. * *
  546. * Returns the minimum version # this program will connect to. *
  547. * *
  548. * If DEV_VERSION is defined, this routine returns the current version, so *
  549. * this program will only connect to an exact copy of itself. *
  550. * *
  551. * INPUT: *
  552. * none. *
  553. * *
  554. * OUTPUT: *
  555. * min version # *
  556. * *
  557. * WARNINGS: *
  558. * The DEV_VERSION version of this routine calls Version_Number(), so *
  559. * don't call this routine until the file system has been initialized! *
  560. * *
  561. * HISTORY: *
  562. * 10/26/1995 BRR : Created. *
  563. *=========================================================================*/
  564. unsigned long VersionClass::Min_Version(void)
  565. {
  566. #ifdef DEV_VERSION
  567. return (Version_Number());
  568. #else
  569. #ifdef FIXIT_VERSION_3
  570. // Note! I'm no longer using MIN_VERSION, MAX_VERSION, or VERSION_RA_300!
  571. // But no time to do three full rebuilds right now, so I'm not deleting them from the header file... ajw
  572. return GAME_VERSION;
  573. #else // FIXIT_VERSION_3
  574. #ifdef FIXIT_VERSION
  575. if ( Is_Counterstrike_Installed() ) {
  576. return (MIN_VERSION - 1);
  577. }
  578. return (MIN_VERSION);
  579. #else
  580. if ( Is_Counterstrike_Installed() ){
  581. return (MIN_VERSION - CS_MINOR_VERSION_MODIFIER);
  582. }else{
  583. return (MIN_VERSION);
  584. }
  585. #endif
  586. #endif // FIXIT_VERSION_3
  587. #endif
  588. } /* end of Min_Version */
  589. /***************************************************************************
  590. * VersionClass::Max_Version -- returns highest version # to connect to *
  591. * *
  592. * Returns the maximum version # this program will connect to. *
  593. * *
  594. * If DEV_VERSION is defined, this routine returns the current version, so *
  595. * this program will only connect to an exact copy of itself. *
  596. * *
  597. * INPUT: *
  598. * none. *
  599. * *
  600. * OUTPUT: *
  601. * max version # *
  602. * *
  603. * WARNINGS: *
  604. * The DEV_VERSION version of this routine calls Version_Number(), so *
  605. * don't call this routine until the file system has been initialized! *
  606. * *
  607. * HISTORY: *
  608. * 10/26/1995 BRR : Created. *
  609. *=========================================================================*/
  610. unsigned long VersionClass::Max_Version(void)
  611. {
  612. #ifdef DEV_VERSION
  613. return (Version_Number());
  614. #else
  615. #ifdef FIXIT_VERSION_3
  616. // Note! I'm no longer using MIN_VERSION, MAX_VERSION, or VERSION_RA_300!
  617. // But no time to do three full rebuilds right now, so I'm not deleting them from the header file... ajw
  618. return GAME_VERSION;
  619. #else
  620. #ifdef FIXIT_CSII // checked - ajw
  621. return (MAX_VERSION);
  622. #else
  623. #ifdef FIXIT_VERSION
  624. if (Is_Counterstrike_Installed() == false) {
  625. return (MAX_VERSION - CS_MINOR_VERSION_MODIFIER);
  626. } else {
  627. return (MAX_VERSION);
  628. }
  629. #else
  630. if ( Is_Counterstrike_Installed() ){
  631. return (MAX_VERSION + CS_MINOR_VERSION_MODIFIER);
  632. }else{
  633. return (MAX_VERSION);
  634. }
  635. #endif
  636. #endif
  637. #endif
  638. #endif // FIXIT_VERSION_3
  639. } /* end of Max_Version */
  640. char const * Version_Name(void)
  641. {
  642. #ifdef NEVER
  643. static char buffer[32];
  644. /*
  645. ** Fetch the day and month components from the current
  646. ** build date.
  647. */
  648. static char * date = __DATE__; // format: Mmm dd yyyy
  649. strupr(date);
  650. char const * tok = strtok(date, " ");
  651. static char const * months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
  652. char const * ptr = strstr(months, tok);
  653. int monthnum = 0;
  654. if (ptr != NULL) {
  655. monthnum = (((ptr - months) / 3) + 1);
  656. }
  657. tok = strtok(NULL, " ");
  658. int daynum = 0;
  659. if (tok != NULL) {
  660. daynum = atoi(tok);
  661. }
  662. /*
  663. ** Fetch the time components from the current build time.
  664. */
  665. static char * time = __TIME__; // format: hh:mm:ss
  666. tok = strtok(time, ": ");
  667. int hournum = 0;
  668. if (tok != NULL) {
  669. hournum = atoi(tok);
  670. }
  671. tok = strtok(NULL, ": ");
  672. int minnum = 0;
  673. if (tok != NULL) {
  674. minnum = atoi(tok);
  675. }
  676. sprintf(buffer, "%02d%02d%02d", monthnum, daynum, (hournum*4) + (minnum / 15));
  677. return(buffer);
  678. #else
  679. static char buffer[128];
  680. memset(buffer, '\0', sizeof(buffer));
  681. #ifdef FIXIT_VERSION_3
  682. strcpy( buffer, "3.03" );
  683. #ifdef ENGLISH
  684. strcat(buffer, "E");
  685. #else
  686. #ifdef GERMAN
  687. strcat(buffer, "G");
  688. #else
  689. #ifdef FRENCH
  690. strcat(buffer, "F");
  691. #endif
  692. #endif
  693. #endif
  694. #else // FIXIT_VERSION_3
  695. #ifdef FIXIT_PATCH_108
  696. //strcpy(buffer, "1.08PE");
  697. strcpy(buffer, "1.08P");
  698. #ifdef FIXIT_CSII
  699. strcpy(buffer,"2.00");
  700. #ifdef DEV_VERSION
  701. strcpy(buffer,VerNum.Version_Name());
  702. #endif
  703. #ifdef DEV_VER_NAME
  704. strcpy(buffer,__DATE__); // format: Mmm dd yyyy
  705. #endif
  706. #endif
  707. #ifdef ENGLISH
  708. strcat(buffer, "E");
  709. #else
  710. #ifdef GERMAN
  711. strcat(buffer, "G");
  712. #else
  713. #ifdef FRENCH
  714. strcat(buffer, "F");
  715. #endif
  716. #endif
  717. #endif
  718. #else
  719. strcpy(buffer, "1.07E");
  720. #endif
  721. #endif // FIXIT_VERSION_3
  722. if (Is_Counterstrike_Installed ()){
  723. strcat (buffer, "CS");
  724. }
  725. if (Is_Aftermath_Installed()) {
  726. strcat (buffer, "AM");
  727. }
  728. #if(TEN)
  729. strcat(buffer, "Ten"); // Ten version
  730. #endif
  731. #if(MPATH)
  732. strcat(buffer, "MPath"); // MPath version
  733. #endif
  734. RawFileClass file("VERSION.TXT");
  735. if (file.Is_Available()) {
  736. strcat(buffer, "\r");
  737. file.Read(&buffer[strlen(buffer)], 25);
  738. }
  739. return(buffer);
  740. #endif
  741. }