void CDoomsDayMissionMgr::Update( ) { CServerMissionMgr::Update( ); // Need to do next round stuff in update and not in other functions to // guarantee we aren't being called by an object. Since nextround can // delete all the objects, this would cause a crash. if( m_bNextRound ) { m_bNextRound = false; NextRound( ); } }
void Die(Fighter* f){ if(nexttimer<0){ f->health=0; ChangeState(f,DEAD); f->opponent->victories++; if(f->opponent->victories >= NUMROUNDS){ NextGame(); } else NextRound(); } }
void ATacticalOpsGameModeBase::OnRoundTimeExpired() { switch (RoundState) { case (ERoundStateEnum::PreRound): StartRound(); break; case (ERoundStateEnum::InProgress): RoundTimeExpired(); break; case (ERoundStateEnum::RoundEnd): NextRound(); break; } }
void CServerMissionMgr::Update( ) { // Update the playertracker. m_PlayerTracker.Update( ); // Since all the players dropped out, we can just finish what we // were doing. if( m_bPlayerTrackerAborted ) { // Clear the abort signal. m_bPlayerTrackerAborted = false; FinishExitLevel( ); } // Check to see if the time limit was reached... if( m_ServerSettings.m_nTimeLimit > 0 && m_fStartTime >= 0.0f ) { float fElapsedTime = g_pLTServer->GetTime() - m_fStartTime; // Convert timelimit to seconds and see how much we have left. float fTimeLeft = ((float)m_ServerSettings.m_nTimeLimit * 60.0f ) - fElapsedTime; // If we ran out of time, then go to the next round. if( fTimeLeft <= 0 ) { g_pLTServer->CPrint( "TimeLimit reached." ); NextRound(); } // Check if we should show a countdown timer. else if( fTimeLeft < 30.0f && m_hDisplayTimer == NULL ) { LTVector vPos; LTRotation rRot; DisplayTimer* pDisplayTimer = ( DisplayTimer* )SpawnObject( "DisplayTimer", vPos, rRot ); if( pDisplayTimer ) { m_hDisplayTimer = pDisplayTimer->m_hObject; pDisplayTimer->Start( fTimeLeft ); } } } }
void CDeathMatchMissionMgr::Update( ) { //check for end of level... //check score limit if ( m_ServerSettings.m_nScoreLimit > 0 && m_fStartTime >= 0.0f ) { CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( ); while( iter != CPlayerObj::GetPlayerObjList( ).end( )) { CPlayerObj* pPlayerObj = *iter; if (pPlayerObj->GetPlayerScore()->GetScore() >= m_ServerSettings.m_nScoreLimit) { g_pLTServer->CPrint("ScoreLimit reached."); NextRound(); } iter++; } } CServerMissionMgr::Update( ); }
void CTeamDeathMatchMissionMgr::Update() { // Check the teams to see if any of them have reached the score limit... if( m_ServerSettings.m_nScoreLimit > 0 && m_fStartTime >= 0.0f ) { for( uint8 i = 0; i < CTeamMgr::Instance().GetNumTeams(); ++i ) { CTeam *pTeam = CTeamMgr::Instance().GetTeam( i ); if( pTeam && (pTeam->GetScore() >= m_ServerSettings.m_nScoreLimit) ) { CTeamMgr::Instance( ).WonRound( i ); g_pLTServer->CPrint( "ScoreLimit reached." ); NextRound(); } } } // Skip the CDeathMatchMissionMgr::Update() but be sure to call up... CServerMissionMgr::Update( ); }
void MyWorld::TakenTurn() { TurnsLeft--; if (TurnsLeft < 0) { // Play end of round music Audio::PlayMusic("game_over.mp3", false); // Game over ChangeState(eGameState_GameOver); } else TurnsLeftChanged = true; if (HasWon()) { // Play end of round music Audio::PlayMusic("end_round.mp3", false); // Next round NextRound(); } }
//The same as encrypt but in reverse... int AES::Decrypt(const char* Cipher, unsigned int CipherLen, const uint8_t* IV, const uint8_t* Key, char* PlainText) { #ifndef NO_NI if(AESNI()) { #ifdef WINDOWS unsigned int l = DecryptWin(Cipher, CipherLen, IV, Key, PlainText); #else unsigned int l = DecryptNix(Cipher, CipherLen, IV, Key, PlainText); #endif return l; } #endif mat4 State = mat4((unsigned char)0); mat4 CipherKey[2] = {mat4(Key), mat4(&Key[16])}; mat4 IVKey = mat4(IV); mat4 NextIV = mat4(0); mat4* Keys = new mat4[15]; Keys[0] = CipherKey[0]; Keys[1] = CipherKey[1]; for(int i = 2; i < 15; i++) Keys[i] = NextRound(Keys, i); for(unsigned int i = 0; (i * 16) < CipherLen; i++) { for(int col = 0; col < 4; col++) for(int row = 0; row < 4; row++) State.p[col][row] = (unsigned char)Cipher[(i * 16) + (4 * col) + row]; NextIV = State; State.AddRoundKey(Keys[14]); State.RevShiftRows(); State.RevSubBytes(); for(int j = 13; j > 0; j--) { State.AddRoundKey(Keys[j]); State.RevMixColumns(); State.RevShiftRows(); State.RevSubBytes(); } State.AddRoundKey(Keys[0]); State.AddRoundKey(IVKey); for(int col = 0; col < 4; col++) for(int row = 0; row < 4; row++) PlainText[(i * 16) + (4 * col) + row] = State.p[col][row]; IVKey = NextIV; } CipherKey[0] = 0; CipherKey[1] = 0; for(int i = 0; i < 15; i++) Keys[i] = 0; int len = CipherLen; int NBytes = (char)PlainText[len-1]; bool BadPad = false; if(NBytes > 16 || NBytes == 0) BadPad = true; for(int i = 0; i < NBytes && !BadPad; i++) //Time to do a simple integrity check { if(PlainText[len-1 - i] != NBytes) BadPad = true; } if(BadPad == true) { return -1; } len -= NBytes; PlainText[len] = 0; delete[] Keys; return len; }
void AES::Encrypt(const char* Msg, unsigned int MsgLen, const uint8_t* IV, const uint8_t* Key, char* CipherText) { #ifndef NO_NI if(AESNI()) { #ifdef WINDOWS EncryptWin(Msg, MsgLen, IV, Key, CipherText); #else EncryptNix(Msg, MsgLen, IV, Key, CipherText); #endif return; } #endif mat4 State = mat4((unsigned char)0); //4x4 Matrix to go from original to cipher text mat4 CipherKey[2] = {mat4(Key), mat4(&Key[16])}; //2 4x4 Matrices to hold parts 1 & 2 of the 256 bit key mat4 IVKey = mat4(IV); mat4* Keys = new mat4[15]; //Will hold all 14 round keys and the initial (at pos 0) Keys[0] = CipherKey[0]; Keys[1] = CipherKey[1]; for(int i = 2; i < 15; i++) Keys[i] = NextRound(Keys, i); unsigned char Pad = 16 - (MsgLen % 16); char PaddedBlock[16]; memcpy(PaddedBlock, &Msg[MsgLen + Pad - 16], 16 - Pad); memset(PaddedBlock + (16 - Pad), Pad, Pad); for(unsigned int i = 0; (i * 16) <= MsgLen; i++) //For every 16 chars, fill the state matrix again. { if((MsgLen + Pad) - (16 * i) > 16) { for(int col = 0; col < 4; col++) for(int row = 0; row < 4; row++) State.p[col][row] = (unsigned char)Msg[(i * 16) + (4 * col) + row]; //i * 16 controls which block we're on, the rest moves through the block } else { for(int col = 0; col < 4; col++) for(int row = 0; row < 4; row++) State.p[col][row] = (unsigned char)PaddedBlock[(4 * col) + row]; } State.AddRoundKey(IVKey); //This adds more randomness to strings with repeating blocks State.AddRoundKey(Keys[0]); for(int j = 1; j < 14; j++) { State.SubBytes(); State.ShiftRows(); State.MixColumns(); State.AddRoundKey(Keys[j]); } State.SubBytes(); State.ShiftRows(); State.AddRoundKey(Keys[14]); for(int col = 0; col < 4; col++) for(int row = 0; row < 4; row++) CipherText[(i * 16) + (4 * col) + row] = State.p[col][row]; IVKey = State; } CipherKey[0] = 0; CipherKey[1] = 0; for(int i = 0; i < 15; i++) Keys[i] = 0; delete[] Keys; return; }