/** * This function returns the exit value of the running process. If the process is not finished, this method * will block until it finishes, or the TestObject timeout value is reached. * If the test times-out, it is explicitly killed, as if a ACTION_TESTOBJECT_KILL message was sent by the harness. * @return the exit value of the process. */ int ExecProcess::getExitValue() { if (exitValue!=NOT_YET_SET) { ConsoleServer::debugMsg(9,"Process already finished (%d) - returning previous exit code\n",exitValue); } else { while ((!testTimedOut())& (stillRunning(pid))) { switch (exitValue) { case NOT_YET_SET: ConsoleServer::debugMsg(9,"Checking process exit value (%s) - will timeout in %d seconds\n", "Still running", getTimeLeft()); break; case TIMEDOUT_STATE : ConsoleServer::debugMsg(9,"Checking process exit value (%s) - will timeout in %d seconds\n", "Timed out", getTimeLeft()); break; } sleep(1); } // exit value set by either testTimedOut() or stillRunning() } return exitValue; }
/** Updates the attachments in case of a kart-kart collision. This must only * be called for one of the karts in the collision, since it will update * the attachment for both karts. * \param other Pointer to the other kart hit. */ void Attachment::handleCollisionWithKart(AbstractKart *other) { Attachment *attachment_other=other->getAttachment(); if(getType()==Attachment::ATTACH_BOMB) { // Don't attach a bomb when the kart is shielded if(other->isShielded()) { other->decreaseShieldTime(); return; } // If both karts have a bomb, explode them immediately: if(attachment_other->getType()==Attachment::ATTACH_BOMB) { setTimeLeft(0.0f); attachment_other->setTimeLeft(0.0f); } else // only this kart has a bomb, move it to the other { // if there are only two karts, let them switch bomb from one to other if (getPreviousOwner() != other || World::getWorld()->getNumKarts() <= 2) { // Don't move if this bomb was from other kart originally other->getAttachment()->set(ATTACH_BOMB, getTimeLeft()+ stk_config->m_bomb_time_increase, m_kart); other->playCustomSFX(SFXManager::CUSTOM_ATTACH); clear(); } } } // type==BOMB else if(attachment_other->getType()==Attachment::ATTACH_BOMB && (attachment_other->getPreviousOwner()!=m_kart || World::getWorld()->getNumKarts() <= 2)) { // Don't attach a bomb when the kart is shielded if(m_kart->isShielded()) { m_kart->decreaseShieldTime(); return; } set(ATTACH_BOMB, other->getAttachment()->getTimeLeft()+ stk_config->m_bomb_time_increase, other); other->getAttachment()->clear(); m_kart->playCustomSFX(SFXManager::CUSTOM_ATTACH); } else { m_kart->playCustomSFX(SFXManager::CUSTOM_CRASH); other->playCustomSFX(SFXManager::CUSTOM_CRASH); } } // handleCollisionWithKart
/** * Will return false until the test has timed out, and then it will return true. * A test is considered as timed out if it runs longer than the value of TestObject.geTimeout() which * is measured in seconds. */ int ExecProcess::testTimedOut() { if (test==NULL) { return TRUE; } if ((test->getTimeout()!=0) &(getTimeLeft()==0)) { interrupt(); return TRUE; } else { return FALSE; } }
/** Updates the attachments in case of a kart-kart collision. This must only * be called for one of the karts in the collision, since it will update * the attachment for both karts. * \param other Pointer to the other kart hit. */ void Attachment::handleCollisionWithKart(AbstractKart *other) { Attachment *attachment_other=other->getAttachment(); if(getType()==Attachment::ATTACH_BOMB) { // If both karts have a bomb, explode them immediately: if(attachment_other->getType()==Attachment::ATTACH_BOMB) { setTimeLeft(0.0f); attachment_other->setTimeLeft(0.0f); } else // only this kart has a bomb, move it to the other { if(getPreviousOwner()!=other) { // Don't move if this bomb was from other kart originally other->getAttachment()->set(ATTACH_BOMB, getTimeLeft()+ stk_config->m_bomb_time_increase, m_kart); other->playCustomSFX(SFXManager::CUSTOM_ATTACH); clear(); } } } // type==BOMB else if(attachment_other->getType()==Attachment::ATTACH_BOMB && attachment_other->getPreviousOwner()!=m_kart) { set(ATTACH_BOMB, other->getAttachment()->getTimeLeft()+ stk_config->m_bomb_time_increase, other); other->getAttachment()->clear(); m_kart->playCustomSFX(SFXManager::CUSTOM_ATTACH); } else { m_kart->playCustomSFX(SFXManager::CUSTOM_CRASH); other->playCustomSFX(SFXManager::CUSTOM_CRASH); } } // handleCollisionWithKart
void BuffImplementation::sendTo(CreatureObject* player) { if (buffCRC != 0) { AddBuffMessage* abm = new AddBuffMessage(player, buffCRC, getTimeLeft()); player->sendMessage(abm); } }