Jump to content

Channel status is always Norm


Recommended Posts

Hello, i have a little problem with channel status, the problem comes from desc_client.cpp where, the function void CLIENT_DESC::UpdateChannelStatus(DWORD t, bool fForce) is not working properly. The function defines 4 states for the server, OFFLINE, NORM, BUSY and FULL. I parsed the variables into a syslog from the function and i realised that the iTotal it's always 0, so the server works in only 2 states, OFFLINE and NORM. Can anybody help me to fix this problem? I want to implement the count of players of the servers into the login interface. Another test i've made is with the command /who ingame, command which count properly the numbler of players.

Here is the function:

void CLIENT_DESC::UpdateChannelStatus(DWORD t, bool fForce)
{
    enum {
        // CHANNELSTATUS_UPDATE_PERIOD = 5*60*1000,    // 5분마다
        CHANNELSTATUS_UPDATE_PERIOD = 1*1000,    // 5분마다
    };
    DWORD tLCSUP = m_tLastChannelStatusUpdateTime+CHANNELSTATUS_UPDATE_PERIOD;
    if (fForce || tLCSUP < t) {

        int iTotal;
        int * paiEmpireUserCount;
        int iLocal;
        DESC_MANAGER::instance().GetUserCount(iTotal, &paiEmpireUserCount, iLocal);
        TChannelStatus channelStatus;
        channelStatus.nPort = mother_port;
#if defined(__CHANNEL_STATUS_UPDATE__)
        channelStatus.player_count = iTotal;
#endif        

        if (g_bNoMoreClient) channelStatus.bStatus = 0;
        else channelStatus.bStatus = iTotal > g_iFullUserCount ? 3 : iTotal > g_iBusyUserCount ? 2 : 1;
        sys_log(0, "Total %d , FullUserCount %d , BusyUserCount %d", iTotal, g_iFullUserCount, g_iBusyUserCount);
        DBPacket(HEADER_GD_UPDATE_CHANNELSTATUS, 0, &channelStatus, sizeof(channelStatus));
        m_tLastChannelStatusUpdateTime = t;
    }
}

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

not the best solution, but you can try to get the number from query

		std::auto_ptr<SQLMsg> pmsg(DBManager::instance().DirectQuery("SELECT COUNT(*) FROM player.player WHERE DATE_SUB(NOW(), INTERVAL 5 MINUTE) < last_play"));

		int count = 0;
		if ( pmsg->Get()->uiNumRows > 0 )
		{
			MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult);
			str_to_number(count, row[0]);
		}

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.