Example #1
0
/***********************************************************
data received from the server
***********************************************************/
void GameClient::ZCom_cbDataReceived( ZCom_ConnID _id, ZCom_BitStream &_data )
{
	//check message type
	unsigned int type = _data.getInt(4);

	switch(type)
	{
		//player is in waiting queue
		case 0:
			//inform user through the gui
			InternalWorkpile::getInstance()->AddEvent(new GameErrorMessageEvent("Map server is full. You have been queued for connection. Please wait for a moment you will get connected automatically..."));
		break;

		//change zoidlevel
		case 1:
			unsigned int newlvl = _data.getInt(32);

			std::stringstream strs;
			strs<<"Game Client: Changing zoidlevel to: "<<newlvl;
			LogHandler::getInstance()->LogToFile(strs.str(), 2);   

			ZCom_requestZoidMode(newlvl, 1);
		break;


	}
}
Example #2
0
/***********************************************************************
 * called when initiated connection process yields a result
 ***********************************************************************/
void GameClient::ZCom_cbConnectResult( ZCom_ConnID _id, eZCom_ConnectResult _result, ZCom_BitStream &_reply )
{
	m_zoi_id = _id;
	m_id = _reply.getInt(32);
	std::string reason(_reply.getStringStatic());

	std::stringstream strs;
	strs<<"Game Client: The connection process for: "<<m_zoi_id<<" returned with resultcode "<<_result<<", the reply was "<<reason;
	LogHandler::getInstance()->LogToFile(strs.str(), 2);   

	if ( _result != eZCom_ConnAccepted )
	{
		m_connected = false;
		if(reason == "")
			reason = "Server not reachable";

		InternalWorkpile::getInstance()->AddEvent(new GameErrorMessageEvent("Problem connecting to game server " + m_servername + " - " + reason));
	}
	else
	{
		m_connected = true;
		ZCom_requestDownstreamLimit(m_zoi_id, m_downpacketpersecond, m_downbyteperpacket);

		#ifndef _ZOID_USED_NEW_VERSION_
		ZCom_requestZoidMode( m_zoi_id, 1 );
		#else
		ZCom_changeObjectChannelSubscription( m_zoi_id, 1, eZCom_Subscribe );
		#endif
	}
}
Example #3
0
void Client::ZCom_cbConnectResult( ZCom_ConnID _id, eZCom_ConnectResult _result, ZCom_BitStream &_reply )
{
    if (_result == eZCom_ConnAccepted)
    {
        printf("Connection established. \n");
        ZCom_requestZoidMode(_id, 1);
        server_id = _id;
    }
    else
        printf("Connection failed\n");
}
Example #4
0
	void NetWorld::ZCom_cbConnectResult( ZCom_ConnID _id, eZCom_ConnectResult _result, ZCom_BitStream &_reply )
	{
		if (_result == eZCom_ConnAccepted)
		{
			ZCom_requestZoidMode(_id, zU16(1));
			ZCom_requestDownstreamLimit(_id, (zU16)50, (zU16)65535 );
		}
		else
		{
			// connection failed
			std::cout << "Connection failed!" << std::endl;
		}
	}
Example #5
0
/***********************************************************************
 * called when initiated connection process yields a result
 ***********************************************************************/
void MainServerClient::ZCom_cbConnectResult( ZCom_ConnID _id, eZCom_ConnectResult _result, ZCom_BitStream &_reply )
{
	m_zoi_id = _id;
	m_id = _reply.getInt(32);
	std::string reason(_reply.getStringStatic());

	if ( _result != eZCom_ConnAccepted )
	{
		m_connected = false;
	}
	else
	{
		m_connected = true;
		ZCom_requestDownstreamLimit(m_zoi_id, m_downpacketpersecond, m_downbyteperpacket);

		#ifndef _ZOID_USED_NEW_VERSION_
		ZCom_requestZoidMode( m_zoi_id, 1 );
		#else
		ZCom_changeObjectChannelSubscription( m_zoi_id, 1, eZCom_Subscribe );
		#endif
	}
}
Example #6
0
void Client::ZCom_cbConnectResult( ZCom_ConnID _id, eZCom_ConnectResult _result, ZCom_BitStream &_reply )
{
	if ( _result != eZCom_ConnAccepted )
	{
		Network::ConnectionReply::type r = static_cast<Network::ConnectionReply::type>(_reply.getInt(8));
		if(r == Network::ConnectionReply::Retry)
		{
			DLOG("Got retry from server");
			network.reconnect(50);
		}
		else if(r == Network::ConnectionReply::Banned)
		{
			console.addLogMsg("* YOU ARE BANNED FROM THIS SERVER");
		}
		else
		{
			console.addLogMsg("* COULDNT ESTABLISH CONNECTION");
		}
	}
	else
	{
		network.setClient(true);
		ZCom_requestDownstreamLimit(_id, network.downPPS, network.downBPP);
		console.addLogMsg("* CONNECTION ACCEPTED");
		network.setServerID(_id);
		network.incConnCount();
		
		std::string mod = _reply.getStringStatic();
		std::string map = _reply.getStringStatic();
		game.refreshLevels();
		game.refreshMods();
		bool hasLevel = game.hasLevel(map);
		bool hasMod = game.hasMod(mod);
		
		if(!hasMod)
		{
			game.error(Game::ErrorModNotFound);
			//This doesn't work somewhy: network.disconnect();
			//And maybe we don't want to do it since it would overwrite our error message
		}
		else if(!hasLevel)
		{
			if(network.autoDownloads)
			{
				ZCom_requestZoidMode(_id, 2); // We need to update
				if(!hasLevel)
					updater.requestLevel(map);
			}
			else
				game.error(Game::ErrorMapNotFound);
		}
		else
		{
			game.setMod( mod );
			if(game.changeLevel( map, false ) && game.isLoaded())
			{
				game.runInitScripts();
				sendConsistencyInfo();
				ZCom_requestZoidMode(_id, 1);
			}
			else
			{
				console.addLogMsg("* COULDN'T LOAD MOD OR LEVEL");
				network.disconnect();
			}
		}
	}
}