Exemple #1
0
        // Performs a test using a count stage whereby each unit of work is interjected
        // in some way by the invocation of interject().
        const CountStats* runCount(CountStage& count_stage) {
            int interjection = 0;
            WorkingSetID wsid;

            while (!count_stage.isEOF()) {
                // do some work -- assumes that one work unit counts a single doc
                PlanStage::StageState state = count_stage.work(&wsid);
                ASSERT_NOT_EQUALS(state, PlanStage::FAILURE);
                ASSERT_NOT_EQUALS(state, PlanStage::DEAD);

                // prepare for yield
                count_stage.saveState();

                // interject in some way kInterjection times
                if (interjection < kInterjections) {
                    interject(count_stage, interjection++);
                }

                // resume from yield
                count_stage.restoreState(&_txn);
            }

            return static_cast<const CountStats*>(count_stage.getSpecificStats());
        }
Exemple #2
0
int main(int argc, char **argv)
{
	int c;
	static struct option long_opts[] = {
		{ "description", required_argument, 0, 'c' },
		{ "defined", required_argument, 0, 'd' },
		{ "developed", required_argument, 0, 'e' },
		{ "gnu", required_argument, 0, 'g' },
		{ "head", no_argument, 0, 'h' },
		{ "help", no_argument, 0, 'H' },
		{ "kernel", required_argument, 0, 'k' },
		{ "operating", required_argument, 0, 'o' },
		{ "os", required_argument, 0, 'p' },
		{ "useful", required_argument, 0, 'u' },
		{ "version", no_argument, 0, 'v' },
		{ 0, 0, 0, 0 }
	};

	while ((c = getopt_long(argc, argv, "hvH", long_opts, NULL)) != EOF) {
		switch (c) {
		case 'c':
			description = optarg;
			break;
		case 'd':
			defined = optarg;
			break;
		case 'e':
			developed = optarg;
			break;
		case 'g':
			gnu = optarg;
			break;
		case 'h':
			head = 1;
			break;
		case 'k':
			kernel = optarg;
			break;
		case 'o':
			operating = optarg;
			break;
		case 'p':
			os = optarg;
			break;
		case 'u':
			useful = optarg;
			break;
		case 'v':
			printf("%s v0.1.0\nCopyright (C) 2016 Alexei Frolov\n"
			                "This program is distributed as free "
			                "software under the\nterms of the GNU "
			                "General Public License, version 3\n",
			                PROG_NAME);
			return EXIT_SUCCESS;
		case 'H':
			usage(PROG_NAME, stdout);
			return EXIT_SUCCESS;
		default:
			usage(argv[0], stderr);
			return EXIT_FAILURE;
		}
	}
	if (optind != argc) {
		if (optind == argc - 1) {
			osname = argv[optind];
		} else {
			usage(argv[0], stderr);
			return EXIT_FAILURE;
		}
	}
	interject();
	putchar('\n');
	return EXIT_SUCCESS;
}
void PD_UI_DissBattle::update(Step * _step){
	if(isEnabled()){
		if(!isGameOver){
			if(modeOffensive && playerQuestionTimer >= playerQuestionTimerLength && !playerResult){
				if(player->wantsToInsultUp()){
					insult(pBubbleBtn1->isEffective, pBubbleBtn1->label->getText(false));
				}else if(player->wantsToInsultDown()){
					insult(pBubbleBtn2->isEffective, pBubbleBtn2->label->getText(false));
				}
			}else{
				if (canInterject && player->wantsToInterject()){
					interject();
				}

				if(player->interjecting()){
					tutorialSpacebarImage->background->mesh->replaceTextures(PD_ResourceManager::scenario->getTexture("DISS-TUTORIAL-SPACEBAR-PRESSED")->texture);
				}else{
					tutorialSpacebarImage->background->mesh->replaceTextures(PD_ResourceManager::scenario->getTexture("DISS-TUTORIAL-SPACEBAR")->texture);
				}
			}

			if(!modeOffensive){
				enemy->pr->talking = true;
				// update interject bubble
				if(interjectBubble->isVisible()){
					if(interjectBubbleTimer >= interjectBubbleTimerLength){
						// hide bubble
						interjectBubble->setVisible(false);
						if(interjected){
							// Switch to player turn
							setUIMode(true);
						}
					}else{
						interjectBubbleTimer += _step->getDeltaTime();

						float s = 0.f;
						// animate bubble
						if(!interjected){
							s = interjectBubbleTimer / interjectBubbleTimerLength <= 0.5 ? Easing::easeOutCubic(interjectBubbleTimer, 0, interjectBubbleScale, interjectBubbleTimerLength * 0.5f) : Easing::easeInCubic(interjectBubbleTimer - interjectBubbleTimerLength * 0.5f, interjectBubbleScale, -interjectBubbleScale, interjectBubbleTimerLength * 0.5f);
						}else{
							s = interjectBubbleTimer / interjectBubbleTimerLength <= 0.7 ? Easing::easeOutElastic(interjectBubbleTimer, 0, interjectBubbleScale, interjectBubbleTimerLength * 0.7f) : Easing::easeInBack(interjectBubbleTimer - interjectBubbleTimerLength * 0.7f, interjectBubbleScale, -interjectBubbleScale, interjectBubbleTimerLength * 0.3f);
						}
						interjectBubble->meshTransform->scale(s, s, 1, false);
					}
				}

				// update enemy turn
				if(!interjected){
					// INTERJECT
					interjectTimer += _step->getDeltaTime();
					// Cursor
					if(glyphIdx < glyphs.size()){
						glm::vec3 screenPos = glyphs.at(glyphIdx)->childTransform->getWorldPos();
						float w = glyphs.at(glyphIdx)->getWidth();

						glm::vec3 screenPos1 = screenPos;
						glm::vec3 screenPos2 = glm::vec3(screenPos.x + w, screenPos.y, screenPos.z);

						cursorDelayDuration += _step->getDeltaTime();

						if(cursorDelayDuration < cursorDelayLength){
							float dx = screenPos2.x - screenPos1.x;
							float dy = screenPos2.y - screenPos1.y;
							float tx = Easing::linear(cursorDelayDuration, screenPos1.x, dx, cursorDelayLength);
							float ty = Easing::linear(cursorDelayDuration, screenPos1.y, dy, cursorDelayLength);
							enemyCursor->childTransform->translate(tx, ty, 0, false);
						}else{
							// Get next glyph

							// Find next punctuation
							if(highlightedPunctuation != nullptr && glyphs.at(glyphIdx) == highlightedPunctuation){
								sweet::Event * e = new sweet::Event("miss");
								eventManager->triggerEvent(e);

								prevHighlightedPunctuation = highlightedPunctuation;
								highlightedPunctuation = findFirstPunctuation(glyphIdx+1);
							}

							if(highlightedWordEnd != nullptr && glyphs.at(glyphIdx) == highlightedWordEnd){
								highlightNextWord(glyphIdx+1);
							}

							++glyphIdx;
							cursorDelayDuration = 0;

							if(glyphIdx < glyphs.size()){
								// set cursor delay for this glyph
								cursorDelayLength = glyphs.at(glyphIdx)->getWidth() / baseGlyphWidth * (glyphs.at(glyphIdx) != highlightedPunctuation ? baseCursorDelayLength * (1.f + (sassInterjectMultiplier - 1.f) * 0.5f) : baseCursorPunctDelayLength * sassInterjectMultiplier);
								
								// play sound
								if(glyphIdx == 1 || glyphs.at(glyphIdx - 1)->character == ' '){
									auto sound = enemy->voice;
									sound->setPitch((glyphs.at(glyphIdx)->character-100.f)/100.f+1.0f);
									sound->play();
								}
							}else{
								// Enemy's insult effective!
								incrementConfidence(-damage);
								setEnemyText();
							}
						}
					}

					// Punctuation Highlight
					if(highlightedPunctuation != nullptr){
						glm::vec3 pos = highlightedPunctuation->firstParent()->getTranslationVector();
						// text label
						glm::mat4 mm = highlightedPunctuation->nodeUIParent->firstParent()->getModelMatrix();
						pos = glm::vec3(mm* glm::vec4(pos, 1));

						punctuationHighlight->childTransform->translate(pos, false);
					}

					// Word Highlight
					if(highlightedWordStart != nullptr){
						glm::vec3 pos = highlightedWordStart->firstParent()->getTranslationVector();
						// text label
						glm::mat4 mm = highlightedWordStart->nodeUIParent->firstParent()->getModelMatrix();
						pos = glm::vec3(mm* glm::vec4(pos, 1));

						wordHighlight->childTransform->translate(pos, false);
					}
				}
			}else{
				enemy->pr->talking = false;
				// update compliment bubble
				if(complimentBubble->isVisible()){
					if(complimentBubbleTimer >= complimentBubbleTimerLength){
						complimentBubble->setVisible(false);
					}else{
						complimentBubbleTimer += _step->getDeltaTime();
						float s = 0.f;
						s = complimentBubbleTimer / complimentBubbleTimerLength <= 0.7 ? Easing::easeOutElastic(complimentBubbleTimer, 0, complimentBubbleScale, complimentBubbleTimerLength * 0.7f) : Easing::easeInBack(complimentBubbleTimer - complimentBubbleTimerLength * 0.7f, complimentBubbleScale, -complimentBubbleScale, complimentBubbleTimerLength * 0.3f);
						complimentBubble->meshTransform->scale(s, s, 1, false);
					}
				}

				// INSULT
				if(playerQuestionTimer >= playerQuestionTimerLength){
					if(!playerResult){
						// Increment player answer timer
						if(playerAnswerTimer >= playerAnswerTimerLength){
							// Out of time, enemy's turn!
							countInsultAccuracy(-1);
							// Reset multipier for failed insult damage
							playerComboMultiplier = 1.f;
							incrementConfidence(-damage);
							PD_ResourceManager::scenario->getAudio(TIMER)->sound->stop();
							PD_ResourceManager::scenario->getAudio(PASSED_INSULT_TIME_LIMIT)->sound->play();
							setUIMode(false);
						}else{
							playerAnswerTimer += _step->getDeltaTime();
						}
					}else{
						// Player Insult Result
						// Increment player result timer
						if(playerResultTimer >= playerResultTimerLength){
							if (playerResultEffective){
								// Insult Success!
								// Reset enemy combo multipier if first insult was effective
								if(enemyComboMultiplier > 1.f){
									enemyComboMultiplier = 1.f;
								}
								// Get next insult
								incrementConfidence(damage);
								setPlayerText();
								playerInsultSpeedMultiplier -= (1.f - MIN_OFFENSE_SPEED_MULTIPLIER) / NUM_OFFENSE_SPEED_CHANGES;

								playerAnswerTimerLength = basePlayerAnswerTimerLength *  sassInsultMultiplier * playerInsultSpeedMultiplier;
								playerQuestionTimerLength = basePlayerQuestionTimerLength * playerInsultSpeedMultiplier;
								playerTimerSlider->setValueMax(playerAnswerTimerLength);
							}
							else{
								//Insult Failed
								// Reset multipier for failed insult
								playerComboMultiplier = 1.f;
								incrementConfidence(-damage);
								setUIMode(false);
							}
						}else{
							playerResultTimer += _step->getDeltaTime();
						}
					}
				}else{
					// Increment player question timer
					playerQuestionTimer += _step->getDeltaTime();
					if(playerQuestionTimer >= playerQuestionTimerLength){
						playerBubbleOptions->setVisible(true);
						playerTimerSlider->setVisible(true);
						PD_ResourceManager::scenario->getAudio(TIMER)->sound->play(true);
					}
				}
			}
		}else{
			gameOverDuration += _step->getDeltaTime();

			if(gameOverDuration >= gameOverLength){
				complete();
			}else{
				float p = gameOverDuration / gameOverLength;
				if(p < 0.75f){
					float size = Easing::easeOutElastic(p, 0.5f, 0.5f, gameOverLength * 0.75f);
					gameOverImage->setRationalHeight(size, gameOverContainer);
					gameOverContainer->invalidateLayout();
				}
			}
		}

		canInterject = !interjectBubble->isVisible() && !modeOffensive;
		VerticalLinearLayout::update(_step);
	}
}