/** ** Cancel Building researching. ** ** @param unit Pointer to unit. */ void CommandCancelResearch(CUnit *unit) { ReleaseOrders(unit); // empty command queue // // Check if unit is still researching? (NETWORK!) // if (unit->Orders[0]->Action == UnitActionResearch) { const CUpgrade *upgrade; upgrade = unit->Data.Research.Upgrade; unit->Player->UpgradeTimers.Upgrades[upgrade->ID] = 0; unit->Player->AddCostsFactor(upgrade->Costs, CancelResearchCostsFactor); unit->Orders[0]->Init(); unit->Orders[0]->Action = UnitActionStill; unit->SubAction = 0; // // Update interface. // if (unit->Player == ThisPlayer && unit->Selected) { SelectedUnitChanged(); } } ClearSavedAction(unit); }
/** ** Cancel building upgrading to. ** ** @param unit pointer to unit. */ void CommandCancelUpgradeTo(CUnit *unit) { ReleaseOrders(unit); // empty command queue // // Check if unit is still upgrading? (NETWORK!) // if (unit->Orders[0]->Action == UnitActionUpgradeTo) { unit->Player->AddCostsFactor( unit->Orders[0]->Type->Stats[unit->Player->Index].Costs, CancelUpgradeCostsFactor); unit->Orders[0]->Init(); unit->Orders[0]->Action = UnitActionStill; unit->SubAction = 0; // // Update interface. // if (unit->Player == ThisPlayer && unit->Selected) { SelectedUnitChanged(); } } ClearSavedAction(unit); }
/** ** Get next free order slot. ** ** @param unit pointer to unit. ** @param flush if true, flush order queue. ** ** @return Pointer to next free order slot. */ static COrder *GetNextOrder(CUnit *unit, int flush) { if (flush) { // empty command queue ReleaseOrders(unit); } if (unit->OrderCount == 0x7F) { return NULL; } unit->Orders.push_back(new COrder); return unit->Orders[(int)unit->OrderCount++]; }
/** ** Get next free order slot. ** ** @param unit pointer to unit. ** @param flush if true, flush order queue. ** ** @return Pointer to next free order slot. */ static COrderPtr *GetNextOrder(CUnit &unit, int flush) { if (flush) { // empty command queue ReleaseOrders(unit); } // FIXME : Remove Hardcoded value. const unsigned int maxOrderCount = 0x7F; if (unit.Orders.size() == maxOrderCount) { return NULL; } unit.Orders.push_back(NULL); return &unit.Orders.back(); }
/** ** Get next free order slot. ** ** @param unit pointer to unit. ** @param flush if true, flush order queue. ** ** @return Pointer to next free order slot. */ static COrderPtr *GetNextOrder(CUnit &unit, int flush) { //Wyrmgus start // if (flush) { if (flush && unit.CurrentAction() != UnitActionUpgradeTo && unit.CurrentAction() != UnitActionTrain && unit.CurrentAction() != UnitActionResearch) { //training, researching and upgrading must be canceled manually //Wyrmgus end // empty command queue ReleaseOrders(unit); } // FIXME : Remove Hardcoded value. const unsigned int maxOrderCount = 0x7F; if (unit.Orders.size() == maxOrderCount) { return NULL; } unit.Orders.push_back(NULL); return &unit.Orders.back(); }