/*********************************************************** * StartRefreshCache ***********************************************************/ void HQueryItem::StartRefreshCache() { PRINT(("Refresh Query\n")); EmptyMailList(); if(fThread != -1) return; fDone = false; // Set icon to open folder BBitmap *icon = ((HApp*)be_app)->GetIcon("CloseQuery"); SetColumnContent(1,icon,2.0,false,false); StartGathering(); }
/** ** Control the unit action: getting a resource. ** ** This the generic function for oil, gold, ... ** ** @param unit Pointer to unit. */ void COrder_Resource::Execute(CUnit &unit) { // can be different by Cloning (trained unit)... this->worker = &unit; if (unit.Wait) { if (!unit.Waiting) { unit.Waiting = 1; unit.WaitBackup = unit.Anim; } //Wyrmgus start // UnitShowAnimation(unit, unit.Type->Animations->Still); UnitShowAnimation(unit, unit.GetAnimations()->Still); //Wyrmgus end unit.Wait--; return; } if (unit.Waiting) { unit.Anim = unit.WaitBackup; unit.Waiting = 0; } // Let's start mining. if (this->State == SUB_START_RESOURCE) { if (ActionResourceInit(unit) == false) { ResourceGiveUp(unit); return; } } // Move to the resource location. if (SUB_MOVE_TO_RESOURCE <= this->State && this->State < SUB_UNREACHABLE_RESOURCE) { const int ret = MoveToResource(unit); switch (ret) { case -1: { // Can't Reach this->State++; unit.Wait = 5; return; } case 1: { // Reached this->State = SUB_START_GATHERING; break; } case 0: // Move along. return; default: { Assert(0); break; } } } // Resource seems to be unreachable if (this->State == SUB_UNREACHABLE_RESOURCE) { if (this->FindAnotherResource(unit) == false) { ResourceGiveUp(unit); return; } } // Start gathering the resource if (this->State == SUB_START_GATHERING) { if (StartGathering(unit)) { this->State = SUB_GATHER_RESOURCE; } else { return; } } // Gather the resource. if (this->State == SUB_GATHER_RESOURCE) { if (GatherResource(unit)) { this->State = SUB_STOP_GATHERING; } else { return; } } // Stop gathering the resource. if (this->State == SUB_STOP_GATHERING) { if (StopGathering(unit)) { this->State = SUB_MOVE_TO_DEPOT; unit.pathFinderData->output.Cycles = 0; //moving counter } else { return; } } // Move back home. if (SUB_MOVE_TO_DEPOT <= this->State && this->State < SUB_UNREACHABLE_DEPOT) { const int ret = MoveToDepot(unit); switch (ret) { case -1: { // Can't Reach this->State++; unit.Wait = 5; return; } case 1: { // Reached this->State = SUB_RETURN_RESOURCE; return; } case 0: // Move along. return; default: { Assert(0); return; } } } // Depot seems to be unreachable if (this->State == SUB_UNREACHABLE_DEPOT) { ResourceGiveUp(unit); return; } // Unload resources at the depot. if (this->State == SUB_RETURN_RESOURCE) { if (WaitInDepot(unit)) { this->State = SUB_START_RESOURCE; // It's posible, though very rare that the unit's goal blows up // this cycle, but after this unit. Thus, next frame the unit // will start mining a destroyed site. If, on the otherhand we // are already in SUB_MOVE_TO_RESOURCE then we can handle it. // So, we pass through SUB_START_RESOURCE the very instant it // goes out of the depot. //HandleActionResource(order, unit); } } }