本文整理汇总了C++中Date::AdvanceMinute方法的典型用法代码示例。如果您正苦于以下问题:C++ Date::AdvanceMinute方法的具体用法?C++ Date::AdvanceMinute怎么用?C++ Date::AdvanceMinute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::AdvanceMinute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ManageOldLogs
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;
}
}
}
}
示例2: Update
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);
}
}
示例3: ArrestClick
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." );
}
}
}