Example #1
0
void CRoom::PlayerClearBlock(CPlayer *player, const s32 *rows, s32 count)
{
	SG_ASSERT( player != NULL );
	SG_ASSERT( player->GetRoom() == this );
	SG_ASSERT( PlayerInRoom(player) );

	SERVER_LOG_DEBUG( "player:" << player->UserId().c_str() << " clear " << count << " rows" );

	_ClearBlock( player, rows, count );
}
Example #2
0
void CRoom::PlayerForceLeave(CPlayer *player)
{
	SG_ASSERT( player != NULL );
	SG_ASSERT( player->GetRoom() == this );
	SG_ASSERT( PlayerInRoom(player) );
	SG_ASSERT( m_pStateMachine != NULL );

	SERVER_LOG_DEBUG( "player:" << player->UserId().c_str() << " force leave" );

	if( m_pStateMachine->CurState() == E_RoomState_InGame )
	{
		SERVER_LOG_DEBUG( "player:" << player->UserId().c_str() << " force leave, game over" );

		SG_ASSERT( player->CurState() == E_PlayerState_InGame );
		PlayerLost( player );
	}

	CRoomBase::PlayerLeave( player );
}
Example #3
0
void CRoom::PlayerPutBlock(CPlayer *player, s32 blockid, s32 column)
{
	SG_ASSERT( player != NULL );
	SG_ASSERT( player->GetRoom() == this );
	SG_ASSERT( PlayerInRoom(player) );

	SERVER_LOG_DEBUG( "player:" << player->UserId().c_str() << " put block:" << blockid << " at:" << column );

	_PutBlock( player, blockid, column );
}
Example #4
0
bool CBuiltinPacketHandler::on_message(
        const net::TCommonMessageHeader& header // 包头,包头的size为包体大小,不包含header本身
      , size_t finished_size            // 已经接收到的大小
      , const char* buffer              // 当前收到的数据
      , size_t buffer_size)
{
    SERVER_LOG_TRACE("enter %s.\n", __FUNCTION__);

    if (finished_size+buffer_size == header.size)
    {
        // 完整包体
        if (_response_context.response_buffer != NULL)
        {
            SERVER_LOG_ERROR("%s is not NULL.\n", _response_context.to_string().c_str());
        }

        // 防止on_message()抛异常
        const char* request_buffer = _request_context.request_buffer;
        _request_context.request_buffer = NULL;

        if (!_message_observer->on_message(header
                                        , request_buffer
                                        , &_response_context.response_buffer
                                        , &_response_context.response_size))
        {
            SERVER_LOG_DEBUG("%s on_message ERROR.\n", _connection->str().c_str());
            return false;
        }

        if ((0 == _response_context.response_size)
         && (_response_context.response_buffer != NULL))
        {
            SERVER_LOG_WARN("%s.\n", _response_context.to_string().c_str());
        }
        else
        {
            SERVER_LOG_DEBUG("%s.\n", _response_context.to_string().c_str());
        }
    }

    return true;
}
Example #5
0
void CRoom::PlayerLost(CPlayer *player)
{
	SG_ASSERT( player != NULL );
	SG_ASSERT( player->GetRoom() == this );
	SG_ASSERT( PlayerInRoom(player) );

	SERVER_LOG_DEBUG( "player:" << player->UserId().c_str() << " lost" );

	_GameEnd( player );
	_NotifyGameEnd( player->UserId() );
}
Example #6
0
void CLoginRpcClient::OnRecv(const byte *pPkg, s32 nPkgLen)
{
	s32 msgId = *((s32*)pPkg);

	SERVER_LOG_DEBUG( "client:" << GetId() << " recv rpc pkg, len=" << nPkgLen << " ,msgId=" << msgId );

	map<int, ProtoProc>::iterator it = m_mapProtoProc.find( msgId );
	if( it != m_mapProtoProc.end() )
	{
		(this->*it->second)( pPkg+MSG_ID_LEN, nPkgLen-MSG_ID_LEN );
	}
	else
	{
		SERVER_LOG_ERROR( "client:" << GetId() << " not found msg process, msgId=" << msgId );
	}
}
Example #7
0
void CRoom::PlayerReady(CPlayer *player)
{
	SG_ASSERT( player != NULL );
	SG_ASSERT( player->GetRoom() == this );
	SG_ASSERT( PlayerInRoom(player) );

	s32 ret = player->Ready();
	_PlayerReadyResponse( player, ret );

	if( ret == sglib::errorcode::E_ErrorCode_Success )
	{
		SERVER_LOG_DEBUG( "player:" << player->UserId().c_str() << " ready" );

		_NotifyPlayerReady( player );
		_CheckGameStart();
	}
}