int response(UOXSOCKET s, P_CHAR pPlayer, char* SpeechUpr) { char *comm=SpeechUpr; if (strstr( comm, "#EMPTY") && online(currchar[s]) && !pPlayer->dead && pPlayer->isGM()) { // restricted to GMs for now. It's too powerful (Duke, 5.6.2001) target(s, 0, 1, 0, 71, "Select container to empty:"); return 1; } if (!online(DEREF_P_CHAR(pPlayer)) || pPlayer->dead) return 0; P_CHAR pc; cRegion::RegionIterator4Chars ri(pPlayer->pos); for (ri.Begin(); (pc=ri.GetData()) != ri.End(); ri++) { if (pc->isPlayer()) // only npcs will respond automagically, players still have to do that themselves ;) continue; if (pPlayer->dist(pc) > 16) // at least they should be on the screen continue; if (pPlayer->isSameAs(pc)) // not talking to ourselves continue; if (StableSpeech(pc, comm, pPlayer, s)) return 1; if (UnStableSpeech(pc, comm, pPlayer, s)) return 1; if (ShieldSpeech(pc, comm, pPlayer, s)) return 1; if (QuestionSpeech(pc, comm, pPlayer, s)) return 1; if (PackupSpeech(pc, comm, pPlayer, s)) return 1; if (TriggerSpeech(pc, comm, pPlayer, s)) return 1; if (EscortSpeech(pc, comm, pPlayer, s)) return 1; if (BankerSpeech(pc, comm, pPlayer, s)) return 1; if (TrainerSpeech(pc, comm, pPlayer, s)) return 1; if (PetCommand(pc, comm, pPlayer, s)) return 1; if (VendorSpeech(pc, comm, pPlayer, s)) return 1; } return 0; }
void SystemMonitor::initialize() { d = new SystemMonitorPrivate(this); QAbstractEventDispatcher::instance()->installNativeEventFilter(d); connect(&d->network, SIGNAL(online()), this, SIGNAL(online())); connect(&d->network, SIGNAL(offline()), this, SIGNAL(offline())); connect(&d->screen, SIGNAL(screenLocked()), this, SIGNAL(screenLocked())); connect(&d->screen, SIGNAL(screenUnlocked()), this, SIGNAL(screenUnlocked())); connect(&d->screen, SIGNAL(screenSaverStarted()), this, SIGNAL(screenSaverStarted())); connect(&d->screen, SIGNAL(screenSaverStopped()), this, SIGNAL(screenSaverStopped())); }
bool can_see(dbref player, dbref thing, bool can_see_loc) { if (!OkObj(player) || !OkObj(thing)) return 0; if (player == thing || Typeof(thing) == TYPE_EXIT || Typeof(thing) == TYPE_ROOM) return 0; if (Light(thing)) return 1; if (can_see_loc) { switch (Typeof(thing)) { case TYPE_PROGRAM: return ((FLAGS(thing) & LINK_OK) || controls(player, thing) || (POWERS(player) & POW_SEE_ALL)); case TYPE_PLAYER: if (tp_dark_sleepers) { return (!Dark(thing) || online(thing) || (POWERS(player) & POW_SEE_ALL)); } default: return (!Dark(thing) || (POWERS(player) & POW_SEE_ALL) || (controls(player, thing) && !(FLAGS(player) & STICKY))); } } else { /* can't see loc */ return (controls(player, thing) && !(FLAGS(player) & STICKY)); } }
void TorProtocolManager::setState(ProtocolManager::State state) { const auto old = state_; state_ = state; if (old != state_) { LFLOG_DEBUG << "TorProtocolManager changing state from " << getName(old) << " to " << getName(state); emit stateChanged(old, state_); switch(state) { case ProtocolManager::State::OFFLINE: emit offline(); break; case ProtocolManager::State::CONNECTING: emit connecting(); break; case ProtocolManager::State::CONNECTED: emit connected(); break; case ProtocolManager::State::ONLINE: emit online(); break; case ProtocolManager::State::SHUTTINGDOWN: emit shutdown(); break; } } }
PrivateTab::PrivateTab(ClientChannel channel, TabWidget *parent) : ChannelBaseTab(channel, LS("talk"), parent) { QVBoxLayout *mainLay = new QVBoxLayout(this); mainLay->addWidget(m_chatView); mainLay->setMargin(0); mainLay->setSpacing(0); setText(channel->name()); ChatClient::channels()->join(id()); connect(ChatClient::channels(), SIGNAL(channel(ChannelInfo)), SLOT(channel(ChannelInfo))); connect(ChatClient::channels(), SIGNAL(quit(QByteArray)), SLOT(quit(QByteArray))); connect(ChatClient::i(), SIGNAL(online()), SLOT(online())); }
/* check if line ab intersectes with segment cd*/ int check(pt_t a, pt_t b, pt_t c, pt_t d) { double tx, ty; intersec(a, b, c, d, &tx, &ty); if(online(a, b, c, d)) return 0; if(onpara(a, b, c, d)) return 0; if(dcmp(ty - d.y) >= 0 && dcmp(c.y - ty) >= 0) return 1; return 0; }
// Reset text formatting parameters. void Adafruit_Thermal::setDefault(){ online(); justify('L'); inverseOff(); doubleHeightOff(); setLineHeight(32); boldOff(); underlineOff(); setBarcodeHeight(50); setSize('s'); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), chat(new ChatEngine(this)), logWindow(new QTextEdit(this)), audio(new QMediaPlayer(this)), settings(new Settings(this)) { ui->setupUi(this); setWindowTitle(QApplication::applicationName()); readSettings(); audio->setMedia(QMediaContent(QUrl::fromLocalFile("C:/Users/fAg1r/Documents/qt-projects/ChatVdvoem/sounds/stranger.mp3"))); connect(chat, SIGNAL(newMessage(QString,bool)), SLOT(receiveMessage(QString,bool))); connect(chat, SIGNAL(startedTyping()), SLOT(startedTyping())); connect(chat, SIGNAL(chatStarted()), SLOT(chatStarted())); connect(chat, SIGNAL(chatStopped()), SLOT(chatStopped())); connect(chat, SIGNAL(newLog(QString)), SLOT(newLog(QString))); connect(ui->exitAction, SIGNAL(triggered()), SLOT(close())); connect(ui->settingsAction, SIGNAL(triggered()), settings, SLOT(show())); connect(ui->startAction, SIGNAL(triggered()), chat, SLOT(startChat())); connect(ui->stopAction, SIGNAL(triggered()), chat, SLOT(stopChatRequest())); logWindow->setWindowFlags(Qt::Window); if (settings->showLog()) logWindow->show(); ui->lineEdit->setEnabled(false); ui->textEdit->setPlaceholderText("Здесь будет бесполезный трёп"); addAnswerForMessage(QStringList() << "прив" << "дарова" << "хай" << "хэй" << "здравствуй" << "ку" << "мж" << "м или ж" << "м ж" << "м/ж" << "здрасьте" << "добрый" << "=ага" << "и тебе", "я парень, мне 23"); addAnswerForMessage(QStringList() << "девушка" << "девка" << "=ж" << "девочка" << "женщина" << "я ж" << "я нет" << "баба" << "тян", "Хочешь фоточку моего выбритого члена?))"); addAnswerForMessage(QStringList() << "как звать" << "как зовут" << "ж?" << "девушка?" << "я парень" << "транс" << "=м" << "=я м" << "мужик" << "=и я" << "и че" << "и что" << "гей" << "тоже" << "я тож" << "бывает" << "прикольно" << "круто" << "молодец" << "поздравляю" << "иди на" << "пошел на" << "иди в" << "нет" << "=не" << "=неа" << "=и?" << "похуй", "<disconnect>"); for (quint8 i = 0; i < 5; ++i) { QAction *action = new QAction(ui->lineEdit); ui->lineEdit->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + 0x31 + i)); connect(action, SIGNAL(triggered()), SLOT(hotAnswer())); hotAnswerActions << action; } QLabel *l = new QLabel(this); connect(chat, SIGNAL(online(QString)), l, SLOT(setText(QString))); ui->statusBar->addPermanentWidget(l); }
MojErr ActivityManagerApp::ready() { LOG_AM_DEBUG("%s ready to accept incoming requests", name().data()); /* All stored Activities have been deserialized from the database. All * previously persisted Activity IDs are marked as used. It's safe to * accept requests. Bring up the Service side interface! */ MojErr err = online(); MojErrCheck(err); /* Activity Manager prepared to accept requests at this point, but not * to allow Activities to move into the scheduled state where their * outcalls are made. */ #ifndef WEBOS_TARGET_MACHINE_IMPL_SIMULATOR /* Engage the Luna Bus Proxy, start mapping services */ m_busProxy->Enable(); #endif /* Start up the various requirement management proxy connections now, * so they don't start a storm of requests once the UI is up. */ m_requirementManager->Enable(); /* Subscribe to timezone notifications. */ m_scheduler->Enable(); #if !defined(WEBOS_TARGET_MACHINE_IMPL_SIMULATOR) char *upstart_job = getenv("UPSTART_JOB"); if (upstart_job) { char *upstart_event = g_strdup_printf("/sbin/initctl emit %s-ready", upstart_job); if (upstart_event) { int retVal = ::system(upstart_event); if (retVal == -1) { LOG_AM_ERROR(MSGID_UPSTART_EMIT_FAIL,0, "ServiceApp: Failed to emit upstart event"); } g_free(upstart_event); } else { LOG_AM_ERROR(MSGID_UPSTART_EMIT_ALLOC_FAIL,0, "ServiceApp: Failed to allocate memory for upstart emit"); } } #endif #if defined(WEBOS_TARGET_MACHINE_IMPL_SIMULATOR) /* SystemManagerProxy not instantiated, so mark the UI as enabled */ m_am->Enable(ActivityManager::UI_ENABLE); #endif return MojErrNone; }
// TESTED: OKAY // Uhm.. do i need char or socket for sysmessage? hehe.. a socket ofcourse, FiXED iT! // guildbroadcast(guildnumber, text) broadcasts message to all online members of guild void cGuildStone::Broadcast(char *text) { unsigned int i; for (i = 0; i < member.size(); ++i) { P_CHAR pc = FindCharBySerial( member[i] ); if ( pc == NULL ) continue; if ( online( pc ) ) sysmessage( calcSocketFromChar( pc ), text); } }
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override { char subcmd = toupper(parameters[0][0]); if (subcmd == '+') { if (parameters.size() > 1) HandlePlus(user, parameters[1]); } else if (subcmd == '-') { if (parameters.size() > 1) HandleMinus(user, parameters[1]); } else if (subcmd == 'C') { manager.UnwatchAll(user); } else if (subcmd == 'L') { user->CommandFloodPenalty += ListPenalty; const IRCv3::Monitor::WatchedList& list = manager.GetWatched(user); ReplyBuilder out(user, RPL_MONLIST); for (IRCv3::Monitor::WatchedList::const_iterator i = list.begin(); i != list.end(); ++i) { IRCv3::Monitor::Entry* entry = *i; out.Add(entry->GetNick()); } out.Flush(); user->WriteNumeric(RPL_ENDOFMONLIST, "End of MONITOR list"); } else if (subcmd == 'S') { user->CommandFloodPenalty += ListPenalty; ReplyBuilder online(user, RPL_MONONLINE); ReplyBuilder offline(user, RPL_MONOFFLINE); const IRCv3::Monitor::WatchedList& list = manager.GetWatched(user); for (IRCv3::Monitor::WatchedList::const_iterator i = list.begin(); i != list.end(); ++i) { IRCv3::Monitor::Entry* entry = *i; ReplyBuilder& out = (IRCv3::Monitor::Manager::FindNick(entry->GetNick()) ? online : offline); out.Add(entry->GetNick()); } online.Flush(); offline.Flush(); } else return CMD_FAILURE; return CMD_SUCCESS; }
//ON-OFF制御ライントレース関数 void RA_linetrace(int forward_speed, int turn_speed) { cmd_forward = forward_speed; int light_value = 0; light_value = online(); if (TRUE != light_value) { cmd_turn = (-1)*turn_speed; } else { cmd_turn = turn_speed; } }
/*detect whether lines l and m intersect */ void find_intersection(struct vertex *l, struct vertex *m, struct intersection ilist[], struct data *input) { float x, y; int i[3]; sgnarea(l, m, i); if (i[2] > 0) return; if (i[2] < 0) { sgnarea(m, l, i); if (i[2] > 0) return; if (!intpoint (l, m, &x, &y, (i[2] < 0) ? 3 : online(m, l, ABS(i[0])))) return; } else if (!intpoint(l, m, &x, &y, (i[0] == i[1]) ? 2 * MAX(online(l, m, 0), online(l, m, 1)) : online(l, m, ABS(i[0])))) return; if (input->ninters >= MAXINTS) { fprintf(stderr, "\n**ERROR**\n using too many intersections\n"); exit(1); } ilist[input->ninters].firstv = l; ilist[input->ninters].secondv = m; ilist[input->ninters].firstp = l->poly; ilist[input->ninters].secondp = m->poly; ilist[input->ninters].x = x; ilist[input->ninters].y = y; input->ninters++; }
//----------------------------------------------------------------------------- void ResourceManager::bring_loaded_online() { m_loaded_mutex.lock(); while (m_loaded_queue.size() > 0) { LoadedResource lr = m_loaded_queue.front(); m_loaded_queue.pop_front(); online(lr.resource, lr.data); } m_loaded_mutex.unlock(); }
void prim_awakep(PRIM_PROTOTYPE) { CHECKOP(1); oper1 = POP(); if (!valid_object(oper1)) abort_interp("invalid argument"); ref = oper1->data.objref; if (Typeof(ref) == TYPE_THING && (FLAGS(ref) & ZOMBIE)) ref = OWNER(ref); if (Typeof(ref) != TYPE_PLAYER) abort_interp("invalid argument"); result = online(ref); PushInt(result); }
//ON-OFF制御ライントレース関数 void RA_linetrace(int forward_speed, int turn_speed) { cmd_forward = forward_speed; int light_value = 0; light_value = online(); if (TRUE != light_value) { cmd_turn = turn_speed; } else { cmd_turn = (-1)*turn_speed; } nxt_motor_set_speed(NXT_PORT_C, forward_speed - cmd_turn/2, 1); nxt_motor_set_speed(NXT_PORT_B, forward_speed + cmd_turn/2, 1); }
void ChatClient::clientStateChanged(int state, int previousState) { if (previousState == Online) emit offline(); if (state == Online) { if (!m_id.isEmpty() && m_id != serverId()) { server()->data().clear(); server()->feeds().clear(); channel()->data().clear(); channel()->feeds().clear(); } m_id = serverId(); emit online(); } }
const char * mfn_awake(MFUNARGS) { dbref obj = mesg_dbref_local(player, what, perms, argv[0]); if (obj == PERMDENIED || obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME) return("0"); if (Typeof(obj) == TYPE_THING && (FLAGS(obj) & ZOMBIE)) { obj = OWNER(obj); } else if (Typeof(obj) != TYPE_PLAYER) { return("0"); } sprintf(buf, "%d", online(obj)); return(buf); }
static int message(int sd, struct packet_st *pkt_r, int recv_len, struct sockaddr_in *hisend) { uint32_t dest; struct database_record_st *record; debug("call %s()\n", __func__); dest = ntohl(pkt_r->msg.dest); record = database_find(dest); if (record == NULL) { return -1; } if (!online(record)) { return -1; } return sendto(sd, pkt_r, recv_len, 0, (struct sockaddr *)&record->addr, sizeof(record->addr)); }
void cCharStuff::cDragonAI::DoAI(P_CHAR pc_i, int currenttime) { int randvalue; int distance; if ( pc_i == NULL ) return; if (pc_i->war) { npctalkall(pc_i, "Who dares disturbe me?!?!", 1); cRegion::RegionIterator4Chars ri(pc_i->pos); for (ri.Begin(); !ri.atEnd(); ri++) { P_CHAR pc = ri.GetData(); if (pc != NULL) { distance = chardist(pc_i, pc); if (!pc->npc && !online(pc)) // no offline players (Duke) continue; if (!(pc->dead)) { if (distance>4) { randvalue = RandomNum(0, 4); switch (randvalue) { case 1: Breath(pc_i, currenttime); break; case 3: HarmMagic(pc_i, currenttime, pc); break; case 4: HealMagic(pc_i, currenttime); break; } } else HarmMagic(pc_i, currenttime, pc); } HealMagic(pc_i, currenttime); } } } else HealMagic(pc_i, currenttime); return; }
int main(int argc, char **argv) { TString type="default"; UInt_t run=0; Bool_t printonly=kFALSE; Bool_t showedUsage=kFALSE; TApplication theApp("App",&argc,argv,NULL,-1); for(Int_t i=1;i<theApp.Argc();i++) { TString sArg = theApp.Argv(i); if(sArg=="-f") { type = theApp.Argv(++i); cout << " File specifier: " << type << endl; } else if (sArg=="-r") { run = atoi(theApp.Argv(++i)); cout << " Runnumber: " << run << endl; } else if (sArg=="-P") { printonly = kTRUE; cout << " PrintOnly" << endl; } else if (sArg=="-h") { if(!showedUsage) Usage(); showedUsage=kTRUE; return 0; } else { cerr << "\"" << sArg << "\"" << " not recognized. Ignored." << endl; if(!showedUsage) Usage(); showedUsage=kTRUE; } } online(type,run,printonly); theApp.Run(); return 0; }
// Tries to equip an item // if that fails it tries to put the item in the users backpack // if *that* fails it puts it at the characters feet // That works for NPCs as well void equipItem( P_CHAR wearer, P_ITEM item ) { tile_st tile; Map->SeekTile( item->id(), &tile ); // User cannot wear the item if( tile.layer == 0 ) { if( online( wearer ) ) sysmessage( calcSocketFromChar( wearer ), "You cannot wear that item." ); item->toBackpack( wearer ); return; } vector< SERIAL > equipment = contsp.getData( wearer->serial ); // If n item on the same layer is already equipped, unequip it for( UI08 i = 0; i < equipment.size(); i++ ) { P_ITEM equip = FindItemBySerial( equipment[ i ] ); // Unequip the item and free the layer that way if( equip && ( equip->layer() == tile.layer ) ) equip->toBackpack( wearer ); wearer->removeItemBonus( equip ); } // *finally* equip the item item->setContSerial( wearer->serial ); // Add the item bonuses wearer->st = (wearer->st + item->st2); wearer->chgDex( item->dx2 ); wearer->in = (wearer->in + item->in2); }
void Endpoint::start(CallerContext &c) { assert(online()); // Can't do anything with a closed socket! assert(protocol && session); // Can't do anything without either! /* * Disable Nagles algorithm (no_delay) when setting our own buffer sizes */ socket().set_option(boost::asio::ip::tcp::no_delay(true)); socket().set_option(boost::asio::socket_base::keep_alive(true)); socket().set_option(boost::asio::socket_base::send_buffer_size(NBS)); socket().set_option(boost::asio::socket_base::receive_buffer_size(NBS)); local.port = socket().local_endpoint().port(); local.ip = socket().local_endpoint().address().to_string(); remote.port = socket().remote_endpoint().port(); remote.ip = socket().remote_endpoint().address().to_string(); session->start(c); // Call first to prepare session/context before transfers protocol->start(); }
void HandlePlus(LocalUser* user, const std::string& input) { ReplyBuilder online(user, RPL_MONONLINE); ReplyBuilder offline(user, RPL_MONOFFLINE); irc::commasepstream ss(input); for (std::string nick; ss.GetToken(nick); ) { IRCv3::Monitor::Manager::WatchResult result = manager.Watch(user, nick, maxmonitor); if (result == IRCv3::Monitor::Manager::WR_TOOMANY) { // List is full, send error which includes the remaining nicks that were not processed user->WriteNumeric(ERR_MONLISTFULL, maxmonitor, InspIRCd::Format("%s%s%s", nick.c_str(), (ss.StreamEnd() ? "" : ","), ss.GetRemaining().c_str()), "Monitor list is full"); break; } else if (result != IRCv3::Monitor::Manager::WR_OK) continue; // Already added or invalid nick ReplyBuilder& out = (IRCv3::Monitor::Manager::FindNick(nick) ? online : offline); out.Add(nick); } online.Flush(); offline.Flush(); }
struct frame * interp(int descr, dbref player, dbref location, dbref program, dbref source, int nosleeps, int whichperms, int forced_pid) { struct frame *fr; int i; if (!MLevel(program) || !MLevel(OWNER(program)) || ((source != NOTHING) && !TrueWizard(OWNER(source)) && !can_link_to(OWNER(source), TYPE_EXIT, program))) { notify_nolisten(player, "Program call: Permission denied.", 1); return 0; } if (free_frames_list) { fr = free_frames_list; free_frames_list = fr->next; } else { fr = (struct frame *) malloc(sizeof(struct frame)); } fr->next = NULL; fr->pid = forced_pid ? forced_pid : top_pid++; fr->descr = descr; fr->multitask = nosleeps; fr->perms = whichperms; fr->already_created = 0; fr->been_background = (nosleeps == 2); fr->trig = source; fr->events = NULL; fr->timercount = 0; fr->started = time(NULL); fr->instcnt = 0; fr->skip_declare = 0; fr->wantsblanks = 0; fr->caller.top = 1; fr->caller.st[0] = source; fr->caller.st[1] = program; fr->system.top = 1; fr->system.st[0].progref = 0; fr->system.st[0].offset = 0; fr->waitees = NULL; fr->waiters = NULL; fr->fors.top = 0; fr->fors.st = NULL; fr->trys.top = 0; fr->trys.st = NULL; fr->errorstr = NULL; fr->errorinst = NULL; fr->errorprog = NOTHING; fr->errorline = 0; fr->rndbuf = NULL; fr->dlogids = NULL; fr->argument.top = 0; fr->pc = PROGRAM_START(program); fr->writeonly = ((source == -1) || (Typeof(source) == TYPE_ROOM) || ((Typeof(source) == TYPE_PLAYER) && (!online(source))) || (FLAGS(player) & READMODE)); fr->level = 0; fr->error.is_flags = 0; /* set basic local variables */ fr->svars = NULL; fr->lvars = NULL; for (i = 0; i < MAX_VAR; i++) { fr->variables[i].type = PROG_INTEGER; fr->variables[i].data.number = 0; } fr->brkpt.force_debugging = 0; fr->brkpt.debugging = 0; fr->brkpt.bypass = 0; fr->brkpt.isread = 0; fr->brkpt.showstack = 0; fr->brkpt.dosyspop = 0; fr->brkpt.lastline = 0; fr->brkpt.lastpc = 0; fr->brkpt.lastlisted = 0; fr->brkpt.lastcmd = NULL; fr->brkpt.breaknum = -1; fr->brkpt.lastproglisted = NOTHING; fr->brkpt.proglines = NULL; fr->brkpt.count = 1; fr->brkpt.temp[0] = 1; fr->brkpt.level[0] = -1; fr->brkpt.line[0] = -1; fr->brkpt.linecount[0] = -2; fr->brkpt.pc[0] = NULL; fr->brkpt.pccount[0] = -2; fr->brkpt.prog[0] = program; fr->proftime.tv_sec = 0; fr->proftime.tv_usec = 0; fr->totaltime.tv_sec = 0; fr->totaltime.tv_usec = 0; fr->variables[0].type = PROG_OBJECT; fr->variables[0].data.objref = player; fr->variables[1].type = PROG_OBJECT; fr->variables[1].data.objref = location; fr->variables[2].type = PROG_OBJECT; fr->variables[2].data.objref = source; fr->variables[3].type = PROG_STRING; fr->variables[3].data.string = (!*match_cmdname) ? 0 : alloc_prog_string(match_cmdname); if (PROGRAM_CODE(program)) { PROGRAM_INC_PROF_USES(program); } PROGRAM_INC_INSTANCES(program); push(fr->argument.st, &(fr->argument.top), PROG_STRING, *match_args ? MIPSCAST alloc_prog_string(match_args) : 0); return fr; }
void Slave::startup() { registerBuiltinBurners(); loadEmbeddedPython(); LOG_5( "Slave::startup()" ); mHost = Host::currentHost(); mSpooler = new Spooler( this ); if( !mHost.isRecord() ) { if( mAutoRegister ) { LOG_3( "Slave::startup: no host record, auto-registering" ); mHost = Host::autoRegister(); } else { LOG_3( "Slave::startup: no host record, uh oh!" ); exit(-1); } } else mHost.updateHardwareInfo(); mHostStatus = mHost.hostStatus(); if( !mHostStatus.isRecord() ) { if( mAutoRegister ) { LOG_3( "Slave::startup: No host status record(are all your triggers installed?), creating one" ); mHostStatus.setHost( mHost ); mHostStatus.setOnline( 1 ); } else { LOG_3( "Slave::startup: no host status record, uh oh!" ); exit(-1); } } mHostStatus.setAvailableMemory( mHost.memory() ); mHostStatus.commit(); connect( Database::current()->connection(), SIGNAL( connectionLost() ), SLOT( slotConnectionLost() ) ); connect( Database::current()->connection(), SIGNAL( connected() ), SLOT( slotConnected() ) ); // The rest of the initialization is only for normal mode where we moniter and manipulate // the hosts status. In burn only mode we simply execute a job and exit if( mBurnOnlyJobAssignmentKey ) { burn( JobAssignment(mBurnOnlyJobAssignmentKey) ); return; } mService = Service::ensureServiceExists("Assburner"); // Start remote log server and set port in our Assburner HostService record RemoteLogServer * rls = new RemoteLogServer(); HostService hs = HostService::recordByHostAndService( mHost, mService ); if( hs.isRecord() && rls->tcpServer()->isListening() ) { hs.setRemoteLogPort( rls->tcpServer()->serverPort() ); hs.commit(); } // Set host version string. mHost.setAbVersion( "v" + QString(VERSION)); mHost.commit(); // Reset any frame assignments and set our host status // to ready. Do we need this anymore? The reaper // should now detect and re-assign frames if we are // offline, and this prevents a client-update from // happening when assburner starts. // // Nope, this doesn't f**k with the status, so it is // safe. It just clears fkeyJob to slaveFrames. And // returns any frames that have fkeyHost=this mHostStatus.returnSlaveFrames(); loadForbiddenProcesses(); mTimer = new QTimer( this ); connect( mTimer, SIGNAL( timeout() ), SLOT( loop() ) ); // Default 5000ms, min 200ms, max 600,000ms - 10 minutes mLoopTime = qMax( 200, qMin( 1000 * 60 * 10, Config::getInt( "assburnerLoopTime", 5000 ) ) ); // Default mLoopTime / 2, min 100ms, max mLoopTime mQuickLoopTime = qMax( 100, qMin( mLoopTime, Config::getInt( "assburnerQuickLoopTime", mLoopTime / 2 ) ) ); // Default 60 seconds, min 10 seconds. mPulsePeriod = qMax( 10, Config::getInt( "arsenalPulsePeriod", 600 ) ); // Default 60 seconds, min 10 seconds. mMemCheckPeriod = qMax( 10, Config::getInt( "abMemCheckPeriod", 60 ) ); IniConfig & c = config(); c.pushSection( "BackgroundMode" ); mBackgroundModeEnabled = c.readBool( "Enabled", true ); c.popSection(); // Pulse right away. pulse(); // We need to set our host status to offline when assburner quits connect( qApp, SIGNAL( aboutToQuit() ), SLOT( offlineFromAboutToQuit() ) ); if( mUseGui ) { mIdle = new Idle(); connect( mIdle, SIGNAL( secondsIdle( int ) ), SLOT( slotSecondsIdle( int ) ) ); mIdle->start(); } if( mHostStatus.slaveStatus() == "client-update-offline" ) offline(); else if( mHostStatus.slaveStatus() == "client-update" ) clientUpdate(); else { // Store the current status QString currentStatus = mHostStatus.slaveStatus(); // We run the host through the online method first online(); // Check if the old host status wasn't empty if( !currentStatus.isEmpty() ) { // Resume the state the host was in. LOG_3("Slave::startup() Resuming previous status of " + currentStatus); handleStatusChange(currentStatus, ""); } } // Create a timer for logged in user checks mUserTimer = new QTimer( this ); connect( mUserTimer, SIGNAL( timeout() ), SLOT( updateLoggedUsers() ) ); // Set it to trigger every 5 mins mUserTimer->start(300000); LOG_5( "Slave::startup() done" ); }
/* determine point of detected intersections */ static int intpoint(struct vertex *l, struct vertex *m, float *x, float *y, int cond) { struct position ls, le, ms, me, pt1, pt2; float m1, m2, c1, c2; if (cond <= 0) return (0); ls = l->pos; le = after(l)->pos; ms = m->pos; me = after(m)->pos; switch (cond) { case 3: /* a simple intersection */ if (ls.x == le.x) { *x = ls.x; *y = me.y + SLOPE(ms, me) * (*x - me.x); } else if (ms.x == me.x) { *x = ms.x; *y = le.y + SLOPE(ls, le) * (*x - le.x); } else { m1 = SLOPE(ms, me); m2 = SLOPE(ls, le); c1 = ms.y - (m1 * ms.x); c2 = ls.y - (m2 * ls.x); *x = (c2 - c1) / (m1 - m2); *y = ((m1 * c2) - (c1 * m2)) / (m1 - m2); } break; case 2: /* the two lines have a common segment */ if (online(l, m, 0) == -1) { /* ms between ls and le */ pt1 = ms; pt2 = (online(m, l, 1) == -1) ? ((online(m, l, 0) == -1) ? le : ls) : me; } else if (online(l, m, 1) == -1) { /* me between ls and le */ pt1 = me; pt2 = (online(l, m, 0) == -1) ? ((online(m, l, 0) == -1) ? le : ls) : ms; } else { /* may be degenerate? */ if (online(m, l, 0) != -1) return 0; pt1 = ls; pt2 = le; } *x = (pt1.x + pt2.x) / 2; *y = (pt1.y + pt2.y) / 2; break; case 1: /* a vertex of line m is on line l */ if ((ls.x - le.x) * (ms.y - ls.y) == (ls.y - le.y) * (ms.x - ls.x)) { *x = ms.x; *y = ms.y; } else { *x = me.x; *y = me.y; } } /* end switch */ return (1); }
/* Return number of acceptable neighbour positions */ int mfndpos(struct monst *mon, coord poss[9], int info[9], int flag) { int x; int y; int nx; int ny; int cnt = 0; int tmp; struct monst *mtmp; x = mon->mx; y = mon->my; if(mon->mconf != 0) { flag |= ALLOW_ALL; flag &= ~NOTONL; } for(nx = x - 1; nx <= x + 1; ++nx) { for(ny = y - 1; ny <= y + 1; ++ny) { if((nx != x) || (ny != y)) { if(isok(nx, ny) != 0) { tmp = levl[nx][ny].typ; if(tmp >= DOOR) { if((nx == x) || (ny == y) || ((levl[x][y].typ != DOOR) && (tmp != DOOR))) { info[cnt] = 0; if((nx == u.ux) && (ny == u.uy)) { if((flag & ALLOW_U) == 0) { continue; } info[cnt] = ALLOW_U; } else { mtmp = m_at(nx, ny); if(mtmp != 0) { if((flag & ALLOW_M) == 0) { continue; } info[cnt] = ALLOW_M; } if(mtmp->mtame != 0) { if((flag & ALLOW_TM) == 0) { continue; } info[cnt] |= ALLOW_TM; } } if(sobj_at(CLOVE_OF_GARLIC, nx, ny) != 0) { if((flag & NOGARLIC) != 0) { continue; } info[cnt] |= NOGARLIC; } if((sobj_at(SCR_SCARE_MONSTER, nx, ny) != 0) || ((mon->mpeaceful == 0) && (sengr_at("Elbereth", nx, ny) != 0))) { if((flag & ALLOW_SSM) == 0) { continue; } info[cnt] |= ALLOW_SSM; } if(sobj_at(ENORMOUS_ROCK, nx, ny) != 0) { if((flag & ALLOW_ROCK) == 0) { continue; } info[cnt] |= ALLOW_ROCK; } if((Invis == 0) && (online(nx, ny) != 0)) { if((flag & NOTONL) != 0) { continue; } info[cnt] |= NOTONL; } /* We cannot avoid traps of an unknown kind */ struct gen *gtmp = g_at(nx, ny, ftrap); int tt; if(gtmp != NULL) { tt = 1 << (gtmp->gflag & ~SEEN); if((mon->mtrapseen & tt) != 0) { if((flag & tt) == 0) { continue; } info[cnt] |= tt; } } poss[cnt].x = nx; poss[cnt].y = ny; ++cnt; } } } } } } return cnt; }
/* * shk_move: return 1: he moved 0: he didnt -1: let m_move do it */ int shk_move(struct monst *shkp) { struct monst *mtmp; struct permonst *mdat = shkp->data; xchar gx, gy, omx, omy, nx, ny, nix, niy; schar appr, i; int udist; int z; schar shkroom, chi, chcnt, cnt; boolean uondoor = 0, satdoor, avoid = 0, badinv; coord poss[9]; int info[9]; struct obj *ib = NULL; omx = shkp->mx; omy = shkp->my; if ((udist = dist(omx, omy)) < 3) { if (ANGRY(shkp)) { hitu(shkp, d(mdat->damn, mdat->damd) + 1); return (0); } if (ESHK(shkp)->following) { if (strncmp(ESHK(shkp)->customer, plname, PL_NSIZ)) { pline("Hello %s! I was looking for %s.", plname, ESHK(shkp)->customer); ESHK(shkp)->following = 0; return (0); } if (!ESHK(shkp)->robbed) { /* impossible? */ ESHK(shkp)->following = 0; return (0); } if (moves > followmsg + 4) { pline("Hello %s! Didn't you forget to pay?", plname); followmsg = moves; } if (udist < 2) return (0); } } shkroom = inroom(omx, omy); appr = 1; gx = ESHK(shkp)->shk.x; gy = ESHK(shkp)->shk.y; satdoor = (gx == omx && gy == omy); if (ESHK(shkp)->following || ((z = holetime()) >= 0 && z * z <= udist)) { gx = u.ux; gy = u.uy; if (shkroom < 0 || shkroom != inroom(u.ux, u.uy)) if (udist > 4) return (-1); /* leave it to m_move */ } else if (ANGRY(shkp)) { long saveBlind = Blind; Blind = 0; if (shkp->mcansee && !Invis && cansee(omx, omy)) { gx = u.ux; gy = u.uy; } Blind = saveBlind; avoid = FALSE; } else { #define GDIST(x, y) ((x - gx) * (x - gx) + (y - gy) * (y - gy)) if (Invis) avoid = FALSE; else { uondoor = (u.ux == ESHK(shkp)->shd.x && u.uy == ESHK(shkp)->shd.y); if (uondoor) { if (ESHK(shkp)->billct) pline("Hello %s! Will you please pay before leaving?", plname); badinv = (carrying(PICK_AXE) || carrying(ICE_BOX)); if (satdoor && badinv) return (0); avoid = !badinv; } else { avoid = (u.uinshop && dist(gx, gy) > 8); badinv = FALSE; } if (((!ESHK(shkp)->robbed && !ESHK(shkp)->billct) || avoid) && GDIST(omx, omy) < 3) { if (!badinv && !online(omx, omy)) return (0); if (satdoor) appr = gx = gy = 0; } } } if (omx == gx && omy == gy) return (0); if (shkp->mconf) { avoid = FALSE; appr = 0; } nix = omx; niy = omy; cnt = mfndpos(shkp, poss, info, ALLOW_SSM); if (avoid && uondoor) { /* perhaps we cannot avoid him */ for (i = 0; i < cnt; i++) if (!(info[i] & NOTONL)) goto notonl_ok; avoid = FALSE; notonl_ok: ; } chi = -1; chcnt = 0; for (i = 0; i < cnt; i++) { nx = poss[i].x; ny = poss[i].y; if (levl[nx][ny].typ == ROOM || shkroom != ESHK(shkp)->shoproom || ESHK(shkp)->following) { #ifdef STUPID /* cater for stupid compilers */ int zz; #endif /* STUPID */ if (uondoor && (ib = sobj_at(ICE_BOX, nx, ny))) { nix = nx; niy = ny; chi = i; break; } if (avoid && (info[i] & NOTONL)) continue; if ((!appr && !rn2(++chcnt)) || #ifdef STUPID (appr && (zz = GDIST(nix, niy)) && zz > GDIST(nx, ny)) #else (appr && GDIST(nx, ny) < GDIST(nix, niy)) #endif /* STUPID */ ) { nix = nx; niy = ny; chi = i; } } } if (nix != omx || niy != omy) { if (info[chi] & ALLOW_M) { mtmp = m_at(nix, niy); if (hitmm(shkp, mtmp) == 1 && rn2(3) && hitmm(mtmp, shkp) == 2) return (2); return (0); } else if (info[chi] & ALLOW_U) { hitu(shkp, d(mdat->damn, mdat->damd) + 1); return (0); } shkp->mx = nix; shkp->my = niy; pmon(shkp); if (ib) { freeobj(ib); mpickobj(shkp, ib); } return (1); } return (0); }
void cTmpEff::Expire() { int k; P_CHAR pc_s = FindCharBySerial(getDest()); if ( num != 9 // grinding && num != 10 // create potion && num != 13 // door close && num != 14 // training dummy && num != 17) // explosion { //Added by TANiS to fix errors, memory corruption and door auto-close 10-6-98 // Check to see if it's a dead char and delete the wrong effect, or if it's just // a door auto-close effect and process it the right way. if ( pc_s == NULL ) { return; // just remove this effect } //End of TANiS' change } switch(num) { case 1: if (pc_s->priv2&0x02) { pc_s->priv2 &= 0xFD; int sk=calcSocketFromChar((pc_s)); if (sk!=-1) sysmessage(sk, "You are no longer frozen."); Magic->afterParticles(38, pc_s); } break; case 2: pc_s->fixedlight='\xFF'; dolight(calcSocketFromChar((pc_s)), worldbrightlevel); break; case 3: pc_s->chgDex(more1); statwindow(calcSocketFromChar(pc_s), pc_s); break; case 4: pc_s->in+=more1; statwindow(calcSocketFromChar(pc_s), pc_s); break; case 5: pc_s->st+=more1; statwindow(calcSocketFromChar(pc_s), pc_s); break; case 6: pc_s->chgDex(-1 * more1); pc_s->stm=min(pc_s->stm, (int)pc_s->effDex()); statwindow(calcSocketFromChar(pc_s), pc_s); break; case 7: pc_s->in-=more1; pc_s->mn=min(pc_s->mn, pc_s->in); statwindow(calcSocketFromChar(pc_s), pc_s); break; case 8: pc_s->st-=more1; pc_s->hp=min(pc_s->hp, pc_s->st); statwindow(calcSocketFromChar(pc_s), pc_s); break; case 9: if (more1 == 0) { if (more2!=0) { sprintf((char*)temp, "*%s continues grinding.*", pc_s->name.c_str()); npcemoteall(pc_s, (char*)temp,1); } soundeffect2(pc_s, 0x0242); } break; case 10: { pc_s = FindCharBySerial(getSour()); P_ITEM pMortar = FindItemBySerial(getDest()); if(pMortar != NULL) //AntiChrist - to prevent crashes Skills->CreatePotion(pc_s, more1, more2, pMortar); } break; case 11: pc_s->st-=more1; pc_s->hp=min(pc_s->hp, pc_s->st); pc_s->chgDex(-1 * more2); pc_s->stm=min(pc_s->stm, (int)pc_s->effDex()); pc_s->in-=more3; pc_s->mn=min(pc_s->mn, pc_s->in); statwindow(calcSocketFromChar(pc_s), pc_s); break; case 12: pc_s->st+=more1; pc_s->chgDex(more2); pc_s->in+=more3; statwindow(calcSocketFromChar(pc_s), pc_s); break; case 13: { P_ITEM pDoor = FindItemBySerial(getDest());// door if (pDoor) { if (pDoor->dooropen==0) break; pDoor->dooropen=0; dooruse(calcSocketFromChar((pc_s)), pDoor); } break; } case 14: //- training dummies Tauriel check to see if item moved or not before searching for it { P_ITEM pTrainDummy = FindItemBySerial(getDest()); if (pTrainDummy) { if (pTrainDummy->id()==0x1071) { pTrainDummy->setId(0x1070); pTrainDummy->gatetime=0; RefreshItem(pTrainDummy);//AntiChrist } else if (pTrainDummy->id()==0x1075) { pTrainDummy->setId(0x1074); pTrainDummy->gatetime=0; RefreshItem(pTrainDummy);//AntiChrist } } } break; case 15: //reactive armor pc_s->ra=0; break; case 16: //Explosion potion messages Tauriel sprintf((char*)temp, "%i", more3); sysmessage(calcSocketFromChar((pc_s)), (char*)temp); // crashfix, LB break; case 17: //Explosion potion explosion Tauriel pc_s = FindCharBySerial(getSour()); explodeitem(calcSocketFromChar((pc_s)), FindItemBySerial(getDest())); //explode this item break; case 18: //Polymorph spell by AntiChrist 9/99 if(pc_s->polymorph)//let's ensure it's under polymorph effect! { pc_s->setId(pc_s->xid); pc_s->polymorph=false; teleport(pc_s); } break; case 19: //Incognito spell by AntiChrist 12/99 reverseIncognito(pc_s); break; case 20: // LSD potions, LB 5'th nov 1999 { k=calcSocketFromChar((pc_s)); if (k==-1) return; LSD[k]=0; sysmessage(k,"LSD has worn off"); pc_s->stm=3; // stamina near 0 pc_s->mn=3; pc_s->hp=pc_s->hp/7; impowncreate(k, pc_s, 0); all_items(k); // absolutely necassairy here !!! AllCharsIterator it; for (it.Begin(); !it.atEnd(); it++) // that hurts, but there's no other good way { P_CHAR pc = it.GetData(); if (chardist( pc_s, pc ) < 15 && ( online(pc) || pc->isNpc() ) ) updatechar(pc); } } break; case 21: int toDrop; toDrop = more1; //Effect->more1; if( ( pc_s->baseskill[PARRYING] - toDrop ) < 0 ) pc_s->baseskill[PARRYING] = 0; else pc_s->baseskill[PARRYING] -= toDrop; break; case 33: // delayed hiding for gms after flamestrike effect k=calcSocketFromChar((pc_s)); sysmessage(k,"You have hidden yourself well."); pc_s->hidden=1; updatechar(pc_s); break; case 34: // delayed unhide for gms // Changed to be uniform with delayed hideing (Aldur) k = calcSocketFromChar((pc_s)); sysmessage(k, "You are now visible."); pc_s->hidden = 0; updatechar(pc_s); break; case 35: //heals some pf - solarin int iHp; iHp=(int)more1; pc_s->hp+=iHp; updatestats(pc_s, 0); if (!more2) tempeffect(pc_s, pc_s, 35, more1+1, 1, more3, 0); break; default: LogErrorVar("Fallout of switch (num = %i).", num); break; } Items->CheckEquipment(pc_s); //AntiChrist - checks equipments for stats requirements }