コード例 #1
0
void CriminalScreenInterface::UpdateScreen ()
{

	if ( IsVisible () ) {

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

		Record *rec = comp->recordbank.GetRecord ( recordindex );
		char *thisname = rec->GetField ( RECORDBANK_NAME );
		char *history = rec->GetField ( "Convictions" );

		Person *person = game->GetWorld ()->GetPerson ( thisname );

		// Update display with the current record

		if ( thisname ) EclGetButton ( "criminal_name" )->SetCaption ( thisname );
		if ( history ) EclGetButton ( "criminal_history" )->SetCaption ( history );

		// Show a photo

		if ( person ) {

			char filename [256];
			UplinkSnprintf ( filename, sizeof ( filename ), "photos/image%d.tif", person->photoindex );
			button_assignbitmap ( "criminal_photo", filename );

		}
		else {

			button_assignbitmap ( "criminal_photo", "photos/image0.tif" );

		}

	}

}
コード例 #2
0
void CriminalScreenInterface::AddConvictionClick ( Button *button )
{

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

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

		char *newconviction = EclGetButton ( "criminal_newconvictiontext" )->caption;

		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 *existing = rec->GetField ( "Convictions" );
		//UplinkAssert (existing);
		
		if ( existing ) {

			std::ostrstream newconvictions;

			if ( strstr ( existing, "None" ) == NULL )
				newconvictions << existing << "\n";

			newconvictions << newconviction
						   << '\x0';

			rec->ChangeField ( "Convictions", newconvictions.str () );

			newconvictions.rdbuf()->freeze( 0 );
			//delete [] newconvictions.str ();

		}

		EclGetButton ( "criminal_newconvictiontext" )->SetCaption ( "" );

		csi->UpdateScreen ();

	}

}
コード例 #3
0
void UserIDScreenInterface::ProceedClick ( Button *button )
{

	// If disconnected which can happend when dialling.

	if ( !game->GetWorld ()->GetPlayer ()->IsConnected () )
		return;
	
	char *name = EclGetButton ( "useridscreen_name" )->caption;
	char *code = EclGetButton ( "useridscreen_code" )->caption;

	if ( strlen ( name ) >= SIZE_PERSON_NAME )
		name [ SIZE_PERSON_NAME - 1 ] = '\0';

	if ( strlen ( code ) >= 64 )
		code [ 64 - 1 ] = '\0';

	// Look up that code in this computer's records

	UserIDScreen *uid = (UserIDScreen *) game->GetInterface ()->GetRemoteInterface ()->GetComputerScreen ();
	UplinkAssert (uid);
	Computer *comp = uid->GetComputer ();
	UplinkAssert (comp);

	Record *rec = comp->recordbank.GetRecordFromNamePassword ( name, code );

	if ( rec ) {

        SgPlaySound ( RsArchiveFileOpen("sounds/login.wav"), "sounds/login.wav", false );

		// This is our code

		int security;
		char *securitytext = rec->GetField ( RECORDBANK_SECURITY );
		if ( securitytext )
			sscanf ( securitytext, "%d", &security );
		else
			security = 10;

		game->GetInterface ()->GetRemoteInterface ()->SetSecurity ( name, security );

		// Add this into the computer's logs

		AccessLog *log = new AccessLog ();
		char logdetails [256];
		UplinkSnprintf ( logdetails, sizeof ( logdetails ), "User [%s] logged on (level %d)", name, security );
		log->SetProperties ( &(game->GetWorld ()->date),
							 game->GetWorld ()->GetPlayer ()->GetConnection ()->GetGhost (), "PLAYER" );
		log->SetData1 ( logdetails );

		comp->logbank.AddLog ( log );

		if ( strcmp ( name, "admin" ) == 0 )
			game->GetWorld ()->GetPlayer ()->GetConnection ()->BeginTrace ();			// Always trace admin access

		if ( uid->nextpage != -1 )
			game->GetInterface ()->GetRemoteInterface ()->RunScreen ( uid->nextpage, uid->GetComputer () );

		return;

	}

	// If we get this far then the access code is not valid

	EclRegisterCaptionChange ( "useridscreen_message", "Invalid Name or Code" );

}
コード例 #4
0
void CriminalScreenInterface::Update ()
{

	if ( searchname && IsVisible () ) {

		int timems = (int)EclGetAccurateTime () - lastupdate;

		if ( timems > 100 ) {

			// We are searching for a record

			// Is this one it?

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

			// Have we searched all records?

			//if ( recordindex == comp->recordbank.records.Size () ) {
			if ( recordindex == -1 ) {

				delete [] searchname;
				searchname = NULL;
				recordindex = -1;
				return;

			}

			Record *rec = comp->recordbank.GetRecord ( recordindex );
			char *thisname = rec->GetField ( RECORDBANK_NAME );
			UplinkAssert (thisname);
			char *lowercasethisname = LowerCaseString (thisname);

			// Update display with the current record

			UpdateScreen ();


			if ( strcmp ( searchname, lowercasethisname ) == 0 ) {

				// Record found - stop searching

				delete [] searchname;
				searchname = NULL;

			}
			else {

				// Record not found

				//recordindex++;
				recordindex = comp->recordbank.FindNextRecordIndexNameNotSystemAccount ( recordindex );

			}

			delete [] lowercasethisname;
			lastupdate = (int)EclGetAccurateTime ();

		}

	}

}
コード例 #5
0
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." );

		}

	}

}