mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-30 08:07:46 +00:00
Style, cleanup
This commit is contained in:
parent
f6ed8125b0
commit
9f145c28c2
2 changed files with 26 additions and 18 deletions
|
@ -111,9 +111,9 @@ void Core::Session::updateLastSqlTime()
|
|||
m_lastSqlTime = static_cast< uint32_t >( Util::getTimeSeconds() );
|
||||
}
|
||||
|
||||
void Core::Session::startReplay( const std::string& folderpath )
|
||||
void Core::Session::startReplay( const std::string& path )
|
||||
{
|
||||
if( !boost::filesystem::exists( folderpath ) )
|
||||
if( !boost::filesystem::exists( path ) )
|
||||
{
|
||||
getPlayer()->sendDebug( "Couldn't find folder." );
|
||||
return;
|
||||
|
@ -123,19 +123,21 @@ void Core::Session::startReplay( const std::string& folderpath )
|
|||
|
||||
std::vector< std::tuple< uint64_t, std::string > > loadedSets;
|
||||
|
||||
for( auto it = boost::filesystem::directory_iterator( boost::filesystem::path( folderpath ) ); it != boost::filesystem::directory_iterator(); ++it )
|
||||
for( auto it = boost::filesystem::directory_iterator( boost::filesystem::path( path ) );
|
||||
it != boost::filesystem::directory_iterator(); ++it )
|
||||
{
|
||||
// Get the filename of the current element
|
||||
auto fileName = it->path().filename().string();
|
||||
auto unixTime = atoi( fileName.substr( 0, 10 ).c_str() );
|
||||
|
||||
if( unixTime > 1000000000)
|
||||
if( unixTime > 1000000000 )
|
||||
{
|
||||
loadedSets.push_back( std::tuple< uint64_t, std::string >( unixTime, it->path().string() ) );
|
||||
}
|
||||
}
|
||||
|
||||
sort( loadedSets.begin(), loadedSets.end(), []( const std::tuple< uint64_t, std::string >& left, const std::tuple< uint64_t, std::string >& right)
|
||||
sort( loadedSets.begin(), loadedSets.end(),
|
||||
[]( const std::tuple< uint64_t, std::string >& left, const std::tuple< uint64_t, std::string >& right)
|
||||
{
|
||||
return std::get< 0 >( left ) < std::get< 0 >( right );
|
||||
} );
|
||||
|
@ -144,7 +146,9 @@ void Core::Session::startReplay( const std::string& folderpath )
|
|||
|
||||
for( auto set : loadedSets )
|
||||
{
|
||||
m_replayCache.push_back( std::tuple<uint64_t, std::string>( Util::getTimeSeconds() + ( std::get< 0 >( set ) - startTime ), std::get< 1 >( set ) ) );
|
||||
m_replayCache.push_back( std::tuple< uint64_t, std::string >(
|
||||
Util::getTimeSeconds() + ( std::get< 0 >( set ) - startTime ), std::get< 1 >( set ) ) );
|
||||
|
||||
g_log.info( "Registering " + std::get< 1 >( set ) + " for " + std::to_string( std::get< 0 >( set ) - startTime ) );
|
||||
}
|
||||
|
||||
|
@ -158,10 +162,8 @@ void Core::Session::stopReplay()
|
|||
m_replayCache.clear();
|
||||
}
|
||||
|
||||
void Core::Session::update()
|
||||
void Core::Session::processReplay()
|
||||
{
|
||||
if( m_isReplaying )
|
||||
{
|
||||
int at = 0;
|
||||
for( const auto& set : m_replayCache )
|
||||
{
|
||||
|
@ -172,7 +174,12 @@ void Core::Session::update()
|
|||
}
|
||||
at++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Session::update()
|
||||
{
|
||||
if( m_isReplaying )
|
||||
processReplay();
|
||||
|
||||
if( m_pZoneConnection )
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace Core {
|
|||
|
||||
void startReplay( const std::string& folderpath );
|
||||
void stopReplay();
|
||||
void processReplay();
|
||||
|
||||
void close();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue