VERSION.CPP 34 KB

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