CnC_Remastered_Collection

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

OBJECT.CPP (146011B)


      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/OBJECT.CPP 1     3/03/97 10:25a 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 : OBJECT.CPP                                                   *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : April 29, 1994                                               *
     28  *                                                                                             *
     29  *                  Last Update : October 6, 1996 [JLB]                                        *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  *   ObjectClass::AI -- Handles generic object AI processing.                                  *
     34  *   ObjectClass::Active_Click_With -- Dispatches action on the object specified.              *
     35  *   ObjectClass::Active_Click_With -- Dispatches action on the specified cell.                *
     36  *   ObjectClass::Attach_Trigger -- Attach specified trigger to object.                        *
     37  *   ObjectClass::Can_Demolish -- Queries whether this object can be sold back.                *
     38  *   ObjectClass::Can_Player_Fire -- Can the player give this object an attack mission?        *
     39  *   ObjectClass::Can_Player_Move -- Can the player give this object a movement mission?       *
     40  *   ObjectClass::Can_Repair -- Queries whether this object can be repaired.                   *
     41  *   ObjectClass::Catch_Fire -- Called when animation is attached to this object.              *
     42  *   ObjectClass::Center_Coord -- Fetches the center coordinate for the object.                *
     43  *   ObjectClass::Clicked_As_Target -- Triggers target selection animation.                    *
     44  *   ObjectClass::Debug_Dump -- Displays status of the object class to the mono monitor.       *
     45  *   ObjectClass::Detach -- Detach the specified target from this object.                      *
     46  *   ObjectClass::Detach_All -- Removes the object from all tracking systems.                  *
     47  *   ObjectClass::Do_Shimmer -- Shimmers this object if it is cloaked.                         *
     48  *   ObjectClass::Docking_Coord -- Fetches the coordinate to dock at this object.              *
     49  *   ObjectClass::Exit_Coord -- Return with the exit coordinate for this object.               *
     50  *   ObjectClass::Exit_Object -- Causes the specified object to leave this object.             *
     51  *   ObjectClass::Fire_Coord -- Fetches the coordinate a projectile will launch from.          *
     52  *   ObjectClass::Fire_Out -- Informs object that attached animation has finished.             *
     53  *   ObjectClass::Get_Mission -- Fetches the current mission of this object.                   *
     54  *   ObjectClass::Get_Ownable -- Fetches the house owner legality options for this object.     *
     55  *   ObjectClass::Hidden -- Called when this object becomes hidden from the player.            *
     56  *   ObjectClass::In_Range -- Determines if the coordinate is within weapon range.             *
     57  *   ObjectClass::In_Which_Layer -- Fetches what layer this object is located in.              *
     58  *   ObjectClass::Init -- Initializes the basic object system.                                 *
     59  *   ObjectClass::Limbo -- Brings the object into a state of limbo.                            *
     60  *   ObjectClass::Look -- Called when this object needs to reveal terrain.                     *
     61  *   ObjectClass::Mark -- Handles basic marking logic.                                         *
     62  *   ObjectClass::Mark_For_Redraw -- Marks object and system for redraw.                       *
     63  *   ObjectClass::Move -- Moves (by force) the object in the desired direction.                *
     64  *   ObjectClass::Name -- Fetches the identification name of this object.                      *
     65  *   ObjectClass::ObjectClass -- Default constructor for objects.                              *
     66  *   ObjectClass::Paradrop -- Unlimbos object in paradrop mode.                                *
     67  *   ObjectClass::Passive_Click_With -- Right mouse button click process.                      *
     68  *   ObjectClass::Receive_Message -- Processes an incoming radio message.                      *
     69  *   ObjectClass::Record_The_Kill -- Records this object as killed by the specified object.    *
     70  *   ObjectClass::Render -- Displays the object onto the map.                                  *
     71  *   ObjectClass::Render_Coord -- Fetches the coordinate to draw this object at.               *
     72  *   ObjectClass::Repair -- Handles object repair control.                                     *
     73  *   ObjectClass::Revealed -- Reveals this object to the house specified.                      *
     74  *   ObjectClass::Scatter -- Tries to scatter this object.                                     *
     75  *   ObjectClass::Select -- Try to make this object the "selected" object.                     *
     76  *   ObjectClass::Sell_Back -- Sells the object -- if possible.                                *
     77  *   ObjectClass::Sort_Y -- Returns the coordinate used for display order sorting.             *
     78  *   ObjectClass::Take_Damage -- Applies damage to the object.                                 *
     79  *   ObjectClass::Target_Coord -- Fetches the coordinate if this object is a target.           *
     80  *   ObjectClass::Unlimbo -- Brings the object into the game system.                           *
     81  *   ObjectClass::Unselect -- This will un-select the object if it was selected.               *
     82  *   ObjectClass::Value -- Fetches the target value of this object.                            *
     83  *   ObjectClass::Weapon_Range -- Returns the weapon range for the weapon specified.           *
     84  *   ObjectClass::What_Action -- Determines what action to perform on specified object.        *
     85  *   ObjectClass::What_Action -- Returns with the action to perform for this object.           *
     86  *   ObjectTypeClass::Cost_Of -- Returns the cost to buy this unit.                            *
     87  *   ObjectTypeClass::Dimensions -- Gets the dimensions of the object in pixels.               *
     88  *   ObjectTypeClass::Get_Cameo_Data -- Fetches pointer to cameo data for this object type.    *
     89  *   ObjectTypeClass::Max_Pips -- Fetches the maximum pips allowed for this object.            *
     90  *   ObjectTypeClass::ObjectTypeClass -- Normal constructor for object type class objects.     *
     91  *   ObjectTypeClass::Occupy_List -- Returns with simple occupation list for object.           *
     92  *   ObjectTypeClass::One_Time -- Handles one time processing for object types.                *
     93  *   ObjectTypeClass::Overlap_List -- Returns a pointer to a simple overlap list.              *
     94  *   ObjectTypeClass::Time_To_Build -- Fetches the time to construct this object.              *
     95  *   ObjectTypeClass::Who_Can_Build_Me -- Determine what building can build this object type.  *
     96  *   ObjectTypeClass::Who_Can_Build_Me -- Finds the factory building that can build this object*
     97  *   ObjectClass::Get_Image_Data -- Fetches the image data to use for this object.             *
     98  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     99 
    100 #include "function.h"
    101 
    102 /*
    103 **	Selected objects have a special marking box around them. This is the shapes that are
    104 **	used for this purpose.
    105 */
    106 void const * ObjectTypeClass::SelectShapes = 0;
    107 
    108 void const * ObjectTypeClass::PipShapes = 0;
    109 
    110 
    111 
    112 /***********************************************************************************************
    113  * ObjectClass::ObjectClass -- Default constructor for objects.                                *
    114  *                                                                                             *
    115  *    This is the default constructor for objects. It is called as an inherent part of the     *
    116  *    construction process for all the normal game objects instantiated. It serves merely to   *
    117  *    initialize the object values to a common (default) state.                                *
    118  *                                                                                             *
    119  * INPUT:   none                                                                               *
    120  *                                                                                             *
    121  * OUTPUT:  none                                                                               *
    122  *                                                                                             *
    123  * WARNINGS:   Objects always start in a state of limbo. They must be Unlimbo()ed before they  *
    124  *             can be used.                                                                    *
    125  *                                                                                             *
    126  * HISTORY:                                                                                    *
    127  *   09/24/1994 JLB : Created.                                                                 *
    128  *=============================================================================================*/
    129 ObjectClass::ObjectClass(RTTIType rtti, int id) :
    130 	AbstractClass(rtti, id),
    131 	IsDown(false),
    132 	IsToDamage(false),
    133 	IsToDisplay(false),
    134 	IsInLimbo(true),
    135 	IsSelected(false),
    136 	IsAnimAttached(false),
    137 	IsFalling(false),
    138 	Riser(0),
    139 	Next(0),
    140 	Trigger(NULL),
    141 	Strength(255),
    142 	IsSelectedMask(0)		// Mask showing who has selected this object
    143 {
    144 }
    145 
    146 
    147 /***********************************************************************************************
    148  * ObjectClass::Get_Image_Data -- Fetches the image data to use for this object.               *
    149  *                                                                                             *
    150  *    This routine will return with a pointer to the image data that should be used when       *
    151  *    this object is drawn.                                                                    *
    152  *                                                                                             *
    153  * INPUT:   none                                                                               *
    154  *                                                                                             *
    155  * OUTPUT:  Returns with a pointer to the shape data for this object.                          *
    156  *                                                                                             *
    157  * WARNINGS:   none                                                                            *
    158  *                                                                                             *
    159  * HISTORY:                                                                                    *
    160  *   08/06/1996 JLB : Created.                                                                 *
    161  *=============================================================================================*/
    162 void const * ObjectClass::Get_Image_Data(void) const
    163 {
    164 	return(Class_Of().Get_Image_Data());
    165 }
    166 
    167 
    168 /***********************************************************************************************
    169  * ObjectClass::Name -- Fetches the identification name of this object.                        *
    170  *                                                                                             *
    171  *    This routine will return a pointer to the identifier name for this object. This name     *
    172  *    is usually short and is used in the INI files to identify this object.                   *
    173  *                                                                                             *
    174  * INPUT:   none                                                                               *
    175  *                                                                                             *
    176  * OUTPUT:  Returns with a pointer to the text identifier name of this object.                 *
    177  *                                                                                             *
    178  * WARNINGS:   none                                                                            *
    179  *                                                                                             *
    180  * HISTORY:                                                                                    *
    181  *   07/29/1996 JLB : Created.                                                                 *
    182  *=============================================================================================*/
    183 char const * ObjectClass::Name(void) const
    184 {
    185 	return(Class_Of().Name());
    186 }
    187 
    188 
    189 /***********************************************************************************************
    190  * ObjectClass::Exit_Coord -- Return with the exit coordinate for this object.                 *
    191  *                                                                                             *
    192  *    Ths exit coordinate is the location that a piggy back or newly produced object will      *
    193  *    appear at when it exits this object. Transports and factory buildings will utilize this  *
    194  *    routine.                                                                                 *
    195  *                                                                                             *
    196  * INPUT:   none                                                                               *
    197  *                                                                                             *
    198  * OUTPUT:  Returns with the coordinate that an object will appear at when exiting this        *
    199  *          object.                                                                            *
    200  *                                                                                             *
    201  * WARNINGS:   none                                                                            *
    202  *                                                                                             *
    203  * HISTORY:                                                                                    *
    204  *   07/29/1996 JLB : Created.                                                                 *
    205  *=============================================================================================*/
    206 COORDINATE ObjectClass::Exit_Coord(void) const
    207 {
    208 	return(Center_Coord());
    209 }
    210 
    211 
    212 /***********************************************************************************************
    213  * ObjectClass::AI -- Handles generic object AI processing.                                    *
    214  *                                                                                             *
    215  *    This routine is used to handle the AI processing that occurs for all object types.       *
    216  *    Typically, this isn't much, but there is the concept of falling that all objects can     *
    217  *    be subjected to (e.g., grenades).                                                        *
    218  *                                                                                             *
    219  * INPUT:   none                                                                               *
    220  *                                                                                             *
    221  * OUTPUT:  none                                                                               *
    222  *                                                                                             *
    223  * WARNINGS:   none                                                                            *
    224  *                                                                                             *
    225  * HISTORY:                                                                                    *
    226  *   02/07/1996 JLB : Created.                                                                 *
    227  *=============================================================================================*/
    228 void ObjectClass::AI(void)
    229 {
    230 	assert(this != 0);
    231 	assert(IsActive);
    232 
    233 	/*
    234 	**	Falling logic is handled here.
    235 	*/
    236 	if (IsFalling) {
    237 		LayerType layer = In_Which_Layer();
    238 
    239 		Height += Riser;
    240 		if (Height <= 0) {
    241 			Height = 0;
    242 			IsFalling = false;
    243 			Per_Cell_Process(PCP_END);
    244 
    245 			Shorten_Attached_Anims(this);
    246 		}
    247 		if (IsAnimAttached) {
    248 			Riser -= 1;
    249 			Riser = max(Riser, -3);
    250 		} else {
    251 			Riser -= Rule.Gravity;
    252 //			Riser -= GRAVITY;
    253 			Riser = max(Riser, -100);
    254 		}
    255 
    256 		if (layer != In_Which_Layer()) {
    257 			Map.Remove(this, layer);
    258 			Map.Submit(this, In_Which_Layer());
    259 
    260 			if (Class_Of().IsFootprint) {
    261 				if (In_Which_Layer() == LAYER_GROUND) {
    262 					Map.Place_Down(Coord_Cell(Center_Coord()), this);
    263 				} else {
    264 					Map.Pick_Up(Coord_Cell(Center_Coord()), this);
    265 				}
    266 			}
    267 		}
    268 	}
    269 }
    270 
    271 
    272 /***********************************************************************************************
    273  * ObjectClass::What_Action -- Determines what action to perform on specified object.          *
    274  *                                                                                             *
    275  *    This routine will return that action that this object could perform if the mouse were    *
    276  *    clicked over the object specified.                                                       *
    277  *                                                                                             *
    278  * INPUT:   object   -- Pointer to the object to check this object against when determining    *
    279  *                      the action to perform.                                                 *
    280  *                                                                                             *
    281  * OUTPUT:  It returns that action that will be performed if the mouse were clicked over the   *
    282  *          object. Since non-derived objects cannot do anything, and cannot even be           *
    283  *          instantiated, this routine will always return ACTION_NONE.                         *
    284  *                                                                                             *
    285  * WARNINGS:   none                                                                            *
    286  *                                                                                             *
    287  * HISTORY:                                                                                    *
    288  *   07/19/1995 JLB : Created.                                                                 *
    289  *=============================================================================================*/
    290 ActionType ObjectClass::What_Action(ObjectClass const *) const
    291 {
    292 	assert(this != 0);
    293 	assert(IsActive);
    294 
    295 	return(ACTION_NONE);
    296 }
    297 
    298 
    299 /***********************************************************************************************
    300  * ObjectClass::What_Action -- Returns with the action to perform for this object.             *
    301  *                                                                                             *
    302  *    This routine is called when information on a potential action if the mouse were clicked  *
    303  *    on the cell specified. This routine merely serves as a virtual placeholder so that       *
    304  *    object types that can actually perform some action will override this routine to provide *
    305  *    true functionality.                                                                      *
    306  *                                                                                             *
    307  * INPUT:   cell  -- The cell that the mouse is over and might be clicked on.                  *
    308  *                                                                                             *
    309  * OUTPUT:  Returns with the action that this object would try to perform if the mouse were    *
    310  *          clicked. Since objects at this level have no ability to do anything, this routine  *
    311  *          will always returns ACTION_NONE unless it is overridden.                           *
    312  *                                                                                             *
    313  * WARNINGS:   none                                                                            *
    314  *                                                                                             *
    315  * HISTORY:                                                                                    *
    316  *   08/13/1995 JLB : Created.                                                                 *
    317  *=============================================================================================*/
    318 ActionType ObjectClass::What_Action(CELL) const
    319 {
    320 	assert(this != 0);
    321 	assert(IsActive);
    322 
    323 	return(ACTION_NONE);
    324 }
    325 
    326 
    327 /***********************************************************************************************
    328  * ObjectClass::In_Which_Layer -- Fetches what layer this object is located in.                *
    329  *                                                                                             *
    330  *    The default layer for object location is the LAYER_GROUND. Aircraft will override this   *
    331  *    routine and make adjustments as necessary according to the aircraft's altitude.          *
    332  *                                                                                             *
    333  * INPUT:   none                                                                               *
    334  *                                                                                             *
    335  * OUTPUT:  Returns with the layer that this object is located in.                             *
    336  *                                                                                             *
    337  * WARNINGS:   none                                                                            *
    338  *                                                                                             *
    339  * HISTORY:                                                                                    *
    340  *   08/13/1995 JLB : Created.                                                                 *
    341  *=============================================================================================*/
    342 LayerType ObjectClass::In_Which_Layer(void) const
    343 {
    344 	assert(this != 0);
    345 	assert(IsActive);
    346 
    347 	if (Height < (FLIGHT_LEVEL - (FLIGHT_LEVEL/3))) {
    348 		return(LAYER_GROUND);
    349 	}
    350 	return(LAYER_TOP);
    351 }
    352 
    353 
    354 /***********************************************************************************************
    355  * ObjectClass::Get_Ownable -- Fetches the house owner legality options for this object.       *
    356  *                                                                                             *
    357  *    This routine will return the ownable bits for this object. Objects at this level can't   *
    358  *    really be owned by anyone, but return the full spectrum of legality just to be safe.     *
    359  *                                                                                             *
    360  * INPUT:   none                                                                               *
    361  *                                                                                             *
    362  * OUTPUT:  Returns with the ownable flags (as a combined bitfield) for this object.           *
    363  *                                                                                             *
    364  * WARNINGS:   none                                                                            *
    365  *                                                                                             *
    366  * HISTORY:                                                                                    *
    367  *   08/13/1995 JLB : Created.                                                                 *
    368  *=============================================================================================*/
    369 int ObjectClass::Get_Ownable(void) const
    370 {
    371 	assert(this != 0);
    372 	assert(IsActive);
    373 
    374 	return(HOUSEF_ALLIES | HOUSEF_SOVIET | HOUSEF_OTHERS);
    375 }
    376 
    377 
    378 /***********************************************************************************************
    379  * ObjectClass::Can_Repair -- Queries whether this object can be repaired.                     *
    380  *                                                                                             *
    381  *    Most objects cannot be repaired. This routine defaults to returning "false", but is      *
    382  *    overridden by derived functions defined by object types that can support repair.         *
    383  *                                                                                             *
    384  * INPUT:   none                                                                               *
    385  *                                                                                             *
    386  * OUTPUT:  Can this object be repaired?                                                       *
    387  *                                                                                             *
    388  * WARNINGS:   none                                                                            *
    389  *                                                                                             *
    390  * HISTORY:                                                                                    *
    391  *   08/13/1995 JLB : Created.                                                                 *
    392  *=============================================================================================*/
    393 bool ObjectClass::Can_Repair(void) const
    394 {
    395 	assert(this != 0);
    396 	assert(IsActive);
    397 
    398 	return(false);
    399 }
    400 
    401 
    402 /***********************************************************************************************
    403  * ObjectClass::Can_Demolish -- Queries whether this object can be sold back.                  *
    404  *                                                                                             *
    405  *    This routine is used to determine if this object can be sold. Most objects cannot be     *
    406  *    but for those objects that can, this routine will be overridden as necessary.            *
    407  *                                                                                             *
    408  * INPUT:   none                                                                               *
    409  *                                                                                             *
    410  * OUTPUT:  Can this object be sold back? Typically, the answer is no.                         *
    411  *                                                                                             *
    412  * WARNINGS:   none                                                                            *
    413  *                                                                                             *
    414  * HISTORY:                                                                                    *
    415  *   08/13/1995 JLB : Created.                                                                 *
    416  *=============================================================================================*/
    417 bool ObjectClass::Can_Demolish(void) const
    418 {
    419 	assert(this != 0);
    420 	assert(IsActive);
    421 
    422 	return(false);
    423 }
    424 
    425 
    426 bool ObjectClass::Can_Demolish_Unit(void) const
    427 {
    428 	assert(this != 0);
    429 	assert(IsActive);
    430 
    431 	return(false);
    432 }
    433 
    434 
    435 bool ObjectClass::Can_Capture(void) const
    436 {
    437 	assert(this != 0);
    438 	assert(IsActive);
    439 
    440 	return(false);
    441 }
    442 
    443 
    444 /***********************************************************************************************
    445  * ObjectClass::Can_Player_Fire -- Can the player give this object an attack mission?          *
    446  *                                                                                             *
    447  *    This routine is used to determine if attacking is an option under player control with    *
    448  *    respect to this unit. This routine will be overridden as necessary for those objects     *
    449  *    that have the ability to attack.                                                         *
    450  *                                                                                             *
    451  * INPUT:   none                                                                               *
    452  *                                                                                             *
    453  * OUTPUT:  Can this object be given an attack order by the player?                            *
    454  *                                                                                             *
    455  * WARNINGS:   none                                                                            *
    456  *                                                                                             *
    457  * HISTORY:                                                                                    *
    458  *   08/13/1995 JLB : Created.                                                                 *
    459  *=============================================================================================*/
    460 bool ObjectClass::Can_Player_Fire(void) const
    461 {
    462 	assert(this != 0);
    463 	assert(IsActive);
    464 
    465 	return(false);
    466 }
    467 
    468 
    469 /***********************************************************************************************
    470  * ObjectClass::Can_Player_Move -- Can the player give this object a movement mission?         *
    471  *                                                                                             *
    472  *    This routine is used to determine if the player has the ability to command this object   *
    473  *    with a movement mission. This routine will be overridden as necessary to support this    *
    474  *    ability.                                                                                 *
    475  *                                                                                             *
    476  * INPUT:   none                                                                               *
    477  *                                                                                             *
    478  * OUTPUT:  Can this object be given a movement mission by the player?                         *
    479  *                                                                                             *
    480  * WARNINGS:   none                                                                            *
    481  *                                                                                             *
    482  * HISTORY:                                                                                    *
    483  *   08/13/1995 JLB : Created.                                                                 *
    484  *=============================================================================================*/
    485 bool ObjectClass::Can_Player_Move(void) const
    486 {
    487 	assert(this != 0);
    488 	assert(IsActive);
    489 
    490 	return(false);
    491 }
    492 
    493 
    494 /***********************************************************************************************
    495  * ObjectClass::Target_Coord -- Fetches the coordinate if this object is a target.             *
    496  *                                                                                             *
    497  *    When the coordinate to use when firing at this object is needed, this routine will       *
    498  *    provide it. Normal objects just use the center of the object for this, but there are     *
    499  *    some more sophisticated objects that are not fired upon the center.                      *
    500  *                                                                                             *
    501  * INPUT:   none                                                                               *
    502  *                                                                                             *
    503  * OUTPUT:  Returns with the coordinate to fire at if this object is a target.                 *
    504  *                                                                                             *
    505  * WARNINGS:   none                                                                            *
    506  *                                                                                             *
    507  * HISTORY:                                                                                    *
    508  *   08/13/1995 JLB : Created.                                                                 *
    509  *=============================================================================================*/
    510 COORDINATE ObjectClass::Target_Coord(void) const
    511 {
    512 	assert(this != 0);
    513 	assert(IsActive);
    514 
    515 	return(Coord_Add(XY_Coord(0, -Height), Center_Coord()));
    516 //	return(Center_Coord());
    517 }
    518 
    519 
    520 /***********************************************************************************************
    521  * ObjectClass::Center_Coord -- Fetches the center coordinate for the object.                  *
    522  *                                                                                             *
    523  *    This routine will return the center coordinate for the object. The center coordinate is  *
    524  *    typically the coordinate recorded in the object structure. Exceptions to this include    *
    525  *    the trees and other terrain elements.                                                    *
    526  *                                                                                             *
    527  * INPUT:   none                                                                               *
    528  *                                                                                             *
    529  * OUTPUT:  Returns the coordinate that is considered the center point of this object.         *
    530  *                                                                                             *
    531  * WARNINGS:   none                                                                            *
    532  *                                                                                             *
    533  * HISTORY:                                                                                    *
    534  *   09/21/1995 JLB : Created.                                                                 *
    535  *=============================================================================================*/
    536 COORDINATE ObjectClass::Center_Coord(void) const
    537 {
    538 	assert(this != 0);
    539 	assert(IsActive);
    540 
    541 	return(Coord);
    542 }
    543 
    544 
    545 /***********************************************************************************************
    546  * ObjectClass::Render_Coord -- Fetches the coordinate to draw this object at.                 *
    547  *                                                                                             *
    548  *    This routine will return the coordinate to base the drawing of this object's graphic     *
    549  *    at. This is adjusted according to the nature of the graphic associated with this         *
    550  *    object.                                                                                  *
    551  *                                                                                             *
    552  * INPUT:   none                                                                               *
    553  *                                                                                             *
    554  * OUTPUT:  Returns the coordinate to draw the graphic of this object at.                      *
    555  *                                                                                             *
    556  * WARNINGS:   none                                                                            *
    557  *                                                                                             *
    558  * HISTORY:                                                                                    *
    559  *   09/21/1995 JLB : Created.                                                                 *
    560  *=============================================================================================*/
    561 COORDINATE ObjectClass::Render_Coord(void) const
    562 {
    563 	assert(this != 0);
    564 	assert(IsActive);
    565 
    566 	return(Center_Coord());
    567 }
    568 
    569 
    570 /***********************************************************************************************
    571  * ObjectClass::Docking_Coord -- Fetches the coordinate to dock at this object.                *
    572  *                                                                                             *
    573  *    This routine returns the coordinate that a potential docking object should home in on.   *
    574  *    Typically, this the center of the object, but in certain cases it is adjusted off center *
    575  *    according to the object type. An example of this would be the airfield.                  *
    576  *                                                                                             *
    577  * INPUT:   none                                                                               *
    578  *                                                                                             *
    579  * OUTPUT:  Returns with the coordinate that a docking object should head for.                 *
    580  *                                                                                             *
    581  * WARNINGS:   none                                                                            *
    582  *                                                                                             *
    583  * HISTORY:                                                                                    *
    584  *   09/21/1995 JLB : Created.                                                                 *
    585  *=============================================================================================*/
    586 COORDINATE ObjectClass::Docking_Coord(void) const
    587 {
    588 	assert(this != 0);
    589 	assert(IsActive);
    590 
    591 	return(Center_Coord());
    592 }
    593 
    594 
    595 /***********************************************************************************************
    596  * ObjectClass::Sort_Y -- Returns the coordinate used for display order sorting.               *
    597  *                                                                                             *
    598  *    This routine will return the value to be used for object sorting. The sorting ensures    *
    599  *    that the object are rendered from a top to bottom order. Certain object use a sorting    *
    600  *    value different from their center coordinate. This is true if the object "touches the    *
    601  *    ground" at a point that is different from the object's center point.                     *
    602  *                                                                                             *
    603  * INPUT:   none                                                                               *
    604  *                                                                                             *
    605  * OUTPUT:  Returns with the value to use as the Y sorting value.                              *
    606  *                                                                                             *
    607  * WARNINGS:   none                                                                            *
    608  *                                                                                             *
    609  * HISTORY:                                                                                    *
    610  *   09/21/1995 JLB : Created.                                                                 *
    611  *=============================================================================================*/
    612 COORDINATE ObjectClass::Sort_Y(void) const
    613 {
    614 	assert(this != 0);
    615 	assert(IsActive);
    616 
    617 	return(Coord);
    618 }
    619 
    620 
    621 /***********************************************************************************************
    622  * ObjectClass::Fire_Coord -- Fetches the coordinate a projectile will launch from.            *
    623  *                                                                                             *
    624  *    For those objects that fire, the coordinate that the projectile it launches will appear  *
    625  *    at the location specified by the return value from this function.                        *
    626  *                                                                                             *
    627  * INPUT:   which -- Which weapon to consider when determining fire coordinate?                *
    628  *                   0: primary weapon                                                         *
    629  *                   1: secondary weapon                                                       *
    630  *                                                                                             *
    631  * OUTPUT:  Returns with the coordinate that a launched projectile will appear at if this      *
    632  *          object were to fire the weapon specified.                                          *
    633  *                                                                                             *
    634  * WARNINGS:   none                                                                            *
    635  *                                                                                             *
    636  * HISTORY:                                                                                    *
    637  *   09/21/1995 JLB : Created.                                                                 *
    638  *=============================================================================================*/
    639 FireDataType ObjectClass::Fire_Data(int which) const
    640 {
    641 	assert(this != 0);
    642 	assert(IsActive);
    643 
    644 	return{Fire_Coord(which),0};
    645 }
    646 
    647 COORDINATE ObjectClass::Fire_Coord(int ) const
    648 {
    649 	assert(this != 0);
    650 	assert(IsActive);
    651 
    652 	return(Coord);
    653 }
    654 
    655 
    656 /***********************************************************************************************
    657  * ObjectClass::Record_The_Kill -- Records this object as killed by the specified object.      *
    658  *                                                                                             *
    659  *    This routine is called when this object is killed. If the source of the death is known,  *
    660  *    then a pointer to the responsible object is provided as a parameter.                     *
    661  *                                                                                             *
    662  * INPUT:   source   -- Pointer to the cause of this unit's death.                             *
    663  *                                                                                             *
    664  * OUTPUT:  none                                                                               *
    665  *                                                                                             *
    666  * WARNINGS:   none                                                                            *
    667  *                                                                                             *
    668  * HISTORY:                                                                                    *
    669  *   09/21/1995 JLB : Created.                                                                 *
    670  *=============================================================================================*/
    671 void ObjectClass::Record_The_Kill(TechnoClass * )
    672 {
    673 	assert(this != 0);
    674 	assert(IsActive);
    675 }
    676 
    677 
    678 /***********************************************************************************************
    679  * ObjectClass::Do_Shimmer -- Shimmers this object if it is cloaked.                           *
    680  *                                                                                             *
    681  *    When an object is cloaked, there are several conditions that would cause it to shimmer   *
    682  *    and thus reveal itself. When such a condition arrises, this function is called. If the   *
    683  *    object is cloaked, then it will shimmer. At this derivation level, cloaking is           *
    684  *    undefined. Objects that can cloak will override this function as necessary.              *
    685  *                                                                                             *
    686  * INPUT:   none                                                                               *
    687  *                                                                                             *
    688  * OUTPUT:  none                                                                               *
    689  *                                                                                             *
    690  * WARNINGS:   none                                                                            *
    691  *                                                                                             *
    692  * HISTORY:                                                                                    *
    693  *   09/21/1995 JLB : Created.                                                                 *
    694  *=============================================================================================*/
    695 void ObjectClass::Do_Shimmer(void)
    696 {
    697 	assert(this != 0);
    698 	assert(IsActive);
    699 }
    700 
    701 
    702 /***********************************************************************************************
    703  * ObjectClass::Exit_Object -- Causes the specified object to leave this object.               *
    704  *                                                                                             *
    705  *    This routine is called, typically, by a transport building type that requires an object  *
    706  *    to leave it. This routine will place the object at a suitable location or return         *
    707  *    a value indicating why not.                                                              *
    708  *                                                                                             *
    709  * INPUT:   object   -- Pointer to the object that wishes to leave this object.                *
    710  *                                                                                             *
    711  * OUTPUT:  Returns the success value of the attempt:                                          *
    712  *             0: Object could not be placed -- ever                                           *
    713  *             1: Object placement is temporarily delayed -- try again later.                  *
    714  *             2: Object placement proceeded normally                                          *
    715  *                                                                                             *
    716  * WARNINGS:   none                                                                            *
    717  *                                                                                             *
    718  * HISTORY:                                                                                    *
    719  *   09/21/1995 JLB : Created.                                                                 *
    720  *=============================================================================================*/
    721 int ObjectClass::Exit_Object(TechnoClass *)
    722 {
    723 	assert(this != 0);
    724 	assert(IsActive);
    725 	return(0);
    726 }
    727 
    728 
    729 /***********************************************************************************************
    730  * ObjectClass::Hidden -- Called when this object becomes hidden from the player.              *
    731  *                                                                                             *
    732  *    This routine is called when the object becomes hidden from the player. It can result in  *
    733  *    lost targeting and tracking abilities with respect to the hidden object.                 *
    734  *                                                                                             *
    735  * INPUT:   none                                                                               *
    736  *                                                                                             *
    737  * OUTPUT:  none                                                                               *
    738  *                                                                                             *
    739  * WARNINGS:   none                                                                            *
    740  *                                                                                             *
    741  * HISTORY:                                                                                    *
    742  *   09/21/1995 JLB : Created.                                                                 *
    743  *=============================================================================================*/
    744 void ObjectClass::Hidden(void)
    745 {
    746 	assert(this != 0);
    747 	assert(IsActive);
    748 }
    749 
    750 
    751 /***********************************************************************************************
    752  * ObjectClass::Look -- Called when this object needs to reveal terrain.                       *
    753  *                                                                                             *
    754  *    This routine is called when the object needs to look around the terrain. For player      *
    755  *    owned objects, the terrain is revealed. For non-player objects, not effect occurs.       *
    756  *                                                                                             *
    757  * INPUT:   incremental -- If true, then the looking algorithm will only examine the edges     *
    758  *                         of the sight range. This is more efficient and work well if the     *
    759  *                         object has only moved one cell since the last time it has performed *
    760  *                         the look operation.                                                 *
    761  *                                                                                             *
    762  * OUTPUT:  none                                                                               *
    763  *                                                                                             *
    764  * WARNINGS:   This can be a time consuming operation. Call only when necessary.               *
    765  *                                                                                             *
    766  * HISTORY:                                                                                    *
    767  *   09/21/1995 JLB : Created.                                                                 *
    768  *=============================================================================================*/
    769 void ObjectClass::Look(bool )
    770 {
    771 	assert(this != 0);
    772 	assert(IsActive);
    773 }
    774 
    775 
    776 /***********************************************************************************************
    777  * ObjectClass::Active_Click_With -- Dispatches action on the object specified.                *
    778  *                                                                                             *
    779  *    This routine is called when this object is selected and the mouse was clicked on the     *
    780  *    tactical map. An action is required from the object. The object that the mouse was       *
    781  *    over and the tentative action to perform are provided as parameters.                     *
    782  *                                                                                             *
    783  * INPUT:   action   -- The requested action to perform with the object specified.             *
    784  *                                                                                             *
    785  *          object   -- The object that the action should be performed on. This object is      *
    786  *                      what the mouse was over when the click occurred.                       *
    787  *                                                                                             *
    788  * OUTPUT:  none                                                                               *
    789  *                                                                                             *
    790  * WARNINGS:   none                                                                            *
    791  *                                                                                             *
    792  * HISTORY:                                                                                    *
    793  *   09/21/1995 JLB : Created.                                                                 *
    794  *=============================================================================================*/
    795 void ObjectClass::Active_Click_With(ActionType , ObjectClass *)
    796 {
    797 	assert(this != 0);
    798 	assert(IsActive);
    799 }
    800 
    801 
    802 /***********************************************************************************************
    803  * ObjectClass::Active_Click_With -- Dispatches action on the specified cell.                  *
    804  *                                                                                             *
    805  *    This routine will dispatch the action requested upon the cell specified. It is called    *
    806  *    when the mouse is clicked over a cell while this object is selected.                     *
    807  *                                                                                             *
    808  * INPUT:   action   -- The action to perform.                                                 *
    809  *                                                                                             *
    810  *          cell     -- The location (cell) to perform this action upon.                       *
    811  *                                                                                             *
    812  * OUTPUT:  none                                                                               *
    813  *                                                                                             *
    814  * WARNINGS:   none                                                                            *
    815  *                                                                                             *
    816  * HISTORY:                                                                                    *
    817  *   09/21/1995 JLB : Created.                                                                 *
    818  *=============================================================================================*/
    819 void ObjectClass::Active_Click_With(ActionType , CELL )
    820 {
    821 	assert(this != 0);
    822 	assert(IsActive);
    823 }
    824 
    825 
    826 /***********************************************************************************************
    827  * ObjectClass::Clicked_As_Target -- Triggers target selection animation.                      *
    828  *                                                                                             *
    829  *    This routine is called when this object is the target of some player click action.       *
    830  *    For more sophisticated object, this will trigger the object to begin flashing a few      *
    831  *    times. At this level, no action is performed.                                            *
    832  *                                                                                             *
    833  * INPUT:   flashes  -- The requested number of times to flash this object.                    *
    834  *                                                                                             *
    835  * OUTPUT:  none                                                                               *
    836  *                                                                                             *
    837  * WARNINGS:   none                                                                            *
    838  *                                                                                             *
    839  * HISTORY:                                                                                    *
    840  *   09/21/1995 JLB : Created.                                                                 *
    841  *=============================================================================================*/
    842 void ObjectClass::Clicked_As_Target(HousesType house, int) // 2019/09/20 JAS - Added record of who clicked on the object
    843 {
    844 	assert(this != 0);
    845 	assert(IsActive);
    846 }
    847 
    848 
    849 /***********************************************************************************************
    850  * ObjectClass::In_Range -- Determines if the coordinate is within weapon range.               *
    851  *                                                                                             *
    852  *    This routine will determine if the specified coordinate is within weapon range.          *
    853  *                                                                                             *
    854  * INPUT:   coord -- The coordinate to check to see if it is within weapon range.              *
    855  *                                                                                             *
    856  *          which -- The weapon to check against.                                              *
    857  *                   0: primary weapon                                                         *
    858  *                   1: secondary weapon                                                       *
    859  *                                                                                             *
    860  * OUTPUT:  bool; Is the specified coordinate within weapon range for the weapon type          *
    861  *                specified?                                                                   *
    862  *                                                                                             *
    863  * WARNINGS:   none                                                                            *
    864  *                                                                                             *
    865  * HISTORY:                                                                                    *
    866  *   09/21/1995 JLB : Created.                                                                 *
    867  *=============================================================================================*/
    868 bool ObjectClass::In_Range(COORDINATE , int) const
    869 {
    870 	assert(this != 0);
    871 	assert(IsActive);
    872 
    873 	return(false);
    874 }
    875 
    876 
    877 /***********************************************************************************************
    878  * ObjectClass::Weapon_Range -- Returns the weapon range for the weapon specified.             *
    879  *                                                                                             *
    880  *    This routine will return the weapon range according to the type of weapon specified.     *
    881  *                                                                                             *
    882  * INPUT:   which -- The weapon to fetch the range from.                                       *
    883  *                   0: primary weapon                                                         *
    884  *                   1: secondary weapon                                                       *
    885  *                                                                                             *
    886  * OUTPUT:  Returns with the range (in leptons) of the weapon specified.                       *
    887  *                                                                                             *
    888  * WARNINGS:   none                                                                            *
    889  *                                                                                             *
    890  * HISTORY:                                                                                    *
    891  *   09/21/1995 JLB : Created.                                                                 *
    892  *=============================================================================================*/
    893 int ObjectClass::Weapon_Range(int) const
    894 {
    895 	assert(this != 0);
    896 	assert(IsActive);
    897 
    898 	return(0);
    899 }
    900 
    901 
    902 /***********************************************************************************************
    903  * ObjectClass::Scatter -- Tries to scatter this object.                                       *
    904  *                                                                                             *
    905  *    This routine is used when the object should scatter from its current location. It        *
    906  *    applies to units that have the ability to move.                                          *
    907  *                                                                                             *
    908  * INPUT:   coord -- The source of the threat that is causing the scatter.                     *
    909  *                                                                                             *
    910  *          forced-- Whether this scatter attempt is serious and scattering should occur       *
    911  *                   regardless of what is doing now.                                          *
    912  *                                                                                             *
    913  * OUTPUT:  none                                                                               *
    914  *                                                                                             *
    915  * WARNINGS:   This may or may not cause the object to scatter. It is merely a request to the  *
    916  *             object that it would be good if it were to scatter.                             *
    917  *                                                                                             *
    918  * HISTORY:                                                                                    *
    919  *   09/21/1995 JLB : Created.                                                                 *
    920  *=============================================================================================*/
    921 void ObjectClass::Scatter(COORDINATE , bool, bool)
    922 {
    923 	assert(this != 0);
    924 	assert(IsActive);
    925 }
    926 
    927 
    928 /***********************************************************************************************
    929  * ObjectClass::Catch_Fire -- Called when animation is attached to this object.                *
    930  *                                                                                             *
    931  *    This routine is called when an animation is attached to this object. It might be a       *
    932  *    fire animation (hence the name), but it might also be smoke or any other animation       *
    933  *    as well.                                                                                 *
    934  *                                                                                             *
    935  * INPUT:   none                                                                               *
    936  *                                                                                             *
    937  * OUTPUT:  bool; Was the object caught on fire by this routine? Actually, this is really      *
    938  *                the answer to this question; "Is this animation attaching to this object     *
    939  *                that doesn't already have an animation attached?"                            *
    940  *                                                                                             *
    941  * WARNINGS:   none                                                                            *
    942  *                                                                                             *
    943  * HISTORY:                                                                                    *
    944  *   09/21/1995 JLB : Created.                                                                 *
    945  *=============================================================================================*/
    946 bool ObjectClass::Catch_Fire(void)
    947 {
    948 	assert(this != 0);
    949 	assert(IsActive);
    950 
    951 	return false;
    952 }
    953 
    954 
    955 /***********************************************************************************************
    956  * ObjectClass::Fire_Out -- Informs object that attached animation has finished.               *
    957  *                                                                                             *
    958  *    This routine is called if there is an attached animation on this object and that         *
    959  *    animation has finished. Typically, this is necessary for when trees are on fire.         *
    960  *                                                                                             *
    961  * INPUT:   none                                                                               *
    962  *                                                                                             *
    963  * OUTPUT:  none                                                                               *
    964  *                                                                                             *
    965  * WARNINGS:   none                                                                            *
    966  *                                                                                             *
    967  * HISTORY:                                                                                    *
    968  *   07/24/1995 JLB : Created.                                                                 *
    969  *=============================================================================================*/
    970 void ObjectClass::Fire_Out(void)
    971 {
    972 	assert(this != 0);
    973 	assert(IsActive);
    974 }
    975 
    976 
    977 /***********************************************************************************************
    978  * ObjectClass::Value -- Fetches the target value of this object.                              *
    979  *                                                                                             *
    980  *    This routine will return the target value of this object. The higher the number, the     *
    981  *    better the object will be as a target. This routine is called when searching for         *
    982  *    targets. Generic objects have no target potential, and this routine returns zero to      *
    983  *    reflect that. Other object types will override this routine to return the appropriate    *
    984  *    target value.                                                                            *
    985  *                                                                                             *
    986  * INPUT:   none                                                                               *
    987  *                                                                                             *
    988  * OUTPUT:  Returns with the value of this object as a target. Higher values mean better       *
    989  *          target.                                                                            *
    990  *                                                                                             *
    991  * WARNINGS:   none                                                                            *
    992  *                                                                                             *
    993  * HISTORY:                                                                                    *
    994  *   07/24/1995 JLB : Created.                                                                 *
    995  *=============================================================================================*/
    996 int ObjectClass::Value(void) const
    997 {
    998 	assert(this != 0);
    999 	assert(IsActive);
   1000 
   1001 	return(0);
   1002 }
   1003 
   1004 
   1005 /***********************************************************************************************
   1006  * ObjectClass::Get_Mission -- Fetches the current mission of this object.                     *
   1007  *                                                                                             *
   1008  *    Generic objects don't have a mission, so this routine will just return MISSION_NONE.     *
   1009  *    However, techno objects do have a mission and this routine is overloaded to handle       *
   1010  *    those objects in order to return the correct mission value.                              *
   1011  *                                                                                             *
   1012  * INPUT:   none                                                                               *
   1013  *                                                                                             *
   1014  * OUTPUT:  Returns with the current mission being followed by this object.                    *
   1015  *                                                                                             *
   1016  * WARNINGS:   none                                                                            *
   1017  *                                                                                             *
   1018  * HISTORY:                                                                                    *
   1019  *   07/24/1995 JLB : Created.                                                                 *
   1020  *=============================================================================================*/
   1021 MissionType ObjectClass::Get_Mission(void) const
   1022 {
   1023 	assert(this != 0);
   1024 	assert(IsActive);
   1025 
   1026 	return(MISSION_NONE);
   1027 }
   1028 
   1029 
   1030 /***********************************************************************************************
   1031  * ObjectClass::Repair -- Handles object repair control.                                       *
   1032  *                                                                                             *
   1033  *    This routine will control object repair mode. At the object level, no repair is          *
   1034  *    possible, so it is expected that any object that can repair will override this function  *
   1035  *    as necessary.                                                                            *
   1036  *                                                                                             *
   1037  * INPUT:   control  -- The repair control parameter.                                          *
   1038  *                      0  = turn repair off                                                   *
   1039  *                      1  = turn repair on                                                    *
   1040  *                      -1 = toggle repair state                                               *
   1041  *                                                                                             *
   1042  * OUTPUT:  none                                                                               *
   1043  *                                                                                             *
   1044  * WARNINGS:   none                                                                            *
   1045  *                                                                                             *
   1046  * HISTORY:                                                                                    *
   1047  *   07/24/1995 JLB : Created.                                                                 *
   1048  *=============================================================================================*/
   1049 void ObjectClass::Repair(int )
   1050 {
   1051 	assert(this != 0);
   1052 	assert(IsActive);
   1053 }
   1054 
   1055 
   1056 /***********************************************************************************************
   1057  * ObjectClass::Sell_Back -- Sells the object -- if possible.                                  *
   1058  *                                                                                             *
   1059  *    This routine is called to sell back the object. Override this routine for the more       *
   1060  *    sophisticated objects that can actually be sold back. Normal objects can't be sold and   *
   1061  *    this routine does nothing as a consequence.                                              *
   1062  *                                                                                             *
   1063  * INPUT:   control  -- How to control the sell state of this object.                          *
   1064  *                      0  = stop selling.                                                     *
   1065  *                      1  = start selling.                                                    *
   1066  *                      -1 = toggle selling state.                                             *
   1067  *                                                                                             *
   1068  * OUTPUT:  none                                                                               *
   1069  *                                                                                             *
   1070  * WARNINGS:   none                                                                            *
   1071  *                                                                                             *
   1072  * HISTORY:                                                                                    *
   1073  *   07/19/1995 JLB : Created.                                                                 *
   1074  *=============================================================================================*/
   1075 void ObjectClass::Sell_Back(int )
   1076 {
   1077 	assert(this != 0);
   1078 	assert(IsActive);
   1079 }
   1080 
   1081 
   1082 /***********************************************************************************************
   1083  * ObjectClass::Move -- Moves (by force) the object in the desired direction.                  *
   1084  *                                                                                             *
   1085  *    This routine will instantly move the object one cell in the specified direction. It      *
   1086  *    moves the object by force. This is typically ONLY used by the scenario editor            *
   1087  *    process.                                                                                 *
   1088  *                                                                                             *
   1089  * INPUT:   facing   -- The direction to move the object.                                      *
   1090  *                                                                                             *
   1091  * OUTPUT:  none                                                                               *
   1092  *                                                                                             *
   1093  * WARNINGS:   Naturally, this can cause illegal placement situations -- use with caution.     *
   1094  *                                                                                             *
   1095  * HISTORY:                                                                                    *
   1096  *   06/19/1994 JLB : Created.                                                                 *
   1097  *=============================================================================================*/
   1098 void ObjectClass::Move(FacingType facing)
   1099 {
   1100 	assert(this != 0);
   1101 	assert(IsActive);
   1102 
   1103 	COORDINATE	coord;
   1104 
   1105 	Mark(MARK_UP);
   1106 	coord = Adjacent_Cell(Coord, facing);
   1107 	if (Can_Enter_Cell(Coord_Cell(coord)) == MOVE_OK) {
   1108 		Coord = coord;
   1109 	}
   1110 	Mark(MARK_DOWN);
   1111 }
   1112 
   1113 
   1114 // Object selection list is switched with player context for GlyphX. ST - 4/17/2019 9:42AM
   1115 extern void Logic_Switch_Player_Context(ObjectClass *object);
   1116 
   1117 /***********************************************************************************************
   1118  * ObjectClass::Unselect -- This will un-select the object if it was selected.                 *
   1119  *                                                                                             *
   1120  *    This routine brings a currently selected object into an unselected state. This is        *
   1121  *    needed when another object becomes selected as well as if the object is destroyed.       *
   1122  *                                                                                             *
   1123  * INPUT:   none                                                                               *
   1124  *                                                                                             *
   1125  * OUTPUT:  none                                                                               *
   1126  *                                                                                             *
   1127  * WARNINGS:   none                                                                            *
   1128  *                                                                                             *
   1129  * HISTORY:                                                                                    *
   1130  *   06/19/1994 JLB : Created.                                                                 *
   1131  *=============================================================================================*/
   1132 void ObjectClass::Unselect(void)
   1133 {
   1134 	assert(this != 0);
   1135 	assert(IsActive);
   1136 
   1137 	//if (IsSelected) { 
   1138 	// Updated to function for multiplayer - 6/26/2019 JAS
   1139 	if (Is_Selected_By_Player()) {
   1140 		
   1141 		if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_UP);
   1142 		
   1143 		IsSelected = false;
   1144 		
   1145 		// Updated to function for multiplayer - 6/26/2019 JAS
   1146 		Set_Unselected_By_Player();
   1147 		
   1148 		if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_DOWN);
   1149 	}
   1150 }
   1151 
   1152 
   1153 /***********************************************************************************************
   1154  * ObjectClass::Unselect_All_Players --	This will un-select the object if it was selected    *
   1155  *											from all players															  *
   1156  *                                                                                             *
   1157  *    This routine brings a currently selected object into an unselected state for all players.*
   1158  *		This is needed when  the object is destroyed.														  *
   1159  *                                                                                             *
   1160  * INPUT:   none                                                                               *
   1161  *                                                                                             *
   1162  * OUTPUT:  none                                                                               *
   1163  *                                                                                             *
   1164  * WARNINGS:   none                                                                            *
   1165  *                                                                                             *
   1166  * HISTORY:                                                                                    *
   1167  *   06/25/2019 JAS : Created.                                                                 *
   1168  *=============================================================================================*/
   1169 void ObjectClass::Unselect_All_Players(void)
   1170 {
   1171 	CurrentObject.Delete_All(this);
   1172 
   1173 	if (In_Which_Layer() == LAYER_GROUND) {
   1174 		Mark(MARK_OVERLAP_UP);
   1175 	}
   1176 
   1177 	IsSelected = false;
   1178 	IsSelectedMask = 0;
   1179 
   1180 	if (In_Which_Layer() == LAYER_GROUND) {
   1181 		Mark(MARK_OVERLAP_DOWN);
   1182 	}
   1183 }
   1184 
   1185 /***********************************************************************************************
   1186  * ObjectClass::Unselect_All_Players_Except_Owner --	This will un-select the object if it was *
   1187  *											selected for all players except for the object's owner		  *
   1188  *                                                                                             *
   1189  *    This routine brings a currently selected object into an unselected state for all players.*
   1190  *		This is needed when the object cloaks.																	  *
   1191  *                                                                                             *
   1192  * INPUT:   none                                                                               *
   1193  *                                                                                             *
   1194  * OUTPUT:  none                                                                               *
   1195  *                                                                                             *
   1196  * WARNINGS:   none                                                                            *
   1197  *                                                                                             *
   1198  * HISTORY:                                                                                    *
   1199  *   06/28/2019 JAS : Created.                                                                 *
   1200  *=============================================================================================*/
   1201 void ObjectClass::Unselect_All_Players_Except_Owner(void)
   1202 {
   1203 	CurrentObject.Delete_All_Except(this, Owner());
   1204 
   1205 	if (In_Which_Layer() == LAYER_GROUND) {
   1206 		Mark(MARK_OVERLAP_UP);
   1207 	}
   1208 
   1209 	int owner_mask = 1 << Owner();
   1210 	if (IsSelectedMask & owner_mask)
   1211 	{
   1212 		IsSelected = true;
   1213 		IsSelectedMask = owner_mask;
   1214 	}
   1215 	else
   1216 	{
   1217 		IsSelected = false;
   1218 		IsSelectedMask = 0;
   1219 	}
   1220 
   1221 	if (In_Which_Layer() == LAYER_GROUND) {
   1222 		Mark(MARK_OVERLAP_DOWN);
   1223 	}
   1224 }
   1225 
   1226 /***********************************************************************************************
   1227  * ObjectClass::Select -- Try to make this object the "selected" object.                       *
   1228  *                                                                                             *
   1229  *    This routine is used to make this object into the one that is "selected". A selected     *
   1230  *    object usually displays a floating bar graph and is available to be given orders from    *
   1231  *    the player's I/O.                                                                        *
   1232  *                                                                                             *
   1233  * INPUT:   allow_mixed -- Allow a mix of player and non-player controlled units?              *
   1234  *                                                                                             *
   1235  * OUTPUT:  none                                                                               *
   1236  *                                                                                             *
   1237  * WARNINGS:   none                                                                            *
   1238  *                                                                                             *
   1239  * HISTORY:                                                                                    *
   1240  *   06/19/1994 JLB : Created.                                                                 *
   1241  *   06/12/1995 JLB : Cannot select a loaner object.                                           *
   1242  *   07/23/1995 JLB : Adds to head or tail depending on leader type flag.                      *
   1243  *=============================================================================================*/
   1244 bool ObjectClass::Select(bool allow_mixed)
   1245 {
   1246 	assert(this != 0);
   1247 	assert(IsActive);
   1248 
   1249 	//if (!Debug_Map && (IsSelected || !Class_Of().IsSelectable)) {
   1250 	//	return(false);
   1251 	//}
   1252 	// Updated to function for multiplayer - 6/26/2019 JAS
   1253 	if (!Debug_Map && (Is_Selected_By_Player() || !Class_Of().IsSelectable)) {
   1254 		return(false);
   1255 	}
   1256 
   1257 	if (!Debug_Map && Can_Player_Move() && Is_Techno() && ((TechnoClass *)this)->IsALoaner) {
   1258 		return(false);
   1259 	}
   1260 
   1261 	/*
   1262 	**	Don't allow selection if the object is still in the air.
   1263 	*/
   1264 	if (Height > 0 && (What_Am_I() == RTTI_UNIT || What_Am_I() == RTTI_VESSEL || What_Am_I() == RTTI_INFANTRY)) {
   1265 		return(false);
   1266 	}
   1267 
   1268 	/*
   1269 	**	Don't allow selection of object when in building placement mode.
   1270 	*/
   1271 	if (Map.PendingObject) {
   1272 		return(false);
   1273 	}
   1274 
   1275 	if (!allow_mixed) {
   1276 		/*
   1277 		**	If selecting an object of a different house than the player's, make sure that
   1278 		**	the entire selection list is cleared.
   1279 		*/
   1280 		for (int i = 0; i < CurrentObject.Count(); i++) {
   1281 			HouseClass * tryhptr = HouseClass::As_Pointer(Owner());
   1282 			HouseClass * oldhptr = HouseClass::As_Pointer(CurrentObject[i]->Owner());
   1283 	//		if (Owner() != CurrentObject[0]->Owner() || CurrentObject[0]->Owner() != PlayerPtr->Class->House) {
   1284 			if (oldhptr->IsPlayerControl != tryhptr->IsPlayerControl) {
   1285 				Unselect_All();
   1286 				break;
   1287 			}
   1288 		}
   1289 	}
   1290 
   1291 	if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_UP);
   1292 
   1293 	//IsSelected = true;
   1294 	// Updated to function for multiplayer - 6/26/2019 JAS
   1295 	Set_Selected_By_Player();
   1296 	
   1297 	if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_DOWN);
   1298 	
   1299 	return(true);
   1300 }
   1301 
   1302 
   1303 /***********************************************************************************************
   1304  * ObjectClass::Render -- Displays the object onto the map.                                    *
   1305  *                                                                                             *
   1306  *    This routine will determine the location of the object and if it is roughly on the       *
   1307  *    visible screen, it will display it. Not displaying objects that are not on the screen    *
   1308  *    will save valuable time.                                                                 *
   1309  *                                                                                             *
   1310  * INPUT:   bool; Should the render be forced regardless of whether the object is flagged to   *
   1311  *                be redrawn?                                                                  *
   1312  *                                                                                             *
   1313  * OUTPUT:  bool; Was the draw code called for this object?                                    *
   1314  *                                                                                             *
   1315  * WARNINGS:   none                                                                            *
   1316  *                                                                                             *
   1317  * HISTORY:                                                                                    *
   1318  *   06/19/1994 JLB : Created.                                                                 *
   1319  *=============================================================================================*/
   1320 bool ObjectClass::Render(bool forced) const
   1321 {
   1322 	assert(this != 0);
   1323 	assert(IsActive);
   1324 
   1325 	int	x, y;
   1326 	COORDINATE coord = Render_Coord();
   1327 	CELL cell = Coord_Cell(coord);
   1328 
   1329 	if (Debug_Map || Debug_Unshroud || ((forced || IsToDisplay) && IsDown && !IsInLimbo)) {
   1330 		const_cast<ObjectClass*>(this)->IsToDisplay = false;		// added const_cast ST - 5/9/2019
   1331 
   1332 		if (Map.Coord_To_Pixel(coord, x, y)) {
   1333 
   1334 			/*
   1335 			**	Draw the object itself
   1336 			*/
   1337 			Draw_It(x, y, WINDOW_TACTICAL);
   1338 
   1339 #ifdef SCENARIO_EDITOR
   1340 			/*
   1341 			**	Draw the trigger attached to the object. Draw_It is window-
   1342 			**	relative, so add the window's x-coord to 'x'.
   1343 			*/
   1344 			if (Debug_Map && Trigger.Is_Valid()) {
   1345 				Fancy_Text_Print(Trigger->Class->IniName,
   1346 					x + (WinX), y,
   1347 					&ColorRemaps[PCOLOR_RED], TBLACK,
   1348 					TPF_CENTER | TPF_NOSHADOW | TPF_6POINT);
   1349 			}
   1350 #endif
   1351 
   1352 			return(true);
   1353 		}
   1354 	}
   1355 	return(false);
   1356 }
   1357 
   1358 
   1359 #ifdef CHEAT_KEYS
   1360 /***********************************************************************************************
   1361  * ObjectClass::Debug_Dump -- Displays status of the object class to the mono monitor.         *
   1362  *                                                                                             *
   1363  *    This routine is used to display the current status of the object class to the mono       *
   1364  *    monitor.                                                                                 *
   1365  *                                                                                             *
   1366  * INPUT:   none                                                                               *
   1367  *                                                                                             *
   1368  * OUTPUT:  none                                                                               *
   1369  *                                                                                             *
   1370  * WARNINGS:   none                                                                            *
   1371  *                                                                                             *
   1372  * HISTORY:                                                                                    *
   1373  *   06/02/1994 JLB : Created.                                                                 *
   1374  *=============================================================================================*/
   1375 void ObjectClass::Debug_Dump(MonoClass * mono) const
   1376 {
   1377 	mono->Set_Cursor(1, 1);mono->Printf("%-18.18s", Text_String(Full_Name()));
   1378 	if (Next != NULL) {
   1379 		mono->Set_Cursor(20, 5);mono->Printf("%08X", Next->As_Target());
   1380 	}
   1381 	if (Trigger.Is_Valid()) {
   1382 		mono->Text_Print(Trigger->Class->IniName, 11, 3);
   1383 	}
   1384 	mono->Set_Cursor(34, 1);mono->Printf("%3d", Strength);
   1385 
   1386 	mono->Fill_Attrib(1, 13, 12, 1, IsDown ? MonoClass::INVERSE : MonoClass::NORMAL);
   1387 	mono->Fill_Attrib(1, 14, 12, 1, IsToDamage ? MonoClass::INVERSE : MonoClass::NORMAL);
   1388 	mono->Fill_Attrib(1, 15, 12, 1, IsToDisplay ? MonoClass::INVERSE : MonoClass::NORMAL);
   1389 	mono->Fill_Attrib(1, 16, 12, 1, IsInLimbo ? MonoClass::INVERSE : MonoClass::NORMAL);
   1390 	// Updated to function for multiplayer - 6/26/2019 JAS
   1391 	mono->Fill_Attrib(1, 17, 12, 1, Is_Selected_By_Player() ? MonoClass::INVERSE : MonoClass::NORMAL);
   1392 	mono->Fill_Attrib(14, 13, 12, 1, IsAnimAttached ? MonoClass::INVERSE : MonoClass::NORMAL);
   1393 	mono->Set_Cursor(23, 14);mono->Printf("%d", Riser);
   1394 	mono->Fill_Attrib(14, 12, 14, 1, IsFalling ? MonoClass::INVERSE : MonoClass::NORMAL);
   1395 
   1396 	AbstractClass::Debug_Dump(mono);
   1397 }
   1398 #endif
   1399 
   1400 
   1401 /***********************************************************************************************
   1402  * ObjectClass::Mark_For_Redraw -- Marks object and system for redraw.                         *
   1403  *                                                                                             *
   1404  *    This routine will mark the object and inform the display system                          *
   1405  *    that appropriate rendering is needed. Whenever it is determined                          *
   1406  *    that an object needs to be redrawn, call this routine.                                   *
   1407  *                                                                                             *
   1408  * INPUT:      none                                                                            *
   1409  *                                                                                             *
   1410  * OUTPUT:     none                                                                            *
   1411  *                                                                                             *
   1412  * WARNINGS:   This is a subordinate function to the function Mark(). If an object needs to    *
   1413  *             be redrawn it is probably better to call the function Mark(MARK_CHANGE) rather  *
   1414  *             than this function. This function does not inform the map system that           *
   1415  *             overlapping objects are to be redrawn and thus unless you are really sure that  *
   1416  *             this routine should be called, don't.                                           *
   1417  *                                                                                             *
   1418  * HISTORY:                                                                                    *
   1419  *   05/08/1994 JLB : Created.                                                                 *
   1420  *   12/23/1994 JLB : Flags map and flags unit only.                                           *
   1421  *=============================================================================================*/
   1422 void ObjectClass::Mark_For_Redraw(void)
   1423 {
   1424 	assert(this != 0);
   1425 	assert(IsActive);
   1426 
   1427 	if (!IsToDisplay) {
   1428 		IsToDisplay = true;
   1429 
   1430 		/*
   1431 		**	This tells the map rendering logic to "go through the motions" and call the
   1432 		**	rendering function. In the rendering function, it will sort out what gets
   1433 		**	rendered and what doesn't.
   1434 		*/
   1435 		Map.Flag_To_Redraw(false);
   1436 	}
   1437 }
   1438 
   1439 
   1440 /***********************************************************************************************
   1441  * ObjectClass::Limbo -- Brings the object into a state of limbo.                              *
   1442  *                                                                                             *
   1443  *    An object brought into a state of limbo by this routine can be safely deleted. This      *
   1444  *    routine will remove the object from all game lists and tracking systems. It is called    *
   1445  *    prior to deleting the object or placing the object "on ice".                             *
   1446  *                                                                                             *
   1447  * INPUT:   none                                                                               *
   1448  *                                                                                             *
   1449  * OUTPUT:  bool; Was the object successfully placed in limbo?                                 *
   1450  *                                                                                             *
   1451  * WARNINGS:   none                                                                            *
   1452  *                                                                                             *
   1453  * HISTORY:                                                                                    *
   1454  *   09/24/1994 JLB : Created.                                                                 *
   1455  *=============================================================================================*/
   1456 bool ObjectClass::Limbo(void)
   1457 {
   1458 	assert(this != 0);
   1459 	assert(IsActive);
   1460 
   1461 	if (GameActive && !IsInLimbo) {
   1462 
   1463 		//Unselect();
   1464 		// Updated to function for multiplayer - 6/26/2019 JAS
   1465 		Unselect_All_Players();
   1466 
   1467 		Detach_All();
   1468 		Mark(MARK_UP);
   1469 
   1470 		/*
   1471 		**	Remove the object from the appropriate display list.
   1472 		*/
   1473 		Map.Remove(this, In_Which_Layer());
   1474 
   1475 		/*
   1476 		**	Remove the object from the logic processing list.
   1477 		*/
   1478 		if (Class_Of().IsSentient) {
   1479 			Logic.Delete(this);
   1480 		}
   1481 
   1482 		Hidden();
   1483 		IsInLimbo = true;
   1484 		IsToDisplay = false;
   1485 		return(true);
   1486 	}
   1487 	return(false);
   1488 }
   1489 
   1490 
   1491 /***********************************************************************************************
   1492  * ObjectClass::Unlimbo -- Brings the object into the game system.                             *
   1493  *                                                                                             *
   1494  *    This routine will place the object into the game tracking and display systems. It is     *
   1495  *    called as a consequence of creating the object. Every game object must be unlimboed at   *
   1496  *    some point.                                                                              *
   1497  *                                                                                             *
   1498  * INPUT:   coord -- The coordinate to place the object into the game system.                  *
   1499  *                                                                                             *
   1500  *          dir (optional) -- initial facing direction for this object                         *
   1501  *                                                                                             *
   1502  * OUTPUT:  bool; Was the game object successfully unlimboed?                                  *
   1503  *                                                                                             *
   1504  * WARNINGS:   none                                                                            *
   1505  *                                                                                             *
   1506  * HISTORY:                                                                                    *
   1507  *   09/24/1994 JLB : Created.                                                                 *
   1508  *   12/23/1994 JLB : Sets object strength.                                                    *
   1509  *=============================================================================================*/
   1510 bool ObjectClass::Unlimbo(COORDINATE coord, DirType )
   1511 {
   1512 	assert(this != 0);
   1513 	assert(IsActive);
   1514 	if (GameActive && IsInLimbo && !IsDown) {
   1515 		if (ScenarioInit || Can_Enter_Cell(Coord_Cell(coord), FACING_NONE) == MOVE_OK) {
   1516 			IsInLimbo = false;
   1517 			IsToDisplay = false;
   1518 			Coord = Class_Of().Coord_Fixup(coord);
   1519 
   1520 			if (Mark(MARK_DOWN)) {
   1521 				if (IsActive) {
   1522 
   1523 					/*
   1524 					**	Add the object to the appropriate map layer. This layer is used
   1525 					**	for rendering purposes.
   1526 					*/
   1527 					if (In_Which_Layer() != LAYER_NONE) {
   1528 						Map.Submit(this, In_Which_Layer());
   1529 					}
   1530 
   1531 					if (Class_Of().IsSentient) {
   1532 						Logic.Submit(this);
   1533 					}
   1534 				}
   1535 				return(true);
   1536 			}
   1537 		}
   1538 	}
   1539 	return(false);
   1540 }
   1541 
   1542 
   1543 /***********************************************************************************************
   1544  * ObjectClass::Detach -- Detach the specified target from this object.                        *
   1545  *                                                                                             *
   1546  *    This routine is called when the object (as specified) is to be removed from the game     *
   1547  *    engine and thus, all references to it must be severed. Typically, the only thing         *
   1548  *    checked for at this level is the attached trigger.                                       *
   1549  *                                                                                             *
   1550  * INPUT:   target   -- The target that will be removed from the game system.                  *
   1551  *                                                                                             *
   1552  * OUTPUT:  none                                                                               *
   1553  *                                                                                             *
   1554  * WARNINGS:   none                                                                            *
   1555  *                                                                                             *
   1556  * HISTORY:                                                                                    *
   1557  *   07/29/1996 JLB : Created.                                                                 *
   1558  *=============================================================================================*/
   1559 void ObjectClass::Detach(TARGET target, bool )
   1560 {
   1561 	if (Trigger.Is_Valid() && Is_Target_Trigger(target) && Trigger->As_Target() == target) {
   1562 		Attach_Trigger(NULL);
   1563 	}
   1564 }
   1565 
   1566 
   1567 /***********************************************************************************************
   1568  * ObjectClass::Detach_All -- Removes the object from all tracking systems.                    *
   1569  *                                                                                             *
   1570  *    This routine will take the object and see that it is removed from all miscellaneous      *
   1571  *    tracking systems in the game. This operation is vital when deleting an object. It is     *
   1572  *    necessary so that when the object is removed from the game, existing game objects won't  *
   1573  *    be referencing a now invalid game object. This typically affects the targeting           *
   1574  *    and navigation computers of other game objects.                                          *
   1575  *                                                                                             *
   1576  * INPUT:   none                                                                               *
   1577  *                                                                                             *
   1578  * OUTPUT:  none                                                                               *
   1579  *                                                                                             *
   1580  * WARNINGS:   none                                                                            *
   1581  *                                                                                             *
   1582  * HISTORY:                                                                                    *
   1583  *   09/24/1994 JLB : Created.                                                                 *
   1584  *=============================================================================================*/
   1585 void ObjectClass::Detach_All(bool all)
   1586 {
   1587 	assert(this != 0);
   1588 	assert(IsActive);
   1589 
   1590 	/*
   1591 	**	Unselect this object if it was selected.
   1592 	*/
   1593 	//if (all || Owner() != PlayerPtr->Class->House) {
   1594 	//	Unselect();
   1595 	//}
   1596 
   1597 	//Added some error handling incase there was an issue removing the object - JAS 6/28/2019
   1598 	if (all) {
   1599 		//Unselect();
   1600 		// Updated to function for multiplayer - 6/28/2019 JAS
   1601 		Unselect_All_Players();
   1602 	}
   1603 	else
   1604 	{
   1605 		Unselect_All_Players_Except_Owner();
   1606 	}
   1607 	//End of change - JAS 6/28/2019
   1608 
   1609 	Map.Detach(this);
   1610 
   1611 	/*
   1612 	**	Remove from targeting computers.
   1613 	*/
   1614 	Detach_This_From_All(As_Target(), all);
   1615 }
   1616 
   1617 
   1618 /***********************************************************************************************
   1619  * ObjectClass::Receive_Message -- Processes an incoming radio message.                        *
   1620  *                                                                                             *
   1621  *    Any radio message received that applies to objects in general are handled by this        *
   1622  *    routine. Typically, this is the "redraw" message, which occurs when another object is    *
   1623  *    loading or unloading and thus overlapping.                                               *
   1624  *                                                                                             *
   1625  * INPUT:   message  -- The message received.                                                  *
   1626  *                                                                                             *
   1627  * OUTPUT:  Returns with the appropriate radio response. If the message was recognized, then   *
   1628  *          RADIO_ROGER is returned, otherwise, just RADIO_STATIC is returned.                 *
   1629  *                                                                                             *
   1630  * WARNINGS:   none                                                                            *
   1631  *                                                                                             *
   1632  * HISTORY:                                                                                    *
   1633  *   09/24/1994 JLB : Created.                                                                 *
   1634  *=============================================================================================*/
   1635 RadioMessageType ObjectClass::Receive_Message(RadioClass *, RadioMessageType message, long & )
   1636 {
   1637 	assert(this != 0);
   1638 	assert(IsActive);
   1639 
   1640 	switch (message) {
   1641 
   1642 		/*
   1643 		**	This message serves as a rendering convenience. It lets the system
   1644 		**	know that there might be a visual conflict and the unit in radio
   1645 		**	contact should be redrawn. This typically occurs when a vehicle
   1646 		**	is being unloaded from a hover lander.
   1647 		*/
   1648 		case RADIO_REDRAW:
   1649 			Mark(MARK_CHANGE);
   1650 			return(RADIO_ROGER);
   1651 
   1652 		default:
   1653 			break;
   1654 	}
   1655 	return(RADIO_STATIC);
   1656 }
   1657 
   1658 
   1659 /***********************************************************************************************
   1660  * ObjectClass::Take_Damage -- Applies damage to the object.                                   *
   1661  *                                                                                             *
   1662  *    This routine applies damage to the object according to the damage parameters. It handles *
   1663  *    reducing the strength of the object and also returns the result of that damage. The      *
   1664  *    result value can be examined to determine if the object was destroyed, greatly damaged,  *
   1665  *    or other results.                                                                        *
   1666  *                                                                                             *
   1667  * INPUT:   damage   -- Reference to the damage number to apply. This number will be adjusted  *
   1668  *                      according to defensive armor and distance. Examine this value after    *
   1669  *                      the call to determine the actual amount of damage applied.             *
   1670  *                                                                                             *
   1671  *          distance -- The distance (in leptons) from the center of the damage causing        *
   1672  *                      explosion to the object itself.                                        *
   1673  *                                                                                             *
   1674  *          warhead  -- The warhead type that is causing the damage.                           *
   1675  *                                                                                             *
   1676  *          source   -- The perpetrator of this damage.                                        *
   1677  *                                                                                             *
   1678  *          forced   -- Is the damage forced upon the object regardless of whether it          *
   1679  *                      is normally immune?                                                    *
   1680  *                                                                                             *
   1681  * OUTPUT:  Returns the ResultType that indicates what the affect of the damage was.           *
   1682  *                                                                                             *
   1683  * WARNINGS:   none                                                                            *
   1684  *                                                                                             *
   1685  * HISTORY:                                                                                    *
   1686  *   11/29/1994 JLB : Created.                                                                 *
   1687  *   12/27/1994 JLB : Trigger event processing for attacked or destroyed.                      *
   1688  *   01/01/1995 JLB : Reduces damage greatly depending on range.                               *
   1689  *=============================================================================================*/
   1690 ResultType ObjectClass::Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source, bool forced)
   1691 {
   1692 	assert(this != 0);
   1693 	assert(IsActive);
   1694 
   1695 	ResultType result = RESULT_NONE;
   1696 	int oldstrength = Strength;
   1697 
   1698 	if (oldstrength && damage != 0 && (forced || !Class_Of().IsImmune)) {
   1699 		int maxstrength = Class_Of().MaxStrength;
   1700 
   1701 		/*
   1702 		**	Modify damage based on the warhead type and the armor of the object. This results
   1703 		**	in a reduced damage value, but never below 1 damage point.  Unless
   1704 		** it's forced damage, in which case we want full damage.
   1705 		*/
   1706 		if (!forced /*&& damage > 0*/) {
   1707 			damage = Modify_Damage(damage, warhead, Class_Of().Armor, distance);
   1708 
   1709 			/*
   1710 			**	Special hack to ensure that dogs only do damage to intended victim and no
   1711 			**	damage to others.
   1712 			*/
   1713 			if (source && source->What_Am_I() == RTTI_INFANTRY && ((InfantryClass *)source)->Class->IsDog) {
   1714 				if (source->TarCom == As_Target()) {
   1715 					damage = Strength;
   1716 				} else {
   1717 					damage = 0;
   1718 				}
   1719 			}
   1720 		}
   1721 		if (damage == 0) return(RESULT_NONE);
   1722 
   1723 		/*
   1724 		** Are we healing/repairing?  If so, add strength, but in
   1725 		** any case, return that no damage was done.
   1726 		*/
   1727 		if (damage < 0) {
   1728 #ifdef FIXIT_CSII	//	checked - ajw 9/28/98
   1729 			if (What_Am_I() == RTTI_INFANTRY || What_Am_I() == RTTI_UNIT || What_Am_I() == RTTI_AIRCRAFT) {
   1730 #else
   1731 			if (What_Am_I() == RTTI_INFANTRY) {
   1732 #endif
   1733 				Clicked_As_Target(PlayerPtr->Class->House, 7); // 2019/09/20 JAS - Added record of who clicked on the object
   1734 				Strength -= damage;
   1735 				if (Strength > maxstrength) {
   1736 					Strength = maxstrength;
   1737 				}
   1738 			}
   1739 			return(RESULT_NONE);
   1740 		}
   1741 
   1742 		/*
   1743 		**	At this point, we KNOW that at least light damage has occurred.
   1744 		*/
   1745 		result = RESULT_LIGHT;
   1746 
   1747 		/*
   1748 		**	A non-fatal blow has occurred. Check to see if the object transitioned to below
   1749 		**	half strength or if it is now down to one hit point.
   1750 		*/
   1751 		if (oldstrength > damage) {
   1752 
   1753 			if (oldstrength >= (maxstrength >> 1) && (oldstrength-damage) < (maxstrength >> 1)) {
   1754 				result = RESULT_HALF;
   1755 			}
   1756 		} else {
   1757 
   1758 			/*
   1759 			**	When an object is damaged to destruction, it will instead stop at one
   1760 			**	damage point. This will prolong the damage state as well as
   1761 			**	give greater satisfaction when it is finally destroyed.
   1762 			*/
   1763 			damage = oldstrength;
   1764 		}
   1765 
   1766 		/*
   1767 		**	Apply the damage to the object.
   1768 		*/
   1769 		Strength = oldstrength - damage;
   1770 
   1771 		/*
   1772 		**	Check to see if the object is majorly damaged or destroyed.
   1773 		*/
   1774 		switch (Strength) {
   1775 			case 0:
   1776 				Record_The_Kill(source);
   1777 				result = RESULT_DESTROYED;
   1778 				if (this->Is_Techno()) {
   1779 					if (this == ::As_Object(((TechnoClass *)this)->House->UnitToTeleport)) ((TechnoClass *)this)->House->UnitToTeleport = 0;
   1780 				}
   1781 				Detach_All();
   1782 				break;
   1783 
   1784 			case 1:
   1785 				result = RESULT_MAJOR;
   1786 				break;
   1787 
   1788 			default:
   1789 				break;
   1790 		}
   1791 
   1792 		/*
   1793 		**	Handle any trigger event associated with this object.
   1794 		*/
   1795 		if (source && Trigger.Is_Valid() && result != RESULT_DESTROYED) {
   1796 			Trigger->Spring(TEVENT_ATTACKED, this);
   1797 		}
   1798 
   1799 		/*
   1800 		**	If any damage was assessed and this object is selected, then flag
   1801 		**	the object to be redrawn so that the health bar will be updated.
   1802 		*/
   1803 		//if (result != RESULT_NONE && IsSelected) {
   1804 		// Updated to function for multiplayer - 6/26/2019 JAS
   1805 		if (result != RESULT_NONE && Is_Selected_By_Player()) {			
   1806 			Mark(MARK_CHANGE);
   1807 		}
   1808 	}
   1809 
   1810 	/*
   1811 	**	Return with the result of the damage taken.
   1812 	*/
   1813 	return(result);
   1814 }
   1815 
   1816 
   1817 /***********************************************************************************************
   1818  * ObjectClass::Mark -- Handles basic marking logic.                                           *
   1819  *                                                                                             *
   1820  *    This routine handles the base logic for marking an object up or down on the map. It      *
   1821  *    manages the IsDown flag as well as flagging the object to be redrawn if necessary.       *
   1822  *    Whenever an object is to be marked, it should call this base class function first. If    *
   1823  *    this function returns true, then the higher level function should proceed with its own   *
   1824  *    logic.                                                                                   *
   1825  *                                                                                             *
   1826  * INPUT:   mark  -- The marking method to use for this object. It can be either MARK_DOWN,    *
   1827  *                   MARK_UP, or MARK_CHANGE.                                                  *
   1828  *                                                                                             *
   1829  * OUTPUT:  bool; Was the object marked successfully?                                          *
   1830  *                                                                                             *
   1831  * WARNINGS:   none                                                                            *
   1832  *                                                                                             *
   1833  * HISTORY:                                                                                    *
   1834  *   01/23/1995 JLB : Created.                                                                 *
   1835  *=============================================================================================*/
   1836 bool ObjectClass::Mark(MarkType mark)
   1837 {
   1838 	assert(this != 0);
   1839 	assert(IsActive);
   1840 
   1841 	if (!IsInLimbo && IsActive) {
   1842 
   1843 		/*
   1844 		**	A mark for change is always successful UNLESS the object
   1845 		**	is not placed down or has already been flagged as changed
   1846 		**	this game frame.
   1847 		*/
   1848 		if (mark == MARK_CHANGE || mark == MARK_CHANGE_REDRAW) {
   1849 			if (IsToDisplay && mark != MARK_CHANGE_REDRAW) return(false);
   1850 			if (IsDown) {
   1851 				Mark_For_Redraw();
   1852 				return(true);
   1853 			}
   1854 			return(false);
   1855 		}
   1856 
   1857 		/*
   1858 		** Handle adding or removing the object in the cells' overlap lists
   1859 		*/
   1860 		if (mark == MARK_OVERLAP_UP) {
   1861 			if (IsDown == true) {
   1862 				if (Class_Of().IsFootprint) {
   1863 					Map.Overlap_Up(Coord_Cell(Coord), this);
   1864 				}
   1865 				Mark_For_Redraw();
   1866 				return(true);
   1867 			}
   1868 		}
   1869 		if (mark == MARK_OVERLAP_DOWN) {
   1870 			if (IsDown == true) {
   1871 				if (Class_Of().IsFootprint) {
   1872 					Map.Overlap_Down(Coord_Cell(Coord), this);
   1873 				}
   1874 				Mark_For_Redraw();
   1875 				return(true);
   1876 			}
   1877 		}
   1878 
   1879 		/*
   1880 		** It is important to know whether the object is a techno class
   1881 		** or not to see if we have to adjust the regional threat ratings
   1882 		*/
   1883 		int threat = 0;
   1884 		HousesType house = HOUSE_NONE;
   1885 		CELL cell = 0;
   1886 		TechnoClass * tech;
   1887 		if (Is_Techno()) {
   1888 			tech 	 = (TechnoClass *)this;
   1889 			threat = tech->Risk();
   1890 			house  = tech->Owner();
   1891 			cell   = Coord_Cell(Coord);
   1892 		} else {
   1893 			tech = NULL;
   1894 		}
   1895 
   1896 		/*
   1897 		**	Marking down is only successful if the object isn't already
   1898 		**	placed down.
   1899 		*/
   1900 		if (mark == MARK_DOWN && !IsDown) {
   1901 			if (tech && Session.Type == GAME_NORMAL && In_Which_Layer() == LAYER_GROUND) {
   1902 				Map[cell].Adjust_Threat(house, threat);
   1903 			}
   1904 			IsDown = true;
   1905 			Mark_For_Redraw();
   1906 			return(true);
   1907 		}
   1908 
   1909 		/*
   1910 		**	Lifting up is only successful if the object isn't already
   1911 		**	lifted up from the map.
   1912 		*/
   1913 		if (mark == MARK_UP && IsDown) {
   1914 			if (tech && Session.Type == GAME_NORMAL && In_Which_Layer() == LAYER_GROUND) {
   1915 				Map[cell].Adjust_Threat(house, -threat);
   1916 			}
   1917 			if (Class_Of().IsFootprint) {
   1918 				Map.Overlap_Up(Coord_Cell(Coord), this);
   1919 			}
   1920 			IsDown = false;
   1921 			return(true);
   1922 		}
   1923 	}
   1924 	return(false);
   1925 }
   1926 
   1927 
   1928 /***********************************************************************************************
   1929  * ObjectClass::Init -- Initializes the basic object system.                                   *
   1930  *                                                                                             *
   1931  *    This routine should be called when the basic object system needs to be initialized. This *
   1932  *    occurs when the scenario is about to be loaded.                                          *
   1933  *                                                                                             *
   1934  * INPUT:   none                                                                               *
   1935  *                                                                                             *
   1936  * OUTPUT:  none                                                                               *
   1937  *                                                                                             *
   1938  * WARNINGS:   none                                                                            *
   1939  *                                                                                             *
   1940  * HISTORY:                                                                                    *
   1941  *   01/23/1995 JLB : Created.                                                                 *
   1942  *=============================================================================================*/
   1943 void ObjectClass::Init(void)
   1944 {
   1945 	CurrentObject.Clear_All();
   1946 }
   1947 
   1948 
   1949 /***********************************************************************************************
   1950  * ObjectClass::Revealed -- Reveals this object to the house specified.                        *
   1951  *                                                                                             *
   1952  *    This routine is called when this object gets revealed to the house specified.            *
   1953  *                                                                                             *
   1954  * INPUT:   house -- Pointer to the house that this object is being revealed to.               *
   1955  *                                                                                             *
   1956  * OUTPUT:  Was this object revealed for the first time to this house? Generic objects always  *
   1957  *          return true unless an invalid house pointer was specified.                         *
   1958  *                                                                                             *
   1959  * WARNINGS:   none                                                                            *
   1960  *                                                                                             *
   1961  * HISTORY:                                                                                    *
   1962  *   07/19/1995 JLB : Created.                                                                 *
   1963  *=============================================================================================*/
   1964 bool ObjectClass::Revealed(HouseClass * house)
   1965 {
   1966 	assert(this != 0);
   1967 	assert(IsActive);
   1968 
   1969 	return(house != NULL);
   1970 }
   1971 
   1972 
   1973 
   1974 
   1975 /***********************************************************************************************
   1976  * ObjectClass::Set_Selected_By_Player -- Set this object as selected by the given player or   *
   1977  *														the default player.											  *
   1978  *                                                                                             *
   1979  * INPUT:   Player pointer                                                                     *
   1980  *                                                                                             *
   1981  * OUTPUT:                                                                                     *
   1982  *                                                                                             *
   1983  * WARNINGS:   none                                                                            *
   1984  *                                                                                             *
   1985  * HISTORY:                                                                                    *
   1986  *   6/25/2019 - JAS																									  *
   1987  *=============================================================================================*/
   1988 void ObjectClass::Set_Selected_By_Player(HouseClass *player)
   1989 {
   1990 	if (!player || !player->Class) {
   1991 		player = PlayerPtr;
   1992 	}
   1993 
   1994 	HousesType house = player->Class->House;
   1995 	if (((TechnoTypeClass const &)Class_Of()).IsLeader) {
   1996 		CurrentObject.Add_Head(house, this);
   1997 	}
   1998 	else {
   1999 		CurrentObject.Add(house, this);
   2000 	}
   2001 
   2002 	int shift = (int)house;
   2003 	IsSelectedMask |= (1 << shift);
   2004 
   2005 	if (Session.Type == GAME_NORMAL && player == PlayerPtr) {
   2006 		IsSelected = true;
   2007 	}
   2008 }
   2009 
   2010 /***********************************************************************************************
   2011  * ObjectClass::Set_Unselected_By_Player -- Set this object as unselected by the given player  *
   2012  *														orthe default player.										  *
   2013  *                                                                                             *
   2014  * INPUT:   Player pointer                                                                     *
   2015  *                                                                                             *
   2016  * OUTPUT:                                                                                     *
   2017  *                                                                                             *
   2018  * WARNINGS:   none                                                                            *
   2019  *                                                                                             *
   2020  * HISTORY:                                                                                    *
   2021  *   6/25/2019 - JAS																									  *
   2022  *=============================================================================================*/
   2023 void ObjectClass::Set_Unselected_By_Player(HouseClass *player)
   2024 {
   2025 	if (!player || !player->Class) {
   2026 		player = PlayerPtr;
   2027 	}
   2028 
   2029 	HousesType house = player->Class->House;
   2030 	CurrentObject.Delete(house, this);
   2031 
   2032 	int shift = (int)house;
   2033 	IsSelectedMask &= ~(1 << shift);
   2034 
   2035 	if (Session.Type == GAME_NORMAL && player == PlayerPtr) {
   2036 		IsSelected = false;
   2037 	}
   2038 }
   2039 
   2040 /***********************************************************************************************
   2041  * ObjectClass::Is_Selected_By_Player -- Has this object been selected by the given player	  *
   2042  *                                                                                             *
   2043  * INPUT:   Player pointer                                                                     *
   2044  *                                                                                             *
   2045  * OUTPUT:  True if selected by that player                                                    *
   2046  *                                                                                             *
   2047  * WARNINGS:   none                                                                            *
   2048  *                                                                                             *
   2049  * HISTORY:                                                                                    *
   2050  *   6/25/2019	- JAS 																								  *
   2051  *=============================================================================================*/
   2052 bool ObjectClass::Is_Selected_By_Player(HouseClass *player) const
   2053 {
   2054 	if (player && player->Class) {
   2055 		int shift = (int)player->Class->House;
   2056 		return (IsSelectedMask & (1 << shift)) ? true : false;
   2057 	}
   2058 	else {
   2059 		int shift = (int)PlayerPtr->Class->House;
   2060 		return (IsSelectedMask & (1 << shift)) ? true : false;
   2061 	}
   2062 	return false;
   2063 }
   2064 
   2065 
   2066 
   2067 
   2068 /***********************************************************************************************
   2069  * ObjectClass::Paradrop -- Unlimbos object in paradrop mode.                                  *
   2070  *                                                                                             *
   2071  *    Call this routine as a replacement for Unlimbo() if the object is to be paradropped onto *
   2072  *    the playing field.                                                                       *
   2073  *                                                                                             *
   2074  * INPUT:   coord -- The desired landing coordinate to give the dropping unit.                 *
   2075  *                                                                                             *
   2076  * OUTPUT:  bool; Was the object successfully unlimboed and has begun paradropping?            *
   2077  *                                                                                             *
   2078  * WARNINGS:   The unit may not be successful in paradropping if the desired destination       *
   2079  *             location cannot be occupied by the object.                                      *
   2080  *                                                                                             *
   2081  * HISTORY:                                                                                    *
   2082  *   02/07/1996 JLB : Created.                                                                 *
   2083  *=============================================================================================*/
   2084 bool ObjectClass::Paradrop(COORDINATE coord)
   2085 {
   2086 	assert(this != 0);
   2087 	assert(IsActive);
   2088 
   2089 	Height = FLIGHT_LEVEL;
   2090 	IsFalling = true;
   2091 	if (Unlimbo(coord, DIR_S)) {
   2092 		AnimClass * anim = NULL;
   2093 
   2094 		if (What_Am_I() == RTTI_BULLET) {
   2095 			anim = new AnimClass(ANIM_PARA_BOMB, Coord_Move(Center_Coord(), DIR_N, 0x0030 + Height));
   2096 		} else {
   2097 			anim = new AnimClass(ANIM_PARACHUTE, Coord_Move(Center_Coord(), DIR_N, 0x0030 + Height));
   2098 		}
   2099 
   2100 		/*
   2101 		**	If the animation was created, then attach it to this object.
   2102 		*/
   2103 		if (anim != NULL) {
   2104 			anim->Attach_To(this);
   2105 		}
   2106 		return(true);
   2107 	}
   2108 	return(false);
   2109 }
   2110 
   2111 
   2112 /***********************************************************************************************
   2113  * ObjectClass::Attach_Trigger -- Attach specified trigger to object.                          *
   2114  *                                                                                             *
   2115  *    This routine is used to attach the specified trigger to the object.                      *
   2116  *                                                                                             *
   2117  * INPUT:   trigger  -- Pointer to the trigger to attach. If any existing trigger is desired   *
   2118  *                      to be detached, then pass NULL to this routine.                        *
   2119  *                                                                                             *
   2120  * OUTPUT:  bool; Was the trigger attached?                                                    *
   2121  *                                                                                             *
   2122  * WARNINGS:   none                                                                            *
   2123  *                                                                                             *
   2124  * HISTORY:                                                                                    *
   2125  *   05/06/1996 JLB : Created.                                                                 *
   2126  *=============================================================================================*/
   2127 bool ObjectClass::Attach_Trigger(TriggerClass * trigger)
   2128 {
   2129 	if (Trigger.Is_Valid()) {
   2130 		TriggerClass * tptr = Trigger;
   2131 		tptr->AttachCount--;
   2132 		Trigger = NULL;
   2133 	}
   2134 
   2135 	if (trigger) {
   2136 		Trigger = trigger;
   2137 		trigger->AttachCount++;
   2138 		return(true);
   2139 	}
   2140 	return(false);
   2141 }
   2142 
   2143 
   2144 // These can't be made inline (for various reasons).
   2145 short const * ObjectClass::Occupy_List(bool placement) const {return(Class_Of().Occupy_List(placement));};
   2146 short const * ObjectClass::Overlap_List(bool ) const {return(Class_Of().Overlap_List());};
   2147 BuildingClass * ObjectClass::Who_Can_Build_Me(bool intheory, bool legal) const {return(Class_Of().Who_Can_Build_Me(intheory, legal, Owner()));};
   2148 fixed ObjectClass::Health_Ratio(void) const {return(fixed(Strength, Class_Of().MaxStrength));};
   2149 int ObjectClass::Full_Name(void) const {return Class_Of().Full_Name();};
   2150 
   2151 
   2152 //**********************************************************************************************
   2153 // MODULE SEPARATION -- ObjectTypeClass member functions follow.
   2154 //**********************************************************************************************
   2155 
   2156 
   2157 /***********************************************************************************************
   2158  * ObjectTypeClass::ObjectTypeClass -- Normal constructor for object type class objects.       *
   2159  *                                                                                             *
   2160  *    This is the base constructor that is used when constructing the object type classes.     *
   2161  *    Every tangible game piece type calls this constructor for the ObjectTypeClass. This      *
   2162  *    class holds static information that is common to objects in general.                     *
   2163  *                                                                                             *
   2164  * INPUT:   see below...                                                                       *
   2165  *                                                                                             *
   2166  * OUTPUT:  none                                                                               *
   2167  *                                                                                             *
   2168  * WARNINGS:   none                                                                            *
   2169  *                                                                                             *
   2170  * HISTORY:                                                                                    *
   2171  *   03/23/1995 JLB : Created.                                                                 *
   2172  *=============================================================================================*/
   2173 ObjectTypeClass::ObjectTypeClass(
   2174 						RTTIType rtti,
   2175 						int id,
   2176 						bool is_sentient,
   2177 						bool is_stealthy,
   2178 						bool is_selectable,
   2179 						bool is_legal_target,
   2180 						bool is_insignificant,
   2181 						bool is_immune,
   2182 						bool is_footprint,
   2183 						int name,
   2184 						char const * ini) :
   2185 	AbstractTypeClass(rtti, id, name, ini),
   2186 	IsCrushable(false),
   2187 	IsStealthy(is_stealthy),
   2188 	IsSelectable(is_selectable),
   2189 	IsLegalTarget(is_legal_target),
   2190 	IsInsignificant(is_insignificant),
   2191 	IsImmune(is_immune),
   2192 	IsSentient(is_sentient),
   2193 	IsFootprint(is_footprint),
   2194 	Armor(ARMOR_NONE),
   2195 	MaxStrength(0),
   2196 	ImageData(0),
   2197 	RadarIcon(0)
   2198 {
   2199 	/*
   2200 	** Init the DimensionData rect. Not sure how this was ever working before without being allocated. It was just trashing
   2201 	** memory later on when the pointer was being dereferenced and written to without being initialized. ST - 8/14/2019 3:15PM
   2202 	*/
   2203 	DimensionData = NULL;
   2204 }
   2205 
   2206 
   2207 /***********************************************************************************************
   2208  * ObjectTypeClass::Max_Pips -- Fetches the maximum pips allowed for this object.              *
   2209  *                                                                                             *
   2210  *    This routine will return the maximum number of pips that can be displayed for this       *
   2211  *    object. When dealing with generic objects, this value is always zero.                    *
   2212  *                                                                                             *
   2213  * INPUT:   none                                                                               *
   2214  *                                                                                             *
   2215  * OUTPUT:  Returns with the number of pip boxes (empty or otherwise) to display.              *
   2216  *                                                                                             *
   2217  * WARNINGS:   none                                                                            *
   2218  *                                                                                             *
   2219  * HISTORY:                                                                                    *
   2220  *   07/19/1995 JLB : Created.                                                                 *
   2221  *=============================================================================================*/
   2222 int ObjectTypeClass::Max_Pips(void) const
   2223 {
   2224 	return(0);
   2225 }
   2226 
   2227 
   2228 /***********************************************************************************************
   2229  * ObjectTypeClass::Dimensions -- Gets the dimensions of the object in pixels.                 *
   2230  *                                                                                             *
   2231  *    This routine will fetch the dimensions of this object expressed as pixels width and      *
   2232  *    pixels height. This information can be used to intelligently update the clipping         *
   2233  *    rectangles.                                                                              *
   2234  *                                                                                             *
   2235  * INPUT:   width    -- Reference to the width variable that will be filled in.                *
   2236  *                                                                                             *
   2237  *          height   -- Reference to the height variable that will be filled in.               *
   2238  *                                                                                             *
   2239  * OUTPUT:  none                                                                               *
   2240  *                                                                                             *
   2241  * WARNINGS:   none                                                                            *
   2242  *                                                                                             *
   2243  * HISTORY:                                                                                    *
   2244  *   07/19/1995 JLB : Created.                                                                 *
   2245  *=============================================================================================*/
   2246 void ObjectTypeClass::Dimensions(int &width, int &height) const
   2247 {
   2248 	width = 10;
   2249 	height = 10;
   2250 }
   2251 
   2252 
   2253 /***********************************************************************************************
   2254  * ObjectTypeClass::Cost_Of -- Returns the cost to buy this unit.                              *
   2255  *                                                                                             *
   2256  *    This routine will return the cost to purchase this unit. This routine is expected to be  *
   2257  *    overridden by the objects that can actually be purchased. All other object types can     *
   2258  *    simply return zero since this value won't be used.                                       *
   2259  *                                                                                             *
   2260  * INPUT:   none                                                                               *
   2261  *                                                                                             *
   2262  * OUTPUT:  Returns the cost of the object.                                                    *
   2263  *                                                                                             *
   2264  * WARNINGS:   none                                                                            *
   2265  *                                                                                             *
   2266  * HISTORY:                                                                                    *
   2267  *   07/19/1995 JLB : Created.                                                                 *
   2268  *=============================================================================================*/
   2269 int ObjectTypeClass::Cost_Of(void) const
   2270 {
   2271 	return(0);
   2272 }
   2273 
   2274 
   2275 /***********************************************************************************************
   2276  * ObjectTypeClass::Time_To_Build -- Fetches the time to construct this object.                *
   2277  *                                                                                             *
   2278  *    This routine will fetch the time in takes to construct this object. Objects that can     *
   2279  *    be constructed will override this routine in order to return a useful value.             *
   2280  *                                                                                             *
   2281  * INPUT:   none                                                                               *
   2282  *                                                                                             *
   2283  * OUTPUT:  Returns with the time units (arbitrary) that it takes to construct this object.    *
   2284  *                                                                                             *
   2285  * WARNINGS:   none                                                                            *
   2286  *                                                                                             *
   2287  * HISTORY:                                                                                    *
   2288  *   07/19/1995 JLB : Created.                                                                 *
   2289  *=============================================================================================*/
   2290 int ObjectTypeClass::Time_To_Build(HousesType ) const
   2291 {
   2292 	return(0);
   2293 }
   2294 
   2295 
   2296 /***********************************************************************************************
   2297  * ObjectTypeClass::Get_Cameo_Data -- Fetches pointer to cameo data for this object type.      *
   2298  *                                                                                             *
   2299  *    This routine will return with the cameo data pointer for this object type. It is         *
   2300  *    expected that objects that can appear on the sidebar will override this routine in order *
   2301  *    to provide proper cameo data pointer.                                                    *
   2302  *                                                                                             *
   2303  * INPUT:   none                                                                               *
   2304  *                                                                                             *
   2305  * OUTPUT:  Returns with a pointer to the cameo shape data.                                    *
   2306  *                                                                                             *
   2307  * WARNINGS:   none                                                                            *
   2308  *                                                                                             *
   2309  * HISTORY:                                                                                    *
   2310  *   07/19/1995 JLB : Created.                                                                 *
   2311  *=============================================================================================*/
   2312 void const * ObjectTypeClass::Get_Cameo_Data(void) const
   2313 {
   2314 	return(NULL);
   2315 }
   2316 
   2317 
   2318 /***********************************************************************************************
   2319  * ObjectTypeClass::Occupy_List -- Returns with simple occupation list for object.             *
   2320  *                                                                                             *
   2321  *    This routine returns a pointer to a simple occupation list for this object. Since at     *
   2322  *    this tier of the object class chain, the exact shape of the object is indeterminate,     *
   2323  *    this function merely returns a single cell occupation list. This actually works for      *
   2324  *    most vehicles.                                                                           *
   2325  *                                                                                             *
   2326  * INPUT:   none                                                                               *
   2327  *                                                                                             *
   2328  * OUTPUT:  Returns a pointer to a simple occupation list.                                     *
   2329  *                                                                                             *
   2330  * WARNINGS:   none                                                                            *
   2331  *                                                                                             *
   2332  * HISTORY:                                                                                    *
   2333  *   05/28/1994 JLB : Created.                                                                 *
   2334  *=============================================================================================*/
   2335 short const * ObjectTypeClass::Occupy_List(bool) const
   2336 {
   2337 	static short const _list[] = {0, REFRESH_EOL};
   2338 	return(_list);
   2339 }
   2340 
   2341 
   2342 /***********************************************************************************************
   2343  * ObjectTypeClass::Overlap_List -- Returns a pointer to a simple overlap list.                *
   2344  *                                                                                             *
   2345  *    This function returns a pointer to an overlap list for the object. An overlap list is    *
   2346  *    the offsets from the object's cell to get the cells the imagery overlaps, but is object  *
   2347  *    is not considered to occupy. Since at this stage, the overlap information is not         *
   2348  *    available, this function merely returns a pointer to an empty list.                      *
   2349  *                                                                                             *
   2350  * INPUT:   none                                                                               *
   2351  *                                                                                             *
   2352  * OUTPUT:  Returns a pointer to the generic overlap list.                                     *
   2353  *                                                                                             *
   2354  * WARNINGS:   none                                                                            *
   2355  *                                                                                             *
   2356  * HISTORY:                                                                                    *
   2357  *   05/28/1994 JLB : Created.                                                                 *
   2358  *=============================================================================================*/
   2359 short const * ObjectTypeClass::Overlap_List(void) const
   2360 {
   2361 	static short const _list[] = {REFRESH_EOL};
   2362 	return(_list);
   2363 }
   2364 
   2365 
   2366 /***********************************************************************************************
   2367  * ObjectTypeClass::One_Time -- Handles one time processing for object types.                  *
   2368  *                                                                                             *
   2369  *    This routine is used to handle the once per game processing required for object types.   *
   2370  *    This consists of loading any data and initializing any data tables the game requires.    *
   2371  *                                                                                             *
   2372  * INPUT:   none                                                                               *
   2373  *                                                                                             *
   2374  * OUTPUT:  none                                                                               *
   2375  *                                                                                             *
   2376  * WARNINGS:   This routine goes to disk.                                                      *
   2377  *                                                                                             *
   2378  * HISTORY:                                                                                    *
   2379  *   11/01/1994 JLB : Created.                                                                 *
   2380  *=============================================================================================*/
   2381 void ObjectTypeClass::One_Time(void)
   2382 {
   2383 	SelectShapes = MFCD::Retrieve("SELECT.SHP");
   2384 
   2385 	#ifndef NDEBUG
   2386 		RawFileClass file("PIPS.SHP");
   2387 		if (file.Is_Available()) {
   2388 			PipShapes = Load_Alloc_Data(file);
   2389 		} else {
   2390 			PipShapes = MFCD::Retrieve("PIPS.SHP");
   2391 		}
   2392 	#else
   2393 		PipShapes = MFCD::Retrieve("PIPS.SHP");
   2394 	#endif
   2395 }
   2396 
   2397 
   2398 /***********************************************************************************************
   2399  * ObjectTypeClass::Who_Can_Build_Me -- Determine what building can build this object type.    *
   2400  *                                                                                             *
   2401  *    This routine will scan through all available factory buildings and determine which       *
   2402  *    is capable of building this object type. The scan can be controlled to scan for only     *
   2403  *    factory buildings that are free to produce now or those that could produce this          *
   2404  *    object type if conditions permit.                                                        *
   2405  *                                                                                             *
   2406  * INPUT:   intheory -- Should the general (when conditions permit) case be examined to see    *
   2407  *                      if a building could build this object type "in theory" even though it  *
   2408  *                      might currently be otherwise occupied?                                 *
   2409  *                                                                                             *
   2410  *          legal    -- Check for building prerequisite and technology level rules? Usually    *
   2411  *                      this would be 'true' for human controlled requests and 'false' for     *
   2412  *                      the computer. This is because the computer is usually not under        *
   2413  *                      the normal restrictions that the player is under.                      *
   2414  *                                                                                             *
   2415  * OUTPUT:  Returns with a pointer to the building that can produce the object of this         *
   2416  *          type. If no suitable factory building could be found, then NULL is returned.       *
   2417  *                                                                                             *
   2418  * WARNINGS:   none                                                                            *
   2419  *                                                                                             *
   2420  * HISTORY:                                                                                    *
   2421  *   07/29/1996 JLB : Created.                                                                 *
   2422  *=============================================================================================*/
   2423 BuildingClass * ObjectTypeClass::Who_Can_Build_Me(bool intheory, bool legal, HousesType house) const
   2424 {
   2425 	BuildingClass * anybuilding = NULL;
   2426 
   2427 	if (!intheory && What_Am_I() == RTTI_AIRCRAFTTYPE && ((AircraftTypeClass*)this)->IsFixedWing) {
   2428 		int num_builders = 0, num_fixed_wings = 0;
   2429 		for (int index = 0; index < Buildings.Count(); index++) {
   2430 			BuildingClass * building = Buildings.Ptr(index);
   2431 			assert(building != NULL);
   2432 
   2433 			if (	!building->IsInLimbo &&
   2434 					building->House->Class->House == house &&
   2435 					building->Class->ToBuild == RTTI &&
   2436 					building->Mission != MISSION_DECONSTRUCTION && building->MissionQueue != MISSION_DECONSTRUCTION &&
   2437 					((1L << building->ActLike) & Get_Ownable()) &&
   2438 					(!legal || building->House->Can_Build(this, building->ActLike))) {
   2439 				num_builders++;
   2440 			}
   2441 		}
   2442 		for (int index = 0; index < Aircraft.Count(); index++) {
   2443 			AircraftClass * aircraft = Aircraft.Ptr(index);
   2444 			assert(aircraft != NULL);
   2445 
   2446 			if (	!aircraft->IsInLimbo &&
   2447 					aircraft->House->Class->House == house &&
   2448 					aircraft->Class->IsFixedWing) {
   2449 				num_fixed_wings++;
   2450 			}
   2451 		}
   2452 		if (num_fixed_wings >= num_builders) {
   2453 			return NULL;
   2454 		}
   2455 	}
   2456 
   2457 	for (int index = 0; index < Buildings.Count(); index++) {
   2458 		BuildingClass * building = Buildings.Ptr(index);
   2459 		assert(building != NULL);
   2460 
   2461 		if (	!building->IsInLimbo &&
   2462 				building->House->Class->House == house &&
   2463 				building->Class->ToBuild == RTTI &&
   2464 				building->Mission != MISSION_DECONSTRUCTION && building->MissionQueue != MISSION_DECONSTRUCTION &&
   2465 				((1L << building->ActLike) & Get_Ownable()) &&
   2466 				(!legal || building->House->Can_Build(this, building->ActLike)) &&
   2467 				(intheory || !building->In_Radio_Contact())) {
   2468 
   2469 			// BG: Hack so only kennels can build dogs, and no other, and barracks can
   2470 			//     only build humans and no other.
   2471 			if (What_Am_I() == RTTI_INFANTRYTYPE) {
   2472 				InfantryTypeClass * me = (InfantryTypeClass *)this;
   2473 				if (me->IsDog) {
   2474 					if (*building == STRUCT_KENNEL) {
   2475 						if (building->IsLeader) return(building);
   2476 						anybuilding = building;
   2477 					}
   2478 				} else {
   2479 					if (*building != STRUCT_KENNEL) {
   2480 						if (building->IsLeader) return(building);
   2481 						anybuilding = building;
   2482 					}
   2483 				}
   2484 			} else {
   2485 
   2486 				/*
   2487 				**	HACK ALERT: Helipads can build aircraft and airstrips can build
   2488 				**	fixed wing craft only.
   2489 				*/
   2490 				if (What_Am_I() == RTTI_AIRCRAFTTYPE) {
   2491 					AircraftTypeClass * air = (AircraftTypeClass *)this;
   2492 					if ((*building == STRUCT_HELIPAD && !air->IsFixedWing) || (*building == STRUCT_AIRSTRIP && air->IsFixedWing)) {
   2493 						if (building->IsLeader) return(building);
   2494 						anybuilding = building;
   2495 					}
   2496 
   2497 				} else {
   2498 					if (building->IsLeader) return(building);
   2499 					anybuilding = building;
   2500 				}
   2501 			}
   2502 		}
   2503 	}
   2504 	return(anybuilding);
   2505 }