1st timestamp iteration and vector cleanup
This commit is contained in:
@@ -1438,9 +1438,9 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
|
|||||||
// ){
|
// ){
|
||||||
// SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
// SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
||||||
} else {
|
} else {
|
||||||
// @FIXME: debug only - final poition is gamestart
|
// @FIXME: debug only - final position is gamestart
|
||||||
session->AddPlayerLastGame((unsigned long)time(NULL));
|
session->AddPlayerLastGame((unsigned long)time(NULL));
|
||||||
LOG_ERROR("TimeStamp stored: " << session->GetPlayerLastGames().front());
|
//LOG_ERROR("TimeStamp stored: " << session->GetPlayerLastGames().front());
|
||||||
MoveSessionToGame(game, session, joinGame.autoleave(), false);
|
MoveSessionToGame(game, session, joinGame.autoleave(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ using namespace std::chrono;
|
|||||||
using namespace boost::chrono;
|
using namespace boost::chrono;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SERVER_ALLOWED_RANKING_GAMES_PER_MINUTES 5
|
||||||
|
#define SERVER_ALLOWED_RANKING_GAMES_MINUTES 60
|
||||||
|
|
||||||
SessionData::SessionData(boost::shared_ptr<boost::asio::ip::tcp::socket> sock, SessionId id, SessionDataCallback &cb, boost::asio::io_service &ioService)
|
SessionData::SessionData(boost::shared_ptr<boost::asio::ip::tcp::socket> sock, SessionId id, SessionDataCallback &cb, boost::asio::io_service &ioService)
|
||||||
: m_socket(sock), m_id(id), m_state(SessionData::Init), m_readyFlag(false), m_wantsLobbyMsg(true),
|
: m_socket(sock), m_id(id), m_state(SessionData::Init), m_readyFlag(false), m_wantsLobbyMsg(true),
|
||||||
m_activityTimeoutSec(0), m_activityWarningRemainingSec(0), m_initTimeoutTimer(ioService), m_globalTimeoutTimer(ioService),
|
m_activityTimeoutSec(0), m_activityWarningRemainingSec(0), m_initTimeoutTimer(ioService), m_globalTimeoutTimer(ioService),
|
||||||
@@ -429,9 +432,28 @@ SessionData::IsPlayerAllowedToJoinLimitRank()
|
|||||||
{
|
{
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
|
|
||||||
// @TODO: iterate m_lastGames
|
// #define SERVER_ALLOWED_RANKING_GAMES_PER_MINUTES 5
|
||||||
|
// #define SERVER_ALLOWED_RANKING_GAMES_MINUTES 60
|
||||||
|
|
||||||
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
|
|
||||||
return true;
|
// @TODO: iterate m_lastGames
|
||||||
|
unsigned long then = (unsigned long)time(NULL) - (unsigned long)(SERVER_ALLOWED_RANKING_GAMES_MINUTES * 10);
|
||||||
|
|
||||||
|
unsigned long num = (unsigned long)SERVER_ALLOWED_RANKING_GAMES_PER_MINUTES;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for(std::vector<T>::iterator timeStamp = m_lastGames.begin(); timeStamp != m_lastGames.end(); ++timeStamp) {
|
||||||
|
if(timeStamp > then)
|
||||||
|
count++;
|
||||||
|
else
|
||||||
|
m_lastGames.erase(timeStamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count < num)
|
||||||
|
retVal = true;
|
||||||
|
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
|
|||||||
@@ -39,8 +39,6 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define SERVER_MAX_GUEST_USERS_LOBBY 50 // LG: Maximum number of guests users in lobby allowed
|
#define SERVER_MAX_GUEST_USERS_LOBBY 50 // LG: Maximum number of guests users in lobby allowed
|
||||||
#define SERVER_ALLOWED_RANKING_GAMES_PER_MINUTES 5
|
|
||||||
#define SERVER_ALLOWED_RANKING_GAMES_MINUTES 60
|
|
||||||
|
|
||||||
SessionManager::SessionManager()
|
SessionManager::SessionManager()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user