bool CPlayGameVorticon::init() { CVorticonMapLoaderWithPlayer MapLoader( mMap, m_Player, mSpriteObjectContainer ); MapLoader.m_checkpointset = m_checkpointset; // load level map if( !MapLoader.load( m_Episode, m_Level, m_Gamepath ) ) return false; gpSaveGameController->setLevel(m_Level); //// If those worked fine, continue the initialization // draw level map mMap->drawAll(); // Now Scroll to the position of the player and center him mMap->gotoPos( 32, 64 ); // Assure that the edges are never seen setupPlayers(); // Well, all players are living because they were newly spawn. g_pTimer->ResetSecondsTimer(); g_pInput->flushAll(); // Initialize the AI mpObjectAI.reset( new CVorticonSpriteObjectAI(mMap.get(), mSpriteObjectContainer, m_Player, m_NumPlayers, m_Episode, m_Level, mMap->m_Dark) ); // Check if Player meets the conditions to show a cutscene. This also happens, when finale of episode has reached verifyFinales(); // When Level starts it's never dark! g_pGfxEngine->Palette.setdark(false); if(m_level_command == GOTO_FINALE) createFinale(); else if(m_showKeensLeft) g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW); // In the case that we are in Episode 3 last Level, show Mortimer Messages if( m_Episode == 3 && m_Level == 16 ) { std::unique_ptr<CMessageBoxVort> msg1(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER"),false, true)); std::unique_ptr<CMessageBoxVort> msg2(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER2"),false, true)); std::unique_ptr<CMessageBoxVort> msg3(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER3"),false, true)); std::unique_ptr<CMessageBoxVort> msg4(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER4"),false, true)); std::unique_ptr<CMessageBoxVort> msg5(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER5"),false, true)); std::unique_ptr<CMessageBoxVort> msg6(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER6"),false, true)); mMessageBoxes.push_back(move(msg1)); mMessageBoxes.push_back(move(msg2)); mMessageBoxes.push_back(move(msg3)); mMessageBoxes.push_back(move(msg4)); mMessageBoxes.push_back(move(msg5)); mMessageBoxes.push_back(move(msg6)); g_pSound->playSound(SOUND_MORTIMER); } return true; }
TEST(Serialization, WriteBitsEasy) { QByteArray msg(1, 'a'); QBitArray bits(1, false); Serialization::WriteBitArray(bits, msg, 0); EXPECT_EQ((char)0x00, (char)msg[0]); QByteArray msg1(1, 'a'); QBitArray bits1(0, false); Serialization::WriteBitArray(bits1, msg1, 0); EXPECT_EQ((char)0x00, (char)msg1[0]); QByteArray msg2(1, 'a'); QBitArray bits2(1, true); Serialization::WriteBitArray(bits2, msg2, 0); EXPECT_EQ((char)0x01, (char)msg2[0]); QByteArray msg3(2, 'a'); QBitArray bits3(8, true); Serialization::WriteBitArray(bits3, msg3, 0); EXPECT_EQ((char)0xFF, (char)msg3[0]); EXPECT_EQ((char)'a', (char)msg3[1]); QByteArray msg4(2, 'a'); QBitArray bits4(8, true); Serialization::WriteBitArray(bits4, msg4, 1); EXPECT_EQ((char)'a', (char)msg4[0]); EXPECT_EQ((char)0xFF, (char)msg4[1]); QByteArray msg5(2, 'a'); QBitArray bits5(9, true); Serialization::WriteBitArray(bits5, msg5, 0); EXPECT_EQ((char)0xFF, (char)msg5[0]); EXPECT_EQ((char)0x01, (char)msg5[1]); QByteArray msg6(2, 'a'); QBitArray bits6(10, true); Serialization::WriteBitArray(bits6, msg6, 0); EXPECT_EQ((char)0xFF, (char)msg6[0]); EXPECT_EQ((char)0x03, (char)msg6[1]); }
int main(int argc, char** argv) { int i; unsigned long v; char num[FMT_ULONG_LEN]; switch (argc) { case 4: i = cvm_client_authenticate_password(argv[1], argv[2], argv[3], 0, 1); break; case 5: i = cvm_client_authenticate_password(argv[1], argv[2], argv[3], argv[4], 1); break; default: die2(1, "Incorrect usage.", usage); return 1; } if (i) { num[fmt_udec(num, i)] = 0; msg5("Authentication failed, error #", num, " (", (i < cvm_nerr) ? cvm_errlist[i] : "Unknown error code", ")"); if (cvm_client_fact_uint(CVM_FACT_OUTOFSCOPE, &v) == 0) u("out of scope: ", v); return i; } s("user name: ", cvm_fact_username); u("user ID: ", cvm_fact_userid); u("group ID: ", cvm_fact_groupid); s("real name: ", cvm_fact_realname); s("directory: ", cvm_fact_directory); s("shell: ", cvm_fact_shell); s("group name: ", cvm_fact_groupname); s("system user name: ", cvm_fact_sys_username); s("system directory: ", cvm_fact_sys_directory); s("domain: ", cvm_fact_domain); s("mailbox path: ", cvm_fact_mailbox); while (cvm_client_fact_uint(CVM_FACT_SUPP_GROUPID, &v) == 0) u("supp. group ID: ", v); return 0; }
bool CPlayGameVorticon::init() { const GsRect<Uint16> gameRect = gVideoDriver.getVidConfig().m_GameRect; gVideoDriver.setNativeResolution(gameRect); // Create the special merge effect (Fadeout) CColorMerge *pColorMergeFX = new CColorMerge(8); gEffectController.setupEffect(pColorMergeFX); CVorticonMapLoaderWithPlayer MapLoader( mMap, m_Player, mSpriteObjectContainer ); MapLoader.m_checkpointset = m_checkpointset; const int numPlayers = g_pBehaviorEngine->mPlayers; // load level map if( !MapLoader.load( m_Episode, m_Level, m_Gamepath ) ) return false; gpSaveGameController->setLevel(m_Level); mMap->setLevel(m_Level); //// If those worked fine, continue the initialization // draw level map mMap->drawAll(); // Now Scroll to the position of the player and center him mMap->gotoPos( 32, 64 ); // Ensure that the edges are never seen setupPlayers(); // Well, all players are living because they were newly spawn. gTimer.ResetSecondsTimer(); gInput.flushAll(); // Initialize the AI mpObjectAI.reset( new CVorticonSpriteObjectAI(mMap.get(), mSpriteObjectContainer, m_Player, numPlayers, m_Episode, m_Level, mMap->m_Dark) ); // Check if Player meets the conditions to show a cutscene. This also happens, when finale of episode is reached verifyFinales(); // When Level starts it's never dark! gGraphics.Palette.setdark(false); const std::string finaleStr = gArgs.getValue("finale"); if(finaleStr == "on") { createFinale(); gArgs.removeTag("finale"); } if(m_showKeensLeft) g_pSound->playSound(SOUND_KEENSLEFT, PLAY_NOW); // In the case that we are in Episode 3 last Level, show Mortimer Messages if( m_Episode == 3 && m_Level == 16 ) { std::unique_ptr<CMessageBoxVort> msg1(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER"),false, true)); std::unique_ptr<CMessageBoxVort> msg2(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER2"),false, true)); std::unique_ptr<CMessageBoxVort> msg3(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER3"),false, true)); std::unique_ptr<CMessageBoxVort> msg4(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER4"),false, true)); std::unique_ptr<CMessageBoxVort> msg5(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER5"),false, true)); std::unique_ptr<CMessageBoxVort> msg6(new CMessageBoxVort(g_pBehaviorEngine->getString("EP3_MORTIMER6"),false, true)); mMessageBoxes.push_back(move(msg1)); mMessageBoxes.push_back(move(msg2)); mMessageBoxes.push_back(move(msg3)); mMessageBoxes.push_back(move(msg4)); mMessageBoxes.push_back(move(msg5)); mMessageBoxes.push_back(move(msg6)); g_pSound->playSound(SOUND_MORTIMER); } return true; }
static void start_slot(int slot, const char* command, const char* envstart) { static str env; char* period; int fd; char hostname[256]; const char* mailto; const struct passwd* pw = &slots[slot].pw; const char* shell; msg5("(", pw->pw_name, ") CMD (", command, ")"); env.len = 0; wrap_str(envstr_set(&env, "PATH", path, 1)); if (envstart) wrap_str(envstr_from_string(&env, envstart, 1)); wrap_str(envstr_set(&env, "HOME", pw->pw_dir, 1)); wrap_str(envstr_set(&env, "USER", pw->pw_name, 1)); wrap_str(envstr_set(&env, "LOGNAME", pw->pw_name, 1)); if ((shell = envstr_get(&env, "SHELL")) == 0) shell = "/bin/sh"; if ((mailto = envstr_get(&env, "MAILTO")) == 0) mailto = pw->pw_name; if (*mailto == 0) { fd = devnull; slots[slot].headerlen = 0; } else { if ((fd = path_mktemp(tmpprefix, &tmp)) == -1) { failsys_slot(slot, "ZCould not create temporary file"); return; } unlink(tmp.s); cloexec_on(fd); gethostname(hostname, sizeof hostname); wrap_str(str_copyns(&tmp, 6, "To: <", mailto, ">\n", "From: Cron Daemon <root@", hostname, ">\n")); if ((period = strchr(hostname, '.')) != 0) *period = 0; wrap_str(str_catns(&tmp, 7, "Subject: Cron <", pw->pw_name, "@", hostname, "> ", command, "\n\n")); slots[slot].headerlen = tmp.len; if (write(fd, tmp.s, tmp.len) != (long)tmp.len) { close(fd); fd = -1; report_slot(slot, "ZCould not write message header"); return; } } shell_argv[shell_argc+0] = shell; shell_argv[shell_argc+1] = "-c"; shell_argv[shell_argc+2] = command; debugf(DEBUG_EXEC, "{slot }d{ starting: }s", slot, command); if (!forkexec_slot(slot, devnull, fd, shell_argv, &env)) { if (fd != devnull) close(fd); fd = -1; } slots[slot].sending_email = 0; slots[slot].tmpfd = fd; }