void K2sendPlayer::blueClose () { close (blue_sock); is_connected = FALSE; QString msg; msg = QString ("Disconnected " + baddr); K2sendStatusEvent *se = new K2sendStatusEvent (K2sendStatusEvent::EventMessage, msg, 2000); //kdDebug(200010) << "post 21" << endl; QApplication::postEvent (m_parent, se); se = new K2sendStatusEvent (K2sendStatusEvent::EventTitle, ""); //kdDebug(200010) << "post 22" << endl; QApplication::postEvent (m_parent, se); clearStatus (); se = new K2sendStatusEvent (K2sendStatusEvent::EventAddr, "00:00:00:00:00:00"); //kdDebug(200010) << "post 23" << endl; QApplication::postEvent (m_parent, se); }
bool WalletImpl::create(const std::string &path, const std::string &password, const std::string &language) { clearStatus(); bool keys_file_exists; bool wallet_file_exists; tools::wallet2::wallet_exists(path, keys_file_exists, wallet_file_exists); // TODO: figure out how to setup logger; LOG_PRINT_L3("wallet_path: " << path << ""); LOG_PRINT_L3("keys_file_exists: " << std::boolalpha << keys_file_exists << std::noboolalpha << " wallet_file_exists: " << std::boolalpha << wallet_file_exists << std::noboolalpha); // add logic to error out if new wallet requested but named wallet file exists if (keys_file_exists || wallet_file_exists) { m_errorString = "attempting to generate or restore wallet, but specified file(s) exist. Exiting to not risk overwriting."; LOG_ERROR(m_errorString); m_status = Status_Error; return false; } // TODO: validate language m_wallet->set_seed_language(language); crypto::secret_key recovery_val, secret_key; try { recovery_val = m_wallet->generate(path, password, secret_key, false, false); m_password = password; m_status = Status_Ok; } catch (const std::exception &e) { LOG_ERROR("Error creating wallet: " << e.what()); m_status = Status_Error; m_errorString = e.what(); return false; } return true; }
void * restoreDbFromTape(void *param) { afs_uint32 taskId = (intptr_t) param; afs_int32 code = 0; afs_int32 i; struct butm_tapeInfo tapeInfo; struct rstTapeInfo rstTapeInfo; struct budb_dumpEntry dumpEntry; extern struct tapeConfig globalTapeConfig; extern struct deviceSyncNode *deviceLatch; setStatus(taskId, DRIVE_WAIT); EnterDeviceQueue(deviceLatch); /* lock tape device */ clearStatus(taskId, DRIVE_WAIT); printf("\n\n"); TLog(taskId, "RestoreDb\n"); tapeInfo.structVersion = BUTM_MAJORVERSION; code = butm_file_Instantiate(&tapeInfo, &globalTapeConfig); if (code) { ErrorLog(0, taskId, code, tapeInfo.error, "Can't initialize tape module\n"); ERROR_EXIT(code); } listEntryHead = NULL; rstTapeInfo.taskId = taskId; rstTapeInfo.tapeSeq = 1; rstTapeInfo.dumpid = 0; code = readDbTape(&tapeInfo, &rstTapeInfo, autoQuery); if (code) ERROR_EXIT(code); code = restoreDbEntries(&tapeInfo, &rstTapeInfo); if (code) ERROR_EXIT(code); error_exit: /* Now put this dump into the database */ /* Make a dump entry from first tape */ listEntryPtr = listEntryHead; if (listEntryPtr) { makeDbDumpEntry(tapeEntryPtr, &dumpEntry); if (dumpEntry.id != 0) { i = bcdb_CreateDump(&dumpEntry); if (i) { if (i == BUDB_DUMPIDEXISTS) fprintf(stderr, "Dump id %d not added to database - already exists\n", dumpEntry.id); else TapeLog(0, taskId, i, 0, "Dump id %d not added to database\n", dumpEntry.id); } else { i = addTapesToDb(taskId); if (!code) code = i; i = bcdb_FinishDump(&dumpEntry); if (!code) code = i; } } freeTapeList(); } unmountTape(taskId, &tapeInfo); waitDbWatcher(); if (code == TC_ABORTEDBYREQUEST) { TLog(taskId, "RestoreDb: Aborted by request\n"); clearStatus(taskId, ABORT_REQUEST); setStatus(taskId, ABORT_DONE); } else if (code) { TapeLog(0, taskId, code, 0, "RestoreDb: Finished with errors\n"); setStatus(taskId, TASK_ERROR); } else { TLog(taskId, "RestoreDb: Finished\n"); } LeaveDeviceQueue(deviceLatch); setStatus(taskId, TASK_DONE); return (void *)(intptr_t)(code); }
void EyeAnalyzer::doAnalyze(void) { clearStatus(); getEyeStatus(); }
void * ScanDumps(void *param) { struct scanTapeIf *ptr = (struct scanTapeIf *)param; struct butm_tapeInfo curTapeInfo; struct tapeScanInfo tapeScanInfo; afs_uint32 taskId; afs_int32 code = 0; taskId = ptr->taskId; setStatus(taskId, DRIVE_WAIT); EnterDeviceQueue(deviceLatch); clearStatus(taskId, DRIVE_WAIT); printf("\n\n"); if (ptr->addDbFlag) TLog(taskId, "ScanTape and add to the database\n"); else TLog(taskId, "Scantape\n"); memset(&tapeScanInfo, 0, sizeof(tapeScanInfo)); tapeScanInfo.addDbFlag = ptr->addDbFlag; memset(&curTapeInfo, 0, sizeof(curTapeInfo)); curTapeInfo.structVersion = BUTM_MAJORVERSION; code = butm_file_Instantiate(&curTapeInfo, &globalTapeConfig); if (code) { ErrorLog(0, taskId, code, curTapeInfo.error, "Can't initialize tape module\n"); ERROR_EXIT(code); } code = getScanTape(taskId, &curTapeInfo, "", 0, autoQuery, &tapeScanInfo.tapeLabel); if (code) ERROR_EXIT(code); code = readDumps(taskId, &curTapeInfo, &tapeScanInfo); if (code) ERROR_EXIT(code); error_exit: unmountTape(taskId, &curTapeInfo); waitDbWatcher(); if (code == TC_ABORTEDBYREQUEST) { ErrorLog(0, taskId, 0, 0, "Scantape: Aborted by request\n"); clearStatus(taskId, ABORT_REQUEST); setStatus(taskId, ABORT_DONE); } else if (code) { ErrorLog(0, taskId, code, 0, "Scantape: Finished with errors\n"); setStatus(taskId, TASK_ERROR); } else { TLog(taskId, "Scantape: Finished\n"); } free(ptr); setStatus(taskId, TASK_DONE); LeaveDeviceQueue(deviceLatch); return (void *)(intptr_t)(code); }
ScriptEditor::ScriptEditor(const QString& source, const QString& filename, int type) : ChildTab(NULL), ui(new Ui::ScriptEditor), m_language(ENGINE_QTSCRIPT), m_editor(NULL) { ui->setupUi(this); m_exampleBtn = new QPushButton(this); m_exampleBtn->setToolTip(tr("Examples")); m_exampleBtn->setCheckable(true); m_exampleBtn->setIconSize(QSize(24, 24)); m_exampleBtn->setIcon(QIcon(":/actions/info")); m_exampleBtn->setFlat(true); m_exampleBtn->setStyleSheet("padding: 3px;"); m_settingsBtn = new QPushButton(this); m_settingsBtn->setToolTip(tr("Settings")); m_settingsBtn->setCheckable(true); m_settingsBtn->setIconSize(QSize(24, 24)); m_settingsBtn->setIcon(QIcon(":/actions/system")); m_settingsBtn->setFlat(true); m_settingsBtn->setStyleSheet("padding: 3px;"); QLabel *docLabel = new QLabel(this); docLabel->setTextFormat(Qt::RichText); docLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); docLabel->setOpenExternalLinks(true); docLabel->setText(tr("<a href=\"http://technika.junior.cz/docs/Lorris/index.html\">Documentation</a>")); docLabel->setToolTip("http://technika.junior.cz/docs/Lorris/index.html"); QToolBar *bar = new QToolBar(this); bar->setIconSize(QSize(24, 24)); QAction *load = bar->addAction(QIcon(":/actions/open"), tr("Load"), this, SLOT(loadAct())); QAction *save = bar->addAction(QIcon(":/actions/save"), tr("Save"), this, SLOT(saveAct())); QAction *saveAs = bar->addAction(QIcon(":/actions/save-as"), tr("Save as..."), this, SLOT(saveAs())); bar->addSeparator(); QAction *undo = bar->addAction(QIcon(":/actions/undo"), tr("Undo"), this, SIGNAL(undo())); QAction *redo = bar->addAction(QIcon(":/actions/redo"), tr("Redo"), this, SIGNAL(redo())); bar->addSeparator(); QAction *apply = bar->addAction(QIcon(":/icons/start"), tr("Apply"), this, SLOT(applyAct())); bar->addSeparator(); bar->addWidget(m_exampleBtn); bar->addWidget(m_settingsBtn); bar->addSeparator(); bar->addWidget(docLabel); load->setShortcut(QKeySequence("Ctrl+O")); load->setToolTip(tr("Load (Ctrl+O)")); save->setShortcut(QKeySequence("Ctrl+S")); save->setToolTip(tr("Save (Ctrl+S)")); saveAs->setShortcut(QKeySequence("Ctrl+Shift+S")); saveAs->setToolTip(tr("Save as... (Ctrl+Shift+S)")); apply->setShortcut(QKeySequence("F5")); apply->setToolTip(tr("Apply (F5)")); connect(this, SIGNAL(undoAvailable(bool)), undo, SLOT(setEnabled(bool))); connect(this, SIGNAL(redoAvailable(bool)), redo, SLOT(setEnabled(bool))); ui->mainLayout->insertWidget(0, bar); quint32 editor_cfg = sConfig.get(CFG_QUINT32_SCRIPTEDITOR_TYPE); #ifdef USE_KATE setEditor(EDITOR_KATE); #elif defined(USE_QSCI) setEditor(EDITOR_QSCINTILLA); #else setEditor(EDITOR_INTERNAL); #endif if(editor_cfg != UINT_MAX) setEditor(editor_cfg); undo->setToolTip(tr("Undo (%1)").arg(m_editor->getUndoShortcut())); redo->setToolTip(tr("Redo (%1)").arg(m_editor->getRedoShortcut())); ui->resizeLine->setOrientation(false); ui->resizeLine->setResizeLayout(ui->mainLayout); ui->mainLayout->setStretch(ui->mainLayout->indexOf(ui->errorEdit), sConfig.get(CFG_QUINT32_SCRIPTEDITOR_STR)); ui->mainLayout->setStretch(ui->mainLayout->indexOf(ui->errorEdit)-2, 100 - sConfig.get(CFG_QUINT32_SCRIPTEDITOR_STR)); ui->resizeLine->updateStretch(); m_errors = 0; m_ignoreFocus = false; m_editor->setText(source); m_changed = !source.isEmpty(); setLanguage(type); connect(&m_status_timer, SIGNAL(timeout()), SLOT(clearStatus())); connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), SLOT(focusChanged(QWidget*,QWidget*))); ui->errorBtn->setChecked(sConfig.get(CFG_BOOL_SHOW_SCRIPT_ERROR)); on_errorBtn_toggled(ui->errorBtn->isChecked()); setFilename(filename); m_contentChanged = false; m_fileChanged = false; checkChange(); connect(m_exampleBtn, SIGNAL(clicked()), SLOT(exampleBtn())); connect(m_settingsBtn, SIGNAL(clicked()), SLOT(settingsBtn())); }
void clearLCD() { clearStatus(); DriverStationLCD::GetInstance()->Clear(); }
PendingTransaction *WalletImpl::createTransaction(const string &dst_addr, const string &payment_id, uint64_t amount, uint32_t mixin_count) { clearStatus(); vector<cryptonote::tx_destination_entry> dsts; cryptonote::tx_destination_entry de; // indicates if dst_addr is integrated address (address + payment_id) bool has_payment_id; crypto::hash8 payment_id_short; // TODO: (https://bitcointalk.org/index.php?topic=753252.msg9985441#msg9985441) size_t fake_outs_count = mixin_count > 0 ? mixin_count : m_wallet->default_mixin(); if (fake_outs_count == 0) fake_outs_count = DEFAULT_MIXIN; PendingTransactionImpl * transaction = new PendingTransactionImpl(*this); do { if(!cryptonote::get_account_integrated_address_from_str(de.addr, has_payment_id, payment_id_short, m_wallet->testnet(), dst_addr)) { // TODO: copy-paste 'if treating as an address fails, try as url' from simplewallet.cpp:1982 m_status = Status_Error; m_errorString = "Invalid destination address"; break; } std::vector<uint8_t> extra; // if dst_addr is not an integrated address, parse payment_id if (!has_payment_id && !payment_id.empty()) { // copy-pasted from simplewallet.cpp:2212 crypto::hash payment_id_long; bool r = tools::wallet2::parse_long_payment_id(payment_id, payment_id_long); if (r) { std::string extra_nonce; cryptonote::set_payment_id_to_tx_extra_nonce(extra_nonce, payment_id_long); r = add_extra_nonce_to_tx_extra(extra, extra_nonce); } else { r = tools::wallet2::parse_short_payment_id(payment_id, payment_id_short); if (r) { std::string extra_nonce; set_encrypted_payment_id_to_tx_extra_nonce(extra_nonce, payment_id_short); r = add_extra_nonce_to_tx_extra(extra, extra_nonce); } } if (!r) { m_status = Status_Error; m_errorString = tr("payment id has invalid format, expected 16 or 64 character hex string: ") + payment_id; break; } } de.amount = amount; if (de.amount <= 0) { m_status = Status_Error; m_errorString = "Invalid amount"; break; } dsts.push_back(de); //std::vector<tools::wallet2::pending_tx> ptx_vector; try { transaction->m_pending_tx = m_wallet->create_transactions_2(dsts, fake_outs_count, 0 /* unlock_time */, 0 /* unused fee arg*/, extra, m_trustedDaemon); } catch (const tools::error::daemon_busy&) { // TODO: make it translatable with "tr"? m_errorString = tr("daemon is busy. Please try again later."); m_status = Status_Error; } catch (const tools::error::no_connection_to_daemon&) { m_errorString = tr("no connection to daemon. Please make sure daemon is running."); m_status = Status_Error; } catch (const tools::error::wallet_rpc_error& e) { m_errorString = tr("RPC error: ") + e.to_string(); m_status = Status_Error; } catch (const tools::error::get_random_outs_error&) { m_errorString = tr("failed to get random outputs to mix"); m_status = Status_Error; } catch (const tools::error::not_enough_money& e) { m_status = Status_Error; std::ostringstream writer; writer << boost::format(tr("not enough money to transfer, available only %s, transaction amount %s = %s + %s (fee)")) % print_money(e.available()) % print_money(e.tx_amount() + e.fee()) % print_money(e.tx_amount()) % print_money(e.fee()); m_errorString = writer.str(); } catch (const tools::error::not_enough_outs_to_mix& e) { std::ostringstream writer; writer << tr("not enough outputs for specified mixin_count") << " = " << e.mixin_count() << ":"; for (const cryptonote::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount& outs_for_amount : e.scanty_outs()) { writer << "\n" << tr("output amount") << " = " << print_money(outs_for_amount.amount) << ", " << tr("found outputs to mix") << " = " << outs_for_amount.outs.size(); } m_errorString = writer.str(); m_status = Status_Error; } catch (const tools::error::tx_not_constructed&) { m_errorString = tr("transaction was not constructed"); m_status = Status_Error; } catch (const tools::error::tx_rejected& e) { std::ostringstream writer; writer << (boost::format(tr("transaction %s was rejected by daemon with status: ")) % get_transaction_hash(e.tx())) << e.status(); m_errorString = writer.str(); m_status = Status_Error; } catch (const tools::error::tx_sum_overflow& e) { m_errorString = e.what(); m_status = Status_Error; } catch (const tools::error::zero_destination&) { m_errorString = tr("one of destinations is zero"); m_status = Status_Error; } catch (const tools::error::tx_too_big& e) { m_errorString = tr("failed to find a suitable way to split transactions"); m_status = Status_Error; } catch (const tools::error::transfer_error& e) { m_errorString = string(tr("unknown transfer error: ")) + e.what(); m_status = Status_Error; } catch (const tools::error::wallet_internal_error& e) { m_errorString = string(tr("internal error: ")) + e.what(); m_status = Status_Error; } catch (const std::exception& e) { m_errorString = string(tr("unexpected error: ")) + e.what(); m_status = Status_Error; } catch (...) { m_errorString = tr("unknown error"); m_status = Status_Error; } } while (false); transaction->m_status = m_status; transaction->m_errorString = m_errorString; return transaction; }
// // Look for all matching messages. // Boolean FindDialog::findMatching(Boolean findAll) { // TODO - CHECK ERROR!!! DtMailEnv error; unsigned int matchCount = 0; /* NL_COMMENT * This string is displayed on the find dialog status line * when searching for a matching message. */ setStatus(GETMSG(DT_catd, 1, 231, "Searching...")); busyCursor(); theRoamApp.busyAllWindows(NULL); // // Get the active list. // MsgScrollingList * displayList = _roamWindow->list(); // // Find the max. number of messages that we are to find matching. // int numberMessages = displayList->get_num_messages(); // // Are there any messages? // if (numberMessages > 0) { // // A pointer to the currently interesting message. // register DtMailMessageHandle currentHandle = NULL; // // The offset of the currentHandle in the MsgScrollingList. // register int handleOffset; // // Find the current message. We would always start from the // currently selected message. // // Get the handle to the currently displaied message. // DtMailMessageHandle initialHandle = displayList->current_msg_handle(); // // Get the list of DtMailMessageHandle's. MsgHndArray * msgHandles = displayList->get_messages(); // // Up to all of them can match, allocate and clear the list. // DtMailMessageHandle * matchList = NULL; if (findAll) { matchList = new DtMailMessageHandle[numberMessages+1]; } unsigned int matchOffset = 0; // // Deselect all messages. // XmListDeselectAllItems(displayList->baseWidget()); // // Start the search from the initially displaied message (+1). // handleOffset = displayList->position(initialHandle) - 1; if (_searchForward) { handleOffset++; if (handleOffset >= numberMessages) { handleOffset = 0; } } else { handleOffset--; if (handleOffset < 0) { handleOffset = numberMessages - 1; } } for (; handleOffset < numberMessages;) { currentHandle = msgHandles->at(handleOffset)->message_handle; // // See if this message is a match, if it is... // if (compareMessage(currentHandle)) { matchCount++; // // If we are finding all, then add to the list. // If not, then display this message and we are done. // if (findAll) { matchList[matchOffset++] = currentHandle; } else { XmListDeselectAllItems(displayList->baseWidget()); //displayList->set_selected_item_position(handleOffset); displayList->display_and_select_message(error, currentHandle); break; // Only one. } } // // If we have looped back to the initial // message (handle), then we are done. // if (currentHandle == initialHandle) { break; } // // Get the next message. // // If we have reached the end, start over. // (as if the list was a circular list) // // We loop forward (_searchForward == TRUE) else we loop backward. // if (_searchForward) { handleOffset++; if (handleOffset >= numberMessages) { handleOffset = 0; } } else { handleOffset--; if (handleOffset < 0) { handleOffset = numberMessages - 1; } } currentHandle = msgHandles->at(handleOffset)->message_handle; } // // Select all the messages that match, and display the last // one in the list. // if (findAll) { displayList->select_all_and_display_last(error, matchList, matchCount); if (matchCount > 0) { char *line = new char[80]; /* NL_COMMENT * These strings are displayed on the find dialog status line * when one or more matching messages are found. The first * string is displayed when there is one matching message, * and the second string is displayed when there is more than * one. The %d is the number of messages that matched. */ if (matchCount == 1) { strcpy(line, GETMSG(DT_catd, 1, 232, "1 message selected")); } else { sprintf(line, GETMSG(DT_catd, 1, 233, "%d messages selected"), matchCount); } setStatus(line); delete [] line; } // Clean up. delete matchList; matchList = NULL; } } normalCursor(); theRoamApp.unbusyAllWindows(); if (error.isNotSet()) { if (matchCount > 0) { if (!findAll) { clearStatus(); } return(TRUE); } } /* NL_COMMENT * This string is displayed on the find dialog status line when * no matching messages were found. */ setStatus(GETMSG(DT_catd, 1, 234, "No matches were found")); return(False); }
// // Create the guts of the dialog // Widget FindDialog::createWorkArea(Widget dialog) { // TODO - CHECK ERROR!!! Widget *label = new Widget[_num_text_fields]; register unsigned int offset; _name = GETMSG(DT_catd, 1, 192, "Mailer - Find"); title(_name); // make this a modal dialog /* XtVaSetValues (dialog, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL); */ printHelpId("dialog", dialog); /* add help callback */ // XtAddCallback(dialog, XmNhelpCallback, HelpCB, helpId); Widget fd_pane = XtVaCreateWidget ("fd_pane", xmPanedWindowWidgetClass, dialog, XmNsashWidth, 1, XmNsashHeight, 1, NULL); printHelpId ("fd_pane", fd_pane); // add help callback // XtAddCallback (fd_pane, XmNhelpCallback, HelpCB, helpId); Widget fd_form = XtVaCreateWidget ("fd_form", xmFormWidgetClass, fd_pane, XmNfractionBase, 100, NULL); printHelpId ("fd_form", fd_form); // add help callback // XtAddCallback (fd_form, XmNhelpCallback, HelpCB, helpId); Widget _fd_labelbox = XtVaCreateManagedWidget ("_fd_labelbox", xmRowColumnWidgetClass, fd_form, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_POSITION, XmNrightAttachment, XmATTACH_POSITION, XmNleftPosition, 5, XmNrightPosition, 95, XmNpacking, XmPACK_COLUMN, XmNnumColumns, 2, XmNorientation, XmVERTICAL, XmNisAligned, True, XmNentryAlignment, XmALIGNMENT_END, XmNentryVerticalAlignment, XmALIGNMENT_CENTER, NULL); printHelpId ("_fd_labelbox", _fd_labelbox); // add help callback // XtAddCallback (_fd_labelbox, XmNhelpCallback, HelpCB, helpId); Widget *_fd_labels = new Widget [_num_text_fields]; int _fd_i = 0; for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++) { _fd_labels [_fd_i] = XtVaCreateManagedWidget ( _text_labels [_fd_i], xmLabelGadgetClass, _fd_labelbox, NULL); printHelpId ("_fd_labels [%s]", _fd_labels [_fd_i]); // naturally, this is bogus --must be fixed to return proper label // add help callback // XtAddCallback(_fd_labels [_fd_i], XmNhelpCallback, HelpCB, helpId); } for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++) { _text_fields [_fd_i] = XtVaCreateManagedWidget ( _text_names [_fd_i], xmTextFieldWidgetClass, _fd_labelbox, NULL); printHelpId ("_text_fields [%s]", _text_fields [_fd_i]); // naturally, this is bogus --must be fixed to return proper label // add help callback // XtAddCallback(_text_fields [_fd_i], XmNhelpCallback, HelpCB, helpId); XtAddCallback(_text_fields [_fd_i], XmNactivateCallback, (XtCallbackProc)textFieldCallback, (XtPointer)this); } XmString strForward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 193, "Forward")); XmString strBackward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 194, "Backward")); Widget fd_direction = XmVaCreateSimpleRadioBox(fd_form, "Direction", 0, // Initial selection directionCallback, //NULL, XmVaRADIOBUTTON, strForward, NULL, NULL, NULL, XmVaRADIOBUTTON, strBackward, NULL, NULL, NULL, XmNuserData, this, XmNsensitive, True, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, _fd_labelbox, XmNorientation, XmHORIZONTAL, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 33, NULL); printHelpId ("fd_direction", fd_direction); // add help callback //XtAddCallback (fd_direction, XmNhelpCallback, HelpCB, helpId); XmStringFree(strForward); XmStringFree(strBackward); // // Now create the Action Area. // #define TIGHTNESS 20 register Widget widget; Widget fd_action = XtVaCreateWidget("actionArea", xmFormWidgetClass, fd_pane, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNfractionBase, TIGHTNESS * _num_buttons-1, NULL); printHelpId ("actionArea", fd_action); // add help callback //XtAddCallback (fd_action, XmNhelpCallback, HelpCB, helpId); for (offset = 0; offset < _num_buttons; offset++) { widget = XtVaCreateManagedWidget(_buttonData[offset].label, xmPushButtonWidgetClass, fd_action, XmNleftAttachment, offset ? XmATTACH_POSITION:XmATTACH_FORM, XmNleftPosition, TIGHTNESS * offset, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, offset != _num_buttons - 1 ? XmATTACH_POSITION : XmATTACH_FORM, XmNrightPosition, TIGHTNESS * offset + (TIGHTNESS - 1), XmNshowAsDefault, offset == 0, NULL); // again, bogus -- doesn't each one need a unique tag? printHelpId ("widget", widget); // add help callback //XtAddCallback (widget, XmNhelpCallback, HelpCB, helpId); if (_buttonData[offset].callback != NULL) { XtAddCallback(widget, XmNactivateCallback, _buttonData[offset].callback, _buttonData[offset].data); } if (offset == 0) { Dimension height; Dimension margin; XtVaGetValues(fd_action, XmNmarginHeight, &margin, NULL); XtVaGetValues(widget, XmNheight, &height, NULL); height +=2 * margin; XtVaSetValues(fd_action, XmNdefaultButton, widget, XmNpaneMaximum, height, XmNpaneMinimum, height, NULL); } } _status_text = XtVaCreateManagedWidget("StatusLabel", xmLabelWidgetClass, fd_pane, XmNrightAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNalignment, XmALIGNMENT_BEGINNING, NULL); Dimension height; XtWidgetGeometry size; size.request_mode = CWHeight; XtQueryGeometry(_status_text, NULL, &size); XtVaSetValues(_status_text, XmNpaneMaximum, size.height, XmNpaneMinimum, size.height, NULL); clearStatus(); XtManageChild (fd_form); XtManageChild (fd_direction); XtManageChild(fd_action); XtManageChild(fd_pane); XtManageChild(dialog); // Make sure get the height of the dialog after it has been // managed. XtVaGetValues(dialog, XmNheight, &height, NULL); XtVaSetValues(dialog, XmNmappedWhenManaged, True, XmNminHeight, height, NULL); XtRealizeWidget(dialog); return (fd_pane); }
void EffectManager::logic() { clearStatus(); for (unsigned i=0; i<effect_list.size(); i++) { // expire timed effects and total up magnitudes of active effects if (effect_list[i].duration >= 0) { if (effect_list[i].type == "damage" && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) damage += effect_list[i].magnitude; else if (effect_list[i].type == "hpot" && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) hpot += effect_list[i].magnitude; else if (effect_list[i].type == "mpot" && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) mpot += effect_list[i].magnitude; else if (effect_list[i].type == "speed") speed = (effect_list[i].magnitude * speed) / 100; else if (effect_list[i].type == "immunity") immunity = true; else if (effect_list[i].type == "stun") stun = true; else if (effect_list[i].type == "forced_move") { forced_move = true; forced_speed = effect_list[i].magnitude; } else if (effect_list[i].type == "revive") revive = true; else if (effect_list[i].type == "hp") bonus_hp += effect_list[i].magnitude; else if (effect_list[i].type == "hp_regen") bonus_hp_regen += effect_list[i].magnitude; else if (effect_list[i].type == "hp_percent") bonus_hp_percent += effect_list[i].magnitude; else if (effect_list[i].type == "mp") bonus_mp += effect_list[i].magnitude; else if (effect_list[i].type == "mp_regen") bonus_mp_regen += effect_list[i].magnitude; else if (effect_list[i].type == "mp_percent") bonus_mp_percent += effect_list[i].magnitude; else if (effect_list[i].type == "accuracy") bonus_accuracy += effect_list[i].magnitude; else if (effect_list[i].type == "avoidance") bonus_avoidance += effect_list[i].magnitude; else if (effect_list[i].type == "crit") bonus_crit += effect_list[i].magnitude; else if (effect_list[i].type == "offense") bonus_offense += effect_list[i].magnitude; else if (effect_list[i].type == "defense") bonus_defense += effect_list[i].magnitude; else if (effect_list[i].type == "physical") bonus_physical += effect_list[i].magnitude; else if (effect_list[i].type == "mental") bonus_mental += effect_list[i].magnitude; else if (effect_list[i].type == "xp") bonus_xp += effect_list[i].magnitude; else if (effect_list[i].type == "currency") bonus_currency += effect_list[i].magnitude; else if (effect_list[i].type == "item_find") bonus_item_find += effect_list[i].magnitude; else if (effect_list[i].type == "stealth") bonus_stealth += effect_list[i].magnitude; else { for (unsigned j=0; j<bonus_resist.size(); j++) { if (effect_list[i].type == ELEMENTS[j].name + "_resist") bonus_resist[j] += effect_list[i].magnitude; } } if (effect_list[i].duration > 0) { if (effect_list[i].ticks > 0) effect_list[i].ticks--; if (effect_list[i].ticks == 0) { removeEffect(i); i--; continue; } } } // expire shield effects if (effect_list[i].magnitude_max > 0 && effect_list[i].magnitude == 0) { if (effect_list[i].type == "shield") { removeEffect(i); i--; continue; } } // expire effects based on animations if ((effect_list[i].animation && effect_list[i].animation->isLastFrame()) || !effect_list[i].animation) { if (effect_list[i].type == "heal") { removeEffect(i); i--; continue; } } // animate if (effect_list[i].animation) { if (!effect_list[i].animation->isCompleted()) effect_list[i].animation->advanceFrame(); } } }
void clv( char* status ) { clearStatus( status, STATUS_V ); }
void cli( char* status ) { clearStatus( status, STATUS_I ); }
void cld( char* status ) { clearStatus( status, STATUS_D ); }
void clc( char* status ) { clearStatus( status, STATUS_C ); }
void * saveDbToTape(void *param) { struct saveDbIf *saveDbIfPtr = (struct saveDbIf *)param; afs_int32 code = 0; afs_int32 i; int wroteLabel; afs_uint32 taskId; Date expires; struct butm_tapeInfo tapeInfo; struct budb_dumpEntry dumpEntry; extern struct deviceSyncNode *deviceLatch; extern struct tapeConfig globalTapeConfig; expires = (saveDbIfPtr->archiveTime ? NEVERDATE : 0); taskId = saveDbIfPtr->taskId; setStatus(taskId, DRIVE_WAIT); EnterDeviceQueue(deviceLatch); /* lock tape device */ clearStatus(taskId, DRIVE_WAIT); printf("\n\n"); TLog(taskId, "SaveDb\n"); tapeInfo.structVersion = BUTM_MAJORVERSION; code = butm_file_Instantiate(&tapeInfo, &globalTapeConfig); if (code) { ErrorLog(0, taskId, code, tapeInfo.error, "Can't initialize tape module\n"); ERROR_EXIT(code); } /* Determine what the last database dump was */ memset(&lastDump, 0, sizeof(lastDump)); code = bcdb_FindLatestDump("", "", &lastDump); if (code) { if (code != BUDB_NODUMPNAME) { ErrorLog(0, taskId, code, 0, "Can't read backup database\n"); ERROR_EXIT(code); } memset(&lastDump, 0, sizeof(lastDump)); } code = CreateDBDump(&dumpEntry); /* Create a dump for this tape */ if (code) { ErrorLog(0, taskId, code, 0, "Can't create dump in database\n"); ERROR_EXIT(code); } listEntryHead = NULL; /* Get the tape and write a new label to it */ code = GetDBTape(taskId, expires, &tapeInfo, dumpEntry.id, 1, autoQuery, &wroteLabel); /* * If did not write the label, remove created dump * Else if wrote the label, remove old dump from db so it's not saved. */ if (!wroteLabel) { i = bcdb_deleteDump(dumpEntry.id, 0, 0, 0); dumpEntry.id = 0; if (i && (i != BUDB_NOENT)) ErrorLog(0, taskId, i, 0, "Unable to delete DB entry %u.\n", dumpEntry.id); } else if (listEntryHead->oldDumpId) { i = bcdb_deleteDump(listEntryHead->oldDumpId, 0, 0, 0); listEntryHead->oldDumpId = 0; if (i && (i != BUDB_NOENT)) { ErrorLog(0, taskId, i, 0, "Unable to delete old DB entry %u.\n", listEntryHead->oldDumpId); ERROR_EXIT(i); } } if (code) ERROR_EXIT(code); TapeLog(1, taskId, 0, 0, "Tape accepted - now dumping database\n"); /* we have a writable tape */ code = writeDbDump(&tapeInfo, taskId, expires, dumpEntry.id); if (code) ERROR_EXIT(code); /* Now delete the entries between time 0 and archive-time */ if (saveDbIfPtr->archiveTime) code = bcdb_deleteDump(0, 0, saveDbIfPtr->archiveTime, 0); error_exit: unmountTape(taskId, &tapeInfo); /* Add this dump's tapes to the database and mark it finished */ if (dumpEntry.id) { i = addTapesToDb(taskId); if (!code) code = i; i = bcdb_FinishDump(&dumpEntry); if (!code) code = i; } freeTapeList(); if (code == TC_ABORTEDBYREQUEST) { TLog(taskId, "SaveDb: Aborted by request\n"); clearStatus(taskId, ABORT_REQUEST); setStatus(taskId, ABORT_DONE); } else if (code) { TapeLog(0, taskId, code, 0, "SaveDb: Finished with errors\n"); setStatus(taskId, TASK_ERROR); } else { TLog(taskId, "SaveDb: Finished\n"); } setStatus(taskId, TASK_DONE); free(saveDbIfPtr); LeaveDeviceQueue(deviceLatch); return (void *)(intptr_t)(code); }
void EffectManager::logic() { clearStatus(); for (unsigned i=0; i<effect_list.size(); i++) { // expire timed effects and total up magnitudes of active effects if (effect_list[i].duration >= 0) { if (effect_list[i].type == "damage" && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) damage += effect_list[i].magnitude; else if (effect_list[i].type == "hpot" && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) hpot += effect_list[i].magnitude; else if (effect_list[i].type == "mpot" && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) mpot += effect_list[i].magnitude; else if (effect_list[i].type == "speed") speed = (effect_list[i].magnitude * speed) / 100; else if (effect_list[i].type == "immunity") immunity = true; else if (effect_list[i].type == "stun") stun = true; else if (effect_list[i].type == "revive") revive = true; else if (effect_list[i].type == "convert") convert = true; else if (effect_list[i].type == "fear") fear = true; else if (effect_list[i].type == "offense") bonus_offense += effect_list[i].magnitude; else if (effect_list[i].type == "defense") bonus_defense += effect_list[i].magnitude; else if (effect_list[i].type == "physical") bonus_physical += effect_list[i].magnitude; else if (effect_list[i].type == "mental") bonus_mental += effect_list[i].magnitude; else { bool found_key = false; for (unsigned j=0; j<STAT_COUNT; j++) { if (effect_list[i].type == STAT_NAME[j]) { bonus[j] += effect_list[i].magnitude; found_key = true; } } if (!found_key) { for (unsigned j=0; j<bonus_resist.size(); j++) { if (effect_list[i].type == ELEMENTS[j].name + "_resist") bonus_resist[j] += effect_list[i].magnitude; } } } if (effect_list[i].duration > 0) { if (effect_list[i].ticks > 0) effect_list[i].ticks--; if (effect_list[i].ticks == 0) { //death sentence is only applied at the end of the timer if (effect_list[i].type == "death_sentence") death_sentence = true; removeEffect(i); i--; continue; } } } // expire shield effects if (effect_list[i].magnitude_max > 0 && effect_list[i].magnitude == 0) { if (effect_list[i].type == "shield") { removeEffect(i); i--; continue; } } // expire effects based on animations if ((effect_list[i].animation && effect_list[i].animation->isLastFrame()) || !effect_list[i].animation) { if (effect_list[i].type == "heal") { removeEffect(i); i--; continue; } } // animate if (effect_list[i].animation) { if (!effect_list[i].animation->isCompleted()) effect_list[i].animation->advanceFrame(); } } }
void EffectManager::logic() { clearStatus(); for (unsigned i=0; i<effect_list.size(); i++) { // @CLASS EffectManager|Description of "type" in powers/effects.txt // expire timed effects and total up magnitudes of active effects if (effect_list[i].duration >= 0) { // @TYPE damage|Damage per second if (effect_list[i].type == EFFECT_DAMAGE && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) damage += effect_list[i].magnitude; // @TYPE damage_percent|Damage per second (percentage of max HP) else if (effect_list[i].type == EFFECT_DAMAGE_PERCENT && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) damage_percent += effect_list[i].magnitude; // @TYPE hpot|HP restored per second else if (effect_list[i].type == EFFECT_HPOT && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) hpot += effect_list[i].magnitude; // @TYPE hpot_percent|HP restored per second (percentage of max HP) else if (effect_list[i].type == EFFECT_HPOT_PERCENT && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) hpot_percent += effect_list[i].magnitude; // @TYPE mpot|MP restored per second else if (effect_list[i].type == EFFECT_MPOT && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) mpot += effect_list[i].magnitude; // @TYPE mpot_percent|MP restored per second (percentage of max MP) else if (effect_list[i].type == EFFECT_MPOT_PERCENT && effect_list[i].ticks % MAX_FRAMES_PER_SEC == 1) mpot_percent += effect_list[i].magnitude; // @TYPE speed|Changes movement speed. A magnitude of 100 is 100% speed (aka normal speed). else if (effect_list[i].type == EFFECT_SPEED) speed = (static_cast<float>(effect_list[i].magnitude) * speed) / 100.f; // @TYPE immunity|Applies all immunity effects. Magnitude is ignored. else if (effect_list[i].type == EFFECT_IMMUNITY) { immunity_damage = true; immunity_slow = true; immunity_stun = true; immunity_hp_steal = true; immunity_mp_steal = true; immunity_knockback = true; immunity_damage_reflect = true; } // @TYPE immunity_damage|Removes and prevents damage over time. Magnitude is ignored. else if (effect_list[i].type == EFFECT_IMMUNITY_DAMAGE) immunity_damage = true; // @TYPE immunity_slow|Removes and prevents slow effects. Magnitude is ignored. else if (effect_list[i].type == EFFECT_IMMUNITY_SLOW) immunity_slow = true; // @TYPE immunity_stun|Removes and prevents stun effects. Magnitude is ignored. else if (effect_list[i].type == EFFECT_IMMUNITY_STUN) immunity_stun = true; // @TYPE immunity_hp_steal|Prevents HP stealing. Magnitude is ignored. else if (effect_list[i].type == EFFECT_IMMUNITY_HP_STEAL) immunity_hp_steal = true; // @TYPE immunity_mp_steal|Prevents MP stealing. Magnitude is ignored. else if (effect_list[i].type == EFFECT_IMMUNITY_MP_STEAL) immunity_mp_steal = true; // @TYPE immunity_knockback|Removes and prevents knockback effects. Magnitude is ignored. else if (effect_list[i].type == EFFECT_IMMUNITY_KNOCKBACK) immunity_knockback = true; // @TYPE immunity_damage_reflect|Prevents damage reflection. Magnitude is ignored. else if (effect_list[i].type == EFFECT_IMMUNITY_DAMAGE_REFLECT) immunity_damage_reflect = true; // @TYPE stun|Can't move or attack. Being attacked breaks stun. else if (effect_list[i].type == EFFECT_STUN) stun = true; // @TYPE revive|Revives the player. Typically attached to a power that triggers when the player dies. else if (effect_list[i].type == EFFECT_REVIVE) revive = true; // @TYPE convert|Causes an enemy or an ally to switch allegiance else if (effect_list[i].type == EFFECT_CONVERT) convert = true; // @TYPE fear|Causes enemies to run away else if (effect_list[i].type == EFFECT_FEAR) fear = true; // @TYPE knockback|Pushes the target away from the source caster. Speed is the given value divided by the framerate cap. else if (effect_list[i].type == EFFECT_KNOCKBACK) knockback_speed = static_cast<float>(effect_list[i].magnitude)/static_cast<float>(MAX_FRAMES_PER_SEC); // @TYPE ${STATNAME}|Increases ${STATNAME}, where ${STATNAME} is any of the base stats. Examples: hp, dmg_melee_min, xp_gain else if (effect_list[i].type >= EFFECT_COUNT && effect_list[i].type < EFFECT_COUNT+STAT_COUNT) { bonus[effect_list[i].type - EFFECT_COUNT] += effect_list[i].magnitude; } // @TYPE ${ELEMENT}_resist|Increase Resistance % to ${ELEMENT}, where ${ELEMENT} is any found in engine/elements.txt. Example: fire_resist else if (effect_list[i].type >= EFFECT_COUNT + STAT_COUNT && effect_list[i].type < EFFECT_COUNT+STAT_COUNT+static_cast<int>(ELEMENTS.size())) { bonus_resist[effect_list[i].type - EFFECT_COUNT - STAT_COUNT] += effect_list[i].magnitude; } // @TYPE ${PRIMARYSTAT}|Increases ${PRIMARYSTAT}, where ${PRIMARYSTAT} is any of the primary stats defined in engine/primary_stats.txt. Example: physical else if (effect_list[i].type >= EFFECT_COUNT) { bonus_primary[effect_list[i].type - EFFECT_COUNT - STAT_COUNT - ELEMENTS.size()] += effect_list[i].magnitude; } if (effect_list[i].duration > 0) { if (effect_list[i].ticks > 0) effect_list[i].ticks--; if (effect_list[i].ticks == 0) { //death sentence is only applied at the end of the timer // @TYPE death_sentence|Causes sudden death at the end of the effect duration. if (effect_list[i].type == EFFECT_DEATH_SENTENCE) death_sentence = true; removeEffect(i); i--; continue; } } } // expire shield effects if (effect_list[i].magnitude_max > 0 && effect_list[i].magnitude == 0) { // @TYPE shield|Create a damage absorbing barrier based on Mental damage stat. Duration is ignored. if (effect_list[i].type == EFFECT_SHIELD) { removeEffect(i); i--; continue; } } // expire effects based on animations if ((effect_list[i].animation && effect_list[i].animation->isLastFrame()) || !effect_list[i].animation) { // @TYPE heal|Restore HP based on Mental damage stat. if (effect_list[i].type == EFFECT_HEAL) { removeEffect(i); i--; continue; } } // animate if (effect_list[i].animation) { if (!effect_list[i].animation->isCompleted()) effect_list[i].animation->advanceFrame(); } } }