Beispiel #1
0
void Computer::ManageOldLogs ()
{

	//
	// Delete any logs older than a certain age
	//

	for ( int i = logbank.logs.Size () - 1; i >= 0; --i ) {
		if ( logbank.logs.ValidIndex (i) ) {

			AccessLog *al = logbank.logs.GetData (i);

			if ( al ) {

				Date testdate;
				testdate.SetDate ( &(al->date) );
				testdate.AdvanceMinute ( TIME_TOEXPIRELOGS );

				if ( testdate.Before ( &(game->GetWorld ()->date) ) ) {

					delete logbank.logs.GetData (i);
					logbank.logs.RemoveData (i);

					if ( logbank.internallogs.ValidIndex ( i ) ) {
						delete logbank.internallogs.GetData (i);				
						logbank.internallogs.RemoveData (i);
					}

				}

			}

		}

	}
	
	//
	// Pack the new log structures together
	//

	int nextlog = 0;

	for ( int il = 0; il < logbank.logs.Size (); ++il ) {

		if ( il > nextlog ) nextlog = il;

		if ( !logbank.logs.ValidIndex (il) ) {

			// This is a blank spot
			// Look for the next available log to fill this space
			
			bool found = false;

			for ( ; nextlog < logbank.logs.Size (); ++nextlog ) {
				
				if ( logbank.logs.ValidIndex (nextlog) ) {

					logbank.logs.PutData	( logbank.logs.GetData (nextlog), il );
					logbank.logs.RemoveData (nextlog);

					if ( logbank.internallogs.ValidIndex(nextlog) ) {
						logbank.internallogs.PutData ( logbank.internallogs.GetData (nextlog), il );
						logbank.internallogs.RemoveData (nextlog);
					}

					++nextlog;

					found = true;
					break;

				}

			}

			if ( !found ) {

				// There are no more valid logs - 
				// So resize the DArray since this is now the max size
				// Then quit

				logbank.logs.SetSize ( il );
				logbank.internallogs.SetSize ( il );
				break;

			}

		}

	}

}
Beispiel #2
0
void Computer::Update ()
{

	if ( !isrunning ) return;

    if ( isinfected_revelation > 1.0 ) {

        Date damagedate;
        damagedate.SetDate ( &infectiondate );
        damagedate.AdvanceMinute ( TIME_REVELATIONREPRODUCE );

        if ( game->GetWorld ()->date.After ( &damagedate ) ) {

            //
            // Spread to two other computers

            Computer *comp1 = WorldGenerator::GetRandomComputer ( COMPUTER_TYPE_INTERNALSERVICESMACHINE );
            Computer *comp2 = WorldGenerator::GetRandomComputer ( COMPUTER_TYPE_INTERNALSERVICESMACHINE |
                                                                  COMPUTER_TYPE_CENTRALMAINFRAME        );

            UplinkAssert (comp1);
            UplinkAssert (comp2);

            game->GetWorld ()->plotgenerator.RunRevelation ( comp1->ip, isinfected_revelation, false );
            game->GetWorld ()->plotgenerator.RunRevelation ( comp2->ip, isinfected_revelation, false );

            //
            // Shut down this computer

	        SetIsRunning ( false );
	        databank.Format ();
	        logbank.Empty ();
            game->GetWorld ()->plotgenerator.Disinfected ( ip );

            //
            // Disconnect the player if he is connected

            if ( strcmp ( game->GetWorld ()->GetPlayer ()->GetRemoteHost ()->ip, ip ) == 0 ) {

	            game->GetWorld ()->GetPlayer ()->connection.Disconnect ();
	            game->GetWorld ()->GetPlayer ()->connection.Reset ();

	            game->GetInterface ()->GetRemoteInterface ()->RunNewLocation ();
	            game->GetInterface ()->GetRemoteInterface ()->RunScreen ( 2 );

            }
            
        }

    }

	//
	// Generate some new files
	//

	if ( databank.NumDataFiles () > 0 && 
		 NumberGenerator::RandomNumber ( 1000 ) == 0 ) {

		Data *data = new Data ();
		data->SetTitle ( NameGenerator::GenerateDataName ( "companyname", DATATYPE_DATA ) );
		data->SetDetails ( DATATYPE_DATA, NumberGenerator::RandomNumber ( 10 ) + 1, 0, 0 );
		if ( !databank.PutData ( data ) )
			delete data;

	}

	//
	// Generate some new logs
	//

	if ( NumberGenerator::RandomNumber ( 1000 ) == 0 ) {

		AccessLog *al = new AccessLog ();
		al->SetProperties ( &(game->GetWorld ()->date), WorldGenerator::GetRandomLocation ()->ip, " " );
		al->SetData1 ( "Accessed File" );
		logbank.AddLog (al);

	}

}
void CriminalScreenInterface::ArrestClick ( Button *button )
{

	CriminalScreenInterface *csi = (CriminalScreenInterface *) GetInterfaceScreen ( SCREEN_CRIMINALSCREEN );
	UplinkAssert (csi);

	if ( csi->recordindex != -1 ) {

		Computer *comp = game->GetWorld ()->GetComputer ( "Global Criminal Database" );
		UplinkAssert (comp);

		if ( comp->security.IsRunning_Proxy () ) {
			create_msgbox ( "Error", "Denied access by Proxy Server" );
			return;
		}

		Record *rec = comp->recordbank.GetRecord ( csi->recordindex );
		UplinkAssert (rec);

		char *name = rec->GetField ( RECORDBANK_NAME );
		UplinkAssert (name);

		char *convictions = rec->GetField ( "Convictions" );
		//UplinkAssert (convictions);

		// Only do this if the person now has at least 3 convicions
		// AND has broken parole

		int numconvictions = 0;
		bool brokenparole = false;

		if ( convictions ) {

			char *current = strchr ( convictions, '\n' );

			while ( current ) {
				++numconvictions;
				current = strchr ( current+1, '\n' );
			}

			brokenparole = strstr ( convictions, "parole" ) || strstr ( convictions, "Parole" );
		}

		if ( numconvictions >= 2 && brokenparole ) {

			// This person is going down

			Date rundate;
			rundate.SetDate ( &(game->GetWorld ()->date) );
			rundate.AdvanceMinute ( TIME_LEGALACTION );

			ArrestEvent *ae = new ArrestEvent ();
			ae->SetName ( name );
			ae->SetReason ( "breaking parole after 2 previous convictions" );
			ae->SetRunDate ( &rundate );
			game->GetWorld ()->scheduler.ScheduleEvent ( ae );

			rundate.AdvanceMinute ( TIME_LEGALACTION_WARNING * -1 );
			game->GetWorld ()->scheduler.ScheduleWarning ( ae, &rundate );

			char message [128];
			UplinkSnprintf ( message, sizeof ( message ), "Authorisation Accepted\nThis man will be arrested in %d hours.", TIME_LEGALACTION / 60 );

			create_msgbox ( "Arrest Authorised", message );

		}
		else {

			create_msgbox ( "Arrest Not Authorised", "Authorisation rejected\nA suspect must have 2 prior convictions "
													 "and must have broken parole before an arrest can be authorised remotely." );

		}

	}

}