/** * Build a piece of canal. * @param tile end tile of stretch-dragging * @param flags type of operation * @param p1 start tile of stretch-dragging * @param p2 waterclass to build. sea and river can only be built in scenario editor * @param text unused * @return the cost of this operation or an error */ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { WaterClass wc = Extract<WaterClass, 0, 2>(p2); if (p1 >= MapSize() || wc == WATER_CLASS_INVALID) return CMD_ERROR; /* Outside of the editor you can only build canals, not oceans */ if (wc != WATER_CLASS_CANAL && _game_mode != GM_EDITOR) return CMD_ERROR; TileArea ta(tile, p1); /* Outside the editor you can only drag canals, and not areas */ if (_game_mode != GM_EDITOR && ta.w != 1 && ta.h != 1) return CMD_ERROR; CommandCost cost(EXPENSES_CONSTRUCTION); TILE_AREA_LOOP(tile, ta) { CommandCost ret; Slope slope = GetTileSlope(tile, NULL); if (slope != SLOPE_FLAT && (wc != WATER_CLASS_RIVER || !IsInclinedSlope(slope))) { return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); } /* can't make water of water! */ if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue; ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; cost.AddCost(ret); if (flags & DC_EXEC) { switch (wc) { case WATER_CLASS_RIVER: MakeRiver(tile, Random()); break; case WATER_CLASS_SEA: if (TileHeight(tile) == 0) { MakeSea(tile); break; } /* FALL THROUGH */ default: MakeCanal(tile, _current_company, Random()); break; } MarkTileDirtyByTile(tile); MarkCanalsAndRiversAroundDirty(tile); } cost.AddCost(_price[PR_BUILD_CANAL]); }
void DepthVideoApp::ImportPointCloud(bool isSubThread) { if (IsCommandAvaliable() == false) { return; } if (isSubThread) { mCommandType = CT_IMPORT_POINTCLOUD; DoCommand(true); } else { std::vector<std::string> fileNames; char filterName[] = "ASC Files(*.asc)\0*.asc\0OBJ Files(*.obj)\0*.obj\0PLY Files(*.ply)\0*.ply\0Geometry++ Point Cloud(*.gpc)\0*.gpc\0"; if (MagicCore::ToolKit::MultiFileOpenDlg(fileNames, filterName)) { if (fileNames.size() == 0) { return; } mIsCommandInProgress = true; mSelectCloudIndex = 0; ClearPointCloudList(); mPointCloudList.reserve(fileNames.size()); for (int fileId = 0; fileId < fileNames.size(); fileId++) { GPP::PointCloud* pointCloud = GPP::Parser::ImportPointCloud(fileNames.at(fileId)); if (pointCloud == NULL) { continue; } if (mPointCloudList.empty()) { pointCloud->UnifyCoords(2.0, &mScaleValue, &mObjCenterCoord); } else { pointCloud->UnifyCoords(mScaleValue, mObjCenterCoord); } mPointCloudList.push_back(pointCloud); if (mPointCloudList.size() == 1) { mUpdatePointCloudListRendering = true; } mUpdateUIScrollBar = true; mProgressValue = int(fileId * 100.0 / fileNames.size()); } mIsCommandInProgress = false; } } }
void CEffectsTab::OnSharpen() { if (!DoCommand(_T("Sharpen"), _T("-1"))) return; EnableControl(IDC_SHARPEN, false); ShowControl(IDC_SHARPEN_APPLY, SW_SHOW); ShowControl(IDC_SHARPEN_CANCEL, SW_SHOW); m_SharpenSlider.SetPos(0); m_SharpenSlider.EnableWindow(true); m_iLastValue = -1; }
void CEffectsTab::OnEdges() { if (!DoCommand(_T("Edges"), _T("-1"))) return; EnableControl(IDC_EDGES, false); ShowControl(IDC_EDGES_APPLY, SW_SHOW); ShowControl(IDC_EDGES_CANCEL, SW_SHOW); m_EdgesSlider.SetPos(0); m_EdgesSlider.EnableWindow(true); m_iLastValue = -1; }
void CEffectsTab::OnSmooth() { if (!DoCommand(_T("Smooth"), _T("-1"))) return; EnableControl(IDC_SMOOTH, false); ShowControl(IDC_SMOOTH_APPLY, SW_SHOW); ShowControl(IDC_SMOOTH_CANCEL, SW_SHOW); m_SmoothSlider.SetPos(0); m_SmoothSlider.EnableWindow(true); m_iLastValue = -1; }
void CBordersTab::OnBorderImage() { CheckRadioButton(IDC_BORDER_NONE, IDC_BORDER_FADE, IDC_BORDER_IMAGE); //j m_btnChoose.EnableWindow(true); m_editBorderImageFileName.EnableWindow(true); m_comboFadedEdgeShape.EnableWindow(false); m_comboFadedEdgeDirection.EnableWindow(false); m_editFadedEdgeWidth.EnableWindow(false); m_editFadedEdgeOpacity.EnableWindow(false); DoCommand(_T("ActivateBorderImage"), _T("")); }
NS_IMETHODIMP nsXULTreeItemAccessibleBase::DoAction(PRUint8 aIndex) { if (IsDefunct()) return NS_ERROR_FAILURE; if (aIndex != eAction_Click && (aIndex != eAction_Expand || !IsExpandable())) return NS_ERROR_INVALID_ARG; DoCommand(nsnull, aIndex); return NS_OK; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CMessageDialog::OnKeyCodePressed( vgui::KeyCode code ) { if ( m_ButtonPressed != BTN_INVALID || GetAlpha() != 255 ) { // inhibit any further key activity or during transitions return; } switch ( GetBaseButtonCode( code ) ) { case KEY_XBUTTON_A: DoCommand( BTN_A ); break; case KEY_XBUTTON_B: DoCommand( BTN_B ); break; default: break; } }
void main() { /* Configure the oscillator for the device */ ConfigureOscillator(); /* Initialize I/O and Peripherals for application */ InitApp(); SendMessage("READY"); while(1) { if (RCIF) { if (FERR) { rxchar = RCREG; ClearRXBuffer(); SendMessage(UART_FRAMING_ERROR); // Framing Error - clear with a read } else { rxchar = RCREG; // recive char if(rxpos < RXBUFFERSIZE) { rxbuffer[rxpos++] = rxchar; if ((rxpos == CMD_SIZE) & (rxchar == 0x0D)) // CR recived - do command { rxchar = DoCommand(); ClearRXBuffer(); SendMessage(rxchar ? CMD_ACK : CMD_ERROR); // command acknowledge } } else { ClearRXBuffer(); SendMessage(BUFFER_FULL_ERROR); // buffer full error } } } if (OERR) { CREN = 0; rxchar = RCREG; rxchar = RCREG; ClearRXBuffer(); SendMessage(UART_OVERFLOW_ERROR); // rx overrun error CREN = 1; } } }
/** * Copy head specific things to the new vehicle chain after it was successfully constructed * @param old_head The old front vehicle (no wagons attached anymore) * @param new_head The new head of the completely replaced vehicle chain * @param flags the command flags to use */ static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, DoCommandFlag flags) { CommandCost cost = CommandCost(); /* Share orders */ if (cost.Succeeded() && old_head != new_head) cost.AddCost(DoCommand(0, new_head->index | CO_SHARE << 30, old_head->index, DC_EXEC, CMD_CLONE_ORDER)); /* Copy group membership */ if (cost.Succeeded() && old_head != new_head) cost.AddCost(DoCommand(0, old_head->group_id, new_head->index, DC_EXEC, CMD_ADD_VEHICLE_GROUP)); /* Perform start/stop check whether the new vehicle suits newgrf restrictions etc. */ if (cost.Succeeded()) { /* Start the vehicle, might be denied by certain things */ assert((new_head->vehstatus & VS_STOPPED) != 0); cost.AddCost(CmdStartStopVehicle(new_head, true)); /* Stop the vehicle again, but do not care about evil newgrfs allowing starting but not stopping :p */ if (cost.Succeeded()) cost.AddCost(CmdStartStopVehicle(new_head, false)); } /* Last do those things which do never fail (resp. we do not care about), but which are not undo-able */ if (cost.Succeeded() && old_head != new_head && (flags & DC_EXEC) != 0) { /* Copy vehicle name */ if (old_head->name != NULL) { DoCommand(0, new_head->index, 0, DC_EXEC | DC_AUTOREPLACE, CMD_RENAME_VEHICLE, old_head->name); } /* Copy other things which cannot be copied by a command and which shall not stay resetted from the build vehicle command */ new_head->CopyVehicleConfigAndStatistics(old_head); /* Switch vehicle windows/news to the new vehicle, so they are not closed/deleted when the old vehicle is sold */ ChangeVehicleViewports(old_head->index, new_head->index); ChangeVehicleViewWindow(old_head->index, new_head->index); ChangeVehicleNews(old_head->index, new_head->index); } return cost; }
void CTranscendenceWnd::OnKeyDownIntro (int iVirtKey, DWORD dwKeyData) // OnKeyDownIntro // // Handle WM_KEYDOWN { if (m_bOverwriteGameDlg) return; if (m_PlayerDisplay.OnKeyDown(iVirtKey)) return; if (m_ButtonBarDisplay.OnKeyDown(iVirtKey)) return; switch (iVirtKey) { case SDLK_RETURN: if (m_bSavedGame) DoCommand(CMD_CONTINUE_OLD_GAME); else DoCommand(CMD_START_NEW_GAME); break; case SDLK_UP: m_HighScoreDisplay.SelectPrevious(); break; case SDLK_DOWN: m_HighScoreDisplay.SelectNext(); break; case SDLK_F1: StartHelp(); break; } }
bool DOS_Shell::CheckConfig(char* cmd_in,char*line) { Section* test = control->GetSectionFromProperty(cmd_in); if(!test) return false; if(line && !line[0]) { std::string val = test->GetPropValue(cmd_in); if(val != NO_SUCH_PROPERTY) WriteOut("%s\n",val.c_str()); return true; } char newcom[1024]; newcom[0] = 0; strcpy(newcom,"z:\\config -set "); strcat(newcom,test->GetName()); strcat(newcom," "); strcat(newcom,cmd_in);strcat(newcom,line); DoCommand(newcom); return true; }
/** * Builds and refits a replacement vehicle * Important: The old vehicle is still in the original vehicle chain (used for determining the cargo when the old vehicle did not carry anything, but the new one does) * @param old_veh A single (articulated/multiheaded) vehicle that shall be replaced. * @param new_vehicle Returns the newly build and refittet vehicle * @param part_of_chain The vehicle is part of a train * @return cost or error */ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehicle, bool part_of_chain) { *new_vehicle = NULL; /* Shall the vehicle be replaced? */ const Company *c = Company::Get(_current_company); EngineID e; CommandCost cost = GetNewEngineType(old_veh, c, e); if (cost.Failed()) return cost; if (e == INVALID_ENGINE) return CommandCost(); // neither autoreplace is set, nor autorenew is triggered /* Does it need to be refitted */ CargoID refit_cargo = GetNewCargoTypeForReplace(old_veh, e, part_of_chain); if (refit_cargo == CT_INVALID) return CommandCost(); // incompatible cargoes /* Build the new vehicle */ cost = DoCommand(old_veh->tile, e, 0, DC_EXEC | DC_AUTOREPLACE, GetCmdBuildVeh(old_veh)); if (cost.Failed()) return cost; Vehicle *new_veh = Vehicle::Get(_new_vehicle_id); *new_vehicle = new_veh; /* Refit the vehicle if needed */ if (refit_cargo != CT_NO_REFIT) { byte subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo); cost.AddCost(DoCommand(0, new_veh->index, refit_cargo | (subtype << 8), DC_EXEC, GetCmdRefitVeh(new_veh))); assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace() } /* Try to reverse the vehicle, but do not care if it fails as the new type might not be reversible */ if (new_veh->type == VEH_TRAIN && HasBit(Train::From(old_veh)->flags, VRF_REVERSE_DIRECTION)) { DoCommand(0, new_veh->index, true, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION); } return cost; }
LRESULT CMultiLineEditDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (uMsg) { case WM_INITDIALOG: { InitDialog(hwndDlg, IDI_GREPWIN); CLanguage::Instance().TranslateWindow(*this); // initialize the controls SetDlgItemText(hwndDlg, IDC_TEXTCONTENT, m_RegexText.c_str()); SetFocus(GetDlgItem(hwndDlg, IDC_TEXTCONTENT)); m_resizer.Init(hwndDlg); m_resizer.AddControl(hwndDlg, IDC_TEXTCONTENT, RESIZER_TOPLEFTBOTTOMRIGHT); m_resizer.AddControl(hwndDlg, IDOK, RESIZER_BOTTOMRIGHT); m_resizer.AddControl(hwndDlg, IDCANCEL, RESIZER_BOTTOMRIGHT); SendMessage(GetDlgItem(*this, IDC_TEXTCONTENT), EM_SETEVENTMASK, 0, ENM_CHANGE); SendMessage(GetDlgItem(*this, IDC_TEXTCONTENT), EM_EXLIMITTEXT, 0, 200*1024); ExtendFrameIntoClientArea(IDC_TEXTCONTENT, IDC_TEXTCONTENT, IDC_TEXTCONTENT, IDC_TEXTCONTENT); m_aerocontrols.SubclassControl(GetDlgItem(*this, IDOK)); m_aerocontrols.SubclassControl(GetDlgItem(*this, IDCANCEL)); if (m_Dwm.IsDwmCompositionEnabled()) m_resizer.ShowSizeGrip(false); } return FALSE; case WM_COMMAND: return DoCommand(LOWORD(wParam), HIWORD(wParam)); case WM_SIZE: { m_resizer.DoResize(LOWORD(lParam), HIWORD(lParam)); } break; case WM_GETMINMAXINFO: { MINMAXINFO * mmi = (MINMAXINFO*)lParam; mmi->ptMinTrackSize.x = m_resizer.GetDlgRect()->right; mmi->ptMinTrackSize.y = m_resizer.GetDlgRect()->bottom; return 0; } break; default: return FALSE; } return FALSE; }
void SendCommand(cdrom_Device *cd, unsigned char val) { if (cd->CmdPtr < 7) { cd->Command[cd->CmdPtr] = (unsigned char)val; cd->CmdPtr++; } if((cd->CmdPtr >= 7) || (cd->Command[0] == 0x8)) { //Poll&=~0x80; ??? DoCommand(cd); cd->CmdPtr=0; } }
int GetVersion(int arg) { arg++; printf("%s Compiled: %s %s\n", "amptest", __DATE__, __TIME__); DoCommand('I',0,NULL); if (ParseIbuf(',')) { printf("FirmwareVersion:%s\n",items[0]); printf("DeviceID :%s\n",items[1]); printf("SerialNumber :%s\n",items[2]); } else { printf("Illegal string or checksum error\n"); printf("%s\n",ibuf); } return arg; }
NS_IMETHODIMP nsHTMLLinkAccessible::DoAction(PRUint8 aIndex) { if (!IsLinked()) return nsHyperTextAccessible::DoAction(aIndex); // Action 0 (default action): Jump to link if (aIndex != eAction_Jump) return NS_ERROR_INVALID_ARG; if (IsDefunct()) return NS_ERROR_FAILURE; nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode)); return DoCommand(content); }
void CDummyUsbDevice::DoTestsL() { iTest.SetLogged(ETrue); iTest.Title(); OpenFileL(); TInt length = GetNextLine(); if (length <= 0) { User::Panic(KUsbChargingTestPanic, EUsbChargingTestPanicBadInputData); } iLineNumber = 1; iTest.Start(_L("test")); InterpretLine(); DoCommand(); DoAsyncOp(); }
NS_IMETHODIMP nsHTMLLinkAccessible::DoAction(PRUint8 aIndex) { if (!IsLinked()) return nsHyperTextAccessible::DoAction(aIndex); // Action 0 (default action): Jump to link if (aIndex != eAction_Jump) return NS_ERROR_INVALID_ARG; if (IsDefunct()) return NS_ERROR_FAILURE; DoCommand(); return NS_OK; }
void CTelnetServer::ProcessIncoming() { EnterCriticalSection(&CommandCS); if(Commands) // process only 1 per pulse, no loop. { PCHARINFO pCharInfo=GetCharInfo(); PSPAWNINFO pSpawn=(PSPAWNINFO)pLocalPlayer; if (pCharInfo) pSpawn=pCharInfo->pSpawn; PCHATBUF Next=Commands->pNext; DoCommand(pSpawn,Commands->szText); free(Commands); Commands=Next; } LeaveCriticalSection(&CommandCS); }
LRESULT CFindBar::DlgFunc(HWND /*hwndDlg*/, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/) { switch (uMsg) { case WM_INITDIALOG: { m_hIcon = (HICON)::LoadImage(hResource, MAKEINTRESOURCE(IDI_CANCELNORMAL), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); SendMessage(GetDlgItem(*this, IDC_FINDEXIT), BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_hIcon); } return TRUE; case WM_COMMAND: return DoCommand(LOWORD(wParam), HIWORD(wParam)); default: return FALSE; } }
int InputLevel(int arg) { char *cp; arg++; DoCommand('L',0,NULL); if (ParseIbuf(',')) { cp = items[0]; printf("Level Input1:%c%c Input2:%c%c\n",cp[2],cp[3],cp[4],cp[5]); printf("Level Otput1:%c%c Otput2:%c%c V-meters\n",cp[6],cp[7],cp[8],cp[9]); } else { printf("Illegal string or checksum error\n"); printf("%s\n",ibuf); } return arg; }
static INT_PTR CALLBACK PINDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_COMMAND: return DoCommand(hDlg, wParam, lParam); break; case WM_INITDIALOG: return DoInitDialog(hDlg, lParam); break; default: break; } return FALSE; }
LRESULT CCleanVerifyDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (uMsg) { case WM_INITDIALOG: { InitDialog(hwndDlg, IDI_FILETOOL); SetDlgItemText(*this, IDC_PATH, m_path.c_str()); } return TRUE; case WM_COMMAND: return DoCommand(LOWORD(wParam)); default: return FALSE; } }
Vd80Err vd80StopAcquisition(int fd, unsigned int mods, unsigned int chns) { int i, mod; unsigned int mski; Vd80Err err; for (i=0; i<Vd80MODULES; i++) { mski = 1 << i; if (mods & mski) { mod = i+1; err = DoCommand(fd,mod,0,Vd80DrvrCommandSTOP); if (err != Vd80ErrSUCCESS) return err; } } return Vd80ErrSUCCESS; }
INT cmd_call (LPTSTR param) { TCHAR line[CMDLINE_LENGTH + 1]; TCHAR *first; BOOL bInQuote = FALSE; TRACE ("cmd_call: (\'%s\')\n", debugstr_aw(param)); if (!_tcsncmp (param, _T("/?"), 2)) { ConOutResPaging(TRUE,STRING_CALL_HELP); return 0; } /* Do a second round of %-variable substitutions */ if (!SubstituteVars(param, line, _T('%'))) return nErrorLevel = 1; /* Find start and end of first word */ first = line; while (_istspace(*first)) first++; for (param = first; *param; param++) { if (!bInQuote && (_istspace(*param) || _tcschr(_T(",;="), *param))) break; bInQuote ^= (*param == _T('"')); } /* Separate first word from rest of line */ memmove(param + 1, param, (_tcslen(param) + 1) * sizeof(TCHAR)); *param++ = _T('\0'); if (*first == _T(':') && (bc)) { /* CALL :label - call a subroutine of the current batch file */ while (*param == _T(' ')) param++; nErrorLevel = Batch(bc->BatchFilePath, first, param, NULL); return nErrorLevel; } nErrorLevel = DoCommand(first, param, NULL); return nErrorLevel; }
/* Note that tab, return, linefeed, ^n, all do the same thing except when it comes to matching a command button hotkey. Return 1 to redraw, 0 for no redraw */ static int process_tabtypes(unsigned char * buf) { Item *item, *old_item; /* Note: the input field ring used with ^P above could probably make this a lot simpler. dje 12/20/98 */ /* Code tracks cursor. */ item = root_item_ptr; /* init item ptr */ if (CF.cur_input != 0) { /* if in text */ item = CF.cur_input->header.next; /* move to next item */ } for ( ; item != 0; item = item->header.next) {/* find next input item */ if (item->type == I_INPUT) { old_item = CF.cur_input; CF.cur_input = item; RedrawItem(old_item, 1, NULL); CF.rel_cursor = CF.abs_cursor = 0; /* home cursor in new input field */ return (1); /* cause redraw */ } } /* end of all text input fields, check for buttons */ for (item = root_item_ptr; item != 0; item = item->header.next) {/* all items */ myfprintf((stderr, "Button: keypress==%d vs buf %d\n", item->button.keypress, buf[0])); if (item->type == I_BUTTON && item->button.keypress == buf[0]) { RedrawItem(item, 1, NULL); usleep(MICRO_S_FOR_10MS); RedrawItem(item, 0, NULL); DoCommand(item); return (0); /* cause no_redraw */ } } /* goto the first text input field */ for (item = root_item_ptr; item != 0; item = item->header.next) {/* all items */ if (item->type == I_INPUT) { old_item = CF.cur_input; CF.cur_input = item; RedrawItem(old_item, 1, NULL); CF.abs_cursor = CF.rel_cursor - item->input.left; return (1); /* goto redraw */ } } return (-1); }
/** * Build a buoy. * @param tile tile where to place the buoy * @param flags operation to perform * @param p1 unused * @param p2 unused * @param text unused * @return the cost of this operation or an error */ CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { if (tile == 0 || !HasTileWaterGround(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); if (GetTileSlope(tile) != SLOPE_FLAT) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); /* Check if there is an already existing, deleted, waypoint close to us that we can reuse. */ Waypoint *wp = FindDeletedWaypointCloseTo(tile, STR_SV_STNAME_BUOY, OWNER_NONE); if (wp == NULL && !Waypoint::CanAllocateItem()) return_cmd_error(STR_ERROR_TOO_MANY_STATIONS_LOADING); CommandCost cost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_WAYPOINT_BUOY]); if (!IsWaterTile(tile)) { CommandCost ret = DoCommand(tile, 0, 0, flags | DC_AUTO, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; cost.AddCost(ret); } if (flags & DC_EXEC) { if (wp == NULL) { wp = new Waypoint(tile); } else { /* Move existing (recently deleted) buoy to the new location */ wp->xy = tile; InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index); } wp->rect.BeforeAddTile(tile, StationRect::ADD_TRY); wp->string_id = STR_SV_STNAME_BUOY; wp->facilities |= FACIL_DOCK; wp->owner = OWNER_NONE; wp->build_date = _date; if (wp->town == NULL) MakeDefaultName(wp); MakeBuoy(tile, wp->index, GetWaterClass(tile)); wp->UpdateVirtCoord(); InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index); } return cost; }
LRESULT CWindowTreeDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (uMsg) { case WM_INITDIALOG: { InitDialog(hwndDlg, IDI_SENDMESSAGE); m_resizer.Init(hwndDlg); m_resizer.AddControl(hwndDlg, IDC_WINDOWTREE, RESIZER_TOPLEFTBOTTOMRIGHT); m_resizer.AddControl(hwndDlg, IDC_REFRESH, RESIZER_BOTTOMRIGHT); m_resizer.AddControl(hwndDlg, IDOK, RESIZER_BOTTOMRIGHT); m_resizer.AddControl(hwndDlg, IDCANCEL, RESIZER_BOTTOMRIGHT); ExtendFrameIntoClientArea(IDC_WINDOWTREE, IDC_WINDOWTREE, IDC_WINDOWTREE, IDC_WINDOWTREE); m_aerocontrols.SubclassControl(GetDlgItem(*this, IDC_REFRESH)); m_aerocontrols.SubclassControl(GetDlgItem(*this, IDOK)); m_aerocontrols.SubclassControl(GetDlgItem(*this, IDCANCEL)); if (m_Dwm.IsDwmCompositionEnabled()) m_resizer.ShowSizeGrip(false); RefreshTree(); } return FALSE; case WM_COMMAND: return DoCommand(LOWORD(wParam), HIWORD(wParam)); case WM_SIZE: { m_resizer.DoResize(LOWORD(lParam), HIWORD(lParam)); } break; case WM_GETMINMAXINFO: { MINMAXINFO * mmi = (MINMAXINFO*)lParam; mmi->ptMinTrackSize.x = m_resizer.GetDlgRect()->right; mmi->ptMinTrackSize.y = m_resizer.GetDlgRect()->bottom; return 0; } break; default: return FALSE; } return FALSE; }
/** Autoreplace all vehicles in the depot * Note: this command can make incorrect cost estimations * Luckily the final price can only drop, not increase. This is due to the fact that * estimation can't predict wagon removal so it presumes worst case which is no income from selling wagons. * @param tile Tile of the depot where the vehicles are * @param flags type of operation * @param p1 Type of vehicle * @param p2 If bit 0 is set, then either replace all or nothing (instead of replacing until money runs out) * @param text unused * @return the cost of this operation or an error */ CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { VehicleList list; CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES); VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8); bool all_or_nothing = HasBit(p2, 0); if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR; /* Get the list of vehicles in the depot */ BuildDepotVehicleList(vehicle_type, tile, &list, &list, true); bool did_something = false; for (uint i = 0; i < list.Length(); i++) { const Vehicle *v = list[i]; /* Ensure that the vehicle completely in the depot */ if (!v->IsInDepot()) continue; CommandCost ret = DoCommand(0, v->index, 0, flags, CMD_AUTOREPLACE_VEHICLE); if (CmdSucceeded(ret)) { did_something = true; cost.AddCost(ret); } else { if (ret.GetErrorMessage() != STR_ERROR_AUTOREPLACE_NOTHING_TO_DO && all_or_nothing) { /* We failed to replace a vehicle even though we set all or nothing. * We should never reach this if DC_EXEC is set since then it should * have failed the estimation guess. */ assert(!(flags & DC_EXEC)); /* Now we will have to return an error. */ return CMD_ERROR; } } } if (!did_something) { /* Either we didn't replace anything or something went wrong. * Either way we want to return an error and not execute this command. */ cost = CMD_ERROR; } return cost; }