Re: Update pinfo [message #438879 is a reply to message #438876] |
Thu, 04 November 2010 15:46   |
 |
danpaul88
Messages: 5795 Registered: June 2004 Location: England
Karma:
|
General (5 Stars) |
|
|
Gen_Blacky wrote on Thu, 04 November 2010 21:11 |
sub pinfotimer
{
POE::Session->create
(
inline_states =>
{
_start => sub
{
RenRemCMD( "pinfo" );
$_[HEAP]->{next_alarm_time} = int( time() ) + 30;
$_[KERNEL]->alarm( tick => $_[HEAP]->{next_alarm_time} );
},
tick => sub
{
RenRemCMD( "pinfo" );
$_[HEAP]->{next_alarm_time} = int( time() ) + 30;
$_[KERNEL]->alarm( restart => $_[HEAP]->{next_alarm_time} );
},
restart => sub
{
RenRemCMD( "pinfo" );
$_[HEAP]->{next_alarm_time} = int( time() ) + 30;
$_[KERNEL]->alarm( tick => $_[HEAP]->{next_alarm_time} );
},
}
);
}
|
You can simplify this bit to
sub pinfotimer
{
POE::Session->create
(
inline_states =>
{
_start => sub
{
$_[KERNEL]->yield('tick');
},
tick => sub
{
RenRemCMD( "pinfo" );
$_[HEAP]->{next_alarm_time} = int( time() ) + 30;
$_[KERNEL]->alarm( tick => $_[HEAP]->{next_alarm_time} );
}
}
);
}
To reduce code duplication. Also, unless you really need to store the alarm time on the heap, you can reduce
$_[HEAP]->{next_alarm_time} = int( time() ) + 30;
$_[KERNEL]->alarm( tick => $_[HEAP]->{next_alarm_time} );
To
$_[KERNEL]->alarm( tick => int( time() ) + 30 );
As for lagging the FDS, highly unlikely, but since BRenBot calls gameinfo and playerinfo every 20 seconds I don't see the point of calling yet another function for effectively the same thing?
|
|
|