diff --git a/src/servers/sapphire_zone/Session.cpp b/src/servers/sapphire_zone/Session.cpp index 69a41237..067571c7 100644 --- a/src/servers/sapphire_zone/Session.cpp +++ b/src/servers/sapphire_zone/Session.cpp @@ -113,7 +113,7 @@ void Core::Session::updateLastSqlTime() void Core::Session::startReplay( const std::string& folderpath ) { - if( !boost::filesystem::exists(folderpath) ) + if( !boost::filesystem::exists( folderpath ) ) { getPlayer()->sendDebug( "Couldn't find folder." ); return; @@ -121,31 +121,31 @@ void Core::Session::startReplay( const std::string& folderpath ) m_replayCache.clear(); - std::vector> 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 ) { // Get the filename of the current element - auto filename = it->path().filename().string(); - auto unixtime = atoi( filename.substr( 0, 10 ).c_str() ); + 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( 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& left, const std::tuple& 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( Util::getTimeSeconds() + ( std::get<0>( thing ) - startTime ), std::get<1>( thing ) ) ); - g_log.info( "Registering " + std::get<1>( thing ) + " for " + std::to_string( std::get<0>( thing ) - startTime ) ); + m_replayCache.push_back( std::tuple( 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 ) ); } getPlayer()->sendDebug( "Registered " + std::to_string( m_replayCache.size() ) + " sets for replay" ); @@ -163,10 +163,11 @@ void Core::Session::update() if( m_isReplaying ) { int at = 0; - for( auto const& set : m_replayCache ) { - if( std::get<0>( set ) == Util::getTimeSeconds() ) + for( const auto& set : m_replayCache ) + { + 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 ); } at++; diff --git a/src/servers/sapphire_zone/Session.h b/src/servers/sapphire_zone/Session.h index 95f5b69d..d16e9b9e 100644 --- a/src/servers/sapphire_zone/Session.h +++ b/src/servers/sapphire_zone/Session.h @@ -52,7 +52,7 @@ namespace Core { bool m_isValid; bool m_isReplaying; - std::vector> m_replayCache; + std::vector< std::tuple< uint64_t, std::string > > m_replayCache; Network::GameConnectionPtr m_pZoneConnection; Network::GameConnectionPtr m_pChatConnection;