Exemplo n.º 1
0
void Server::Net_cbDataReceived( Net_ConnID  _id, BitStream &_data)
{
	Network::NetEvents event = (Network::NetEvents) _data.getInt(8);
	switch( event ) {
			case Network::RConMsg: {
				std::string passwordSent = _data.getString();
				if ( !gusGame.options.rConPassword.empty() && gusGame.options.rConPassword == passwordSent ) {
					//console.addQueueCommand(_data.getStringStatic());
					console.parseLine(_data.getString());
				}
			}
			break;

			case Network::ConsistencyInfo: {
				int clientProtocol = _data.getInt(32);
				if(clientProtocol != Network::protocolVersion) {
					network.disconnect(_id, Network::IncompatibleProtocol);
				}

				if(!gusGame.checkCRCs(_data) && network.checkCRC) // We call checkCRC anyway so that the stream is advanced
					network.disconnect(_id, Network::IncompatibleData);

			}
			break;
	}
}
Exemplo n.º 2
0
static std::string rawFromBits(BitStream& bits) {
	size_t oldPos = bits.bitPos();
	bits.resetPos();
	std::string ret;
	ret.reserve((bits.bitSize() + 7) / 8);
	for(size_t i = 0; i < bits.bitSize() / 8; ++i)
		ret += getCharFromBits(bits);
	if(bits.bitSize() % 8 != 0)
		ret += (char) (unsigned char) bits.getInt(bits.bitSize() % 8);
	bits.setBitPos(oldPos);
	return ret;
}