예제 #1
0
	bool AddBlacklisted(uint32 ownerId, uint32 targetId)
	{
		if (IsBlacklisted(ownerId, targetId))
			return false;

		const int8* sql = "INSERT INTO char_blacklist (charid_owner, charid_target) VALUES (%u, %u);";
		return (Sql_Query(SqlHandle, sql, ownerId, targetId) != SQL_ERROR && Sql_AffectedRows(SqlHandle) == 1);
	}
예제 #2
0
	bool DeleteBlacklisted(uint32 ownerId, uint32 targetId)
	{
		if (!IsBlacklisted(ownerId, targetId))
			return false;

		const int8* sql = "DELETE FROM char_blacklist WHERE charid_owner = %u AND charid_target = %u;";
		return (Sql_Query(SqlHandle, sql, ownerId, targetId) != SQL_ERROR && Sql_AffectedRows(SqlHandle) == 1);
	}
예제 #3
0
	//Account Creation
	void Packet0x02(session_data_t* session, CPlayer* player, int8* data)
	{
		char* query = "SELECT id, handle FROM accounts WHERE handle LIKE '%s';";

		char handle[11];
		memset(handle, 0, sizeof handle);
		memcpy(handle, data + 0x02, 10);
		char pass[17];
		memset(pass, 0, sizeof pass);
		memcpy(pass, data + 0x0C, 16);

		char escapedHandle[(sizeof handle) * 2 + 1];
		char escapedPass[(sizeof pass) * 2 + 1];

		Sql_EscapeStringLen(SqlHandle, escapedHandle, handle, sizeof handle);
		Sql_EscapeStringLen(SqlHandle, escapedPass, pass, sizeof pass);

		int ret = Sql_Query(SqlHandle, query, escapedHandle);

		//TODO: validate name/pass
		if (ret != SQL_ERROR)
		{
			if (Sql_NumRows(SqlHandle) == 0)
			{
				query = "INSERT INTO accounts (handle, password) VALUES('%s', PASSWORD('%s'));";

				ret = Sql_Query(SqlHandle, query, escapedHandle, escapedPass);

				if (ret != SQL_ERROR && Sql_AffectedRows(SqlHandle) == 1)
				{
					session->PPlayer->pushPacket(new CAccountCreatePacket(CREATE_SUCCESS));
					ShowDebug("Account %s has been created\n", handle);
				}
				else
				{
					session->PPlayer->pushPacket(new CAccountCreatePacket(CREATE_UNDEF));
				}
			}
			else
			{
				session->PPlayer->pushPacket(new CAccountCreatePacket(CREATE_NAME_TAKEN));
			}
		}
		else
		{
			session->PPlayer->pushPacket(new CAccountCreatePacket(CREATE_UNDEF));
		}
	}