CnC_Remastered_Collection

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

FLY.CPP (7770B)


      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: /CounterStrike/FLY.CPP 1     3/03/97 10:24a 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 : FLY.CPP                                                      *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : April 24, 1994                                               *
     28  *                                                                                             *
     29  *                  Last Update : June 5, 1995 [JLB]                                           *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  *   FlyClass::Fly_Speed -- Sets the flying object to the speed specified.                     *
     34  *   FlyClass::Physics -- Performs vector physics (movement).                                  *
     35  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     36 
     37 #include	"function.h"
     38 
     39 
     40 /***********************************************************************************************
     41  * FlyClass::Physics -- Performs vector physics (movement).                                    *
     42  *                                                                                             *
     43  *    This routine performs movement (vector) physics. It takes the                            *
     44  *    specified location and moves it according to the facing and speed                        *
     45  *    of the vector. It returns the status of the move.                                        *
     46  *                                                                                             *
     47  * INPUT:   coord -- Reference to the coordinate that the vector will                          *
     48  *                   be applied to.                                                            *
     49  *                                                                                             *
     50  * OUTPUT:  Returns with the status of the vector physics. This could                          *
     51  *          range from no effect, to exiting the edge of the world.                            *
     52  *                                                                                             *
     53  * WARNINGS:   none                                                                            *
     54  *                                                                                             *
     55  * HISTORY:                                                                                    *
     56  *   04/24/1994 JLB : Created.                                                                 *
     57  *   06/05/1995 JLB : Simplified to just do movement.                                          *
     58  *=============================================================================================*/
     59 ImpactType FlyClass::Physics(COORDINATE & coord, DirType facing)
     60 {
     61 	if (SpeedAdd != MPH_IMMOBILE) {
     62 		int actual = (int)SpeedAdd + SpeedAccum;
     63 		div_t result = div(actual, PIXEL_LEPTON_W);
     64 		SpeedAccum = result.rem;
     65 		actual -= result.rem;
     66 		COORDINATE old = coord;
     67 
     68 		/*
     69 		**	If movement occurred that is at least one
     70 		**	pixel, then check update the coordinate and
     71 		**	check for edge of world collision.
     72 		*/
     73 		if (result.quot) {
     74 			COORDINATE		newcoord;		// New working coordinate.
     75 			newcoord = Coord_Move(coord, facing, actual);
     76 			/*
     77 			**	If no movement occurred, then presume it hasn't moved at all
     78 			**	and return immediately with this indication.
     79 			*/
     80 			if (newcoord == coord) {
     81 				return(IMPACT_NONE);
     82 			}
     83 
     84 			/*
     85 			**	Remember the new position.
     86 			*/
     87 			coord = newcoord;
     88 
     89 			/*
     90 			**	If the new coordinate is off the edge of the world, then report
     91 			**	this.
     92 			*/
     93 			if (newcoord & HIGH_COORD_MASK /*|| !Map.In_Radar(Coord_Cell(newcoord))*/) {
     94 //			if (!Map.In_Radar(Coord_Cell(newcoord))) {
     95 				coord = old;
     96 				return(IMPACT_EDGE);
     97 			}
     98 
     99 			return(IMPACT_NORMAL);
    100 		}
    101 	}
    102 	return(IMPACT_NONE);
    103 }
    104 
    105 
    106 /***********************************************************************************************
    107  * FlyClass::Fly_Speed -- Sets the flying object to the speed specified.                       *
    108  *                                                                                             *
    109  *    This sets the speed of the projectile. It basically functions like a throttle value      *
    110  *    where 0 equals stop and 255 equals maximum speed (whatever that is for the particular    *
    111  *    object).                                                                                 *
    112  *                                                                                             *
    113  * INPUT:   speed -- Speed setting from 0 to 255.                                              *
    114  *                                                                                             *
    115  *          maximum  -- The maximum speed of the object.                                       *
    116  *                                                                                             *
    117  * OUTPUT:  none                                                                               *
    118  *                                                                                             *
    119  * WARNINGS:   none                                                                            *
    120  *                                                                                             *
    121  * HISTORY:                                                                                    *
    122  *   07/26/1994 JLB : Created.                                                                 *
    123  *   07/26/1994 JLB : Added maximum speed as guiding value.                                    *
    124  *=============================================================================================*/
    125 void FlyClass::Fly_Speed(int speed, MPHType maximum)
    126 {
    127 	SpeedAdd = (MPHType)( maximum * fixed(speed, 256));
    128 //	SpeedAdd = (MPHType)Fixed_To_Cardinal((int)maximum, speed);
    129 }
    130 
    131