TerminalMessageView* TerminalMessageView::create() { auto ret = new TerminalMessageView(); if (!ret) { CC_SAFE_DELETE(ret); return nullptr; } ret->autorelease(); // 開始位置固定 ret->setAnchorPoint(Point(0, 0)); ret->setPosition(16, 56); ret->setScale(2.0f); auto msg_label = Label::createWithBMFont("fonts/message_font.fnt", ""); msg_label->getTexture()->setAliasTexParameters(); msg_label->setAnchorPoint(Point(0, 1)); msg_label->setPosition(8, 40); msg_label->setColor(Color3B(0, 255, 30)); msg_label->setWidth(132); msg_label->setLineBreakWithoutSpace(true); ret->addChild(msg_label); ret->setMsgLabel(msg_label); ret->setVisible(false); ret->setStringIdx(0); ret->setMsg(""); return ret; }
void TerminalMessageView::viewMessage(std::string msg) { setStringIdx(0); setMsg(msg); auto dispatcher = Raciela::Dispatcher::getInstance(); dispatcher->dispatch("update_terminal_msg_state", TerminalMessageViewState::PROGRESS); setVisible(true); schedule(schedule_selector(TerminalMessageView::update), 0.03f); }
void TipArea::win(int team) { if(team==1) winpix.load("resource/GameWinRed.png"); else winpix.load("resource/GameWinBlue.png"); winflag = true; setMsg(""); setVisible(1); update(); }
IRCChannelWidget::IRCChannelWidget(QWidget *parent, IRCClient* client) : QWidget(parent), _kickAction(this), _sendFileAction(this), _whoIsAction(this), _userOptions(this), _defaultChannel(0), _privMsg(this) { _subject = 0; _client = client; _msgScreen = new QPlainTextEdit(this); // we use the text-edit to display text _msgScreen->setReadOnly(true); _lineEdit = new QLineEdit(this); _submitText = new QPushButton(this); _submitText->setText("submit"); _submitText->setMinimumWidth(180); _users = new QListWidget(this); _users->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Expanding); // on entering or pressing submit we let the GUI know that we want to send text connect(_lineEdit, SIGNAL(returnPressed()),this, SLOT(textEntered())); connect(_submitText, SIGNAL(clicked()), this, SLOT(textEntered())); connect(this, SIGNAL(notified()), this, SLOT(updateGui())); // create our grid layout constructMainLayout(); stealFocus(); // create rightclickmenu and actions connected to functions handeling the actions _users->setContextMenuPolicy(Qt::CustomContextMenu); _whoIsAction.setText("Who Is"); _sendFileAction.setText("Send File"); _kickAction.setText("Kick"); _privMsg.setText("Privmsg"); _userOptions.addAction(&_whoIsAction); _userOptions.addAction(&_sendFileAction); _userOptions.addAction(&_kickAction); _userOptions.addAction(&_privMsg); connect(_users, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showUserOptionsMenu(const QPoint &))); connect(&_whoIsAction, SIGNAL(triggered()), this, SLOT(sendWhoIs())); connect(&_sendFileAction, SIGNAL(triggered()), this, SLOT(sendFile())); connect(&_kickAction, SIGNAL(triggered()), this, SLOT(kickUser())); connect(&_privMsg, SIGNAL(triggered()), this, SLOT(setMsg())); }
void CMobEntity::OnMobSkillFinished(CMobSkillState& state, action_t& action) { auto PSkill = state.GetSkill(); auto PTarget = static_cast<CBattleEntity*>(state.GetTarget()); static_cast<CMobController*>(PAI->GetController())->TapDeaggroTime(); // store the skill used m_UsedSkillIds[PSkill->getID()] = GetMLevel(); PAI->TargetFind->reset(); float distance = PSkill->getDistance(); uint8 findFlags = 0; if (PSkill->getFlag() & SKILLFLAG_HIT_ALL) { findFlags |= FINDFLAGS_HIT_ALL; } // Mob buff abilities also hit monster's pets if (PSkill->getValidTargets() == TARGET_SELF) { findFlags |= FINDFLAGS_PET; } action.id = id; if (objtype == TYPE_PET && static_cast<CPetEntity*>(this)->getPetType() == PETTYPE_JUG_PET && static_cast<CPetEntity*>(this)->getPetType() == PETTYPE_AUTOMATON) action.actiontype = ACTION_PET_MOBABILITY_FINISH; else if (PSkill->getID() < 256) action.actiontype = ACTION_WEAPONSKILL_FINISH; else action.actiontype = ACTION_MOBABILITY_FINISH; action.actionid = PSkill->getID(); if (PTarget && PAI->TargetFind->isWithinRange(&PTarget->loc.p, distance)) { if (PSkill->isAoE()) { PAI->TargetFind->findWithinArea(PTarget, (AOERADIUS)PSkill->getAoe(), PSkill->getRadius(), findFlags); } else if (PSkill->isConal()) { float angle = 45.0f; PAI->TargetFind->findWithinCone(PTarget, distance, angle, findFlags); } else { PAI->TargetFind->findSingleTarget(PTarget, findFlags); } } else { action.actiontype = ACTION_MOBABILITY_INTERRUPT; actionList_t& actionList = action.getNewActionList(); actionList.ActionTargetID = id; actionTarget_t& actionTarget = actionList.getNewActionTarget(); actionTarget.animation = PSkill->getID(); return; } uint16 actionsLength = PAI->TargetFind->m_targets.size(); PSkill->setTotalTargets(actionsLength); PSkill->setTP(state.GetSpentTP()); PSkill->setHPP(GetHPP()); uint16 msg = 0; uint16 defaultMessage = PSkill->getMsg(); bool first {true}; for (auto&& PTarget : PAI->TargetFind->m_targets) { actionList_t& list = action.getNewActionList(); list.ActionTargetID = PTarget->id; actionTarget_t& target = list.getNewActionTarget(); list.ActionTargetID = PTarget->id; target.reaction = REACTION_HIT; target.speceffect = SPECEFFECT_HIT; target.animation = PSkill->getAnimationID(); target.messageID = PSkill->getMsg(); // reset the skill's message back to default PSkill->setMsg(defaultMessage); if (objtype == TYPE_PET && static_cast<CPetEntity*>(this)->getPetType() != PETTYPE_JUG_PET) { target.animation = PSkill->getPetAnimationID(); target.param = luautils::OnPetAbility(PTarget, this, PSkill, PMaster, &action); } else { target.param = luautils::OnMobWeaponSkill(PTarget, this, PSkill); } if (msg == 0) { msg = PSkill->getMsg(); } else { msg = PSkill->getAoEMsg(); } target.messageID = msg; if (PSkill->hasMissMsg()) { target.reaction = REACTION_MISS; target.speceffect = SPECEFFECT_NONE; if (msg = PSkill->getAoEMsg()) msg = 282; } else { target.reaction = REACTION_HIT; } if (target.speceffect & SPECEFFECT_HIT) { target.speceffect = SPECEFFECT_RECOIL; target.knockback = PSkill->getKnockback(); if (first && (PSkill->getSkillchain() != 0)) { CWeaponSkill* PWeaponSkill = battleutils::GetWeaponSkill(PSkill->getSkillchain()); if (PWeaponSkill) { SUBEFFECT effect = battleutils::GetSkillChainEffect(PTarget, PWeaponSkill); if (effect != SUBEFFECT_NONE) { int32 skillChainDamage = battleutils::TakeSkillchainDamage(this, PTarget, target.param); if (skillChainDamage < 0) { target.addEffectParam = -skillChainDamage; target.addEffectMessage = 384 + effect; } else { target.addEffectParam = skillChainDamage; target.addEffectMessage = 287 + effect; } target.additionalEffect = effect; } } first = false; } } PTarget->StatusEffectContainer->DelStatusEffectsByFlag(EFFECTFLAG_DETECTABLE); } }
AIVDmsg::AIVDmsg(std::string parseMsg, Endpoint_ptr sender, bool check_checksum): NMEAmsg(parseMsg, sender, check_checksum){ setMsg(NMEAmsg::getMsg()); }
//server thread, one per client void *serverThread(void *data){ int candidateQID; //msg queue ID of candidateQID (for CHAT) int clientQID; //msg queue ID of private server-client queue CLLNode *clientCLL, *threadCLLNext; //pointer to next candidate in client thread JOINMsg *jMsgPtr = data, jMsg; CLIENTMsg cMsg, canMsg, tempMsg; dStruct *dBuffer; int retval; pthread_t pingThread; //create private semaphore between server thread and client 'sem+PID', w/init value = 0 char semname[MAXNAMELEN]; sem_t *tSemPtr; jMsg.PID = jMsgPtr->PID; jMsg.AAIdx = jMsgPtr->AAIdx; strcpy(jMsg.mname, jMsgPtr->mname); strcpy(jMsg.minfo, jMsgPtr->minfo); dBuffer = initClient(&jMsg); clientQID = dBuffer->clQID; clientCLL = dBuffer->clNodePtr; threadCLLNext = Head; //initialize current candidate to Head of CLL sprintf(semname, "/tSem%d", jMsg.PID); umask(0x0000); tSemPtr = sem_open(semname, O_CREAT, S_IRUSR|S_IWUSR|S_IROTH|S_IWOTH, 0); if (tSemPtr == SEM_FAILED){ perror("sem_open"); } printClientsFwd(); setMsg(ACK, &cMsg, threadCLLNext); //send ACK message to client if( msgsnd(clientQID, &cMsg, sizeof(CLIENTMsg)-sizeof(long), 0) == -1){ fprintf(stderr, "Server: cannot send ACK message to client PID: %d\n", cMsg.PID); perror("msgsnd"); } printf("ACK message sent to client\n"); //-----semwait(sem+PID) here //if( sem_wait(tSemPtr) < 0){ perror("sem_wait"); } sleep(1); //create (sub)thread to "PING" client to see if connection is still good. Set timeout of about 1 ms. /* retval = pthread_create(&pingThread, NULL, ping, (void*)jMsgPtr); if( retval ){ fprintf(stderr, "\n Server: error(%d): cannot create connection pinger ping()\n", retval); perror("pthread_create"); } */ cMsg.mtype = PASS; while (cMsg.mtype != QUIT) { /* serverThread listens for commands from client*/ if (clientCount == 1){ //only one (self) client logged on, override command type in message cMsg.mtype = NIL; cMsg.PID = -1; cMsg.status = NOTLIKED; strcpy(cMsg.mname, threadCLLNext->name); strcpy(cMsg.minfo, threadCLLNext->info); } printf("client %d mtype is %ld\n", clientCLL->PID, cMsg.mtype); switch (cMsg.mtype){ case PASS: printf("PASS command received\n"); threadCLLNext = threadCLLNext->Next; //check linked list for the next candidate while (threadCLLNext->PID == -1 || threadCLLNext->PID == jMsg.PID) threadCLLNext = threadCLLNext->Next; //advance ptr to next if Head or same as client //determine status of next candidate and set status bits setStatus(&cMsg, clientCLL, threadCLLNext); printf("In PASS, cMsg.status=%d, cMsg.PID=%d, cMsg.mname=%s,\n cMsg.minfo=%s\n", cMsg.status, cMsg.PID, cMsg.mname, cMsg.minfo); setMsg(OK, &cMsg, threadCLLNext); msgsnd(clientQID, &cMsg, sizeof(CLIENTMsg)-sizeof(long), 0); //send info to client //-----semwait(sem+PID) here //if( sem_wait(tSemPtr) < 0){ perror("sem_wait"); } break; case ENDCHAT: //ENDCHAT command can come from either client - procedure similar to PASS, can combine threadCLLNext = threadCLLNext->Next; //check linked list for the next candidate while (threadCLLNext->PID == -1 || threadCLLNext->PID == jMsg.PID) threadCLLNext = threadCLLNext->Next; //advance ptr to next if Head or same as client //determine status of next candidate and set status bits setStatus(&cMsg, clientCLL, threadCLLNext); setMsg(OK, &cMsg, threadCLLNext); msgsnd(clientQID, &cMsg, sizeof(CLIENTMsg)-sizeof(long), 0); //send info to client //-----semwait(sem+PID) here //if( sem_wait(tSemPtr) < 0){ perror("sem_wait"); } break; case LIKE: printf("LIKE command received\n"); //update client's Like Matrix against current candidate to like. LikeMatrix[clientCLL->AssignArrIdx][threadCLLNext->AssignArrIdx] = 'L'; //---rest same as PASS threadCLLNext = threadCLLNext->Next; //check linked list for the next candidate while (threadCLLNext->PID == -1 || threadCLLNext->PID == jMsg.PID) threadCLLNext = threadCLLNext->Next; //advance ptr to next if Head or same as client //determine status of next candidate and set status bits setStatus(&cMsg, clientCLL, threadCLLNext); setMsg(OK, &cMsg, threadCLLNext); msgsnd(clientQID, &cMsg, sizeof(CLIENTMsg)-sizeof(long), 0); //send info to client //-----semwait(sem+PID) here //if( sem_wait(tSemPtr) < 0){ perror("sem_wait"); } break; case CHAT: //CHAT command originates from client (single starting point) msgsnd(clientQID, &cMsg, sizeof(CLIENTMsg)-sizeof(long), 0);//relays back CHAT message to originator client //-----semwait(sem+PID) here //if( sem_wait(tSemPtr) < 0){ perror("sem_wait"); } //determine candidateQID of current candidate (threadCLLNext) to be able to send message to that client MQ candidateQID = initClientQueue("ftokfile.txt", threadCLLNext->PID); printf("CHAT command received, clientQID is %d, candidateQID is %d\n", clientQID, candidateQID); canMsg.status = 0x0003; //status is MATCHED setMsg(CHATCAN, &canMsg, clientCLL); //send canMsg to current candidate to CHATCAN msgsnd(candidateQID, &canMsg, sizeof(CLIENTMsg)-sizeof(long), 0); //client should send ENDCHAT command if client ends chat //-----NONONONO semwait(sem+PID) here break; case CHATCAN: //to be able to synch properly, this recipient server thread must read (ahead) the next message from its client in the MQ and store the command. //Commands can be PASS, LIKE, QUIT, CHAT, ENDCHAT, (or another CHATCAN) //After the CHATCAN msg is sent to the client, the stored command is processed. //Alternatively, the command from the client can be discarded. This will simplify the processing by quite a bit... In this way, the message synch is maintained if (msgrcv(clientQID, &tempMsg, sizeof(CLIENTMsg)-sizeof(long), 0, 0) == -1) perror("msgrcv"); //As you can see, handling this case can be quite complex!!!!! msgsnd(clientQID, &cMsg, sizeof(CLIENTMsg)-sizeof(long), 0);//relays back CHAT message to candidate client //-----semwait(sem+PID) here, since received an extra msg from chat originator candidate //if( sem_wait(tSemPtr) < 0){ perror("sem_wait"); } break; case NIL: printf("NIL command received\n"); msgsnd(clientQID, &cMsg, sizeof(CLIENTMsg)-sizeof(long), 0); //-----semwait(sem+PID) here //if( sem_wait(tSemPtr) < 0){ perror("sem_wait"); } threadCLLNext = threadCLLNext->Next; //check linked list for the next candidate if (threadCLLNext->PID == -1) threadCLLNext = threadCLLNext->Next; //advance ptr to next if Head break; case QUIT: //same as DISCONNECTED:, removeClient() is called after exit from while() loop case DISCONNECTED: break; default: fprintf(stderr, "Server: error - invalid command from client %d\n", cMsg.PID); //should disconnect client and close server thread (to recover and save server's state) break; }//END switch() if (msgrcv(clientQID, &cMsg, sizeof(CLIENTMsg)-sizeof(long), 0, 0) == -1) { perror("msgrcv"); } //-----sempost(sem+PID) here //if( sem_post(tSemPtr) < 0){ perror("sem_post"); } }//END while (cMsg.mtype != QUIT) loop //thread closing procedures (QUIT command received from client) removeClient(clientQID, clientCLL); //pthread_join(pingThread, NULL); //send UNJOIN message to Join MQ so server can free up space (pthread_join) in thread array, and decrease the client count. jMsg.mtype = UNJOIN; printf("UNJOIN sent to server parent. Client PID is %d\n", jMsg.PID); //jMsgPtr->PID = same; msgsnd(joinQID, &jMsg, sizeof(JOINMsg)-sizeof(long), 0); pthread_exit(NULL); }
void Mailman::write(string msg) { setMsg(msg); write(); }
void SpyMini::stop(){ setMsg(STOP); moveIt(); }
void SpyMini::turnLeft(){ setMsg(TURNLEFT); moveIt(); }
ZDAmsg::ZDAmsg(std::string parseMsg, Endpoint_ptr sender, bool check_checksum): NMEAmsg(parseMsg, sender, check_checksum), zone(boost::local_time::posix_time_zone("UTC+0")){ setMsg(NMEAmsg::getMsg()); }
//! @name Creators //@{ //! Constructor taking only an error code explicit Error(int code) : code_(code), count_(0) { setMsg(); }
Error(int code, const A& arg1, const B& arg2, const C& arg3) : code_(code), count_(3), arg1_(toString(arg1)), arg2_(toString(arg2)), arg3_(toString(arg3)) { setMsg(); }
Error(int code, const A& arg1) : code_(code), count_(1), arg1_(toString(arg1)) { setMsg(); }
void SpyMini::forward(){ setMsg(FORWARD); moveIt(); }
void SpyMini::backward(){ setMsg(BACKWARD); moveIt(); }
Exception::Exception( const char *file, const char *line, const char *message ) { setMsg( file, line, message ); }
void SpyMini::turnRigt(){ setMsg(TURNRIGHT); moveIt(); }
Exception::Exception( const char *file, const char *line, const std::string &message ) { setMsg( file, line, message.c_str() ); }
void goDoItAlready() { setMsg("Downloading data set..."); // Start downloading the latest version std::string zip = get.getPath("cache.zip"); //std::string url = "http://tiggit.net/dl/client/cache"; std::string url = "http://sourceforge.net/projects/tiggit/files/client_data/cache.zip"; DownloadJob getter(url, zip); getter.run(); // Poll-loop until it's done while(true) { yield(); wxMilliSleep(40); bool res; if(getter.total != 0) { // Calculate progress int prog = (int)(getter.current*100.0/getter.total); // Avoid auto-closing the window if(prog >= 100) prog=99; res = update(prog); } else res = pulse(); // Did the user click 'Cancel'? if(!res) // Abort download thread getter.abort(); // Did we finish, one way or another? if(getter.isFinished()) break; } // If something went wrong, just forget about it. The cache file // is only an optimization, not critically important. if(getter.isNonSuccess()) return; // Download complete! Start unpacking setMsg("Unpacking cache..."); ZipJob install(zip, get.base.string()); install.run(); // Do another semi-busy loop while(true) { yield(); wxMilliSleep(40); // Disabled this because it looks like crap on windows. On // linux/gtk it works exactly like it should though. //pulse(); // Exit when done if(install.isFinished()) break; } }
Exception::Exception( const char *file, const char *line, const std::string &message, FT_STATUS ftStatus ) { stringstream ss; ss << message << " (FT_STATUS="<<ftStatusToString(ftStatus)<<")"; setMsg( file, line, ss.str().c_str() ); }