Exemple #1
0
bool LoginConnexion::OnLoginRequest(ThreadPoolLocalStorage *tls, BufferStream msg, u32 bytes)
{
	WARN("LoginConnexion") << _client_addr.IPToString() << ':' << _client_addr.GetPort() << " : Got LoginRequest";

	// Validate name
	char *name = msg.c_str() + 1 + 64;
	int name_len = GetFixedStrLen(name, USER_NAME_MAXLEN);

	if (!ValidLoginServerUserName(name, name_len))
	{
		WriteReliable(STREAM_1, LC_LOGIN_BAD_NAME);
		return true;
	}

	// Validate alias
	char *alias = name + USER_NAME_MAXLEN;
	int alias_len = GetFixedStrLen(alias, USER_NAME_MAXLEN);

	if (!ValidLoginServerUserName(alias, alias_len))
	{
		WriteReliable(STREAM_1, LC_LOGIN_BAD_ALIAS);
		return true;
	}

	// Copy message data into connexion object
	SetFixedStr(_account_name, sizeof(_account_name), name, name_len);
	SetFixedStr(_alias_name, sizeof(_alias_name), alias, alias_len);
	memcpy(_public_key, msg+1, sizeof(_public_key));

	// Expect ban ids next
	_state = SS_LOGIN_BANID_CDROM;
	return true;
}
Exemple #2
0
void LoginAdminClient::OnAddPlayer(ThreadPoolLocalStorage *tls, BufferStream msg, u32 bytes)
{
	if (bytes < 1 + 2 + 1)
	{
		WARN("AdminClient") << "Corrupted add player packet";
		on_disconnect();
		return;
	}

	u16 id;
	++msg >> id;

	Player &player = _player_list[id];

	SetFixedStr(player.name, USER_NAME_MAXLEN+1, msg.c_str(), bytes - 3);

	WARN("AdminClient") << "Player joined: " << player.name;

	on_add_player(player.name);
}
Exemple #3
0
void LoginAdminClient::OnChat(ThreadPoolLocalStorage *tls, BufferStream msg, u32 bytes)
{
	if (bytes < 1 + 2)
	{
		WARN("AdminClient") << "Corrupted chat packet";
		on_disconnect();
		return;
	}

	u32 msglen = bytes - 3;

	u16 id;
	++msg >> id;

	QString chatline = QString::fromAscii(msg.c_str(), msglen);

	Player &player = _player_list[id];

	WARN("AdminClient") << "<" << player.name << "> " << chatline.toAscii().data();

	on_chat_message(player.name, chatline);
}