Exemple #1
0
bool Server::ZCom_cbConnectionRequest( ZCom_ConnID id, ZCom_BitStream &_request, ZCom_BitStream &reply )
{
	if(network.isBanned(id))
	{
		reply.addInt(Network::ConnectionReply::Banned, 8);
		return false;
	}
	else if(network.clientRetry)
	{
		reply.addInt(Network::ConnectionReply::Retry, 8);
		return false;
	}
	else if ( !m_preShutdown )
	{
		console.addLogMsg("* CONNECTION REQUESTED");
		//_reply.addInt(Network::ConnectionReply::Ok, 8);
		reply.addString( game.getMod().c_str() );
		reply.addString( game.level.getName().c_str() );

		return true;
	}
	else
	{
		reply.addInt(Network::ConnectionReply::Refused, 8);
		return false;
	}
}
Exemple #2
0
MapInfoObject::MapInfoObject(ZCom_Control *_control, unsigned int zoidlevel, const MapInfo & minfo)
{
	#ifndef _ZOID_USED_NEW_VERSION_
		m_node->registerNodeDynamic(m_classid, _control);
	#else
		_control->ZCom_registerDynamicNode( m_node, m_classid );
	#endif

	#ifdef _DEBUG
		LogHandler::getInstance()->LogToFile("New Node " + GetObjectName() + " of name " + minfo.Name);
	#endif


	// only do that on authority
	if(m_node->getRole() == eZCom_RoleAuthority)
	{
		// add announcement data
		ZCom_BitStream *adata = new ZCom_BitStream();
		adata->addString(minfo.Name.c_str());
		adata->addString(minfo.Type.c_str());
		adata->addString(minfo.Music.c_str());
		adata->addSignedInt(minfo.MusicLoop, 16);
		m_node->setAnnounceData(adata);


		// change zoidlevel
		m_node->applyForZoidLevel( zoidlevel );
		//m_node->removeFromZoidLevel( 1 );
	}


}
Exemple #3
0
void Client::requestPlayer(PlayerOptions const& playerOptions)
{
	ZCom_BitStream *req = new ZCom_BitStream;
	req->addInt(Network::PLAYER_REQUEST,8);
	req->addString( playerOptions.name.c_str() );
	req->addInt(playerOptions.colour, 24);
	req->addSignedInt(playerOptions.team, 8);
	req->addInt(playerOptions.uniqueID, 32);
	ZCom_sendData( network.getServerID(), req, eZCom_ReliableOrdered );
}
/***********************************************************************
 * connect to a server given an address + port
 ***********************************************************************/
void MainServerClient::ConnectToServer(const std::string & address, const std::string & login, 
								 const std::string & password, const std::string & excpectedversion)
{
	if(m_connected)
		return;

	// create target address 
	ZCom_Address dst_udp;
	dst_udp.setAddress( eZCom_AddressUDP, 0, address.c_str() );

	//prepare login info
    ZCom_BitStream *req = new ZCom_BitStream();
	req->addString( login.c_str() );
	req->addString( password.c_str() );
	req->addString( excpectedversion.c_str() );

	// connect to server
	if (!ZCom_Connect( dst_udp, req))
		LogHandler::getInstance()->LogToFile("Main client: unable to start connecting!", 2);
}
Exemple #5
0
/***********************************************************************
 * connect to a server given an address + port
 ***********************************************************************/
void GameClient::ConnectToServer(const std::string & servername, const std::string & address, 
								 const std::string & login, 
								 const std::string & password, const std::string & excpectedversion,
								 GameClientCallbackBase * callback)
{
	m_callback = callback;

	if(m_connected)
	{
		if(m_servername == servername)
		{
			LogHandler::getInstance()->LogToFile("Zoid: Already connected to chat server - skipping connection", 2);
			return;
		}
		else
			CloseConnection();
	}

	m_servername = servername;

	std::string md5pass = MD5(password).hexdigest();


	// create target address 
	ZCom_Address dst_udp;
	dst_udp.setAddress( eZCom_AddressUDP, 0, address.c_str() );

	//prepare login info
    ZCom_BitStream *req = new ZCom_BitStream();
	req->addString( login.c_str() );
	req->addString( md5pass.c_str() );
	req->addString( excpectedversion.c_str() );

	// connect to server
	LogHandler::getInstance()->LogToFile("Game client connecting to "+address, 2);

	//m_id = ZCom_Connect( dst_udp, req);
	if (!ZCom_Connect( dst_udp, req))
		LogHandler::getInstance()->LogToFile("Game client: unable to start connecting!", 2);
}