1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

Style fixes

This commit is contained in:
goaaats 2018-01-08 23:23:09 +01:00
parent a25ee827a5
commit a543a149cc
2 changed files with 17 additions and 16 deletions

View file

@ -113,7 +113,7 @@ void Core::Session::updateLastSqlTime()
void Core::Session::startReplay( const std::string& folderpath ) void Core::Session::startReplay( const std::string& folderpath )
{ {
if( !boost::filesystem::exists(folderpath) ) if( !boost::filesystem::exists( folderpath ) )
{ {
getPlayer()->sendDebug( "Couldn't find folder." ); getPlayer()->sendDebug( "Couldn't find folder." );
return; return;
@ -121,31 +121,31 @@ void Core::Session::startReplay( const std::string& folderpath )
m_replayCache.clear(); m_replayCache.clear();
std::vector<std::tuple<uint64_t, std::string>> loadedSets; 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( folderpath ) ); it != boost::filesystem::directory_iterator(); ++it )
{ {
// Get the filename of the current element // Get the filename of the current element
auto filename = it->path().filename().string(); auto fileName = it->path().filename().string();
auto unixtime = atoi( filename.substr( 0, 10 ).c_str() ); 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() ) ); 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 ); return std::get< 0 >( left ) < std::get< 0 >( right );
} ); } );
int startTime = std::get<0>( loadedSets.at( 0 ) ); int startTime = std::get< 0 >( loadedSets.at( 0 ) );
for( auto thing : loadedSets ) for( auto set : loadedSets )
{ {
m_replayCache.push_back( std::tuple<uint64_t, std::string>( Util::getTimeSeconds() + ( std::get<0>( thing ) - startTime ), std::get<1>( thing ) ) ); 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>( thing ) + " for " + std::to_string( std::get<0>( thing ) - startTime ) ); g_log.info( "Registering " + std::get< 1 >( set ) + " for " + std::to_string( std::get< 0 >( set ) - startTime ) );
} }
getPlayer()->sendDebug( "Registered " + std::to_string( m_replayCache.size() ) + " sets for replay" ); getPlayer()->sendDebug( "Registered " + std::to_string( m_replayCache.size() ) + " sets for replay" );
@ -163,10 +163,11 @@ void Core::Session::update()
if( m_isReplaying ) if( m_isReplaying )
{ {
int at = 0; int at = 0;
for( auto const& set : m_replayCache ) { for( const auto& set : m_replayCache )
if( std::get<0>( set ) == Util::getTimeSeconds() ) {
if( std::get< 0 >( set ) == Util::getTimeSeconds() )
{ {
m_pZoneConnection->injectPacket( std::get<1>( set ), *getPlayer().get() ); m_pZoneConnection->injectPacket( std::get< 1 >( set ), *getPlayer().get() );
m_replayCache.erase( m_replayCache.begin() + at ); m_replayCache.erase( m_replayCache.begin() + at );
} }
at++; at++;

View file

@ -52,7 +52,7 @@ namespace Core {
bool m_isValid; bool m_isValid;
bool m_isReplaying; bool m_isReplaying;
std::vector<std::tuple<uint64_t, std::string>> m_replayCache; std::vector< std::tuple< uint64_t, std::string > > m_replayCache;
Network::GameConnectionPtr m_pZoneConnection; Network::GameConnectionPtr m_pZoneConnection;
Network::GameConnectionPtr m_pChatConnection; Network::GameConnectionPtr m_pChatConnection;