Browse Source

Cpp11 initializers 2 (#5999)

* C++11 patchset 10: continue cleanup on constructors

* Drop obsolete bool MainMenuData::enable_public (setting is called with cURL in server loop)

* More classes cleanup

* More classes cleanup + change NULL tests to boolean tests
Loïc Blot 7 năm trước cách đây
mục cha
commit
8f7785771b
59 tập tin đã thay đổi với 333 bổ sung646 xóa
  1. 8 8
      src/client.cpp
  2. 1 1
      src/client.h
  3. 0 2
      src/client/clientlauncher.cpp
  4. 5 6
      src/clientiface.cpp
  5. 4 4
      src/clientmap.cpp
  6. 12 12
      src/content_cao.cpp
  7. 2 2
      src/environment.cpp
  8. 2 2
      src/game.cpp
  9. 3 6
      src/guiChatConsole.cpp
  10. 1 1
      src/guiEngine.cpp
  11. 2 2
      src/guiFormSpecMenu.cpp
  12. 8 11
      src/guiKeyChangeMenu.cpp
  13. 3 4
      src/guiKeyChangeMenu.h
  14. 7 16
      src/guiMainMenu.h
  15. 1 4
      src/guiPasswordChange.cpp
  16. 3 3
      src/guiPasswordChange.h
  17. 0 2
      src/guiPathSelectMenu.cpp
  18. 3 3
      src/guiPathSelectMenu.h
  19. 2 17
      src/guiTable.cpp
  20. 18 25
      src/guiTable.h
  21. 0 4
      src/httpfetch.cpp
  22. 12 17
      src/httpfetch.h
  23. 0 9
      src/hud.cpp
  24. 5 5
      src/hud.h
  25. 3 7
      src/intlGUIEditBox.cpp
  26. 29 22
      src/intlGUIEditBox.h
  27. 0 1
      src/inventory.cpp
  28. 7 6
      src/inventory.h
  29. 0 6
      src/keycode.cpp
  30. 4 4
      src/keycode.h
  31. 0 54
      src/localplayer.cpp
  32. 51 47
      src/localplayer.h
  33. 1 1
      src/main.cpp
  34. 6 12
      src/mainmenumanager.h
  35. 2 10
      src/map.cpp
  36. 12 20
      src/map.h
  37. 0 1
      src/map_settings_manager.cpp
  38. 3 3
      src/map_settings_manager.h
  39. 6 28
      src/mapblock.cpp
  40. 18 75
      src/mapblock.h
  41. 1 6
      src/mapblock_mesh.cpp
  42. 4 4
      src/mapblock_mesh.h
  43. 0 18
      src/mapgen.cpp
  44. 28 44
      src/mapgen.h
  45. 0 9
      src/mapgen_flat.cpp
  46. 8 8
      src/mapgen_flat.h
  47. 0 12
      src/mapgen_fractal.cpp
  48. 11 11
      src/mapgen_fractal.h
  49. 0 6
      src/mapgen_v5.cpp
  50. 5 5
      src/mapgen_v5.h
  51. 0 6
      src/mapgen_v6.cpp
  52. 4 3
      src/mapgen_v6.h
  53. 0 10
      src/mapgen_v7.cpp
  54. 9 9
      src/mapgen_v7.h
  55. 0 10
      src/mapgen_valleys.cpp
  56. 9 9
      src/mapgen_valleys.h
  57. 6 8
      src/mapsector.cpp
  58. 3 3
      src/mapsector.h
  59. 1 2
      src/network/clientpackethandler.cpp

+ 8 - 8
src/client.cpp

@@ -221,7 +221,7 @@ Client::~Client()
 		scene::IAnimatedMesh *mesh =
 			m_device->getSceneManager()->getMeshCache()->getMeshByIndex(0);
 
-		if (mesh != NULL)
+		if (mesh)
 			m_device->getSceneManager()->getMeshCache()->removeMesh(mesh);
 	}
 
@@ -383,7 +383,7 @@ void Client::step(float dtime)
 	*/
 	// Control local player (0ms)
 	LocalPlayer *player = m_env.getLocalPlayer();
-	assert(player != NULL);
+	assert(player);
 	player->applyControl(dtime);
 
 	// Step environment
@@ -459,7 +459,7 @@ void Client::step(float dtime)
 			if (block) {
 				// Delete the old mesh
 				delete block->mesh;
-				block->mesh = NULL;
+				block->mesh = nullptr;
 
 				if (r.mesh) {
 					minimap_mapblock = r.mesh->moveMinimapMapblock();
@@ -1370,7 +1370,7 @@ void Client::addNode(v3s16 p, MapNode n, bool remove_metadata)
 void Client::setPlayerControl(PlayerControl &control)
 {
 	LocalPlayer *player = m_env.getLocalPlayer();
-	assert(player != NULL);
+	assert(player);
 	player->control = control;
 }
 
@@ -1394,7 +1394,7 @@ bool Client::getLocalInventoryUpdated()
 void Client::getLocalInventory(Inventory &dst)
 {
 	LocalPlayer *player = m_env.getLocalPlayer();
-	assert(player != NULL);
+	assert(player);
 	dst = player->inventory;
 }
 
@@ -1407,7 +1407,7 @@ Inventory* Client::getInventory(const InventoryLocation &loc)
 	case InventoryLocation::CURRENT_PLAYER:
 	{
 		LocalPlayer *player = m_env.getLocalPlayer();
-		assert(player != NULL);
+		assert(player);
 		return &player->inventory;
 	}
 	break;
@@ -1496,7 +1496,7 @@ void Client::setCrack(int level, v3s16 pos)
 u16 Client::getHP()
 {
 	LocalPlayer *player = m_env.getLocalPlayer();
-	assert(player != NULL);
+	assert(player);
 	return player->hp;
 }
 
@@ -1529,7 +1529,7 @@ void Client::typeChatMessage(const std::wstring &message)
 		// compatibility code
 		if (m_proto_ver < 29) {
 			LocalPlayer *player = m_env.getLocalPlayer();
-			assert(player != NULL);
+			assert(player);
 			std::wstring name = narrow_to_wide(player->getName());
 			pushToChatQueue((std::wstring)L"<" + name + L"> " + message);
 		}

+ 1 - 1
src/client.h

@@ -457,7 +457,7 @@ public:
 	bool nodedefReceived()
 	{ return m_nodedef_received; }
 	bool mediaReceived()
-	{ return m_media_downloader == NULL; }
+	{ return !m_media_downloader; }
 
 	u8 getProtoVersion()
 	{ return m_proto_ver; }

+ 0 - 2
src/client/clientlauncher.cpp

@@ -357,8 +357,6 @@ bool ClientLauncher::launch_game(std::string &error_message,
 	if (cmd_args.exists("password"))
 		menudata.password = cmd_args.get("password");
 
-	menudata.enable_public = g_settings->getBool("server_announce");
-
 	// If a world was commanded, append and select it
 	if (game_params.world_path != "") {
 		worldspec.gameid = getWorldGameId(game_params.world_path, true);

+ 5 - 6
src/clientiface.cpp

@@ -79,11 +79,11 @@ void RemoteClient::GetNextBlocks (
 
 	RemotePlayer *player = env->getPlayer(peer_id);
 	// This can happen sometimes; clients and players are not in perfect sync.
-	if (player == NULL)
+	if (!player)
 		return;
 
 	PlayerSAO *sao = player->getPlayerSAO();
-	if (sao == NULL)
+	if (!sao)
 		return;
 
 	// Won't send anything if already sending
@@ -275,8 +275,7 @@ void RemoteClient::GetNextBlocks (
 
 			bool surely_not_found_on_disk = false;
 			bool block_is_invalid = false;
-			if(block != NULL)
-			{
+			if (block) {
 				// Reset usage timer, this block will be of use in the future.
 				block->resetUsageTimer();
 
@@ -645,7 +644,7 @@ void ClientInterface::step(float dtime)
 
 void ClientInterface::UpdatePlayerList()
 {
-	if (m_env != NULL) {
+	if (m_env) {
 		std::vector<u16> clients = getClientIDs();
 		m_clients_names.clear();
 
@@ -664,7 +663,7 @@ void ClientInterface::UpdatePlayerList()
 			{
 				MutexAutoLock clientslock(m_clients_mutex);
 				RemoteClient* client = lockedGetClientNoEx(*i);
-				if(client != NULL)
+				if (client)
 					client->PrintInfo(infostream);
 			}
 

+ 4 - 4
src/clientmap.cpp

@@ -212,11 +212,11 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
 				if not seen on display
 			*/
 
-			if (block->mesh != NULL)
+			if (block->mesh)
 				block->mesh->updateCameraOffset(m_camera_offset);
 
 			float range = 100000 * BS;
-			if (m_control.range_all == false)
+			if (!m_control.range_all)
 				range = m_control.wanted_range * BS;
 
 			float d = 0.0;
@@ -229,7 +229,7 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
 			/*
 				Ignore if mesh doesn't exist
 			*/
-			if (block->mesh == NULL) {
+			if (!block->mesh) {
 				blocks_in_range_without_mesh++;
 				continue;
 			}
@@ -398,7 +398,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
 		MapBlock *block = i->second;
 
 		// If the mesh of the block happened to get deleted, ignore it
-		if (block->mesh == NULL)
+		if (!block->mesh)
 			continue;
 
 		float d = 0.0;

+ 12 - 12
src/content_cao.cpp

@@ -202,7 +202,7 @@ void TestCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
 
 void TestCAO::removeFromScene(bool permanent)
 {
-	if(m_node == NULL)
+	if (!m_node)
 		return;
 
 	m_node->remove();
@@ -220,7 +220,7 @@ v3s16 TestCAO::getLightPosition()
 
 void TestCAO::updateNodePos()
 {
-	if(m_node == NULL)
+	if (!m_node)
 		return;
 
 	m_node->setPosition(m_position);
@@ -377,16 +377,16 @@ void ItemCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
 
 void ItemCAO::removeFromScene(bool permanent)
 {
-	if(m_node == NULL)
+	if (!m_node)
 		return;
 
 	m_node->remove();
-	m_node = NULL;
+	m_node = nullptr;
 }
 
 void ItemCAO::updateLight(u8 light_at_pos)
 {
-	if(m_node == NULL)
+	if (!m_node)
 		return;
 
 	u8 li = decode_light(light_at_pos);
@@ -401,7 +401,7 @@ v3s16 ItemCAO::getLightPosition()
 
 void ItemCAO::updateNodePos()
 {
-	if(m_node == NULL)
+	if (!m_node)
 		return;
 
 	m_node->setPosition(m_position);
@@ -428,7 +428,7 @@ void ItemCAO::updateInfoText()
 
 void ItemCAO::updateTexture()
 {
-	if(m_node == NULL)
+	if (!m_node)
 		return;
 
 	// Create an inventory item to see what is its image
@@ -1155,13 +1155,13 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
 			updateTextures(m_previous_texture_modifier);
 		}
 	}
-	if(getParent() == NULL && fabs(m_prop.automatic_rotate) > 0.001)
+	if(!getParent() && fabs(m_prop.automatic_rotate) > 0.001)
 	{
 		m_yaw += dtime * m_prop.automatic_rotate * 180 / M_PI;
 		updateNodePos();
 	}
 
-	if (getParent() == NULL && m_prop.automatic_face_movement_dir &&
+	if (!getParent() && m_prop.automatic_face_movement_dir &&
 			(fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001))
 	{
 		float optimal_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI
@@ -1408,7 +1408,7 @@ void GenericCAO::updateTextures(std::string mod)
 
 void GenericCAO::updateAnimation()
 {
-	if(m_animated_meshnode == NULL)
+	if (!m_animated_meshnode)
 		return;
 
 	if (m_animated_meshnode->getStartFrame() != m_animation_range.X ||
@@ -1426,7 +1426,7 @@ void GenericCAO::updateAnimation()
 
 void GenericCAO::updateBonePosition()
 {
-	if(m_bone_position.empty() || m_animated_meshnode == NULL)
+	if(m_bone_position.empty() || !m_animated_meshnode)
 		return;
 
 	m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render
@@ -1447,7 +1447,7 @@ void GenericCAO::updateBonePosition()
 void GenericCAO::updateAttachments()
 {
 
-	if (getParent() == NULL) { // Detach or don't attach
+	if (!getParent()) { // Detach or don't attach
 		scene::ISceneNode *node = getSceneNode();
 		if (node) {
 			v3f old_position = node->getAbsolutePosition();

+ 2 - 2
src/environment.cpp

@@ -28,9 +28,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 
 Environment::Environment(IGameDef *gamedef):
-	m_gamedef(gamedef),
 	m_time_of_day_speed(0.0f),
-	m_day_count(0)
+	m_day_count(0),
+	m_gamedef(gamedef)
 {
 	m_cache_enable_shaders = g_settings->getBool("enable_shaders");
 	m_cache_active_block_mgmt_interval = g_settings->getFloat("active_block_mgmt_interval");

+ 2 - 2
src/game.cpp

@@ -2643,7 +2643,7 @@ void Game::openInventory()
 	 */
 
 	LocalPlayer *player = client->getEnv().getLocalPlayer();
-	if (player == NULL || player->getCAO() == NULL)
+	if (!player || !player->getCAO())
 		return;
 
 	infostream << "the_game: " << "Launching inventory" << std::endl;
@@ -3402,7 +3402,7 @@ void Game::updateCamera(u32 busy_time, f32 dtime)
 		GenericCAO *playercao = player->getCAO();
 
 		// If playercao not loaded, don't change camera
-		if (playercao == NULL)
+		if (!playercao)
 			return;
 
 		camera->toggleCameraMode();

+ 3 - 6
src/guiChatConsole.cpp

@@ -76,12 +76,9 @@ GUIChatConsole::GUIChatConsole(
 
 	m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono);
 
-	if (m_font == NULL)
-	{
+	if (!m_font) {
 		errorstream << "GUIChatConsole: Unable to load mono font ";
-	}
-	else
-	{
+	} else {
 		core::dimension2d<u32> dim = m_font->getDimension(L"M");
 		m_fontsize = v2u32(dim.Width, dim.Height);
 		m_font->grab();
@@ -353,7 +350,7 @@ void GUIChatConsole::drawText()
 
 void GUIChatConsole::drawPrompt()
 {
-	if (m_font == NULL)
+	if (!m_font)
 		return;
 
 	u32 row = m_chat_backend->getConsoleBuffer().getRows();

+ 1 - 1
src/guiEngine.cpp

@@ -323,7 +323,7 @@ GUIEngine::~GUIEngine()
 
 	//clean up texture pointers
 	for (unsigned int i = 0; i < TEX_LAYER_MAX; i++) {
-		if (m_textures[i].texture != NULL)
+		if (m_textures[i].texture)
 			driver->removeTexture(m_textures[i].texture);
 	}
 

+ 2 - 2
src/guiFormSpecMenu.cpp

@@ -2004,7 +2004,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
 
 	// Add tooltip
 	{
-		assert(m_tooltip_element == NULL);
+		assert(!m_tooltip_element);
 		// Note: parent != this so that the tooltip isn't clipped by the menu rectangle
 		m_tooltip_element = addStaticText(Environment, L"",core::rect<s32>(0,0,110,18));
 		m_tooltip_element->enableOverrideColor(true);
@@ -2157,7 +2157,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
 	m_tooltip_element->setOverrideFont(m_font);
 
 	gui::IGUISkin* skin = Environment->getSkin();
-	sanity_check(skin != NULL);
+	sanity_check(skin);
 	gui::IGUIFont *old_font = skin->getFont();
 	skin->setFont(m_font);
 

+ 8 - 11
src/guiKeyChangeMenu.cpp

@@ -75,12 +75,9 @@ GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
 				gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) :
 GUIModalMenu(env, parent, id, menumgr)
 {
-	shift_down = false;
-	activeKey = -1;
-	this->key_used_text = NULL;
 	init_keys();
-	for(size_t i=0; i<key_settings.size(); i++)
-		this->key_used.push_back(key_settings.at(i)->key);
+	for (size_t i = 0; i < key_settings.size(); i++)
+		key_used.push_back(key_settings.at(i)->key);
 }
 
 GUIKeyChangeMenu::~GUIKeyChangeMenu()
@@ -115,7 +112,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
 {
 	removeChildren();
 	v2s32 size(745, 430);
-	
+
 	core::rect < s32 > rect(screensize.X / 2 - size.X / 2,
 							screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2,
 							screensize.Y / 2 + size.Y / 2);
@@ -124,7 +121,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
 	recalculateAbsolutePosition(false);
 
 	v2s32 topleft(0, 0);
-	
+
 	{
 		core::rect < s32 > rect(0, 0, 600, 40);
 		rect += topleft + v2s32(25, 3);
@@ -163,7 +160,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
 			offset += v2s32(0, 25);
 		}
 	}
-	
+
 	{
 		s32 option_x = offset.X;
 		s32 option_y = offset.Y + 5;
@@ -209,7 +206,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
 		Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON,
 				text);
 		delete[] text;
-	}	
+	}
 }
 
 void GUIKeyChangeMenu::drawMenu()
@@ -279,10 +276,10 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
 {
 	if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0
 			&& event.KeyInput.PressedDown) {
-		
+
 		bool prefer_character = shift_down;
 		KeyPress kp(event.KeyInput, prefer_character);
-		
+
 		bool shift_went_down = false;
 		if(!shift_down &&
 				(event.KeyInput.Key == irr::KEY_SHIFT ||

+ 3 - 4
src/guiKeyChangeMenu.h

@@ -65,12 +65,11 @@ private:
 
 	void add_key(int id, const wchar_t *button_name, const std::string &setting_name);
 
-	bool shift_down;
-
-	s32 activeKey;
+	bool shift_down = false;
+	s32 activeKey = -1;
 
 	std::vector<KeyPress> key_used;
-	gui::IGUIStaticText *key_used_text;
+	gui::IGUIStaticText *key_used_text = nullptr;
 	std::vector<key_setting *> key_settings;
 };
 

+ 7 - 16
src/guiMainMenu.h

@@ -27,14 +27,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 struct MainMenuDataForScript {
 
-	MainMenuDataForScript() :
-		reconnect_requested(false)
-	{}
+	MainMenuDataForScript() {}
 
 	// Whether the server has requested a reconnect
-	bool reconnect_requested;
-
-	std::string errormessage;
+	bool reconnect_requested = false;
+	std::string errormessage = "";
 };
 
 struct MainMenuData {
@@ -46,22 +43,16 @@ struct MainMenuData {
 	std::string name;
 	std::string password;
 	// Whether to reconnect
-	bool do_reconnect;
+	bool do_reconnect = false;
 
 	// Server options
-	bool enable_public;
-	int selected_world;
-	bool simple_singleplayer_mode;
+	int selected_world = 0;
+	bool simple_singleplayer_mode = false;
 
 	// Data to be passed to the script
 	MainMenuDataForScript script_data;
 
-	MainMenuData():
-		do_reconnect(false),
-		enable_public(false),
-		selected_world(0),
-		simple_singleplayer_mode(false)
-	{}
+	MainMenuData() {}
 };
 
 #endif

+ 1 - 4
src/guiPasswordChange.cpp

@@ -41,10 +41,7 @@ GUIPasswordChange::GUIPasswordChange(gui::IGUIEnvironment* env,
 		Client* client
 ):
 	GUIModalMenu(env, parent, id, menumgr),
-	m_client(client),
-	m_oldpass(L""),
-	m_newpass(L""),
-	m_newpass_confirm(L"")
+	m_client(client)
 {
 }
 

+ 3 - 3
src/guiPasswordChange.h

@@ -47,9 +47,9 @@ public:
 
 private:
 	Client *m_client;
-	std::wstring m_oldpass;
-	std::wstring m_newpass;
-	std::wstring m_newpass_confirm;
+	std::wstring m_oldpass = L"";
+	std::wstring m_newpass = L"";
+	std::wstring m_newpass_confirm = L"";
 };
 
 #endif

+ 0 - 2
src/guiPathSelectMenu.cpp

@@ -25,8 +25,6 @@ GUIFileSelectMenu::GUIFileSelectMenu(gui::IGUIEnvironment* env,
 		bool is_file_select) :
 	GUIModalMenu(env, parent, id, menumgr),
 	m_title(utf8_to_wide(title)),
-	m_accepted(false),
-	m_text_dst(NULL),
 	m_formname(formname),
 	m_file_select_dialog(is_file_select)
 {

+ 3 - 3
src/guiPathSelectMenu.h

@@ -49,11 +49,11 @@ private:
 	void acceptInput();
 
 	std::wstring m_title;
-	bool m_accepted;
+	bool m_accepted = false;
 
-	gui::IGUIFileOpenDialog *m_fileOpenDialog;
+	gui::IGUIFileOpenDialog *m_fileOpenDialog = nullptr;
 
-	TextDest *m_text_dst;
+	TextDest *m_text_dst = nullptr;
 
 	std::string m_formname;
 	bool m_file_select_dialog;

+ 2 - 17
src/guiTable.cpp

@@ -47,22 +47,7 @@ GUITable::GUITable(gui::IGUIEnvironment *env,
 		ISimpleTextureSource *tsrc
 ):
 	gui::IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, rectangle),
-	m_tsrc(tsrc),
-	m_is_textlist(false),
-	m_has_tree_column(false),
-	m_selected(-1),
-	m_sel_column(0),
-	m_sel_doubleclick(false),
-	m_keynav_time(0),
-	m_keynav_buffer(L""),
-	m_border(true),
-	m_color(255, 255, 255, 255),
-	m_background(255, 0, 0, 0),
-	m_highlight(255, 70, 100, 50),
-	m_highlight_text(255, 255, 255, 255),
-	m_rowheight(1),
-	m_font(NULL),
-	m_scrollbar(NULL)
+	m_tsrc(tsrc)
 {
 	assert(tsrc != NULL);
 
@@ -109,7 +94,7 @@ GUITable::~GUITable()
 
 	if (m_font)
 		m_font->drop();
-	
+
 	m_scrollbar->remove();
 }
 

+ 18 - 25
src/guiTable.h

@@ -52,18 +52,11 @@ public:
 	*/
 	struct DynamicData
 	{
-		s32 selected;
-		s32 scrollpos;
-		s32 keynav_time;
+		s32 selected = 0;
+		s32 scrollpos = 0;
+		s32 keynav_time = 0;
 		core::stringw keynav_buffer;
 		std::set<s32> opened_trees;
-
-		DynamicData()
-		{
-			selected = 0;
-			scrollpos = 0;
-			keynav_time = 0;
-		}
 	};
 
 	/*
@@ -187,27 +180,27 @@ protected:
 	std::vector<Row> m_rows;
 	// Table content (only visible; indices into m_rows)
 	std::vector<s32> m_visible_rows;
-	bool m_is_textlist;
-	bool m_has_tree_column;
+	bool m_is_textlist = false;
+	bool m_has_tree_column = false;
 
 	// Selection status
-	s32 m_selected; // index of row (1...n), or 0 if none selected
-	s32 m_sel_column;
-	bool m_sel_doubleclick;
+	s32 m_selected = -1; // index of row (1...n), or 0 if none selected
+	s32 m_sel_column = 0;
+	bool m_sel_doubleclick = false;
 
 	// Keyboard navigation stuff
-	u64 m_keynav_time;
-	core::stringw m_keynav_buffer;
+	u64 m_keynav_time = 0;
+	core::stringw m_keynav_buffer = L"";
 
 	// Drawing and geometry information
-	bool m_border;
-	video::SColor m_color;
-	video::SColor m_background;
-	video::SColor m_highlight;
-	video::SColor m_highlight_text;
-	s32 m_rowheight;
-	gui::IGUIFont *m_font;
-	gui::IGUIScrollBar *m_scrollbar;
+	bool m_border = true;
+	video::SColor m_color = video::SColor(255, 255, 255, 255);
+	video::SColor m_background = video::SColor(255, 0, 0, 0);
+	video::SColor m_highlight = video::SColor(255, 70, 100, 50);
+	video::SColor m_highlight_text = video::SColor(255, 255, 255, 255);
+	s32 m_rowheight = 1;
+	gui::IGUIFont *m_font = nullptr;
+	gui::IGUIScrollBar *m_scrollbar = nullptr;
 
 	// Allocated strings and images
 	std::vector<core::stringw> m_strings;

+ 0 - 4
src/httpfetch.cpp

@@ -42,12 +42,8 @@ std::map<unsigned long, std::queue<HTTPFetchResult> > g_httpfetch_results;
 PcgRandom g_callerid_randomness;
 
 HTTPFetchRequest::HTTPFetchRequest() :
-	url(""),
-	caller(HTTPFETCH_DISCARD),
-	request_id(0),
 	timeout(g_settings->getS32("curl_timeout")),
 	connect_timeout(timeout),
-	multipart(false),
 	useragent(std::string(PROJECT_NAME_C "/") + g_version_hash + " (" + porting::get_sysinfo() + ")")
 {
 }

+ 12 - 17
src/httpfetch.h

@@ -31,15 +31,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 struct HTTPFetchRequest
 {
-	std::string url;
+	std::string url = "";
 
 	// Identifies the caller (for asynchronous requests)
 	// Ignored by httpfetch_sync
-	unsigned long caller;
+	unsigned long caller = HTTPFETCH_DISCARD;
 
 	// Some number that identifies the request
 	// (when the same caller issues multiple httpfetch_async calls)
-	unsigned long request_id;
+	unsigned long request_id = 0;
 
 	// Timeout for the whole transfer, in milliseconds
 	long timeout;
@@ -49,7 +49,7 @@ struct HTTPFetchRequest
 
 	// Indicates if this is multipart/form-data or
 	// application/x-www-form-urlencoded.  POST-only.
-	bool multipart;
+	bool multipart = false;
 
 	// POST fields.  Fields are escaped properly.
 	// If this is empty a GET request is done instead.
@@ -69,23 +69,18 @@ struct HTTPFetchRequest
 
 struct HTTPFetchResult
 {
-	bool succeeded;
-	bool timeout;
-	long response_code;
-	std::string data;
+	bool succeeded = false;
+	bool timeout = false;
+	long response_code = 0;
+	std::string data = "";
 	// The caller and request_id from the corresponding HTTPFetchRequest.
-	unsigned long caller;
-	unsigned long request_id;
+	unsigned long caller = HTTPFETCH_DISCARD;
+	unsigned long request_id = 0;
 
-	HTTPFetchResult()
-	    : succeeded(false), timeout(false), response_code(0), data(""),
-	      caller(HTTPFETCH_DISCARD), request_id(0)
-	{
-	}
+	HTTPFetchResult() {}
 
 	HTTPFetchResult(const HTTPFetchRequest &fetch_request)
-	    : succeeded(false), timeout(false), response_code(0), data(""),
-	      caller(fetch_request.caller), request_id(fetch_request.request_id)
+	    : caller(fetch_request.caller), request_id(fetch_request.request_id)
 	{
 	}
 };

+ 0 - 9
src/hud.cpp

@@ -51,8 +51,6 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
 	this->inventory   = inventory;
 
 	m_hud_scaling      = g_settings->getFloat("hud_scaling");
-	m_screensize       = v2u32(0, 0);
-	m_displaycenter    = v2s32(0, 0);
 	m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE * porting::getDisplayDensity() + 0.5);
 	m_hotbar_imagesize *= m_hud_scaling;
 	m_padding = m_hotbar_imagesize / 12;
@@ -77,16 +75,9 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
 
 	use_crosshair_image = tsrc->isKnownSourceImage("crosshair.png");
 
-	hotbar_image = "";
-	use_hotbar_image = false;
-	hotbar_selected_image = "";
-	use_hotbar_selected_image = false;
-
-	m_selection_mesh = NULL;
 	m_selection_boxes.clear();
 	m_halo_boxes.clear();
 
-	m_selection_pos = v3f(0.0, 0.0, 0.0);
 	std::string mode_setting = g_settings->get("node_highlighting");
 
 	if (mode_setting == "halo") {

+ 5 - 5
src/hud.h

@@ -114,10 +114,10 @@ public:
 
 	video::SColor crosshair_argb;
 	video::SColor selectionbox_argb;
-	bool use_crosshair_image;
-	std::string hotbar_image;
-	bool use_hotbar_image;
-	std::string hotbar_selected_image;
+	bool use_crosshair_image = false;
+	std::string hotbar_image = "";
+	bool use_hotbar_image = false;
+	std::string hotbar_selected_image = "";
 	bool use_hotbar_selected_image;
 
 	Hud(video::IVideoDriver *driver,scene::ISceneManager* smgr,
@@ -170,7 +170,7 @@ private:
 	v3f m_selection_pos;
 	v3f m_selection_pos_with_offset;
 
-	scene::IMesh* m_selection_mesh;
+	scene::IMesh *m_selection_mesh = nullptr;
 	video::SColor m_selection_mesh_color;
 	v3f m_selected_face_normal;
 

+ 3 - 7
src/intlGUIEditBox.cpp

@@ -62,13 +62,9 @@ namespace gui
 intlGUIEditBox::intlGUIEditBox(const wchar_t* text, bool border,
 		IGUIEnvironment* environment, IGUIElement* parent, s32 id,
 		const core::rect<s32>& rectangle)
-	: IGUIEditBox(environment, parent, id, rectangle), MouseMarking(false),
-	Border(border), OverrideColorEnabled(false), MarkBegin(0), MarkEnd(0),
-	OverrideColor(video::SColor(101,255,255,255)), OverrideFont(0), LastBreakFont(0),
-	Operator(0), BlinkStartTime(0), CursorPos(0), HScrollPos(0), VScrollPos(0), Max(0),
-	WordWrap(false), MultiLine(false), AutoScroll(true), PasswordBox(false),
-	PasswordChar(L'*'), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER),
-	CurrentTextRect(0,0,1,1), FrameRect(rectangle)
+	: IGUIEditBox(environment, parent, id, rectangle),
+	Border(border),
+	FrameRect(rectangle)
 {
 	#ifdef _DEBUG
 	setDebugName("intlintlGUIEditBox");

+ 29 - 22
src/intlGUIEditBox.h

@@ -145,29 +145,36 @@ namespace gui
 		bool processMouse(const SEvent& event);
 		s32 getCursorPos(s32 x, s32 y);
 
-		bool MouseMarking;
+		bool MouseMarking = false;
 		bool Border;
-		bool OverrideColorEnabled;
-		s32 MarkBegin;
-		s32 MarkEnd;
-
-		video::SColor OverrideColor;
-		gui::IGUIFont *OverrideFont, *LastBreakFont;
-		IOSOperator* Operator;
-
-		u64 BlinkStartTime;
-		s32 CursorPos;
-		s32 HScrollPos, VScrollPos; // scroll position in characters
-		u32 Max;
-
-		bool WordWrap, MultiLine, AutoScroll, PasswordBox;
-		wchar_t PasswordChar;
-		EGUI_ALIGNMENT HAlign, VAlign;
-
-		core::array< core::stringw > BrokenText;
-		core::array< s32 > BrokenTextPositions;
-
-		core::rect<s32> CurrentTextRect, FrameRect; // temporary values
+		bool OverrideColorEnabled = false;
+		s32 MarkBegin = 0;
+		s32 MarkEnd = 0;
+
+		video::SColor OverrideColor = video::SColor(101,255,255,255);
+		gui::IGUIFont *OverrideFont = nullptr;
+		gui::IGUIFont *LastBreakFont = nullptr;
+		IOSOperator *Operator = nullptr;
+
+		u64 BlinkStartTime = 0;
+		s32 CursorPos = 0;
+		s32 HScrollPos = 0;
+		s32 VScrollPos = 0; // scroll position in characters
+		u32 Max = 0;
+
+		bool WordWrap = false;
+		bool MultiLine = false;
+		bool AutoScroll = true;
+		bool PasswordBox = false;
+		wchar_t PasswordChar = L'*';
+		EGUI_ALIGNMENT HAlign = EGUIA_UPPERLEFT;
+		EGUI_ALIGNMENT VAlign = EGUIA_CENTER;
+
+		core::array<core::stringw> BrokenText;
+		core::array<s32> BrokenTextPositions;
+
+		core::rect<s32> CurrentTextRect = core::rect<s32>(0,0,1,1);
+		core::rect<s32> FrameRect; // temporary values
 	};
 
 

+ 0 - 1
src/inventory.cpp

@@ -372,7 +372,6 @@ ItemStack ItemStack::peekItem(u32 peekcount) const
 InventoryList::InventoryList(const std::string &name, u32 size, IItemDefManager *itemdef):
 	m_name(name),
 	m_size(size),
-	m_width(0),
 	m_itemdef(itemdef)
 {
 	clearItems();

+ 7 - 6
src/inventory.h

@@ -33,7 +33,7 @@ struct ToolCapabilities;
 
 struct ItemStack
 {
-	ItemStack(): name(""), count(0), wear(0) {}
+	ItemStack() {}
 	ItemStack(const std::string &name_, u16 count_,
 			u16 wear, IItemDefManager *itemdef);
 
@@ -164,9 +164,9 @@ struct ItemStack
 	/*
 		Properties
 	*/
-	std::string name;
-	u16 count;
-	u16 wear;
+	std::string name = "";
+	u16 count = 0;
+	u16 wear = 0;
 	ItemStackMetadata metadata;
 };
 
@@ -252,7 +252,8 @@ public:
 private:
 	std::vector<ItemStack> m_items;
 	std::string m_name;
-	u32 m_size, m_width;
+	u32 m_size;
+	u32 m_width = 0;
 	IItemDefManager *m_itemdef;
 };
 
@@ -307,7 +308,7 @@ private:
 
 	std::vector<InventoryList*> m_lists;
 	IItemDefManager *m_itemdef;
-	bool m_dirty;
+	bool m_dirty = false;
 };
 
 #endif

+ 0 - 6
src/keycode.cpp

@@ -278,12 +278,6 @@ struct table_key lookup_keychar(wchar_t Char)
 	throw UnknownKeycode(os.str().c_str());
 }
 
-KeyPress::KeyPress() :
-	Key(irr::KEY_KEY_CODES_COUNT),
-	Char(L'\0'),
-	m_name("")
-{}
-
 KeyPress::KeyPress(const char *name)
 {
 	if (strlen(name) == 0) {

+ 4 - 4
src/keycode.h

@@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class KeyPress
 {
 public:
-	KeyPress();
+	KeyPress() {}
 	KeyPress(const char *name);
 
 	KeyPress(const irr::SEvent::SKeyInput &in, bool prefer_character = false);
@@ -50,9 +50,9 @@ protected:
 		return k > 0 && k < irr::KEY_KEY_CODES_COUNT;
 	}
 
-	irr::EKEY_CODE Key;
-	wchar_t Char;
-	std::string m_name;
+	irr::EKEY_CODE Key = irr::KEY_KEY_CODES_COUNT;
+	wchar_t Char = L'\0';
+	std::string m_name = "";
 };
 
 extern const KeyPress EscapeKey;

+ 0 - 54
src/localplayer.cpp

@@ -34,62 +34,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 LocalPlayer::LocalPlayer(Client *client, const char *name):
 	Player(name, client->idef()),
-	parent(0),
-	hp(PLAYER_MAX_HP),
-	isAttached(false),
-	touching_ground(false),
-	in_liquid(false),
-	in_liquid_stable(false),
-	liquid_viscosity(0),
-	is_climbing(false),
-	swimming_vertical(false),
-	// Movement overrides are multipliers and must be 1 by default
-	physics_override_speed(1.0f),
-	physics_override_jump(1.0f),
-	physics_override_gravity(1.0f),
-	physics_override_sneak(true),
-	physics_override_sneak_glitch(false),
-	physics_override_new_move(true),  // Temporary option for old move code
-	overridePosition(v3f(0,0,0)),
-	last_position(v3f(0,0,0)),
-	last_speed(v3f(0,0,0)),
-	last_pitch(0),
-	last_yaw(0),
-	last_keyPressed(0),
-	last_camera_fov(0),
-	last_wanted_range(0),
-	camera_impact(0.f),
-	makes_footstep_sound(true),
-	last_animation(NO_ANIM),
-	hotbar_image(""),
-	hotbar_selected_image(""),
-	light_color(255,255,255,255),
-	hurt_tilt_timer(0.0f),
-	hurt_tilt_strength(0.0f),
-	m_position(0,0,0),
-	m_sneak_node(32767,32767,32767),
-	m_sneak_node_bb_ymax(0),  // To support temporary option for old move code
-	m_sneak_node_bb_top(0,0,0,0,0,0),
-	m_sneak_node_exists(false),
-	m_need_to_get_new_sneak_node(true),
-	m_sneak_ladder_detected(false),
-	m_ledge_detected(false),
-	m_old_node_below(32767,32767,32767),
-	m_old_node_below_type("air"),
-	m_can_jump(false),
-	m_breath(PLAYER_MAX_BREATH),
-	m_yaw(0),
-	m_pitch(0),
-	camera_barely_in_ceiling(false),
-	m_collisionbox(-BS * 0.30, 0.0, -BS * 0.30, BS * 0.30, BS * 1.75, BS * 0.30),
-	m_cao(NULL),
 	m_client(client)
 {
-	// Initialize hp to 0, so that no hearts will be shown if server
-	// doesn't support health points
-	hp = 0;
-	eye_offset_first = v3f(0,0,0);
-	eye_offset_third = v3f(0,0,0);
 }
 
 LocalPlayer::~LocalPlayer()

+ 51 - 47
src/localplayer.h

@@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "player.h"
 #include "environment.h"
+#include "constants.h"
 #include <list>
 
 class Client;
@@ -44,27 +45,29 @@ public:
 	LocalPlayer(Client *client, const char *name);
 	virtual ~LocalPlayer();
 
-	ClientActiveObject *parent;
+	ClientActiveObject *parent = nullptr;
 
-	u16 hp;
-	bool isAttached;
-	bool touching_ground;
+	// Initialize hp to 0, so that no hearts will be shown if server
+	// doesn't support health points
+	u16 hp = 0;
+	bool isAttached = false;
+	bool touching_ground = false;
 	// This oscillates so that the player jumps a bit above the surface
-	bool in_liquid;
+	bool in_liquid = false;
 	// This is more stable and defines the maximum speed of the player
-	bool in_liquid_stable;
+	bool in_liquid_stable = false;
 	// Gets the viscosity of water to calculate friction
-	u8 liquid_viscosity;
-	bool is_climbing;
-	bool swimming_vertical;
-
-	float physics_override_speed;
-	float physics_override_jump;
-	float physics_override_gravity;
-	bool physics_override_sneak;
-	bool physics_override_sneak_glitch;
+	u8 liquid_viscosity = 0;
+	bool is_climbing = false;
+	bool swimming_vertical = false;
+
+	float physics_override_speed = 1.0f;
+	float physics_override_jump = 1.0f;
+	float physics_override_gravity = 1.0f;
+	bool physics_override_sneak = true;
+	bool physics_override_sneak_glitch = false;
 	// Temporary option for old move code
-	bool physics_override_new_move;
+	bool physics_override_new_move = true;
 
 	v3f overridePosition;
 
@@ -83,32 +86,32 @@ public:
 	// Used to check if anything changed and prevent sending packets if not
 	v3f last_position;
 	v3f last_speed;
-	float last_pitch;
-	float last_yaw;
-	unsigned int last_keyPressed;
-	u8 last_camera_fov;
-	u8 last_wanted_range;
+	float last_pitch = 0.0f;
+	float last_yaw = 0.0f;
+	unsigned int last_keyPressed = 0;
+	u8 last_camera_fov = 0;
+	u8 last_wanted_range = 0;
 
-	float camera_impact;
+	float camera_impact = 0.0f;
 
-	bool makes_footstep_sound;
+	bool makes_footstep_sound = true;
 
-	int last_animation;
+	int last_animation = NO_ANIM;
 	float last_animation_speed;
 
-	std::string hotbar_image;
-	std::string hotbar_selected_image;
+	std::string hotbar_image = "";
+	std::string hotbar_selected_image = "";
 
-	video::SColor light_color;
+	video::SColor light_color = video::SColor(255, 255, 255, 255);
 
-	float hurt_tilt_timer;
-	float hurt_tilt_strength;
+	float hurt_tilt_timer = 0.0f;
+	float hurt_tilt_strength = 0.0f;
 
 	GenericCAO *getCAO() const { return m_cao; }
 
 	void setCAO(GenericCAO *toset)
 	{
-		assert(m_cao == NULL); // Pre-condition
+		assert(!m_cao); // Pre-condition
 		m_cao = toset;
 	}
 
@@ -143,35 +146,36 @@ private:
 
 	v3f m_position;
 
-	v3s16 m_sneak_node;
+	v3s16 m_sneak_node = v3s16(32767, 32767, 32767);
 	// Stores the max player uplift by m_sneak_node
 	// To support temporary option for old move code
-	f32 m_sneak_node_bb_ymax;
+	f32 m_sneak_node_bb_ymax = 0.0f;
 	// Stores the top bounding box of m_sneak_node
-	aabb3f m_sneak_node_bb_top;
+	aabb3f m_sneak_node_bb_top = aabb3f(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
 	// Whether the player is allowed to sneak
-	bool m_sneak_node_exists;
+	bool m_sneak_node_exists = false;
 	// Whether recalculation of m_sneak_node and its top bbox is needed
-	bool m_need_to_get_new_sneak_node;
+	bool m_need_to_get_new_sneak_node = true;
 	// Whether a "sneak ladder" structure is detected at the players pos
 	// see detectSneakLadder() in the .cpp for more info (always false if disabled)
-	bool m_sneak_ladder_detected;
+	bool m_sneak_ladder_detected = false;
 	// Whether a 2-node-up ledge is detected at the players pos,
 	// see detectLedge() in the .cpp for more info (always false if disabled).
-	bool m_ledge_detected;
+	bool m_ledge_detected = false;
 
 	// Node below player, used to determine whether it has been removed,
 	// and its old type
-	v3s16 m_old_node_below;
-	std::string m_old_node_below_type;
-	bool m_can_jump;
-	u16 m_breath;
-	f32 m_yaw;
-	f32 m_pitch;
-	bool camera_barely_in_ceiling;
-	aabb3f m_collisionbox;
-
-	GenericCAO *m_cao;
+	v3s16 m_old_node_below = v3s16(32767, 32767, 32767);
+	std::string m_old_node_below_type = "air";
+	bool m_can_jump = false;
+	u16 m_breath = PLAYER_MAX_BREATH;
+	f32 m_yaw = 0.0f;
+	f32 m_pitch = 0.0f;
+	bool camera_barely_in_ceiling = false;
+	aabb3f m_collisionbox = aabb3f(-BS * 0.30f, 0.0f, -BS * 0.30f, BS * 0.30f,
+			BS * 1.75f, BS * 0.30f);
+
+	GenericCAO *m_cao = nullptr;
 	Client *m_client;
 };
 

+ 1 - 1
src/main.cpp

@@ -319,7 +319,7 @@ static void print_allowed_options(const OptionList &allowed_options)
 
 		std::cout << padStringRight(os1.str(), 30);
 
-		if (i->second.help != NULL)
+		if (i->second.help)
 			std::cout << i->second.help;
 
 		std::cout << std::endl;

+ 6 - 12
src/mainmenumanager.h

@@ -125,12 +125,6 @@ class MainGameCallback : public IGameCallback
 {
 public:
 	MainGameCallback(IrrlichtDevice *a_device):
-		disconnect_requested(false),
-		changepassword_requested(false),
-		changevolume_requested(false),
-		keyconfig_requested(false),
-		shutdown_requested(false),
-		keyconfig_changed(false),
 		device(a_device)
 	{
 	}
@@ -169,13 +163,13 @@ public:
 	}
 
 
-	bool disconnect_requested;
-	bool changepassword_requested;
-	bool changevolume_requested;
-	bool keyconfig_requested;
-	bool shutdown_requested;
+	bool disconnect_requested = false;
+	bool changepassword_requested = false;
+	bool changevolume_requested = false;
+	bool keyconfig_requested = false;
+	bool shutdown_requested = false;
 
-	bool keyconfig_changed;
+	bool keyconfig_changed = false;
 
 	IrrlichtDevice *device;
 };

+ 2 - 10
src/map.cpp

@@ -65,12 +65,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 Map::Map(std::ostream &dout, IGameDef *gamedef):
 	m_dout(dout),
 	m_gamedef(gamedef),
-	m_sector_cache(NULL),
-	m_nodedef(gamedef->ndef()),
-	m_transforming_liquid_loop_count_multiplier(1.0f),
-	m_unprocessed_count(0),
-	m_inc_trending_up_start_time(0),
-	m_queue_size_timer_started(false)
+	m_nodedef(gamedef->ndef())
 {
 }
 
@@ -1240,8 +1235,7 @@ ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef,
 		EmergeManager *emerge):
 	Map(dout_server, gamedef),
 	settings_mgr(g_settings, savedir + DIR_DELIM + "map_meta.txt"),
-	m_emerge(emerge),
-	m_map_metadata_changed(true)
+	m_emerge(emerge)
 {
 	verbosestream<<FUNCTION_NAME<<std::endl;
 
@@ -2618,8 +2612,6 @@ bool ServerMap::repairBlockLight(v3s16 blockpos,
 
 MMVManip::MMVManip(Map *map):
 		VoxelManipulator(),
-		m_is_dirty(false),
-		m_create_area(false),
 		m_map(map)
 {
 }

+ 12 - 20
src/map.h

@@ -72,17 +72,13 @@ enum MapEditEventType{
 
 struct MapEditEvent
 {
-	MapEditEventType type;
+	MapEditEventType type = MEET_OTHER;
 	v3s16 p;
-	MapNode n;
+	MapNode n = CONTENT_AIR;
 	std::set<v3s16> modified_blocks;
-	u16 already_known_by_peer;
+	u16 already_known_by_peer = 0;
 
-	MapEditEvent():
-		type(MEET_OTHER),
-		n(CONTENT_AIR),
-		already_known_by_peer(0)
-	{ }
+	MapEditEvent() {}
 
 	MapEditEvent * clone()
 	{
@@ -323,7 +319,7 @@ protected:
 	std::map<v2s16, MapSector*> m_sectors;
 
 	// Be sure to set this to NULL when the cached sector is deleted
-	MapSector *m_sector_cache;
+	MapSector *m_sector_cache = nullptr;
 	v2s16 m_sector_cache_p;
 
 	// Queued transforming water nodes
@@ -336,10 +332,10 @@ protected:
 			float start_off, float end_off, u32 needed_count);
 
 private:
-	f32 m_transforming_liquid_loop_count_multiplier;
-	u32 m_unprocessed_count;
-	u64 m_inc_trending_up_start_time; // milliseconds
-	bool m_queue_size_timer_started;
+	f32 m_transforming_liquid_loop_count_multiplier = 1.0f;
+	u32 m_unprocessed_count = 0;
+	u64 m_inc_trending_up_start_time = 0; // milliseconds
+	bool m_queue_size_timer_started = false;
 };
 
 /*
@@ -501,8 +497,8 @@ private:
 		Metadata is re-written on disk only if this is true.
 		This is reset to false when written on disk.
 	*/
-	bool m_map_metadata_changed;
-	MapDatabase *dbase;
+	bool m_map_metadata_changed = true;
+	MapDatabase *dbase = nullptr;
 };
 
 
@@ -521,9 +517,6 @@ public:
 		m_loaded_blocks.clear();
 	}
 
-	void setMap(Map *map)
-	{m_map = map;}
-
 	void initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
 		bool load_if_inexistent = true);
 
@@ -531,10 +524,9 @@ public:
 	void blitBackAll(std::map<v3s16, MapBlock*> * modified_blocks,
 		bool overwrite_generated = true);
 
-	bool m_is_dirty;
+	bool m_is_dirty = false;
 
 protected:
-	bool m_create_area;
 	Map *m_map;
 	/*
 		key = blockpos

+ 0 - 1
src/map_settings_manager.cpp

@@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 MapSettingsManager::MapSettingsManager(Settings *user_settings,
 		const std::string &map_meta_path):
-	mapgen_params(NULL),
 	m_map_meta_path(map_meta_path),
 	m_map_settings(new Settings()),
 	m_user_settings(user_settings)

+ 3 - 3
src/map_settings_manager.h

@@ -45,13 +45,13 @@ struct MapgenParams;
 */
 class MapSettingsManager {
 public:
-	// Finalized map generation parameters
-	MapgenParams *mapgen_params;
-
 	MapSettingsManager(Settings *user_settings,
 		const std::string &map_meta_path);
 	~MapSettingsManager();
 
+	// Finalized map generation parameters
+	MapgenParams *mapgen_params = nullptr;
+
 	bool getMapSetting(const std::string &name, std::string *value_out);
 
 	bool getMapSettingNoiseParams(

+ 6 - 28
src/mapblock.cpp

@@ -69,36 +69,18 @@ MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy):
 		m_parent(parent),
 		m_pos(pos),
 		m_pos_relative(pos * MAP_BLOCKSIZE),
-		m_gamedef(gamedef),
-		m_modified(MOD_STATE_WRITE_NEEDED),
-		m_modified_reason(MOD_REASON_INITIAL),
-		is_underground(false),
-		m_lighting_complete(0xFFFF),
-		m_day_night_differs(false),
-		m_day_night_differs_expired(true),
-		m_generated(false),
-		m_timestamp(BLOCK_TIMESTAMP_UNDEFINED),
-		m_disk_timestamp(BLOCK_TIMESTAMP_UNDEFINED),
-		m_usage_timer(0),
-		m_refcount(0)
+		m_gamedef(gamedef)
 {
-	data = NULL;
 	if(dummy == false)
 		reallocate();
-
-#ifndef SERVER
-	mesh = NULL;
-#endif
 }
 
 MapBlock::~MapBlock()
 {
 #ifndef SERVER
 	{
-		//MutexAutoLock lock(mesh_mutex);
-
 		delete mesh;
-		mesh = NULL;
+		mesh = nullptr;
 	}
 #endif
 
@@ -121,7 +103,7 @@ MapNode MapBlock::getNodeParent(v3s16 p, bool *is_valid_position)
 	if (isValidPosition(p) == false)
 		return m_parent->getNodeNoEx(getPosRelative() + p, is_valid_position);
 
-	if (data == NULL) {
+	if (!data) {
 		if (is_valid_position)
 			*is_valid_position = false;
 		return MapNode(CONTENT_IGNORE);
@@ -374,7 +356,7 @@ void MapBlock::actuallyUpdateDayNightDiff()
 	// Running this function un-expires m_day_night_differs
 	m_day_night_differs_expired = false;
 
-	if (data == NULL) {
+	if (!data) {
 		m_day_night_differs = false;
 		return;
 	}
@@ -415,9 +397,7 @@ void MapBlock::actuallyUpdateDayNightDiff()
 
 void MapBlock::expireDayNightDiff()
 {
-	//INodeDefManager *nodemgr = m_gamedef->ndef();
-
-	if(data == NULL){
+	if (!data) {
 		m_day_night_differs = false;
 		m_day_night_differs_expired = false;
 		return;
@@ -554,10 +534,8 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk)
 	if(!ser_ver_supported(version))
 		throw VersionMismatchException("ERROR: MapBlock format not supported");
 
-	if(data == NULL)
-	{
+	if (!data)
 		throw SerializationError("ERROR: Not writing dummy block.");
-	}
 
 	FATAL_ERROR_IF(version < SER_FMT_VER_LOWEST_WRITE, "Serialisation version error");
 

+ 18 - 75
src/mapblock.h

@@ -42,63 +42,6 @@ class VoxelManipulator;
 
 #define BLOCK_TIMESTAMP_UNDEFINED 0xffffffff
 
-/*// Named by looking towards z+
-enum{
-	FACE_BACK=0,
-	FACE_TOP,
-	FACE_RIGHT,
-	FACE_FRONT,
-	FACE_BOTTOM,
-	FACE_LEFT
-};*/
-
-// NOTE: If this is enabled, set MapBlock to be initialized with
-//       CONTENT_IGNORE.
-/*enum BlockGenerationStatus
-{
-	// Completely non-generated (filled with CONTENT_IGNORE).
-	BLOCKGEN_UNTOUCHED=0,
-	// Trees or similar might have been blitted from other blocks to here.
-	// Otherwise, the block contains CONTENT_IGNORE
-	BLOCKGEN_FROM_NEIGHBORS=2,
-	// Has been generated, but some neighbors might put some stuff in here
-	// when they are generated.
-	// Does not contain any CONTENT_IGNORE
-	BLOCKGEN_SELF_GENERATED=4,
-	// The block and all its neighbors have been generated
-	BLOCKGEN_FULLY_GENERATED=6
-};*/
-
-#if 0
-enum
-{
-	NODECONTAINER_ID_MAPBLOCK,
-	NODECONTAINER_ID_MAPSECTOR,
-	NODECONTAINER_ID_MAP,
-	NODECONTAINER_ID_MAPBLOCKCACHE,
-	NODECONTAINER_ID_VOXELMANIPULATOR,
-};
-
-class NodeContainer
-{
-public:
-	virtual bool isValidPosition(v3s16 p) = 0;
-	virtual MapNode getNode(v3s16 p) = 0;
-	virtual void setNode(v3s16 p, MapNode & n) = 0;
-	virtual u16 nodeContainerId() const = 0;
-
-	MapNode getNodeNoEx(v3s16 p)
-	{
-		try{
-			return getNode(p);
-		}
-		catch(InvalidPositionException &e){
-			return MapNode(CONTENT_IGNORE);
-		}
-	}
-};
-#endif
-
 ////
 //// MapBlock modified reason flags
 ////
@@ -128,7 +71,7 @@ public:
 //// MapBlock itself
 ////
 
-class MapBlock /*: public NodeContainer*/
+class MapBlock
 {
 public:
 	MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy=false);
@@ -198,7 +141,7 @@ public:
 
 	inline bool isDummy()
 	{
-		return (data == NULL);
+		return !data;
 	}
 
 	inline void unDummify()
@@ -298,7 +241,7 @@ public:
 
 	inline bool isValidPosition(s16 x, s16 y, s16 z)
 	{
-		return data != NULL
+		return data
 			&& x >= 0 && x < MAP_BLOCKSIZE
 			&& y >= 0 && y < MAP_BLOCKSIZE
 			&& z >= 0 && z < MAP_BLOCKSIZE;
@@ -350,7 +293,7 @@ public:
 
 	inline MapNode getNodeNoCheck(s16 x, s16 y, s16 z, bool *valid_position)
 	{
-		*valid_position = data != NULL;
+		*valid_position = data != nullptr;
 		if (!valid_position)
 			return MapNode(CONTENT_IGNORE);
 
@@ -380,7 +323,7 @@ public:
 
 	inline void setNodeNoCheck(s16 x, s16 y, s16 z, MapNode & n)
 	{
-		if (data == NULL)
+		if (!data)
 			throw InvalidPositionException();
 
 		data[z * zstride + y * ystride + x] = n;
@@ -579,7 +522,7 @@ public:
 	*/
 
 #ifndef SERVER // Only on client
-	MapBlockMesh *mesh;
+	MapBlockMesh *mesh = nullptr;
 #endif
 
 	NodeMetadataList m_node_metadata;
@@ -615,15 +558,15 @@ private:
 		If NULL, block is a dummy block.
 		Dummy blocks are used for caching not-found-on-disk blocks.
 	*/
-	MapNode *data;
+	MapNode *data = nullptr;
 
 	/*
 		- On the server, this is used for telling whether the
 		  block has been modified from the one on disk.
 		- On the client, this is used for nothing.
 	*/
-	u32 m_modified;
-	u32 m_modified_reason;
+	u32 m_modified = MOD_STATE_WRITE_NEEDED;
+	u32 m_modified_reason = MOD_REASON_INITIAL;
 
 	/*
 		When propagating sunlight and the above block doesn't exist,
@@ -633,7 +576,7 @@ private:
 		undeground with nothing visible above the ground except
 		caves.
 	*/
-	bool is_underground;
+	bool is_underground = false;
 
 	/*!
 	 * Each bit indicates if light spreading was finished
@@ -643,33 +586,33 @@ private:
 	 * night X-, night Y-, night Z-, night Z+, night Y+, night X+,
 	 * day X-,   day Y-,   day Z-,   day Z+,   day Y+,   day X+.
 	*/
-	u16 m_lighting_complete;
+	u16 m_lighting_complete = 0xFFFF;
 
 	// Whether day and night lighting differs
-	bool m_day_night_differs;
-	bool m_day_night_differs_expired;
+	bool m_day_night_differs = false;
+	bool m_day_night_differs_expired = true;
 
-	bool m_generated;
+	bool m_generated = false;
 
 	/*
 		When block is removed from active blocks, this is set to gametime.
 		Value BLOCK_TIMESTAMP_UNDEFINED=0xffffffff means there is no timestamp.
 	*/
-	u32 m_timestamp;
+	u32 m_timestamp = BLOCK_TIMESTAMP_UNDEFINED;
 	// The on-disk (or to-be on-disk) timestamp value
-	u32 m_disk_timestamp;
+	u32 m_disk_timestamp = BLOCK_TIMESTAMP_UNDEFINED;
 
 	/*
 		When the block is accessed, this is set to 0.
 		Map will unload the block when this reaches a timeout.
 	*/
-	float m_usage_timer;
+	float m_usage_timer = 0;
 
 	/*
 		Reference count; currently used for determining if this block is in
 		the list of blocks to be drawn.
 	*/
-	int m_refcount;
+	int m_refcount = 0;
 };
 
 typedef std::vector<MapBlock*> MapBlockVect;

+ 1 - 6
src/mapblock_mesh.cpp

@@ -38,11 +38,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 MeshMakeData::MeshMakeData(Client *client, bool use_shaders,
 		bool use_tangent_vertices):
-	m_vmanip(),
-	m_blockpos(-1337,-1337,-1337),
-	m_crack_pos_relative(-1337, -1337, -1337),
-	m_smooth_lighting(false),
-	m_show_hud(false),
 	m_client(client),
 	m_use_shaders(use_shaders),
 	m_use_tangent_vertices(use_tangent_vertices)
@@ -1073,7 +1068,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
 			const u16 indices[] = {0,1,2,2,3,0};
 			const u16 indices_alternate[] = {0,1,3,2,3,1};
 
-			if (f.layer.texture == NULL)
+			if (!f.layer.texture)
 				continue;
 
 			const u16 *indices_p =

+ 4 - 4
src/mapblock_mesh.h

@@ -39,10 +39,10 @@ struct MinimapMapblock;
 struct MeshMakeData
 {
 	VoxelManipulator m_vmanip;
-	v3s16 m_blockpos;
-	v3s16 m_crack_pos_relative;
-	bool m_smooth_lighting;
-	bool m_show_hud;
+	v3s16 m_blockpos = v3s16(-1337,-1337,-1337);
+	v3s16 m_crack_pos_relative = v3s16(-1337,-1337,-1337);
+	bool m_smooth_lighting = false;
+	bool m_show_hud = false;
 
 	Client *m_client;
 	bool m_use_shaders;

+ 0 - 18
src/mapgen.cpp

@@ -98,25 +98,12 @@ STATIC_ASSERT(
 
 Mapgen::Mapgen()
 {
-	generating   = false;
-	id           = -1;
-	seed         = 0;
-	water_level  = 0;
-	mapgen_limit = 0;
-	flags        = 0;
-
-	vm        = NULL;
-	ndef      = NULL;
-	biomegen  = NULL;
-	biomemap  = NULL;
-	heightmap = NULL;
 }
 
 
 Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
 	gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids)
 {
-	generating   = false;
 	id           = mapgenid;
 	water_level  = params->water_level;
 	mapgen_limit = params->mapgen_limit;
@@ -138,11 +125,7 @@ Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
 	*/
 	seed = (s32)params->seed;
 
-	vm        = NULL;
 	ndef      = emerge->ndef;
-	biomegen  = NULL;
-	biomemap  = NULL;
-	heightmap = NULL;
 }
 
 
@@ -929,7 +912,6 @@ void MapgenBasic::generateDungeons(s16 max_stone_y, MgStoneType stone_type)
 
 GenerateNotifier::GenerateNotifier()
 {
-	m_notify_on = 0;
 }
 
 

+ 28 - 44
src/mapgen.h

@@ -105,7 +105,7 @@ public:
 		bool peek_events=false);
 
 private:
-	u32 m_notify_on;
+	u32 m_notify_on = 0;
 	std::set<u32> *m_notify_on_deco_ids;
 	std::list<GenNotifyEvent> m_notify_events;
 };
@@ -122,37 +122,21 @@ enum MapgenType {
 };
 
 struct MapgenParams {
-	MapgenType mgtype;
-	s16 chunksize;
-	u64 seed;
-	s16 water_level;
-	s16 mapgen_limit;
-	u32 flags;
-
-	BiomeParams *bparams;
-
-	s16 mapgen_edge_min;
-	s16 mapgen_edge_max;
-
-	MapgenParams() :
-		mgtype(MAPGEN_DEFAULT),
-		chunksize(5),
-		seed(0),
-		water_level(1),
-		mapgen_limit(MAX_MAP_GENERATION_LIMIT),
-		flags(MG_CAVES | MG_LIGHT | MG_DECORATIONS),
-		bparams(NULL),
-
-		mapgen_edge_min(-MAX_MAP_GENERATION_LIMIT),
-		mapgen_edge_max(MAX_MAP_GENERATION_LIMIT),
-		m_sao_limit_min(-MAX_MAP_GENERATION_LIMIT * BS),
-		m_sao_limit_max(MAX_MAP_GENERATION_LIMIT * BS),
-		m_mapgen_edges_calculated(false)
-	{
-	}
-
+	MapgenParams() {}
 	virtual ~MapgenParams();
 
+	MapgenType mgtype = MAPGEN_DEFAULT;
+	s16 chunksize = 5;
+	u64 seed = 0;
+	s16 water_level = 1;
+	s16 mapgen_limit = MAX_MAP_GENERATION_LIMIT;
+	u32 flags = MG_CAVES | MG_LIGHT | MG_DECORATIONS;
+
+	BiomeParams *bparams = nullptr;
+
+	s16 mapgen_edge_min = -MAX_MAP_GENERATION_LIMIT;
+	s16 mapgen_edge_max = MAX_MAP_GENERATION_LIMIT;
+
 	virtual void readParams(const Settings *settings);
 	virtual void writeParams(Settings *settings) const;
 
@@ -162,9 +146,9 @@ struct MapgenParams {
 private:
 	void calcMapgenEdges();
 
-	float m_sao_limit_min;
-	float m_sao_limit_max;
-	bool m_mapgen_edges_calculated;
+	float m_sao_limit_min = -MAX_MAP_GENERATION_LIMIT * BS;
+	float m_sao_limit_max = MAX_MAP_GENERATION_LIMIT * BS;
+	bool m_mapgen_edges_calculated = false;
 };
 
 
@@ -179,22 +163,22 @@ private:
 */
 class Mapgen {
 public:
-	s32 seed;
-	int water_level;
-	int mapgen_limit;
-	u32 flags;
-	bool generating;
-	int id;
+	s32 seed = 0;
+	int water_level = 0;
+	int mapgen_limit = 0;
+	u32 flags = 0;
+	bool generating = false;
+	int id = -1;
 
-	MMVManip *vm;
-	INodeDefManager *ndef;
+	MMVManip *vm = nullptr;
+	INodeDefManager *ndef = nullptr;
 
 	u32 blockseed;
-	s16 *heightmap;
-	biome_t *biomemap;
+	s16 *heightmap = nullptr;
+	biome_t *biomemap = nullptr;
 	v3s16 csize;
 
-	BiomeGen *biomegen;
+	BiomeGen *biomegen = nullptr;
 	GenerateNotifier gennotify;
 
 	Mapgen();

+ 0 - 9
src/mapgen_flat.cpp

@@ -82,15 +82,6 @@ MapgenFlat::~MapgenFlat()
 
 MapgenFlatParams::MapgenFlatParams()
 {
-	spflags          = 0;
-	ground_level     = 8;
-	large_cave_depth = -33;
-	cave_width       = 0.09;
-	lake_threshold   = -0.45;
-	lake_steepness   = 48.0;
-	hill_threshold   = 0.45;
-	hill_steepness   = 64.0;
-
 	np_terrain      = NoiseParams(0, 1,   v3f(600, 600, 600), 7244,  5, 0.6, 2.0);
 	np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261,   3, 0.7, 2.0);
 	np_cave1        = NoiseParams(0, 12,  v3f(61,  61,  61),  52534, 3, 0.5, 2.0);

+ 8 - 8
src/mapgen_flat.h

@@ -33,14 +33,14 @@ extern FlagDesc flagdesc_mapgen_flat[];
 
 struct MapgenFlatParams : public MapgenParams
 {
-	u32 spflags;
-	s16 ground_level;
-	s16 large_cave_depth;
-	float cave_width;
-	float lake_threshold;
-	float lake_steepness;
-	float hill_threshold;
-	float hill_steepness;
+	u32 spflags = 0;
+	s16 ground_level = 8;
+	s16 large_cave_depth = -33;
+	float cave_width = 0.09f;
+	float lake_threshold = -0.45f;
+	float lake_steepness = 48.0f;
+	float hill_threshold = 0.45f;
+	float hill_steepness = 64.0f;
 	NoiseParams np_terrain;
 	NoiseParams np_filler_depth;
 	NoiseParams np_cave1;

+ 0 - 12
src/mapgen_fractal.cpp

@@ -82,18 +82,6 @@ MapgenFractal::~MapgenFractal()
 
 MapgenFractalParams::MapgenFractalParams()
 {
-	spflags    = 0;
-	cave_width = 0.09;
-	fractal    = 1;
-	iterations = 11;
-	scale      = v3f(4096.0, 1024.0, 4096.0);
-	offset     = v3f(1.79, 0.0, 0.0);
-	slice_w    = 0.0;
-	julia_x    = 0.33;
-	julia_y    = 0.33;
-	julia_z    = 0.33;
-	julia_w    = 0.33;
-
 	np_seabed       = NoiseParams(-14, 9,   v3f(600, 600, 600), 41900, 5, 0.6, 2.0);
 	np_filler_depth = NoiseParams(0,   1.2, v3f(150, 150, 150), 261,   3, 0.7, 2.0);
 	np_cave1        = NoiseParams(0,   12,  v3f(61,  61,  61),  52534, 3, 0.5, 2.0);

+ 11 - 11
src/mapgen_fractal.h

@@ -34,17 +34,17 @@ extern FlagDesc flagdesc_mapgen_fractal[];
 
 struct MapgenFractalParams : public MapgenParams
 {
-	u32 spflags;
-	float cave_width;
-	u16 fractal;
-	u16 iterations;
-	v3f scale;
-	v3f offset;
-	float slice_w;
-	float julia_x;
-	float julia_y;
-	float julia_z;
-	float julia_w;
+	u32 spflags = 0;
+	float cave_width = 0.09f;
+	u16 fractal = 1;
+	u16 iterations = 11;
+	v3f scale = v3f(4096.0, 1024.0, 4096.0);
+	v3f offset = v3f(1.79, 0.0, 0.0);
+	float slice_w = 0.0f;
+	float julia_x = 0.33f;
+	float julia_y = 0.33f;
+	float julia_z = 0.33f;
+	float julia_w = 0.33f;
 	NoiseParams np_seabed;
 	NoiseParams np_filler_depth;
 	NoiseParams np_cave1;

+ 0 - 6
src/mapgen_v5.cpp

@@ -80,12 +80,6 @@ MapgenV5::~MapgenV5()
 
 MapgenV5Params::MapgenV5Params()
 {
-	spflags          = MGV5_CAVERNS;
-	cave_width       = 0.125;
-	cavern_limit     = -256;
-	cavern_taper     = 256;
-	cavern_threshold = 0.7;
-
 	np_filler_depth = NoiseParams(0, 1,  v3f(150, 150, 150), 261,    4, 0.7,  2.0);
 	np_factor       = NoiseParams(0, 1,  v3f(250, 250, 250), 920381, 3, 0.45, 2.0);
 	np_height       = NoiseParams(0, 10, v3f(250, 250, 250), 84174,  4, 0.5,  2.0);

+ 5 - 5
src/mapgen_v5.h

@@ -34,11 +34,11 @@ extern FlagDesc flagdesc_mapgen_v5[];
 
 struct MapgenV5Params : public MapgenParams
 {
-	u32 spflags;
-	float cave_width;
-	s16 cavern_limit;
-	s16 cavern_taper;
-	float cavern_threshold;
+	u32 spflags = MGV5_CAVERNS;
+	float cave_width = 0.125f;
+	s16 cavern_limit = -256;
+	s16 cavern_taper = 256;
+	float cavern_threshold = 0.7f;
 
 	NoiseParams np_filler_depth;
 	NoiseParams np_factor;

+ 0 - 6
src/mapgen_v6.cpp

@@ -147,12 +147,6 @@ MapgenV6::~MapgenV6()
 
 MapgenV6Params::MapgenV6Params()
 {
-	spflags = MGV6_JUNGLES | MGV6_SNOWBIOMES | MGV6_TREES |
-		MGV6_BIOMEBLEND | MGV6_MUDFLOW;
-
-	freq_desert = 0.45;
-	freq_beach  = 0.15;
-
 	np_terrain_base   = NoiseParams(-4,   20.0, v3f(250.0, 250.0, 250.0), 82341,  5, 0.6,  2.0);
 	np_terrain_higher = NoiseParams(20,   16.0, v3f(500.0, 500.0, 500.0), 85039,  5, 0.6,  2.0);
 	np_steepness      = NoiseParams(0.85, 0.5,  v3f(125.0, 125.0, 125.0), -932,   5, 0.7,  2.0);

+ 4 - 3
src/mapgen_v6.h

@@ -56,9 +56,10 @@ enum BiomeV6Type
 
 
 struct MapgenV6Params : public MapgenParams {
-	u32 spflags;
-	float freq_desert;
-	float freq_beach;
+	u32 spflags = MGV6_JUNGLES | MGV6_SNOWBIOMES | MGV6_TREES |
+		MGV6_BIOMEBLEND | MGV6_MUDFLOW;
+	float freq_desert = 0.45f;
+	float freq_beach = 0.15f;
 	NoiseParams np_terrain_base;
 	NoiseParams np_terrain_higher;
 	NoiseParams np_steepness;

+ 0 - 10
src/mapgen_v7.cpp

@@ -122,16 +122,6 @@ MapgenV7::~MapgenV7()
 
 MapgenV7Params::MapgenV7Params()
 {
-	spflags             = MGV7_MOUNTAINS | MGV7_RIDGES | MGV7_CAVERNS;
-	cave_width          = 0.09;
-	float_mount_density = 0.6;
-	float_mount_height  = 128.0;
-	floatland_level     = 1280;
-	shadow_limit        = 1024;
-	cavern_limit        = -256;
-	cavern_taper        = 256;
-	cavern_threshold    = 0.7;
-
 	np_terrain_base      = NoiseParams(4,    70,   v3f(600,  600,  600),  82341, 5, 0.6,  2.0);
 	np_terrain_alt       = NoiseParams(4,    25,   v3f(600,  600,  600),  5934,  5, 0.6,  2.0);
 	np_terrain_persist   = NoiseParams(0.6,  0.1,  v3f(2000, 2000, 2000), 539,   3, 0.6,  2.0);

+ 9 - 9
src/mapgen_v7.h

@@ -35,15 +35,15 @@ extern FlagDesc flagdesc_mapgen_v7[];
 
 
 struct MapgenV7Params : public MapgenParams {
-	u32 spflags;
-	float cave_width;
-	float float_mount_density;
-	float float_mount_height;
-	s16 floatland_level;
-	s16 shadow_limit;
-	s16 cavern_limit;
-	s16 cavern_taper;
-	float cavern_threshold;
+	u32 spflags = MGV7_MOUNTAINS | MGV7_RIDGES | MGV7_CAVERNS;
+	float cave_width = 0.09f;
+	float float_mount_density = 0.6f;
+	float float_mount_height = 128.0f;
+	s16 floatland_level = 1280;
+	s16 shadow_limit = 1024;
+	s16 cavern_limit = -256;
+	s16 cavern_taper = 256;
+	float cavern_threshold = 0.7f;
 
 	NoiseParams np_terrain_base;
 	NoiseParams np_terrain_alt;

+ 0 - 10
src/mapgen_valleys.cpp

@@ -127,16 +127,6 @@ MapgenValleys::~MapgenValleys()
 
 MapgenValleysParams::MapgenValleysParams()
 {
-	spflags            = MGVALLEYS_HUMID_RIVERS | MGVALLEYS_ALT_CHILL;
-	altitude_chill     = 90; // The altitude at which temperature drops by 20C.
-	large_cave_depth   = -33;
-	lava_features      = 0;  // How often water will occur in caves.
-	massive_cave_depth = -256;  // highest altitude of massive caves
-	river_depth        = 4;  // How deep to carve river channels.
-	river_size         = 5;  // How wide to make rivers.
-	water_features     = 0;  // How often water will occur in caves.
-	cave_width         = 0.09;
-
 	np_cave1              = NoiseParams(0,     12,   v3f(61,   61,   61),   52534, 3, 0.5,   2.0);
 	np_cave2              = NoiseParams(0,     12,   v3f(67,   67,   67),   10325, 3, 0.5,   2.0);
 	np_filler_depth       = NoiseParams(0.f,   1.2f, v3f(256,  256,  256),  1605,  3, 0.5f,  2.f);

+ 9 - 9
src/mapgen_valleys.h

@@ -46,15 +46,15 @@ class BiomeGenOriginal;
 
 
 struct MapgenValleysParams : public MapgenParams {
-	u32 spflags;
-	s16 large_cave_depth;
-	s16 massive_cave_depth;
-	u16 altitude_chill;
-	u16 lava_features;
-	u16 river_depth;
-	u16 river_size;
-	u16 water_features;
-	float cave_width;
+	u32 spflags = MGVALLEYS_HUMID_RIVERS | MGVALLEYS_ALT_CHILL;
+	s16 large_cave_depth = -33;
+	s16 massive_cave_depth = -256; // highest altitude of massive caves
+	u16 altitude_chill = 90; // The altitude at which temperature drops by 20C.
+	u16 lava_features = 0; // How often water will occur in caves.
+	u16 river_depth = 4; // How deep to carve river channels.
+	u16 river_size = 5; // How wide to make rivers.
+	u16 water_features = 0; // How often water will occur in caves.
+	float cave_width = 0.09f;
 	NoiseParams np_cave1;
 	NoiseParams np_cave2;
 	NoiseParams np_filler_depth;

+ 6 - 8
src/mapsector.cpp

@@ -23,11 +23,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "serialization.h"
 
 MapSector::MapSector(Map *parent, v2s16 pos, IGameDef *gamedef):
-		differs_from_disk(false),
 		m_parent(parent),
 		m_pos(pos),
-		m_gamedef(gamedef),
-		m_block_cache(NULL)
+		m_gamedef(gamedef)
 {
 }
 
@@ -39,7 +37,7 @@ MapSector::~MapSector()
 void MapSector::deleteBlocks()
 {
 	// Clear cache
-	m_block_cache = NULL;
+	m_block_cache = nullptr;
 
 	// Delete all
 	for (std::unordered_map<s16, MapBlock*>::iterator i = m_blocks.begin();
@@ -55,13 +53,13 @@ MapBlock * MapSector::getBlockBuffered(s16 y)
 {
 	MapBlock *block;
 
-	if (m_block_cache != NULL && y == m_block_cache_y) {
+	if (m_block_cache && y == m_block_cache_y) {
 		return m_block_cache;
 	}
 
 	// If block doesn't exist, return NULL
 	std::unordered_map<s16, MapBlock*>::const_iterator n = m_blocks.find(y);
-	block = (n != m_blocks.end() ? n->second : NULL);
+	block = (n != m_blocks.end() ? n->second : nullptr);
 
 	// Cache the last result
 	m_block_cache_y = y;
@@ -100,7 +98,7 @@ void MapSector::insertBlock(MapBlock *block)
 	s16 block_y = block->getPos().Y;
 
 	MapBlock *block2 = getBlockBuffered(block_y);
-	if(block2 != NULL){
+	if (block2) {
 		throw AlreadyExistsException("Block already exists");
 	}
 
@@ -116,7 +114,7 @@ void MapSector::deleteBlock(MapBlock *block)
 	s16 block_y = block->getPos().Y;
 
 	// Clear from cache
-	m_block_cache = NULL;
+	m_block_cache = nullptr;
 
 	// Remove from container
 	m_blocks.erase(block_y);

+ 3 - 3
src/mapsector.h

@@ -66,7 +66,7 @@ public:
 	bool empty() const { return m_blocks.empty(); }
 
 	// Always false at the moment, because sector contains no metadata.
-	bool differs_from_disk;
+	bool differs_from_disk = false;
 
 protected:
 
@@ -80,8 +80,8 @@ protected:
 	IGameDef *m_gamedef;
 
 	// Last-used block is cached here for quicker access.
-	// Be sure to set this to NULL when the cached block is deleted
-	MapBlock *m_block_cache;
+	// Be sure to set this to nullptr when the cached block is deleted
+	MapBlock *m_block_cache = nullptr;
 	s16 m_block_cache_y;
 
 	/*

+ 1 - 2
src/network/clientpackethandler.cpp

@@ -683,8 +683,7 @@ void Client::handleCommand_Media(NetworkPacket* pkt)
 	if (num_files == 0)
 		return;
 
-	if (m_media_downloader == NULL ||
-			!m_media_downloader->isStarted()) {
+	if (!m_media_downloader || !m_media_downloader->isStarted()) {
 		const char *problem = m_media_downloader ?
 			"media has not been requested" :
 			"all media has been received already";