electronicarts/CnC_Remastered_Collection

Looking for method which handles selection of builindgs

wetswan opened this issue · 3 comments

Hi,
I'm trying to get an overview and wanted to start with something simple that should happen when a building is selected (just for testing). So far I have been unable to find the method/routine that handles selection of builindgs.
Could anybody please point me in the right direction?

I suppose there is the current "select object" logic :)

/***********************************************************************************************
* ObjectClass::Select -- Try to make this object the "selected" object. *
* *
* This routine is used to make this object into the one that is "selected". A selected *
* object usually displays a floating bar graph and is available to be given orders from *
* the player's I/O. *
* *
* INPUT: allow_mixed -- Allow a mix of player and non-player controlled units? *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/19/1994 JLB : Created. *
* 06/12/1995 JLB : Cannot select a loaner object. *
* 07/23/1995 JLB : Adds to head or tail depending on leader type flag. *
*=============================================================================================*/
bool ObjectClass::Select(bool allow_mixed)
{
assert(this != 0);
assert(IsActive);
//if (!Debug_Map && (IsSelected || !Class_Of().IsSelectable)) {
// return(false);
//}
// Updated to function for multiplayer - 6/26/2019 JAS
if (!Debug_Map && (Is_Selected_By_Player() || !Class_Of().IsSelectable)) {
return(false);
}
if (!Debug_Map && Can_Player_Move() && Is_Techno() && ((TechnoClass *)this)->IsALoaner) {
return(false);
}
/*
** Don't allow selection if the object is still in the air.
*/
if (Height > 0 && (What_Am_I() == RTTI_UNIT || What_Am_I() == RTTI_VESSEL || What_Am_I() == RTTI_INFANTRY)) {
return(false);
}
/*
** Don't allow selection of object when in building placement mode.
*/
if (Map.PendingObject) {
return(false);
}
if (!allow_mixed) {
/*
** If selecting an object of a different house than the player's, make sure that
** the entire selection list is cleared.
*/
for (int i = 0; i < CurrentObject.Count(); i++) {
HouseClass * tryhptr = HouseClass::As_Pointer(Owner());
HouseClass * oldhptr = HouseClass::As_Pointer(CurrentObject[i]->Owner());
// if (Owner() != CurrentObject[0]->Owner() || CurrentObject[0]->Owner() != PlayerPtr->Class->House) {
if (oldhptr->IsPlayerControl != tryhptr->IsPlayerControl) {
Unselect_All();
break;
}
}
}
if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_UP);
//IsSelected = true;
// Updated to function for multiplayer - 6/26/2019 JAS
Set_Selected_By_Player();
if (In_Which_Layer() == LAYER_GROUND) Mark(MARK_OVERLAP_DOWN);
return(true);
}

But i can be wrong because i'm not a c++ dev actually. Just also researching source code )

Or this one:

/***********************************************************************************************
* TechnoClass::Select -- Selects object and checks to see if can be selected. *
* *
* This function checks to see if this techno object can be selected. If it can, then it *
* is selected. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 12/11/1994 JLB : Created. *
*=============================================================================================*/
bool TechnoClass::Select(bool allow_mixed)
{
assert(IsActive);
//if (!IsDiscoveredByPlayer && !House->IsPlayerControl && !Debug_Unshroud) { // ST - 8/7/2019 11:24AM
if (!Is_Discovered_By_Player() && !House->IsPlayerControl && !Debug_Unshroud) {
return(false);
}
if (RadioClass::Select(allow_mixed)) {
/*
** Speak a confirmation of selection.
*/
if (House->IsPlayerControl && AllowVoice) {
Response_Select();
}
return(true);
}
return(false);
}

Thanks, good points. Will check those :) Still digging through it, would be great if there was some more documentation besides the code comments.