CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

FTIMER.H (3953B)


      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 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header:   F:\projects\c&c\vcs\code\ftimer.h_v   2.14   16 Oct 1995 16:47:28   JOE_BOSTIC  $ */
     17 /*********************************************************************************************** 
     18  ***              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               *** 
     19  *********************************************************************************************** 
     20  *                                                                                             * 
     21  *                 Project Name : Command & Conquer                                            * 
     22  *                                                                                             * 
     23  *                    File Name : FTIMER.H                                                     * 
     24  *                                                                                             * 
     25  *                   Programmer : Joe L. Bostic                                                * 
     26  *                                                                                             * 
     27  *                   Start Date : 03/16/95                                                     * 
     28  *                                                                                             * 
     29  *                  Last Update : March 16, 1995 [JLB]                                         * 
     30  *                                                                                             * 
     31  *---------------------------------------------------------------------------------------------* 
     32  * Functions:                                                                                  * 
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef FTIMER_H
     36 #define FTIMER_H
     37 
     38 /*
     39 **	This timer class is based around an external tick system. As such, it is inherently 
     40 **	in sync with any connected system (through network or modem) that also keeps the external
     41 **	tick system in sync. The game frame number is a good sync value.
     42 */
     43 class TCountDownTimerClass {
     44 	public:
     45 		// Constructor.  Timers set before low level init has been done will not
     46 		// be able to be 'Started' or 'on' until timer system is in place.	
     47 		TCountDownTimerClass(long set=0) {
     48 			Set(set);
     49 		};
     50 
     51 		// No destructor.
     52 		~TCountDownTimerClass(void) {}
     53 
     54 		operator long(void) const {return Time();};
     55 
     56 		// Public functions
     57 		void Set(long set) {
     58 			Started = Frame;
     59 			DelayTime = set;
     60 		};		// Set count down value.
     61 
     62 		void Clear(void) {
     63 			Started   = -1;
     64 			DelayTime = 0;
     65 		};
     66 		long Get_Start(void) const {
     67 			return(Started);
     68 		};
     69 		long Get_Delay(void) const {
     70 			return(DelayTime);
     71 		};
     72 		bool Active(void) const {
     73 			return(Started != -1);
     74 		};
     75 		int Expired(void) const {return (Time() == 0);};
     76 		long Time(void) const {
     77 			long remain = DelayTime - (Frame-Started);
     78 			if (remain < 0) remain = 0;
     79 			return(remain);
     80 		};			// Fetch current count down value.
     81 
     82 	protected:
     83 		long Started;				// Initial frame time start.
     84 		long DelayTime;			// Ticks remaining before countdown timer expires.
     85 };
     86 
     87 
     88 #endif