• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Compiling Avesta 0.6.1 Problem on outputmessage.cpp

Zeint

New Member
Joined
Dec 7, 2008
Messages
38
Reaction score
0
Location
Barcelona
Hello Otland!

Well, i have a little problem with my Avesta 0.6.1 for my 7.6 ot.

Image:
sinttulobsu.png


outputmessage.cpp:
Code:
	m_isOpen = true;
}

OutputMessagePool::~OutputMessagePool()
{
	InternalOutputMessageList::iterator it;
	for(it = m_outputMessages.begin(); it != m_outputMessages.end(); ++it){
		delete *it;
	}
	m_outputMessages.clear();
}

void OutputMessagePool::send(OutputMessage_ptr msg)
{
	m_outputPoolLock.lock();
	OutputMessage::OutputMessageState state = msg->getState();
	m_outputPoolLock.unlock();

	if(state == OutputMessage::STATE_ALLOCATED_NO_AUTOSEND){
		#ifdef __DEBUG_NET_DETAIL__
		std::cout << "Sending message - SINGLE" << std::endl;
		#endif

		if(msg->getConnection()){
			if(msg->getConnection()->send(msg)){
				// Note: if we ever decide to change how the pool works this will have to change
				m_outputPoolLock.lock();
				if(msg->getState() != OutputMessage::STATE_FREE) {
					msg->setState(OutputMessage::STATE_WAITING);
				}
				m_outputPoolLock.unlock();
			}
			else{
				msg->getProtocol()->onSendMessage(msg);
			}
		}
		else{
			#ifdef __DEBUG_NET__
			std::cout << "Error: [OutputMessagePool::send] NULL connection." << std::endl;
			#endif
		}
	}
	else{
		#ifdef __DEBUG_NET__
		std::cout << "Warning: [OutputMessagePool::send] State != STATE_ALLOCATED_NO_AUTOSEND" << std::endl;
		#endif
	}
}

void OutputMessagePool::sendAll()
{
	boost::recursive_mutex::scoped_lock lockClass(m_outputPoolLock);

	OutputMessageMessageList::iterator it;
	for(it = m_autoSendOutputMessages.begin(); it != m_autoSendOutputMessages.end(); ){
		OutputMessage_ptr omsg = *it;
		#ifdef __NO_PLAYER_SENDBUFFER__
		//use this define only for debugging
		bool v = 1;
		#else
		//It will send only messages bigger then 1 kb or with a lifetime greater than 10 ms
		bool v = omsg->getMessageLength() > 1024 || (m_frameTime - omsg->getFrame() > 10);
		#endif
		if(v){
			#ifdef __DEBUG_NET_DETAIL__
			std::cout << "Sending message - ALL" << std::endl;
			#endif

			if(omsg->getConnection()){
				if(omsg->getConnection()->send(omsg)){
					// Note: if we ever decide to change how the pool works this will have to change
					if(omsg->getState() != OutputMessage::STATE_FREE) {
						omsg->setState(OutputMessage::STATE_WAITING);
					}
				}
				else{
					omsg->getProtocol()->onSendMessage(omsg);
				}
			}
			else{
				#ifdef __DEBUG_NET__
				std::cout << "Error: [OutputMessagePool::send] NULL connection." << std::endl;
				#endif
			}

			it = m_autoSendOutputMessages.erase(it);
		}
		else{
			++it;
		}
	}
}

void OutputMessagePool::internalReleaseMessage(OutputMessage* msg)
{
	if(msg->getProtocol()){
		msg->getProtocol()->unRef();
#ifdef __DEBUG_NET_DETAIL__
		std::cout << "Removing reference to protocol " << msg->getProtocol() << std::endl;
#endif
	}
	else{
		std::cout << "No protocol found." << std::endl;
	}

	if(msg->getConnection()){
		msg->getConnection()->unRef();
#ifdef __DEBUG_NET_DETAIL__
		std::cout << "Removing reference to connection " << msg->getConnection() << std::endl;
#endif
	}
	else{
		std::cout << "No connection found." << std::endl;
	}

	msg->freeMessage();
	m_outputMessages.push_back(msg);
}

OutputMessage_ptr OutputMessagePool::getOutputMessage(Protocol* protocol, bool autosend /*= true*/)
{
	#ifdef __DEBUG_NET_DETAIL__
	std::cout << "request output message - auto = " << autosend << std::endl;
	#endif

	if(!m_isOpen){
		return OutputMessage_ptr();
	}

	boost::recursive_mutex::scoped_lock lockClass(m_outputPoolLock);

	if(protocol->getConnection() == NULL){
		return OutputMessage_ptr();
	}

	OutputMessage_ptr outputmessage;
	if(m_outputMessages.empty()) {
#ifdef __TRACK_NETWORK__
		if(m_allOutputMessages.size() >= 5000){
			std::cout << "High usage of outputmessages: " << std::endl;
			m_allOutputMessages.back()->PrintTrace();
		}
#endif
		outputmessage.reset(new OutputMessage,
			boost::bind(&OutputMessagePool::internalReleaseMessage, this, _1));

#ifdef __TRACK_NETWORK__
		m_allOutputMessages.push_back(outputmessage..get());
#endif
	} else {
		outputmessage.reset(m_outputMessages.back(),
			boost::bind(&OutputMessagePool::internalReleaseMessage, this, _1));
#ifdef __TRACK_NETWORK__
		// Print message trace
		if(outputmessage->getState() != OutputMessage::STATE_FREE) {
			std::cout << "Using allocated message, message trace:" << std::endl;
			outputmessage->PrintTrace();
		}
#else
		assert(outputmessage->getState() == OutputMessage::STATE_FREE);
#endif
		m_outputMessages.pop_back();
	}

	configureOutputMessage(outputmessage, protocol, autosend);
	return outputmessage;
}

void OutputMessagePool::configureOutputMessage(OutputMessage_ptr msg, Protocol* protocol, bool autosend)
{
	msg->Reset();
	if(autosend){
		msg->setState(OutputMessage::STATE_ALLOCATED);
		m_autoSendOutputMessages.push_back(msg);
	}
	else{
		msg->setState(OutputMessage::STATE_ALLOCATED_NO_AUTOSEND);
	}

	Connection* connection = protocol->getConnection();
	assert(connection != NULL);

	msg->setProtocol(protocol);
	protocol->addRef();
#ifdef __DEBUG_NET_DETAIL__
	std::cout << "Adding reference to protocol - " << protocol << std::endl;
#endif
	msg->setConnection(connection);
	connection->addRef();
#ifdef __DEBUG_NET_DETAIL__
	std::cout << "Adding reference to connection - " << connection << std::endl;
#endif
	msg->setFrame(m_frameTime);
}

"Wrong" line 208:

Code:
		assert(outputmessage->getState() == OutputMessage::STATE_FREE);

With this error, Avesta get crashes every time when people is playing...
If someone can help me... i'll be thankful , thx for your time.
 
Last edited:
The only thing I can think of is this. Hope it fixes it...
Code:
	m_isOpen = true;
}

OutputMessagePool::~OutputMessagePool()
{
	InternalOutputMessageList::iterator it;
	for(it = m_outputMessages.begin(); it != m_outputMessages.end(); ++it){
		delete *it;
	}
	m_outputMessages.clear();
}

void OutputMessagePool::send(OutputMessage_ptr msg)
{
	m_outputPoolLock.lock();
	OutputMessage::OutputMessageState state = msg->getState();
	m_outputPoolLock.unlock();

	if(state == OutputMessage::STATE_ALLOCATED_NO_AUTOSEND){
		#ifdef __DEBUG_NET_DETAIL__
		std::cout << "Sending message - SINGLE" << std::endl;
		#endif

		if(msg->getConnection()){
			if(msg->getConnection()->send(msg)){
				// Note: if we ever decide to change how the pool works this will have to change
				m_outputPoolLock.lock();
				if(msg->getState() != OutputMessage::STATE_FREE) {
					msg->setState(OutputMessage::STATE_WAITING);
				}
				m_outputPoolLock.unlock();
			}
			else{
				msg->getProtocol()->onSendMessage(msg);
			}
		}
		else{
			#ifdef __DEBUG_NET__
			std::cout << "Error: [OutputMessagePool::send] NULL connection." << std::endl;
			#endif
		}
	}
	else{
		#ifdef __DEBUG_NET__
		std::cout << "Warning: [OutputMessagePool::send] State != STATE_ALLOCATED_NO_AUTOSEND" << std::endl;
		#endif
	}
}

void OutputMessagePool::sendAll()
{
	boost::recursive_mutex::scoped_lock lockClass(m_outputPoolLock);

	OutputMessageMessageList::iterator it;
	for(it = m_autoSendOutputMessages.begin(); it != m_autoSendOutputMessages.end(); ){
		OutputMessage_ptr omsg = *it;
		#ifdef __NO_PLAYER_SENDBUFFER__
		//use this define only for debugging
		bool v = 1;
		#else
		//It will send only messages bigger then 1 kb or with a lifetime greater than 10 ms
		bool v = omsg->getMessageLength() > 1024 || (m_frameTime - omsg->getFrame() > 10);
		#endif
		if(v){
			#ifdef __DEBUG_NET_DETAIL__
			std::cout << "Sending message - ALL" << std::endl;
			#endif

			if(omsg->getConnection()){
				if(omsg->getConnection()->send(omsg)){
					// Note: if we ever decide to change how the pool works this will have to change
					if(omsg->getState() != OutputMessage::STATE_FREE) {
						omsg->setState(OutputMessage::STATE_WAITING);
					}
				}
				else{
					omsg->getProtocol()->onSendMessage(omsg);
				}
			}
			else{
				#ifdef __DEBUG_NET__
				std::cout << "Error: [OutputMessagePool::send] NULL connection." << std::endl;
				#endif
			}

			it = m_autoSendOutputMessages.erase(it);
		}
		else{
			++it;
		}
	}
}

void OutputMessagePool::internalReleaseMessage(OutputMessage* msg)
{
	if(msg->getProtocol())
	{
		msg->getProtocol()->unRef();
#ifdef __DEBUG_NET_DETAIL__
		std::cout << "Removing reference to protocol " << msg->getProtocol() << std::endl;
#endif
	}
	else
	{
		std::cout << "No protocol found." << std::endl;
	}

	if(msg->getConnection())
	{
		msg->getConnection()->unRef();
#ifdef __DEBUG_NET_DETAIL__
		std::cout << "Removing reference to connection " << msg->getConnection() << std::endl;
#endif
	}
	else
	{
		std::cout << "No connection found." << std::endl;
	}

	msg->freeMessage();
	m_outputMessages.push_back(msg);
}

OutputMessage_ptr OutputMessagePool::getOutputMessage(Protocol* protocol, bool autosend /*= true*/)
{
	#ifdef __DEBUG_NET_DETAIL__
	std::cout << "request output message - auto = " << autosend << std::endl;
	#endif

	if(!m_isOpen)
	{
		return OutputMessage_ptr();
	}

	boost::recursive_mutex::scoped_lock lockClass(m_outputPoolLock);

	if(protocol->getConnection() == NULL)
	{
		return OutputMessage_ptr();
	}

	OutputMessage_ptr outputmessage;
	if(m_outputMessages.empty()) 
	{
#ifdef __TRACK_NETWORK__
		if(m_allOutputMessages.size() >= 5000){
			std::cout << "High usage of outputmessages: " << std::endl;
			m_allOutputMessages.back()->PrintTrace();
		}
#endif
		outputmessage.reset(new OutputMessage,
			boost::bind(&OutputMessagePool::internalReleaseMessage, this, _1));

#ifdef __TRACK_NETWORK__
		m_allOutputMessages.push_back(outputmessage..get());
#endif
	} else 
	{
		outputmessage.reset(m_outputMessages.back(),
			boost::bind(&OutputMessagePool::internalReleaseMessage, this, _1));
#ifdef __TRACK_NETWORK__
		// Print message trace
		if(outputmessage->getState() != OutputMessage::STATE_FREE) 
		{
			std::cout << "Using allocated message, message trace:" << std::endl;
			outputmessage->PrintTrace();
		}
		else   
		{
		assert(outputmessage->getState() == OutputMessage::STATE_FREE);
		}
#endif
		m_outputMessages.pop_back();
	}

	configureOutputMessage(outputmessage, protocol, autosend);
	return outputmessage;
}

void OutputMessagePool::configureOutputMessage(OutputMessage_ptr msg, Protocol* protocol, bool autosend)
{
	msg->Reset();
	if(autosend){
		msg->setState(OutputMessage::STATE_ALLOCATED);
		m_autoSendOutputMessages.push_back(msg);
	}
	else{
		msg->setState(OutputMessage::STATE_ALLOCATED_NO_AUTOSEND);
	}

	Connection* connection = protocol->getConnection();
	assert(connection != NULL);

	msg->setProtocol(protocol);
	protocol->addRef();
#ifdef __DEBUG_NET_DETAIL__
	std::cout << "Adding reference to protocol - " << protocol << std::endl;
#endif
	msg->setConnection(connection);
	connection->addRef();
#ifdef __DEBUG_NET_DETAIL__
	std::cout << "Adding reference to connection - " << connection << std::endl;
#endif
	msg->setFrame(m_frameTime);
}

I am not very good at C++ so I would recommend making a backup of your original outputmessage.cpp before replacing it.

EDIT: You are only allowed to Bump you post ONCE every 24 hours. Next time, when you make a post, please wait 24 hours before bumping it. If you haven't received replies yet, that just means that the people looking at your post don't have a solution for it. It is against the rules to Bump your post in increments less than 24 hours.
 
Last edited:
Don't use that engine, it's not stable. Use the latest avesta instead just compile it with __76__ and it will be 7.6
 
Back
Top