aboutsummaryrefslogtreecommitdiff
path: root/games/devtest/mods/basetools/textures/basetools_steelaxe.png
diff options
context:
space:
mode:
authorBenjaminRi <28017860+BenjaminRi@users.noreply.github.com>2020-08-23 15:39:55 +0200
committerGitHub <noreply@github.com>2020-08-23 15:39:55 +0200
commitf5a203fbcd3af358bc1639467014063ba8409d3e (patch)
tree9ffc980351cc6c4fc8e61f83fcdc6ac05f66cb6b /games/devtest/mods/basetools/textures/basetools_steelaxe.png
parentcf5547227d9fffd9fb0043ce0b5633b831536eb6 (diff)
downloadminetest-f5a203fbcd3af358bc1639467014063ba8409d3e.tar.gz
minetest-f5a203fbcd3af358bc1639467014063ba8409d3e.tar.bz2
minetest-f5a203fbcd3af358bc1639467014063ba8409d3e.zip
Fix light overflow of u8 if light is saturated at 255 (#10305)
Diffstat (limited to 'games/devtest/mods/basetools/textures/basetools_steelaxe.png')
0 files changed, 0 insertions, 0 deletions
d='n149' href='#n149'>149 150 151
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "test.h"

#include "log.h"
#include "socket.h"
#include "settings.h"

class TestSocket : public TestBase {
public:
	TestSocket()
	{
		if (INTERNET_SIMULATOR == false)
			TestManager::registerTestModule(this);
	}

	const char *getName() { return "TestSocket"; }

	void runTests(IGameDef *gamedef);

	void testIPv4Socket();
	void testIPv6Socket();

	static const int port = 30003;
};

static TestSocket g_test_instance;

void TestSocket::runTests(IGameDef *gamedef)
{
	TEST(testIPv4Socket);

	if (g_settings->getBool("enable_ipv6"))
		TEST(testIPv6Socket);
}

////////////////////////////////////////////////////////////////////////////////

void TestSocket::testIPv4Socket()
{
	Address address(0, 0, 0, 0, port);
	Address bind_addr(0, 0, 0, 0, port);

	/*
	 * Try to use the bind_address for servers with no localhost address
	 * For example: FreeBSD jails
	 */
	std::string bind_str = g_settings->get("bind_address");
	try {
		bind_addr.Resolve(bind_str.c_str());

		if (!bind_addr.isIPv6()) {
			address = bind_addr;
		}
	} catch (ResolveError &e) {
	}

	UDPSocket socket(false);
	socket.Bind(address);

	const char sendbuffer[] = "hello world!";
	/*
	 * If there is a bind address, use it.
	 * It's useful in container environments