SESSION.CPP 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875
  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/SESSION.CPP 3 3/10/97 6:23p Steve_tall $ */
  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 : SESSION.CPP *
  22. * *
  23. * Programmer : Bill R. Randolph *
  24. * *
  25. * Start Date : 11/30/95 *
  26. * *
  27. * Last Update : September 10, 1996 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * SessionClass::SessionClass -- Constructor *
  32. * SessionClass::~SessionClass -- Destructor *
  33. * SessionClass::One_Time -- one-time initializations *
  34. * SessionClass::Init -- Initializes all values *
  35. * SessionClass::Create_Connections -- forms connections to other players *
  36. * SessionClass::Am_I_Master -- tells if the local system is the "master" *
  37. * SessionClass::Save -- Saves this class to a file *
  38. * SessionClass::Load -- Loads this class from a file *
  39. * SessionClass::Read_MultiPlayer_Settings -- reads settings from INI *
  40. * SessionClass::Write_MultiPlayer_Settings -- writes settings to INI *
  41. * SessionClass::Read_Scenario_Descriptions -- reads scen. descriptions *
  42. * SessionClass::Free_Scenario_Descriptions -- frees scen. descriptions *
  43. * SessionClass::Trap_Object -- searches for an object, for debugging *
  44. * SessionClass::Compute_Unique_ID -- computes unique local ID number *
  45. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  46. #include "function.h"
  47. #include <dos.h> // for station ID computation
  48. #include <time.h> // for station ID computation
  49. //#include "WolDebug.h"
  50. /***************************** Globals *************************************/
  51. //---------------------------------------------------------------------------
  52. // This is the array of remap colors. Each player in a network game is
  53. // assigned one of these colors. The 'G' is for graphics drawing; the 'T'
  54. // is for text printing (indicates a remap table for the font to use).
  55. //---------------------------------------------------------------------------
  56. //int SessionClass::GColors[MAX_MPLAYER_COLORS] = {
  57. //5, // Yellow
  58. //127, // Red
  59. //135, // BlueGreen
  60. //26, // Orange
  61. //4, // Green
  62. //202 // Blue-Grey
  63. //};
  64. //int SessionClass::TColors[MAX_MPLAYER_COLORS] = {
  65. //CC_GDI_COLOR, // Yellow
  66. //CC_NOD_COLOR, // Red
  67. //CC_BLUE_GREEN, // BlueGreen
  68. //CC_ORANGE, // Orange
  69. //CC_GREEN, // Green
  70. //CC_BLUE_GREY, // Blue
  71. //};
  72. /*---------------------------------------------------------------------------
  73. Min & Max unit count values; index0 = bases OFF, index1 = bases ON
  74. ---------------------------------------------------------------------------*/
  75. int SessionClass::CountMin[2] = {1,0};
  76. int SessionClass::CountMax[2] = {50,12};
  77. //---------------------------------------------------------------------------
  78. // This is a list of all the names of the multiplayer scenarios
  79. //---------------------------------------------------------------------------
  80. char SessionClass::Descriptions[100][40];
  81. //---------------------------------------------------------------------------
  82. // These values are used purely for the Mono debug display. They show the
  83. // names of the Global Channel packet types, and the event types.
  84. //---------------------------------------------------------------------------
  85. char * SessionClass::GlobalPacketNames[] = {
  86. "Game?",
  87. "Game!",
  88. "Player?",
  89. "Player!",
  90. "Join?",
  91. "Join!",
  92. "Reject",
  93. "GameOptions",
  94. "Sign Off",
  95. "GO!",
  96. "Message",
  97. "Ping",
  98. "Load"
  99. };
  100. char * SessionClass::SerialPacketNames[] = {
  101. "CONNECT",
  102. "GAME_OPTIONS",
  103. "SIGN_OFF",
  104. "GO",
  105. "MESSAGE",
  106. "TIMING",
  107. "SCORE_SCREEN",
  108. "LOADGAME",
  109. "LAST_COMMAND",
  110. };
  111. char * SessionClass::DialMethodCheck[ DIAL_METHODS ] = {
  112. "T",
  113. "P"
  114. };
  115. char *SessionClass::CallWaitStrings[ CALL_WAIT_STRINGS_NUM ] = {
  116. "*70,",
  117. "70#,",
  118. "1170,",
  119. "CUSTOM - "
  120. };
  121. /***************************************************************************
  122. * SessionClass::SessionClass -- Constructor *
  123. * *
  124. * INPUT: *
  125. * none. *
  126. * *
  127. * OUTPUT: *
  128. * none. *
  129. * *
  130. * WARNINGS: *
  131. * none. *
  132. * *
  133. * HISTORY: *
  134. * 11/30/1995 BRR : Created. *
  135. *=========================================================================*/
  136. SessionClass::SessionClass(void)
  137. {
  138. Type = GAME_NORMAL;
  139. CommProtocol = DEFAULT_COMM_PROTOCOL;
  140. Options.ScenarioIndex = 0;
  141. Options.Bases = 0;
  142. Options.Credits = 0;
  143. Options.Tiberium = 0;
  144. Options.Goodies = 0;
  145. Options.Ghosts = 0;
  146. Options.UnitCount = 0;
  147. UniqueID = 0;
  148. Handle[0] = 0;
  149. PrefColor = PCOLOR_FIRST;
  150. ColorIdx = PCOLOR_FIRST;
  151. House = HOUSE_GOOD;
  152. ObiWan = 0;
  153. Solo = 0;
  154. MaxPlayers = 8;
  155. NumPlayers = 0;
  156. MaxAhead = 5;
  157. FrameSendRate = DEFAULT_FRAME_SEND_RATE;
  158. LoadGame = 0;
  159. EmergencySave = 0;
  160. LastMessage[0] = 0;
  161. WWChat = 0;
  162. RecordFile.Set_Name("RECORD.BIN"); // always uses this name
  163. Record= 0; // set via command line
  164. Play = 0; // set via command line
  165. Attract = 0; // set via command line
  166. IsBridge = 0;
  167. NetStealth = 0;
  168. NetProtect = 1;
  169. NetOpen = 0;
  170. GameName[0] = 0;
  171. GProductID = 0;
  172. MetaSize = MAX_IPX_PACKET_SIZE;
  173. ModemService = true;
  174. CurPhoneIdx = 0; // set from INI file
  175. SerialDefaults.Port = 0x2f8; // set from INI file
  176. SerialDefaults.IRQ = 3; // set from INI file
  177. SerialDefaults.Baud = 9600; // set from INI file
  178. SerialDefaults.DialMethod = DIAL_TOUCH_TONE; // set from INI file
  179. SerialDefaults.InitStringIndex = 0; // set from INI file
  180. SerialDefaults.CallWaitStringIndex = 0; // set from INI file
  181. strcpy(SerialDefaults.CallWaitString,"");
  182. ModemType = MODEM_NULL_HOST; // set from INI file
  183. TrapFrame = 0x7fffffff; // frame to start trapping object values at
  184. TrapObjType = RTTI_NONE; // type of object to trap
  185. TrapObject.Ptr.All = NULL; // ptr to object being trapped
  186. TrapCoord = 0; // COORDINATE of object to trap
  187. TrapTarget = TARGET_NONE; // TARGET value of object to trap
  188. TrapCell = NULL; // for trapping a cell
  189. TrapCheckHeap = 0; // start checking the Heap
  190. TrapPrintCRC = 0; // output CRC file
  191. #if(TEN)
  192. TenPacket = NULL;
  193. TenSize = 200;
  194. TenPlayerID = -1;
  195. OptionsFile[0] = 0;
  196. AllowSolo = 0;
  197. NetResponseTime = 600;
  198. #endif // TEN
  199. #if(MPATH)
  200. MPathPacket = NULL;
  201. MPathSize = 200;
  202. OptionsFile[0] = 0;
  203. AllowSolo = 0;
  204. NetResponseTime = 600;
  205. #endif // MPATH
  206. } // end of SessionClass
  207. /***************************************************************************
  208. * SessionClass::~SessionClass -- Destructor *
  209. * *
  210. * INPUT: *
  211. * none. *
  212. * *
  213. * OUTPUT: *
  214. * none. *
  215. * *
  216. * WARNINGS: *
  217. * none. *
  218. * *
  219. * HISTORY: *
  220. * 11/30/1995 BRR : Created. *
  221. *=========================================================================*/
  222. SessionClass::~SessionClass(void)
  223. {
  224. } // end of ~SessionClass
  225. /***************************************************************************
  226. * SessionClass::One_Time -- one-time initializations *
  227. * *
  228. * INPUT: *
  229. * none. *
  230. * *
  231. * OUTPUT: *
  232. * none. *
  233. * *
  234. * WARNINGS: *
  235. * none. *
  236. * *
  237. * HISTORY: *
  238. * 12/01/1995 BRR : Created. *
  239. *=========================================================================*/
  240. void SessionClass::One_Time(void)
  241. {
  242. Read_MultiPlayer_Settings();
  243. Read_Scenario_Descriptions();
  244. UniqueID = Compute_Unique_ID();
  245. } // end of One_Time
  246. /***************************************************************************
  247. * SessionClass::Init -- Initializes all values *
  248. * *
  249. * This function should be called for every new game played; it only sets *
  250. * those variables that should be set for a new game. *
  251. * *
  252. * INPUT: *
  253. * none. *
  254. * *
  255. * OUTPUT: *
  256. * none. *
  257. * *
  258. * WARNINGS: *
  259. * none. *
  260. * *
  261. * HISTORY: *
  262. * 11/30/1995 BRR : Created. *
  263. *=========================================================================*/
  264. void SessionClass::Init(void)
  265. {
  266. } // end of Init
  267. /***************************************************************************
  268. * SessionClass::Create_Connections -- forms connections to other players *
  269. * *
  270. * This routine uses the contents of the Players vector, combined with *
  271. * that of the Houses array, to create connections to each other player. *
  272. * It is assumed that 'Players' contains all the other players to connect *
  273. * to, and that the HouseClass's have been filled in with players' data. *
  274. * *
  275. * INPUT: *
  276. * none. *
  277. * *
  278. * OUTPUT: *
  279. * 1 = success, 0 = failure *
  280. * *
  281. * WARNINGS: *
  282. * none. *
  283. * *
  284. * HISTORY: *
  285. * 11/30/1995 BRR : Created. *
  286. *=========================================================================*/
  287. int SessionClass::Create_Connections(void)
  288. {
  289. #if (0)//PG
  290. int i;
  291. if (Session.Type != GAME_IPX && Session.Type != GAME_INTERNET) {
  292. return (0);
  293. }
  294. //------------------------------------------------------------------------
  295. // Loop through all entries in 'Players'. To avoid connecting to myself,
  296. // skip the 1st entry.
  297. //------------------------------------------------------------------------
  298. for (i = 1; i < Players.Count(); i++) {
  299. //.....................................................................
  300. // Make sure the name matches before creating the connection
  301. //.....................................................................
  302. if (!stricmp (Players[i]->Name,
  303. HouseClass::As_Pointer(Players[i]->Player.ID)->IniName)) {
  304. Ipx.Create_Connection((int)Players[i]->Player.ID, Players[i]->Name,
  305. &(Players[i]->Address) );
  306. Players[i]->Player.ProcessTime = -1;
  307. }
  308. else {
  309. return (0);
  310. }
  311. }
  312. #endif
  313. return (1);
  314. } // end of Create_Connections
  315. #if(TEN)
  316. /***************************************************************************
  317. * SessionClass::Create_TEN_Connections -- forms connections to TEN players*
  318. * *
  319. * This routine uses the contents of the Players vector, combined with *
  320. * that of the Houses array, to create connections to each other player. *
  321. * It is assumed that 'Players' contains all the other players to connect *
  322. * to, and that the HouseClass's have been filled in with players' data. *
  323. * *
  324. * INPUT: *
  325. * none. *
  326. * *
  327. * OUTPUT: *
  328. * 1 = success, 0 = failure *
  329. * *
  330. * WARNINGS: *
  331. * none. *
  332. * *
  333. * HISTORY: *
  334. * 11/30/1995 BRR : Created. *
  335. *=========================================================================*/
  336. int SessionClass::Create_TEN_Connections(void)
  337. {
  338. int i;
  339. if (Session.Type != GAME_TEN) {
  340. return (0);
  341. }
  342. //------------------------------------------------------------------------
  343. // Loop through all entries in 'Players'. To avoid connecting to myself,
  344. // skip the 1st entry.
  345. //------------------------------------------------------------------------
  346. for (i = 1; i < Players.Count(); i++) {
  347. //.....................................................................
  348. // Make sure the name matches before creating the connection
  349. //.....................................................................
  350. if (!stricmp (Players[i]->Name,
  351. HouseClass::As_Pointer(Players[i]->Player.ID)->IniName)) {
  352. Ten->Create_Connection((int)Players[i]->Player.ID, Players[i]->Name,
  353. Players[i]->TenAddress);
  354. Players[i]->Player.ProcessTime = -1;
  355. }
  356. else {
  357. return (0);
  358. }
  359. }
  360. return (1);
  361. } // end of Create_TEN_Connections
  362. #endif // TEN
  363. #if(MPATH)
  364. /***************************************************************************
  365. * SessionClass::Create_MPATH_Connections -- forms connections to MPATH players*
  366. * *
  367. * This routine uses the contents of the Players vector, combined with *
  368. * that of the Houses array, to create connections to each other player. *
  369. * It is assumed that 'Players' contains all the other players to connect *
  370. * to, and that the HouseClass's have been filled in with players' data. *
  371. * *
  372. * INPUT: *
  373. * none. *
  374. * *
  375. * OUTPUT: *
  376. * 1 = success, 0 = failure *
  377. * *
  378. * WARNINGS: *
  379. * none. *
  380. * *
  381. * HISTORY: *
  382. * 11/30/1995 BRR : Created. *
  383. *=========================================================================*/
  384. int SessionClass::Create_MPATH_Connections(void)
  385. {
  386. int i;
  387. if (Session.Type != GAME_MPATH) {
  388. return (0);
  389. }
  390. //------------------------------------------------------------------------
  391. // Loop through all entries in 'Players'. To avoid connecting to myself,
  392. // skip the 1st entry.
  393. //------------------------------------------------------------------------
  394. for (i = 1; i < Players.Count(); i++) {
  395. //.....................................................................
  396. // Make sure the name matches before creating the connection
  397. //.....................................................................
  398. if (!stricmp (Players[i]->Name,
  399. HouseClass::As_Pointer(Players[i]->Player.ID)->IniName)) {
  400. MPath->Create_Connection((int)Players[i]->Player.ID, Players[i]->Name,
  401. Players[i]->MPathAddress);
  402. Players[i]->Player.ProcessTime = -1;
  403. }
  404. else {
  405. return (0);
  406. }
  407. }
  408. return (1);
  409. } // end of Create_MPATH_Connections
  410. #endif // MPATH
  411. /***************************************************************************
  412. * SessionClass::Am_I_Master -- tells if the local system is the "master" *
  413. * *
  414. * INPUT: *
  415. * none. *
  416. * *
  417. * OUTPUT: *
  418. * none. *
  419. * *
  420. * WARNINGS: *
  421. * none. *
  422. * *
  423. * HISTORY: *
  424. * 11/29/1995 BRR : Created. *
  425. *=========================================================================*/
  426. bool SessionClass::Am_I_Master(void)
  427. {
  428. int i;
  429. HousesType house;
  430. HouseClass *hptr;
  431. //------------------------------------------------------------------------
  432. // Check every house; if PlayerPtr points to the first human house, we're
  433. // the master.
  434. //------------------------------------------------------------------------
  435. for (i = 0; i < Session.MaxPlayers; i++) {
  436. house = (HousesType)((int)HOUSE_MULTI1 + i);
  437. hptr = HouseClass::As_Pointer(house);
  438. if (hptr->IsHuman) {
  439. if (PlayerPtr == hptr) {
  440. return (true);
  441. }
  442. else {
  443. return (false);
  444. }
  445. }
  446. }
  447. return (false);
  448. } // end of Am_I_Master
  449. /***************************************************************************
  450. * SessionClass::Save -- Saves this class to a file *
  451. * *
  452. * Only certain members of this class should be saved into a save-game *
  453. * file; this routine saves only those members. *
  454. * *
  455. * INPUT: *
  456. * file file to save to *
  457. * *
  458. * OUTPUT: *
  459. * 1 = OK, 0 = error *
  460. * *
  461. * WARNINGS: *
  462. * none. *
  463. * *
  464. * HISTORY: *
  465. * 12/04/1995 BRR : Created. *
  466. *=========================================================================*/
  467. int SessionClass::Save(Pipe & file) const
  468. {
  469. #ifdef FIXIT_MULTI_SAVE
  470. file.Put(&CommProtocol, sizeof(CommProtocol));
  471. file.Put(&MaxAhead, sizeof(MaxAhead));
  472. file.Put(&FrameSendRate, sizeof(FrameSendRate));
  473. file.Put(&DesiredFrameRate, sizeof(DesiredFrameRate));
  474. #endif // FIXIT_MULTI_SAVE
  475. file.Put(&PrefColor, sizeof(PrefColor));
  476. file.Put(&ColorIdx, sizeof(ColorIdx));
  477. file.Put(&House, sizeof(House));
  478. file.Put(&NumPlayers, sizeof(NumPlayers));
  479. file.Put(&Options.Bases, sizeof(Options.Bases));
  480. file.Put(&Options.Credits, sizeof(Options.Credits));
  481. file.Put(&Options.Tiberium, sizeof(Options.Tiberium));
  482. file.Put(&Options.Goodies, sizeof(Options.Goodies));
  483. file.Put(&Options.Ghosts, sizeof(Options.Ghosts));
  484. file.Put(&Options.UnitCount, sizeof(Options.UnitCount));
  485. file.Put(&Options.AIPlayers, sizeof(Options.AIPlayers));
  486. file.Put(&ObiWan, sizeof(ObiWan));
  487. file.Put(&EmergencySave, sizeof(EmergencySave));
  488. return (1);
  489. } // end of Save
  490. /***************************************************************************
  491. * SessionClass::Load -- Loads this class from a file *
  492. * *
  493. * INPUT: *
  494. * file file to load from *
  495. * *
  496. * OUTPUT: *
  497. * 1 = OK, 0 = error *
  498. * *
  499. * WARNINGS: *
  500. * none. *
  501. * *
  502. * HISTORY: *
  503. * 12/04/1995 BRR : Created. *
  504. *=========================================================================*/
  505. int SessionClass::Load(Straw & file)
  506. {
  507. #ifdef FIXIT_MULTI_SAVE
  508. // if(GameVersion != 0x0100616D){
  509. file.Get(&CommProtocol, sizeof(CommProtocol));
  510. file.Get(&MaxAhead, sizeof(MaxAhead));
  511. file.Get(&FrameSendRate, sizeof(FrameSendRate));
  512. file.Get(&DesiredFrameRate, sizeof(DesiredFrameRate));
  513. // }
  514. #endif // FIXIT_MULTI_SAVE
  515. file.Get(&PrefColor, sizeof(PrefColor));
  516. file.Get(&ColorIdx, sizeof(ColorIdx));
  517. file.Get(&House, sizeof(House));
  518. file.Get(&NumPlayers, sizeof(NumPlayers));
  519. file.Get(&Options.Bases, sizeof(Options.Bases));
  520. file.Get(&Options.Credits, sizeof(Options.Credits));
  521. file.Get(&Options.Tiberium, sizeof(Options.Tiberium));
  522. file.Get(&Options.Goodies, sizeof(Options.Goodies));
  523. file.Get(&Options.Ghosts, sizeof(Options.Ghosts));
  524. file.Get(&Options.UnitCount, sizeof(Options.UnitCount));
  525. file.Get(&Options.AIPlayers, sizeof(Options.AIPlayers));
  526. file.Get(&ObiWan, sizeof(ObiWan));
  527. file.Get(&EmergencySave, sizeof(EmergencySave));
  528. return (1);
  529. } // end of Load
  530. /***************************************************************************
  531. * SessionClass::Save -- Saves this class to a file *
  532. * *
  533. * Only certain members of this class should be saved into a save-game *
  534. * file; this routine saves only those members. *
  535. * *
  536. * INPUT: *
  537. * file file to save to *
  538. * *
  539. * OUTPUT: *
  540. * 1 = OK, 0 = error *
  541. * *
  542. * WARNINGS: *
  543. * none. *
  544. * *
  545. * HISTORY: *
  546. * 12/04/1995 BRR : Created. *
  547. *=========================================================================*/
  548. int SessionClass::Save(CCFileClass & file)
  549. {
  550. int i;
  551. file.Write(&Type, sizeof(Type));
  552. file.Write(&CommProtocol, sizeof(CommProtocol));
  553. file.Write(&FrameSendRate, sizeof(FrameSendRate));
  554. file.Write(&PrefColor, sizeof(PrefColor));
  555. file.Write(&ColorIdx, sizeof(ColorIdx));
  556. file.Write(&House, sizeof(House));
  557. file.Write(&NumPlayers, sizeof(NumPlayers));
  558. file.Write(&Options.Bases, sizeof(Options.Bases));
  559. file.Write(&Options.Credits, sizeof(Options.Credits));
  560. file.Write(&Options.Tiberium, sizeof(Options.Tiberium));
  561. file.Write(&Options.Goodies, sizeof(Options.Goodies));
  562. file.Write(&Options.Ghosts, sizeof(Options.Ghosts));
  563. file.Write(&Options.UnitCount, sizeof(Options.UnitCount));
  564. file.Write(&Options.AIPlayers, sizeof(Options.AIPlayers));
  565. file.Write(&ObiWan, sizeof(ObiWan));
  566. file.Write(&EmergencySave, sizeof(EmergencySave));
  567. i = Players.Count();
  568. file.Write(&i, sizeof(i));
  569. for (i = 0; i < Players.Count(); i++) {
  570. file.Write(Players[i], sizeof(NodeNameType));
  571. }
  572. return (1);
  573. } // end of Save
  574. /***************************************************************************
  575. * SessionClass::Load -- Loads this class from a file *
  576. * *
  577. * INPUT: *
  578. * file file to load from *
  579. * *
  580. * OUTPUT: *
  581. * 1 = OK, 0 = error *
  582. * *
  583. * WARNINGS: *
  584. * none. *
  585. * *
  586. * HISTORY: *
  587. * 12/04/1995 BRR : Created. *
  588. *=========================================================================*/
  589. int SessionClass::Load(CCFileClass & file)
  590. {
  591. int count;
  592. int i;
  593. NodeNameType *node;
  594. file.Read(&Type, sizeof(Type));
  595. file.Read(&CommProtocol, sizeof(CommProtocol));
  596. file.Read(&FrameSendRate, sizeof(FrameSendRate));
  597. file.Read(&PrefColor, sizeof(PrefColor));
  598. file.Read(&ColorIdx, sizeof(ColorIdx));
  599. file.Read(&House, sizeof(House));
  600. file.Read(&NumPlayers, sizeof(NumPlayers));
  601. file.Read(&Options.Bases, sizeof(Options.Bases));
  602. file.Read(&Options.Credits, sizeof(Options.Credits));
  603. file.Read(&Options.Tiberium, sizeof(Options.Tiberium));
  604. file.Read(&Options.Goodies, sizeof(Options.Goodies));
  605. file.Read(&Options.Ghosts, sizeof(Options.Ghosts));
  606. file.Read(&Options.UnitCount, sizeof(Options.UnitCount));
  607. file.Read(&Options.AIPlayers, sizeof(Options.AIPlayers));
  608. file.Read(&ObiWan, sizeof(ObiWan));
  609. file.Read(&EmergencySave, sizeof(EmergencySave));
  610. file.Read(&count, sizeof(count));
  611. for (i = 0; i < count; i++) {
  612. node = new NodeNameType;
  613. file.Read(node, sizeof(NodeNameType));
  614. Players.Add(node);
  615. }
  616. return (1);
  617. } // end of Load
  618. /***************************************************************************
  619. * SessionClass::Read_MultiPlayer_Settings -- reads settings INI *
  620. * *
  621. * INPUT: *
  622. * none. *
  623. * *
  624. * OUTPUT: *
  625. * none. *
  626. * *
  627. * WARNINGS: *
  628. * none. *
  629. * *
  630. * HISTORY: *
  631. * 02/14/1995 BR : Created. *
  632. *=========================================================================*/
  633. void SessionClass::Read_MultiPlayer_Settings (void)
  634. {
  635. #if (0)//PG
  636. char *tokenptr; // ptr to token
  637. PhoneEntryClass *phone; // a phone book entry
  638. char *entry; // a phone book entry
  639. char buf[128]; // buffer for parsing INI entry
  640. int i;
  641. CELL cell;
  642. // CCFileClass file (CONFIG_FILE_NAME);
  643. //------------------------------------------------------------------------
  644. // Clear the initstring entries
  645. //------------------------------------------------------------------------
  646. for (i = 0; i < InitStrings.Count(); i++) {
  647. delete[] InitStrings[i];
  648. }
  649. InitStrings.Clear();
  650. // Clear the dialing entries
  651. for (i = 0; i < PhoneBook.Count(); i++) {
  652. delete[] PhoneBook[i];
  653. }
  654. PhoneBook.Clear();
  655. // Create filename and read the file.
  656. INIClass ini;
  657. if (ini.Load(RawFileClass(CONFIG_FILE_NAME))) {
  658. // Get the player's last-used Handle
  659. ini.Get_String("MultiPlayer", "Handle", "Noname", Handle, sizeof(Handle));
  660. // Get the player's last-used Color
  661. PrefColor = (PlayerColorType)ini.Get_Int("MultiPlayer", "Color", 0);
  662. #ifdef FIXIT_VERSION_3
  663. int iSide = ini.Get_Int("MultiPlayer", "Side", HOUSE_USSR);
  664. iSide = max( 2, min( 6, iSide ) );
  665. House = (HousesType)iSide;
  666. #else
  667. House = (HousesType)ini.Get_Int("MultiPlayer", "Side", HOUSE_USSR);
  668. #endif
  669. CurPhoneIdx = ini.Get_Int("MultiPlayer", "PhoneIndex", -1);
  670. TrapCheckHeap = ini.Get_Int("MultiPlayer", "CheckHeap", 0);
  671. // Read in default serial settings
  672. ini.Get_String("SerialDefaults", "ModemName", "NoName", SerialDefaults.ModemName, MODEM_NAME_MAX);
  673. if (!strcmp ( SerialDefaults.ModemName, "NoName")) {
  674. SerialDefaults.ModemName[0] = 0;
  675. }
  676. SerialDefaults.Port = ini.Get_Int("SerialDefaults", "Port", 0);
  677. SerialDefaults.IRQ = ini.Get_Int("SerialDefaults", "IRQ", -1);
  678. SerialDefaults.Baud = ini.Get_Int("SerialDefaults", "Baud", -1);
  679. SerialDefaults.Compression = ini.Get_Int ("SerialDefaults", "Compression", 0);
  680. SerialDefaults.ErrorCorrection = ini.Get_Int ("SerialDefaults", "ErrorCorrection", 0);
  681. SerialDefaults.HardwareFlowControl = ini.Get_Int ("SerialDefaults", "HardwareFlowControl", 1);
  682. ini.Get_String("SerialDefaults", "DialMethod", "T", buf, 2);
  683. #ifndef WIN32
  684. /*
  685. ** Ignore any modem name in DOS. This should only be nessasary if the user
  686. ** previously set up the modem in the windows version.
  687. */
  688. if (SerialDefaults.ModemName[0] && SerialDefaults.Port == 1) {
  689. SerialDefaults.Port = 0x3F8;
  690. SerialDefaults.ModemName[0] = 0;
  691. }
  692. #endif //WIN32
  693. // find dial method
  694. for (i = 0; i < DIAL_METHODS; i++) {
  695. if ( !strcmpi( buf, DialMethodCheck[ i ]) ) {
  696. SerialDefaults.DialMethod = (DialMethodType)i;
  697. break;
  698. }
  699. }
  700. // if method not found set to touch tone
  701. if (i == DIAL_METHODS) {
  702. SerialDefaults.DialMethod = DIAL_TOUCH_TONE;
  703. }
  704. SerialDefaults.InitStringIndex = ini.Get_Int("SerialDefaults", "InitStringIndex", 0);
  705. SerialDefaults.CallWaitStringIndex = ini.Get_Int("SerialDefaults", "CallWaitStringIndex", CALL_WAIT_CUSTOM);
  706. ini.Get_String("SerialDefaults", "CallWaitString", "", SerialDefaults.CallWaitString, CWAITSTRBUF_MAX);
  707. if (SerialDefaults.IRQ == 0 || SerialDefaults.Baud == 0) {
  708. SerialDefaults.Port = 0;
  709. SerialDefaults.IRQ = -1;
  710. SerialDefaults.Baud = -1;
  711. }
  712. int initcount = ini.Entry_Count("InitStrings");
  713. for (int index = 0; index < initcount; index++) {
  714. entry = new char[ INITSTRBUF_MAX ];
  715. entry[0] = 0;
  716. ini.Get_String("InitStrings", ini.Get_Entry("InitStrings", index), NULL, entry, INITSTRBUF_MAX);
  717. strupr( entry );
  718. InitStrings.Add( entry );
  719. }
  720. // if no entries then have at least one
  721. if (initcount == 0) {
  722. entry = new char[ INITSTRBUF_MAX ];
  723. strcpy( entry, "ATZ" );
  724. InitStrings.Add( entry );
  725. SerialDefaults.InitStringIndex = 0;
  726. }
  727. // Read the entry names in
  728. int phonecount = ini.Entry_Count("PhoneBook");
  729. for (int index = 0; index < phonecount; index++) {
  730. // Create a new phone book entry
  731. phone = new PhoneEntryClass();
  732. // Read the entire entry in
  733. ini.Get_String("PhoneBook", ini.Get_Entry("PhoneBook", index), NULL, buf, sizeof(buf));
  734. // Extract name, phone # & serial port settings
  735. tokenptr = strtok( buf, "|" );
  736. if (tokenptr) {
  737. strcpy( phone->Name, tokenptr );
  738. strupr( phone->Name );
  739. } else {
  740. phone->Name[0] = 0;
  741. }
  742. tokenptr = strtok( NULL, "|" );
  743. if (tokenptr) {
  744. strcpy( phone->Number, tokenptr );
  745. strupr( phone->Number );
  746. } else {
  747. phone->Number[0] = 0;
  748. }
  749. tokenptr = strtok( NULL, "|" );
  750. if (tokenptr) {
  751. sscanf( tokenptr, "%x", &phone->Settings.Port );
  752. } else {
  753. phone->Settings.Port = 0;
  754. }
  755. tokenptr = strtok( NULL, "|" );
  756. if (tokenptr) {
  757. phone->Settings.IRQ = atoi( tokenptr );
  758. } else {
  759. phone->Settings.IRQ = -1;
  760. }
  761. tokenptr = strtok( NULL, "|" );
  762. if (tokenptr) {
  763. phone->Settings.Baud = atoi( tokenptr );
  764. } else {
  765. phone->Settings.Baud = -1;
  766. }
  767. phone->Settings.Compression = 0;
  768. phone->Settings.ErrorCorrection = 0;
  769. phone->Settings.HardwareFlowControl = 1;
  770. /*
  771. ** Find out if this phonebook entry has the new settings included. If not
  772. ** then we need to skip this section.
  773. */
  774. tokenptr = strtok( NULL, "|" );
  775. if (tokenptr){
  776. strcpy( buf, tokenptr );
  777. // find dial method
  778. for (i = 0; i < DIAL_METHODS; i++) {
  779. if ( !strcmpi( buf, DialMethodCheck[ i ]) ) {
  780. /*
  781. ** This must be an old phonebook entry
  782. */
  783. break;
  784. }
  785. }
  786. /*
  787. ** Method wasnt found - assume its a new phonebook entry so get the extra settings
  788. */
  789. // if method not found set to touch tone
  790. if (i == DIAL_METHODS) {
  791. phone->Settings.Compression = atoi( tokenptr );
  792. tokenptr = strtok( NULL, "|" );
  793. if (tokenptr) {
  794. phone->Settings.ErrorCorrection = atoi( tokenptr );
  795. }
  796. tokenptr = strtok( NULL, "|" );
  797. if (tokenptr) {
  798. phone->Settings.HardwareFlowControl = atoi( tokenptr );
  799. }
  800. tokenptr = strtok( NULL, "|" );
  801. }
  802. }
  803. if (tokenptr) {
  804. strcpy( buf, tokenptr );
  805. // find dial method
  806. for (i = 0; i < DIAL_METHODS; i++) {
  807. if ( !strcmpi( buf, DialMethodCheck[ i ]) ) {
  808. phone->Settings.DialMethod = (DialMethodType)i;
  809. break;
  810. }
  811. }
  812. // if method not found set to touch tone
  813. if (i == DIAL_METHODS) {
  814. phone->Settings.DialMethod = DIAL_TOUCH_TONE;
  815. }
  816. } else {
  817. phone->Settings.DialMethod = DIAL_TOUCH_TONE;
  818. }
  819. tokenptr = strtok( NULL, "|" );
  820. if (tokenptr) {
  821. phone->Settings.InitStringIndex = atoi( tokenptr );
  822. } else {
  823. phone->Settings.InitStringIndex = 0;
  824. }
  825. tokenptr = strtok( NULL, "|" );
  826. if (tokenptr) {
  827. phone->Settings.CallWaitStringIndex = atoi( tokenptr );
  828. } else {
  829. phone->Settings.CallWaitStringIndex = CALL_WAIT_CUSTOM;
  830. }
  831. tokenptr = strtok( NULL, "|" );
  832. if (tokenptr) {
  833. strcpy (phone->Settings.CallWaitString, tokenptr);
  834. } else {
  835. phone->Settings.CallWaitString[0] = 0;
  836. }
  837. // Add it to our list
  838. PhoneBook.Add(phone);
  839. }
  840. // Read special recording playback values, to help find sync bugs
  841. TrapFrame = ini.Get_Int("SyncBug", "Frame", 0x7fffffff);
  842. ini.Get_String("SyncBug", "Type", "NONE", buf, 80);
  843. if (!stricmp(buf,"AIRCRAFT"))
  844. TrapObjType = RTTI_AIRCRAFT;
  845. else if (!stricmp(buf,"ANIM"))
  846. TrapObjType = RTTI_ANIM;
  847. else if (!stricmp(buf,"BUILDING"))
  848. TrapObjType = RTTI_BUILDING;
  849. else if (!stricmp(buf,"BULLET"))
  850. TrapObjType = RTTI_BULLET;
  851. else if (!stricmp(buf,"INFANTRY"))
  852. TrapObjType = RTTI_INFANTRY;
  853. else if (!stricmp(buf,"UNIT"))
  854. TrapObjType = RTTI_UNIT;
  855. else {
  856. TrapObjType = RTTI_NONE;
  857. }
  858. ini.Get_String("SyncBug", "Coord", "0", buf, 80);
  859. sscanf(buf,"%x",&TrapCoord);
  860. ini.Get_String("SyncBug", "Target", "0", buf, 80);
  861. sscanf(buf,"%x",&TrapTarget);
  862. ini.Get_String("SyncBug", "Cell", "0", buf, 80);
  863. cell = atoi(buf);
  864. if (cell) {
  865. TrapCell = &(Map[cell]);
  866. }
  867. TrapPrintCRC = ini.Get_Int("SyncBug", "PrintCRC", 0x7fffffff);
  868. }
  869. #endif
  870. }
  871. /***************************************************************************
  872. * SessionClass::Write_MultiPlayer_Settings -- writes settings INI *
  873. * *
  874. * INPUT: *
  875. * none. *
  876. * *
  877. * OUTPUT: *
  878. * none. *
  879. * *
  880. * WARNINGS: *
  881. * none. *
  882. * *
  883. * HISTORY: *
  884. * 02/14/1995 BR : Created. *
  885. *=========================================================================*/
  886. void SessionClass::Write_MultiPlayer_Settings (void)
  887. {
  888. #ifdef NEVER
  889. char * buffer; // INI staging buffer pointer.
  890. CCFileClass file;
  891. int i;
  892. char entrytext[4];
  893. char buf[128]; // buffer for parsing INI entry
  894. //------------------------------------------------------------------------
  895. // Get a working pointer to the INI staging buffer. Make sure that the
  896. // buffer starts cleared out of any data.
  897. //------------------------------------------------------------------------
  898. buffer = (char *)_ShapeBuffer;
  899. memset(buffer, '\0', _ShapeBufferSize);
  900. file.Set_Name(CONFIG_FILE_NAME);
  901. if (file.Is_Available()) {
  902. file.Open(READ);
  903. file.Read(buffer, _ShapeBufferSize-1);
  904. file.Close();
  905. }
  906. //------------------------------------------------------------------------
  907. // Save the player's last-used Handle & Color
  908. //------------------------------------------------------------------------
  909. WWWritePrivateProfileInt("MultiPlayer", "PhoneIndex", CurPhoneIdx, buffer);
  910. WWWritePrivateProfileInt ("MultiPlayer", "Color", (int)PrefColor, buffer);
  911. WWWritePrivateProfileInt ("MultiPlayer", "Side", House, buffer);
  912. WWWritePrivateProfileString("MultiPlayer", "Handle", Handle, buffer);
  913. //------------------------------------------------------------------------
  914. // Clear all existing Settings.SerialDefault entries.
  915. //------------------------------------------------------------------------
  916. WWWritePrivateProfileString ("SerialDefaults", NULL, NULL, buffer);
  917. //------------------------------------------------------------------------
  918. // Save default serial settings in opposite order you want to see them
  919. //------------------------------------------------------------------------
  920. WWWritePrivateProfileString("SerialDefaults", "CallWaitString", SerialDefaults.CallWaitString, buffer);
  921. WWWritePrivateProfileInt ("SerialDefaults", "CallWaitStringIndex", SerialDefaults.CallWaitStringIndex, buffer);
  922. WWWritePrivateProfileInt ("SerialDefaults", "InitStringIndex", SerialDefaults.InitStringIndex, buffer);
  923. WWWritePrivateProfileString("SerialDefaults", "DialMethod", DialMethodCheck[ SerialDefaults.DialMethod ], buffer);
  924. WWWritePrivateProfileInt ("SerialDefaults", "Baud", SerialDefaults.Baud, buffer);
  925. WWWritePrivateProfileInt ("SerialDefaults", "IRQ", SerialDefaults.IRQ, buffer);
  926. sprintf(buf, "%x", SerialDefaults.Port);
  927. WWWritePrivateProfileString("SerialDefaults", "Port", buf, buffer);
  928. WWWritePrivateProfileInt ("SerialDefaults", "Compression", SerialDefaults.Compression , buffer);
  929. WWWritePrivateProfileInt ("SerialDefaults", "ErrorCorrection", SerialDefaults.ErrorCorrection, buffer);
  930. WWWritePrivateProfileInt ("SerialDefaults", "HardwareFlowControl", SerialDefaults.HardwareFlowControl, buffer);
  931. //------------------------------------------------------------------------
  932. // Clear all existing InitString entries.
  933. //------------------------------------------------------------------------
  934. WWWritePrivateProfileString ("InitStrings", NULL, NULL, buffer);
  935. //------------------------------------------------------------------------
  936. // Save all InitString entries. In descending order so they come out in
  937. // ascending order.
  938. //------------------------------------------------------------------------
  939. for (i = (InitStrings.Count() - 1); i >= 0; i--) {
  940. sprintf( buf, "%03d", i);
  941. WWWritePrivateProfileString ("InitStrings", buf, InitStrings[i], buffer);
  942. }
  943. //------------------------------------------------------------------------
  944. // Clear all existing Phone Book entries.
  945. //------------------------------------------------------------------------
  946. WWWritePrivateProfileString ("PhoneBook", NULL, NULL, buffer);
  947. //------------------------------------------------------------------------
  948. // Save all Phone Book entries.
  949. // Format: Entry=Name,PhoneNum,Port,IRQ,Baud,InitString
  950. //------------------------------------------------------------------------
  951. for (i = (PhoneBook.Count() - 1); i >= 0; i--) {
  952. sprintf(buf,"%s|%s|%x|%d|%d|%d|%d|%d|%s|%d|%d|%s",
  953. PhoneBook[i]->Name,
  954. PhoneBook[i]->Number,
  955. PhoneBook[i]->Settings.Port,
  956. PhoneBook[i]->Settings.IRQ,
  957. PhoneBook[i]->Settings.Baud,
  958. PhoneBook[i]->Settings.Compression,
  959. PhoneBook[i]->Settings.ErrorCorrection,
  960. PhoneBook[i]->Settings.HardwareFlowControl,
  961. DialMethodCheck[ PhoneBook[i]->Settings.DialMethod ],
  962. PhoneBook[i]->Settings.InitStringIndex,
  963. PhoneBook[i]->Settings.CallWaitStringIndex,
  964. PhoneBook[i]->Settings.CallWaitString);
  965. sprintf( entrytext, "%03d", i );
  966. WWWritePrivateProfileString ("PhoneBook", entrytext, buf, buffer);
  967. }
  968. //------------------------------------------------------------------------
  969. // Write the INI data out to a file.
  970. //------------------------------------------------------------------------
  971. file.Open(WRITE);
  972. file.Write(buffer,strlen(buffer));
  973. file.Close();
  974. #endif
  975. #if (0)//PG
  976. INIClass ini;
  977. RawFileClass file(CONFIG_FILE_NAME);
  978. if (ini.Load(file)) {
  979. // Save the player's last-used Handle & Color
  980. ini.Put_Int("MultiPlayer", "PhoneIndex", CurPhoneIdx);
  981. ini.Put_Int("MultiPlayer", "Color", (int)PrefColor);
  982. ini.Put_Int("MultiPlayer", "Side", House);
  983. ini.Put_String("MultiPlayer", "Handle", Handle);
  984. // Clear all existing Settings.SerialDefault entries.
  985. ini.Clear("SerialDefaults");
  986. // Save default serial settings in opposite order you want to see them
  987. ini.Put_String("SerialDefaults", "CallWaitString", SerialDefaults.CallWaitString);
  988. ini.Put_Int("SerialDefaults", "CallWaitStringIndex", SerialDefaults.CallWaitStringIndex);
  989. ini.Put_Int("SerialDefaults", "InitStringIndex", SerialDefaults.InitStringIndex);
  990. ini.Put_String("SerialDefaults", "DialMethod", DialMethodCheck[ SerialDefaults.DialMethod ]);
  991. ini.Put_Int("SerialDefaults", "Baud", SerialDefaults.Baud);
  992. ini.Put_Int("SerialDefaults", "IRQ", SerialDefaults.IRQ);
  993. ini.Put_Int("SerialDefaults", "Port", SerialDefaults.Port, 1);
  994. ini.Put_String("SerialDefaults", "ModemName", SerialDefaults.ModemName);
  995. ini.Put_Int ("SerialDefaults", "Compression", SerialDefaults.Compression );
  996. ini.Put_Int ("SerialDefaults", "ErrorCorrection", SerialDefaults.ErrorCorrection );
  997. ini.Put_Int ("SerialDefaults", "HardwareFlowControl", SerialDefaults.HardwareFlowControl );
  998. // Clear all existing InitString entries.
  999. ini.Clear("InitStrings");
  1000. // Save all InitString entries.
  1001. for (int index = 0; index < InitStrings.Count(); index++) {
  1002. char buf[10];
  1003. sprintf( buf, "%03d", index);
  1004. ini.Put_String("InitStrings", buf, InitStrings[index]);
  1005. }
  1006. // Clear all existing Phone Book entries.
  1007. ini.Clear("PhoneBook");
  1008. // Save all Phone Book entries.
  1009. // Format: Entry=Name,PhoneNum,Port,IRQ,Baud,InitString
  1010. for (int i = (PhoneBook.Count() - 1); i >= 0; i--) {
  1011. char buf[128];
  1012. char entrytext[10];
  1013. sprintf(buf,"%s|%s|%x|%d|%d|%d|%d|%d|%s|%d|%d|%s",
  1014. PhoneBook[i]->Name,
  1015. PhoneBook[i]->Number,
  1016. PhoneBook[i]->Settings.Port,
  1017. PhoneBook[i]->Settings.IRQ,
  1018. PhoneBook[i]->Settings.Baud,
  1019. PhoneBook[i]->Settings.Compression,
  1020. PhoneBook[i]->Settings.ErrorCorrection,
  1021. PhoneBook[i]->Settings.HardwareFlowControl,
  1022. DialMethodCheck[ PhoneBook[i]->Settings.DialMethod ],
  1023. PhoneBook[i]->Settings.InitStringIndex,
  1024. PhoneBook[i]->Settings.CallWaitStringIndex,
  1025. PhoneBook[i]->Settings.CallWaitString);
  1026. sprintf( entrytext, "%03d", i );
  1027. ini.Put_String("PhoneBook", entrytext, buf);
  1028. }
  1029. // Write the INI data out to a file.
  1030. ini.Save(file);
  1031. }
  1032. #endif
  1033. }
  1034. // Determine if a mission is from counterstrike or aftermath, or either.
  1035. // Multiplayer maps >24, with a numerical name, are Counterstrike.
  1036. // Multiplayer maps with an alphabetical name, like SCMJGEA.INI, are Aftermath.
  1037. bool Is_Mission_Counterstrike (char *file_name)
  1038. {
  1039. int scenario_number = 0;
  1040. if ( isdigit ( file_name[5] )){
  1041. sscanf (file_name, "SCM%03d", &scenario_number);
  1042. } else {
  1043. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  1044. if (!isdigit(file_name[3]) || !isdigit(file_name[4])) {
  1045. return(false);
  1046. }
  1047. #endif
  1048. sscanf (file_name, "SCM%02d", &scenario_number);
  1049. }
  1050. return ( scenario_number > 24 );
  1051. }
  1052. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  1053. bool Is_Mission_Aftermath (char *file_name)
  1054. {
  1055. // ajw added
  1056. // Must start with "scm".
  1057. char szCopy[ _MAX_PATH + 1 ];
  1058. strcpy( szCopy, file_name );
  1059. _strlwr( szCopy );
  1060. if( strstr( szCopy, "scm" ) != szCopy )
  1061. return false;
  1062. if (isdigit(file_name[5])) {
  1063. return(false);
  1064. }
  1065. if ( !isdigit(file_name[3]) || !isdigit(file_name[4]) ) {
  1066. return (true);
  1067. }
  1068. return (false);
  1069. }
  1070. /*
  1071. ** Certain missions are 126x126 size, and those can't be downloaded to a
  1072. ** non-Aftermath player, so this function checks to see if the map in
  1073. ** question is one of those. We'll know that by the file name: if it's
  1074. ** K0 -> M9, it's 126x126.
  1075. */
  1076. bool Is_Mission_126x126 (char *file_name) // This is no longer used. ajw
  1077. {
  1078. if (isdigit(file_name[5])) {
  1079. return(false);
  1080. }
  1081. if ( (file_name[3] >= 'k' && file_name[3] <= 'm') ||
  1082. (file_name[3] >= 'K' && file_name[3] <= 'M') ) {
  1083. return (true);
  1084. }
  1085. return (false);
  1086. }
  1087. #endif
  1088. /***************************************************************************
  1089. * SessionClass::Read_Scenario_Descriptions -- reads scen. descriptions *
  1090. * *
  1091. * INPUT: *
  1092. * none. *
  1093. * *
  1094. * OUTPUT: *
  1095. * none. *
  1096. * *
  1097. * WARNINGS: *
  1098. * none. *
  1099. * *
  1100. * HISTORY: *
  1101. * 02/14/1995 BR : Created. *
  1102. * 09/10/1996 JLB : Searches using different method. *
  1103. *=========================================================================*/
  1104. void SessionClass::Read_Scenario_Descriptions (void)
  1105. {
  1106. // Clear the scenario description lists
  1107. Scenarios.Clear();
  1108. /*
  1109. ** Fetch the main multiplayer scenario packet data.
  1110. */
  1111. CCFileClass file("MISSIONS.PKT");
  1112. if (file.Is_Available()) {
  1113. INIClass ini;
  1114. ini.Load(file);
  1115. int count = ini.Entry_Count("Missions");
  1116. //debugprint( "Found %i missions in Missions.pkt\n", count );
  1117. for (int index = 0; index < count; index++) {
  1118. char const * fname = ini.Get_Entry("Missions", index);
  1119. char buffer[128];
  1120. ini.Get_String("Missions", fname, "", buffer, sizeof(buffer));
  1121. #ifdef FIXIT_VERSION_3
  1122. Scenarios.Add(new MultiMission(fname, buffer, NULL, true,
  1123. Is_Mission_Counterstrike ((char*)fname)));
  1124. #else // FIXIT_VERSION_3
  1125. #ifdef FIXIT_CSII // checked - ajw
  1126. bool official = Is_Mission_126x126( (char *)fname);
  1127. if (!official) {
  1128. official = !Is_Mission_Aftermath((char *)fname);
  1129. }
  1130. Scenarios.Add(new MultiMission(fname, buffer, NULL, official,
  1131. Is_Mission_Counterstrike ((char*)fname)));
  1132. #else
  1133. Scenarios.Add(new MultiMission(fname, buffer, NULL, true,
  1134. Is_Mission_Counterstrike ((char*)fname)));
  1135. #endif
  1136. #endif // FIXIT_VERSION_3
  1137. }
  1138. /* // ajw Copy file for viewing.
  1139. CCFileClass fileCopy( "msns_pkt.txt" );
  1140. file.Seek( 0, SEEK_SET );
  1141. long lSize = file.Size();
  1142. char* pData = new char[ lSize + 1 ];
  1143. file.Read( pData, lSize );
  1144. fileCopy.Write( pData, lSize );
  1145. fileCopy.Close();
  1146. */ }
  1147. /*
  1148. ** Fetch any scenario packet lists and apply them first.
  1149. */
  1150. #ifdef WIN32
  1151. WIN32_FIND_DATA block;
  1152. HANDLE handle = FindFirstFile("*.PKT", &block);
  1153. while (handle != INVALID_HANDLE_VALUE) {
  1154. if ((block.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY)) == 0) {
  1155. char const * name = &block.cAlternateFileName[0];
  1156. if (*name == '\0') name = &block.cFileName[0];
  1157. //Mono_Printf("Found file '%s'.\n", block.cAlternateFileName);
  1158. //Mono_Printf("Found file '%s'.\n", block.cFileName);
  1159. //debugprint("Found file '%s'.\n", block.cAlternateFileName);
  1160. //debugprint("Found file '%s'.\n", block.cFileName);
  1161. //debugprint( "Found alternate PKT file.\n" );
  1162. CCFileClass file(name);
  1163. INIClass ini;
  1164. ini.Load(file);
  1165. int count = ini.Entry_Count("Missions");
  1166. for (int index = 0; index < count; index++) {
  1167. char const * fname = ini.Get_Entry("Missions", index);
  1168. char buffer[128];
  1169. ini.Get_String("Missions", fname, "", buffer, sizeof(buffer));
  1170. #ifdef FIXIT_VERSION_3
  1171. Scenarios.Add(new MultiMission(fname, buffer, NULL, true,
  1172. Is_Mission_Counterstrike ((char*)fname)));
  1173. #else // FIXIT_VERSION_3
  1174. #ifdef FIXIT_CSII // checked - ajw
  1175. bool official = Is_Mission_126x126( (char *)fname);
  1176. if (!official) {
  1177. official = !Is_Mission_Aftermath((char *)fname);
  1178. }
  1179. Scenarios.Add(new MultiMission(fname, buffer, NULL, official,
  1180. Is_Mission_Counterstrike ((char*)fname)));
  1181. #else
  1182. Scenarios.Add(new MultiMission(fname, buffer, NULL, true,
  1183. Is_Mission_Counterstrike ((char*)fname)));
  1184. #endif
  1185. #endif // FIXIT_VERSION_3
  1186. }
  1187. }
  1188. if (FindNextFile(handle, &block) == 0) break;
  1189. }
  1190. #ifdef FIXIT_CSII // checked - ajw
  1191. /*
  1192. ** Fetch the Counterstrike multiplayer scenario packet data.
  1193. ** Load the scenarios regardless of whether counterstrike's installed,
  1194. ** and at the point of hosting a network game, enable the counterstrike
  1195. ** maps only if they have CS installed. If they don't, then the maps
  1196. ** are available as a guest, but not as a host, which fixes a multitude
  1197. ** of problems without obviously giving the maps away to non-CS owners.
  1198. */
  1199. #ifdef FIXIT_VERSION_3
  1200. if( Is_Counterstrike_Installed() )
  1201. {
  1202. #endif
  1203. CCFileClass file2("CSTRIKE.PKT");
  1204. if (file2.Is_Available()) {
  1205. INIClass ini;
  1206. ini.Load(file2);
  1207. int count = ini.Entry_Count("Missions");
  1208. //debugprint( "Found %i missions in cstrike.pkt\n", count );
  1209. for (int index = 0; index < count; index++) {
  1210. char const * fname = ini.Get_Entry("Missions", index);
  1211. char buffer[128];
  1212. ini.Get_String("Missions", fname, "", buffer, sizeof(buffer));
  1213. #ifdef FIXIT_VERSION_3
  1214. Scenarios.Add(new MultiMission(fname, buffer, NULL, true,
  1215. Is_Mission_Counterstrike ((char*)fname)));
  1216. #else
  1217. bool official = Is_Mission_126x126( (char *)fname);
  1218. if (!official) {
  1219. official = !Is_Mission_Aftermath((char *)fname);
  1220. }
  1221. Scenarios.Add(new MultiMission(fname, buffer, NULL, official,
  1222. Is_Mission_Counterstrike ((char*)fname)));
  1223. #endif
  1224. }
  1225. /* // ajw Copy file for viewing.
  1226. CCFileClass fileCopy( "cs_pkt.txt" );
  1227. file2.Seek( 0, SEEK_SET );
  1228. long lSize = file2.Size();
  1229. char* pData = new char[ lSize + 1 ];
  1230. file2.Read( pData, lSize );
  1231. fileCopy.Write( pData, lSize );
  1232. fileCopy.Close();
  1233. */ }
  1234. #ifdef FIXIT_VERSION_3
  1235. }
  1236. #endif
  1237. #endif
  1238. #ifdef FIXIT_VERSION_3 // Aftermath scenarios are now in their own pkt file.
  1239. if( Is_Aftermath_Installed() )
  1240. {
  1241. CCFileClass file2("AFTMATH.PKT");
  1242. if (file2.Is_Available()) {
  1243. INIClass ini;
  1244. ini.Load(file2);
  1245. int count = ini.Entry_Count("Missions");
  1246. //debugprint( "Found %i missions in aftmath.pkt\n", count );
  1247. for (int index = 0; index < count; index++) {
  1248. char const * fname = ini.Get_Entry("Missions", index);
  1249. char buffer[128];
  1250. ini.Get_String("Missions", fname, "", buffer, sizeof(buffer));
  1251. Scenarios.Add(new MultiMission(fname, buffer, NULL, true,
  1252. Is_Mission_Counterstrike ((char*)fname)));
  1253. }
  1254. }
  1255. }
  1256. #endif
  1257. /*
  1258. ** Scan the current directory for any loose .MPR files and build the appropriate entries
  1259. ** into the scenario list list
  1260. */
  1261. char const * file_name;
  1262. char name_buffer[128];
  1263. char digest_buffer[32];
  1264. handle = FindFirstFile ( "*.MPR" , &block );
  1265. while (handle != INVALID_HANDLE_VALUE) {
  1266. if ((block.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY)) == 0) {
  1267. file_name = &block.cAlternateFileName[0];
  1268. if (*file_name == '\0') file_name = &block.cFileName[0];
  1269. //debugprint( "Found MPR '%s'\n", file_name );
  1270. CCFileClass file(file_name);
  1271. INIClass ini;
  1272. ini.Load(file);
  1273. ini.Get_String ("Basic", "Name", "No Name", name_buffer, sizeof (name_buffer) );
  1274. ini.Get_String ("Digest", "1", "No Digest", digest_buffer, sizeof (digest_buffer) );
  1275. Scenarios.Add (new MultiMission (file_name, name_buffer, digest_buffer,ini.Get_Bool("Basic", "Official", false), false ));
  1276. }
  1277. if (FindNextFile(handle, &block) == 0) break;
  1278. }
  1279. #else //WIN32
  1280. #error What? You think you can still build the DOS version after all this time?
  1281. char name_buffer[128];
  1282. char digest_buffer[32];
  1283. struct find_t block;
  1284. if (_dos_findfirst("*.PKT", _A_NORMAL, &block) == 0) {
  1285. do {
  1286. CCFileClass file(block.name);
  1287. INIClass ini;
  1288. ini.Load(file);
  1289. int count = ini.Entry_Count("Missions");
  1290. for (int index = 0; index < count; index++) {
  1291. char const * fname = ini.Get_Entry("Missions", index);
  1292. char buffer[128];
  1293. ini.Get_String("Missions", fname, "", buffer, sizeof(buffer));
  1294. #ifdef FIXIT_CSII
  1295. bool official = Is_Mission_126x126( (char *)fname);
  1296. if (!official) {
  1297. official = !Is_Mission_Aftermath((char *)fname);
  1298. }
  1299. Scenarios.Add(new MultiMission(fname, buffer, NULL, official,
  1300. Is_Mission_Counterstrike ((char*)fname)));
  1301. #else
  1302. Scenarios.Add(new MultiMission(fname, buffer, NULL, true,
  1303. Is_Mission_Counterstrike ((char*)fname)));
  1304. #endif
  1305. }
  1306. } while(_dos_findnext(&block) == 0);
  1307. }
  1308. /*
  1309. ** Scan the current directory for any loose .MPR files and build the appropriate entries
  1310. ** into the scenario list list
  1311. */
  1312. if (_dos_findfirst("*.MPR", _A_NORMAL, &block) == 0) {
  1313. do {
  1314. CCFileClass file(block.name);
  1315. INIClass ini;
  1316. ini.Load(file);
  1317. ini.Get_String ("Basic", "Name", "No Name", name_buffer, sizeof (name_buffer) );
  1318. ini.Get_String ("Digest", "1", "No Digest", digest_buffer, sizeof (digest_buffer) );
  1319. bool official = ini.Get_Bool("Basic", "Official", false);
  1320. Scenarios.Add (new MultiMission (block.name, name_buffer, digest_buffer, official, false ));
  1321. } while(_dos_findnext(&block) == 0);
  1322. }
  1323. #ifdef FIXIT_CSII
  1324. /*
  1325. ** Fetch the Counterstrike multiplayer scenario packet data.
  1326. ** Load the scenarios regardless of whether counterstrike's installed,
  1327. ** and at the point of hosting a network game, enable the counterstrike
  1328. ** maps only if they have CS installed. If they don't, then the maps
  1329. ** are available as a guest, but not as a host, which fixes a multitude
  1330. ** of problems without obviously giving the maps away to non-CS owners.
  1331. */
  1332. // if (Is_Counterstrike_Installed()) {
  1333. CCFileClass file2("CSTRIKE.PKT");
  1334. if (file2.Is_Available()) {
  1335. INIClass ini;
  1336. ini.Load(file2);
  1337. int count = ini.Entry_Count("Missions");
  1338. for (int index = 0; index < count; index++) {
  1339. char const * fname = ini.Get_Entry("Missions", index);
  1340. char buffer[128];
  1341. ini.Get_String("Missions", fname, "", buffer, sizeof(buffer));
  1342. bool official = Is_Mission_126x126( (char *)fname);
  1343. if (!official) {
  1344. official = !Is_Mission_Aftermath((char *)fname);
  1345. }
  1346. Scenarios.Add(new MultiMission(fname, buffer, NULL, official,
  1347. Is_Mission_Counterstrike ((char*)fname)));
  1348. }
  1349. }
  1350. // }
  1351. #endif
  1352. #endif //WIN32
  1353. }
  1354. /***************************************************************************
  1355. * SessionClass::Free_Scenario_Descriptions -- frees scen. descriptions *
  1356. * *
  1357. * INPUT: *
  1358. * none. *
  1359. * *
  1360. * OUTPUT: *
  1361. * none. *
  1362. * *
  1363. * WARNINGS: *
  1364. * none. *
  1365. * *
  1366. * HISTORY: *
  1367. * 06/05/1995 BRR : Created. *
  1368. *=========================================================================*/
  1369. void SessionClass::Free_Scenario_Descriptions(void)
  1370. {
  1371. int i;
  1372. //------------------------------------------------------------------------
  1373. // Clear the scenario descriptions & filenames
  1374. //------------------------------------------------------------------------
  1375. for (int index = 0; index < Scenarios.Count(); index++) {
  1376. delete Scenarios[index];
  1377. }
  1378. Scenarios.Clear();
  1379. // Filenum.Clear();
  1380. //------------------------------------------------------------------------
  1381. // Clear the initstring entries
  1382. //------------------------------------------------------------------------
  1383. for (i = 0; i < InitStrings.Count(); i++) {
  1384. delete InitStrings[i];
  1385. }
  1386. InitStrings.Clear();
  1387. #if (0)//PG
  1388. //------------------------------------------------------------------------
  1389. // Clear the dialing entries
  1390. //------------------------------------------------------------------------
  1391. for (i = 0; i < PhoneBook.Count(); i++) {
  1392. delete PhoneBook[i];
  1393. }
  1394. PhoneBook.Clear();
  1395. #endif
  1396. } /* end of Free_Scenario_Descriptions */
  1397. /***************************************************************************
  1398. * SessionClass::Trap_Object -- searches for an object, for debugging *
  1399. * *
  1400. * INPUT: *
  1401. * none. *
  1402. * *
  1403. * OUTPUT: *
  1404. * none. *
  1405. * *
  1406. * WARNINGS: *
  1407. * none. *
  1408. * *
  1409. * HISTORY: *
  1410. * 06/02/1995 BRR : Created. *
  1411. *=========================================================================*/
  1412. void SessionClass::Trap_Object(void)
  1413. {
  1414. int i;
  1415. //------------------------------------------------------------------------
  1416. // Initialize
  1417. //------------------------------------------------------------------------
  1418. TrapObject.Ptr.All = NULL;
  1419. //------------------------------------------------------------------------
  1420. // Search for the object based upon its type, then its coordinate or
  1421. // 'this' pointer value.
  1422. //------------------------------------------------------------------------
  1423. switch (TrapObjType) {
  1424. case RTTI_AIRCRAFT:
  1425. for (i = 0; i < Aircraft.Count(); i++) {
  1426. if (Aircraft.Ptr(i)->Coord == TrapCoord ||
  1427. Aircraft.Ptr(i)->As_Target()==TrapTarget) {
  1428. TrapObject.Ptr.Aircraft = Aircraft.Ptr(i);
  1429. break;
  1430. }
  1431. }
  1432. break;
  1433. case RTTI_ANIM:
  1434. for (i = 0; i < Anims.Count(); i++) {
  1435. if (Anims.Ptr(i)->Coord == TrapCoord ||
  1436. Anims.Ptr(i)->As_Target()==TrapTarget) {
  1437. TrapObject.Ptr.Anim = Anims.Ptr(i);
  1438. break;
  1439. }
  1440. }
  1441. break;
  1442. case RTTI_BUILDING:
  1443. for (i = 0; i < Buildings.Count(); i++) {
  1444. if (Buildings.Ptr(i)->Coord == TrapCoord ||
  1445. Buildings.Ptr(i)->As_Target()==TrapTarget) {
  1446. TrapObject.Ptr.Building = Buildings.Ptr(i);
  1447. break;
  1448. }
  1449. }
  1450. break;
  1451. case RTTI_BULLET:
  1452. for (i = 0; i < Bullets.Count(); i++) {
  1453. if (Bullets.Ptr(i)->Coord == TrapCoord ||
  1454. Bullets.Ptr(i)->As_Target()==TrapTarget) {
  1455. TrapObject.Ptr.Bullet = Bullets.Ptr(i);
  1456. break;
  1457. }
  1458. }
  1459. break;
  1460. case RTTI_INFANTRY:
  1461. for (i = 0; i < Infantry.Count(); i++) {
  1462. if (Infantry.Ptr(i)->Coord == TrapCoord ||
  1463. Infantry.Ptr(i)->As_Target()==TrapTarget) {
  1464. TrapObject.Ptr.Infantry = Infantry.Ptr(i);
  1465. break;
  1466. }
  1467. }
  1468. break;
  1469. case RTTI_UNIT:
  1470. for (i = 0; i < Units.Count(); i++) {
  1471. if (Units.Ptr(i)->Coord == TrapCoord ||
  1472. Units.Ptr(i)->As_Target()==TrapTarget) {
  1473. TrapObject.Ptr.Unit = Units.Ptr(i);
  1474. break;
  1475. }
  1476. }
  1477. break;
  1478. //.....................................................................
  1479. // Last-ditch find-the-object-right-now-darnit loop
  1480. //.....................................................................
  1481. case RTTI_NONE:
  1482. for (i = 0; i < Aircraft.Count(); i++) {
  1483. if (Aircraft.Raw_Ptr(i)->Coord == TrapCoord ||
  1484. Aircraft.Raw_Ptr(i)->As_Target()==TrapTarget) {
  1485. TrapObject.Ptr.Aircraft = Aircraft.Raw_Ptr(i);
  1486. TrapObjType = RTTI_AIRCRAFT;
  1487. return;
  1488. }
  1489. }
  1490. for (i = 0; i < Anims.Count(); i++) {
  1491. if (Anims.Raw_Ptr(i)->Coord == TrapCoord ||
  1492. Anims.Raw_Ptr(i)->As_Target()==TrapTarget) {
  1493. TrapObject.Ptr.Anim = Anims.Raw_Ptr(i);
  1494. TrapObjType = RTTI_ANIM;
  1495. return;
  1496. }
  1497. }
  1498. for (i = 0; i < Buildings.Count(); i++) {
  1499. if (Buildings.Raw_Ptr(i)->Coord == TrapCoord ||
  1500. Buildings.Raw_Ptr(i)->As_Target()==TrapTarget) {
  1501. TrapObject.Ptr.Building = Buildings.Raw_Ptr(i);
  1502. TrapObjType = RTTI_BUILDING;
  1503. return;
  1504. }
  1505. }
  1506. for (i = 0; i < Bullets.Count(); i++) {
  1507. if (Bullets.Raw_Ptr(i)->Coord == TrapCoord ||
  1508. Bullets.Raw_Ptr(i)->As_Target()==TrapTarget) {
  1509. TrapObject.Ptr.Bullet = Bullets.Raw_Ptr(i);
  1510. TrapObjType = RTTI_BULLET;
  1511. return;
  1512. }
  1513. }
  1514. for (i = 0; i < Infantry.Count(); i++) {
  1515. if (Infantry.Raw_Ptr(i)->Coord == TrapCoord ||
  1516. Infantry.Raw_Ptr(i)->As_Target()==TrapTarget) {
  1517. TrapObject.Ptr.Infantry = Infantry.Raw_Ptr(i);
  1518. TrapObjType = RTTI_INFANTRY;
  1519. return;
  1520. }
  1521. }
  1522. for (i = 0; i < Units.Count(); i++) {
  1523. if (Units.Raw_Ptr(i)->Coord == TrapCoord ||
  1524. Units.Raw_Ptr(i)->As_Target()==TrapTarget) {
  1525. TrapObject.Ptr.Unit = Units.Raw_Ptr(i);
  1526. TrapObjType = RTTI_UNIT;
  1527. return;
  1528. }
  1529. }
  1530. default:
  1531. break;
  1532. }
  1533. }
  1534. /***************************************************************************
  1535. * SessionClass::Compute_Unique_ID -- computes unique local ID number *
  1536. * *
  1537. * INPUT: *
  1538. * none. *
  1539. * *
  1540. * OUTPUT: *
  1541. * none. *
  1542. * *
  1543. * WARNINGS: *
  1544. * none. *
  1545. * *
  1546. * HISTORY: *
  1547. * 12/07/1995 BRR : Created. *
  1548. *=========================================================================*/
  1549. unsigned long SessionClass::Compute_Unique_ID(void)
  1550. {
  1551. return 1;//PG
  1552. #if (0) //PG
  1553. time_t tm;
  1554. unsigned long id;
  1555. struct diskfree_t dtable;
  1556. char *path;
  1557. int i;
  1558. //------------------------------------------------------------------------
  1559. // Start with the seconds since Jan 1, 1970 (system local time)
  1560. //------------------------------------------------------------------------
  1561. time(&tm);
  1562. id = (unsigned long)tm;
  1563. //------------------------------------------------------------------------
  1564. // Now add in the free space on the hard drive
  1565. //------------------------------------------------------------------------
  1566. if (_dos_getdiskfree(3, &dtable) == 0) {
  1567. Add_CRC(&id, (unsigned long)dtable.avail_clusters);
  1568. Add_CRC(&id, (unsigned long)dtable.total_clusters);
  1569. Add_CRC(&id, (unsigned long)dtable.bytes_per_sector);
  1570. Add_CRC(&id, (unsigned long)dtable.sectors_per_cluster);
  1571. }
  1572. //------------------------------------------------------------------------
  1573. // Add in every byte in the user's path environment variable
  1574. //------------------------------------------------------------------------
  1575. path = getenv("PATH");
  1576. if (path) {
  1577. for (i = 0; i < strlen(path); i++) {
  1578. Add_CRC(&id, (unsigned long)path[i]);
  1579. }
  1580. }
  1581. return (id);
  1582. #endif
  1583. } // end of Compute_Unique_ID
  1584. MultiMission::MultiMission(char const * filename, char const * description, char const * digest, bool official, bool expansion)
  1585. {
  1586. Set_Filename(filename);
  1587. Set_Description(description);
  1588. Set_Digest(digest);
  1589. Set_Official(official);
  1590. Set_Expansion(expansion);
  1591. }
  1592. void MultiMission::Draw_It(int , int x, int y, int width, int height, bool selected, TextPrintType flags) const
  1593. {
  1594. RemapControlType * scheme = GadgetClass::Get_Color_Scheme();
  1595. static int _tabs[] = {35, 60, 80, 100};
  1596. if ((flags & 0x0F) == TPF_6PT_GRAD || (flags & 0x0F) == TPF_EFNT) {
  1597. if (selected) {
  1598. flags = flags | TPF_BRIGHT_COLOR;
  1599. LogicPage->Fill_Rect(x, y, x + width - 1, y + height - 1, scheme->Shadow);
  1600. } else {
  1601. if (!(flags & TPF_USE_GRAD_PAL)) {
  1602. flags = flags | TPF_MEDIUM_COLOR;
  1603. }
  1604. }
  1605. Conquer_Clip_Text_Print(ScenarioDescription, x, y, scheme, TBLACK, flags, width, _tabs);
  1606. } else {
  1607. Conquer_Clip_Text_Print(ScenarioDescription, x, y, (selected ? &ColorRemaps[PCOLOR_DIALOG_BLUE] : &ColorRemaps[PCOLOR_GREY]), TBLACK, flags, width, _tabs);
  1608. }
  1609. }
  1610. void MultiMission::Set_Description(char const * description)
  1611. {
  1612. if (description != NULL) {
  1613. strncpy(ScenarioDescription, description, ARRAY_SIZE(ScenarioDescription));
  1614. ScenarioDescription[ARRAY_SIZE(ScenarioDescription)-1] = '\0';
  1615. }
  1616. }
  1617. void MultiMission::Set_Filename(char const * filename)
  1618. {
  1619. if (filename != NULL) {
  1620. strncpy(Filename, filename, ARRAY_SIZE(Filename));
  1621. Filename[ARRAY_SIZE(Filename)-1] = '\0';
  1622. }
  1623. }
  1624. void MultiMission::Set_Digest(char const * digest)
  1625. {
  1626. if (digest != NULL) {
  1627. strncpy(Digest, digest, ARRAY_SIZE(Digest));
  1628. Digest[ARRAY_SIZE(Digest)-1] = '\0';
  1629. }
  1630. else
  1631. {
  1632. strcpy( Digest, "NODIGEST" );
  1633. }
  1634. }
  1635. void MultiMission::Set_Official (bool official)
  1636. {
  1637. IsOfficial = official;
  1638. }
  1639. void MultiMission::Set_Expansion (bool expansion)
  1640. {
  1641. IsExpansion = expansion;
  1642. }
  1643. /************************** end of session.cpp *****************************/