Local void subgrep(struct LOC_grep *LINK) { LINK->matching = true; if (LINK->pattern[LINK->p-1] == '*') { remember(LINK->s, strlen(LINK->source), LINK); LINK->p++; return; } if (LINK->pattern[LINK->p-1] == '?') { remember(LINK->s, LINK->s, LINK); LINK->p++; return; } if (LINK->pattern[LINK->p-1] == '#') { matchnum(LINK); return; } if (LINK->pattern[LINK->p-1] == '\\') { matchmeta(LINK); return; } if (LINK->source[LINK->s-1] == LINK->pattern[LINK->p-1]) { LINK->s++; LINK->p++; } else LINK->matching = false; }
void nmethod::check_store() { if (key.is_new() || scopes->is_new()) { remember(); return; } FOR_MY_CODETABLE_ENTRIES(e) if (e->key.is_new()) { remember(); return; } }
int computermove (void) { int move, bestmove, rank, bestrank, c, r, check; int saveboard[14]; for (c=0; c < 14; c++) saveboard[c] = board[c]; bestrank = -99; for (move = 7; move <= 12; move++) if (board[move]) { rank = 0; domove(move, 13); for (c = 0; c < 5; c++) if (board[c]) { r = 0; check = board[c] + c; while (check > 14) { check -= 14; r = -1;} if ((!board[check]) && (check !=6) && (check != 13)) r-=board[12 - check]; rank =(r < rank) ? r : rank; } rank += board[13] - board[6]; if (turn < 9) { check = memory[memory[0]] * 6 + move - 7; for (c = 1; c < memory[0]; c++) if (check == (int) ((float) memory[c] / pow (6, (7 - turn)))) rank -= 2; } for (c=0; c < 14; c++) board[c] = saveboard[c]; if (rank >= bestrank) {bestrank = rank; bestmove = move;} } remember (bestmove); printf("Computer moves %d", (bestmove - 6)); return (bestmove); }
bool SimpSolver::addClause(vec<Lit>& ps) { for (int i = 0; i < ps.size(); i++) if (isEliminated(var(ps[i]))) remember(var(ps[i])); int nclauses = clauses.size(); if (redundancy_check && implied(ps)) return true; if (!Solver::addClause(ps)) return false; if (use_simplification && clauses.size() == nclauses + 1){ Clause& c = *clauses.last(); subsumption_queue.insert(&c); for (int i = 0; i < c.size(); i++){ assert(occurs.size() > var(c[i])); assert(!find(occurs[var(c[i])], &c)); occurs[var(c[i])].push(&c); n_occ[toInt(c[i])]++; touched[var(c[i])] = 1; assert(elimtable[var(c[i])].order == 0); if (elim_heap.inHeap(var(c[i]))) elim_heap.increase_(var(c[i])); } } return true; }
//------------------------------------------------------------------------ void CTextEdit::platformLooseFocus (bool returnPressed) { remember (); bWasReturnPressed = returnPressed; getFrame ()->setFocusView (0); forget (); }
window():env(app::inst()), back_color( 197, 194, 197 ), // grey border_color ( 255, 255, 255 ), ximg(0), place(100,100,600,400), next(0),prev(0) { remember(); }
int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer uart_timer_configure(); uart_init(); _enable_interrupts(); uart_puts("\n\r***************\n\r"); uart_puts("MSP430 SunV2\n\r"); uart_puts("***************\n\r\n\r"); uint8_t c; // Timeshare between UART and dimming while(1) { if(uart_getc(&c)) { if(c == '\r') { uart_putc('\n'); uart_putc('\r'); } else { uart_putc('['); uart_putc(c); uart_putc(']'); // Clear UART configuration _disable_interrupts(); timer_deconfigure(); uart_disable(); uart_timerA_disable(); switch (c) { case 'w': turnOn(); break; case 's': turnOff(); break; case 'r': remember(); break; case 'd': dimUp(); break; case 'a': dimDown(); break; } // UART configuration art_init(); timer_deconfigure(); uart_timer_configure(); uart_timerA_enable(); _enable_interrupts(); } } } }
int playermove (int pl) { int input; do { printf ("Player #%d, your move? (1 - 6) ", pl + 1); scanf ("%d", &input); if ((input < 1) || (input > 6) || !board[input + ((pl) ? 6 : - 1)]) { printf ("Illegal move.\n"); input=0; } } while (!input); remember (--input); return (input + ((pl) ? 7 : 0)); }
ShutdownPrompt::ShutdownPrompt( QWidget *parent ) : QDialog( parent ), ui( new Ui::ShutdownPrompt ) { ui->setupUi( this ); QStyle *style = this->style(); int iconSize = style->pixelMetric( QStyle::PM_MessageBoxIconSize, 0, this ); QIcon tmpIcon = style->standardIcon( QStyle::SP_MessageBoxQuestion, 0, this ); ui->iconLabel->setPixmap( tmpIcon.pixmap( iconSize, iconSize ) ); connect( ui->remember, SIGNAL( clicked() ), this, SLOT( remember() ) ); connect( ui->dontRemember, SIGNAL( clicked() ), this, SLOT( dontRemember() ) ); }
lbool SimpSolver::solve(const vec<Lit>& assumps, bool do_simp, bool turn_off_simp) { vec<Var> extra_frozen; lbool result = l_True; do_simp &= use_simplification; do_simp &= (decisionLevel() == 0); if (do_simp){ // Assumptions must be temporarily frozen to run variable elimination: for (int i = 0; i < assumps.size(); i++){ Var v = var(assumps[i]); // If an assumption has been eliminated, remember it. if (isEliminated(v)) remember(v); if (!frozen[v]){ // Freeze and store. setFrozen(v, true); extra_frozen.push(v); } } if(eliminate(turn_off_simp)) result = l_True; else result = l_False; } if (result == l_True) result = Solver::solve(assumps); if (result == l_True) { extendModel(); #ifndef NDEBUG verifyModel(); #endif } if (do_simp) // Unfreeze the assumptions that were frozen: for (int i = 0; i < extra_frozen.size(); i++) setFrozen(extra_frozen[i], false); return result; }
int sched.result() /* wait for termination and retrieve result */ { DB(("%x->sched::result( )\n", this)); DB((" o_type == x%x\n", o_type)); if (this == (sched*)thistask) task_error(E_RESULT,0); while (s_state != TERMINATED) { remember(thistask); DB((" o_type == x%x -- remember(x%x)\n", o_type,thistask)); thistask->sleep(); DB((" o_type == x%x -- x%x->sleep()\n", o_type,thistask)); forget(thistask); DB((" o_type == x%x -- forget(x%x)\n", o_type,thistask)); } return (int) s_time; }
void run_sspath(t_csr *gs, p_list *predecesor, lint source, double delta){ int i; char f_buf[100]; sprintf(f_buf, "./data/log/ori"); FILE *log = fopen(f_buf, "w"); p_list *B = (p_list*)malloc(sizeof(p_list)*1000); for(i=0;i<1000;i++){ B[i] = (p_list) malloc(sizeof(t_list)); creat_list(B[i]); } p_list R = (p_list)malloc(sizeof(t_list)); p_list S = (p_list)malloc(sizeof(t_list)); creat_list(R); creat_list(S); for(i=0;i<gs->v_size;i++) gs->vet_info[i].weight = INFINITY; //relax source vertex add_list_two(B[0], source, 0.0); gs->vet_info[source].weight = 0.0; lint b_total = 1; lint iter = 0; //major computing while(b_total>0){ empty(R); while (B[iter]->next!=NULL){ request(gs, delta, B[iter], R, TYPE_LIGHT); remember(B[iter], S, &b_total); relax(gs, predecesor, B, R, delta, &b_total); //DPRINTF(1, "finished relax\n"); } request(gs, delta, S, R, TYPE_HEAVY); relax(gs, predecesor, B, R, delta, &b_total); print_B(B, log, iter); //printf("=================iter %ld\n", iter); iter++; //DPRINTF(1, "finished iteration %lld \n", iter); } //DPRINTF(1, "iterations taken %lld\n", iter); //for(i=0;i<gs->v_size;i++) // DPRINTF(1, "vertex %lld %f\n", (i+1), gs->vet_info[i].weight); //DPRINTF(1, "\n"); }
AutoFillNotification::AutoFillNotification(const QUrl &url, const PageFormData &formData, const PasswordEntry &updateData) : AnimatedWidget(AnimatedWidget::Down, 300, 0) , ui(new Ui::AutoFillNotification) , m_url(url) , m_formData(formData) , m_updateData(updateData) { setAutoFillBackground(true); setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(widget()); ui->closeButton->setIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton)); QString hostPart; QString userPart; if (!url.host().isEmpty()) { hostPart = tr("on %1").arg(url.host()); } if (!m_formData.username.isEmpty()) { userPart = tr("for <b>%1</b>").arg(m_formData.username); } if (m_updateData.isValid()) { ui->label->setText(tr("Do you want QupZilla to update saved password %1?").arg(userPart)); ui->remember->setVisible(false); ui->never->setVisible(false); } else { ui->label->setText(tr("Do you want QupZilla to remember the password %1 %2?").arg(userPart, hostPart)); ui->update->setVisible(false); } connect(ui->update, SIGNAL(clicked()), this, SLOT(update())); connect(ui->remember, SIGNAL(clicked()), this, SLOT(remember())); connect(ui->never, SIGNAL(clicked()), this, SLOT(never())); connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide())); startAnimation(); }
Local void matchnum(struct LOC_grep *LINK) { boolean allowsign = false, allowpoint = false, quit = false; short s0; LINK->matching = false; s0 = LINK->s; if (LINK->p < strlen(LINK->pattern)) { if (LINK->pattern[LINK->p] == '#') { LINK->p++; allowsign = true; if (LINK->p < strlen(LINK->pattern)) { if (LINK->pattern[LINK->p] == '#') { LINK->p++; allowpoint = true; } } } } if (allowsign && (LINK->source[LINK->s-1] == '-' || LINK->source[LINK->s-1] == '+')) { LINK->s++; if (LINK->s > strlen(LINK->source)) return; } while (!quit && LINK->s <= strlen(LINK->source)) { if (LINK->source[LINK->s-1] == '.') { if (!allowpoint) quit = true; else { LINK->s++; allowpoint = false; } } if (isdigit(LINK->source[LINK->i-1])) { LINK->s++; LINK->matching = true; } else quit = true; } if (LINK->matching) remember(s0, LINK->s - 1, LINK); }
static int doglob(struct dirbuf *np, const char *pattern) { struct dirbuf name = *np; struct stat stb; const char *s; /* Loop over all pattern components */ while (*pattern) { /* Skip slashes, but make sure the named file * exists and is a directory. * This takes care of "foobar/" patterns */ if (*pattern == '/' || !strncmp(pattern, "./", 2)) { if (stat(dirbuf_as_path(&name), &stb) < 0 || !S_ISDIR(stb.st_mode)) return 0; pattern++; continue; } /* Try to match a component of the path name */ for (s = pattern; *s && *s != '/'; s++) { /* Remainder has globbing chars */ if (strchr(GLOBCHARS, *s)) return matchdir(&name, pattern); } /* This path component didn't contain a special * character, so no matching required. * Make sure though that the file exists. */ if (!dirbuf_addslash(&name) || !dirbuf_appends(&name, pattern, s - pattern) || access(dirbuf_as_path(&name), F_OK) < 0) return 0; pattern = s; } remember(dirbuf_as_path(&name)); return 1; }
AutoFillNotification::AutoFillNotification(const QUrl &url, const QByteArray &data, const QString &user, const QString &pass, QWidget* parent) : AnimatedWidget(AnimatedWidget::Down, 300, parent) , ui(new Ui::AutoFillWidget) , m_url(url) , m_data(data) , m_user(user) , m_pass(pass) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(widget()); ui->label->setText(tr("Do you want QupZilla to remember the password for <b>%1</b> on %2?").arg(user, url.host())); ui->closeButton->setIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton)); connect(ui->remember, SIGNAL(clicked()), this, SLOT(remember())); connect(ui->never, SIGNAL(clicked()), this, SLOT(never())); connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide())); startAnimation(); }
void PointDialog::init() { update(); remember(); connect(&m_viewer.electrons(), SIGNAL(modeChanged(PointCloud::Mode)), this, SLOT(updateComboBoxElectrons(PointCloud::Mode))); connect(&m_viewer.defects(), SIGNAL(modeChanged(PointCloud::Mode)), this, SLOT(updateComboBoxDefects(PointCloud::Mode))); connect(&m_viewer.holes(), SIGNAL(modeChanged(PointCloud::Mode)), this, SLOT(updateComboBoxHoles(PointCloud::Mode))); connect(&m_viewer.traps(), SIGNAL(modeChanged(PointCloud::Mode)), this, SLOT(updateComboBoxTraps(PointCloud::Mode))); connect(&m_viewer.electrons(), SIGNAL(pointSizeChanged(float)), this, SLOT(updateSpinBoxElectrons(float))); connect(&m_viewer.defects(), SIGNAL(pointSizeChanged(float)), this, SLOT(updateSpinBoxDefects(float))); connect(&m_viewer.holes(), SIGNAL(pointSizeChanged(float)), this, SLOT(updateSpinBoxHoles(float))); connect(&m_viewer.traps(), SIGNAL(pointSizeChanged(float)), this, SLOT(updateSpinBoxTraps(float))); connect(&m_viewer.electrons(), SIGNAL(visibleChanged(bool)), this, SLOT(updateCheckBoxElectrons(bool))); connect(&m_viewer.defects(), SIGNAL(visibleChanged(bool)), this, SLOT(updateCheckBoxDefects(bool))); connect(&m_viewer.holes(), SIGNAL(visibleChanged(bool)), this, SLOT(updateCheckBoxHoles(bool))); connect(&m_viewer.traps(), SIGNAL(visibleChanged(bool)), this, SLOT(updateCheckBoxTraps(bool))); }
int Gh3c::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: iconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break; case 1: remember((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: login(); break; case 3: disconnect(); break; case 4: about(); break; case 5: userchanged(); break; case 6: showtime(); break; default: ; } _id -= 7; } return _id; }
void Player::makeMove() { vector<Vec2> squareDirs = creature->getConstSquare()->getTravelDir(); const vector<Creature*>& creatures = creature->getLevel()->getAllCreatures(); if (creature->isAffected(Creature::HALLU)) ViewObject::setHallu(true); else ViewObject::setHallu(false); MEASURE( model->getView()->refreshView(creature), "level render time"); if (Options::getValue(OptionId::HINTS) && displayTravelInfo && creature->getConstSquare()->getName() == "road") { model->getView()->presentText("", "Use ctrl + arrows to travel quickly on roads and corridors."); displayTravelInfo = false; } static bool greeting = false; if (Options::getValue(OptionId::HINTS) && displayGreeting) { CHECK(creature->getFirstName()); model->getView()->presentText("", "Dear " + *creature->getFirstName() + ",\n \n \tIf you are reading this letter, then you have arrived in the valley of " + NameGenerator::worldNames.getNext() + ". There is a band of dwarves dwelling in caves under a mountain. Find them, talk to them, they will help you. Let your sword guide you.\n \n \nYours, " + NameGenerator::firstNames.getNext() + "\n \nPS.: Beware the goblins!"); model->getView()->presentText("", "Every settlement that you find has a leader, and they may have quests for you." "\n \nYou can turn these messages off in the options (press F2)."); displayGreeting = false; model->getView()->refreshView(creature); } for (const Creature* c : creature->getVisibleEnemies()) { if (c->isSpecialMonster() && !contains(specialCreatures, c)) { privateMessage(MessageBuffer::important(c->getDescription())); model->getView()->refreshView(creature); specialCreatures.push_back(c); } } if (travelling) travelAction(); else if (target) targetAction(); else { Action action = model->getView()->getAction(); vector<Vec2> direction; bool travel = false; switch (action.getId()) { case ActionId::FIRE: fireAction(action.getDirection()); break; case ActionId::TRAVEL: travel = true; case ActionId::MOVE: direction.push_back(action.getDirection()); break; case ActionId::MOVE_TO: if (action.getDirection().dist8(creature->getPosition()) == 1) { Vec2 dir = action.getDirection() - creature->getPosition(); if (const Creature* c = creature->getConstSquare(dir)->getCreature()) { if (!creature->isEnemy(c)) { chatAction(dir); break; } } direction.push_back(dir); } else if (action.getDirection() != creature->getPosition()) { target = action.getDirection(); target = Vec2(min(creature->getLevel()->getBounds().getKX() - 1, max(0, target->x)), min(creature->getLevel()->getBounds().getKY() - 1, max(0, target->y))); // Just in case if (!target->inRectangle(creature->getLevel()->getBounds())) target = Nothing(); } else pickUpAction(false); break; case ActionId::SHOW_INVENTORY: displayInventory(); break; case ActionId::PICK_UP: pickUpAction(false); break; case ActionId::EXT_PICK_UP: pickUpAction(true); break; case ActionId::DROP: dropAction(false); break; case ActionId::EXT_DROP: dropAction(true); break; case ActionId::WAIT: creature->wait(); break; case ActionId::APPLY_ITEM: applyAction(); break; case ActionId::THROW: throwAction(); break; case ActionId::THROW_DIR: throwAction(action.getDirection()); break; case ActionId::EQUIPMENT: equipmentAction(); break; case ActionId::HIDE: hideAction(); break; case ActionId::PAY_DEBT: payDebtAction(); break; case ActionId::CHAT: chatAction(); break; case ActionId::SHOW_HISTORY: messageBuffer.showHistory(); break; case ActionId::UNPOSSESS: if (creature->canPopController()) { creature->popController(); return; } break; case ActionId::CAST_SPELL: spellAction(); break; case ActionId::DRAW_LEVEL_MAP: model->getView()->drawLevelMap(creature); break; case ActionId::EXIT: model->exitAction(); break; case ActionId::IDLE: break; } if (creature->isAffected(Creature::SLEEP) && creature->canPopController()) { if (model->getView()->yesOrNoPrompt("You fell asleep. Do you want to leave your minion?")) creature->popController(); return; } for (Vec2 dir : direction) if (travel) { vector<Vec2> squareDirs = creature->getConstSquare()->getTravelDir(); if (findElement(squareDirs, dir)) { travelDir = dir; lastLocation = creature->getLevel()->getLocation(creature->getPosition()); travelling = true; travelAction(); } } else if (creature->canMove(dir)) { creature->move(dir); itemsMessage(); break; } else { const Creature *c = creature->getConstSquare(dir)->getCreature(); if (creature->canBumpInto(dir)) { creature->bumpInto(dir); break; } else if (creature->canDestroy(dir)) { privateMessage("You bash the " + creature->getSquare(dir)->getName()); creature->destroy(dir); break; } } } for (Vec2 pos : creature->getLevel()->getVisibleTiles(creature)) { ViewIndex index = creature->getLevel()->getSquare(pos)->getViewIndex(creature); (*levelMemory)[creature->getLevel()].clearSquare(pos); for (ViewLayer l : { ViewLayer::ITEM, ViewLayer::FLOOR_BACKGROUND, ViewLayer::FLOOR, ViewLayer::LARGE_ITEM}) if (index.hasObject(l)) remember(pos, index.getObject(l)); } }
void Player::learnLocation(const Location* loc) { for (Vec2 v : loc->getBounds()) remember(v, creature->getLevel()->getSquare(v)->getViewObject()); }
void check_store(oop x, char *bound) { if (Universe::new_gen.is_new(x, bound)) remember(); }
void genfile_cache::remember(const char *outfile, const llvm::Module *module, const std::string &options) { uint32_t hash = convert_mod2crc(module, options); remember(outfile, hash); }
void genfile_cache::remember(const char *outfile, const std::string &source, const std::string &options) { uint32_t hash = convert_src2crc(source, options); remember(outfile, hash); }
lbool SimpSMTSolver::solve( const vec< Lit > & assumps , const unsigned conflicts , bool do_simp , bool turn_off_simp) { vec<Var> extra_frozen; bool result = true; if ( config.sat_preprocess_theory == 0 ) goto skip_theory_preproc; opensmt_error( "preprocess theory has been temporairly disabled in this version" ); skip_theory_preproc: // Added Code //================================================================================================= do_simp &= use_simplification; if (do_simp) { // Assumptions must be temporarily frozen to run variable elimination: for (int i = 0; i < assumps.size(); i++) { Var v = var(assumps[i]); // If an assumption has been eliminated, remember it. if (isEliminated(v)) remember(v); if (!frozen[v]) { // Freeze and store. setFrozen(v, true); extra_frozen.push(v); } } result = eliminate(turn_off_simp); } #ifdef STATISTICS CoreSMTSolver::preproc_time = cpuTime( ); #endif lbool lresult = l_Undef; if (result) lresult = CoreSMTSolver::solve(assumps, conflicts); else lresult = l_False; if (lresult == l_True) { extendModel(); // Previous line // #ifndef NDEBUG #ifndef SMTCOMP verifyModel(); #endif } if (do_simp) // Unfreeze the assumptions that were frozen: for (int i = 0; i < extra_frozen.size(); i++) setFrozen(extra_frozen[i], false); return lresult; }
bool SimpSMTSolver::addClause( vec<Lit> & ps #ifdef PRODUCE_PROOF , const ipartitions_t & in #endif ) { //================================================================================================= // Added code if ( !use_simplification ) #ifdef PRODUCE_PROOF return CoreSMTSolver::addClause( ps, in ); #else return CoreSMTSolver::addClause( ps ); #endif // Added code //================================================================================================= for (int i = 0; i < ps.size(); i++) if (isEliminated(var(ps[i]))) remember(var(ps[i])); int nclauses = clauses.size(); if (redundancy_check && implied(ps)) return true; //================================================================================================= // Added code // // Hack to consider clauses of size 1 that // wouldn't otherwise be considered by // MiniSAT // if ( config.sat_preprocess_theory != 0 && ps.size( ) == 1 // Consider unit clauses && var(ps[0]) >= 2 ) // Don't consider true/false { Var v = var( ps[0] ); cerr << "XXX skipped handling of unary theory literal?" << endl; /* Enode * e = theory_handler->varToEnode( v ); if ( e->isTAtom( ) ) { Clause * uc = Clause_new(ps, false); unary_to_remove.push_back( uc ); Clause &c = *(unary_to_remove.back( )); Enode * x, * y; getDLVars( e, sign(ps[0]), &x, &y ); assert( x->isVar( ) ); assert( y->isVar( ) ); t_pos[ x->getId( ) ].push_back( &c ); t_neg[ y->getId( ) ].push_back( &c ); t_var[ x ].insert( y->getId( ) ); t_var[ y ].insert( x->getId( ) ); } */ } // Added code //================================================================================================= if (!CoreSMTSolver::addClause(ps)) return false; if (use_simplification && clauses.size() == nclauses + 1) { Clause& c = *clauses.last(); subsumption_queue.insert(&c); for (int i = 0; i < c.size(); i++) { assert(occurs.size() > var(c[i])); assert(!find(occurs[var(c[i])], &c)); occurs[var(c[i])].push(&c); n_occ[toInt(c[i])]++; touched[var(c[i])] = 1; assert(elimtable[var(c[i])].order == 0); if (elim_heap.inHeap(var(c[i]))) elim_heap.increase_(var(c[i])); } } return true; }
/* * Alert: As of bpl14, this function returns the following codes: * < 0 Victim died. * = 0 No damage. * > 0 How much damage done. */ int damage(struct char_data *ch, struct char_data *victim, int dam, int attacktype) { if (GET_POS(victim) <= POS_DEAD) { /* This is "normal"-ish now with delayed extraction. -gg 3/15/2001 */ if (PLR_FLAGGED(victim, PLR_NOTDEADYET) || MOB_FLAGGED(victim, MOB_NOTDEADYET)) return (-1); log("SYSERR: Attempt to damage corpse '%s' in room #%d by '%s'.", GET_NAME(victim), GET_ROOM_VNUM(IN_ROOM(victim)), GET_NAME(ch)); die(victim); return (-1); /* -je, 7/7/92 */ } /* peaceful rooms */ if (ch != victim && ROOM_FLAGGED(IN_ROOM(ch), ROOM_PEACEFUL)) { send_to_char(ch, "This room just has such a peaceful, easy feeling...\r\n"); return (0); } /* shopkeeper protection */ if (!ok_damage_shopkeeper(ch, victim)) return (0); /* You can't damage an immortal! */ if (!IS_NPC(victim) && (GET_LEVEL(victim) >= LVL_IMMORT)) dam = 0; if (victim != ch) { /* Start the attacker fighting the victim */ if (GET_POS(ch) > POS_STUNNED && (FIGHTING(ch) == NULL)) set_fighting(ch, victim); /* Start the victim fighting the attacker */ if (GET_POS(victim) > POS_STUNNED && (FIGHTING(victim) == NULL)) { set_fighting(victim, ch); if (MOB_FLAGGED(victim, MOB_MEMORY) && !IS_NPC(ch)) remember(victim, ch); } } /* If you attack a pet, it hates your guts */ if (victim->master == ch) stop_follower(victim); /* If the attacker is invisible, he becomes visible */ if (AFF_FLAGGED(ch, AFF_INVISIBLE | AFF_HIDE)) appear(ch); /* Cut damage in half if victim has sanct, to a minimum 1 */ if (AFF_FLAGGED(victim, AFF_SANCTUARY) && dam >= 2) dam /= 2; /* Check for PK if this is not a PK MUD */ if (!pk_allowed) { check_killer(ch, victim); if (PLR_FLAGGED(ch, PLR_KILLER) && (ch != victim)) dam = 0; } /* Set the maximum damage per round and subtract the hit points */ dam = MAX(MIN(dam, 100), 0); GET_HIT(victim) -= dam; /* Gain exp for the hit */ if (ch != victim) gain_exp(ch, GET_LEVEL(victim) * dam); update_pos(victim); /* * skill_message sends a message from the messages file in lib/misc. * dam_message just sends a generic "You hit $n extremely hard.". * skill_message is preferable to dam_message because it is more * descriptive. * * If we are _not_ attacking with a weapon (i.e. a spell), always use * skill_message. If we are attacking with a weapon: If this is a miss or a * death blow, send a skill_message if one exists; if not, default to a * dam_message. Otherwise, always send a dam_message. */ if (!IS_WEAPON(attacktype)) skill_message(dam, ch, victim, attacktype); else { if (GET_POS(victim) == POS_DEAD || dam == 0) { if (!skill_message(dam, ch, victim, attacktype)) dam_message(dam, ch, victim, attacktype); } else { dam_message(dam, ch, victim, attacktype); } } /* Use send_to_char -- act() doesn't send message if you are DEAD. */ switch (GET_POS(victim)) { case POS_MORTALLYW: act("$n is mortally wounded, and will die soon, if not aided.", TRUE, victim, 0, 0, CommTarget::TO_ROOM); send_to_char(victim, "You are mortally wounded, and will die soon, if not aided.\r\n"); break; case POS_INCAP: act("$n is incapacitated and will slowly die, if not aided.", TRUE, victim, 0, 0, CommTarget::TO_ROOM); send_to_char(victim, "You are incapacitated an will slowly die, if not aided.\r\n"); break; case POS_STUNNED: act("$n is stunned, but will probably regain consciousness again.", TRUE, victim, 0, 0, CommTarget::TO_ROOM); send_to_char(victim, "You're stunned, but will probably regain consciousness again.\r\n"); break; case POS_DEAD: act("$n is dead! R.I.P.", FALSE, victim, 0, 0, CommTarget::TO_ROOM); send_to_char(victim, "You are dead! Sorry...\r\n"); break; default: /* >= POSITION SLEEPING */ if (dam > (GET_MAX_HIT(victim) / 4)) send_to_char(victim, "That really did HURT!\r\n"); if (GET_HIT(victim) < (GET_MAX_HIT(victim) / 4)) { send_to_char(victim, "%sYou wish that your wounds would stop BLEEDING so much!%s\r\n", CCRED(victim, C_SPR), CCNRM(victim, C_SPR)); if (ch != victim && MOB_FLAGGED(victim, MOB_WIMPY)) do_flee(victim, NULL, 0, 0); } if (!IS_NPC(victim) && GET_WIMP_LEV(victim) && (victim != ch) && GET_HIT(victim) < GET_WIMP_LEV(victim) && GET_HIT(victim) > 0) { send_to_char(victim, "You wimp out, and attempt to flee!\r\n"); do_flee(victim, NULL, 0, 0); } break; } /* Help out poor linkless people who are attacked */ if (!IS_NPC(victim) && !(victim->desc) && GET_POS(victim) > POS_STUNNED) { do_flee(victim, NULL, 0, 0); if (!FIGHTING(victim)) { act("$n is rescued by divine forces.", FALSE, victim, 0, 0, CommTarget::TO_ROOM); GET_WAS_IN(victim) = IN_ROOM(victim); char_from_room(victim); char_to_room(victim, 0); } } /* stop someone from fighting if they're stunned or worse */ if (GET_POS(victim) <= POS_STUNNED && FIGHTING(victim) != NULL) stop_fighting(victim); /* Uh oh. Victim died. */ if (GET_POS(victim) == POS_DEAD) { if (ch != victim && (IS_NPC(victim) || victim->desc)) { if (AFF_FLAGGED(ch, AFF_GROUP)) group_gain(ch, victim); else solo_gain(ch, victim); } if (!IS_NPC(victim)) { mudlog(BRF, LVL_IMMORT, TRUE, "%s killed by %s at %s", GET_NAME(victim), GET_NAME(ch), world[IN_ROOM(victim)].name); if (MOB_FLAGGED(ch, MOB_MEMORY)) forget(ch, victim); } die(victim); return (-1); } return (dam); }
void perform_psidrain(struct creature *ch, struct creature *vict) { int find_distance(struct room_data *tmp, struct room_data *location); int dist, drain, prob, percent; if (!can_psidrain(ch, vict, &dist, true)) return; if (AFF3_FLAGGED(vict, AFF3_PSISHIELD) && creature_distrusts(vict, ch)) { prob = CHECK_SKILL(ch, SKILL_PSIDRAIN) + GET_INT(ch); prob += skill_bonus(ch, SKILL_PSIDRAIN); percent = skill_bonus(vict, SPELL_PSISHIELD); percent += number(1, 120); if (mag_savingthrow(vict, GET_LEVEL(ch), SAVING_PSI)) percent *= 2; if (GET_INT(vict) > GET_INT(ch)) percent += (GET_INT(vict) - GET_INT(ch)) * 8; if (percent >= prob) { act("Your attack is deflected by $N's psishield!", false, ch, NULL, vict, TO_CHAR); act("$n's psychic attack is deflected by your psishield!", false, ch, NULL, vict, TO_VICT); act("$n staggers under an unseen force.", true, ch, NULL, vict, TO_NOTVICT); return; } } if (GET_MANA(vict) <= 0) { act("$E is completely drained of psychic energy.", true, ch, NULL, vict, TO_CHAR); return; } drain = dice(GET_LEVEL(ch), GET_INT(ch) + GET_REMORT_GEN(ch)) + CHECK_SKILL(ch, SKILL_PSIDRAIN); if (dist > 0) drain /= dist + 1; drain /= 4; drain = MAX(0, MIN(GET_MANA(vict), drain)); prob = CHECK_SKILL(ch, SKILL_PSIDRAIN) + GET_INT(ch) + (AFF3_FLAGGED(vict, AFF3_PSISHIELD) ? -20 : 0); if (is_fighting(vict)) prob += 15; if (dist > 0) prob -= dist * 3; act("$n strains against an unseen force.", false, ch, NULL, vict, TO_ROOM); // // failure // if (number(0, 121) > prob) { send_to_char(ch, "You are unable to create the drainage link!\r\n"); WAIT_STATE(ch, 2 RL_SEC); if (IS_NPC(vict) && !is_fighting(vict)) { if (ch->in_room == vict->in_room) { add_combat(vict, ch, false); add_combat(ch, vict, true); } else { remember(vict, ch); if (NPC2_FLAGGED(vict, NPC2_HUNT)) start_hunting(vict, ch); } } } // // success // else { act("A torrent of psychic energy is ripped out of $N's mind!", false, ch, NULL, vict, TO_CHAR); if (ch->in_room != vict->in_room && GET_LEVEL(vict) + number(0, CHECK_SKILL(vict, SKILL_PSIDRAIN)) > GET_LEVEL(ch)) act("Your psychic energy is ripped from you from afar!", false, ch, NULL, vict, TO_VICT); else act("Your psychic energy is ripped from you by $n!", false, ch, NULL, vict, TO_VICT); GET_MANA(vict) -= drain; GET_MANA(ch) = MIN(GET_MAX_MANA(ch), GET_MANA(ch) + drain); GET_MOVE(ch) -= 20; WAIT_STATE(vict, 1 RL_SEC); WAIT_STATE(ch, 5 RL_SEC); gain_skill_prof(ch, SKILL_PSIDRAIN); if (IS_NPC(vict) && !(is_fighting(vict))) { if (ch->in_room == vict->in_room) { remember(vict, ch); if (NPC2_FLAGGED(vict, NPC2_HUNT)) start_hunting(vict, ch); add_combat(vict, ch, false); add_combat(ch, vict, true); } } } }
/* * Possible date formats include any combination of: * 3-charmonth (January, Jan, Jan) * 3-charweekday (Friday, Monday, mon.) * numeric month or day (1, 2, 04) * * Any character may separate them, or they may not be separated. Any line, * following a line that is matched, that starts with "whitespace", is shown * along with the matched line. */ int parsedaymonth(char *date, int *yearp, int *monthp, int *dayp, int *flags, char **edp) { char month[100], dayofmonth[100], dayofweek[100], modifieroffset[100]; char syear[100]; char modifierindex[100], specialday[100]; int idayofweek = -1, imonth = -1, idayofmonth = -1, iyear = -1; int year, remindex; int d, m, dow, rm, rd, offset; char *ed; int retvalsign = 1; /* * CONVENTION * * Month: 1-12 * Monthname: Jan .. Dec * Day: 1-31 * Weekday: Mon .. Sun * */ *flags = 0; if (debug) debug_determinestyle(1, date, *flags, month, imonth, dayofmonth, idayofmonth, dayofweek, idayofweek, modifieroffset, modifierindex, specialday, syear, iyear); if (determinestyle(date, flags, month, &imonth, dayofmonth, &idayofmonth, dayofweek, &idayofweek, modifieroffset, modifierindex, specialday, syear, &iyear) == 0) { if (debug) printf("Failed!\n"); return (0); } if (debug) debug_determinestyle(0, date, *flags, month, imonth, dayofmonth, idayofmonth, dayofweek, idayofweek, modifieroffset, modifierindex, specialday, syear, iyear); remindex = 0; for (year = year1; year <= year2; year++) { int lflags = *flags; /* If the year is specified, only do it if it is this year! */ if ((lflags & F_YEAR) != 0) if (iyear != year) continue; lflags &= ~F_YEAR; /* Get important dates for this year */ yearinfo = years; while (yearinfo != NULL) { if (yearinfo->year == year) break; yearinfo = yearinfo -> next; } if (yearinfo == NULL) { yearinfo = (struct yearinfo *)calloc(1, sizeof(struct yearinfo)); if (yearinfo == NULL) errx(1, "Unable to allocate more years"); yearinfo->year = year; yearinfo->next = years; years = yearinfo; yearinfo->monthdays = monthdaytab[isleap(year)]; yearinfo->ieaster = easter(year); yearinfo->ipaskha = paskha(year); fpom(year, UTCOffset, yearinfo->ffullmoon, yearinfo->fnewmoon); fpom(year, UTCOFFSET_CNY, yearinfo->ffullmooncny, yearinfo->fnewmooncny); fequinoxsolstice(year, UTCOffset, yearinfo->equinoxdays, yearinfo->solsticedays); /* * CNY: Match day with sun longitude at 330` with new * moon */ yearinfo->firstcnyday = calculatesunlongitude30(year, UTCOFFSET_CNY, yearinfo->ichinesemonths); for (m = 0; yearinfo->fnewmooncny[m] >= 0; m++) { if (yearinfo->fnewmooncny[m] > yearinfo->firstcnyday) { yearinfo->firstcnyday = floor(yearinfo->fnewmooncny[m - 1]); break; } } } /* Same day every year */ if (lflags == (F_MONTH | F_DAYOFMONTH)) { if (!remember_ymd(year, imonth, idayofmonth)) continue; remember(&remindex, yearp, monthp, dayp, edp, year, imonth, idayofmonth, NULL); continue; } /* XXX Same day every year, but variable */ if (lflags == (F_MONTH | F_DAYOFMONTH | F_VARIABLE)) { if (!remember_ymd(year, imonth, idayofmonth)) continue; remember(&remindex, yearp, monthp, dayp, edp, year, imonth, idayofmonth, NULL); continue; } /* Same day every month */ if (lflags == (F_ALLMONTH | F_DAYOFMONTH)) { for (m = 1; m <= 12; m++) { if (!remember_ymd(year, m, idayofmonth)) continue; remember(&remindex, yearp, monthp, dayp, edp, year, m, idayofmonth, NULL); } continue; } /* Every day of a month */ if (lflags == (F_ALLDAY | F_MONTH)) { for (d = 1; d <= yearinfo->monthdays[imonth]; d++) { if (!remember_ymd(year, imonth, d)) continue; remember(&remindex, yearp, monthp, dayp, edp, year, imonth, d, NULL); } continue; } /* One day of every month */ if (lflags == (F_ALLMONTH | F_DAYOFWEEK)) { for (m = 1; m <= 12; m++) { if (!remember_ymd(year, m, idayofmonth)) continue; remember(&remindex, yearp, monthp, dayp, edp, year, m, idayofmonth, NULL); } continue; } /* Every dayofweek of the year */ if (lflags == (F_DAYOFWEEK | F_VARIABLE)) { dow = first_dayofweek_of_year(year); d = (idayofweek - dow + 8) % 7; while (d <= 366) { if (remember_yd(year, d, &rm, &rd)) remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, NULL); d += 7; } continue; } /* * Every so-manied dayofweek of every month of the year: * Thu-3 */ if (lflags == (F_DAYOFWEEK | F_MODIFIERINDEX | F_VARIABLE)) { offset = indextooffset(modifierindex); for (m = 0; m <= 12; m++) { d = wdayom (idayofweek, offset, m, year); if (remember_ymd(year, m, d)) { remember(&remindex, yearp, monthp, dayp, edp, year, m, d, NULL); continue; } } continue; } /* * A certain dayofweek of a month * Jan/Thu-3 */ if (lflags == (F_MONTH | F_DAYOFWEEK | F_MODIFIERINDEX | F_VARIABLE)) { offset = indextooffset(modifierindex); dow = first_dayofweek_of_month(year, imonth); d = (idayofweek - dow + 8) % 7; if (offset > 0) { while (d <= yearinfo->monthdays[imonth]) { if (--offset == 0 && remember_ymd(year, imonth, d)) { remember(&remindex, yearp, monthp, dayp, edp, year, imonth, d, NULL); continue; } d += 7; } continue; } if (offset < 0) { while (d <= yearinfo->monthdays[imonth]) d += 7; while (offset != 0) { offset++; d -= 7; } if (remember_ymd(year, imonth, d)) remember(&remindex, yearp, monthp, dayp, edp, year, imonth, d, NULL); continue; } continue; } /* Every dayofweek of the month */ if (lflags == (F_DAYOFWEEK | F_MONTH | F_VARIABLE)) { dow = first_dayofweek_of_month(year, imonth); d = (idayofweek - dow + 8) % 7; while (d <= yearinfo->monthdays[imonth]) { if (remember_ymd(year, imonth, d)) remember(&remindex, yearp, monthp, dayp, edp, year, imonth, d, NULL); d += 7; } continue; } /* Easter */ if ((lflags & ~F_MODIFIEROFFSET) == (F_SPECIALDAY | F_VARIABLE | F_EASTER)) { offset = 0; if ((lflags & F_MODIFIEROFFSET) != 0) offset = parseoffset(modifieroffset); if (remember_yd(year, yearinfo->ieaster + offset, &rm, &rd)) remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, NULL); continue; } /* Paskha */ if ((lflags & ~F_MODIFIEROFFSET) == (F_SPECIALDAY | F_VARIABLE | F_PASKHA)) { offset = 0; if ((lflags & F_MODIFIEROFFSET) != 0) offset = parseoffset(modifieroffset); if (remember_yd(year, yearinfo->ipaskha + offset, &rm, &rd)) remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, NULL); continue; } /* Chinese New Year */ if ((lflags & ~F_MODIFIEROFFSET) == (F_SPECIALDAY | F_VARIABLE | F_CNY)) { offset = 0; if ((lflags & F_MODIFIEROFFSET) != 0) offset = parseoffset(modifieroffset); if (remember_yd(year, yearinfo->firstcnyday + offset, &rm, &rd)) remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, NULL); continue; } /* FullMoon */ if ((lflags & ~F_MODIFIEROFFSET) == (F_SPECIALDAY | F_VARIABLE | F_FULLMOON)) { int i; offset = 0; if ((lflags & F_MODIFIEROFFSET) != 0) offset = parseoffset(modifieroffset); for (i = 0; yearinfo->ffullmoon[i] > 0; i++) { if (remember_yd(year, floor(yearinfo->ffullmoon[i]) + offset, &rm, &rd)) { ed = floattotime( yearinfo->ffullmoon[i]); remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, ed); } } continue; } /* NewMoon */ if ((lflags & ~F_MODIFIEROFFSET) == (F_SPECIALDAY | F_VARIABLE | F_NEWMOON)) { int i; offset = 0; if ((lflags & F_MODIFIEROFFSET) != 0) offset = parseoffset(modifieroffset); for (i = 0; yearinfo->ffullmoon[i] > 0; i++) { if (remember_yd(year, floor(yearinfo->fnewmoon[i]) + offset, &rm, &rd)) { ed = floattotime(yearinfo->fnewmoon[i]); remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, ed); } } continue; } /* (Mar|Sep)Equinox */ if ((lflags & ~F_MODIFIEROFFSET) == (F_SPECIALDAY | F_VARIABLE | F_MAREQUINOX)) { offset = 0; if ((lflags & F_MODIFIEROFFSET) != 0) offset = parseoffset(modifieroffset); if (remember_yd(year, yearinfo->equinoxdays[0] + offset, &rm, &rd)) { ed = floattotime(yearinfo->equinoxdays[0]); remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, ed); } continue; } if ((lflags & ~F_MODIFIEROFFSET) == (F_SPECIALDAY | F_VARIABLE | F_SEPEQUINOX)) { offset = 0; if ((lflags & F_MODIFIEROFFSET) != 0) offset = parseoffset(modifieroffset); if (remember_yd(year, yearinfo->equinoxdays[1] + offset, &rm, &rd)) { ed = floattotime(yearinfo->equinoxdays[1]); remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, ed); } continue; } /* (Jun|Dec)Solstice */ if ((lflags & ~F_MODIFIEROFFSET) == (F_SPECIALDAY | F_VARIABLE | F_JUNSOLSTICE)) { offset = 0; if ((lflags & F_MODIFIEROFFSET) != 0) offset = parseoffset(modifieroffset); if (remember_yd(year, yearinfo->solsticedays[0] + offset, &rm, &rd)) { ed = floattotime(yearinfo->solsticedays[0]); remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, ed); } continue; } if ((lflags & ~F_MODIFIEROFFSET) == (F_SPECIALDAY | F_VARIABLE | F_DECSOLSTICE)) { offset = 0; if ((lflags & F_MODIFIEROFFSET) != 0) offset = parseoffset(modifieroffset); if (remember_yd(year, yearinfo->solsticedays[1] + offset, &rm, &rd)) { ed = floattotime(yearinfo->solsticedays[1]); remember(&remindex, yearp, monthp, dayp, edp, year, rm, rd, ed); } continue; } if (debug) { printf("Unprocessed:\n"); debug_determinestyle(2, date, lflags, month, imonth, dayofmonth, idayofmonth, dayofweek, idayofweek, modifieroffset, modifierindex, specialday, syear, iyear); } retvalsign = -1; } if (retvalsign == -1) return (-remindex - 1); else return (remindex); }