Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case RADIO_HELLO:
- //Refineries can't be interupted while they're processing a harvester - LLL April 22, 2020
- if (Mission == MISSION_HARVEST) {
- return(RADIO_NEGATIVE);
- }
- else if (Class->Type == STRUCT_REFINERY && ActiveCFEPatchConfig.EnableHarvyQueueJump && In_Radio_Contact()) {
- if (from->What_Am_I() == RTTI_UNIT && *((UnitClass*)from) == UNIT_HARVESTER) {
- UnitClass& currentHarvy = *static_cast<UnitClass*>(Contact_With_Whom());
- UnitClass& newHarvy = *static_cast<UnitClass*>(from);
- int currentHarvyDistance;
- int newHarvyDistance;
- int jumpcutoff;
- if (ActiveCFEPatchConfig.EnableASPathing){
- int currentHarvyDistanceAStar = currentHarvy.Find_Path_AStar(nullptr, Coord_Cell(currentHarvy.Coord), Coord_Cell(this->Center_Coord()), 1, MOVE_NO, -1);
- if (currentHarvyDistanceAStar){
- currentHarvyDistance = currentHarvyDistanceAStar;
- }
- else{ //either harvy is right on top of refinery, or no path at all
- int currentHarvyDistanceCrowFlies = currentHarvy.Distance(Coord_Cell(this->Center_Coord()));
- if (currentHarvyDistanceCrowFlies <= 6){
- currentHarvyDistance = currentHarvyDistanceCrowFlies;
- }
- else {
- currentHarvyDistance = INT_MAX;
- }
- }
- int newHarvyDistanceAStar = newHarvy.Find_Path_AStar(nullptr, Coord_Cell(newHarvy.Coord), Coord_Cell(this->Center_Coord()), 1, MOVE_NO, -1);
- if (newHarvyDistanceAStar){
- newHarvyDistance = newHarvyDistanceAStar;
- }
- else{ //either harvy is right on top of refinery, or no path at all
- int newHarvyDistanceCrowFlies = newHarvy.Distance(Coord_Cell(this->Center_Coord()));
- if (newHarvyDistanceCrowFlies <= 6){
- newHarvyDistance = newHarvyDistanceCrowFlies;
- }
- else {
- newHarvyDistance = INT_MAX;
- }
- }
- jumpcutoff = ActiveCFEPatchConfig.HarvyQueueJumpCutoff;
- }
- else{ // A-Star not enabled
- currentHarvyDistance = currentHarvy.Distance(this);
- newHarvyDistance = newHarvy.Distance(this);
- jumpcutoff = Cell_To_Lepton(ActiveCFEPatchConfig.HarvyQueueJumpCutoff); //distance to coords are in leptons, not cells, so need to convert
- }
- if (currentHarvyDistance > jumpcutoff && newHarvyDistance < currentHarvyDistance) {
- //Kick the current harvester out
- Transmit_Message(RADIO_CANCEL, ¤tHarvy);
- //Accept the new one
- return(TechnoClass::Receive_Message(from, message, param));
- }
- }
- }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement