aboutsummaryrefslogtreecommitdiff
path: root/src/client.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.h')
-rw-r--r--src/client.h64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/client.h b/src/client.h
index babfe4680..1d5ab1298 100644
--- a/src/client.h
+++ b/src/client.h
@@ -575,11 +575,11 @@ private:
bool canSendChatMessage() const;
- float m_packetcounter_timer;
- float m_connection_reinit_timer;
- float m_avg_rtt_timer;
- float m_playerpos_send_timer;
- float m_ignore_damage_timer; // Used after server moves player
+ float m_packetcounter_timer = 0.0f;
+ float m_connection_reinit_timer = 0.1f;
+ float m_avg_rtt_timer = 0.0f;
+ float m_playerpos_send_timer = 0.0f;
+ float m_ignore_damage_timer = 0.0f; // Used after server moves player
IntervalLimiter m_map_timer_and_unload_interval;
IWritableTextureSource *m_tsrc;
@@ -596,9 +596,9 @@ private:
con::Connection m_con;
std::string m_address_name;
IrrlichtDevice *m_device;
- Camera *m_camera;
- Minimap *m_minimap;
- bool m_minimap_disabled_by_server;
+ Camera *m_camera = nullptr;
+ Minimap *m_minimap = nullptr;
+ bool m_minimap_disabled_by_server = false;
// Server serialization version
u8 m_server_ser_ver;
@@ -607,16 +607,16 @@ private:
// and aren't accurate. We simply just don't know, because
// the server didn't send the version back then.
// If 0, server init hasn't been received yet.
- u8 m_proto_ver;
+ u8 m_proto_ver = 0;
- u16 m_playeritem;
- bool m_inventory_updated;
- Inventory *m_inventory_from_server;
- float m_inventory_from_server_age;
+ u16 m_playeritem = 0;
+ bool m_inventory_updated = false;
+ Inventory *m_inventory_from_server = nullptr;
+ float m_inventory_from_server_age = 0.0f;
PacketCounter m_packetcounter;
// Block mesh animation parameters
- float m_animation_time;
- int m_crack_level;
+ float m_animation_time = 0.0f;
+ int m_crack_level = -1;
v3s16 m_crack_pos;
// 0 <= m_daynight_i < DAYNIGHT_CACHE_COUNT
//s32 m_daynight_i;
@@ -624,13 +624,13 @@ private:
std::queue<std::wstring> m_chat_queue;
std::queue<std::wstring> m_out_chat_queue;
u32 m_last_chat_message_sent;
- float m_chat_message_allowance;
+ float m_chat_message_allowance = 5.0f;
// The authentication methods we can use to enter sudo mode (=change password)
u32 m_sudo_auth_methods;
// The seed returned by the server in TOCLIENT_INIT is stored here
- u64 m_map_seed;
+ u64 m_map_seed = 0;
// Auth data
std::string m_playername;
@@ -639,27 +639,27 @@ private:
std::string m_new_password;
// Usable by auth mechanisms.
AuthMechanism m_chosen_auth_mech;
- void * m_auth_data;
+ void *m_auth_data = nullptr;
- bool m_access_denied;
- bool m_access_denied_reconnect;
- std::string m_access_denied_reason;
+ bool m_access_denied = false;
+ bool m_access_denied_reconnect = false;
+ std::string m_access_denied_reason = "";
std::queue<ClientEvent> m_client_event_queue;
- bool m_itemdef_received;
- bool m_nodedef_received;
+ bool m_itemdef_received = false;
+ bool m_nodedef_received = false;
ClientMediaDownloader *m_media_downloader;
// time_of_day speed approximation for old protocol
- bool m_time_of_day_set;
- float m_last_time_of_day_f;
- float m_time_of_day_update_timer;
+ bool m_time_of_day_set = false;
+ float m_last_time_of_day_f = -1.0f;
+ float m_time_of_day_update_timer = 0.0f;
// An interval for generally sending object positions and stuff
- float m_recommended_send_interval;
+ float m_recommended_send_interval = 0.1f;
// Sounds
- float m_removed_sounds_check_timer;
+ float m_removed_sounds_check_timer = 0.0f;
// Mapping from server sound ids to our sound ids
std::unordered_map<s32, int> m_sounds_server_to_client;
// And the other way!
@@ -681,17 +681,17 @@ private:
LocalClientState m_state;
// Used for saving server map to disk client-side
- MapDatabase *m_localdb;
+ MapDatabase *m_localdb = nullptr;
IntervalLimiter m_localdb_save_interval;
u16 m_cache_save_interval;
- ClientScripting *m_script;
+ ClientScripting *m_script = nullptr;
bool m_modding_enabled;
std::unordered_map<std::string, ModMetadata *> m_mod_storages;
- float m_mod_storage_save_timer;
+ float m_mod_storage_save_timer = 10.0f;
GameUIFlags *m_game_ui_flags;
- bool m_shutdown;
+ bool m_shutdown = false;
};
#endif // !CLIENT_HEADER
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
/*
Minetest
Copyright (C) 2010-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 <cmath>
#include "mapgen_math.h"
#include "voxel.h"
#include "mapblock.h"
#include "mapnode.h"
#include "map.h"
#include "nodedef.h"
#include "voxelalgorithms.h"
#include "profiler.h"
#include "settings.h" // For g_settings
#include "main.h" // For g_profiler
#include "emerge.h"
#include "biome.h"

// can use ported lib from http://mandelbulber.googlecode.com/svn/trunk/src
//#include "mandelbulber/fractal.h"
//#include "mandelbulber/fractal.cpp"

double mandelbox(double x, double y, double z, double d, int nn = 10) {
	int s = 7;
	x *= s;
	y *= s;
	z *= s;
	d *= s;

	double posX = x;
	double posY = y;
	double posZ = z;

	double dr = 1.0;
	double r = 0.0;

	double scale = 2;

	double minRadius2 = 0.25;
	double fixedRadius2 = 1;

	for (int n = 0; n < nn; n++) {
		// Reflect
		if (x > 1.0)
			x = 2.0 - x;
		else if (x < -1.0)
			x = -2.0 - x;
		if (y > 1.0)
			y = 2.0 - y;
		else if (y < -1.0)
			y = -2.0 - y;
		if (z > 1.0)
			z = 2.0 - z;
		else if (z < -1.0)
			z = -2.0 - z;

		// Sphere Inversion
		double r2 = x * x + y * y + z * z;

		if (r2 < minRadius2) {
			x = x * fixedRadius2 / minRadius2;
			y = y * fixedRadius2 / minRadius2;
			z = z * fixedRadius2 / minRadius2;
			dr = dr * fixedRadius2 / minRadius2;
		} else if (r2 < fixedRadius2) {
			x = x * fixedRadius2 / r2;
			y = y * fixedRadius2 / r2;
			z = z * fixedRadius2 / r2;
			fixedRadius2 *= fixedRadius2 / r2;
		}

		x = x * scale + posX;
		y = y * scale + posY;
		z = z * scale + posZ;
		dr *= scale;
	}
	r = sqrt(x * x + y * y + z * z);
	return ((r / fabs(dr)) < d);

}

double mengersponge(double x, double y, double z, double d, int MI = 10) {

	double r = x * x + y * y + z * z;
	double scale = 3;
	int i = 0;


	for (i = 0; i < MI && r < 9; i++) {


		x = fabs(x);
		y = fabs(y);
		z = fabs(z);


		if (x - y < 0) {
			double x1 = y;
			y = x;
			x = x1;
		}
		if (x - z < 0) {
			double x1 = z;
			z = x;
			x = x1;
		}
		if (y - z < 0) {
			double y1 = z;
			z = y;
			y = y1;
		}


		x = scale * x - 1 * (scale - 1);
		y = scale * y - 1 * (scale - 1);
		z = scale * z;


		if (z > 0.5 * 1 * (scale - 1))
			z -= 1 * (scale - 1);


		r = x * x + y * y + z * z;
	}
	return ((sqrt(r)) * pow(scale, (-i)) < d);
}

double sphere(double x, double y, double z, double d, int ITR = 1) {
	return v3f(x, y, z).getLength() < d;
}


//////////////////////// Mapgen Math parameter read/write

bool MapgenMathParams::readParams(Settings *settings) {
	//params = settings->getJson("mg_math");
	// can be counfigured from here.
	std::string value = "{}";
	Json::Reader reader;
	if (!reader.parse( value, params ) ) {
		errorstream  << "Failed to parse json conf var ='" << value << "' : " << reader.getFormattedErrorMessages();
	}

	if (params["generator"].empty()) params["generator"] = settings->get("mgmath_generator");

	return true;
}


void MapgenMathParams::writeParams(Settings *settings) {
	//settings->setJson("mg_math", params);
	settings->set("mgmath_generator", params["generator"].asString());
}

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

MapgenMath::MapgenMath(int mapgenid, MapgenMathParams *params_, EmergeManager *emerge) : MapgenV7(mapgenid, params_, emerge) {
	mg_params = params_;
	this->flags |= MG_NOLIGHT;

	Json::Value & params = mg_params->params;
	invert = params["invert"].empty() ? 1 : params["invert"].asBool(); //params["invert"].empty()?1:params["invert"].asBool();
	size = params["size"].empty() ? 0 : params["size"].asDouble(); // = max_r
	scale = params["scale"].empty() ? 0 : params["scale"].asDouble(); //(double)1 / size;
	if(!params["center"].empty()) center = v3f(params["center"]["x"].asFloat(), params["center"]["y"].asFloat(), params["center"]["z"].asFloat()); //v3f(5, -size - 5, 5);
	iterations = params["iterations"].empty() ? 0 : params["iterations"].asInt(); //10;
	distance = params["distance"].empty() ? 0 : params["distance"].asDouble(); // = 1/size;

	func = &sphere;

	if (params["generator"].empty()) params["generator"] = "mandelbox";
	if (params["generator"].asString() == "mengersponge") {
		if (!size) size = (MAP_GENERATION_LIMIT - 1000) / 2;
		if (!iterations) iterations = 10;
		if (!distance) distance = 0.0003;
		//if (!scale) scale = (double)0.1 / size;
		//if (!distance) distance = 0.01; //10/size;//sqrt3 * bd4;
		//if (!scale) scale = 0.01; //10/size;//sqrt3 * bd4;
		//center=v3f(-size/3,-size/3+(-2*-invert),2);
		center = v3f(-size, -size, -size);
		func = &mengersponge;
	} else if (params["generator"].asString() == "mandelbox") {
		/*
			size = MAP_GENERATION_LIMIT - 1000;
			//size = 1000;
			distance = 0.01; //100/size; //0.01;